Revision d5295253 hw/ppc_chrp.c

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);

Also available in: Unified diff