uhci: tracing support
[qemu/opensuse.git] / hw / ppc_prep.c
blobdc9edd7bf50b13ee11636b7f4cb9f2e7993cdee5
1 /*
2 * QEMU PPC PREP hardware System Emulator
4 * Copyright (c) 2003-2007 Jocelyn Mayer
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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.
24 #include "hw.h"
25 #include "nvram.h"
26 #include "pc.h"
27 #include "fdc.h"
28 #include "net.h"
29 #include "sysemu.h"
30 #include "isa.h"
31 #include "pci.h"
32 #include "pci_host.h"
33 #include "ppc.h"
34 #include "boards.h"
35 #include "qemu-log.h"
36 #include "ide.h"
37 #include "loader.h"
38 #include "mc146818rtc.h"
39 #include "blockdev.h"
40 #include "exec-memory.h"
42 //#define HARD_DEBUG_PPC_IO
43 //#define DEBUG_PPC_IO
45 /* SMP is not enabled, for now */
46 #define MAX_CPUS 1
48 #define MAX_IDE_BUS 2
50 #define BIOS_SIZE (1024 * 1024)
51 #define BIOS_FILENAME "ppc_rom.bin"
52 #define KERNEL_LOAD_ADDR 0x01000000
53 #define INITRD_LOAD_ADDR 0x01800000
55 #if defined (HARD_DEBUG_PPC_IO) && !defined (DEBUG_PPC_IO)
56 #define DEBUG_PPC_IO
57 #endif
59 #if defined (HARD_DEBUG_PPC_IO)
60 #define PPC_IO_DPRINTF(fmt, ...) \
61 do { \
62 if (qemu_loglevel_mask(CPU_LOG_IOPORT)) { \
63 qemu_log("%s: " fmt, __func__ , ## __VA_ARGS__); \
64 } else { \
65 printf("%s : " fmt, __func__ , ## __VA_ARGS__); \
66 } \
67 } while (0)
68 #elif defined (DEBUG_PPC_IO)
69 #define PPC_IO_DPRINTF(fmt, ...) \
70 qemu_log_mask(CPU_LOG_IOPORT, fmt, ## __VA_ARGS__)
71 #else
72 #define PPC_IO_DPRINTF(fmt, ...) do { } while (0)
73 #endif
75 /* Constants for devices init */
76 static const int ide_iobase[2] = { 0x1f0, 0x170 };
77 static const int ide_iobase2[2] = { 0x3f6, 0x376 };
78 static const int ide_irq[2] = { 13, 13 };
80 #define NE2000_NB_MAX 6
82 static uint32_t ne2000_io[NE2000_NB_MAX] = { 0x300, 0x320, 0x340, 0x360, 0x280, 0x380 };
83 static int ne2000_irq[NE2000_NB_MAX] = { 9, 10, 11, 3, 4, 5 };
85 /* ISA IO ports bridge */
86 #define PPC_IO_BASE 0x80000000
88 /* PCI intack register */
89 /* Read-only register (?) */
90 static void PPC_intack_write (void *opaque, target_phys_addr_t addr,
91 uint64_t value, unsigned size)
93 #if 0
94 printf("%s: 0x" TARGET_FMT_plx " => 0x%08" PRIx64 "\n", __func__, addr,
95 value);
96 #endif
99 static uint64_t PPC_intack_read(void *opaque, target_phys_addr_t addr,
100 unsigned size)
102 uint32_t retval = 0;
104 if ((addr & 0xf) == 0)
105 retval = pic_read_irq(isa_pic);
106 #if 0
107 printf("%s: 0x" TARGET_FMT_plx " <= %08" PRIx32 "\n", __func__, addr,
108 retval);
109 #endif
111 return retval;
114 static const MemoryRegionOps PPC_intack_ops = {
115 .read = PPC_intack_read,
116 .write = PPC_intack_write,
117 .endianness = DEVICE_LITTLE_ENDIAN,
120 /* PowerPC control and status registers */
121 #if 0 // Not used
122 static struct {
123 /* IDs */
124 uint32_t veni_devi;
125 uint32_t revi;
126 /* Control and status */
127 uint32_t gcsr;
128 uint32_t xcfr;
129 uint32_t ct32;
130 uint32_t mcsr;
131 /* General purpose registers */
132 uint32_t gprg[6];
133 /* Exceptions */
134 uint32_t feen;
135 uint32_t fest;
136 uint32_t fema;
137 uint32_t fecl;
138 uint32_t eeen;
139 uint32_t eest;
140 uint32_t eecl;
141 uint32_t eeint;
142 uint32_t eemck0;
143 uint32_t eemck1;
144 /* Error diagnostic */
145 } XCSR;
147 static void PPC_XCSR_writeb (void *opaque,
148 target_phys_addr_t addr, uint32_t value)
150 printf("%s: 0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", __func__, addr,
151 value);
154 static void PPC_XCSR_writew (void *opaque,
155 target_phys_addr_t addr, uint32_t value)
157 printf("%s: 0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", __func__, addr,
158 value);
161 static void PPC_XCSR_writel (void *opaque,
162 target_phys_addr_t addr, uint32_t value)
164 printf("%s: 0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", __func__, addr,
165 value);
168 static uint32_t PPC_XCSR_readb (void *opaque, target_phys_addr_t addr)
170 uint32_t retval = 0;
172 printf("%s: 0x" TARGET_FMT_plx " <= %08" PRIx32 "\n", __func__, addr,
173 retval);
175 return retval;
178 static uint32_t PPC_XCSR_readw (void *opaque, target_phys_addr_t addr)
180 uint32_t retval = 0;
182 printf("%s: 0x" TARGET_FMT_plx " <= %08" PRIx32 "\n", __func__, addr,
183 retval);
185 return retval;
188 static uint32_t PPC_XCSR_readl (void *opaque, target_phys_addr_t addr)
190 uint32_t retval = 0;
192 printf("%s: 0x" TARGET_FMT_plx " <= %08" PRIx32 "\n", __func__, addr,
193 retval);
195 return retval;
198 static const MemoryRegionOps PPC_XCSR_ops = {
199 .old_mmio = {
200 .read = { PPC_XCSR_readb, PPC_XCSR_readw, PPC_XCSR_readl, },
201 .write = { PPC_XCSR_writeb, PPC_XCSR_writew, PPC_XCSR_writel, },
203 .endianness = DEVICE_LITTLE_ENDIAN,
206 #endif
208 /* Fake super-io ports for PREP platform (Intel 82378ZB) */
209 typedef struct sysctrl_t {
210 qemu_irq reset_irq;
211 M48t59State *nvram;
212 uint8_t state;
213 uint8_t syscontrol;
214 uint8_t fake_io[2];
215 int contiguous_map;
216 int endian;
217 } sysctrl_t;
219 enum {
220 STATE_HARDFILE = 0x01,
223 static sysctrl_t *sysctrl;
225 static void PREP_io_write (void *opaque, uint32_t addr, uint32_t val)
227 sysctrl_t *sysctrl = opaque;
229 PPC_IO_DPRINTF("0x%08" PRIx32 " => 0x%02" PRIx32 "\n", addr - PPC_IO_BASE,
230 val);
231 sysctrl->fake_io[addr - 0x0398] = val;
234 static uint32_t PREP_io_read (void *opaque, uint32_t addr)
236 sysctrl_t *sysctrl = opaque;
238 PPC_IO_DPRINTF("0x%08" PRIx32 " <= 0x%02" PRIx32 "\n", addr - PPC_IO_BASE,
239 sysctrl->fake_io[addr - 0x0398]);
240 return sysctrl->fake_io[addr - 0x0398];
243 static void PREP_io_800_writeb (void *opaque, uint32_t addr, uint32_t val)
245 sysctrl_t *sysctrl = opaque;
247 PPC_IO_DPRINTF("0x%08" PRIx32 " => 0x%02" PRIx32 "\n",
248 addr - PPC_IO_BASE, val);
249 switch (addr) {
250 case 0x0092:
251 /* Special port 92 */
252 /* Check soft reset asked */
253 if (val & 0x01) {
254 qemu_irq_raise(sysctrl->reset_irq);
255 } else {
256 qemu_irq_lower(sysctrl->reset_irq);
258 /* Check LE mode */
259 if (val & 0x02) {
260 sysctrl->endian = 1;
261 } else {
262 sysctrl->endian = 0;
264 break;
265 case 0x0800:
266 /* Motorola CPU configuration register : read-only */
267 break;
268 case 0x0802:
269 /* Motorola base module feature register : read-only */
270 break;
271 case 0x0803:
272 /* Motorola base module status register : read-only */
273 break;
274 case 0x0808:
275 /* Hardfile light register */
276 if (val & 1)
277 sysctrl->state |= STATE_HARDFILE;
278 else
279 sysctrl->state &= ~STATE_HARDFILE;
280 break;
281 case 0x0810:
282 /* Password protect 1 register */
283 if (sysctrl->nvram != NULL)
284 m48t59_toggle_lock(sysctrl->nvram, 1);
285 break;
286 case 0x0812:
287 /* Password protect 2 register */
288 if (sysctrl->nvram != NULL)
289 m48t59_toggle_lock(sysctrl->nvram, 2);
290 break;
291 case 0x0814:
292 /* L2 invalidate register */
293 // tlb_flush(first_cpu, 1);
294 break;
295 case 0x081C:
296 /* system control register */
297 sysctrl->syscontrol = val & 0x0F;
298 break;
299 case 0x0850:
300 /* I/O map type register */
301 sysctrl->contiguous_map = val & 0x01;
302 break;
303 default:
304 printf("ERROR: unaffected IO port write: %04" PRIx32
305 " => %02" PRIx32"\n", addr, val);
306 break;
310 static uint32_t PREP_io_800_readb (void *opaque, uint32_t addr)
312 sysctrl_t *sysctrl = opaque;
313 uint32_t retval = 0xFF;
315 switch (addr) {
316 case 0x0092:
317 /* Special port 92 */
318 retval = 0x00;
319 break;
320 case 0x0800:
321 /* Motorola CPU configuration register */
322 retval = 0xEF; /* MPC750 */
323 break;
324 case 0x0802:
325 /* Motorola Base module feature register */
326 retval = 0xAD; /* No ESCC, PMC slot neither ethernet */
327 break;
328 case 0x0803:
329 /* Motorola base module status register */
330 retval = 0xE0; /* Standard MPC750 */
331 break;
332 case 0x080C:
333 /* Equipment present register:
334 * no L2 cache
335 * no upgrade processor
336 * no cards in PCI slots
337 * SCSI fuse is bad
339 retval = 0x3C;
340 break;
341 case 0x0810:
342 /* Motorola base module extended feature register */
343 retval = 0x39; /* No USB, CF and PCI bridge. NVRAM present */
344 break;
345 case 0x0814:
346 /* L2 invalidate: don't care */
347 break;
348 case 0x0818:
349 /* Keylock */
350 retval = 0x00;
351 break;
352 case 0x081C:
353 /* system control register
354 * 7 - 6 / 1 - 0: L2 cache enable
356 retval = sysctrl->syscontrol;
357 break;
358 case 0x0823:
359 /* */
360 retval = 0x03; /* no L2 cache */
361 break;
362 case 0x0850:
363 /* I/O map type register */
364 retval = sysctrl->contiguous_map;
365 break;
366 default:
367 printf("ERROR: unaffected IO port: %04" PRIx32 " read\n", addr);
368 break;
370 PPC_IO_DPRINTF("0x%08" PRIx32 " <= 0x%02" PRIx32 "\n",
371 addr - PPC_IO_BASE, retval);
373 return retval;
376 static inline target_phys_addr_t prep_IO_address(sysctrl_t *sysctrl,
377 target_phys_addr_t addr)
379 if (sysctrl->contiguous_map == 0) {
380 /* 64 KB contiguous space for IOs */
381 addr &= 0xFFFF;
382 } else {
383 /* 8 MB non-contiguous space for IOs */
384 addr = (addr & 0x1F) | ((addr & 0x007FFF000) >> 7);
387 return addr;
390 static void PPC_prep_io_writeb (void *opaque, target_phys_addr_t addr,
391 uint32_t value)
393 sysctrl_t *sysctrl = opaque;
395 addr = prep_IO_address(sysctrl, addr);
396 cpu_outb(addr, value);
399 static uint32_t PPC_prep_io_readb (void *opaque, target_phys_addr_t addr)
401 sysctrl_t *sysctrl = opaque;
402 uint32_t ret;
404 addr = prep_IO_address(sysctrl, addr);
405 ret = cpu_inb(addr);
407 return ret;
410 static void PPC_prep_io_writew (void *opaque, target_phys_addr_t addr,
411 uint32_t value)
413 sysctrl_t *sysctrl = opaque;
415 addr = prep_IO_address(sysctrl, addr);
416 PPC_IO_DPRINTF("0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", addr, value);
417 cpu_outw(addr, value);
420 static uint32_t PPC_prep_io_readw (void *opaque, target_phys_addr_t addr)
422 sysctrl_t *sysctrl = opaque;
423 uint32_t ret;
425 addr = prep_IO_address(sysctrl, addr);
426 ret = cpu_inw(addr);
427 PPC_IO_DPRINTF("0x" TARGET_FMT_plx " <= 0x%08" PRIx32 "\n", addr, ret);
429 return ret;
432 static void PPC_prep_io_writel (void *opaque, target_phys_addr_t addr,
433 uint32_t value)
435 sysctrl_t *sysctrl = opaque;
437 addr = prep_IO_address(sysctrl, addr);
438 PPC_IO_DPRINTF("0x" TARGET_FMT_plx " => 0x%08" PRIx32 "\n", addr, value);
439 cpu_outl(addr, value);
442 static uint32_t PPC_prep_io_readl (void *opaque, target_phys_addr_t addr)
444 sysctrl_t *sysctrl = opaque;
445 uint32_t ret;
447 addr = prep_IO_address(sysctrl, addr);
448 ret = cpu_inl(addr);
449 PPC_IO_DPRINTF("0x" TARGET_FMT_plx " <= 0x%08" PRIx32 "\n", addr, ret);
451 return ret;
454 static const MemoryRegionOps PPC_prep_io_ops = {
455 .old_mmio = {
456 .read = { PPC_prep_io_readb, PPC_prep_io_readw, PPC_prep_io_readl },
457 .write = { PPC_prep_io_writeb, PPC_prep_io_writew, PPC_prep_io_writel },
459 .endianness = DEVICE_LITTLE_ENDIAN,
462 #define NVRAM_SIZE 0x2000
464 static void cpu_request_exit(void *opaque, int irq, int level)
466 CPUState *env = cpu_single_env;
468 if (env && level) {
469 cpu_exit(env);
473 /* PowerPC PREP hardware initialisation */
474 static void ppc_prep_init (ram_addr_t ram_size,
475 const char *boot_device,
476 const char *kernel_filename,
477 const char *kernel_cmdline,
478 const char *initrd_filename,
479 const char *cpu_model)
481 MemoryRegion *sysmem = get_system_memory();
482 CPUState *env = NULL;
483 char *filename;
484 nvram_t nvram;
485 M48t59State *m48t59;
486 MemoryRegion *PPC_io_memory = g_new(MemoryRegion, 1);
487 MemoryRegion *intack = g_new(MemoryRegion, 1);
488 #if 0
489 MemoryRegion *xcsr = g_new(MemoryRegion, 1);
490 #endif
491 int linux_boot, i, nb_nics1, bios_size;
492 MemoryRegion *ram = g_new(MemoryRegion, 1);
493 MemoryRegion *bios = g_new(MemoryRegion, 1);
494 uint32_t kernel_base, initrd_base;
495 long kernel_size, initrd_size;
496 DeviceState *dev;
497 SysBusDevice *sys;
498 PCIHostState *pcihost;
499 PCIBus *pci_bus;
500 PCIDevice *pci;
501 ISABus *isa_bus;
502 qemu_irq *cpu_exit_irq;
503 int ppc_boot_device;
504 DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
505 DriveInfo *fd[MAX_FD];
507 sysctrl = g_malloc0(sizeof(sysctrl_t));
509 linux_boot = (kernel_filename != NULL);
511 /* init CPUs */
512 if (cpu_model == NULL)
513 cpu_model = "602";
514 for (i = 0; i < smp_cpus; i++) {
515 env = cpu_init(cpu_model);
516 if (!env) {
517 fprintf(stderr, "Unable to find PowerPC CPU definition\n");
518 exit(1);
520 if (env->flags & POWERPC_FLAG_RTC_CLK) {
521 /* POWER / PowerPC 601 RTC clock frequency is 7.8125 MHz */
522 cpu_ppc_tb_init(env, 7812500UL);
523 } else {
524 /* Set time-base frequency to 100 Mhz */
525 cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
527 qemu_register_reset((QEMUResetHandler*)&cpu_reset, env);
530 /* allocate RAM */
531 memory_region_init_ram(ram, "ppc_prep.ram", ram_size);
532 vmstate_register_ram_global(ram);
533 memory_region_add_subregion(sysmem, 0, ram);
535 /* allocate and load BIOS */
536 memory_region_init_ram(bios, "ppc_prep.bios", BIOS_SIZE);
537 memory_region_set_readonly(bios, true);
538 memory_region_add_subregion(sysmem, (uint32_t)(-BIOS_SIZE), bios);
539 vmstate_register_ram_global(bios);
540 if (bios_name == NULL)
541 bios_name = BIOS_FILENAME;
542 filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
543 if (filename) {
544 bios_size = get_image_size(filename);
545 } else {
546 bios_size = -1;
548 if (bios_size > 0 && bios_size <= BIOS_SIZE) {
549 target_phys_addr_t bios_addr;
550 bios_size = (bios_size + 0xfff) & ~0xfff;
551 bios_addr = (uint32_t)(-bios_size);
552 bios_size = load_image_targphys(filename, bios_addr, bios_size);
554 if (bios_size < 0 || bios_size > BIOS_SIZE) {
555 hw_error("qemu: could not load PPC PREP bios '%s'\n", bios_name);
557 if (filename) {
558 g_free(filename);
561 if (linux_boot) {
562 kernel_base = KERNEL_LOAD_ADDR;
563 /* now we can load the kernel */
564 kernel_size = load_image_targphys(kernel_filename, kernel_base,
565 ram_size - kernel_base);
566 if (kernel_size < 0) {
567 hw_error("qemu: could not load kernel '%s'\n", kernel_filename);
568 exit(1);
570 /* load initrd */
571 if (initrd_filename) {
572 initrd_base = INITRD_LOAD_ADDR;
573 initrd_size = load_image_targphys(initrd_filename, initrd_base,
574 ram_size - initrd_base);
575 if (initrd_size < 0) {
576 hw_error("qemu: could not load initial ram disk '%s'\n",
577 initrd_filename);
579 } else {
580 initrd_base = 0;
581 initrd_size = 0;
583 ppc_boot_device = 'm';
584 } else {
585 kernel_base = 0;
586 kernel_size = 0;
587 initrd_base = 0;
588 initrd_size = 0;
589 ppc_boot_device = '\0';
590 /* For now, OHW cannot boot from the network. */
591 for (i = 0; boot_device[i] != '\0'; i++) {
592 if (boot_device[i] >= 'a' && boot_device[i] <= 'f') {
593 ppc_boot_device = boot_device[i];
594 break;
597 if (ppc_boot_device == '\0') {
598 fprintf(stderr, "No valid boot device for Mac99 machine\n");
599 exit(1);
603 if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
604 hw_error("Only 6xx bus is supported on PREP machine\n");
607 dev = qdev_create(NULL, "raven-pcihost");
608 sys = sysbus_from_qdev(dev);
609 pcihost = DO_UPCAST(PCIHostState, busdev, sys);
610 pcihost->address_space = get_system_memory();
611 qdev_init_nofail(dev);
612 object_property_add_child(object_get_root(), "raven", OBJECT(dev), NULL);
613 pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0");
614 if (pci_bus == NULL) {
615 fprintf(stderr, "Couldn't create PCI host controller.\n");
616 exit(1);
619 /* PCI -> ISA bridge */
620 pci = pci_create_simple(pci_bus, PCI_DEVFN(1, 0), "i82378");
621 cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
622 qdev_connect_gpio_out(&pci->qdev, 0,
623 first_cpu->irq_inputs[PPC6xx_INPUT_INT]);
624 qdev_connect_gpio_out(&pci->qdev, 1, *cpu_exit_irq);
625 sysbus_connect_irq(&pcihost->busdev, 0, qdev_get_gpio_in(&pci->qdev, 9));
626 sysbus_connect_irq(&pcihost->busdev, 1, qdev_get_gpio_in(&pci->qdev, 11));
627 sysbus_connect_irq(&pcihost->busdev, 2, qdev_get_gpio_in(&pci->qdev, 9));
628 sysbus_connect_irq(&pcihost->busdev, 3, qdev_get_gpio_in(&pci->qdev, 11));
629 isa_bus = DO_UPCAST(ISABus, qbus, qdev_get_child_bus(&pci->qdev, "isa.0"));
631 /* Register 8 MB of ISA IO space (needed for non-contiguous map) */
632 memory_region_init_io(PPC_io_memory, &PPC_prep_io_ops, sysctrl,
633 "ppc-io", 0x00800000);
634 memory_region_add_subregion(sysmem, 0x80000000, PPC_io_memory);
636 /* init basic PC hardware */
637 pci_vga_init(pci_bus);
639 if (serial_hds[0])
640 serial_isa_init(isa_bus, 0, serial_hds[0]);
641 nb_nics1 = nb_nics;
642 if (nb_nics1 > NE2000_NB_MAX)
643 nb_nics1 = NE2000_NB_MAX;
644 for(i = 0; i < nb_nics1; i++) {
645 if (nd_table[i].model == NULL) {
646 nd_table[i].model = g_strdup("ne2k_isa");
648 if (strcmp(nd_table[i].model, "ne2k_isa") == 0) {
649 isa_ne2000_init(isa_bus, ne2000_io[i], ne2000_irq[i],
650 &nd_table[i]);
651 } else {
652 pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL);
656 ide_drive_get(hd, MAX_IDE_BUS);
657 for(i = 0; i < MAX_IDE_BUS; i++) {
658 isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], ide_irq[i],
659 hd[2 * i],
660 hd[2 * i + 1]);
662 isa_create_simple(isa_bus, "i8042");
664 // SB16_init();
666 for(i = 0; i < MAX_FD; i++) {
667 fd[i] = drive_get(IF_FLOPPY, 0, i);
669 fdctrl_init_isa(isa_bus, fd);
671 /* Register fake IO ports for PREP */
672 sysctrl->reset_irq = first_cpu->irq_inputs[PPC6xx_INPUT_HRESET];
673 register_ioport_read(0x398, 2, 1, &PREP_io_read, sysctrl);
674 register_ioport_write(0x398, 2, 1, &PREP_io_write, sysctrl);
675 /* System control ports */
676 register_ioport_read(0x0092, 0x01, 1, &PREP_io_800_readb, sysctrl);
677 register_ioport_write(0x0092, 0x01, 1, &PREP_io_800_writeb, sysctrl);
678 register_ioport_read(0x0800, 0x52, 1, &PREP_io_800_readb, sysctrl);
679 register_ioport_write(0x0800, 0x52, 1, &PREP_io_800_writeb, sysctrl);
680 /* PCI intack location */
681 memory_region_init_io(intack, &PPC_intack_ops, NULL, "ppc-intack", 4);
682 memory_region_add_subregion(sysmem, 0xBFFFFFF0, intack);
683 /* PowerPC control and status register group */
684 #if 0
685 memory_region_init_io(xcsr, &PPC_XCSR_ops, NULL, "ppc-xcsr", 0x1000);
686 memory_region_add_subregion(sysmem, 0xFEFF0000, xcsr);
687 #endif
689 if (usb_enabled) {
690 pci_create_simple(pci_bus, -1, "pci-ohci");
693 m48t59 = m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 59);
694 if (m48t59 == NULL)
695 return;
696 sysctrl->nvram = m48t59;
698 /* Initialise NVRAM */
699 nvram.opaque = m48t59;
700 nvram.read_fn = &m48t59_read;
701 nvram.write_fn = &m48t59_write;
702 PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "PREP", ram_size, ppc_boot_device,
703 kernel_base, kernel_size,
704 kernel_cmdline,
705 initrd_base, initrd_size,
706 /* XXX: need an option to load a NVRAM image */
708 graphic_width, graphic_height, graphic_depth);
710 /* Special port to get debug messages from Open-Firmware */
711 register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);
714 static QEMUMachine prep_machine = {
715 .name = "prep",
716 .desc = "PowerPC PREP platform",
717 .init = ppc_prep_init,
718 .max_cpus = MAX_CPUS,
721 static void prep_machine_init(void)
723 qemu_register_machine(&prep_machine);
726 machine_init(prep_machine_init);