boston.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. /*
  2. * MIPS Boston development board emulation.
  3. *
  4. * Copyright (c) 2016 Imagination Technologies
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include "qemu/osdep.h"
  20. #include "qemu/units.h"
  21. #include "exec/address-spaces.h"
  22. #include "hw/boards.h"
  23. #include "hw/char/serial.h"
  24. #include "hw/ide/pci.h"
  25. #include "hw/ide/ahci.h"
  26. #include "hw/loader.h"
  27. #include "hw/loader-fit.h"
  28. #include "hw/mips/cps.h"
  29. #include "hw/mips/cpudevs.h"
  30. #include "hw/pci-host/xilinx-pcie.h"
  31. #include "hw/qdev-properties.h"
  32. #include "qapi/error.h"
  33. #include "qemu/error-report.h"
  34. #include "qemu/log.h"
  35. #include "chardev/char.h"
  36. #include "sysemu/device_tree.h"
  37. #include "sysemu/sysemu.h"
  38. #include "sysemu/qtest.h"
  39. #include "sysemu/runstate.h"
  40. #include <libfdt.h>
  41. #define TYPE_MIPS_BOSTON "mips-boston"
  42. #define BOSTON(obj) OBJECT_CHECK(BostonState, (obj), TYPE_MIPS_BOSTON)
  43. typedef struct {
  44. SysBusDevice parent_obj;
  45. MachineState *mach;
  46. MIPSCPSState cps;
  47. SerialState *uart;
  48. CharBackend lcd_display;
  49. char lcd_content[8];
  50. bool lcd_inited;
  51. hwaddr kernel_entry;
  52. hwaddr fdt_base;
  53. } BostonState;
  54. enum boston_plat_reg {
  55. PLAT_FPGA_BUILD = 0x00,
  56. PLAT_CORE_CL = 0x04,
  57. PLAT_WRAPPER_CL = 0x08,
  58. PLAT_SYSCLK_STATUS = 0x0c,
  59. PLAT_SOFTRST_CTL = 0x10,
  60. #define PLAT_SOFTRST_CTL_SYSRESET (1 << 4)
  61. PLAT_DDR3_STATUS = 0x14,
  62. #define PLAT_DDR3_STATUS_LOCKED (1 << 0)
  63. #define PLAT_DDR3_STATUS_CALIBRATED (1 << 2)
  64. PLAT_PCIE_STATUS = 0x18,
  65. #define PLAT_PCIE_STATUS_PCIE0_LOCKED (1 << 0)
  66. #define PLAT_PCIE_STATUS_PCIE1_LOCKED (1 << 8)
  67. #define PLAT_PCIE_STATUS_PCIE2_LOCKED (1 << 16)
  68. PLAT_FLASH_CTL = 0x1c,
  69. PLAT_SPARE0 = 0x20,
  70. PLAT_SPARE1 = 0x24,
  71. PLAT_SPARE2 = 0x28,
  72. PLAT_SPARE3 = 0x2c,
  73. PLAT_MMCM_DIV = 0x30,
  74. #define PLAT_MMCM_DIV_CLK0DIV_SHIFT 0
  75. #define PLAT_MMCM_DIV_INPUT_SHIFT 8
  76. #define PLAT_MMCM_DIV_MUL_SHIFT 16
  77. #define PLAT_MMCM_DIV_CLK1DIV_SHIFT 24
  78. PLAT_BUILD_CFG = 0x34,
  79. #define PLAT_BUILD_CFG_IOCU_EN (1 << 0)
  80. #define PLAT_BUILD_CFG_PCIE0_EN (1 << 1)
  81. #define PLAT_BUILD_CFG_PCIE1_EN (1 << 2)
  82. #define PLAT_BUILD_CFG_PCIE2_EN (1 << 3)
  83. PLAT_DDR_CFG = 0x38,
  84. #define PLAT_DDR_CFG_SIZE (0xf << 0)
  85. #define PLAT_DDR_CFG_MHZ (0xfff << 4)
  86. PLAT_NOC_PCIE0_ADDR = 0x3c,
  87. PLAT_NOC_PCIE1_ADDR = 0x40,
  88. PLAT_NOC_PCIE2_ADDR = 0x44,
  89. PLAT_SYS_CTL = 0x48,
  90. };
  91. static void boston_lcd_event(void *opaque, int event)
  92. {
  93. BostonState *s = opaque;
  94. if (event == CHR_EVENT_OPENED && !s->lcd_inited) {
  95. qemu_chr_fe_printf(&s->lcd_display, " ");
  96. s->lcd_inited = true;
  97. }
  98. }
  99. static uint64_t boston_lcd_read(void *opaque, hwaddr addr,
  100. unsigned size)
  101. {
  102. BostonState *s = opaque;
  103. uint64_t val = 0;
  104. switch (size) {
  105. case 8:
  106. val |= (uint64_t)s->lcd_content[(addr + 7) & 0x7] << 56;
  107. val |= (uint64_t)s->lcd_content[(addr + 6) & 0x7] << 48;
  108. val |= (uint64_t)s->lcd_content[(addr + 5) & 0x7] << 40;
  109. val |= (uint64_t)s->lcd_content[(addr + 4) & 0x7] << 32;
  110. /* fall through */
  111. case 4:
  112. val |= (uint64_t)s->lcd_content[(addr + 3) & 0x7] << 24;
  113. val |= (uint64_t)s->lcd_content[(addr + 2) & 0x7] << 16;
  114. /* fall through */
  115. case 2:
  116. val |= (uint64_t)s->lcd_content[(addr + 1) & 0x7] << 8;
  117. /* fall through */
  118. case 1:
  119. val |= (uint64_t)s->lcd_content[(addr + 0) & 0x7];
  120. break;
  121. }
  122. return val;
  123. }
  124. static void boston_lcd_write(void *opaque, hwaddr addr,
  125. uint64_t val, unsigned size)
  126. {
  127. BostonState *s = opaque;
  128. switch (size) {
  129. case 8:
  130. s->lcd_content[(addr + 7) & 0x7] = val >> 56;
  131. s->lcd_content[(addr + 6) & 0x7] = val >> 48;
  132. s->lcd_content[(addr + 5) & 0x7] = val >> 40;
  133. s->lcd_content[(addr + 4) & 0x7] = val >> 32;
  134. /* fall through */
  135. case 4:
  136. s->lcd_content[(addr + 3) & 0x7] = val >> 24;
  137. s->lcd_content[(addr + 2) & 0x7] = val >> 16;
  138. /* fall through */
  139. case 2:
  140. s->lcd_content[(addr + 1) & 0x7] = val >> 8;
  141. /* fall through */
  142. case 1:
  143. s->lcd_content[(addr + 0) & 0x7] = val;
  144. break;
  145. }
  146. qemu_chr_fe_printf(&s->lcd_display,
  147. "\r%-8.8s", s->lcd_content);
  148. }
  149. static const MemoryRegionOps boston_lcd_ops = {
  150. .read = boston_lcd_read,
  151. .write = boston_lcd_write,
  152. .endianness = DEVICE_NATIVE_ENDIAN,
  153. };
  154. static uint64_t boston_platreg_read(void *opaque, hwaddr addr,
  155. unsigned size)
  156. {
  157. BostonState *s = opaque;
  158. uint32_t gic_freq, val;
  159. if (size != 4) {
  160. qemu_log_mask(LOG_UNIMP, "%uB platform register read\n", size);
  161. return 0;
  162. }
  163. switch (addr & 0xffff) {
  164. case PLAT_FPGA_BUILD:
  165. case PLAT_CORE_CL:
  166. case PLAT_WRAPPER_CL:
  167. return 0;
  168. case PLAT_DDR3_STATUS:
  169. return PLAT_DDR3_STATUS_LOCKED | PLAT_DDR3_STATUS_CALIBRATED;
  170. case PLAT_MMCM_DIV:
  171. gic_freq = mips_gictimer_get_freq(s->cps.gic.gic_timer) / 1000000;
  172. val = gic_freq << PLAT_MMCM_DIV_INPUT_SHIFT;
  173. val |= 1 << PLAT_MMCM_DIV_MUL_SHIFT;
  174. val |= 1 << PLAT_MMCM_DIV_CLK0DIV_SHIFT;
  175. val |= 1 << PLAT_MMCM_DIV_CLK1DIV_SHIFT;
  176. return val;
  177. case PLAT_BUILD_CFG:
  178. val = PLAT_BUILD_CFG_PCIE0_EN;
  179. val |= PLAT_BUILD_CFG_PCIE1_EN;
  180. val |= PLAT_BUILD_CFG_PCIE2_EN;
  181. return val;
  182. case PLAT_DDR_CFG:
  183. val = s->mach->ram_size / GiB;
  184. assert(!(val & ~PLAT_DDR_CFG_SIZE));
  185. val |= PLAT_DDR_CFG_MHZ;
  186. return val;
  187. default:
  188. qemu_log_mask(LOG_UNIMP, "Read platform register 0x%" HWADDR_PRIx "\n",
  189. addr & 0xffff);
  190. return 0;
  191. }
  192. }
  193. static void boston_platreg_write(void *opaque, hwaddr addr,
  194. uint64_t val, unsigned size)
  195. {
  196. if (size != 4) {
  197. qemu_log_mask(LOG_UNIMP, "%uB platform register write\n", size);
  198. return;
  199. }
  200. switch (addr & 0xffff) {
  201. case PLAT_FPGA_BUILD:
  202. case PLAT_CORE_CL:
  203. case PLAT_WRAPPER_CL:
  204. case PLAT_DDR3_STATUS:
  205. case PLAT_PCIE_STATUS:
  206. case PLAT_MMCM_DIV:
  207. case PLAT_BUILD_CFG:
  208. case PLAT_DDR_CFG:
  209. /* read only */
  210. break;
  211. case PLAT_SOFTRST_CTL:
  212. if (val & PLAT_SOFTRST_CTL_SYSRESET) {
  213. qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
  214. }
  215. break;
  216. default:
  217. qemu_log_mask(LOG_UNIMP, "Write platform register 0x%" HWADDR_PRIx
  218. " = 0x%" PRIx64 "\n", addr & 0xffff, val);
  219. break;
  220. }
  221. }
  222. static const MemoryRegionOps boston_platreg_ops = {
  223. .read = boston_platreg_read,
  224. .write = boston_platreg_write,
  225. .endianness = DEVICE_NATIVE_ENDIAN,
  226. };
  227. static const TypeInfo boston_device = {
  228. .name = TYPE_MIPS_BOSTON,
  229. .parent = TYPE_SYS_BUS_DEVICE,
  230. .instance_size = sizeof(BostonState),
  231. };
  232. static void boston_register_types(void)
  233. {
  234. type_register_static(&boston_device);
  235. }
  236. type_init(boston_register_types)
  237. static void gen_firmware(uint32_t *p, hwaddr kernel_entry, hwaddr fdt_addr,
  238. bool is_64b)
  239. {
  240. const uint32_t cm_base = 0x16100000;
  241. const uint32_t gic_base = 0x16120000;
  242. const uint32_t cpc_base = 0x16200000;
  243. /* Move CM GCRs */
  244. if (is_64b) {
  245. stl_p(p++, 0x40287803); /* dmfc0 $8, CMGCRBase */
  246. stl_p(p++, 0x00084138); /* dsll $8, $8, 4 */
  247. } else {
  248. stl_p(p++, 0x40087803); /* mfc0 $8, CMGCRBase */
  249. stl_p(p++, 0x00084100); /* sll $8, $8, 4 */
  250. }
  251. stl_p(p++, 0x3c09a000); /* lui $9, 0xa000 */
  252. stl_p(p++, 0x01094025); /* or $8, $9 */
  253. stl_p(p++, 0x3c0a0000 | (cm_base >> 16)); /* lui $10, cm_base >> 16 */
  254. if (is_64b) {
  255. stl_p(p++, 0xfd0a0008); /* sd $10, 0x8($8) */
  256. } else {
  257. stl_p(p++, 0xad0a0008); /* sw $10, 0x8($8) */
  258. }
  259. stl_p(p++, 0x012a4025); /* or $8, $10 */
  260. /* Move & enable GIC GCRs */
  261. stl_p(p++, 0x3c090000 | (gic_base >> 16)); /* lui $9, gic_base >> 16 */
  262. stl_p(p++, 0x35290001); /* ori $9, 0x1 */
  263. if (is_64b) {
  264. stl_p(p++, 0xfd090080); /* sd $9, 0x80($8) */
  265. } else {
  266. stl_p(p++, 0xad090080); /* sw $9, 0x80($8) */
  267. }
  268. /* Move & enable CPC GCRs */
  269. stl_p(p++, 0x3c090000 | (cpc_base >> 16)); /* lui $9, cpc_base >> 16 */
  270. stl_p(p++, 0x35290001); /* ori $9, 0x1 */
  271. if (is_64b) {
  272. stl_p(p++, 0xfd090088); /* sd $9, 0x88($8) */
  273. } else {
  274. stl_p(p++, 0xad090088); /* sw $9, 0x88($8) */
  275. }
  276. /*
  277. * Setup argument registers to follow the UHI boot protocol:
  278. *
  279. * a0/$4 = -2
  280. * a1/$5 = virtual address of FDT
  281. * a2/$6 = 0
  282. * a3/$7 = 0
  283. */
  284. stl_p(p++, 0x2404fffe); /* li $4, -2 */
  285. /* lui $5, hi(fdt_addr) */
  286. stl_p(p++, 0x3c050000 | ((fdt_addr >> 16) & 0xffff));
  287. if (fdt_addr & 0xffff) { /* ori $5, lo(fdt_addr) */
  288. stl_p(p++, 0x34a50000 | (fdt_addr & 0xffff));
  289. }
  290. stl_p(p++, 0x34060000); /* li $6, 0 */
  291. stl_p(p++, 0x34070000); /* li $7, 0 */
  292. /* Load kernel entry address & jump to it */
  293. /* lui $25, hi(kernel_entry) */
  294. stl_p(p++, 0x3c190000 | ((kernel_entry >> 16) & 0xffff));
  295. /* ori $25, lo(kernel_entry) */
  296. stl_p(p++, 0x37390000 | (kernel_entry & 0xffff));
  297. stl_p(p++, 0x03200009); /* jr $25 */
  298. }
  299. static const void *boston_fdt_filter(void *opaque, const void *fdt_orig,
  300. const void *match_data, hwaddr *load_addr)
  301. {
  302. BostonState *s = BOSTON(opaque);
  303. MachineState *machine = s->mach;
  304. const char *cmdline;
  305. int err;
  306. void *fdt;
  307. size_t fdt_sz, ram_low_sz, ram_high_sz;
  308. fdt_sz = fdt_totalsize(fdt_orig) * 2;
  309. fdt = g_malloc0(fdt_sz);
  310. err = fdt_open_into(fdt_orig, fdt, fdt_sz);
  311. if (err) {
  312. fprintf(stderr, "unable to open FDT\n");
  313. return NULL;
  314. }
  315. cmdline = (machine->kernel_cmdline && machine->kernel_cmdline[0])
  316. ? machine->kernel_cmdline : " ";
  317. err = qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", cmdline);
  318. if (err < 0) {
  319. fprintf(stderr, "couldn't set /chosen/bootargs\n");
  320. return NULL;
  321. }
  322. ram_low_sz = MIN(256 * MiB, machine->ram_size);
  323. ram_high_sz = machine->ram_size - ram_low_sz;
  324. qemu_fdt_setprop_sized_cells(fdt, "/memory@0", "reg",
  325. 1, 0x00000000, 1, ram_low_sz,
  326. 1, 0x90000000, 1, ram_high_sz);
  327. fdt = g_realloc(fdt, fdt_totalsize(fdt));
  328. qemu_fdt_dumpdtb(fdt, fdt_sz);
  329. s->fdt_base = *load_addr;
  330. return fdt;
  331. }
  332. static const void *boston_kernel_filter(void *opaque, const void *kernel,
  333. hwaddr *load_addr, hwaddr *entry_addr)
  334. {
  335. BostonState *s = BOSTON(opaque);
  336. s->kernel_entry = *entry_addr;
  337. return kernel;
  338. }
  339. static const struct fit_loader_match boston_matches[] = {
  340. { "img,boston" },
  341. { NULL },
  342. };
  343. static const struct fit_loader boston_fit_loader = {
  344. .matches = boston_matches,
  345. .addr_to_phys = cpu_mips_kseg0_to_phys,
  346. .fdt_filter = boston_fdt_filter,
  347. .kernel_filter = boston_kernel_filter,
  348. };
  349. static inline XilinxPCIEHost *
  350. xilinx_pcie_init(MemoryRegion *sys_mem, uint32_t bus_nr,
  351. hwaddr cfg_base, uint64_t cfg_size,
  352. hwaddr mmio_base, uint64_t mmio_size,
  353. qemu_irq irq, bool link_up)
  354. {
  355. DeviceState *dev;
  356. MemoryRegion *cfg, *mmio;
  357. dev = qdev_create(NULL, TYPE_XILINX_PCIE_HOST);
  358. qdev_prop_set_uint32(dev, "bus_nr", bus_nr);
  359. qdev_prop_set_uint64(dev, "cfg_base", cfg_base);
  360. qdev_prop_set_uint64(dev, "cfg_size", cfg_size);
  361. qdev_prop_set_uint64(dev, "mmio_base", mmio_base);
  362. qdev_prop_set_uint64(dev, "mmio_size", mmio_size);
  363. qdev_prop_set_bit(dev, "link_up", link_up);
  364. qdev_init_nofail(dev);
  365. cfg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0);
  366. memory_region_add_subregion_overlap(sys_mem, cfg_base, cfg, 0);
  367. mmio = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 1);
  368. memory_region_add_subregion_overlap(sys_mem, 0, mmio, 0);
  369. qdev_connect_gpio_out_named(dev, "interrupt_out", 0, irq);
  370. return XILINX_PCIE_HOST(dev);
  371. }
  372. static void boston_mach_init(MachineState *machine)
  373. {
  374. DeviceState *dev;
  375. BostonState *s;
  376. Error *err = NULL;
  377. MemoryRegion *flash, *ddr, *ddr_low_alias, *lcd, *platreg;
  378. MemoryRegion *sys_mem = get_system_memory();
  379. XilinxPCIEHost *pcie2;
  380. PCIDevice *ahci;
  381. DriveInfo *hd[6];
  382. Chardev *chr;
  383. int fw_size, fit_err;
  384. bool is_64b;
  385. if ((machine->ram_size % GiB) ||
  386. (machine->ram_size > (2 * GiB))) {
  387. error_report("Memory size must be 1GB or 2GB");
  388. exit(1);
  389. }
  390. dev = qdev_create(NULL, TYPE_MIPS_BOSTON);
  391. qdev_init_nofail(dev);
  392. s = BOSTON(dev);
  393. s->mach = machine;
  394. if (!cpu_supports_cps_smp(machine->cpu_type)) {
  395. error_report("Boston requires CPUs which support CPS");
  396. exit(1);
  397. }
  398. is_64b = cpu_supports_isa(machine->cpu_type, ISA_MIPS64);
  399. sysbus_init_child_obj(OBJECT(machine), "cps", OBJECT(&s->cps),
  400. sizeof(s->cps), TYPE_MIPS_CPS);
  401. object_property_set_str(OBJECT(&s->cps), machine->cpu_type, "cpu-type",
  402. &err);
  403. object_property_set_int(OBJECT(&s->cps), machine->smp.cpus, "num-vp", &err);
  404. object_property_set_bool(OBJECT(&s->cps), true, "realized", &err);
  405. if (err != NULL) {
  406. error_report("%s", error_get_pretty(err));
  407. exit(1);
  408. }
  409. sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->cps), 0, 0, 1);
  410. flash = g_new(MemoryRegion, 1);
  411. memory_region_init_rom(flash, NULL, "boston.flash", 128 * MiB, &err);
  412. memory_region_add_subregion_overlap(sys_mem, 0x18000000, flash, 0);
  413. ddr = g_new(MemoryRegion, 1);
  414. memory_region_allocate_system_memory(ddr, NULL, "boston.ddr",
  415. machine->ram_size);
  416. memory_region_add_subregion_overlap(sys_mem, 0x80000000, ddr, 0);
  417. ddr_low_alias = g_new(MemoryRegion, 1);
  418. memory_region_init_alias(ddr_low_alias, NULL, "boston_low.ddr",
  419. ddr, 0, MIN(machine->ram_size, (256 * MiB)));
  420. memory_region_add_subregion_overlap(sys_mem, 0, ddr_low_alias, 0);
  421. xilinx_pcie_init(sys_mem, 0,
  422. 0x10000000, 32 * MiB,
  423. 0x40000000, 1 * GiB,
  424. get_cps_irq(&s->cps, 2), false);
  425. xilinx_pcie_init(sys_mem, 1,
  426. 0x12000000, 32 * MiB,
  427. 0x20000000, 512 * MiB,
  428. get_cps_irq(&s->cps, 1), false);
  429. pcie2 = xilinx_pcie_init(sys_mem, 2,
  430. 0x14000000, 32 * MiB,
  431. 0x16000000, 1 * MiB,
  432. get_cps_irq(&s->cps, 0), true);
  433. platreg = g_new(MemoryRegion, 1);
  434. memory_region_init_io(platreg, NULL, &boston_platreg_ops, s,
  435. "boston-platregs", 0x1000);
  436. memory_region_add_subregion_overlap(sys_mem, 0x17ffd000, platreg, 0);
  437. s->uart = serial_mm_init(sys_mem, 0x17ffe000, 2,
  438. get_cps_irq(&s->cps, 3), 10000000,
  439. serial_hd(0), DEVICE_NATIVE_ENDIAN);
  440. lcd = g_new(MemoryRegion, 1);
  441. memory_region_init_io(lcd, NULL, &boston_lcd_ops, s, "boston-lcd", 0x8);
  442. memory_region_add_subregion_overlap(sys_mem, 0x17fff000, lcd, 0);
  443. chr = qemu_chr_new("lcd", "vc:320x240", NULL);
  444. qemu_chr_fe_init(&s->lcd_display, chr, NULL);
  445. qemu_chr_fe_set_handlers(&s->lcd_display, NULL, NULL,
  446. boston_lcd_event, NULL, s, NULL, true);
  447. ahci = pci_create_simple_multifunction(&PCI_BRIDGE(&pcie2->root)->sec_bus,
  448. PCI_DEVFN(0, 0),
  449. true, TYPE_ICH9_AHCI);
  450. g_assert(ARRAY_SIZE(hd) == ahci_get_num_ports(ahci));
  451. ide_drive_get(hd, ahci_get_num_ports(ahci));
  452. ahci_ide_create_devs(ahci, hd);
  453. if (machine->firmware) {
  454. fw_size = load_image_targphys(machine->firmware,
  455. 0x1fc00000, 4 * MiB);
  456. if (fw_size == -1) {
  457. error_report("unable to load firmware image '%s'",
  458. machine->firmware);
  459. exit(1);
  460. }
  461. } else if (machine->kernel_filename) {
  462. fit_err = load_fit(&boston_fit_loader, machine->kernel_filename, s);
  463. if (fit_err) {
  464. error_report("unable to load FIT image");
  465. exit(1);
  466. }
  467. gen_firmware(memory_region_get_ram_ptr(flash) + 0x7c00000,
  468. s->kernel_entry, s->fdt_base, is_64b);
  469. } else if (!qtest_enabled()) {
  470. error_report("Please provide either a -kernel or -bios argument");
  471. exit(1);
  472. }
  473. }
  474. static void boston_mach_class_init(MachineClass *mc)
  475. {
  476. mc->desc = "MIPS Boston";
  477. mc->init = boston_mach_init;
  478. mc->block_default_type = IF_IDE;
  479. mc->default_ram_size = 1 * GiB;
  480. mc->max_cpus = 16;
  481. mc->default_cpu_type = MIPS_CPU_TYPE_NAME("I6400");
  482. }
  483. DEFINE_MACHINE("boston", boston_mach_class_init)