Revision 2c9fade2
b/Makefile | ||
---|---|---|
222 | 222 |
ifdef INSTALL_BLOBS |
223 | 223 |
BLOBS=bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \ |
224 | 224 |
video.x openbios-sparc32 openbios-sparc64 pxe-ne2k_pci.bin \ |
225 |
pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin |
|
225 |
pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin bamboo.dtb
|
|
226 | 226 |
else |
227 | 227 |
BLOBS= |
228 | 228 |
endif |
b/Makefile.target | ||
---|---|---|
655 | 655 |
OBJS+= unin_pci.o ppc_chrp.o |
656 | 656 |
# PowerPC 4xx boards |
657 | 657 |
OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boards.o |
658 |
OBJS+= ppc440.o |
|
658 |
OBJS+= ppc440.o ppc440_bamboo.o
|
|
659 | 659 |
ifdef FDT_LIBS |
660 | 660 |
OBJS+= device_tree.o |
661 | 661 |
LIBS+= $(FDT_LIBS) |
b/hw/boards.h | ||
---|---|---|
38 | 38 |
extern QEMUMachine heathrow_machine; |
39 | 39 |
extern QEMUMachine ref405ep_machine; |
40 | 40 |
extern QEMUMachine taihu_machine; |
41 |
extern QEMUMachine bamboo_machine; |
|
41 | 42 |
|
42 | 43 |
/* mips_r4k.c */ |
43 | 44 |
extern QEMUMachine mips_machine; |
b/hw/ppc440_bamboo.c | ||
---|---|---|
1 |
/* |
|
2 |
* Qemu PowerPC 440 Bamboo board emulation |
|
3 |
* |
|
4 |
* Copyright 2007 IBM Corporation. |
|
5 |
* Authors: |
|
6 |
* Jerone Young <jyoung5@us.ibm.com> |
|
7 |
* Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> |
|
8 |
* Hollis Blanchard <hollisb@us.ibm.com> |
|
9 |
* |
|
10 |
* This work is licensed under the GNU GPL license version 2 or later. |
|
11 |
* |
|
12 |
*/ |
|
13 |
|
|
14 |
#include "config.h" |
|
15 |
#include "qemu-common.h" |
|
16 |
#include "net.h" |
|
17 |
#include "hw.h" |
|
18 |
#include "pci.h" |
|
19 |
#include "virtio-blk.h" |
|
20 |
#include "boards.h" |
|
21 |
#include "sysemu.h" |
|
22 |
#include "ppc440.h" |
|
23 |
#include "kvm.h" |
|
24 |
#include "kvm_ppc.h" |
|
25 |
#include "device_tree.h" |
|
26 |
|
|
27 |
#define BINARY_DEVICE_TREE_FILE "bamboo.dtb" |
|
28 |
|
|
29 |
static void *bamboo_load_device_tree(void *addr, |
|
30 |
uint32_t ramsize, |
|
31 |
target_phys_addr_t initrd_base, |
|
32 |
target_phys_addr_t initrd_size, |
|
33 |
const char *kernel_cmdline) |
|
34 |
{ |
|
35 |
void *fdt = NULL; |
|
36 |
#ifdef HAVE_FDT |
|
37 |
uint32_t mem_reg_property[] = { 0, 0, ramsize }; |
|
38 |
char *path; |
|
39 |
int pathlen; |
|
40 |
int ret; |
|
41 |
|
|
42 |
pathlen = snprintf(NULL, 0, "%s/%s", bios_dir, BINARY_DEVICE_TREE_FILE) + 1; |
|
43 |
path = qemu_malloc(pathlen); |
|
44 |
if (path == NULL) |
|
45 |
return NULL; |
|
46 |
|
|
47 |
snprintf(path, pathlen, "%s/%s", bios_dir, BINARY_DEVICE_TREE_FILE); |
|
48 |
|
|
49 |
fdt = load_device_tree(path, addr); |
|
50 |
free(path); |
|
51 |
if (fdt == NULL) |
|
52 |
goto out; |
|
53 |
|
|
54 |
/* Manipulate device tree in memory. */ |
|
55 |
|
|
56 |
ret = qemu_devtree_setprop(fdt, "/memory", "reg", mem_reg_property, |
|
57 |
sizeof(mem_reg_property)); |
|
58 |
if (ret < 0) |
|
59 |
fprintf(stderr, "couldn't set /memory/reg\n"); |
|
60 |
|
|
61 |
ret = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-start", |
|
62 |
initrd_base); |
|
63 |
if (ret < 0) |
|
64 |
fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n"); |
|
65 |
|
|
66 |
ret = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-end", |
|
67 |
(initrd_base + initrd_size)); |
|
68 |
if (ret < 0) |
|
69 |
fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n"); |
|
70 |
|
|
71 |
ret = qemu_devtree_setprop_string(fdt, "/chosen", "bootargs", |
|
72 |
kernel_cmdline); |
|
73 |
if (ret < 0) |
|
74 |
fprintf(stderr, "couldn't set /chosen/bootargs\n"); |
|
75 |
|
|
76 |
if (kvm_enabled()) |
|
77 |
kvmppc_fdt_update(fdt); |
|
78 |
|
|
79 |
out: |
|
80 |
#endif |
|
81 |
|
|
82 |
return fdt; |
|
83 |
} |
|
84 |
|
|
85 |
static void bamboo_init(ram_addr_t ram_size, int vga_ram_size, |
|
86 |
const char *boot_device, DisplayState *ds, |
|
87 |
const char *kernel_filename, |
|
88 |
const char *kernel_cmdline, |
|
89 |
const char *initrd_filename, |
|
90 |
const char *cpu_model) |
|
91 |
{ |
|
92 |
unsigned int pci_irq_nrs[4] = { 28, 27, 26, 25 }; |
|
93 |
NICInfo *nd; |
|
94 |
PCIBus *pcibus; |
|
95 |
CPUState *env; |
|
96 |
uint64_t elf_entry; |
|
97 |
uint64_t elf_lowaddr; |
|
98 |
target_ulong entry = 0; |
|
99 |
target_ulong loadaddr = 0; |
|
100 |
target_long kernel_size = 0; |
|
101 |
target_ulong initrd_base = 0; |
|
102 |
target_long initrd_size = 0; |
|
103 |
target_ulong dt_base = 0; |
|
104 |
void *fdt; |
|
105 |
int i; |
|
106 |
|
|
107 |
/* Setup CPU. */ |
|
108 |
env = ppc440ep_init(&ram_size, &pcibus, pci_irq_nrs, 1); |
|
109 |
|
|
110 |
if (pcibus) { |
|
111 |
int unit_id = 0; |
|
112 |
|
|
113 |
/* Add virtio block devices. */ |
|
114 |
while ((i = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) { |
|
115 |
virtio_blk_init(pcibus, drives_table[i].bdrv); |
|
116 |
unit_id++; |
|
117 |
} |
|
118 |
|
|
119 |
/* Register network interfaces. */ |
|
120 |
for (i = 0; i < nb_nics; i++) { |
|
121 |
nd = &nd_table[i]; |
|
122 |
if (!nd->model) { |
|
123 |
/* There are no PCI NICs on the Bamboo board, but there are |
|
124 |
* PCI slots, so we can pick model whatever we want. */ |
|
125 |
nd->model = "e1000"; |
|
126 |
} |
|
127 |
pci_nic_init(pcibus, nd, -1); |
|
128 |
} |
|
129 |
} |
|
130 |
|
|
131 |
/* Load kernel. */ |
|
132 |
if (kernel_filename) { |
|
133 |
kernel_size = load_uimage(kernel_filename, &entry, &loadaddr, NULL); |
|
134 |
if (kernel_size < 0) { |
|
135 |
kernel_size = load_elf(kernel_filename, 0, &elf_entry, &elf_lowaddr, |
|
136 |
NULL); |
|
137 |
entry = elf_entry; |
|
138 |
loadaddr = elf_lowaddr; |
|
139 |
} |
|
140 |
/* XXX try again as binary */ |
|
141 |
if (kernel_size < 0) { |
|
142 |
fprintf(stderr, "qemu: could not load kernel '%s'\n", |
|
143 |
kernel_filename); |
|
144 |
exit(1); |
|
145 |
} |
|
146 |
} |
|
147 |
|
|
148 |
/* Load initrd. */ |
|
149 |
if (initrd_filename) { |
|
150 |
initrd_base = kernel_size + loadaddr; |
|
151 |
initrd_size = load_image(initrd_filename, phys_ram_base + initrd_base); |
|
152 |
|
|
153 |
if (initrd_size < 0) { |
|
154 |
fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", |
|
155 |
initrd_filename); |
|
156 |
exit(1); |
|
157 |
} |
|
158 |
} |
|
159 |
|
|
160 |
/* If we're loading a kernel directly, we must load the device tree too. */ |
|
161 |
if (kernel_filename) { |
|
162 |
if (initrd_base) |
|
163 |
dt_base = initrd_base + initrd_size; |
|
164 |
else |
|
165 |
dt_base = kernel_size + loadaddr; |
|
166 |
|
|
167 |
fdt = bamboo_load_device_tree(phys_ram_base + dt_base, ram_size, |
|
168 |
initrd_base, initrd_size, kernel_cmdline); |
|
169 |
if (fdt == NULL) { |
|
170 |
fprintf(stderr, "couldn't load device tree\n"); |
|
171 |
exit(1); |
|
172 |
} |
|
173 |
|
|
174 |
/* Set initial guest state. */ |
|
175 |
env->gpr[1] = (16<<20) - 8; |
|
176 |
env->gpr[3] = dt_base; |
|
177 |
env->nip = entry; |
|
178 |
/* XXX we currently depend on KVM to create some initial TLB entries. */ |
|
179 |
} |
|
180 |
|
|
181 |
if (kvm_enabled()) |
|
182 |
kvmppc_init(); |
|
183 |
} |
|
184 |
|
|
185 |
QEMUMachine bamboo_machine = { |
|
186 |
.name = "bamboo", |
|
187 |
.desc = "bamboo", |
|
188 |
.init = bamboo_init, |
|
189 |
.ram_require = 8<<20 | RAMSIZE_FIXED, |
|
190 |
}; |
b/pc-bios/bamboo.dts | ||
---|---|---|
1 |
/* |
|
2 |
* Device Tree Source for AMCC Bamboo |
|
3 |
* |
|
4 |
* Copyright (c) 2006, 2007 IBM Corp. |
|
5 |
* Josh Boyer <jwboyer@linux.vnet.ibm.com> |
|
6 |
* |
|
7 |
* This file is licensed under the terms of the GNU General Public |
|
8 |
* License version 2. This program is licensed "as is" without |
|
9 |
* any warranty of any kind, whether express or implied. |
|
10 |
*/ |
|
11 |
|
|
12 |
/ { |
|
13 |
#address-cells = <2>; |
|
14 |
#size-cells = <1>; |
|
15 |
model = "amcc,bamboo"; |
|
16 |
compatible = "amcc,bamboo"; |
|
17 |
dcr-parent = <&/cpus/cpu@0>; |
|
18 |
|
|
19 |
aliases { |
|
20 |
serial0 = &UART0; |
|
21 |
serial1 = &UART1; |
|
22 |
}; |
|
23 |
|
|
24 |
cpus { |
|
25 |
#address-cells = <1>; |
|
26 |
#size-cells = <0>; |
|
27 |
|
|
28 |
cpu@0 { |
|
29 |
device_type = "cpu"; |
|
30 |
model = "PowerPC,440EP"; |
|
31 |
reg = <0>; |
|
32 |
clock-frequency = <1fca0550>; |
|
33 |
timebase-frequency = <017d7840>; |
|
34 |
i-cache-line-size = <20>; |
|
35 |
d-cache-line-size = <20>; |
|
36 |
i-cache-size = <8000>; |
|
37 |
d-cache-size = <8000>; |
|
38 |
dcr-controller; |
|
39 |
dcr-access-method = "native"; |
|
40 |
}; |
|
41 |
}; |
|
42 |
|
|
43 |
memory { |
|
44 |
device_type = "memory"; |
|
45 |
reg = <0 0 9000000>; |
|
46 |
}; |
|
47 |
|
|
48 |
UIC0: interrupt-controller0 { |
|
49 |
compatible = "ibm,uic-440ep","ibm,uic"; |
|
50 |
interrupt-controller; |
|
51 |
cell-index = <0>; |
|
52 |
dcr-reg = <0c0 009>; |
|
53 |
#address-cells = <0>; |
|
54 |
#size-cells = <0>; |
|
55 |
#interrupt-cells = <2>; |
|
56 |
}; |
|
57 |
/* |
|
58 |
UIC1: interrupt-controller1 { |
|
59 |
compatible = "ibm,uic-440ep","ibm,uic"; |
|
60 |
interrupt-controller; |
|
61 |
cell-index = <1>; |
|
62 |
dcr-reg = <0d0 009>; |
|
63 |
#address-cells = <0>; |
|
64 |
#size-cells = <0>; |
|
65 |
#interrupt-cells = <2>; |
|
66 |
interrupts = <1e 4 1f 4>; |
|
67 |
interrupt-parent = <&UIC0>; |
|
68 |
}; |
|
69 |
*/ |
|
70 |
|
|
71 |
SDR0: sdr { |
|
72 |
compatible = "ibm,sdr-440ep"; |
|
73 |
dcr-reg = <00e 002>; |
|
74 |
}; |
|
75 |
|
|
76 |
CPR0: cpr { |
|
77 |
compatible = "ibm,cpr-440ep"; |
|
78 |
dcr-reg = <00c 002>; |
|
79 |
}; |
|
80 |
|
|
81 |
plb { |
|
82 |
compatible = "ibm,plb-440ep", "ibm,plb-440gp", "ibm,plb4"; |
|
83 |
#address-cells = <2>; |
|
84 |
#size-cells = <1>; |
|
85 |
ranges; |
|
86 |
clock-frequency = <07f28154>; |
|
87 |
|
|
88 |
SDRAM0: sdram { |
|
89 |
compatible = "ibm,sdram-440ep", "ibm,sdram-405gp"; |
|
90 |
dcr-reg = <010 2>; |
|
91 |
}; |
|
92 |
|
|
93 |
DMA0: dma { |
|
94 |
compatible = "ibm,dma-440ep", "ibm,dma-440gp"; |
|
95 |
dcr-reg = <100 027>; |
|
96 |
}; |
|
97 |
|
|
98 |
POB0: opb { |
|
99 |
compatible = "ibm,opb-440ep", "ibm,opb-440gp", "ibm,opb"; |
|
100 |
#address-cells = <1>; |
|
101 |
#size-cells = <1>; |
|
102 |
/* Bamboo is oddball in the 44x world and doesn't use the ERPN |
|
103 |
* bits. |
|
104 |
*/ |
|
105 |
ranges = <00000000 0 00000000 80000000 |
|
106 |
80000000 0 80000000 80000000>; |
|
107 |
/* interrupt-parent = <&UIC1>; */ |
|
108 |
interrupts = <7 4>; |
|
109 |
clock-frequency = <03f940aa>; |
|
110 |
|
|
111 |
EBC0: ebc { |
|
112 |
compatible = "ibm,ebc-440ep", "ibm,ebc-440gp", "ibm,ebc"; |
|
113 |
dcr-reg = <012 2>; |
|
114 |
#address-cells = <2>; |
|
115 |
#size-cells = <1>; |
|
116 |
clock-frequency = <03f940aa>; |
|
117 |
interrupts = <5 1>; |
|
118 |
/* interrupt-parent = <&UIC1>; */ |
|
119 |
}; |
|
120 |
|
|
121 |
UART0: serial@ef600300 { |
|
122 |
device_type = "serial"; |
|
123 |
compatible = "ns16550"; |
|
124 |
reg = <ef600300 8>; |
|
125 |
virtual-reg = <ef600300>; |
|
126 |
clock-frequency = <00a8c000>; |
|
127 |
current-speed = <1c200>; |
|
128 |
interrupt-parent = <&UIC0>; |
|
129 |
interrupts = <0 4>; |
|
130 |
}; |
|
131 |
|
|
132 |
UART1: serial@ef600400 { |
|
133 |
device_type = "serial"; |
|
134 |
compatible = "ns16550"; |
|
135 |
reg = <ef600400 8>; |
|
136 |
virtual-reg = <ef600400>; |
|
137 |
clock-frequency = <00a8c000>; |
|
138 |
current-speed = <0>; |
|
139 |
interrupt-parent = <&UIC0>; |
|
140 |
interrupts = <1 4>; |
|
141 |
}; |
|
142 |
/* |
|
143 |
UART2: serial@ef600500 { |
|
144 |
device_type = "serial"; |
|
145 |
compatible = "ns16550"; |
|
146 |
reg = <ef600500 8>; |
|
147 |
virtual-reg = <ef600500>; |
|
148 |
clock-frequency = <0>; |
|
149 |
current-speed = <0>; |
|
150 |
interrupt-parent = <&UIC0>; |
|
151 |
interrupts = <3 4>; |
|
152 |
}; |
|
153 |
|
|
154 |
UART3: serial@ef600600 { |
|
155 |
device_type = "serial"; |
|
156 |
compatible = "ns16550"; |
|
157 |
reg = <ef600600 8>; |
|
158 |
virtual-reg = <ef600600>; |
|
159 |
clock-frequency = <0>; |
|
160 |
current-speed = <0>; |
|
161 |
interrupt-parent = <&UIC0>; |
|
162 |
interrupts = <4 4>; |
|
163 |
}; |
|
164 |
|
|
165 |
*/ |
|
166 |
IIC0: i2c@ef600700 { |
|
167 |
device_type = "i2c"; |
|
168 |
compatible = "ibm,iic-440ep", "ibm,iic-440gp", "ibm,iic"; |
|
169 |
reg = <ef600700 14>; |
|
170 |
interrupt-parent = <&UIC0>; |
|
171 |
interrupts = <2 4>; |
|
172 |
}; |
|
173 |
|
|
174 |
IIC1: i2c@ef600800 { |
|
175 |
device_type = "i2c"; |
|
176 |
compatible = "ibm,iic-440ep", "ibm,iic-440gp", "ibm,iic"; |
|
177 |
reg = <ef600800 14>; |
|
178 |
interrupt-parent = <&UIC0>; |
|
179 |
interrupts = <7 4>; |
|
180 |
}; |
|
181 |
|
|
182 |
ZMII0: emac-zmii@ef600d00 { |
|
183 |
device_type = "zmii-interface"; |
|
184 |
compatible = "ibm,zmii-440ep", "ibm,zmii-440gp", "ibm,zmii"; |
|
185 |
reg = <ef600d00 c>; |
|
186 |
}; |
|
187 |
|
|
188 |
}; |
|
189 |
|
|
190 |
PCI0: pci@ec000000 { |
|
191 |
device_type = "pci"; |
|
192 |
#interrupt-cells = <1>; |
|
193 |
#size-cells = <2>; |
|
194 |
#address-cells = <3>; |
|
195 |
compatible = "ibm,plb440ep-pci", "ibm,plb-pci"; |
|
196 |
primary; |
|
197 |
reg = <0 eec00000 8 /* Config space access */ |
|
198 |
0 eed00000 4 /* IACK */ |
|
199 |
0 eed00000 4 /* Special cycle */ |
|
200 |
0 ef400000 40>; /* Internal registers */ |
|
201 |
|
|
202 |
/* Outbound ranges, one memory and one IO, |
|
203 |
* later cannot be changed. Chip supports a second |
|
204 |
* IO range but we don't use it for now |
|
205 |
*/ |
|
206 |
ranges = <02000000 0 a0000000 0 a0000000 0 20000000 |
|
207 |
01000000 0 00000000 0 e8000000 0 00010000>; |
|
208 |
|
|
209 |
/* Inbound 2GB range starting at 0 */ |
|
210 |
dma-ranges = <42000000 0 0 0 0 0 80000000>; |
|
211 |
|
|
212 |
/* Bamboo has all 4 IRQ pins tied together per slot */ |
|
213 |
interrupt-map-mask = <f800 0 0 0>; |
|
214 |
interrupt-map = < |
|
215 |
/* IDSEL 1 */ |
|
216 |
0800 0 0 0 &UIC0 1c 8 |
|
217 |
|
|
218 |
/* IDSEL 2 */ |
|
219 |
1000 0 0 0 &UIC0 1b 8 |
|
220 |
|
|
221 |
/* IDSEL 3 */ |
|
222 |
1800 0 0 0 &UIC0 1a 8 |
|
223 |
|
|
224 |
/* IDSEL 4 */ |
|
225 |
2000 0 0 0 &UIC0 19 8 |
|
226 |
>; |
|
227 |
}; |
|
228 |
|
|
229 |
}; |
|
230 |
|
|
231 |
chosen { |
|
232 |
linux,stdout-path = "/plb/opb/serial@ef600300"; |
|
233 |
}; |
|
234 |
}; |
b/target-ppc/machine.c | ||
---|---|---|
8 | 8 |
qemu_register_machine(&prep_machine); |
9 | 9 |
qemu_register_machine(&ref405ep_machine); |
10 | 10 |
qemu_register_machine(&taihu_machine); |
11 |
qemu_register_machine(&bamboo_machine); |
|
11 | 12 |
} |
12 | 13 |
|
13 | 14 |
void cpu_save(QEMUFile *f, void *opaque) |
Also available in: Unified diff