Revision ae0bfb79

b/Makefile
176 176

  
177 177
ifdef INSTALL_BLOBS
178 178
BLOBS=bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \
179
video.x openbios-sparc32 openbios-sparc64 openbios-ppc \
179
openbios-sparc32 openbios-sparc64 openbios-ppc \
180 180
gpxe-eepro100-80861209.rom \
181 181
gpxe-eepro100-80861229.rom \
182 182
pxe-e1000.bin \
......
323 323
	$(datadir)/vgabios.bin \
324 324
	$(datadir)/vgabios-cirrus.bin \
325 325
	$(datadir)/ppc_rom.bin \
326
	$(datadir)/video.x \
327 326
	$(datadir)/openbios-sparc32 \
328 327
	$(datadir)/openbios-sparc64 \
329 328
	$(datadir)/openbios-ppc \
b/configure
3084 3084
    FILES="Makefile tests/Makefile"
3085 3085
    FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
3086 3086
    FILES="$FILES tests/test-mmap.c"
3087
    FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps pc-bios/video.x"
3087
    FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
3088 3088
    FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
3089 3089
    for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
3090 3090
        FILES="$FILES pc-bios/`basename $bios_file`"
b/hw/ppc_mac.h
30 30

  
31 31
#define BIOS_SIZE     (1024 * 1024)
32 32
#define BIOS_FILENAME "ppc_rom.bin"
33
#define VGABIOS_FILENAME "video.x"
34 33
#define NVRAM_SIZE        0x2000
35 34
#define PROM_FILENAME    "openbios-ppc"
36 35
#define PROM_ADDR         0xfff00000
b/hw/ppc_newworld.c
69 69
#include "blockdev.h"
70 70

  
71 71
#define MAX_IDE_BUS 2
72
#define VGA_BIOS_SIZE 65536
73 72
#define CFG_ADDR 0xf0000510
74 73

  
75 74
/* debug UniNorth */
......
134 133
    qemu_irq *pic, **openpic_irqs;
135 134
    int unin_memory;
136 135
    int linux_boot, i;
137
    ram_addr_t ram_offset, bios_offset, vga_bios_offset;
136
    ram_addr_t ram_offset, bios_offset;
138 137
    uint32_t kernel_base, initrd_base;
139 138
    long kernel_size, initrd_size;
140 139
    PCIBus *pci_bus;
141 140
    MacIONVRAMState *nvr;
142 141
    int nvram_mem_index;
143
    int vga_bios_size, bios_size;
142
    int bios_size;
144 143
    int pic_mem_index, dbdma_mem_index, cuda_mem_index, escc_mem_index;
145 144
    int ide_mem_index[3];
146 145
    int ppc_boot_device;
147 146
    DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
148 147
    void *fw_cfg;
149 148
    void *dbdma;
150
    uint8_t *vga_bios_ptr;
151 149
    int machine_arch;
152 150

  
153 151
    linux_boot = (kernel_filename != NULL);
......
167 165
        }
168 166
        /* Set time-base frequency to 100 Mhz */
169 167
        cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
170
#if 0
171
        env->osi_call = vga_osi_call;
172
#endif
173 168
        qemu_register_reset((QEMUResetHandler*)&cpu_reset, env);
174 169
        envs[i] = env;
175 170
    }
......
199 194
        exit(1);
200 195
    }
201 196

  
202
    /* allocate and load VGA BIOS */
203
    vga_bios_offset = qemu_ram_alloc(NULL, "ppc_core99.vbios", VGA_BIOS_SIZE);
204
    vga_bios_ptr = qemu_get_ram_ptr(vga_bios_offset);
205
    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, VGABIOS_FILENAME);
206
    if (filename) {
207
        vga_bios_size = load_image(filename, vga_bios_ptr + 8);
208
        qemu_free(filename);
209
    } else {
210
        vga_bios_size = -1;
211
    }
212
    if (vga_bios_size < 0) {
213
        /* if no bios is present, we can still work */
214
        fprintf(stderr, "qemu: warning: could not load VGA bios '%s'\n",
215
                VGABIOS_FILENAME);
216
        vga_bios_size = 0;
217
    } else {
218
        /* set a specific header (XXX: find real Apple format for NDRV
219
           drivers) */
220
        vga_bios_ptr[0] = 'N';
221
        vga_bios_ptr[1] = 'D';
222
        vga_bios_ptr[2] = 'R';
223
        vga_bios_ptr[3] = 'V';
224
        cpu_to_be32w((uint32_t *)(vga_bios_ptr + 4), vga_bios_size);
225
        vga_bios_size += 8;
226

  
227
        /* Round to page boundary */
228
        vga_bios_size = (vga_bios_size + TARGET_PAGE_SIZE - 1) &
229
            TARGET_PAGE_MASK;
230
    }
