an5206.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Arnewsh 5206 ColdFire system emulation.
  3. *
  4. * Copyright (c) 2007 CodeSourcery.
  5. *
  6. * This code is licenced under the GPL
  7. */
  8. #include "hw.h"
  9. #include "mcf.h"
  10. #include "sysemu.h"
  11. #include "boards.h"
  12. #define KERNEL_LOAD_ADDR 0x10000
  13. #define AN5206_MBAR_ADDR 0x10000000
  14. #define AN5206_RAMBAR_ADDR 0x20000000
  15. /* Stub functions for hardware that doesn't exist. */
  16. void pic_info(void)
  17. {
  18. }
  19. void irq_info(void)
  20. {
  21. }
  22. /* Board init. */
  23. static void an5206_init(ram_addr_t ram_size, int vga_ram_size,
  24. const char *boot_device,
  25. const char *kernel_filename, const char *kernel_cmdline,
  26. const char *initrd_filename, const char *cpu_model)
  27. {
  28. CPUState *env;
  29. int kernel_size;
  30. uint64_t elf_entry;
  31. target_ulong entry;
  32. if (!cpu_model)
  33. cpu_model = "m5206";
  34. env = cpu_init(cpu_model);
  35. if (!env) {
  36. cpu_abort(env, "Unable to find m68k CPU definition\n");
  37. }
  38. /* Initialize CPU registers. */
  39. env->vbr = 0;
  40. /* TODO: allow changing MBAR and RAMBAR. */
  41. env->mbar = AN5206_MBAR_ADDR | 1;
  42. env->rambar0 = AN5206_RAMBAR_ADDR | 1;
  43. /* DRAM at address zero */
  44. cpu_register_physical_memory(0, ram_size,
  45. qemu_ram_alloc(ram_size) | IO_MEM_RAM);
  46. /* Internal SRAM. */
  47. cpu_register_physical_memory(AN5206_RAMBAR_ADDR, 512,
  48. qemu_ram_alloc(512) | IO_MEM_RAM);
  49. mcf5206_init(AN5206_MBAR_ADDR, env);
  50. /* Load kernel. */
  51. if (!kernel_filename) {
  52. fprintf(stderr, "Kernel image must be specified\n");
  53. exit(1);
  54. }
  55. kernel_size = load_elf(kernel_filename, 0, &elf_entry, NULL, NULL);
  56. entry = elf_entry;
  57. if (kernel_size < 0) {
  58. kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL);
  59. }
  60. if (kernel_size < 0) {
  61. kernel_size = load_image(kernel_filename,
  62. phys_ram_base + KERNEL_LOAD_ADDR);
  63. entry = KERNEL_LOAD_ADDR;
  64. }
  65. if (kernel_size < 0) {
  66. fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename);
  67. exit(1);
  68. }
  69. env->pc = entry;
  70. }
  71. QEMUMachine an5206_machine = {
  72. .name = "an5206",
  73. .desc = "Arnewsh 5206",
  74. .init = an5206_init,
  75. .ram_require = 512,
  76. };