Revision 4040ab72 hw/spapr.c

b/hw/spapr.c
25 25
 *
26 26
 */
27 27
#include "sysemu.h"
28
#include "qemu-char.h"
29 28
#include "hw.h"
30 29
#include "elf.h"
31 30

  
......
34 33
#include "hw/loader.h"
35 34

  
36 35
#include "hw/spapr.h"
36
#include "hw/spapr_vio.h"
37 37

  
38 38
#include <libfdt.h>
39 39

  
......
60 60
    uint32_t end_prop = cpu_to_be32(initrd_base + initrd_size);
61 61
    int i;
62 62
    char *modelname;
63
    int ret;
63 64

  
64 65
#define _FDT(exp) \
65 66
    do { \
......
159 160

  
160 161
    _FDT((fdt_end_node(fdt)));
161 162

  
163
    /* vdevice */
164
    _FDT((fdt_begin_node(fdt, "vdevice")));
165

  
166
    _FDT((fdt_property_string(fdt, "device_type", "vdevice")));
167
    _FDT((fdt_property_string(fdt, "compatible", "IBM,vdevice")));
168
    _FDT((fdt_property_cell(fdt, "#address-cells", 0x1)));
169
    _FDT((fdt_property_cell(fdt, "#size-cells", 0x0)));
170

  
171
    _FDT((fdt_end_node(fdt)));
172

  
162 173
    _FDT((fdt_end_node(fdt))); /* close root node */
163 174
    _FDT((fdt_finish(fdt)));
164 175

  
176
    /* re-expand to allow for further tweaks */
177
    _FDT((fdt_open_into(fdt, fdt, FDT_MAX_SIZE)));
178

  
179
    ret = spapr_populate_vdevice(spapr->vio_bus, fdt);
180
    if (ret < 0) {
181
        fprintf(stderr, "couldn't setup vio devices in fdt\n");
182
        exit(1);
183
    }
184

  
185
    _FDT((fdt_pack(fdt)));
186

  
165 187
    *fdt_size = fdt_totalsize(fdt);
166 188

  
167 189
    return fdt;
......
177 199
    env->gpr[3] = spapr_hypercall(env, env->gpr[3], &env->gpr[4]);
178 200
}
179 201

  
180
/* FIXME: hack until we implement the proper VIO console */
181
static target_ulong h_put_term_char(CPUState *env, sPAPREnvironment *spapr,
182
                                    target_ulong opcode, target_ulong *args)
183
{
184
    uint8_t buf[16];
185

  
186
    stq_p(buf, args[2]);
187
    stq_p(buf + 8, args[3]);
188

  
189
    qemu_chr_write(serial_hds[0], buf, args[1]);
190

  
191
    return 0;
192
}
193

  
194

  
195 202
/* pSeries LPAR / sPAPR hardware init */
196 203
static void ppc_spapr_init(ram_addr_t ram_size,
197 204
                           const char *boot_device,
......
243 250
    ram_offset = qemu_ram_alloc(NULL, "ppc_spapr.ram", ram_size);
244 251
    cpu_register_physical_memory(0, ram_size, ram_offset);
245 252

  
246
    spapr_register_hypercall(H_PUT_TERM_CHAR, h_put_term_char);
253
    spapr->vio_bus = spapr_vio_bus_init();
254

  
255
    for (i = 0; i < MAX_SERIAL_PORTS; i++) {
256
        if (serial_hds[i]) {
257
            spapr_vty_create(spapr->vio_bus, i, serial_hds[i]);
258
        }
259
    }
247 260

  
248 261
    if (kernel_filename) {
249 262
        uint64_t lowaddr = 0;
......
276 289
            initrd_base = 0;
277 290
            initrd_size = 0;
278 291
        }
279

  
280 292
    } else {
281 293
        fprintf(stderr, "pSeries machine needs -kernel for now");
282 294
        exit(1);

Also available in: Unified diff