Commit d5295253b0d2baf190180b08c2a531021af91c99
1 parent
fb3444b8
VGA bios support for PowerPC
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1494 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
8 changed files
with
65 additions
and
21 deletions
Makefile
@@ -59,7 +59,7 @@ install: all | @@ -59,7 +59,7 @@ install: all | ||
59 | mkdir -p "$(datadir)" | 59 | mkdir -p "$(datadir)" |
60 | install -m 644 pc-bios/bios.bin pc-bios/vgabios.bin \ | 60 | install -m 644 pc-bios/bios.bin pc-bios/vgabios.bin \ |
61 | pc-bios/vgabios-cirrus.bin \ | 61 | pc-bios/vgabios-cirrus.bin \ |
62 | - pc-bios/ppc_rom.bin \ | 62 | + pc-bios/ppc_rom.bin pc-bios/video.x \ |
63 | pc-bios/proll.elf \ | 63 | pc-bios/proll.elf \ |
64 | pc-bios/linux_boot.bin "$(datadir)" | 64 | pc-bios/linux_boot.bin "$(datadir)" |
65 | mkdir -p "$(docdir)" | 65 | mkdir -p "$(docdir)" |
@@ -121,6 +121,7 @@ tarbin: | @@ -121,6 +121,7 @@ tarbin: | ||
121 | $(datadir)/vgabios.bin \ | 121 | $(datadir)/vgabios.bin \ |
122 | $(datadir)/vgabios-cirrus.bin \ | 122 | $(datadir)/vgabios-cirrus.bin \ |
123 | $(datadir)/ppc_rom.bin \ | 123 | $(datadir)/ppc_rom.bin \ |
124 | + $(datadir)/video.x \ | ||
124 | $(datadir)/proll.elf \ | 125 | $(datadir)/proll.elf \ |
125 | $(datadir)/linux_boot.bin \ | 126 | $(datadir)/linux_boot.bin \ |
126 | $(docdir)/qemu-doc.html \ | 127 | $(docdir)/qemu-doc.html \ |
hw/mips_r4k.c
@@ -242,7 +242,7 @@ void mips_r4k_init (int ram_size, int vga_ram_size, int boot_device, | @@ -242,7 +242,7 @@ void mips_r4k_init (int ram_size, int vga_ram_size, int boot_device, | ||
242 | isa_pic = pic_init(pic_irq_request, cpu_single_env); | 242 | isa_pic = pic_init(pic_irq_request, cpu_single_env); |
243 | serial_init(0x3f8, 4, serial_hds[0]); | 243 | serial_init(0x3f8, 4, serial_hds[0]); |
244 | vga_initialize(NULL, ds, phys_ram_base + ram_size, ram_size, | 244 | vga_initialize(NULL, ds, phys_ram_base + ram_size, ram_size, |
245 | - vga_ram_size); | 245 | + vga_ram_size, 0, 0); |
246 | 246 | ||
247 | isa_ne2000_init(0x300, 9, &nd_table[0]); | 247 | isa_ne2000_init(0x300, 9, &nd_table[0]); |
248 | } | 248 | } |
hw/pc.c
@@ -547,7 +547,7 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device, | @@ -547,7 +547,7 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device, | ||
547 | } | 547 | } |
548 | } else { | 548 | } else { |
549 | vga_initialize(pci_bus, ds, phys_ram_base + ram_size, ram_size, | 549 | vga_initialize(pci_bus, ds, phys_ram_base + ram_size, ram_size, |
550 | - vga_ram_size); | 550 | + vga_ram_size, 0, 0); |
551 | } | 551 | } |
552 | 552 | ||
553 | rtc_state = rtc_init(0x70, 8); | 553 | rtc_state = rtc_init(0x70, 8); |
hw/ppc_chrp.c
@@ -24,6 +24,7 @@ | @@ -24,6 +24,7 @@ | ||
24 | #include "vl.h" | 24 | #include "vl.h" |
25 | 25 | ||
26 | #define BIOS_FILENAME "ppc_rom.bin" | 26 | #define BIOS_FILENAME "ppc_rom.bin" |
27 | +#define VGABIOS_FILENAME "video.x" | ||
27 | #define NVRAM_SIZE 0x2000 | 28 | #define NVRAM_SIZE 0x2000 |
28 | 29 | ||
29 | #define KERNEL_LOAD_ADDR 0x01000000 | 30 | #define KERNEL_LOAD_ADDR 0x01000000 |
@@ -232,12 +233,13 @@ static void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device, | @@ -232,12 +233,13 @@ static void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device, | ||
232 | void *pic; | 233 | void *pic; |
233 | m48t59_t *nvram; | 234 | m48t59_t *nvram; |
234 | int PPC_io_memory, unin_memory; | 235 | int PPC_io_memory, unin_memory; |
235 | - int ret, linux_boot, i; | ||
236 | - unsigned long bios_offset; | 236 | + int linux_boot, i; |
237 | + unsigned long bios_offset, vga_bios_offset; | ||
237 | uint32_t kernel_base, kernel_size, initrd_base, initrd_size; | 238 | uint32_t kernel_base, kernel_size, initrd_base, initrd_size; |
238 | ppc_def_t *def; | 239 | ppc_def_t *def; |
239 | PCIBus *pci_bus; | 240 | PCIBus *pci_bus; |
240 | const char *arch_name; | 241 | const char *arch_name; |
242 | + int vga_bios_size, bios_size; | ||
241 | 243 | ||
242 | linux_boot = (kernel_filename != NULL); | 244 | linux_boot = (kernel_filename != NULL); |
243 | 245 | ||
@@ -247,15 +249,36 @@ static void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device, | @@ -247,15 +249,36 @@ static void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device, | ||
247 | /* allocate and load BIOS */ | 249 | /* allocate and load BIOS */ |
248 | bios_offset = ram_size + vga_ram_size; | 250 | bios_offset = ram_size + vga_ram_size; |
249 | snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME); | 251 | snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME); |
250 | - ret = load_image(buf, phys_ram_base + bios_offset); | ||
251 | - if (ret != BIOS_SIZE) { | ||
252 | - fprintf(stderr, "qemu: could not load PPC PREP bios '%s'\n", buf); | 252 | + bios_size = load_image(buf, phys_ram_base + bios_offset); |
253 | + if (bios_size < 0 || bios_size > BIOS_SIZE) { | ||
254 | + fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n", buf); | ||
253 | exit(1); | 255 | exit(1); |
254 | } | 256 | } |
255 | - cpu_register_physical_memory((uint32_t)(-BIOS_SIZE), | ||
256 | - BIOS_SIZE, bios_offset | IO_MEM_ROM); | ||
257 | - cpu_single_env->nip = 0xfffffffc; | ||
258 | - | 257 | + bios_size = (bios_size + 0xfff) & ~0xfff; |
258 | + cpu_register_physical_memory((uint32_t)(-bios_size), | ||
259 | + bios_size, bios_offset | IO_MEM_ROM); | ||
260 | + | ||
261 | + /* allocate and load VGA BIOS */ | ||
262 | + vga_bios_offset = bios_offset + bios_size; | ||
263 | + snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME); | ||
264 | + vga_bios_size = load_image(buf, phys_ram_base + vga_bios_offset + 8); | ||
265 | + if (vga_bios_size < 0) { | ||
266 | + /* if no bios is present, we can still work */ | ||
267 | + fprintf(stderr, "qemu: warning: could not load VGA bios '%s'\n", buf); | ||
268 | + vga_bios_size = 0; | ||
269 | + } else { | ||
270 | + /* set a specific header (XXX: find real Apple format for NDRV | ||
271 | + drivers) */ | ||
272 | + phys_ram_base[vga_bios_offset] = 'N'; | ||
273 | + phys_ram_base[vga_bios_offset + 1] = 'D'; | ||
274 | + phys_ram_base[vga_bios_offset + 2] = 'R'; | ||
275 | + phys_ram_base[vga_bios_offset + 3] = 'V'; | ||
276 | + cpu_to_be32w((uint32_t *)(phys_ram_base + vga_bios_offset + 4), | ||
277 | + vga_bios_size); | ||
278 | + vga_bios_size += 8; | ||
279 | + } | ||
280 | + vga_bios_size = (vga_bios_size + 0xfff) & ~0xfff; | ||
281 | + | ||
259 | if (linux_boot) { | 282 | if (linux_boot) { |
260 | kernel_base = KERNEL_LOAD_ADDR; | 283 | kernel_base = KERNEL_LOAD_ADDR; |
261 | /* now we can load the kernel */ | 284 | /* 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, | @@ -321,8 +344,9 @@ static void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device, | ||
321 | cpu_register_physical_memory(0xfe000000, 0x00200000, PPC_io_memory); | 344 | cpu_register_physical_memory(0xfe000000, 0x00200000, PPC_io_memory); |
322 | 345 | ||
323 | /* init basic PC hardware */ | 346 | /* init basic PC hardware */ |
324 | - vga_initialize(pci_bus, ds, phys_ram_base + ram_size, ram_size, | ||
325 | - vga_ram_size); | 347 | + vga_initialize(pci_bus, ds, phys_ram_base + ram_size, |
348 | + ram_size, vga_ram_size, | ||
349 | + vga_bios_offset, vga_bios_size); | ||
326 | pic = heathrow_pic_init(&heathrow_pic_mem_index); | 350 | pic = heathrow_pic_init(&heathrow_pic_mem_index); |
327 | set_irq = heathrow_pic_set_irq; | 351 | set_irq = heathrow_pic_set_irq; |
328 | pci_set_pic(pci_bus, set_irq, pic); | 352 | 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, | @@ -363,8 +387,9 @@ static void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device, | ||
363 | cpu_register_physical_memory(0xf8000000, 0x00001000, unin_memory); | 387 | cpu_register_physical_memory(0xf8000000, 0x00001000, unin_memory); |
364 | 388 | ||
365 | /* init basic PC hardware */ | 389 | /* init basic PC hardware */ |
366 | - vga_initialize(pci_bus, ds, phys_ram_base + ram_size, ram_size, | ||
367 | - vga_ram_size); | 390 | + vga_initialize(pci_bus, ds, phys_ram_base + ram_size, |
391 | + ram_size, vga_ram_size, | ||
392 | + vga_bios_offset, vga_bios_size); | ||
368 | pic = openpic_init(NULL, &openpic_mem_index, 1); | 393 | pic = openpic_init(NULL, &openpic_mem_index, 1); |
369 | set_irq = openpic_set_irq; | 394 | set_irq = openpic_set_irq; |
370 | pci_set_pic(pci_bus, set_irq, pic); | 395 | pci_set_pic(pci_bus, set_irq, pic); |
hw/vga.c
@@ -1654,8 +1654,11 @@ static void vga_map(PCIDevice *pci_dev, int region_num, | @@ -1654,8 +1654,11 @@ static void vga_map(PCIDevice *pci_dev, int region_num, | ||
1654 | uint32_t addr, uint32_t size, int type) | 1654 | uint32_t addr, uint32_t size, int type) |
1655 | { | 1655 | { |
1656 | VGAState *s = vga_state; | 1656 | VGAState *s = vga_state; |
1657 | - | ||
1658 | - cpu_register_physical_memory(addr, s->vram_size, s->vram_offset); | 1657 | + if (region_num == PCI_ROM_SLOT) { |
1658 | + cpu_register_physical_memory(addr, s->bios_size, s->bios_offset); | ||
1659 | + } else { | ||
1660 | + cpu_register_physical_memory(addr, s->vram_size, s->vram_offset); | ||
1661 | + } | ||
1659 | } | 1662 | } |
1660 | 1663 | ||
1661 | void vga_common_init(VGAState *s, DisplayState *ds, uint8_t *vga_ram_base, | 1664 | 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, | @@ -1701,7 +1704,8 @@ void vga_common_init(VGAState *s, DisplayState *ds, uint8_t *vga_ram_base, | ||
1701 | 1704 | ||
1702 | 1705 | ||
1703 | int vga_initialize(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, | 1706 | int vga_initialize(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, |
1704 | - unsigned long vga_ram_offset, int vga_ram_size) | 1707 | + unsigned long vga_ram_offset, int vga_ram_size, |
1708 | + unsigned long vga_bios_offset, int vga_bios_size) | ||
1705 | { | 1709 | { |
1706 | VGAState *s; | 1710 | VGAState *s; |
1707 | 1711 | ||
@@ -1776,6 +1780,17 @@ int vga_initialize(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, | @@ -1776,6 +1780,17 @@ int vga_initialize(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, | ||
1776 | /* XXX: vga_ram_size must be a power of two */ | 1780 | /* XXX: vga_ram_size must be a power of two */ |
1777 | pci_register_io_region(d, 0, vga_ram_size, | 1781 | pci_register_io_region(d, 0, vga_ram_size, |
1778 | PCI_ADDRESS_SPACE_MEM_PREFETCH, vga_map); | 1782 | PCI_ADDRESS_SPACE_MEM_PREFETCH, vga_map); |
1783 | + if (vga_bios_size != 0) { | ||
1784 | + unsigned int bios_total_size; | ||
1785 | + s->bios_offset = vga_bios_offset; | ||
1786 | + s->bios_size = vga_bios_size; | ||
1787 | + /* must be a power of two */ | ||
1788 | + bios_total_size = 1; | ||
1789 | + while (bios_total_size < vga_bios_size) | ||
1790 | + bios_total_size <<= 1; | ||
1791 | + pci_register_io_region(d, PCI_ROM_SLOT, bios_total_size, | ||
1792 | + PCI_ADDRESS_SPACE_MEM_PREFETCH, vga_map); | ||
1793 | + } | ||
1779 | } else { | 1794 | } else { |
1780 | #ifdef CONFIG_BOCHS_VBE | 1795 | #ifdef CONFIG_BOCHS_VBE |
1781 | /* XXX: use optimized standard vga accesses */ | 1796 | /* XXX: use optimized standard vga accesses */ |
hw/vga_int.h
@@ -78,6 +78,8 @@ | @@ -78,6 +78,8 @@ | ||
78 | uint8_t *vram_ptr; \ | 78 | uint8_t *vram_ptr; \ |
79 | unsigned long vram_offset; \ | 79 | unsigned long vram_offset; \ |
80 | unsigned int vram_size; \ | 80 | unsigned int vram_size; \ |
81 | + unsigned long bios_offset; \ | ||
82 | + unsigned int bios_size; \ | ||
81 | uint32_t latch; \ | 83 | uint32_t latch; \ |
82 | uint8_t sr_index; \ | 84 | uint8_t sr_index; \ |
83 | uint8_t sr[256]; \ | 85 | uint8_t sr[256]; \ |
pc-bios/video.x
0 → 100644
No preview for this file type
vl.h
@@ -137,7 +137,7 @@ extern int win2k_install_hack; | @@ -137,7 +137,7 @@ extern int win2k_install_hack; | ||
137 | 137 | ||
138 | /* XXX: make it dynamic */ | 138 | /* XXX: make it dynamic */ |
139 | #if defined (TARGET_PPC) | 139 | #if defined (TARGET_PPC) |
140 | -#define BIOS_SIZE (512 * 1024) | 140 | +#define BIOS_SIZE ((512 + 32) * 1024) |
141 | #elif defined(TARGET_MIPS) | 141 | #elif defined(TARGET_MIPS) |
142 | #define BIOS_SIZE (128 * 1024) | 142 | #define BIOS_SIZE (128 * 1024) |
143 | #else | 143 | #else |
@@ -596,7 +596,8 @@ static inline void dpy_resize(DisplayState *s, int w, int h) | @@ -596,7 +596,8 @@ static inline void dpy_resize(DisplayState *s, int w, int h) | ||
596 | } | 596 | } |
597 | 597 | ||
598 | int vga_initialize(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, | 598 | int vga_initialize(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, |
599 | - unsigned long vga_ram_offset, int vga_ram_size); | 599 | + unsigned long vga_ram_offset, int vga_ram_size, |
600 | + unsigned long vga_bios_offset, int vga_bios_size); | ||
600 | void vga_update_display(void); | 601 | void vga_update_display(void); |
601 | void vga_invalidate_display(void); | 602 | void vga_invalidate_display(void); |
602 | void vga_screen_dump(const char *filename); | 603 | void vga_screen_dump(const char *filename); |