1 /* 2 * Copyright (c) 2011, Max Filippov, Open Source and Linux Lab. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * * Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * * Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * * Neither the name of the Open Source and Linux Lab nor the 13 * names of its contributors may be used to endorse or promote products 14 * derived from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #include "qemu/osdep.h" 29 #include "qemu/units.h" 30 #include "qapi/error.h" 31 #include "cpu.h" 32 #include "sysemu/sysemu.h" 33 #include "hw/boards.h" 34 #include "hw/loader.h" 35 #include "hw/qdev-properties.h" 36 #include "elf.h" 37 #include "exec/memory.h" 38 #include "exec/tswap.h" 39 #include "hw/char/serial-mm.h" 40 #include "net/net.h" 41 #include "hw/sysbus.h" 42 #include "hw/block/flash.h" 43 #include "chardev/char.h" 44 #include "sysemu/device_tree.h" 45 #include "sysemu/reset.h" 46 #include "sysemu/runstate.h" 47 #include "qemu/error-report.h" 48 #include "qemu/option.h" 49 #include "bootparam.h" 50 #include "xtensa_memory.h" 51 #include "hw/xtensa/mx_pic.h" 52 #include "migration/vmstate.h" 53 54 typedef struct XtfpgaFlashDesc { 55 hwaddr base; 56 size_t size; 57 size_t boot_base; 58 size_t sector_size; 59 } XtfpgaFlashDesc; 60 61 typedef struct XtfpgaBoardDesc { 62 const XtfpgaFlashDesc *flash; 63 size_t sram_size; 64 const hwaddr *io; 65 } XtfpgaBoardDesc; 66 67 typedef struct XtfpgaFpgaState { 68 MemoryRegion iomem; 69 uint32_t freq; 70 uint32_t leds; 71 uint32_t switches; 72 } XtfpgaFpgaState; 73 74 static void xtfpga_fpga_reset(void *opaque) 75 { 76 XtfpgaFpgaState *s = opaque; 77 78 s->leds = 0; 79 s->switches = 0; 80 } 81 82 static uint64_t xtfpga_fpga_read(void *opaque, hwaddr addr, 83 unsigned size) 84 { 85 XtfpgaFpgaState *s = opaque; 86 87 switch (addr) { 88 case 0x0: /*build date code*/ 89 return 0x09272011; 90 91 case 0x4: /*processor clock frequency, Hz*/ 92 return s->freq; 93 94 case 0x8: /*LEDs (off = 0, on = 1)*/ 95 return s->leds; 96 97 case 0xc: /*DIP switches (off = 0, on = 1)*/ 98 return s->switches; 99 } 100 return 0; 101 } 102 103 static void xtfpga_fpga_write(void *opaque, hwaddr addr, 104 uint64_t val, unsigned size) 105 { 106 XtfpgaFpgaState *s = opaque; 107 108 switch (addr) { 109 case 0x8: /*LEDs (off = 0, on = 1)*/ 110 s->leds = val; 111 break; 112 113 case 0x10: /*board reset*/ 114 if (val == 0xdead) { 115 qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); 116 } 117 break; 118 } 119 } 120 121 static const MemoryRegionOps xtfpga_fpga_ops = { 122 .read = xtfpga_fpga_read, 123 .write = xtfpga_fpga_write, 124 .endianness = DEVICE_NATIVE_ENDIAN, 125 }; 126 127 static XtfpgaFpgaState *xtfpga_fpga_init(MemoryRegion *address_space, 128 hwaddr base, uint32_t freq) 129 { 130 XtfpgaFpgaState *s = g_new(XtfpgaFpgaState, 1); 131 132 memory_region_init_io(&s->iomem, NULL, &xtfpga_fpga_ops, s, 133 "xtfpga.fpga", 0x10000); 134 memory_region_add_subregion(address_space, base, &s->iomem); 135 s->freq = freq; 136 xtfpga_fpga_reset(s); 137 qemu_register_reset(xtfpga_fpga_reset, s); 138 return s; 139 } 140 141 static void xtfpga_net_init(MemoryRegion *address_space, 142 hwaddr base, 143 hwaddr descriptors, 144 hwaddr buffers, 145 qemu_irq irq) 146 { 147 DeviceState *dev; 148 SysBusDevice *s; 149 MemoryRegion *ram; 150 151 dev = qemu_create_nic_device("open_eth", true, NULL); 152 if (!dev) { 153 return; 154 } 155 156 s = SYS_BUS_DEVICE(dev); 157 sysbus_realize_and_unref(s, &error_fatal); 158 sysbus_connect_irq(s, 0, irq); 159 memory_region_add_subregion(address_space, base, 160 sysbus_mmio_get_region(s, 0)); 161 memory_region_add_subregion(address_space, descriptors, 162 sysbus_mmio_get_region(s, 1)); 163 164 ram = g_malloc(sizeof(*ram)); 165 memory_region_init_ram_nomigrate(ram, OBJECT(s), "open_eth.ram", 16 * KiB, 166 &error_fatal); 167 vmstate_register_ram_global(ram); 168 memory_region_add_subregion(address_space, buffers, ram); 169 } 170 171 static PFlashCFI01 *xtfpga_flash_init(MemoryRegion *address_space, 172 const XtfpgaBoardDesc *board, 173 DriveInfo *dinfo, int be) 174 { 175 SysBusDevice *s; 176 DeviceState *dev = qdev_new(TYPE_PFLASH_CFI01); 177 178 qdev_prop_set_drive(dev, "drive", blk_by_legacy_dinfo(dinfo)); 179 qdev_prop_set_uint32(dev, "num-blocks", 180 board->flash->size / board->flash->sector_size); 181 qdev_prop_set_uint64(dev, "sector-length", board->flash->sector_size); 182 qdev_prop_set_uint8(dev, "width", 2); 183 qdev_prop_set_bit(dev, "big-endian", be); 184 qdev_prop_set_string(dev, "name", "xtfpga.io.flash"); 185 s = SYS_BUS_DEVICE(dev); 186 sysbus_realize_and_unref(s, &error_fatal); 187 memory_region_add_subregion(address_space, board->flash->base, 188 sysbus_mmio_get_region(s, 0)); 189 return PFLASH_CFI01(dev); 190 } 191 192 static uint64_t translate_phys_addr(void *opaque, uint64_t addr) 193 { 194 XtensaCPU *cpu = opaque; 195 196 return cpu_get_phys_page_debug(CPU(cpu), addr); 197 } 198 199 static void xtfpga_reset(void *opaque) 200 { 201 XtensaCPU *cpu = opaque; 202 203 cpu_reset(CPU(cpu)); 204 } 205 206 static uint64_t xtfpga_io_read(void *opaque, hwaddr addr, 207 unsigned size) 208 { 209 return 0; 210 } 211 212 static void xtfpga_io_write(void *opaque, hwaddr addr, 213 uint64_t val, unsigned size) 214 { 215 } 216 217 static const MemoryRegionOps xtfpga_io_ops = { 218 .read = xtfpga_io_read, 219 .write = xtfpga_io_write, 220 .endianness = DEVICE_NATIVE_ENDIAN, 221 }; 222 223 static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) 224 { 225 MemoryRegion *system_memory = get_system_memory(); 226 XtensaCPU *cpu = NULL; 227 CPUXtensaState *env = NULL; 228 MemoryRegion *system_io; 229 XtensaMxPic *mx_pic = NULL; 230 qemu_irq *extints; 231 DriveInfo *dinfo; 232 PFlashCFI01 *flash = NULL; 233 const char *kernel_filename = machine->kernel_filename; 234 const char *kernel_cmdline = machine->kernel_cmdline; 235 const char *dtb_filename = machine->dtb; 236 const char *initrd_filename = machine->initrd_filename; 237 const unsigned system_io_size = 224 * MiB; 238 uint32_t freq = 10000000; 239 int n; 240 unsigned int smp_cpus = machine->smp.cpus; 241 242 if (smp_cpus > 1) { 243 mx_pic = xtensa_mx_pic_init(31); 244 qemu_register_reset(xtensa_mx_pic_reset, mx_pic); 245 } 246 for (n = 0; n < smp_cpus; n++) { 247 CPUXtensaState *cenv = NULL; 248 249 cpu = XTENSA_CPU(cpu_create(machine->cpu_type)); 250 cenv = &cpu->env; 251 if (!env) { 252 env = cenv; 253 freq = env->config->clock_freq_khz * 1000; 254 } 255 256 if (mx_pic) { 257 MemoryRegion *mx_eri; 258 259 mx_eri = xtensa_mx_pic_register_cpu(mx_pic, 260 xtensa_get_extints(cenv), 261 xtensa_get_runstall(cenv)); 262 memory_region_add_subregion(xtensa_get_er_region(cenv), 263 0, mx_eri); 264 } 265 cenv->sregs[PRID] = n; 266 xtensa_select_static_vectors(cenv, n != 0); 267 qemu_register_reset(xtfpga_reset, cpu); 268 /* Need MMU initialized prior to ELF loading, 269 * so that ELF gets loaded into virtual addresses 270 */ 271 cpu_reset(CPU(cpu)); 272 } 273 if (smp_cpus > 1) { 274 extints = xtensa_mx_pic_get_extints(mx_pic); 275 } else { 276 extints = xtensa_get_extints(env); 277 } 278 279 if (env) { 280 XtensaMemory sysram = env->config->sysram; 281 282 sysram.location[0].size = machine->ram_size; 283 xtensa_create_memory_regions(&env->config->instrom, "xtensa.instrom", 284 system_memory); 285 xtensa_create_memory_regions(&env->config->instram, "xtensa.instram", 286 system_memory); 287 xtensa_create_memory_regions(&env->config->datarom, "xtensa.datarom", 288 system_memory); 289 xtensa_create_memory_regions(&env->config->dataram, "xtensa.dataram", 290 system_memory); 291 xtensa_create_memory_regions(&sysram, "xtensa.sysram", 292 system_memory); 293 } 294 295 system_io = g_malloc(sizeof(*system_io)); 296 memory_region_init_io(system_io, NULL, &xtfpga_io_ops, NULL, "xtfpga.io", 297 system_io_size); 298 memory_region_add_subregion(system_memory, board->io[0], system_io); 299 if (board->io[1]) { 300 MemoryRegion *io = g_malloc(sizeof(*io)); 301 302 memory_region_init_alias(io, NULL, "xtfpga.io.cached", 303 system_io, 0, system_io_size); 304 memory_region_add_subregion(system_memory, board->io[1], io); 305 } 306 xtfpga_fpga_init(system_io, 0x0d020000, freq); 307 xtfpga_net_init(system_io, 0x0d030000, 0x0d030400, 0x0d800000, extints[1]); 308 309 serial_mm_init(system_io, 0x0d050020, 2, extints[0], 310 115200, serial_hd(0), DEVICE_NATIVE_ENDIAN); 311 312 dinfo = drive_get(IF_PFLASH, 0, 0); 313 if (dinfo) { 314 flash = xtfpga_flash_init(system_io, board, dinfo, TARGET_BIG_ENDIAN); 315 } 316 317 /* Use presence of kernel file name as 'boot from SRAM' switch. */ 318 if (kernel_filename) { 319 uint32_t entry_point = env->pc; 320 size_t bp_size = 3 * get_tag_size(0); /* first/last and memory tags */ 321 uint32_t tagptr = env->config->sysrom.location[0].addr + 322 board->sram_size; 323 uint32_t cur_tagptr; 324 BpMemInfo memory_location = { 325 .type = tswap32(MEMORY_TYPE_CONVENTIONAL), 326 .start = tswap32(env->config->sysram.location[0].addr), 327 .end = tswap32(env->config->sysram.location[0].addr + 328 machine->ram_size), 329 }; 330 uint32_t lowmem_end = machine->ram_size < 0x08000000 ? 331 machine->ram_size : 0x08000000; 332 uint32_t cur_lowmem = QEMU_ALIGN_UP(lowmem_end / 2, 4096); 333 334 lowmem_end += env->config->sysram.location[0].addr; 335 cur_lowmem += env->config->sysram.location[0].addr; 336 337 xtensa_create_memory_regions(&env->config->sysrom, "xtensa.sysrom", 338 system_memory); 339 340 if (kernel_cmdline) { 341 bp_size += get_tag_size(strlen(kernel_cmdline) + 1); 342 } 343 if (dtb_filename) { 344 bp_size += get_tag_size(sizeof(uint32_t)); 345 } 346 if (initrd_filename) { 347 bp_size += get_tag_size(sizeof(BpMemInfo)); 348 } 349 350 /* Put kernel bootparameters to the end of that SRAM */ 351 tagptr = (tagptr - bp_size) & ~0xff; 352 cur_tagptr = put_tag(tagptr, BP_TAG_FIRST, 0, NULL); 353 cur_tagptr = put_tag(cur_tagptr, BP_TAG_MEMORY, 354 sizeof(memory_location), &memory_location); 355 356 if (kernel_cmdline) { 357 cur_tagptr = put_tag(cur_tagptr, BP_TAG_COMMAND_LINE, 358 strlen(kernel_cmdline) + 1, kernel_cmdline); 359 } 360 if (dtb_filename) { 361 int fdt_size; 362 void *fdt = load_device_tree(dtb_filename, &fdt_size); 363 uint32_t dtb_addr = tswap32(cur_lowmem); 364 365 if (!fdt) { 366 error_report("could not load DTB '%s'", dtb_filename); 367 exit(EXIT_FAILURE); 368 } 369 370 cpu_physical_memory_write(cur_lowmem, fdt, fdt_size); 371 cur_tagptr = put_tag(cur_tagptr, BP_TAG_FDT, 372 sizeof(dtb_addr), &dtb_addr); 373 cur_lowmem = QEMU_ALIGN_UP(cur_lowmem + fdt_size, 4 * KiB); 374 g_free(fdt); 375 } 376 if (initrd_filename) { 377 BpMemInfo initrd_location = { 0 }; 378 int initrd_size = load_ramdisk(initrd_filename, cur_lowmem, 379 lowmem_end - cur_lowmem); 380 381 if (initrd_size < 0) { 382 initrd_size = load_image_targphys(initrd_filename, 383 cur_lowmem, 384 lowmem_end - cur_lowmem); 385 } 386 if (initrd_size < 0) { 387 error_report("could not load initrd '%s'", initrd_filename); 388 exit(EXIT_FAILURE); 389 } 390 initrd_location.start = tswap32(cur_lowmem); 391 initrd_location.end = tswap32(cur_lowmem + initrd_size); 392 cur_tagptr = put_tag(cur_tagptr, BP_TAG_INITRD, 393 sizeof(initrd_location), &initrd_location); 394 cur_lowmem = QEMU_ALIGN_UP(cur_lowmem + initrd_size, 4 * KiB); 395 } 396 cur_tagptr = put_tag(cur_tagptr, BP_TAG_LAST, 0, NULL); 397 env->regs[2] = tagptr; 398 399 uint64_t elf_entry; 400 int success = load_elf(kernel_filename, NULL, translate_phys_addr, cpu, 401 &elf_entry, NULL, NULL, NULL, TARGET_BIG_ENDIAN, 402 EM_XTENSA, 0, 0); 403 if (success > 0) { 404 entry_point = elf_entry; 405 } else { 406 hwaddr ep; 407 int is_linux; 408 success = load_uimage(kernel_filename, &ep, NULL, &is_linux, 409 translate_phys_addr, cpu); 410 if (success > 0 && is_linux) { 411 entry_point = ep; 412 } else { 413 error_report("could not load kernel '%s'", 414 kernel_filename); 415 exit(EXIT_FAILURE); 416 } 417 } 418 if (entry_point != env->pc) { 419 uint8_t boot_be[] = { 420 0x60, 0x00, 0x08, /* j 1f */ 421 0x00, /* .literal_position */ 422 0x00, 0x00, 0x00, 0x00, /* .literal entry_pc */ 423 0x00, 0x00, 0x00, 0x00, /* .literal entry_a2 */ 424 /* 1: */ 425 0x10, 0xff, 0xfe, /* l32r a0, entry_pc */ 426 0x12, 0xff, 0xfe, /* l32r a2, entry_a2 */ 427 0x0a, 0x00, 0x00, /* jx a0 */ 428 }; 429 uint8_t boot_le[] = { 430 0x06, 0x02, 0x00, /* j 1f */ 431 0x00, /* .literal_position */ 432 0x00, 0x00, 0x00, 0x00, /* .literal entry_pc */ 433 0x00, 0x00, 0x00, 0x00, /* .literal entry_a2 */ 434 /* 1: */ 435 0x01, 0xfe, 0xff, /* l32r a0, entry_pc */ 436 0x21, 0xfe, 0xff, /* l32r a2, entry_a2 */ 437 0xa0, 0x00, 0x00, /* jx a0 */ 438 }; 439 const size_t boot_sz = TARGET_BIG_ENDIAN ? sizeof(boot_be) 440 : sizeof(boot_le); 441 uint8_t *boot = TARGET_BIG_ENDIAN ? boot_be : boot_le; 442 uint32_t entry_pc = tswap32(entry_point); 443 uint32_t entry_a2 = tswap32(tagptr); 444 445 memcpy(boot + 4, &entry_pc, sizeof(entry_pc)); 446 memcpy(boot + 8, &entry_a2, sizeof(entry_a2)); 447 cpu_physical_memory_write(env->pc, boot, boot_sz); 448 } 449 } else { 450 if (flash) { 451 MemoryRegion *flash_mr = pflash_cfi01_get_memory(flash); 452 MemoryRegion *flash_io = g_malloc(sizeof(*flash_io)); 453 uint32_t size = env->config->sysrom.location[0].size; 454 455 if (board->flash->size - board->flash->boot_base < size) { 456 size = board->flash->size - board->flash->boot_base; 457 } 458 459 memory_region_init_alias(flash_io, NULL, "xtfpga.flash", 460 flash_mr, board->flash->boot_base, size); 461 memory_region_add_subregion(system_memory, 462 env->config->sysrom.location[0].addr, 463 flash_io); 464 } else { 465 xtensa_create_memory_regions(&env->config->sysrom, "xtensa.sysrom", 466 system_memory); 467 } 468 } 469 } 470 471 #define XTFPGA_MMU_RESERVED_MEMORY_SIZE (128 * MiB) 472 473 static const hwaddr xtfpga_mmu_io[2] = { 474 0xf0000000, 475 }; 476 477 static const hwaddr xtfpga_nommu_io[2] = { 478 0x90000000, 479 0x70000000, 480 }; 481 482 static const XtfpgaFlashDesc lx60_flash = { 483 .base = 0x08000000, 484 .size = 0x00400000, 485 .sector_size = 0x10000, 486 }; 487 488 static void xtfpga_lx60_init(MachineState *machine) 489 { 490 static const XtfpgaBoardDesc lx60_board = { 491 .flash = &lx60_flash, 492 .sram_size = 0x20000, 493 .io = xtfpga_mmu_io, 494 }; 495 xtfpga_init(&lx60_board, machine); 496 } 497 498 static void xtfpga_lx60_nommu_init(MachineState *machine) 499 { 500 static const XtfpgaBoardDesc lx60_board = { 501 .flash = &lx60_flash, 502 .sram_size = 0x20000, 503 .io = xtfpga_nommu_io, 504 }; 505 xtfpga_init(&lx60_board, machine); 506 } 507 508 static const XtfpgaFlashDesc lx200_flash = { 509 .base = 0x08000000, 510 .size = 0x01000000, 511 .sector_size = 0x20000, 512 }; 513 514 static void xtfpga_lx200_init(MachineState *machine) 515 { 516 static const XtfpgaBoardDesc lx200_board = { 517 .flash = &lx200_flash, 518 .sram_size = 0x2000000, 519 .io = xtfpga_mmu_io, 520 }; 521 xtfpga_init(&lx200_board, machine); 522 } 523 524 static void xtfpga_lx200_nommu_init(MachineState *machine) 525 { 526 static const XtfpgaBoardDesc lx200_board = { 527 .flash = &lx200_flash, 528 .sram_size = 0x2000000, 529 .io = xtfpga_nommu_io, 530 }; 531 xtfpga_init(&lx200_board, machine); 532 } 533 534 static const XtfpgaFlashDesc ml605_flash = { 535 .base = 0x08000000, 536 .size = 0x01000000, 537 .sector_size = 0x20000, 538 }; 539 540 static void xtfpga_ml605_init(MachineState *machine) 541 { 542 static const XtfpgaBoardDesc ml605_board = { 543 .flash = &ml605_flash, 544 .sram_size = 0x2000000, 545 .io = xtfpga_mmu_io, 546 }; 547 xtfpga_init(&ml605_board, machine); 548 } 549 550 static void xtfpga_ml605_nommu_init(MachineState *machine) 551 { 552 static const XtfpgaBoardDesc ml605_board = { 553 .flash = &ml605_flash, 554 .sram_size = 0x2000000, 555 .io = xtfpga_nommu_io, 556 }; 557 xtfpga_init(&ml605_board, machine); 558 } 559 560 static const XtfpgaFlashDesc kc705_flash = { 561 .base = 0x00000000, 562 .size = 0x08000000, 563 .boot_base = 0x06000000, 564 .sector_size = 0x20000, 565 }; 566 567 static void xtfpga_kc705_init(MachineState *machine) 568 { 569 static const XtfpgaBoardDesc kc705_board = { 570 .flash = &kc705_flash, 571 .sram_size = 0x2000000, 572 .io = xtfpga_mmu_io, 573 }; 574 xtfpga_init(&kc705_board, machine); 575 } 576 577 static void xtfpga_kc705_nommu_init(MachineState *machine) 578 { 579 static const XtfpgaBoardDesc kc705_board = { 580 .flash = &kc705_flash, 581 .sram_size = 0x2000000, 582 .io = xtfpga_nommu_io, 583 }; 584 xtfpga_init(&kc705_board, machine); 585 } 586 587 static void xtfpga_lx60_class_init(ObjectClass *oc, void *data) 588 { 589 MachineClass *mc = MACHINE_CLASS(oc); 590 591 mc->desc = "lx60 EVB (" XTENSA_DEFAULT_CPU_MODEL ")"; 592 mc->init = xtfpga_lx60_init; 593 mc->max_cpus = 32; 594 mc->default_cpu_type = XTENSA_DEFAULT_CPU_TYPE; 595 mc->default_ram_size = 64 * MiB; 596 } 597 598 static const TypeInfo xtfpga_lx60_type = { 599 .name = MACHINE_TYPE_NAME("lx60"), 600 .parent = TYPE_MACHINE, 601 .class_init = xtfpga_lx60_class_init, 602 }; 603 604 static void xtfpga_lx60_nommu_class_init(ObjectClass *oc, void *data) 605 { 606 MachineClass *mc = MACHINE_CLASS(oc); 607 608 mc->desc = "lx60 noMMU EVB (" XTENSA_DEFAULT_CPU_NOMMU_MODEL ")"; 609 mc->init = xtfpga_lx60_nommu_init; 610 mc->max_cpus = 32; 611 mc->default_cpu_type = XTENSA_DEFAULT_CPU_NOMMU_TYPE; 612 mc->default_ram_size = 64 * MiB; 613 } 614 615 static const TypeInfo xtfpga_lx60_nommu_type = { 616 .name = MACHINE_TYPE_NAME("lx60-nommu"), 617 .parent = TYPE_MACHINE, 618 .class_init = xtfpga_lx60_nommu_class_init, 619 }; 620 621 static void xtfpga_lx200_class_init(ObjectClass *oc, void *data) 622 { 623 MachineClass *mc = MACHINE_CLASS(oc); 624 625 mc->desc = "lx200 EVB (" XTENSA_DEFAULT_CPU_MODEL ")"; 626 mc->init = xtfpga_lx200_init; 627 mc->max_cpus = 32; 628 mc->default_cpu_type = XTENSA_DEFAULT_CPU_TYPE; 629 mc->default_ram_size = 96 * MiB; 630 } 631 632 static const TypeInfo xtfpga_lx200_type = { 633 .name = MACHINE_TYPE_NAME("lx200"), 634 .parent = TYPE_MACHINE, 635 .class_init = xtfpga_lx200_class_init, 636 }; 637 638 static void xtfpga_lx200_nommu_class_init(ObjectClass *oc, void *data) 639 { 640 MachineClass *mc = MACHINE_CLASS(oc); 641 642 mc->desc = "lx200 noMMU EVB (" XTENSA_DEFAULT_CPU_NOMMU_MODEL ")"; 643 mc->init = xtfpga_lx200_nommu_init; 644 mc->max_cpus = 32; 645 mc->default_cpu_type = XTENSA_DEFAULT_CPU_NOMMU_TYPE; 646 mc->default_ram_size = 96 * MiB; 647 } 648 649 static const TypeInfo xtfpga_lx200_nommu_type = { 650 .name = MACHINE_TYPE_NAME("lx200-nommu"), 651 .parent = TYPE_MACHINE, 652 .class_init = xtfpga_lx200_nommu_class_init, 653 }; 654 655 static void xtfpga_ml605_class_init(ObjectClass *oc, void *data) 656 { 657 MachineClass *mc = MACHINE_CLASS(oc); 658 659 mc->desc = "ml605 EVB (" XTENSA_DEFAULT_CPU_MODEL ")"; 660 mc->init = xtfpga_ml605_init; 661 mc->max_cpus = 32; 662 mc->default_cpu_type = XTENSA_DEFAULT_CPU_TYPE; 663 mc->default_ram_size = 512 * MiB - XTFPGA_MMU_RESERVED_MEMORY_SIZE; 664 } 665 666 static const TypeInfo xtfpga_ml605_type = { 667 .name = MACHINE_TYPE_NAME("ml605"), 668 .parent = TYPE_MACHINE, 669 .class_init = xtfpga_ml605_class_init, 670 }; 671 672 static void xtfpga_ml605_nommu_class_init(ObjectClass *oc, void *data) 673 { 674 MachineClass *mc = MACHINE_CLASS(oc); 675 676 mc->desc = "ml605 noMMU EVB (" XTENSA_DEFAULT_CPU_NOMMU_MODEL ")"; 677 mc->init = xtfpga_ml605_nommu_init; 678 mc->max_cpus = 32; 679 mc->default_cpu_type = XTENSA_DEFAULT_CPU_NOMMU_TYPE; 680 mc->default_ram_size = 256 * MiB; 681 } 682 683 static const TypeInfo xtfpga_ml605_nommu_type = { 684 .name = MACHINE_TYPE_NAME("ml605-nommu"), 685 .parent = TYPE_MACHINE, 686 .class_init = xtfpga_ml605_nommu_class_init, 687 }; 688 689 static void xtfpga_kc705_class_init(ObjectClass *oc, void *data) 690 { 691 MachineClass *mc = MACHINE_CLASS(oc); 692 693 mc->desc = "kc705 EVB (" XTENSA_DEFAULT_CPU_MODEL ")"; 694 mc->init = xtfpga_kc705_init; 695 mc->max_cpus = 32; 696 mc->default_cpu_type = XTENSA_DEFAULT_CPU_TYPE; 697 mc->default_ram_size = 1 * GiB - XTFPGA_MMU_RESERVED_MEMORY_SIZE; 698 } 699 700 static const TypeInfo xtfpga_kc705_type = { 701 .name = MACHINE_TYPE_NAME("kc705"), 702 .parent = TYPE_MACHINE, 703 .class_init = xtfpga_kc705_class_init, 704 }; 705 706 static void xtfpga_kc705_nommu_class_init(ObjectClass *oc, void *data) 707 { 708 MachineClass *mc = MACHINE_CLASS(oc); 709 710 mc->desc = "kc705 noMMU EVB (" XTENSA_DEFAULT_CPU_NOMMU_MODEL ")"; 711 mc->init = xtfpga_kc705_nommu_init; 712 mc->max_cpus = 32; 713 mc->default_cpu_type = XTENSA_DEFAULT_CPU_NOMMU_TYPE; 714 mc->default_ram_size = 256 * MiB; 715 } 716 717 static const TypeInfo xtfpga_kc705_nommu_type = { 718 .name = MACHINE_TYPE_NAME("kc705-nommu"), 719 .parent = TYPE_MACHINE, 720 .class_init = xtfpga_kc705_nommu_class_init, 721 }; 722 723 static void xtfpga_machines_init(void) 724 { 725 type_register_static(&xtfpga_lx60_type); 726 type_register_static(&xtfpga_lx200_type); 727 type_register_static(&xtfpga_ml605_type); 728 type_register_static(&xtfpga_kc705_type); 729 type_register_static(&xtfpga_lx60_nommu_type); 730 type_register_static(&xtfpga_lx200_nommu_type); 731 type_register_static(&xtfpga_ml605_nommu_type); 732 type_register_static(&xtfpga_kc705_nommu_type); 733 } 734 735 type_init(xtfpga_machines_init) 736