From d5295253b0d2baf190180b08c2a531021af91c99 Mon Sep 17 00:00:00 2001 From: bellard Date: Sun, 3 Jul 2005 14:00:51 +0000 Subject: [PATCH] VGA bios support for PowerPC git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1494 c046a42c-6fe2-441c-8c8c-71466251a162 --- Makefile | 3 ++- hw/mips_r4k.c | 2 +- hw/pc.c | 2 +- hw/ppc_chrp.c | 51 ++++++++++++++++++++++++++++++++++++------------ hw/vga.c | 21 +++++++++++++++++--- hw/vga_int.h | 2 ++ pc-bios/video.x | Bin 0 -> 12192 bytes vl.h | 5 +++-- 8 files changed, 65 insertions(+), 21 deletions(-) create mode 100644 pc-bios/video.x diff --git a/Makefile b/Makefile index 11b38d15f1..74b1a94eb9 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ install: all mkdir -p "$(datadir)" install -m 644 pc-bios/bios.bin pc-bios/vgabios.bin \ pc-bios/vgabios-cirrus.bin \ - pc-bios/ppc_rom.bin \ + pc-bios/ppc_rom.bin pc-bios/video.x \ pc-bios/proll.elf \ pc-bios/linux_boot.bin "$(datadir)" mkdir -p "$(docdir)" @@ -121,6 +121,7 @@ tarbin: $(datadir)/vgabios.bin \ $(datadir)/vgabios-cirrus.bin \ $(datadir)/ppc_rom.bin \ + $(datadir)/video.x \ $(datadir)/proll.elf \ $(datadir)/linux_boot.bin \ $(docdir)/qemu-doc.html \ diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index 9ce4a5ac94..ca135ac39b 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]); } diff --git a/hw/pc.c b/hw/pc.c index 696c9192c9..29037db7b5 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -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 515806fbb5..5d20333d73 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); diff --git a/hw/vga.c b/hw/vga.c index 2c425ffe9b..49e5b211f9 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -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 2e7fb30efb..621268de4c 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]; \ diff --git a/pc-bios/video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$8$+e-v7tE$=#T9fn zFIiEu6f%B0+CcDDI8^y9x87E9`(NInRW@yGZi#K$+}gI~{`RdMom~%f#}nJO??~=^ zkoCVju6ps3nx)IWTU&Q`eZ%s5Ry3}>cU5HdeQVaP`yP+0x@UDm!y>ND9YERt&B~l| zjN6xGY&KjY#u+I7%j4&8o97z4jGK#iQgQ|b`%aXzj=GI=!r#jN-#Es721Wkg{rw-@ C=6}@y literal 0 HcmV?d00001 diff --git a/vl.h b/vl.h index 6f6aba75b8..85d0cf4733 100644 --- a/vl.h +++ b/vl.h @@ -137,7 +137,7 @@ extern int win2k_install_hack; /* XXX: make it dynamic */ #if defined (TARGET_PPC) -#define BIOS_SIZE (512 * 1024) +#define BIOS_SIZE ((512 + 32) * 1024) #elif defined(TARGET_MIPS) #define BIOS_SIZE (128 * 1024) #else @@ -596,7 +596,8 @@ static inline void dpy_resize(DisplayState *s, int w, int h) } 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); void vga_update_display(void); void vga_invalidate_display(void); void vga_screen_dump(const char *filename);