231

  
232 197
    if (linux_boot) {
233 198
        uint64_t lowaddr = 0;
234 199
        int bswap_needed;
......
352 317
        machine_arch = ARCH_MAC99;
353 318
    }
354 319
    /* init basic PC hardware */
355
    pci_vga_init(pci_bus, vga_bios_offset, vga_bios_size);
320
    pci_vga_init(pci_bus, 0, 0);
356 321

  
357 322
    escc_mem_index = escc_init(0x80013000, pic[0x25], pic[0x24],
358 323
                               serial_hds[0], serial_hds[1], ESCC_CLOCK, 4);
b/hw/ppc_oldworld.c
1

  
1 2
/*
2 3
 * QEMU OldWorld PowerMac (currently ~G3 Beige) hardware System Emulator
3 4
 *
......
44 45
#include "blockdev.h"
45 46

  
46 47
#define MAX_IDE_BUS 2
47
#define VGA_BIOS_SIZE 65536
48 48
#define CFG_ADDR 0xf0000510
49 49

  
50
/* temporary frame buffer OSI calls for the video.x driver. The right
51
   solution is to modify the driver to use VGA PCI I/Os */
52
/* XXX: to be removed. This is no way related to emulation */
53
static int vga_osi_call (CPUState *env)
54
{
55
    static int vga_vbl_enabled;
56
    int linesize;
57

  
58
#if 0
59
    printf("osi_call R5=%016" PRIx64 "\n", ppc_dump_gpr(env, 5));
60
#endif
61

  
62
    /* same handler as PearPC, coming from the original MOL video
63
       driver. */
64
    switch(env->gpr[5]) {
65
    case 4:
66
        break;
67
    case 28: /* set_vmode */
68
        if (env->gpr[6] != 1 || env->gpr[7] != 0)
69
            env->gpr[3] = 1;
70
        else
71
            env->gpr[3] = 0;
72
        break;
73
    case 29: /* get_vmode_info */
74
        if (env->gpr[6] != 0) {
75
            if (env->gpr[6] != 1 || env->gpr[7] != 0) {
76
                env->gpr[3] = 1;
77
                break;
78
            }
79
        }
80
        env->gpr[3] = 0;
81
        env->gpr[4] = (1 << 16) | 1; /* num_vmodes, cur_vmode */
82
        env->gpr[5] = (1 << 16) | 0; /* num_depths, cur_depth_mode */
83
        env->gpr[6] = (graphic_width << 16) | graphic_height; /* w, h */
84
        env->gpr[7] = 85 << 16; /* refresh rate */
85
        env->gpr[8] = (graphic_depth + 7) & ~7; /* depth (round to byte) */
86
        linesize = ((graphic_depth + 7) >> 3) * graphic_width;
87
        linesize = (linesize + 3) & ~3;
88
        env->gpr[9] = (linesize << 16) | 0; /* row_bytes, offset */
89
        break;
90
    case 31: /* set_video power */
91
        env->gpr[3] = 0;
92
        break;
93
    case 39: /* video_ctrl */
94
        if (env->gpr[6] == 0 || env->gpr[6] == 1)
95
            vga_vbl_enabled = env->gpr[6];
96
        env->gpr[3] = 0;
97
        break;
98
    case 47:
99
        break;
100
    case 59: /* set_color */
101
        /* R6 = index, R7 = RGB */
102
        env->gpr[3] = 0;
103
        break;
104
    case 64: /* get color */
105
        /* R6 = index */
106
        env->gpr[3] = 0;
107
        break;
108
    case 116: /* set hwcursor */
109
        /* R6 = x, R7 = y, R8 = visible, R9 = data */
110
        break;
111
    default:
112
        fprintf(stderr, "unsupported OSI call R5=%016" PRIx64 "\n",
113
                ppc_dump_gpr(env, 5));
114
        break;
115
    }
116

  
117
    return 1; /* osi_call handled */
118
}
119

  
120 50
static int fw_cfg_boot_set(void *opaque, const char *boot_device)
121 51
{
122 52
    fw_cfg_add_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]);
......
140 70
    char *filename;
141 71
    qemu_irq *pic, **heathrow_irqs;
142 72
    int linux_boot, i;
143
    ram_addr_t ram_offset, bios_offset, vga_bios_offset;
73
    ram_addr_t ram_offset, bios_offset;
144 74
    uint32_t kernel_base, initrd_base;
145 75
    int32_t kernel_size, initrd_size;
146 76
    PCIBus *pci_bus;
147 77
    MacIONVRAMState *nvr;
148
    int vga_bios_size, bios_size;
78
    int bios_size;
149 79
    int pic_mem_index, nvram_mem_index, dbdma_mem_index, cuda_mem_index;
150 80
    int escc_mem_index, ide_mem_index[2];
151 81
    uint16_t ppc_boot_device;
