Revision d5295253

b/Makefile
59 59
	mkdir -p "$(datadir)"
60 60
	install -m 644 pc-bios/bios.bin pc-bios/vgabios.bin \
61 61
                       pc-bios/vgabios-cirrus.bin \
62
                       pc-bios/ppc_rom.bin \
62
                       pc-bios/ppc_rom.bin pc-bios/video.x \
63 63
                       pc-bios/proll.elf \
64 64
                       pc-bios/linux_boot.bin "$(datadir)"
65 65
	mkdir -p "$(docdir)"
......
121 121
	$(datadir)/vgabios.bin \
122 122
	$(datadir)/vgabios-cirrus.bin \
123 123
	$(datadir)/ppc_rom.bin \
124
	$(datadir)/video.x \
124 125
	$(datadir)/proll.elf \
125 126
	$(datadir)/linux_boot.bin \
126 127
	$(docdir)/qemu-doc.html \
b/hw/mips_r4k.c
242 242
    isa_pic = pic_init(pic_irq_request, cpu_single_env);
243 243
    serial_init(0x3f8, 4, serial_hds[0]);
244 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 247
    isa_ne2000_init(0x300, 9, &nd_table[0]);
248 248
}
b/hw/pc.c
547 547
        }
548 548
    } else {
549 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 553
    rtc_state = rtc_init(0x70, 8);
b/hw/ppc_chrp.c
24 24
#include "vl.h"
25 25

  
26 26
#define BIOS_FILENAME "ppc_rom.bin"
27
#define VGABIOS_FILENAME "video.x"
27 28
#define NVRAM_SIZE        0x2000
28 29

  
29 30
#define KERNEL_LOAD_ADDR 0x01000000
......
232 233
    void *pic;
233 234
    m48t59_t *nvram;
234 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 238
    uint32_t kernel_base, kernel_size, initrd_base, initrd_size;
238 239
    ppc_def_t *def;
239 240
    PCIBus *pci_bus;
240 241
    const char *arch_name;
242
    int vga_bios_size, bios_size;
241 243

  
242 244
    linux_boot = (kernel_filename != NULL);
243 245

  
......
247 249
    /* allocate and load BIOS */
248 250
    bios_offset = ram_size + vga_ram_size;
249 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 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 282
    if (linux_boot) {
260 283
        kernel_base = KERNEL_LOAD_ADDR;
261 284
        /* now we can load the kernel */
......
321 344
        cpu_register_physical_memory(0xfe000000, 0x00200000, PPC_io_memory);
322 345
        
323 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 350
        pic = heathrow_pic_init(&heathrow_pic_mem_index);
327 351
        set_irq = heathrow_pic_set_irq;
328 352
        pci_set_pic(pci_bus, set_irq, pic);
......
363 387
        cpu_register_physical_memory(0xf8000000, 0x00001000, unin_memory);
364 388

  
365 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 393
        pic = openpic_init(NULL, &openpic_mem_index, 1);
369 394
        set_irq = openpic_set_irq;
370 395
        pci_set_pic(pci_bus, set_irq, pic);
b/hw/vga.c
1654 1654
                    uint32_t addr, uint32_t size, int type)
1655 1655
{
1656 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 1664
void vga_common_init(VGAState *s, DisplayState *ds, uint8_t *vga_ram_base, 
......
1701 1704

  
1702 1705

  
1703 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 1710
    VGAState *s;
1707 1711

  
......
1776 1780
        /* XXX: vga_ram_size must be a power of two */
1777 1781
        pci_register_io_region(d, 0, vga_ram_size, 
1778 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 1794
    } else {
1780 1795
#ifdef CONFIG_BOCHS_VBE
1781 1796
        /* XXX: use optimized standard vga accesses */
b/hw/vga_int.h
78 78
    uint8_t *vram_ptr;                                                  \
79 79
    unsigned long vram_offset;                                          \
80 80
    unsigned int vram_size;                                             \
81
    unsigned long bios_offset;                                          \
82
    unsigned int bios_size;                                             \
81 83
    uint32_t latch;                                                     \
82 84
    uint8_t sr_index;                                                   \
83 85
    uint8_t sr[256];                                                    \
b/vl.h
137 137

  
138 138
/* XXX: make it dynamic */
139 139
#if defined (TARGET_PPC)
140
#define BIOS_SIZE (512 * 1024)
140
#define BIOS_SIZE ((512 + 32) * 1024)
141 141
#elif defined(TARGET_MIPS)
142 142
#define BIOS_SIZE (128 * 1024)
143 143
#else
......
596 596
}
597 597

  
598 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 601
void vga_update_display(void);
601 602
void vga_invalidate_display(void);
602 603
void vga_screen_dump(const char *filename);

Also available in: Unified diff