2
0

sun4m.c 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602
  1. /*
  2. * QEMU Sun4m & Sun4d & Sun4c System Emulator
  3. *
  4. * Copyright (c) 2003-2005 Fabrice Bellard
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. * THE SOFTWARE.
  23. */
  24. #include "hw.h"
  25. #include "qemu-timer.h"
  26. #include "sun4m.h"
  27. #include "nvram.h"
  28. #include "sparc32_dma.h"
  29. #include "fdc.h"
  30. #include "sysemu.h"
  31. #include "net.h"
  32. #include "boards.h"
  33. #include "firmware_abi.h"
  34. #include "scsi.h"
  35. #include "pc.h"
  36. #include "isa.h"
  37. #include "fw_cfg.h"
  38. #include "escc.h"
  39. //#define DEBUG_IRQ
  40. /*
  41. * Sun4m architecture was used in the following machines:
  42. *
  43. * SPARCserver 6xxMP/xx
  44. * SPARCclassic (SPARCclassic Server)(SPARCstation LC) (4/15),
  45. * SPARCclassic X (4/10)
  46. * SPARCstation LX/ZX (4/30)
  47. * SPARCstation Voyager
  48. * SPARCstation 10/xx, SPARCserver 10/xx
  49. * SPARCstation 5, SPARCserver 5
  50. * SPARCstation 20/xx, SPARCserver 20
  51. * SPARCstation 4
  52. *
  53. * Sun4d architecture was used in the following machines:
  54. *
  55. * SPARCcenter 2000
  56. * SPARCserver 1000
  57. *
  58. * Sun4c architecture was used in the following machines:
  59. * SPARCstation 1/1+, SPARCserver 1/1+
  60. * SPARCstation SLC
  61. * SPARCstation IPC
  62. * SPARCstation ELC
  63. * SPARCstation IPX
  64. *
  65. * See for example: http://www.sunhelp.org/faq/sunref1.html
  66. */
  67. #ifdef DEBUG_IRQ
  68. #define DPRINTF(fmt, args...) \
  69. do { printf("CPUIRQ: " fmt , ##args); } while (0)
  70. #else
  71. #define DPRINTF(fmt, args...)
  72. #endif
  73. #define KERNEL_LOAD_ADDR 0x00004000
  74. #define CMDLINE_ADDR 0x007ff000
  75. #define INITRD_LOAD_ADDR 0x00800000
  76. #define PROM_SIZE_MAX (1024 * 1024)
  77. #define PROM_VADDR 0xffd00000
  78. #define PROM_FILENAME "openbios-sparc32"
  79. #define CFG_ADDR 0xd00000510ULL
  80. #define FW_CFG_SUN4M_DEPTH (FW_CFG_ARCH_LOCAL + 0x00)
  81. // Control plane, 8-bit and 24-bit planes
  82. #define TCX_SIZE (9 * 1024 * 1024)
  83. #define MAX_CPUS 16
  84. #define MAX_PILS 16
  85. #define ESCC_CLOCK 4915200
  86. struct sun4m_hwdef {
  87. target_phys_addr_t iommu_base, slavio_base;
  88. target_phys_addr_t intctl_base, counter_base, nvram_base, ms_kb_base;
  89. target_phys_addr_t serial_base, fd_base;
  90. target_phys_addr_t idreg_base, dma_base, esp_base, le_base;
  91. target_phys_addr_t tcx_base, cs_base, apc_base, aux1_base, aux2_base;
  92. target_phys_addr_t ecc_base;
  93. uint32_t ecc_version;
  94. long vram_size, nvram_size;
  95. // IRQ numbers are not PIL ones, but master interrupt controller
  96. // register bit numbers
  97. int esp_irq, le_irq, clock_irq, clock1_irq;
  98. int ser_irq, ms_kb_irq, fd_irq, me_irq, cs_irq, ecc_irq;
  99. uint8_t nvram_machine_id;
  100. uint16_t machine_id;
  101. uint32_t iommu_version;
  102. uint32_t intbit_to_level[32];
  103. uint64_t max_mem;
  104. const char * const default_cpu_model;
  105. };
  106. #define MAX_IOUNITS 5
  107. struct sun4d_hwdef {
  108. target_phys_addr_t iounit_bases[MAX_IOUNITS], slavio_base;
  109. target_phys_addr_t counter_base, nvram_base, ms_kb_base;
  110. target_phys_addr_t serial_base;
  111. target_phys_addr_t espdma_base, esp_base;
  112. target_phys_addr_t ledma_base, le_base;
  113. target_phys_addr_t tcx_base;
  114. target_phys_addr_t sbi_base;
  115. unsigned long vram_size, nvram_size;
  116. // IRQ numbers are not PIL ones, but SBI register bit numbers
  117. int esp_irq, le_irq, clock_irq, clock1_irq;
  118. int ser_irq, ms_kb_irq, me_irq;
  119. uint8_t nvram_machine_id;
  120. uint16_t machine_id;
  121. uint32_t iounit_version;
  122. uint64_t max_mem;
  123. const char * const default_cpu_model;
  124. };
  125. struct sun4c_hwdef {
  126. target_phys_addr_t iommu_base, slavio_base;
  127. target_phys_addr_t intctl_base, counter_base, nvram_base, ms_kb_base;
  128. target_phys_addr_t serial_base, fd_base;
  129. target_phys_addr_t idreg_base, dma_base, esp_base, le_base;
  130. target_phys_addr_t tcx_base, aux1_base;
  131. long vram_size, nvram_size;
  132. // IRQ numbers are not PIL ones, but master interrupt controller
  133. // register bit numbers
  134. int esp_irq, le_irq, clock_irq, clock1_irq;
  135. int ser_irq, ms_kb_irq, fd_irq, me_irq;
  136. uint8_t nvram_machine_id;
  137. uint16_t machine_id;
  138. uint32_t iommu_version;
  139. uint32_t intbit_to_level[32];
  140. uint64_t max_mem;
  141. const char * const default_cpu_model;
  142. };
  143. int DMA_get_channel_mode (int nchan)
  144. {
  145. return 0;
  146. }
  147. int DMA_read_memory (int nchan, void *buf, int pos, int size)
  148. {
  149. return 0;
  150. }
  151. int DMA_write_memory (int nchan, void *buf, int pos, int size)
  152. {
  153. return 0;
  154. }
  155. void DMA_hold_DREQ (int nchan) {}
  156. void DMA_release_DREQ (int nchan) {}
  157. void DMA_schedule(int nchan) {}
  158. void DMA_init (int high_page_enable) {}
  159. void DMA_register_channel (int nchan,
  160. DMA_transfer_handler transfer_handler,
  161. void *opaque)
  162. {
  163. }
  164. static int nvram_boot_set(void *opaque, const char *boot_device)
  165. {
  166. unsigned int i;
  167. uint8_t image[sizeof(ohwcfg_v3_t)];
  168. ohwcfg_v3_t *header = (ohwcfg_v3_t *)ℑ
  169. m48t59_t *nvram = (m48t59_t *)opaque;
  170. for (i = 0; i < sizeof(image); i++)
  171. image[i] = m48t59_read(nvram, i) & 0xff;
  172. pstrcpy((char *)header->boot_devices, sizeof(header->boot_devices),
  173. boot_device);
  174. header->nboot_devices = strlen(boot_device) & 0xff;
  175. header->crc = cpu_to_be16(OHW_compute_crc(header, 0x00, 0xF8));
  176. for (i = 0; i < sizeof(image); i++)
  177. m48t59_write(nvram, i, image[i]);
  178. return 0;
  179. }
  180. static void nvram_init(m48t59_t *nvram, uint8_t *macaddr, const char *cmdline,
  181. const char *boot_devices, ram_addr_t RAM_size,
  182. uint32_t kernel_size,
  183. int width, int height, int depth,
  184. int nvram_machine_id, const char *arch)
  185. {
  186. unsigned int i;
  187. uint32_t start, end;
  188. uint8_t image[0x1ff0];
  189. ohwcfg_v3_t *header = (ohwcfg_v3_t *)&image;
  190. struct sparc_arch_cfg *sparc_header;
  191. struct OpenBIOS_nvpart_v1 *part_header;
  192. memset(image, '\0', sizeof(image));
  193. // Try to match PPC NVRAM
  194. pstrcpy((char *)header->struct_ident, sizeof(header->struct_ident),
  195. "QEMU_BIOS");
  196. header->struct_version = cpu_to_be32(3); /* structure v3 */
  197. header->nvram_size = cpu_to_be16(0x2000);
  198. header->nvram_arch_ptr = cpu_to_be16(sizeof(ohwcfg_v3_t));
  199. header->nvram_arch_size = cpu_to_be16(sizeof(struct sparc_arch_cfg));
  200. pstrcpy((char *)header->arch, sizeof(header->arch), arch);
  201. header->nb_cpus = smp_cpus & 0xff;
  202. header->RAM0_base = 0;
  203. header->RAM0_size = cpu_to_be64((uint64_t)RAM_size);
  204. pstrcpy((char *)header->boot_devices, sizeof(header->boot_devices),
  205. boot_devices);
  206. header->nboot_devices = strlen(boot_devices) & 0xff;
  207. header->kernel_image = cpu_to_be64((uint64_t)KERNEL_LOAD_ADDR);
  208. header->kernel_size = cpu_to_be64((uint64_t)kernel_size);
  209. if (cmdline) {
  210. pstrcpy_targphys(CMDLINE_ADDR, TARGET_PAGE_SIZE, cmdline);
  211. header->cmdline = cpu_to_be64((uint64_t)CMDLINE_ADDR);
  212. header->cmdline_size = cpu_to_be64((uint64_t)strlen(cmdline));
  213. }
  214. // XXX add initrd_image, initrd_size
  215. header->width = cpu_to_be16(width);
  216. header->height = cpu_to_be16(height);
  217. header->depth = cpu_to_be16(depth);
  218. if (nographic)
  219. header->graphic_flags = cpu_to_be16(OHW_GF_NOGRAPHICS);
  220. header->crc = cpu_to_be16(OHW_compute_crc(header, 0x00, 0xF8));
  221. // Architecture specific header
  222. start = sizeof(ohwcfg_v3_t);
  223. sparc_header = (struct sparc_arch_cfg *)&image[start];
  224. sparc_header->valid = 0;
  225. start += sizeof(struct sparc_arch_cfg);
  226. // OpenBIOS nvram variables
  227. // Variable partition
  228. part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
  229. part_header->signature = OPENBIOS_PART_SYSTEM;
  230. pstrcpy(part_header->name, sizeof(part_header->name), "system");
  231. end = start + sizeof(struct OpenBIOS_nvpart_v1);
  232. for (i = 0; i < nb_prom_envs; i++)
  233. end = OpenBIOS_set_var(image, end, prom_envs[i]);
  234. // End marker
  235. image[end++] = '\0';
  236. end = start + ((end - start + 15) & ~15);
  237. OpenBIOS_finish_partition(part_header, end - start);
  238. // free partition
  239. start = end;
  240. part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
  241. part_header->signature = OPENBIOS_PART_FREE;
  242. pstrcpy(part_header->name, sizeof(part_header->name), "free");
  243. end = 0x1fd0;
  244. OpenBIOS_finish_partition(part_header, end - start);
  245. Sun_init_header((struct Sun_nvram *)&image[0x1fd8], macaddr,
  246. nvram_machine_id);
  247. for (i = 0; i < sizeof(image); i++)
  248. m48t59_write(nvram, i, image[i]);
  249. qemu_register_boot_set(nvram_boot_set, nvram);
  250. }
  251. static void *slavio_intctl;
  252. void pic_info(void)
  253. {
  254. if (slavio_intctl)
  255. slavio_pic_info(slavio_intctl);
  256. }
  257. void irq_info(void)
  258. {
  259. if (slavio_intctl)
  260. slavio_irq_info(slavio_intctl);
  261. }
  262. void cpu_check_irqs(CPUState *env)
  263. {
  264. if (env->pil_in && (env->interrupt_index == 0 ||
  265. (env->interrupt_index & ~15) == TT_EXTINT)) {
  266. unsigned int i;
  267. for (i = 15; i > 0; i--) {
  268. if (env->pil_in & (1 << i)) {
  269. int old_interrupt = env->interrupt_index;
  270. env->interrupt_index = TT_EXTINT | i;
  271. if (old_interrupt != env->interrupt_index) {
  272. DPRINTF("Set CPU IRQ %d\n", i);
  273. cpu_interrupt(env, CPU_INTERRUPT_HARD);
  274. }
  275. break;
  276. }
  277. }
  278. } else if (!env->pil_in && (env->interrupt_index & ~15) == TT_EXTINT) {
  279. DPRINTF("Reset CPU IRQ %d\n", env->interrupt_index & 15);
  280. env->interrupt_index = 0;
  281. cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
  282. }
  283. }
  284. static void cpu_set_irq(void *opaque, int irq, int level)
  285. {
  286. CPUState *env = opaque;
  287. if (level) {
  288. DPRINTF("Raise CPU IRQ %d\n", irq);
  289. env->halted = 0;
  290. env->pil_in |= 1 << irq;
  291. cpu_check_irqs(env);
  292. } else {
  293. DPRINTF("Lower CPU IRQ %d\n", irq);
  294. env->pil_in &= ~(1 << irq);
  295. cpu_check_irqs(env);
  296. }
  297. }
  298. static void dummy_cpu_set_irq(void *opaque, int irq, int level)
  299. {
  300. }
  301. static void *slavio_misc;
  302. void qemu_system_powerdown(void)
  303. {
  304. slavio_set_power_fail(slavio_misc, 1);
  305. }
  306. static void main_cpu_reset(void *opaque)
  307. {
  308. CPUState *env = opaque;
  309. cpu_reset(env);
  310. env->halted = 0;
  311. }
  312. static void secondary_cpu_reset(void *opaque)
  313. {
  314. CPUState *env = opaque;
  315. cpu_reset(env);
  316. env->halted = 1;
  317. }
  318. static void cpu_halt_signal(void *opaque, int irq, int level)
  319. {
  320. if (level && cpu_single_env)
  321. cpu_interrupt(cpu_single_env, CPU_INTERRUPT_HALT);
  322. }
  323. static unsigned long sun4m_load_kernel(const char *kernel_filename,
  324. const char *initrd_filename,
  325. ram_addr_t RAM_size)
  326. {
  327. int linux_boot;
  328. unsigned int i;
  329. long initrd_size, kernel_size;
  330. linux_boot = (kernel_filename != NULL);
  331. kernel_size = 0;
  332. if (linux_boot) {
  333. kernel_size = load_elf(kernel_filename, -0xf0000000ULL, NULL, NULL,
  334. NULL);
  335. if (kernel_size < 0)
  336. kernel_size = load_aout(kernel_filename, KERNEL_LOAD_ADDR,
  337. RAM_size - KERNEL_LOAD_ADDR);
  338. if (kernel_size < 0)
  339. kernel_size = load_image_targphys(kernel_filename,
  340. KERNEL_LOAD_ADDR,
  341. RAM_size - KERNEL_LOAD_ADDR);
  342. if (kernel_size < 0) {
  343. fprintf(stderr, "qemu: could not load kernel '%s'\n",
  344. kernel_filename);
  345. exit(1);
  346. }
  347. /* load initrd */
  348. initrd_size = 0;
  349. if (initrd_filename) {
  350. initrd_size = load_image_targphys(initrd_filename,
  351. INITRD_LOAD_ADDR,
  352. RAM_size - INITRD_LOAD_ADDR);
  353. if (initrd_size < 0) {
  354. fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
  355. initrd_filename);
  356. exit(1);
  357. }
  358. }
  359. if (initrd_size > 0) {
  360. for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) {
  361. if (ldl_phys(KERNEL_LOAD_ADDR + i) == 0x48647253) { // HdrS
  362. stl_phys(KERNEL_LOAD_ADDR + i + 16, INITRD_LOAD_ADDR);
  363. stl_phys(KERNEL_LOAD_ADDR + i + 20, initrd_size);
  364. break;
  365. }
  366. }
  367. }
  368. }
  369. return kernel_size;
  370. }
  371. static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
  372. const char *boot_device,
  373. const char *kernel_filename,
  374. const char *kernel_cmdline,
  375. const char *initrd_filename, const char *cpu_model)
  376. {
  377. CPUState *env, *envs[MAX_CPUS];
  378. unsigned int i;
  379. void *iommu, *espdma, *ledma, *main_esp, *nvram;
  380. qemu_irq *cpu_irqs[MAX_CPUS], *slavio_irq, *slavio_cpu_irq,
  381. *espdma_irq, *ledma_irq;
  382. qemu_irq *esp_reset, *le_reset;
  383. qemu_irq *fdc_tc;
  384. qemu_irq *cpu_halt;
  385. ram_addr_t ram_offset, prom_offset, tcx_offset, idreg_offset;
  386. unsigned long kernel_size;
  387. int ret;
  388. char buf[1024];
  389. BlockDriverState *fd[MAX_FD];
  390. int drive_index;
  391. void *fw_cfg;
  392. /* init CPUs */
  393. if (!cpu_model)
  394. cpu_model = hwdef->default_cpu_model;
  395. for(i = 0; i < smp_cpus; i++) {
  396. env = cpu_init(cpu_model);
  397. if (!env) {
  398. fprintf(stderr, "qemu: Unable to find Sparc CPU definition\n");
  399. exit(1);
  400. }
  401. cpu_sparc_set_id(env, i);
  402. envs[i] = env;
  403. if (i == 0) {
  404. qemu_register_reset(main_cpu_reset, env);
  405. } else {
  406. qemu_register_reset(secondary_cpu_reset, env);
  407. env->halted = 1;
  408. }
  409. cpu_irqs[i] = qemu_allocate_irqs(cpu_set_irq, envs[i], MAX_PILS);
  410. env->prom_addr = hwdef->slavio_base;
  411. }
  412. for (i = smp_cpus; i < MAX_CPUS; i++)
  413. cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS);
  414. /* allocate RAM */
  415. if ((uint64_t)RAM_size > hwdef->max_mem) {
  416. fprintf(stderr,
  417. "qemu: Too much memory for this machine: %d, maximum %d\n",
  418. (unsigned int)(RAM_size / (1024 * 1024)),
  419. (unsigned int)(hwdef->max_mem / (1024 * 1024)));
  420. exit(1);
  421. }
  422. ram_offset = qemu_ram_alloc(RAM_size);
  423. cpu_register_physical_memory(0, RAM_size, ram_offset);
  424. /* load boot prom */
  425. prom_offset = qemu_ram_alloc(PROM_SIZE_MAX);
  426. cpu_register_physical_memory(hwdef->slavio_base,
  427. (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) &
  428. TARGET_PAGE_MASK,
  429. prom_offset | IO_MEM_ROM);
  430. if (bios_name == NULL)
  431. bios_name = PROM_FILENAME;
  432. snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
  433. ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL);
  434. if (ret < 0 || ret > PROM_SIZE_MAX)
  435. ret = load_image_targphys(buf, hwdef->slavio_base, PROM_SIZE_MAX);
  436. if (ret < 0 || ret > PROM_SIZE_MAX) {
  437. fprintf(stderr, "qemu: could not load prom '%s'\n",
  438. buf);
  439. exit(1);
  440. }
  441. /* set up devices */
  442. slavio_intctl = slavio_intctl_init(hwdef->intctl_base,
  443. hwdef->intctl_base + 0x10000ULL,
  444. &hwdef->intbit_to_level[0],
  445. &slavio_irq, &slavio_cpu_irq,
  446. cpu_irqs,
  447. hwdef->clock_irq);
  448. if (hwdef->idreg_base) {
  449. static const uint8_t idreg_data[] = { 0xfe, 0x81, 0x01, 0x03 };
  450. idreg_offset = qemu_ram_alloc(sizeof(idreg_data));
  451. cpu_register_physical_memory(hwdef->idreg_base, sizeof(idreg_data),
  452. idreg_offset | IO_MEM_ROM);
  453. cpu_physical_memory_write_rom(hwdef->idreg_base, idreg_data,
  454. sizeof(idreg_data));
  455. }
  456. iommu = iommu_init(hwdef->iommu_base, hwdef->iommu_version,
  457. slavio_irq[hwdef->me_irq]);
  458. espdma = sparc32_dma_init(hwdef->dma_base, slavio_irq[hwdef->esp_irq],
  459. iommu, &espdma_irq, &esp_reset);
  460. ledma = sparc32_dma_init(hwdef->dma_base + 16ULL,
  461. slavio_irq[hwdef->le_irq], iommu, &ledma_irq,
  462. &le_reset);
  463. if (graphic_depth != 8 && graphic_depth != 24) {
  464. fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
  465. exit (1);
  466. }
  467. tcx_offset = qemu_ram_alloc(hwdef->vram_size);
  468. tcx_init(hwdef->tcx_base, phys_ram_base + tcx_offset, tcx_offset,
  469. hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
  470. lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
  471. nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0,
  472. hwdef->nvram_size, 8);
  473. slavio_timer_init_all(hwdef->counter_base, slavio_irq[hwdef->clock1_irq],
  474. slavio_cpu_irq, smp_cpus);
  475. slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[hwdef->ms_kb_irq],
  476. nographic, ESCC_CLOCK, 1);
  477. // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
  478. // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
  479. escc_init(hwdef->serial_base, slavio_irq[hwdef->ser_irq], slavio_irq[hwdef->ser_irq],
  480. serial_hds[0], serial_hds[1], ESCC_CLOCK, 1);
  481. cpu_halt = qemu_allocate_irqs(cpu_halt_signal, NULL, 1);
  482. slavio_misc = slavio_misc_init(hwdef->slavio_base, hwdef->apc_base,
  483. hwdef->aux1_base, hwdef->aux2_base,
  484. slavio_irq[hwdef->me_irq], cpu_halt[0],
  485. &fdc_tc);
  486. if (hwdef->fd_base) {
  487. /* there is zero or one floppy drive */
  488. memset(fd, 0, sizeof(fd));
  489. drive_index = drive_get_index(IF_FLOPPY, 0, 0);
  490. if (drive_index != -1)
  491. fd[0] = drives_table[drive_index].bdrv;
  492. sun4m_fdctrl_init(slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd,
  493. fdc_tc);
  494. }
  495. if (drive_get_max_bus(IF_SCSI) > 0) {
  496. fprintf(stderr, "qemu: too many SCSI bus\n");
  497. exit(1);
  498. }
  499. main_esp = esp_init(hwdef->esp_base, 2,
  500. espdma_memory_read, espdma_memory_write,
  501. espdma, *espdma_irq, esp_reset);
  502. for (i = 0; i < ESP_MAX_DEVS; i++) {
  503. drive_index = drive_get_index(IF_SCSI, 0, i);
  504. if (drive_index == -1)
  505. continue;
  506. esp_scsi_attach(main_esp, drives_table[drive_index].bdrv, i);
  507. }
  508. if (hwdef->cs_base)
  509. cs_init(hwdef->cs_base, hwdef->cs_irq, slavio_intctl);
  510. kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename,
  511. RAM_size);
  512. nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
  513. boot_device, RAM_size, kernel_size, graphic_width,
  514. graphic_height, graphic_depth, hwdef->nvram_machine_id,
  515. "Sun4m");
  516. if (hwdef->ecc_base)
  517. ecc_init(hwdef->ecc_base, slavio_irq[hwdef->ecc_irq],
  518. hwdef->ecc_version);
  519. fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
  520. fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
  521. fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
  522. fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id);
  523. fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, graphic_depth);
  524. }
  525. enum {
  526. ss2_id = 0,
  527. ss5_id = 32,
  528. vger_id,
  529. lx_id,
  530. ss4_id,
  531. scls_id,
  532. sbook_id,
  533. ss10_id = 64,
  534. ss20_id,
  535. ss600mp_id,
  536. ss1000_id = 96,
  537. ss2000_id,
  538. };
  539. static const struct sun4m_hwdef sun4m_hwdefs[] = {
  540. /* SS-5 */
  541. {
  542. .iommu_base = 0x10000000,
  543. .tcx_base = 0x50000000,
  544. .cs_base = 0x6c000000,
  545. .slavio_base = 0x70000000,
  546. .ms_kb_base = 0x71000000,
  547. .serial_base = 0x71100000,
  548. .nvram_base = 0x71200000,
  549. .fd_base = 0x71400000,
  550. .counter_base = 0x71d00000,
  551. .intctl_base = 0x71e00000,
  552. .idreg_base = 0x78000000,
  553. .dma_base = 0x78400000,
  554. .esp_base = 0x78800000,
  555. .le_base = 0x78c00000,
  556. .apc_base = 0x6a000000,
  557. .aux1_base = 0x71900000,
  558. .aux2_base = 0x71910000,
  559. .vram_size = 0x00100000,
  560. .nvram_size = 0x2000,
  561. .esp_irq = 18,
  562. .le_irq = 16,
  563. .clock_irq = 7,
  564. .clock1_irq = 19,
  565. .ms_kb_irq = 14,
  566. .ser_irq = 15,
  567. .fd_irq = 22,
  568. .me_irq = 30,
  569. .cs_irq = 5,
  570. .nvram_machine_id = 0x80,
  571. .machine_id = ss5_id,
  572. .iommu_version = 0x05000000,
  573. .intbit_to_level = {
  574. 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
  575. 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
  576. },
  577. .max_mem = 0x10000000,
  578. .default_cpu_model = "Fujitsu MB86904",
  579. },
  580. /* SS-10 */
  581. {
  582. .iommu_base = 0xfe0000000ULL,
  583. .tcx_base = 0xe20000000ULL,
  584. .slavio_base = 0xff0000000ULL,
  585. .ms_kb_base = 0xff1000000ULL,
  586. .serial_base = 0xff1100000ULL,
  587. .nvram_base = 0xff1200000ULL,
  588. .fd_base = 0xff1700000ULL,
  589. .counter_base = 0xff1300000ULL,
  590. .intctl_base = 0xff1400000ULL,
  591. .idreg_base = 0xef0000000ULL,
  592. .dma_base = 0xef0400000ULL,
  593. .esp_base = 0xef0800000ULL,
  594. .le_base = 0xef0c00000ULL,
  595. .apc_base = 0xefa000000ULL, // XXX should not exist
  596. .aux1_base = 0xff1800000ULL,
  597. .aux2_base = 0xff1a01000ULL,
  598. .ecc_base = 0xf00000000ULL,
  599. .ecc_version = 0x10000000, // version 0, implementation 1
  600. .vram_size = 0x00100000,
  601. .nvram_size = 0x2000,
  602. .esp_irq = 18,
  603. .le_irq = 16,
  604. .clock_irq = 7,
  605. .clock1_irq = 19,
  606. .ms_kb_irq = 14,
  607. .ser_irq = 15,
  608. .fd_irq = 22,
  609. .me_irq = 30,
  610. .ecc_irq = 28,
  611. .nvram_machine_id = 0x72,
  612. .machine_id = ss10_id,
  613. .iommu_version = 0x03000000,
  614. .intbit_to_level = {
  615. 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
  616. 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
  617. },
  618. .max_mem = 0xf00000000ULL,
  619. .default_cpu_model = "TI SuperSparc II",
  620. },
  621. /* SS-600MP */
  622. {
  623. .iommu_base = 0xfe0000000ULL,
  624. .tcx_base = 0xe20000000ULL,
  625. .slavio_base = 0xff0000000ULL,
  626. .ms_kb_base = 0xff1000000ULL,
  627. .serial_base = 0xff1100000ULL,
  628. .nvram_base = 0xff1200000ULL,
  629. .counter_base = 0xff1300000ULL,
  630. .intctl_base = 0xff1400000ULL,
  631. .dma_base = 0xef0081000ULL,
  632. .esp_base = 0xef0080000ULL,
  633. .le_base = 0xef0060000ULL,
  634. .apc_base = 0xefa000000ULL, // XXX should not exist
  635. .aux1_base = 0xff1800000ULL,
  636. .aux2_base = 0xff1a01000ULL, // XXX should not exist
  637. .ecc_base = 0xf00000000ULL,
  638. .ecc_version = 0x00000000, // version 0, implementation 0
  639. .vram_size = 0x00100000,
  640. .nvram_size = 0x2000,
  641. .esp_irq = 18,
  642. .le_irq = 16,
  643. .clock_irq = 7,
  644. .clock1_irq = 19,
  645. .ms_kb_irq = 14,
  646. .ser_irq = 15,
  647. .fd_irq = 22,
  648. .me_irq = 30,
  649. .ecc_irq = 28,
  650. .nvram_machine_id = 0x71,
  651. .machine_id = ss600mp_id,
  652. .iommu_version = 0x01000000,
  653. .intbit_to_level = {
  654. 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
  655. 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
  656. },
  657. .max_mem = 0xf00000000ULL,
  658. .default_cpu_model = "TI SuperSparc II",
  659. },
  660. /* SS-20 */
  661. {
  662. .iommu_base = 0xfe0000000ULL,
  663. .tcx_base = 0xe20000000ULL,
  664. .slavio_base = 0xff0000000ULL,
  665. .ms_kb_base = 0xff1000000ULL,
  666. .serial_base = 0xff1100000ULL,
  667. .nvram_base = 0xff1200000ULL,
  668. .fd_base = 0xff1700000ULL,
  669. .counter_base = 0xff1300000ULL,
  670. .intctl_base = 0xff1400000ULL,
  671. .idreg_base = 0xef0000000ULL,
  672. .dma_base = 0xef0400000ULL,
  673. .esp_base = 0xef0800000ULL,
  674. .le_base = 0xef0c00000ULL,
  675. .apc_base = 0xefa000000ULL, // XXX should not exist
  676. .aux1_base = 0xff1800000ULL,
  677. .aux2_base = 0xff1a01000ULL,
  678. .ecc_base = 0xf00000000ULL,
  679. .ecc_version = 0x20000000, // version 0, implementation 2
  680. .vram_size = 0x00100000,
  681. .nvram_size = 0x2000,
  682. .esp_irq = 18,
  683. .le_irq = 16,
  684. .clock_irq = 7,
  685. .clock1_irq = 19,
  686. .ms_kb_irq = 14,
  687. .ser_irq = 15,
  688. .fd_irq = 22,
  689. .me_irq = 30,
  690. .ecc_irq = 28,
  691. .nvram_machine_id = 0x72,
  692. .machine_id = ss20_id,
  693. .iommu_version = 0x13000000,
  694. .intbit_to_level = {
  695. 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
  696. 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
  697. },
  698. .max_mem = 0xf00000000ULL,
  699. .default_cpu_model = "TI SuperSparc II",
  700. },
  701. /* Voyager */
  702. {
  703. .iommu_base = 0x10000000,
  704. .tcx_base = 0x50000000,
  705. .slavio_base = 0x70000000,
  706. .ms_kb_base = 0x71000000,
  707. .serial_base = 0x71100000,
  708. .nvram_base = 0x71200000,
  709. .fd_base = 0x71400000,
  710. .counter_base = 0x71d00000,
  711. .intctl_base = 0x71e00000,
  712. .idreg_base = 0x78000000,
  713. .dma_base = 0x78400000,
  714. .esp_base = 0x78800000,
  715. .le_base = 0x78c00000,
  716. .apc_base = 0x71300000, // pmc
  717. .aux1_base = 0x71900000,
  718. .aux2_base = 0x71910000,
  719. .vram_size = 0x00100000,
  720. .nvram_size = 0x2000,
  721. .esp_irq = 18,
  722. .le_irq = 16,
  723. .clock_irq = 7,
  724. .clock1_irq = 19,
  725. .ms_kb_irq = 14,
  726. .ser_irq = 15,
  727. .fd_irq = 22,
  728. .me_irq = 30,
  729. .nvram_machine_id = 0x80,
  730. .machine_id = vger_id,
  731. .iommu_version = 0x05000000,
  732. .intbit_to_level = {
  733. 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
  734. 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
  735. },
  736. .max_mem = 0x10000000,
  737. .default_cpu_model = "Fujitsu MB86904",
  738. },
  739. /* LX */
  740. {
  741. .iommu_base = 0x10000000,
  742. .tcx_base = 0x50000000,
  743. .slavio_base = 0x70000000,
  744. .ms_kb_base = 0x71000000,
  745. .serial_base = 0x71100000,
  746. .nvram_base = 0x71200000,
  747. .fd_base = 0x71400000,
  748. .counter_base = 0x71d00000,
  749. .intctl_base = 0x71e00000,
  750. .idreg_base = 0x78000000,
  751. .dma_base = 0x78400000,
  752. .esp_base = 0x78800000,
  753. .le_base = 0x78c00000,
  754. .aux1_base = 0x71900000,
  755. .aux2_base = 0x71910000,
  756. .vram_size = 0x00100000,
  757. .nvram_size = 0x2000,
  758. .esp_irq = 18,
  759. .le_irq = 16,
  760. .clock_irq = 7,
  761. .clock1_irq = 19,
  762. .ms_kb_irq = 14,
  763. .ser_irq = 15,
  764. .fd_irq = 22,
  765. .me_irq = 30,
  766. .nvram_machine_id = 0x80,
  767. .machine_id = lx_id,
  768. .iommu_version = 0x04000000,
  769. .intbit_to_level = {
  770. 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
  771. 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
  772. },
  773. .max_mem = 0x10000000,
  774. .default_cpu_model = "TI MicroSparc I",
  775. },
  776. /* SS-4 */
  777. {
  778. .iommu_base = 0x10000000,
  779. .tcx_base = 0x50000000,
  780. .cs_base = 0x6c000000,
  781. .slavio_base = 0x70000000,
  782. .ms_kb_base = 0x71000000,
  783. .serial_base = 0x71100000,
  784. .nvram_base = 0x71200000,
  785. .fd_base = 0x71400000,
  786. .counter_base = 0x71d00000,
  787. .intctl_base = 0x71e00000,
  788. .idreg_base = 0x78000000,
  789. .dma_base = 0x78400000,
  790. .esp_base = 0x78800000,
  791. .le_base = 0x78c00000,
  792. .apc_base = 0x6a000000,
  793. .aux1_base = 0x71900000,
  794. .aux2_base = 0x71910000,
  795. .vram_size = 0x00100000,
  796. .nvram_size = 0x2000,
  797. .esp_irq = 18,
  798. .le_irq = 16,
  799. .clock_irq = 7,
  800. .clock1_irq = 19,
  801. .ms_kb_irq = 14,
  802. .ser_irq = 15,
  803. .fd_irq = 22,
  804. .me_irq = 30,
  805. .cs_irq = 5,
  806. .nvram_machine_id = 0x80,
  807. .machine_id = ss4_id,
  808. .iommu_version = 0x05000000,
  809. .intbit_to_level = {
  810. 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
  811. 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
  812. },
  813. .max_mem = 0x10000000,
  814. .default_cpu_model = "Fujitsu MB86904",
  815. },
  816. /* SPARCClassic */
  817. {
  818. .iommu_base = 0x10000000,
  819. .tcx_base = 0x50000000,
  820. .slavio_base = 0x70000000,
  821. .ms_kb_base = 0x71000000,
  822. .serial_base = 0x71100000,
  823. .nvram_base = 0x71200000,
  824. .fd_base = 0x71400000,
  825. .counter_base = 0x71d00000,
  826. .intctl_base = 0x71e00000,
  827. .idreg_base = 0x78000000,
  828. .dma_base = 0x78400000,
  829. .esp_base = 0x78800000,
  830. .le_base = 0x78c00000,
  831. .apc_base = 0x6a000000,
  832. .aux1_base = 0x71900000,
  833. .aux2_base = 0x71910000,
  834. .vram_size = 0x00100000,
  835. .nvram_size = 0x2000,
  836. .esp_irq = 18,
  837. .le_irq = 16,
  838. .clock_irq = 7,
  839. .clock1_irq = 19,
  840. .ms_kb_irq = 14,
  841. .ser_irq = 15,
  842. .fd_irq = 22,
  843. .me_irq = 30,
  844. .nvram_machine_id = 0x80,
  845. .machine_id = scls_id,
  846. .iommu_version = 0x05000000,
  847. .intbit_to_level = {
  848. 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
  849. 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
  850. },
  851. .max_mem = 0x10000000,
  852. .default_cpu_model = "TI MicroSparc I",
  853. },
  854. /* SPARCbook */
  855. {
  856. .iommu_base = 0x10000000,
  857. .tcx_base = 0x50000000, // XXX
  858. .slavio_base = 0x70000000,
  859. .ms_kb_base = 0x71000000,
  860. .serial_base = 0x71100000,
  861. .nvram_base = 0x71200000,
  862. .fd_base = 0x71400000,
  863. .counter_base = 0x71d00000,
  864. .intctl_base = 0x71e00000,
  865. .idreg_base = 0x78000000,
  866. .dma_base = 0x78400000,
  867. .esp_base = 0x78800000,
  868. .le_base = 0x78c00000,
  869. .apc_base = 0x6a000000,
  870. .aux1_base = 0x71900000,
  871. .aux2_base = 0x71910000,
  872. .vram_size = 0x00100000,
  873. .nvram_size = 0x2000,
  874. .esp_irq = 18,
  875. .le_irq = 16,
  876. .clock_irq = 7,
  877. .clock1_irq = 19,
  878. .ms_kb_irq = 14,
  879. .ser_irq = 15,
  880. .fd_irq = 22,
  881. .me_irq = 30,
  882. .nvram_machine_id = 0x80,
  883. .machine_id = sbook_id,
  884. .iommu_version = 0x05000000,
  885. .intbit_to_level = {
  886. 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
  887. 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
  888. },
  889. .max_mem = 0x10000000,
  890. .default_cpu_model = "TI MicroSparc I",
  891. },
  892. };
  893. /* SPARCstation 5 hardware initialisation */
  894. static void ss5_init(ram_addr_t RAM_size, int vga_ram_size,
  895. const char *boot_device,
  896. const char *kernel_filename, const char *kernel_cmdline,
  897. const char *initrd_filename, const char *cpu_model)
  898. {
  899. sun4m_hw_init(&sun4m_hwdefs[0], RAM_size, boot_device, kernel_filename,
  900. kernel_cmdline, initrd_filename, cpu_model);
  901. }
  902. /* SPARCstation 10 hardware initialisation */
  903. static void ss10_init(ram_addr_t RAM_size, int vga_ram_size,
  904. const char *boot_device,
  905. const char *kernel_filename, const char *kernel_cmdline,
  906. const char *initrd_filename, const char *cpu_model)
  907. {
  908. sun4m_hw_init(&sun4m_hwdefs[1], RAM_size, boot_device, kernel_filename,
  909. kernel_cmdline, initrd_filename, cpu_model);
  910. }
  911. /* SPARCserver 600MP hardware initialisation */
  912. static void ss600mp_init(ram_addr_t RAM_size, int vga_ram_size,
  913. const char *boot_device,
  914. const char *kernel_filename,
  915. const char *kernel_cmdline,
  916. const char *initrd_filename, const char *cpu_model)
  917. {
  918. sun4m_hw_init(&sun4m_hwdefs[2], RAM_size, boot_device, kernel_filename,
  919. kernel_cmdline, initrd_filename, cpu_model);
  920. }
  921. /* SPARCstation 20 hardware initialisation */
  922. static void ss20_init(ram_addr_t RAM_size, int vga_ram_size,
  923. const char *boot_device,
  924. const char *kernel_filename, const char *kernel_cmdline,
  925. const char *initrd_filename, const char *cpu_model)
  926. {
  927. sun4m_hw_init(&sun4m_hwdefs[3], RAM_size, boot_device, kernel_filename,
  928. kernel_cmdline, initrd_filename, cpu_model);
  929. }
  930. /* SPARCstation Voyager hardware initialisation */
  931. static void vger_init(ram_addr_t RAM_size, int vga_ram_size,
  932. const char *boot_device,
  933. const char *kernel_filename, const char *kernel_cmdline,
  934. const char *initrd_filename, const char *cpu_model)
  935. {
  936. sun4m_hw_init(&sun4m_hwdefs[4], RAM_size, boot_device, kernel_filename,
  937. kernel_cmdline, initrd_filename, cpu_model);
  938. }
  939. /* SPARCstation LX hardware initialisation */
  940. static void ss_lx_init(ram_addr_t RAM_size, int vga_ram_size,
  941. const char *boot_device,
  942. const char *kernel_filename, const char *kernel_cmdline,
  943. const char *initrd_filename, const char *cpu_model)
  944. {
  945. sun4m_hw_init(&sun4m_hwdefs[5], RAM_size, boot_device, kernel_filename,
  946. kernel_cmdline, initrd_filename, cpu_model);
  947. }
  948. /* SPARCstation 4 hardware initialisation */
  949. static void ss4_init(ram_addr_t RAM_size, int vga_ram_size,
  950. const char *boot_device,
  951. const char *kernel_filename, const char *kernel_cmdline,
  952. const char *initrd_filename, const char *cpu_model)
  953. {
  954. sun4m_hw_init(&sun4m_hwdefs[6], RAM_size, boot_device, kernel_filename,
  955. kernel_cmdline, initrd_filename, cpu_model);
  956. }
  957. /* SPARCClassic hardware initialisation */
  958. static void scls_init(ram_addr_t RAM_size, int vga_ram_size,
  959. const char *boot_device,
  960. const char *kernel_filename, const char *kernel_cmdline,
  961. const char *initrd_filename, const char *cpu_model)
  962. {
  963. sun4m_hw_init(&sun4m_hwdefs[7], RAM_size, boot_device, kernel_filename,
  964. kernel_cmdline, initrd_filename, cpu_model);
  965. }
  966. /* SPARCbook hardware initialisation */
  967. static void sbook_init(ram_addr_t RAM_size, int vga_ram_size,
  968. const char *boot_device,
  969. const char *kernel_filename, const char *kernel_cmdline,
  970. const char *initrd_filename, const char *cpu_model)
  971. {
  972. sun4m_hw_init(&sun4m_hwdefs[8], RAM_size, boot_device, kernel_filename,
  973. kernel_cmdline, initrd_filename, cpu_model);
  974. }
  975. QEMUMachine ss5_machine = {
  976. .name = "SS-5",
  977. .desc = "Sun4m platform, SPARCstation 5",
  978. .init = ss5_init,
  979. .ram_require = PROM_SIZE_MAX + TCX_SIZE,
  980. .nodisk_ok = 1,
  981. .use_scsi = 1,
  982. };
  983. QEMUMachine ss10_machine = {
  984. .name = "SS-10",
  985. .desc = "Sun4m platform, SPARCstation 10",
  986. .init = ss10_init,
  987. .ram_require = PROM_SIZE_MAX + TCX_SIZE,
  988. .nodisk_ok = 1,
  989. .use_scsi = 1,
  990. .max_cpus = 4,
  991. };
  992. QEMUMachine ss600mp_machine = {
  993. .name = "SS-600MP",
  994. .desc = "Sun4m platform, SPARCserver 600MP",
  995. .init = ss600mp_init,
  996. .ram_require = PROM_SIZE_MAX + TCX_SIZE,
  997. .nodisk_ok = 1,
  998. .use_scsi = 1,
  999. .max_cpus = 4,
  1000. };
  1001. QEMUMachine ss20_machine = {
  1002. .name = "SS-20",
  1003. .desc = "Sun4m platform, SPARCstation 20",
  1004. .init = ss20_init,
  1005. .ram_require = PROM_SIZE_MAX + TCX_SIZE,
  1006. .nodisk_ok = 1,
  1007. .use_scsi = 1,
  1008. .max_cpus = 4,
  1009. };
  1010. QEMUMachine voyager_machine = {
  1011. .name = "Voyager",
  1012. .desc = "Sun4m platform, SPARCstation Voyager",
  1013. .init = vger_init,
  1014. .ram_require = PROM_SIZE_MAX + TCX_SIZE,
  1015. .nodisk_ok = 1,
  1016. .use_scsi = 1,
  1017. };
  1018. QEMUMachine ss_lx_machine = {
  1019. .name = "LX",
  1020. .desc = "Sun4m platform, SPARCstation LX",
  1021. .init = ss_lx_init,
  1022. .ram_require = PROM_SIZE_MAX + TCX_SIZE,
  1023. .nodisk_ok = 1,
  1024. .use_scsi = 1,
  1025. };
  1026. QEMUMachine ss4_machine = {
  1027. .name = "SS-4",
  1028. .desc = "Sun4m platform, SPARCstation 4",
  1029. .init = ss4_init,
  1030. .ram_require = PROM_SIZE_MAX + TCX_SIZE,
  1031. .nodisk_ok = 1,
  1032. .use_scsi = 1,
  1033. };
  1034. QEMUMachine scls_machine = {
  1035. .name = "SPARCClassic",
  1036. .desc = "Sun4m platform, SPARCClassic",
  1037. .init = scls_init,
  1038. .ram_require = PROM_SIZE_MAX + TCX_SIZE,
  1039. .nodisk_ok = 1,
  1040. .use_scsi = 1,
  1041. };
  1042. QEMUMachine sbook_machine = {
  1043. .name = "SPARCbook",
  1044. .desc = "Sun4m platform, SPARCbook",
  1045. .init = sbook_init,
  1046. .ram_require = PROM_SIZE_MAX + TCX_SIZE,
  1047. .nodisk_ok = 1,
  1048. .use_scsi = 1,
  1049. };
  1050. static const struct sun4d_hwdef sun4d_hwdefs[] = {
  1051. /* SS-1000 */
  1052. {
  1053. .iounit_bases = {
  1054. 0xfe0200000ULL,
  1055. 0xfe1200000ULL,
  1056. 0xfe2200000ULL,
  1057. 0xfe3200000ULL,
  1058. -1,
  1059. },
  1060. .tcx_base = 0x820000000ULL,
  1061. .slavio_base = 0xf00000000ULL,
  1062. .ms_kb_base = 0xf00240000ULL,
  1063. .serial_base = 0xf00200000ULL,
  1064. .nvram_base = 0xf00280000ULL,
  1065. .counter_base = 0xf00300000ULL,
  1066. .espdma_base = 0x800081000ULL,
  1067. .esp_base = 0x800080000ULL,
  1068. .ledma_base = 0x800040000ULL,
  1069. .le_base = 0x800060000ULL,
  1070. .sbi_base = 0xf02800000ULL,
  1071. .vram_size = 0x00100000,
  1072. .nvram_size = 0x2000,
  1073. .esp_irq = 3,
  1074. .le_irq = 4,
  1075. .clock_irq = 14,
  1076. .clock1_irq = 10,
  1077. .ms_kb_irq = 12,
  1078. .ser_irq = 12,
  1079. .nvram_machine_id = 0x80,
  1080. .machine_id = ss1000_id,
  1081. .iounit_version = 0x03000000,
  1082. .max_mem = 0xf00000000ULL,
  1083. .default_cpu_model = "TI SuperSparc II",
  1084. },
  1085. /* SS-2000 */
  1086. {
  1087. .iounit_bases = {
  1088. 0xfe0200000ULL,
  1089. 0xfe1200000ULL,
  1090. 0xfe2200000ULL,
  1091. 0xfe3200000ULL,
  1092. 0xfe4200000ULL,
  1093. },
  1094. .tcx_base = 0x820000000ULL,
  1095. .slavio_base = 0xf00000000ULL,
  1096. .ms_kb_base = 0xf00240000ULL,
  1097. .serial_base = 0xf00200000ULL,
  1098. .nvram_base = 0xf00280000ULL,
  1099. .counter_base = 0xf00300000ULL,
  1100. .espdma_base = 0x800081000ULL,
  1101. .esp_base = 0x800080000ULL,
  1102. .ledma_base = 0x800040000ULL,
  1103. .le_base = 0x800060000ULL,
  1104. .sbi_base = 0xf02800000ULL,
  1105. .vram_size = 0x00100000,
  1106. .nvram_size = 0x2000,
  1107. .esp_irq = 3,
  1108. .le_irq = 4,
  1109. .clock_irq = 14,
  1110. .clock1_irq = 10,
  1111. .ms_kb_irq = 12,
  1112. .ser_irq = 12,
  1113. .nvram_machine_id = 0x80,
  1114. .machine_id = ss2000_id,
  1115. .iounit_version = 0x03000000,
  1116. .max_mem = 0xf00000000ULL,
  1117. .default_cpu_model = "TI SuperSparc II",
  1118. },
  1119. };
  1120. static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
  1121. const char *boot_device,
  1122. const char *kernel_filename,
  1123. const char *kernel_cmdline,
  1124. const char *initrd_filename, const char *cpu_model)
  1125. {
  1126. CPUState *env, *envs[MAX_CPUS];
  1127. unsigned int i;
  1128. void *iounits[MAX_IOUNITS], *espdma, *ledma, *main_esp, *nvram, *sbi;
  1129. qemu_irq *cpu_irqs[MAX_CPUS], *sbi_irq, *sbi_cpu_irq,
  1130. *espdma_irq, *ledma_irq;
  1131. qemu_irq *esp_reset, *le_reset;
  1132. ram_addr_t ram_offset, prom_offset, tcx_offset;
  1133. unsigned long kernel_size;
  1134. int ret;
  1135. char buf[1024];
  1136. int drive_index;
  1137. void *fw_cfg;
  1138. /* init CPUs */
  1139. if (!cpu_model)
  1140. cpu_model = hwdef->default_cpu_model;
  1141. for (i = 0; i < smp_cpus; i++) {
  1142. env = cpu_init(cpu_model);
  1143. if (!env) {
  1144. fprintf(stderr, "qemu: Unable to find Sparc CPU definition\n");
  1145. exit(1);
  1146. }
  1147. cpu_sparc_set_id(env, i);
  1148. envs[i] = env;
  1149. if (i == 0) {
  1150. qemu_register_reset(main_cpu_reset, env);
  1151. } else {
  1152. qemu_register_reset(secondary_cpu_reset, env);
  1153. env->halted = 1;
  1154. }
  1155. cpu_irqs[i] = qemu_allocate_irqs(cpu_set_irq, envs[i], MAX_PILS);
  1156. env->prom_addr = hwdef->slavio_base;
  1157. }
  1158. for (i = smp_cpus; i < MAX_CPUS; i++)
  1159. cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS);
  1160. /* allocate RAM */
  1161. if ((uint64_t)RAM_size > hwdef->max_mem) {
  1162. fprintf(stderr,
  1163. "qemu: Too much memory for this machine: %d, maximum %d\n",
  1164. (unsigned int)(RAM_size / (1024 * 1024)),
  1165. (unsigned int)(hwdef->max_mem / (1024 * 1024)));
  1166. exit(1);
  1167. }
  1168. ram_offset = qemu_ram_alloc(RAM_size);
  1169. cpu_register_physical_memory(0, RAM_size, ram_offset);
  1170. /* load boot prom */
  1171. prom_offset = qemu_ram_alloc(PROM_SIZE_MAX);
  1172. cpu_register_physical_memory(hwdef->slavio_base,
  1173. (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) &
  1174. TARGET_PAGE_MASK,
  1175. prom_offset | IO_MEM_ROM);
  1176. if (bios_name == NULL)
  1177. bios_name = PROM_FILENAME;
  1178. snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
  1179. ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL);
  1180. if (ret < 0 || ret > PROM_SIZE_MAX)
  1181. ret = load_image_targphys(buf, hwdef->slavio_base, PROM_SIZE_MAX);
  1182. if (ret < 0 || ret > PROM_SIZE_MAX) {
  1183. fprintf(stderr, "qemu: could not load prom '%s'\n",
  1184. buf);
  1185. exit(1);
  1186. }
  1187. /* set up devices */
  1188. sbi = sbi_init(hwdef->sbi_base, &sbi_irq, &sbi_cpu_irq, cpu_irqs);
  1189. for (i = 0; i < MAX_IOUNITS; i++)
  1190. if (hwdef->iounit_bases[i] != (target_phys_addr_t)-1)
  1191. iounits[i] = iommu_init(hwdef->iounit_bases[i],
  1192. hwdef->iounit_version,
  1193. sbi_irq[hwdef->me_irq]);
  1194. espdma = sparc32_dma_init(hwdef->espdma_base, sbi_irq[hwdef->esp_irq],
  1195. iounits[0], &espdma_irq, &esp_reset);
  1196. ledma = sparc32_dma_init(hwdef->ledma_base, sbi_irq[hwdef->le_irq],
  1197. iounits[0], &ledma_irq, &le_reset);
  1198. if (graphic_depth != 8 && graphic_depth != 24) {
  1199. fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
  1200. exit (1);
  1201. }
  1202. tcx_offset = qemu_ram_alloc(hwdef->vram_size);
  1203. tcx_init(hwdef->tcx_base, phys_ram_base + tcx_offset, tcx_offset,
  1204. hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
  1205. lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
  1206. nvram = m48t59_init(sbi_irq[0], hwdef->nvram_base, 0,
  1207. hwdef->nvram_size, 8);
  1208. slavio_timer_init_all(hwdef->counter_base, sbi_irq[hwdef->clock1_irq],
  1209. sbi_cpu_irq, smp_cpus);
  1210. slavio_serial_ms_kbd_init(hwdef->ms_kb_base, sbi_irq[hwdef->ms_kb_irq],
  1211. nographic, ESCC_CLOCK, 1);
  1212. // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
  1213. // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
  1214. escc_init(hwdef->serial_base, sbi_irq[hwdef->ser_irq], sbi_irq[hwdef->ser_irq],
  1215. serial_hds[0], serial_hds[1], ESCC_CLOCK, 1);
  1216. if (drive_get_max_bus(IF_SCSI) > 0) {
  1217. fprintf(stderr, "qemu: too many SCSI bus\n");
  1218. exit(1);
  1219. }
  1220. main_esp = esp_init(hwdef->esp_base, 2,
  1221. espdma_memory_read, espdma_memory_write,
  1222. espdma, *espdma_irq, esp_reset);
  1223. for (i = 0; i < ESP_MAX_DEVS; i++) {
  1224. drive_index = drive_get_index(IF_SCSI, 0, i);
  1225. if (drive_index == -1)
  1226. continue;
  1227. esp_scsi_attach(main_esp, drives_table[drive_index].bdrv, i);
  1228. }
  1229. kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename,
  1230. RAM_size);
  1231. nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
  1232. boot_device, RAM_size, kernel_size, graphic_width,
  1233. graphic_height, graphic_depth, hwdef->nvram_machine_id,
  1234. "Sun4d");
  1235. fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
  1236. fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
  1237. fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
  1238. fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id);
  1239. }
  1240. /* SPARCserver 1000 hardware initialisation */
  1241. static void ss1000_init(ram_addr_t RAM_size, int vga_ram_size,
  1242. const char *boot_device,
  1243. const char *kernel_filename, const char *kernel_cmdline,
  1244. const char *initrd_filename, const char *cpu_model)
  1245. {
  1246. sun4d_hw_init(&sun4d_hwdefs[0], RAM_size, boot_device, kernel_filename,
  1247. kernel_cmdline, initrd_filename, cpu_model);
  1248. }
  1249. /* SPARCcenter 2000 hardware initialisation */
  1250. static void ss2000_init(ram_addr_t RAM_size, int vga_ram_size,
  1251. const char *boot_device,
  1252. const char *kernel_filename, const char *kernel_cmdline,
  1253. const char *initrd_filename, const char *cpu_model)
  1254. {
  1255. sun4d_hw_init(&sun4d_hwdefs[1], RAM_size, boot_device, kernel_filename,
  1256. kernel_cmdline, initrd_filename, cpu_model);
  1257. }
  1258. QEMUMachine ss1000_machine = {
  1259. .name = "SS-1000",
  1260. .desc = "Sun4d platform, SPARCserver 1000",
  1261. .init = ss1000_init,
  1262. .ram_require = PROM_SIZE_MAX + TCX_SIZE,
  1263. .nodisk_ok = 1,
  1264. .use_scsi = 1,
  1265. .max_cpus = 8,
  1266. };
  1267. QEMUMachine ss2000_machine = {
  1268. .name = "SS-2000",
  1269. .desc = "Sun4d platform, SPARCcenter 2000",
  1270. .init = ss2000_init,
  1271. .ram_require = PROM_SIZE_MAX + TCX_SIZE,
  1272. .nodisk_ok = 1,
  1273. .use_scsi = 1,
  1274. .max_cpus = 20,
  1275. };
  1276. static const struct sun4c_hwdef sun4c_hwdefs[] = {
  1277. /* SS-2 */
  1278. {
  1279. .iommu_base = 0xf8000000,
  1280. .tcx_base = 0xfe000000,
  1281. .slavio_base = 0xf6000000,
  1282. .intctl_base = 0xf5000000,
  1283. .counter_base = 0xf3000000,
  1284. .ms_kb_base = 0xf0000000,
  1285. .serial_base = 0xf1000000,
  1286. .nvram_base = 0xf2000000,
  1287. .fd_base = 0xf7200000,
  1288. .dma_base = 0xf8400000,
  1289. .esp_base = 0xf8800000,
  1290. .le_base = 0xf8c00000,
  1291. .aux1_base = 0xf7400003,
  1292. .vram_size = 0x00100000,
  1293. .nvram_size = 0x800,
  1294. .esp_irq = 2,
  1295. .le_irq = 3,
  1296. .clock_irq = 5,
  1297. .clock1_irq = 7,
  1298. .ms_kb_irq = 1,
  1299. .ser_irq = 1,
  1300. .fd_irq = 1,
  1301. .me_irq = 1,
  1302. .nvram_machine_id = 0x55,
  1303. .machine_id = ss2_id,
  1304. .max_mem = 0x10000000,
  1305. .default_cpu_model = "Cypress CY7C601",
  1306. },
  1307. };
  1308. static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,
  1309. const char *boot_device,
  1310. const char *kernel_filename,
  1311. const char *kernel_cmdline,
  1312. const char *initrd_filename, const char *cpu_model)
  1313. {
  1314. CPUState *env;
  1315. unsigned int i;
  1316. void *iommu, *espdma, *ledma, *main_esp, *nvram;
  1317. qemu_irq *cpu_irqs, *slavio_irq, *espdma_irq, *ledma_irq;
  1318. qemu_irq *esp_reset, *le_reset;
  1319. qemu_irq *fdc_tc;
  1320. ram_addr_t ram_offset, prom_offset, tcx_offset;
  1321. unsigned long kernel_size;
  1322. int ret;
  1323. char buf[1024];
  1324. BlockDriverState *fd[MAX_FD];
  1325. int drive_index;
  1326. void *fw_cfg;
  1327. /* init CPU */
  1328. if (!cpu_model)
  1329. cpu_model = hwdef->default_cpu_model;
  1330. env = cpu_init(cpu_model);
  1331. if (!env) {
  1332. fprintf(stderr, "qemu: Unable to find Sparc CPU definition\n");
  1333. exit(1);
  1334. }
  1335. cpu_sparc_set_id(env, 0);
  1336. qemu_register_reset(main_cpu_reset, env);
  1337. cpu_irqs = qemu_allocate_irqs(cpu_set_irq, env, MAX_PILS);
  1338. env->prom_addr = hwdef->slavio_base;
  1339. /* allocate RAM */
  1340. if ((uint64_t)RAM_size > hwdef->max_mem) {
  1341. fprintf(stderr,
  1342. "qemu: Too much memory for this machine: %d, maximum %d\n",
  1343. (unsigned int)(RAM_size / (1024 * 1024)),
  1344. (unsigned int)(hwdef->max_mem / (1024 * 1024)));
  1345. exit(1);
  1346. }
  1347. ram_offset = qemu_ram_alloc(RAM_size);
  1348. cpu_register_physical_memory(0, RAM_size, ram_offset);
  1349. /* load boot prom */
  1350. prom_offset = qemu_ram_alloc(PROM_SIZE_MAX);
  1351. cpu_register_physical_memory(hwdef->slavio_base,
  1352. (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) &
  1353. TARGET_PAGE_MASK,
  1354. prom_offset | IO_MEM_ROM);
  1355. if (bios_name == NULL)
  1356. bios_name = PROM_FILENAME;
  1357. snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
  1358. ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL);
  1359. if (ret < 0 || ret > PROM_SIZE_MAX)
  1360. ret = load_image_targphys(buf, hwdef->slavio_base, PROM_SIZE_MAX);
  1361. if (ret < 0 || ret > PROM_SIZE_MAX) {
  1362. fprintf(stderr, "qemu: could not load prom '%s'\n",
  1363. buf);
  1364. exit(1);
  1365. }
  1366. /* set up devices */
  1367. slavio_intctl = sun4c_intctl_init(hwdef->intctl_base,
  1368. &slavio_irq, cpu_irqs);
  1369. iommu = iommu_init(hwdef->iommu_base, hwdef->iommu_version,
  1370. slavio_irq[hwdef->me_irq]);
  1371. espdma = sparc32_dma_init(hwdef->dma_base, slavio_irq[hwdef->esp_irq],
  1372. iommu, &espdma_irq, &esp_reset);
  1373. ledma = sparc32_dma_init(hwdef->dma_base + 16ULL,
  1374. slavio_irq[hwdef->le_irq], iommu, &ledma_irq,
  1375. &le_reset);
  1376. if (graphic_depth != 8 && graphic_depth != 24) {
  1377. fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
  1378. exit (1);
  1379. }
  1380. tcx_offset = qemu_ram_alloc(hwdef->vram_size);
  1381. tcx_init(hwdef->tcx_base, phys_ram_base + tcx_offset, tcx_offset,
  1382. hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
  1383. lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
  1384. nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0,
  1385. hwdef->nvram_size, 2);
  1386. slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[hwdef->ms_kb_irq],
  1387. nographic, ESCC_CLOCK, 1);
  1388. // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
  1389. // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
  1390. escc_init(hwdef->serial_base, slavio_irq[hwdef->ser_irq],
  1391. slavio_irq[hwdef->ser_irq], serial_hds[0], serial_hds[1],
  1392. ESCC_CLOCK, 1);
  1393. slavio_misc = slavio_misc_init(0, 0, hwdef->aux1_base, 0,
  1394. slavio_irq[hwdef->me_irq], NULL, &fdc_tc);
  1395. if (hwdef->fd_base != (target_phys_addr_t)-1) {
  1396. /* there is zero or one floppy drive */
  1397. memset(fd, 0, sizeof(fd));
  1398. drive_index = drive_get_index(IF_FLOPPY, 0, 0);
  1399. if (drive_index != -1)
  1400. fd[0] = drives_table[drive_index].bdrv;
  1401. sun4m_fdctrl_init(slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd,
  1402. fdc_tc);
  1403. }
  1404. if (drive_get_max_bus(IF_SCSI) > 0) {
  1405. fprintf(stderr, "qemu: too many SCSI bus\n");
  1406. exit(1);
  1407. }
  1408. main_esp = esp_init(hwdef->esp_base, 2,
  1409. espdma_memory_read, espdma_memory_write,
  1410. espdma, *espdma_irq, esp_reset);
  1411. for (i = 0; i < ESP_MAX_DEVS; i++) {
  1412. drive_index = drive_get_index(IF_SCSI, 0, i);
  1413. if (drive_index == -1)
  1414. continue;
  1415. esp_scsi_attach(main_esp, drives_table[drive_index].bdrv, i);
  1416. }
  1417. kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename,
  1418. RAM_size);
  1419. nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
  1420. boot_device, RAM_size, kernel_size, graphic_width,
  1421. graphic_height, graphic_depth, hwdef->nvram_machine_id,
  1422. "Sun4c");
  1423. fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
  1424. fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
  1425. fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
  1426. fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id);
  1427. }
  1428. /* SPARCstation 2 hardware initialisation */
  1429. static void ss2_init(ram_addr_t RAM_size, int vga_ram_size,
  1430. const char *boot_device,
  1431. const char *kernel_filename, const char *kernel_cmdline,
  1432. const char *initrd_filename, const char *cpu_model)
  1433. {
  1434. sun4c_hw_init(&sun4c_hwdefs[0], RAM_size, boot_device, kernel_filename,
  1435. kernel_cmdline, initrd_filename, cpu_model);
  1436. }
  1437. QEMUMachine ss2_machine = {
  1438. .name = "SS-2",
  1439. .desc = "Sun4c platform, SPARCstation 2",
  1440. .init = ss2_init,
  1441. .ram_require = PROM_SIZE_MAX + TCX_SIZE,
  1442. .nodisk_ok = 1,
  1443. .use_scsi = 1,
  1444. };