152 82
    DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
153 83
    void *fw_cfg;
154 84
    void *dbdma;
155
    uint8_t *vga_bios_ptr;
156 85

  
157 86
    linux_boot = (kernel_filename != NULL);
158 87

  
......
167 96
        }
168 97
        /* Set time-base frequency to 16.6 Mhz */
169 98
        cpu_ppc_tb_init(env,  16600000UL);
170
        env->osi_call = vga_osi_call;
171 99
        qemu_register_reset((QEMUResetHandler*)&cpu_reset, env);
172 100
        envs[i] = env;
173 101
    }
......
203 131
        exit(1);
204 132
    }
205 133

  
206
    /* allocate and load VGA BIOS */
207
    vga_bios_offset = qemu_ram_alloc(NULL, "ppc_heathrow.vbios", VGA_BIOS_SIZE);
208
    vga_bios_ptr = qemu_get_ram_ptr(vga_bios_offset);
209
    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, VGABIOS_FILENAME);
210
    if (filename) {
211
        vga_bios_size = load_image(filename, vga_bios_ptr + 8);
212
        qemu_free(filename);
213
    } else {
214
        vga_bios_size = -1;
215
    }
216
    if (vga_bios_size < 0) {
217
        /* if no bios is present, we can still work */
218
        fprintf(stderr, "qemu: warning: could not load VGA bios '%s'\n",
219
                VGABIOS_FILENAME);
220
        vga_bios_size = 0;
221
    } else {
222
        /* set a specific header (XXX: find real Apple format for NDRV
223
           drivers) */
224
        vga_bios_ptr[0] = 'N';
225
        vga_bios_ptr[1] = 'D';
226
        vga_bios_ptr[2] = 'R';
227
        vga_bios_ptr[3] = 'V';
228
        cpu_to_be32w((uint32_t *)(vga_bios_ptr + 4), vga_bios_size);
229
        vga_bios_size += 8;
230

  
231
        /* Round to page boundary */
232
        vga_bios_size = (vga_bios_size + TARGET_PAGE_SIZE - 1) &
233
            TARGET_PAGE_MASK;
234
    }
235

  
236 134
    if (linux_boot) {
237 135
        uint64_t lowaddr = 0;
238 136
        int bswap_needed;
......
330 228
    }
331 229
    pic = heathrow_pic_init(&pic_mem_index, 1, heathrow_irqs);
332 230
    pci_bus = pci_grackle_init(0xfec00000, pic);
333
    pci_vga_init(pci_bus, vga_bios_offset, vga_bios_size);
231
    pci_vga_init(pci_bus, 0, 0);
334 232

  
335 233
    escc_mem_index = escc_init(0x80013000, pic[0x0f], pic[0x10], serial_hds[0],
336 234
                               serial_hds[1], ESCC_CLOCK, 4);
b/pc-bios/README
7 7
- The PowerPC Open Hack'Ware Open Firmware Compatible BIOS is
8 8
  available at http://perso.magic.fr/l_indien/OpenHackWare/index.htm.
9 9

  
10
- video.x is a PowerMac NDRV compatible driver for a VGA frame
11
  buffer. It comes from the Mac-on-Linux project
12
  (http://www.maconlinux.org/).
13

  
14 10
- OpenBIOS (http://www.openbios.org/) is a free (GPL v2) portable
15 11
  firmware implementation. The goal is to implement a 100% IEEE
16 12
  1275-1994 (referred to as Open Firmware) compliant firmware.
b/target-ppc/cpu.h
700 700
    int power_mode;
701 701
    int (*check_pow)(CPUPPCState *env);
702 702

  
703
    /* temporary hack to handle OSI calls (only used if non NULL) */
704
    int (*osi_call)(struct CPUPPCState *env);
705

  
706 703
#if !defined(CONFIG_USER_ONLY)
707 704
    void *load_info;    /* Holds boot loading state.  */
708 705
#endif
b/target-ppc/helper.c
2226 2226
            new_msr |= (target_ulong)MSR_HVB;
2227 2227
        goto store_current;
2228 2228
    case POWERPC_EXCP_SYSCALL:   /* System call exception                    */
2229
        /* NOTE: this is a temporary hack to support graphics OSI
2230
           calls from the MOL driver */
2231
        /* XXX: To be removed */
2232
        if (env->gpr[3] == 0x113724fa && env->gpr[4] == 0x77810f9b &&
2233
            env->osi_call) {
2234
            if (env->osi_call(env) != 0) {
2235
                env->exception_index = POWERPC_EXCP_NONE;
2236
                env->error_code = 0;
2237
                return;
2238
            }
2239
        }
2240 2229
        dump_syscall(env);
2241 2230
        lev = env->error_code;
2242 2231
        if (lev == 1 || (lpes0 == 0 && lpes1 == 0))

Also available in: Unified diff