Clean up KVM/QEMU interaction
[qemu-kvm/fedora.git] / hw / ppc440_bamboo.c
blobd3c2bfd83004bc7310819820bbc2e94887c3215d
1 /*
2 * Qemu PowerPC 440 board emualtion
4 * Copyright 2007 IBM Corporation.
5 * Authors: Jerone Young <jyoung5@us.ibm.com>
7 * This work is licensed under the GNU LGPL license, version 2.
9 */
11 #include "ppc440.h"
13 #define KERNEL_LOAD_ADDR 0x400000 /* uboot loader puts kernel at 4MB */
15 #include "qemu-kvm.h"
17 /* PPC 440 refrence demo board
19 * 440 PowerPC CPU
22 void bamboo_init(ram_addr_t ram_size, int vga_ram_size,
23 const char *boot_device, DisplayState *ds,
24 const char *kernel_filename,
25 const char *kernel_cmdline,
26 const char *initrd_filename,
27 const char *cpu_model)
29 target_phys_addr_t ram_bases[2], ram_sizes[2];
30 qemu_irq *pic;
31 CPUState *env;
32 target_ulong ep;
33 int is_linux=1; /* Will assume allways is Linux for now */
34 long kernel_size=0;
35 target_ulong initrd_base=0;
36 target_ulong initrd_size=0;
38 printf("%s: START\n", __func__);
40 /* Setup Memory */
41 if (ram_size) {
42 printf("Ram size specified on command line is %i bytes\n",
43 (int)ram_size);
44 printf("WARNING: RAM is hard coded to 144MB\n");
46 else {
47 printf("Using defualt ram size of %iMB\n",
48 ((int)ram_size/1024)/1024);
51 /* Each bank can only have memory in configurations of
52 * 16MB, 32MB, 64MB, 128MB, or 256MB
54 ram_bases[0] = 0x0;
55 ram_sizes[0] = 0x08000000;
56 ram_bases[1] = 0x0;
57 ram_sizes[1] = 0x01000000;
59 printf("Ram size of domain is %d bytes\n", (int)ram_size);
61 /* Setup CPU */
62 /* XXX We cheat for now and use 405 */
63 env = cpu_ppc_init("405");
64 if (!env) {
65 fprintf(stderr, "Unable to initilize CPU!\n");
66 exit(1);
69 /* call init */
70 printf("Calling function ppc440_init\n");
71 ppc440_init(env, ram_bases, ram_sizes, &pic,1);
72 printf("Done calling ppc440_init\n");
74 /* Register mem */
75 cpu_register_physical_memory(0, ram_size, 0);
76 if (kvm_enabled())
77 kvm_cpu_register_physical_memory(0, ram_size, 0);
79 /* load kernel with uboot loader */
80 printf("%s: load kernel\n", __func__);
81 kernel_size = load_uboot(kernel_filename, &ep, &is_linux);
82 if (kernel_size < 0) {
83 fprintf(stderr, "qemu: could not load kernel '%s'\n",
84 kernel_filename);
85 exit(1);
88 /* load initrd */
89 if (initrd_filename) {
90 initrd_base = kernel_size + KERNEL_LOAD_ADDR;
91 initrd_size = load_image(initrd_filename,
92 phys_ram_base + initrd_base);
94 if (initrd_size < 0) {
95 fprintf(stderr,
96 "qemu: could not load initial ram disk '%s'\n",
97 initrd_filename);
98 exit(1);
102 if (kvm_enabled()) {
103 /* XXX insert TLB entries */
104 env->gpr[1] = (16<<20) - 8;
105 env->gpr[4] = initrd_base;
106 env->gpr[5] = initrd_size;
108 env->nip = ep;
110 env->cpu_index = 0;
111 printf("%s: loading kvm registers\n", __func__);
112 kvm_load_registers(env);
115 printf("%s: DONE\n", __func__);
118 QEMUMachine bamboo_machine = {
119 "bamboo",
120 "bamboo",
121 bamboo_init,