Revision ae0bfb79 hw/ppc_oldworld.c

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

Also available in: Unified diff