diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2005-07-03 14:00:51 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2005-07-03 14:00:51 +0000 |
commit | d5295253b0d2baf190180b08c2a531021af91c99 (patch) | |
tree | 834843d9fb1fc969b2959a9e40f555f31c6d1aad /hw | |
parent | fb3444b86cd84c8c0750d1df189aa76beec8e1d8 (diff) | |
download | hqemu-d5295253b0d2baf190180b08c2a531021af91c99.zip hqemu-d5295253b0d2baf190180b08c2a531021af91c99.tar.gz |
VGA bios support for PowerPC
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1494 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw')
-rw-r--r-- | hw/mips_r4k.c | 2 | ||||
-rw-r--r-- | hw/pc.c | 2 | ||||
-rw-r--r-- | hw/ppc_chrp.c | 51 | ||||
-rw-r--r-- | hw/vga.c | 21 | ||||
-rw-r--r-- | hw/vga_int.h | 2 |
5 files changed, 60 insertions, 18 deletions
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index 9ce4a5a..ca135ac 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -242,7 +242,7 @@ void mips_r4k_init (int ram_size, int vga_ram_size, int boot_device, isa_pic = pic_init(pic_irq_request, cpu_single_env); serial_init(0x3f8, 4, serial_hds[0]); vga_initialize(NULL, ds, phys_ram_base + ram_size, ram_size, - vga_ram_size); + vga_ram_size, 0, 0); isa_ne2000_init(0x300, 9, &nd_table[0]); } @@ -547,7 +547,7 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device, } } else { vga_initialize(pci_bus, ds, phys_ram_base + ram_size, ram_size, - vga_ram_size); + vga_ram_size, 0, 0); } rtc_state = rtc_init(0x70, 8); diff --git a/hw/ppc_chrp.c b/hw/ppc_chrp.c index 515806f..5d20333 100644 --- a/hw/ppc_chrp.c +++ b/hw/ppc_chrp.c @@ -24,6 +24,7 @@ #include "vl.h" #define BIOS_FILENAME "ppc_rom.bin" +#define VGABIOS_FILENAME "video.x" #define NVRAM_SIZE 0x2000 #define KERNEL_LOAD_ADDR 0x01000000 @@ -232,12 +233,13 @@ static void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device, void *pic; m48t59_t *nvram; int PPC_io_memory, unin_memory; - int ret, linux_boot, i; - unsigned long bios_offset; + int linux_boot, i; + unsigned long bios_offset, vga_bios_offset; uint32_t kernel_base, kernel_size, initrd_base, initrd_size; ppc_def_t *def; PCIBus *pci_bus; const char *arch_name; + int vga_bios_size, bios_size; linux_boot = (kernel_filename != NULL); @@ -247,15 +249,36 @@ static void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device, /* allocate and load BIOS */ bios_offset = ram_size + vga_ram_size; snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME); - ret = load_image(buf, phys_ram_base + bios_offset); - if (ret != BIOS_SIZE) { - fprintf(stderr, "qemu: could not load PPC PREP bios '%s'\n", buf); + bios_size = load_image(buf, phys_ram_base + bios_offset); + if (bios_size < 0 || bios_size > BIOS_SIZE) { + fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n", buf); exit(1); } - cpu_register_physical_memory((uint32_t)(-BIOS_SIZE), - BIOS_SIZE, bios_offset | IO_MEM_ROM); - cpu_single_env->nip = 0xfffffffc; - + bios_size = (bios_size + 0xfff) & ~0xfff; + cpu_register_physical_memory((uint32_t)(-bios_size), + bios_size, bios_offset | IO_MEM_ROM); + + /* allocate and load VGA BIOS */ + vga_bios_offset = bios_offset + bios_size; + snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME); + vga_bios_size = load_image(buf, phys_ram_base + vga_bios_offset + 8); + if (vga_bios_size < 0) { + /* if no bios is present, we can still work */ + fprintf(stderr, "qemu: warning: could not load VGA bios '%s'\n", buf); + vga_bios_size = 0; + } else { + /* set a specific header (XXX: find real Apple format for NDRV + drivers) */ + phys_ram_base[vga_bios_offset] = 'N'; + phys_ram_base[vga_bios_offset + 1] = 'D'; + phys_ram_base[vga_bios_offset + 2] = 'R'; + phys_ram_base[vga_bios_offset + 3] = 'V'; + cpu_to_be32w((uint32_t *)(phys_ram_base + vga_bios_offset + 4), + vga_bios_size); + vga_bios_size += 8; + } + vga_bios_size = (vga_bios_size + 0xfff) & ~0xfff; + if (linux_boot) { kernel_base = KERNEL_LOAD_ADDR; /* now we can load the kernel */ @@ -321,8 +344,9 @@ static void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device, cpu_register_physical_memory(0xfe000000, 0x00200000, PPC_io_memory); /* init basic PC hardware */ - vga_initialize(pci_bus, ds, phys_ram_base + ram_size, ram_size, - vga_ram_size); + vga_initialize(pci_bus, ds, phys_ram_base + ram_size, + ram_size, vga_ram_size, + vga_bios_offset, vga_bios_size); pic = heathrow_pic_init(&heathrow_pic_mem_index); set_irq = heathrow_pic_set_irq; pci_set_pic(pci_bus, set_irq, pic); @@ -363,8 +387,9 @@ static void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device, cpu_register_physical_memory(0xf8000000, 0x00001000, unin_memory); /* init basic PC hardware */ - vga_initialize(pci_bus, ds, phys_ram_base + ram_size, ram_size, - vga_ram_size); + vga_initialize(pci_bus, ds, phys_ram_base + ram_size, + ram_size, vga_ram_size, + vga_bios_offset, vga_bios_size); pic = openpic_init(NULL, &openpic_mem_index, 1); set_irq = openpic_set_irq; pci_set_pic(pci_bus, set_irq, pic); @@ -1654,8 +1654,11 @@ static void vga_map(PCIDevice *pci_dev, int region_num, uint32_t addr, uint32_t size, int type) { VGAState *s = vga_state; - - cpu_register_physical_memory(addr, s->vram_size, s->vram_offset); + if (region_num == PCI_ROM_SLOT) { + cpu_register_physical_memory(addr, s->bios_size, s->bios_offset); + } else { + cpu_register_physical_memory(addr, s->vram_size, s->vram_offset); + } } void vga_common_init(VGAState *s, DisplayState *ds, uint8_t *vga_ram_base, @@ -1701,7 +1704,8 @@ void vga_common_init(VGAState *s, DisplayState *ds, uint8_t *vga_ram_base, int vga_initialize(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, - unsigned long vga_ram_offset, int vga_ram_size) + unsigned long vga_ram_offset, int vga_ram_size, + unsigned long vga_bios_offset, int vga_bios_size) { VGAState *s; @@ -1776,6 +1780,17 @@ int vga_initialize(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, /* XXX: vga_ram_size must be a power of two */ pci_register_io_region(d, 0, vga_ram_size, PCI_ADDRESS_SPACE_MEM_PREFETCH, vga_map); + if (vga_bios_size != 0) { + unsigned int bios_total_size; + s->bios_offset = vga_bios_offset; + s->bios_size = vga_bios_size; + /* must be a power of two */ + bios_total_size = 1; + while (bios_total_size < vga_bios_size) + bios_total_size <<= 1; + pci_register_io_region(d, PCI_ROM_SLOT, bios_total_size, + PCI_ADDRESS_SPACE_MEM_PREFETCH, vga_map); + } } else { #ifdef CONFIG_BOCHS_VBE /* XXX: use optimized standard vga accesses */ diff --git a/hw/vga_int.h b/hw/vga_int.h index 2e7fb30..621268d 100644 --- a/hw/vga_int.h +++ b/hw/vga_int.h @@ -78,6 +78,8 @@ uint8_t *vram_ptr; \ unsigned long vram_offset; \ unsigned int vram_size; \ + unsigned long bios_offset; \ + unsigned int bios_size; \ uint32_t latch; \ uint8_t sr_index; \ uint8_t sr[256]; \ |