root / hw / ppc405_boards.c @ 795928f6
History | View | Annotate | Download (20 kB)
1 | 1a6c0886 | j_mayer | /*
|
---|---|---|---|
2 | 1a6c0886 | j_mayer | * QEMU PowerPC 405 evaluation boards emulation
|
3 | 5fafdf24 | ths | *
|
4 | 1a6c0886 | j_mayer | * Copyright (c) 2007 Jocelyn Mayer
|
5 | 5fafdf24 | ths | *
|
6 | 1a6c0886 | j_mayer | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | 1a6c0886 | j_mayer | * of this software and associated documentation files (the "Software"), to deal
|
8 | 1a6c0886 | j_mayer | * in the Software without restriction, including without limitation the rights
|
9 | 1a6c0886 | j_mayer | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | 1a6c0886 | j_mayer | * copies of the Software, and to permit persons to whom the Software is
|
11 | 1a6c0886 | j_mayer | * furnished to do so, subject to the following conditions:
|
12 | 1a6c0886 | j_mayer | *
|
13 | 1a6c0886 | j_mayer | * The above copyright notice and this permission notice shall be included in
|
14 | 1a6c0886 | j_mayer | * all copies or substantial portions of the Software.
|
15 | 1a6c0886 | j_mayer | *
|
16 | 1a6c0886 | j_mayer | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | 1a6c0886 | j_mayer | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | 1a6c0886 | j_mayer | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | 1a6c0886 | j_mayer | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | 1a6c0886 | j_mayer | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | 1a6c0886 | j_mayer | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | 1a6c0886 | j_mayer | * THE SOFTWARE.
|
23 | 1a6c0886 | j_mayer | */
|
24 | 87ecb68b | pbrook | #include "hw.h" |
25 | 87ecb68b | pbrook | #include "ppc.h" |
26 | 1a6c0886 | j_mayer | #include "ppc405.h" |
27 | 87ecb68b | pbrook | #include "nvram.h" |
28 | 87ecb68b | pbrook | #include "flash.h" |
29 | 87ecb68b | pbrook | #include "sysemu.h" |
30 | 87ecb68b | pbrook | #include "block.h" |
31 | 87ecb68b | pbrook | #include "boards.h" |
32 | 3b3fb322 | blueswir1 | #include "qemu-log.h" |
33 | ca20cf32 | Blue Swirl | #include "loader.h" |
34 | 2446333c | Blue Swirl | #include "blockdev.h" |
35 | cfe5f011 | Avi Kivity | #include "exec-memory.h" |
36 | 1a6c0886 | j_mayer | |
37 | 1a6c0886 | j_mayer | #define BIOS_FILENAME "ppc405_rom.bin" |
38 | 1a6c0886 | j_mayer | #define BIOS_SIZE (2048 * 1024) |
39 | 1a6c0886 | j_mayer | |
40 | 1a6c0886 | j_mayer | #define KERNEL_LOAD_ADDR 0x00000000 |
41 | 1a6c0886 | j_mayer | #define INITRD_LOAD_ADDR 0x01800000 |
42 | 1a6c0886 | j_mayer | |
43 | 1a6c0886 | j_mayer | #define USE_FLASH_BIOS
|
44 | 1a6c0886 | j_mayer | |
45 | 1a6c0886 | j_mayer | #define DEBUG_BOARD_INIT
|
46 | 1a6c0886 | j_mayer | |
47 | 1a6c0886 | j_mayer | /*****************************************************************************/
|
48 | 1a6c0886 | j_mayer | /* PPC405EP reference board (IBM) */
|
49 | 1a6c0886 | j_mayer | /* Standalone board with:
|
50 | 1a6c0886 | j_mayer | * - PowerPC 405EP CPU
|
51 | 1a6c0886 | j_mayer | * - SDRAM (0x00000000)
|
52 | 1a6c0886 | j_mayer | * - Flash (0xFFF80000)
|
53 | 1a6c0886 | j_mayer | * - SRAM (0xFFF00000)
|
54 | 1a6c0886 | j_mayer | * - NVRAM (0xF0000000)
|
55 | 1a6c0886 | j_mayer | * - FPGA (0xF0300000)
|
56 | 1a6c0886 | j_mayer | */
|
57 | c227f099 | Anthony Liguori | typedef struct ref405ep_fpga_t ref405ep_fpga_t; |
58 | c227f099 | Anthony Liguori | struct ref405ep_fpga_t {
|
59 | 1a6c0886 | j_mayer | uint8_t reg0; |
60 | 1a6c0886 | j_mayer | uint8_t reg1; |
61 | 1a6c0886 | j_mayer | }; |
62 | 1a6c0886 | j_mayer | |
63 | c227f099 | Anthony Liguori | static uint32_t ref405ep_fpga_readb (void *opaque, target_phys_addr_t addr) |
64 | 1a6c0886 | j_mayer | { |
65 | c227f099 | Anthony Liguori | ref405ep_fpga_t *fpga; |
66 | 1a6c0886 | j_mayer | uint32_t ret; |
67 | 1a6c0886 | j_mayer | |
68 | 1a6c0886 | j_mayer | fpga = opaque; |
69 | 1a6c0886 | j_mayer | switch (addr) {
|
70 | 1a6c0886 | j_mayer | case 0x0: |
71 | 1a6c0886 | j_mayer | ret = fpga->reg0; |
72 | 1a6c0886 | j_mayer | break;
|
73 | 1a6c0886 | j_mayer | case 0x1: |
74 | 1a6c0886 | j_mayer | ret = fpga->reg1; |
75 | 1a6c0886 | j_mayer | break;
|
76 | 1a6c0886 | j_mayer | default:
|
77 | 1a6c0886 | j_mayer | ret = 0;
|
78 | 1a6c0886 | j_mayer | break;
|
79 | 1a6c0886 | j_mayer | } |
80 | 1a6c0886 | j_mayer | |
81 | 1a6c0886 | j_mayer | return ret;
|
82 | 1a6c0886 | j_mayer | } |
83 | 1a6c0886 | j_mayer | |
84 | 1a6c0886 | j_mayer | static void ref405ep_fpga_writeb (void *opaque, |
85 | c227f099 | Anthony Liguori | target_phys_addr_t addr, uint32_t value) |
86 | 1a6c0886 | j_mayer | { |
87 | c227f099 | Anthony Liguori | ref405ep_fpga_t *fpga; |
88 | 1a6c0886 | j_mayer | |
89 | 1a6c0886 | j_mayer | fpga = opaque; |
90 | 1a6c0886 | j_mayer | switch (addr) {
|
91 | 1a6c0886 | j_mayer | case 0x0: |
92 | 1a6c0886 | j_mayer | /* Read only */
|
93 | 1a6c0886 | j_mayer | break;
|
94 | 1a6c0886 | j_mayer | case 0x1: |
95 | 1a6c0886 | j_mayer | fpga->reg1 = value; |
96 | 1a6c0886 | j_mayer | break;
|
97 | 1a6c0886 | j_mayer | default:
|
98 | 1a6c0886 | j_mayer | break;
|
99 | 1a6c0886 | j_mayer | } |
100 | 1a6c0886 | j_mayer | } |
101 | 1a6c0886 | j_mayer | |
102 | c227f099 | Anthony Liguori | static uint32_t ref405ep_fpga_readw (void *opaque, target_phys_addr_t addr) |
103 | 1a6c0886 | j_mayer | { |
104 | 1a6c0886 | j_mayer | uint32_t ret; |
105 | 1a6c0886 | j_mayer | |
106 | 1a6c0886 | j_mayer | ret = ref405ep_fpga_readb(opaque, addr) << 8;
|
107 | 1a6c0886 | j_mayer | ret |= ref405ep_fpga_readb(opaque, addr + 1);
|
108 | 1a6c0886 | j_mayer | |
109 | 1a6c0886 | j_mayer | return ret;
|
110 | 1a6c0886 | j_mayer | } |
111 | 1a6c0886 | j_mayer | |
112 | 1a6c0886 | j_mayer | static void ref405ep_fpga_writew (void *opaque, |
113 | c227f099 | Anthony Liguori | target_phys_addr_t addr, uint32_t value) |
114 | 1a6c0886 | j_mayer | { |
115 | 1a6c0886 | j_mayer | ref405ep_fpga_writeb(opaque, addr, (value >> 8) & 0xFF); |
116 | 1a6c0886 | j_mayer | ref405ep_fpga_writeb(opaque, addr + 1, value & 0xFF); |
117 | 1a6c0886 | j_mayer | } |
118 | 1a6c0886 | j_mayer | |
119 | c227f099 | Anthony Liguori | static uint32_t ref405ep_fpga_readl (void *opaque, target_phys_addr_t addr) |
120 | 1a6c0886 | j_mayer | { |
121 | 1a6c0886 | j_mayer | uint32_t ret; |
122 | 1a6c0886 | j_mayer | |
123 | 1a6c0886 | j_mayer | ret = ref405ep_fpga_readb(opaque, addr) << 24;
|
124 | 1a6c0886 | j_mayer | ret |= ref405ep_fpga_readb(opaque, addr + 1) << 16; |
125 | 1a6c0886 | j_mayer | ret |= ref405ep_fpga_readb(opaque, addr + 2) << 8; |
126 | 1a6c0886 | j_mayer | ret |= ref405ep_fpga_readb(opaque, addr + 3);
|
127 | 1a6c0886 | j_mayer | |
128 | 1a6c0886 | j_mayer | return ret;
|
129 | 1a6c0886 | j_mayer | } |
130 | 1a6c0886 | j_mayer | |
131 | 1a6c0886 | j_mayer | static void ref405ep_fpga_writel (void *opaque, |
132 | c227f099 | Anthony Liguori | target_phys_addr_t addr, uint32_t value) |
133 | 1a6c0886 | j_mayer | { |
134 | 8de24106 | aurel32 | ref405ep_fpga_writeb(opaque, addr, (value >> 24) & 0xFF); |
135 | 8de24106 | aurel32 | ref405ep_fpga_writeb(opaque, addr + 1, (value >> 16) & 0xFF); |
136 | 8de24106 | aurel32 | ref405ep_fpga_writeb(opaque, addr + 2, (value >> 8) & 0xFF); |
137 | 1a6c0886 | j_mayer | ref405ep_fpga_writeb(opaque, addr + 3, value & 0xFF); |
138 | 1a6c0886 | j_mayer | } |
139 | 1a6c0886 | j_mayer | |
140 | a682fd5c | Avi Kivity | static const MemoryRegionOps ref405ep_fpga_ops = { |
141 | a682fd5c | Avi Kivity | .old_mmio = { |
142 | a682fd5c | Avi Kivity | .read = { |
143 | a682fd5c | Avi Kivity | ref405ep_fpga_readb, ref405ep_fpga_readw, ref405ep_fpga_readl, |
144 | a682fd5c | Avi Kivity | }, |
145 | a682fd5c | Avi Kivity | .write = { |
146 | a682fd5c | Avi Kivity | ref405ep_fpga_writeb, ref405ep_fpga_writew, ref405ep_fpga_writel, |
147 | a682fd5c | Avi Kivity | }, |
148 | a682fd5c | Avi Kivity | }, |
149 | a682fd5c | Avi Kivity | .endianness = DEVICE_NATIVE_ENDIAN, |
150 | 1a6c0886 | j_mayer | }; |
151 | 1a6c0886 | j_mayer | |
152 | 1a6c0886 | j_mayer | static void ref405ep_fpga_reset (void *opaque) |
153 | 1a6c0886 | j_mayer | { |
154 | c227f099 | Anthony Liguori | ref405ep_fpga_t *fpga; |
155 | 1a6c0886 | j_mayer | |
156 | 1a6c0886 | j_mayer | fpga = opaque; |
157 | 1a6c0886 | j_mayer | fpga->reg0 = 0x00;
|
158 | 1a6c0886 | j_mayer | fpga->reg1 = 0x0F;
|
159 | 1a6c0886 | j_mayer | } |
160 | 1a6c0886 | j_mayer | |
161 | a682fd5c | Avi Kivity | static void ref405ep_fpga_init (MemoryRegion *sysmem, uint32_t base) |
162 | 1a6c0886 | j_mayer | { |
163 | c227f099 | Anthony Liguori | ref405ep_fpga_t *fpga; |
164 | a682fd5c | Avi Kivity | MemoryRegion *fpga_memory = g_new(MemoryRegion, 1);
|
165 | 1a6c0886 | j_mayer | |
166 | 7267c094 | Anthony Liguori | fpga = g_malloc0(sizeof(ref405ep_fpga_t));
|
167 | a682fd5c | Avi Kivity | memory_region_init_io(fpga_memory, &ref405ep_fpga_ops, fpga, |
168 | a682fd5c | Avi Kivity | "fpga", 0x00000100); |
169 | a682fd5c | Avi Kivity | memory_region_add_subregion(sysmem, base, fpga_memory); |
170 | a08d4367 | Jan Kiszka | qemu_register_reset(&ref405ep_fpga_reset, fpga); |
171 | 1a6c0886 | j_mayer | } |
172 | 1a6c0886 | j_mayer | |
173 | c227f099 | Anthony Liguori | static void ref405ep_init (ram_addr_t ram_size, |
174 | 3023f332 | aliguori | const char *boot_device, |
175 | 5fafdf24 | ths | const char *kernel_filename, |
176 | 1a6c0886 | j_mayer | const char *kernel_cmdline, |
177 | 1a6c0886 | j_mayer | const char *initrd_filename, |
178 | 1a6c0886 | j_mayer | const char *cpu_model) |
179 | 1a6c0886 | j_mayer | { |
180 | 5cea8590 | Paul Brook | char *filename;
|
181 | c227f099 | Anthony Liguori | ppc4xx_bd_info_t bd; |
182 | 1a6c0886 | j_mayer | CPUPPCState *env; |
183 | 1a6c0886 | j_mayer | qemu_irq *pic; |
184 | cfe5f011 | Avi Kivity | MemoryRegion *bios; |
185 | a682fd5c | Avi Kivity | MemoryRegion *sram = g_new(MemoryRegion, 1);
|
186 | a682fd5c | Avi Kivity | ram_addr_t bdloc; |
187 | b6dcbe08 | Avi Kivity | MemoryRegion *ram_memories = g_malloc(2 * sizeof(*ram_memories)); |
188 | c227f099 | Anthony Liguori | target_phys_addr_t ram_bases[2], ram_sizes[2]; |
189 | 093209cd | Blue Swirl | target_ulong sram_size; |
190 | 093209cd | Blue Swirl | long bios_size;
|
191 | 1a6c0886 | j_mayer | //int phy_addr = 0;
|
192 | 1a6c0886 | j_mayer | //static int phy_addr = 1;
|
193 | 093209cd | Blue Swirl | target_ulong kernel_base, initrd_base; |
194 | 093209cd | Blue Swirl | long kernel_size, initrd_size;
|
195 | 1a6c0886 | j_mayer | int linux_boot;
|
196 | 1a6c0886 | j_mayer | int fl_idx, fl_sectors, len;
|
197 | 751c6a17 | Gerd Hoffmann | DriveInfo *dinfo; |
198 | a682fd5c | Avi Kivity | MemoryRegion *sysmem = get_system_memory(); |
199 | 1a6c0886 | j_mayer | |
200 | 1a6c0886 | j_mayer | /* XXX: fix this */
|
201 | b6dcbe08 | Avi Kivity | memory_region_init_ram(&ram_memories[0], NULL, "ef405ep.ram", 0x08000000); |
202 | b6dcbe08 | Avi Kivity | ram_bases[0] = 0; |
203 | 1a6c0886 | j_mayer | ram_sizes[0] = 0x08000000; |
204 | b6dcbe08 | Avi Kivity | memory_region_init(&ram_memories[1], "ef405ep.ram1", 0); |
205 | 1a6c0886 | j_mayer | ram_bases[1] = 0x00000000; |
206 | 1a6c0886 | j_mayer | ram_sizes[1] = 0x00000000; |
207 | 1a6c0886 | j_mayer | ram_size = 128 * 1024 * 1024; |
208 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
209 | 1a6c0886 | j_mayer | printf("%s: register cpu\n", __func__);
|
210 | 1a6c0886 | j_mayer | #endif
|
211 | a682fd5c | Avi Kivity | env = ppc405ep_init(sysmem, ram_memories, ram_bases, ram_sizes, |
212 | 52ce55a1 | Richard Henderson | 33333333, &pic, kernel_filename == NULL ? 0 : 1); |
213 | 1a6c0886 | j_mayer | /* allocate SRAM */
|
214 | 5c130f65 | pbrook | sram_size = 512 * 1024; |
215 | a682fd5c | Avi Kivity | memory_region_init_ram(sram, NULL, "ef405ep.sram", sram_size); |
216 | a682fd5c | Avi Kivity | memory_region_add_subregion(sysmem, 0xFFF00000, sram);
|
217 | 1a6c0886 | j_mayer | /* allocate and load BIOS */
|
218 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
219 | 1a6c0886 | j_mayer | printf("%s: register BIOS\n", __func__);
|
220 | 1a6c0886 | j_mayer | #endif
|
221 | 1a6c0886 | j_mayer | fl_idx = 0;
|
222 | 1a6c0886 | j_mayer | #ifdef USE_FLASH_BIOS
|
223 | 751c6a17 | Gerd Hoffmann | dinfo = drive_get(IF_PFLASH, 0, fl_idx);
|
224 | 751c6a17 | Gerd Hoffmann | if (dinfo) {
|
225 | 751c6a17 | Gerd Hoffmann | bios_size = bdrv_getlength(dinfo->bdrv); |
226 | 1a6c0886 | j_mayer | fl_sectors = (bios_size + 65535) >> 16; |
227 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
228 | 093209cd | Blue Swirl | printf("Register parallel flash %d size %lx"
|
229 | cfe5f011 | Avi Kivity | " at addr %lx '%s' %d\n",
|
230 | cfe5f011 | Avi Kivity | fl_idx, bios_size, -bios_size, |
231 | 751c6a17 | Gerd Hoffmann | bdrv_get_device_name(dinfo->bdrv), fl_sectors); |
232 | 1a6c0886 | j_mayer | #endif
|
233 | cfe5f011 | Avi Kivity | pflash_cfi02_register((uint32_t)(-bios_size), |
234 | cfe5f011 | Avi Kivity | NULL, "ef405ep.bios", bios_size, |
235 | 751c6a17 | Gerd Hoffmann | dinfo->bdrv, 65536, fl_sectors, 1, |
236 | 01e0451a | Anthony Liguori | 2, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA, |
237 | 01e0451a | Anthony Liguori | 1);
|
238 | 1a6c0886 | j_mayer | fl_idx++; |
239 | 1a6c0886 | j_mayer | } else
|
240 | 1a6c0886 | j_mayer | #endif
|
241 | 1a6c0886 | j_mayer | { |
242 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
243 | 1a6c0886 | j_mayer | printf("Load BIOS from file\n");
|
244 | 1a6c0886 | j_mayer | #endif
|
245 | cfe5f011 | Avi Kivity | bios = g_new(MemoryRegion, 1);
|
246 | cfe5f011 | Avi Kivity | memory_region_init_ram(bios, NULL, "ef405ep.bios", BIOS_SIZE); |
247 | 1192dad8 | j_mayer | if (bios_name == NULL) |
248 | 1192dad8 | j_mayer | bios_name = BIOS_FILENAME; |
249 | 5cea8590 | Paul Brook | filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); |
250 | 5cea8590 | Paul Brook | if (filename) {
|
251 | cfe5f011 | Avi Kivity | bios_size = load_image(filename, memory_region_get_ram_ptr(bios)); |
252 | 7267c094 | Anthony Liguori | g_free(filename); |
253 | 5cea8590 | Paul Brook | } else {
|
254 | 5cea8590 | Paul Brook | bios_size = -1;
|
255 | 5cea8590 | Paul Brook | } |
256 | 1a6c0886 | j_mayer | if (bios_size < 0 || bios_size > BIOS_SIZE) { |
257 | 5cea8590 | Paul Brook | fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n",
|
258 | 5cea8590 | Paul Brook | bios_name); |
259 | 1a6c0886 | j_mayer | exit(1);
|
260 | 1a6c0886 | j_mayer | } |
261 | 1a6c0886 | j_mayer | bios_size = (bios_size + 0xfff) & ~0xfff; |
262 | cfe5f011 | Avi Kivity | memory_region_set_readonly(bios, true);
|
263 | a682fd5c | Avi Kivity | memory_region_add_subregion(sysmem, (uint32_t)(-bios_size), bios); |
264 | 1a6c0886 | j_mayer | } |
265 | 1a6c0886 | j_mayer | /* Register FPGA */
|
266 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
267 | 1a6c0886 | j_mayer | printf("%s: register FPGA\n", __func__);
|
268 | 1a6c0886 | j_mayer | #endif
|
269 | a682fd5c | Avi Kivity | ref405ep_fpga_init(sysmem, 0xF0300000);
|
270 | 1a6c0886 | j_mayer | /* Register NVRAM */
|
271 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
272 | 1a6c0886 | j_mayer | printf("%s: register NVRAM\n", __func__);
|
273 | 1a6c0886 | j_mayer | #endif
|
274 | 1a6c0886 | j_mayer | m48t59_init(NULL, 0xF0000000, 0, 8192, 8); |
275 | 1a6c0886 | j_mayer | /* Load kernel */
|
276 | 1a6c0886 | j_mayer | linux_boot = (kernel_filename != NULL);
|
277 | 1a6c0886 | j_mayer | if (linux_boot) {
|
278 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
279 | 1a6c0886 | j_mayer | printf("%s: load kernel\n", __func__);
|
280 | 1a6c0886 | j_mayer | #endif
|
281 | 1a6c0886 | j_mayer | memset(&bd, 0, sizeof(bd)); |
282 | 1a6c0886 | j_mayer | bd.bi_memstart = 0x00000000;
|
283 | 1a6c0886 | j_mayer | bd.bi_memsize = ram_size; |
284 | 217fae2d | j_mayer | bd.bi_flashstart = -bios_size; |
285 | 1a6c0886 | j_mayer | bd.bi_flashsize = -bios_size; |
286 | 1a6c0886 | j_mayer | bd.bi_flashoffset = 0;
|
287 | 1a6c0886 | j_mayer | bd.bi_sramstart = 0xFFF00000;
|
288 | 1a6c0886 | j_mayer | bd.bi_sramsize = sram_size; |
289 | 1a6c0886 | j_mayer | bd.bi_bootflags = 0;
|
290 | 1a6c0886 | j_mayer | bd.bi_intfreq = 133333333;
|
291 | 1a6c0886 | j_mayer | bd.bi_busfreq = 33333333;
|
292 | 1a6c0886 | j_mayer | bd.bi_baudrate = 115200;
|
293 | 1a6c0886 | j_mayer | bd.bi_s_version[0] = 'Q'; |
294 | 1a6c0886 | j_mayer | bd.bi_s_version[1] = 'M'; |
295 | 1a6c0886 | j_mayer | bd.bi_s_version[2] = 'U'; |
296 | 1a6c0886 | j_mayer | bd.bi_s_version[3] = '\0'; |
297 | 1a6c0886 | j_mayer | bd.bi_r_version[0] = 'Q'; |
298 | 1a6c0886 | j_mayer | bd.bi_r_version[1] = 'E'; |
299 | 1a6c0886 | j_mayer | bd.bi_r_version[2] = 'M'; |
300 | 1a6c0886 | j_mayer | bd.bi_r_version[3] = 'U'; |
301 | 1a6c0886 | j_mayer | bd.bi_r_version[4] = '\0'; |
302 | 1a6c0886 | j_mayer | bd.bi_procfreq = 133333333;
|
303 | 1a6c0886 | j_mayer | bd.bi_plb_busfreq = 33333333;
|
304 | 1a6c0886 | j_mayer | bd.bi_pci_busfreq = 33333333;
|
305 | 1a6c0886 | j_mayer | bd.bi_opbfreq = 33333333;
|
306 | b8d3f5d1 | j_mayer | bdloc = ppc405_set_bootinfo(env, &bd, 0x00000001);
|
307 | 1a6c0886 | j_mayer | env->gpr[3] = bdloc;
|
308 | 1a6c0886 | j_mayer | kernel_base = KERNEL_LOAD_ADDR; |
309 | 1a6c0886 | j_mayer | /* now we can load the kernel */
|
310 | 5c130f65 | pbrook | kernel_size = load_image_targphys(kernel_filename, kernel_base, |
311 | 5c130f65 | pbrook | ram_size - kernel_base); |
312 | 1a6c0886 | j_mayer | if (kernel_size < 0) { |
313 | 5fafdf24 | ths | fprintf(stderr, "qemu: could not load kernel '%s'\n",
|
314 | 1a6c0886 | j_mayer | kernel_filename); |
315 | 1a6c0886 | j_mayer | exit(1);
|
316 | 1a6c0886 | j_mayer | } |
317 | 093209cd | Blue Swirl | printf("Load kernel size %ld at " TARGET_FMT_lx,
|
318 | 5c130f65 | pbrook | kernel_size, kernel_base); |
319 | 1a6c0886 | j_mayer | /* load initrd */
|
320 | 1a6c0886 | j_mayer | if (initrd_filename) {
|
321 | 1a6c0886 | j_mayer | initrd_base = INITRD_LOAD_ADDR; |
322 | 5c130f65 | pbrook | initrd_size = load_image_targphys(initrd_filename, initrd_base, |
323 | 5c130f65 | pbrook | ram_size - initrd_base); |
324 | 1a6c0886 | j_mayer | if (initrd_size < 0) { |
325 | 5fafdf24 | ths | fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
|
326 | 1a6c0886 | j_mayer | initrd_filename); |
327 | 1a6c0886 | j_mayer | exit(1);
|
328 | 1a6c0886 | j_mayer | } |
329 | 1a6c0886 | j_mayer | } else {
|
330 | 1a6c0886 | j_mayer | initrd_base = 0;
|
331 | 1a6c0886 | j_mayer | initrd_size = 0;
|
332 | 1a6c0886 | j_mayer | } |
333 | 1a6c0886 | j_mayer | env->gpr[4] = initrd_base;
|
334 | 1a6c0886 | j_mayer | env->gpr[5] = initrd_size;
|
335 | 1a6c0886 | j_mayer | if (kernel_cmdline != NULL) { |
336 | 1a6c0886 | j_mayer | len = strlen(kernel_cmdline); |
337 | 1a6c0886 | j_mayer | bdloc -= ((len + 255) & ~255); |
338 | 5c130f65 | pbrook | cpu_physical_memory_write(bdloc, (void *)kernel_cmdline, len + 1); |
339 | 1a6c0886 | j_mayer | env->gpr[6] = bdloc;
|
340 | 1a6c0886 | j_mayer | env->gpr[7] = bdloc + len;
|
341 | 1a6c0886 | j_mayer | } else {
|
342 | 1a6c0886 | j_mayer | env->gpr[6] = 0; |
343 | 1a6c0886 | j_mayer | env->gpr[7] = 0; |
344 | 1a6c0886 | j_mayer | } |
345 | 1a6c0886 | j_mayer | env->nip = KERNEL_LOAD_ADDR; |
346 | 1a6c0886 | j_mayer | } else {
|
347 | 1a6c0886 | j_mayer | kernel_base = 0;
|
348 | 1a6c0886 | j_mayer | kernel_size = 0;
|
349 | 1a6c0886 | j_mayer | initrd_base = 0;
|
350 | 1a6c0886 | j_mayer | initrd_size = 0;
|
351 | 1a6c0886 | j_mayer | bdloc = 0;
|
352 | 1a6c0886 | j_mayer | } |
353 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
354 | 1a6c0886 | j_mayer | printf("%s: Done\n", __func__);
|
355 | 1a6c0886 | j_mayer | #endif
|
356 | e5697f20 | Stefan Hajnoczi | printf("bdloc " RAM_ADDR_FMT "\n", bdloc); |
357 | 1a6c0886 | j_mayer | } |
358 | 1a6c0886 | j_mayer | |
359 | f80f9ec9 | Anthony Liguori | static QEMUMachine ref405ep_machine = {
|
360 | 4b32e168 | aliguori | .name = "ref405ep",
|
361 | 4b32e168 | aliguori | .desc = "ref405ep",
|
362 | 4b32e168 | aliguori | .init = ref405ep_init, |
363 | 1a6c0886 | j_mayer | }; |
364 | 1a6c0886 | j_mayer | |
365 | 1a6c0886 | j_mayer | /*****************************************************************************/
|
366 | 1a6c0886 | j_mayer | /* AMCC Taihu evaluation board */
|
367 | 1a6c0886 | j_mayer | /* - PowerPC 405EP processor
|
368 | 1a6c0886 | j_mayer | * - SDRAM 128 MB at 0x00000000
|
369 | 1a6c0886 | j_mayer | * - Boot flash 2 MB at 0xFFE00000
|
370 | 1a6c0886 | j_mayer | * - Application flash 32 MB at 0xFC000000
|
371 | 1a6c0886 | j_mayer | * - 2 serial ports
|
372 | 1a6c0886 | j_mayer | * - 2 ethernet PHY
|
373 | 1a6c0886 | j_mayer | * - 1 USB 1.1 device 0x50000000
|
374 | 1a6c0886 | j_mayer | * - 1 LCD display 0x50100000
|
375 | 1a6c0886 | j_mayer | * - 1 CPLD 0x50100000
|
376 | 1a6c0886 | j_mayer | * - 1 I2C EEPROM
|
377 | 1a6c0886 | j_mayer | * - 1 I2C thermal sensor
|
378 | 1a6c0886 | j_mayer | * - a set of LEDs
|
379 | 1a6c0886 | j_mayer | * - bit-bang SPI port using GPIOs
|
380 | 1a6c0886 | j_mayer | * - 1 EBC interface connector 0 0x50200000
|
381 | 1a6c0886 | j_mayer | * - 1 cardbus controller + expansion slot.
|
382 | 1a6c0886 | j_mayer | * - 1 PCI expansion slot.
|
383 | 1a6c0886 | j_mayer | */
|
384 | 1a6c0886 | j_mayer | typedef struct taihu_cpld_t taihu_cpld_t; |
385 | 1a6c0886 | j_mayer | struct taihu_cpld_t {
|
386 | 1a6c0886 | j_mayer | uint8_t reg0; |
387 | 1a6c0886 | j_mayer | uint8_t reg1; |
388 | 1a6c0886 | j_mayer | }; |
389 | 1a6c0886 | j_mayer | |
390 | c227f099 | Anthony Liguori | static uint32_t taihu_cpld_readb (void *opaque, target_phys_addr_t addr) |
391 | 1a6c0886 | j_mayer | { |
392 | 1a6c0886 | j_mayer | taihu_cpld_t *cpld; |
393 | 1a6c0886 | j_mayer | uint32_t ret; |
394 | 1a6c0886 | j_mayer | |
395 | 1a6c0886 | j_mayer | cpld = opaque; |
396 | 1a6c0886 | j_mayer | switch (addr) {
|
397 | 1a6c0886 | j_mayer | case 0x0: |
398 | 1a6c0886 | j_mayer | ret = cpld->reg0; |
399 | 1a6c0886 | j_mayer | break;
|
400 | 1a6c0886 | j_mayer | case 0x1: |
401 | 1a6c0886 | j_mayer | ret = cpld->reg1; |
402 | 1a6c0886 | j_mayer | break;
|
403 | 1a6c0886 | j_mayer | default:
|
404 | 1a6c0886 | j_mayer | ret = 0;
|
405 | 1a6c0886 | j_mayer | break;
|
406 | 1a6c0886 | j_mayer | } |
407 | 1a6c0886 | j_mayer | |
408 | 1a6c0886 | j_mayer | return ret;
|
409 | 1a6c0886 | j_mayer | } |
410 | 1a6c0886 | j_mayer | |
411 | 1a6c0886 | j_mayer | static void taihu_cpld_writeb (void *opaque, |
412 | c227f099 | Anthony Liguori | target_phys_addr_t addr, uint32_t value) |
413 | 1a6c0886 | j_mayer | { |
414 | 1a6c0886 | j_mayer | taihu_cpld_t *cpld; |
415 | 1a6c0886 | j_mayer | |
416 | 1a6c0886 | j_mayer | cpld = opaque; |
417 | 1a6c0886 | j_mayer | switch (addr) {
|
418 | 1a6c0886 | j_mayer | case 0x0: |
419 | 1a6c0886 | j_mayer | /* Read only */
|
420 | 1a6c0886 | j_mayer | break;
|
421 | 1a6c0886 | j_mayer | case 0x1: |
422 | 1a6c0886 | j_mayer | cpld->reg1 = value; |
423 | 1a6c0886 | j_mayer | break;
|
424 | 1a6c0886 | j_mayer | default:
|
425 | 1a6c0886 | j_mayer | break;
|
426 | 1a6c0886 | j_mayer | } |
427 | 1a6c0886 | j_mayer | } |
428 | 1a6c0886 | j_mayer | |
429 | c227f099 | Anthony Liguori | static uint32_t taihu_cpld_readw (void *opaque, target_phys_addr_t addr) |
430 | 1a6c0886 | j_mayer | { |
431 | 1a6c0886 | j_mayer | uint32_t ret; |
432 | 1a6c0886 | j_mayer | |
433 | 1a6c0886 | j_mayer | ret = taihu_cpld_readb(opaque, addr) << 8;
|
434 | 1a6c0886 | j_mayer | ret |= taihu_cpld_readb(opaque, addr + 1);
|
435 | 1a6c0886 | j_mayer | |
436 | 1a6c0886 | j_mayer | return ret;
|
437 | 1a6c0886 | j_mayer | } |
438 | 1a6c0886 | j_mayer | |
439 | 1a6c0886 | j_mayer | static void taihu_cpld_writew (void *opaque, |
440 | c227f099 | Anthony Liguori | target_phys_addr_t addr, uint32_t value) |
441 | 1a6c0886 | j_mayer | { |
442 | 1a6c0886 | j_mayer | taihu_cpld_writeb(opaque, addr, (value >> 8) & 0xFF); |
443 | 1a6c0886 | j_mayer | taihu_cpld_writeb(opaque, addr + 1, value & 0xFF); |
444 | 1a6c0886 | j_mayer | } |
445 | 1a6c0886 | j_mayer | |
446 | c227f099 | Anthony Liguori | static uint32_t taihu_cpld_readl (void *opaque, target_phys_addr_t addr) |
447 | 1a6c0886 | j_mayer | { |
448 | 1a6c0886 | j_mayer | uint32_t ret; |
449 | 1a6c0886 | j_mayer | |
450 | 1a6c0886 | j_mayer | ret = taihu_cpld_readb(opaque, addr) << 24;
|
451 | 1a6c0886 | j_mayer | ret |= taihu_cpld_readb(opaque, addr + 1) << 16; |
452 | 1a6c0886 | j_mayer | ret |= taihu_cpld_readb(opaque, addr + 2) << 8; |
453 | 1a6c0886 | j_mayer | ret |= taihu_cpld_readb(opaque, addr + 3);
|
454 | 1a6c0886 | j_mayer | |
455 | 1a6c0886 | j_mayer | return ret;
|
456 | 1a6c0886 | j_mayer | } |
457 | 1a6c0886 | j_mayer | |
458 | 1a6c0886 | j_mayer | static void taihu_cpld_writel (void *opaque, |
459 | c227f099 | Anthony Liguori | target_phys_addr_t addr, uint32_t value) |
460 | 1a6c0886 | j_mayer | { |
461 | 1a6c0886 | j_mayer | taihu_cpld_writel(opaque, addr, (value >> 24) & 0xFF); |
462 | 1a6c0886 | j_mayer | taihu_cpld_writel(opaque, addr + 1, (value >> 16) & 0xFF); |
463 | 1a6c0886 | j_mayer | taihu_cpld_writel(opaque, addr + 2, (value >> 8) & 0xFF); |
464 | 1a6c0886 | j_mayer | taihu_cpld_writeb(opaque, addr + 3, value & 0xFF); |
465 | 1a6c0886 | j_mayer | } |
466 | 1a6c0886 | j_mayer | |
467 | a682fd5c | Avi Kivity | static const MemoryRegionOps taihu_cpld_ops = { |
468 | a682fd5c | Avi Kivity | .old_mmio = { |
469 | a682fd5c | Avi Kivity | .read = { taihu_cpld_readb, taihu_cpld_readw, taihu_cpld_readl, }, |
470 | a682fd5c | Avi Kivity | .write = { taihu_cpld_writeb, taihu_cpld_writew, taihu_cpld_writel, }, |
471 | a682fd5c | Avi Kivity | }, |
472 | a682fd5c | Avi Kivity | .endianness = DEVICE_NATIVE_ENDIAN, |
473 | 1a6c0886 | j_mayer | }; |
474 | 1a6c0886 | j_mayer | |
475 | 1a6c0886 | j_mayer | static void taihu_cpld_reset (void *opaque) |
476 | 1a6c0886 | j_mayer | { |
477 | 1a6c0886 | j_mayer | taihu_cpld_t *cpld; |
478 | 1a6c0886 | j_mayer | |
479 | 1a6c0886 | j_mayer | cpld = opaque; |
480 | 1a6c0886 | j_mayer | cpld->reg0 = 0x01;
|
481 | 1a6c0886 | j_mayer | cpld->reg1 = 0x80;
|
482 | 1a6c0886 | j_mayer | } |
483 | 1a6c0886 | j_mayer | |
484 | a682fd5c | Avi Kivity | static void taihu_cpld_init (MemoryRegion *sysmem, uint32_t base) |
485 | 1a6c0886 | j_mayer | { |
486 | 1a6c0886 | j_mayer | taihu_cpld_t *cpld; |
487 | a682fd5c | Avi Kivity | MemoryRegion *cpld_memory = g_new(MemoryRegion, 1);
|
488 | 1a6c0886 | j_mayer | |
489 | 7267c094 | Anthony Liguori | cpld = g_malloc0(sizeof(taihu_cpld_t));
|
490 | a682fd5c | Avi Kivity | memory_region_init_io(cpld_memory, &taihu_cpld_ops, cpld, "cpld", 0x100); |
491 | a682fd5c | Avi Kivity | memory_region_add_subregion(sysmem, base, cpld_memory); |
492 | a08d4367 | Jan Kiszka | qemu_register_reset(&taihu_cpld_reset, cpld); |
493 | 1a6c0886 | j_mayer | } |
494 | 1a6c0886 | j_mayer | |
495 | c227f099 | Anthony Liguori | static void taihu_405ep_init(ram_addr_t ram_size, |
496 | 3023f332 | aliguori | const char *boot_device, |
497 | 5fafdf24 | ths | const char *kernel_filename, |
498 | 1a6c0886 | j_mayer | const char *kernel_cmdline, |
499 | 1a6c0886 | j_mayer | const char *initrd_filename, |
500 | 1a6c0886 | j_mayer | const char *cpu_model) |
501 | 1a6c0886 | j_mayer | { |
502 | 5cea8590 | Paul Brook | char *filename;
|
503 | 1a6c0886 | j_mayer | qemu_irq *pic; |
504 | a682fd5c | Avi Kivity | MemoryRegion *sysmem = get_system_memory(); |
505 | cfe5f011 | Avi Kivity | MemoryRegion *bios; |
506 | b6dcbe08 | Avi Kivity | MemoryRegion *ram_memories = g_malloc(2 * sizeof(*ram_memories)); |
507 | c227f099 | Anthony Liguori | target_phys_addr_t ram_bases[2], ram_sizes[2]; |
508 | 093209cd | Blue Swirl | long bios_size;
|
509 | 093209cd | Blue Swirl | target_ulong kernel_base, initrd_base; |
510 | 093209cd | Blue Swirl | long kernel_size, initrd_size;
|
511 | 1a6c0886 | j_mayer | int linux_boot;
|
512 | 1a6c0886 | j_mayer | int fl_idx, fl_sectors;
|
513 | 751c6a17 | Gerd Hoffmann | DriveInfo *dinfo; |
514 | 3b46e624 | ths | |
515 | 1a6c0886 | j_mayer | /* RAM is soldered to the board so the size cannot be changed */
|
516 | b6dcbe08 | Avi Kivity | memory_region_init_ram(&ram_memories[0], NULL, |
517 | b6dcbe08 | Avi Kivity | "taihu_405ep.ram-0", 0x04000000); |
518 | b6dcbe08 | Avi Kivity | ram_bases[0] = 0; |
519 | 1a6c0886 | j_mayer | ram_sizes[0] = 0x04000000; |
520 | b6dcbe08 | Avi Kivity | memory_region_init_ram(&ram_memories[1], NULL, |
521 | b6dcbe08 | Avi Kivity | "taihu_405ep.ram-1", 0x04000000); |
522 | b6dcbe08 | Avi Kivity | ram_bases[1] = 0x04000000; |
523 | 1a6c0886 | j_mayer | ram_sizes[1] = 0x04000000; |
524 | a0b753df | pbrook | ram_size = 0x08000000;
|
525 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
526 | 1a6c0886 | j_mayer | printf("%s: register cpu\n", __func__);
|
527 | 1a6c0886 | j_mayer | #endif
|
528 | a682fd5c | Avi Kivity | ppc405ep_init(sysmem, ram_memories, ram_bases, ram_sizes, |
529 | 52ce55a1 | Richard Henderson | 33333333, &pic, kernel_filename == NULL ? 0 : 1); |
530 | 1a6c0886 | j_mayer | /* allocate and load BIOS */
|
531 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
532 | 1a6c0886 | j_mayer | printf("%s: register BIOS\n", __func__);
|
533 | 1a6c0886 | j_mayer | #endif
|
534 | 1a6c0886 | j_mayer | fl_idx = 0;
|
535 | 1a6c0886 | j_mayer | #if defined(USE_FLASH_BIOS)
|
536 | 751c6a17 | Gerd Hoffmann | dinfo = drive_get(IF_PFLASH, 0, fl_idx);
|
537 | 751c6a17 | Gerd Hoffmann | if (dinfo) {
|
538 | 751c6a17 | Gerd Hoffmann | bios_size = bdrv_getlength(dinfo->bdrv); |
539 | 1a6c0886 | j_mayer | /* XXX: should check that size is 2MB */
|
540 | 1a6c0886 | j_mayer | // bios_size = 2 * 1024 * 1024;
|
541 | 1a6c0886 | j_mayer | fl_sectors = (bios_size + 65535) >> 16; |
542 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
543 | 093209cd | Blue Swirl | printf("Register parallel flash %d size %lx"
|
544 | cfe5f011 | Avi Kivity | " at addr %lx '%s' %d\n",
|
545 | cfe5f011 | Avi Kivity | fl_idx, bios_size, -bios_size, |
546 | 751c6a17 | Gerd Hoffmann | bdrv_get_device_name(dinfo->bdrv), fl_sectors); |
547 | 1a6c0886 | j_mayer | #endif
|
548 | cfe5f011 | Avi Kivity | pflash_cfi02_register((uint32_t)(-bios_size), |
549 | cfe5f011 | Avi Kivity | NULL, "taihu_405ep.bios", bios_size, |
550 | 751c6a17 | Gerd Hoffmann | dinfo->bdrv, 65536, fl_sectors, 1, |
551 | 01e0451a | Anthony Liguori | 4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA, |
552 | 01e0451a | Anthony Liguori | 1);
|
553 | 1a6c0886 | j_mayer | fl_idx++; |
554 | 1a6c0886 | j_mayer | } else
|
555 | 1a6c0886 | j_mayer | #endif
|
556 | 1a6c0886 | j_mayer | { |
557 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
558 | 1a6c0886 | j_mayer | printf("Load BIOS from file\n");
|
559 | 1a6c0886 | j_mayer | #endif
|
560 | 1192dad8 | j_mayer | if (bios_name == NULL) |
561 | 1192dad8 | j_mayer | bios_name = BIOS_FILENAME; |
562 | cfe5f011 | Avi Kivity | bios = g_new(MemoryRegion, 1);
|
563 | cfe5f011 | Avi Kivity | memory_region_init_ram(bios, NULL, "taihu_405ep.bios", BIOS_SIZE); |
564 | 5cea8590 | Paul Brook | filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); |
565 | 5cea8590 | Paul Brook | if (filename) {
|
566 | cfe5f011 | Avi Kivity | bios_size = load_image(filename, memory_region_get_ram_ptr(bios)); |
567 | 7267c094 | Anthony Liguori | g_free(filename); |
568 | 5cea8590 | Paul Brook | } else {
|
569 | 5cea8590 | Paul Brook | bios_size = -1;
|
570 | 5cea8590 | Paul Brook | } |
571 | 1a6c0886 | j_mayer | if (bios_size < 0 || bios_size > BIOS_SIZE) { |
572 | 5cea8590 | Paul Brook | fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n",
|
573 | 5cea8590 | Paul Brook | bios_name); |
574 | 1a6c0886 | j_mayer | exit(1);
|
575 | 1a6c0886 | j_mayer | } |
576 | 1a6c0886 | j_mayer | bios_size = (bios_size + 0xfff) & ~0xfff; |
577 | cfe5f011 | Avi Kivity | memory_region_set_readonly(bios, true);
|
578 | a682fd5c | Avi Kivity | memory_region_add_subregion(sysmem, (uint32_t)(-bios_size), bios); |
579 | 1a6c0886 | j_mayer | } |
580 | 1a6c0886 | j_mayer | /* Register Linux flash */
|
581 | 751c6a17 | Gerd Hoffmann | dinfo = drive_get(IF_PFLASH, 0, fl_idx);
|
582 | 751c6a17 | Gerd Hoffmann | if (dinfo) {
|
583 | 751c6a17 | Gerd Hoffmann | bios_size = bdrv_getlength(dinfo->bdrv); |
584 | 1a6c0886 | j_mayer | /* XXX: should check that size is 32MB */
|
585 | 1a6c0886 | j_mayer | bios_size = 32 * 1024 * 1024; |
586 | 1a6c0886 | j_mayer | fl_sectors = (bios_size + 65535) >> 16; |
587 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
588 | 093209cd | Blue Swirl | printf("Register parallel flash %d size %lx"
|
589 | cfe5f011 | Avi Kivity | " at addr " TARGET_FMT_lx " '%s'\n", |
590 | cfe5f011 | Avi Kivity | fl_idx, bios_size, (target_ulong)0xfc000000,
|
591 | 751c6a17 | Gerd Hoffmann | bdrv_get_device_name(dinfo->bdrv)); |
592 | 1a6c0886 | j_mayer | #endif
|
593 | cfe5f011 | Avi Kivity | pflash_cfi02_register(0xfc000000, NULL, "taihu_405ep.flash", bios_size, |
594 | 751c6a17 | Gerd Hoffmann | dinfo->bdrv, 65536, fl_sectors, 1, |
595 | 01e0451a | Anthony Liguori | 4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA, |
596 | 01e0451a | Anthony Liguori | 1);
|
597 | 1a6c0886 | j_mayer | fl_idx++; |
598 | 1a6c0886 | j_mayer | } |
599 | 1a6c0886 | j_mayer | /* Register CLPD & LCD display */
|
600 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
601 | 1a6c0886 | j_mayer | printf("%s: register CPLD\n", __func__);
|
602 | 1a6c0886 | j_mayer | #endif
|
603 | a682fd5c | Avi Kivity | taihu_cpld_init(sysmem, 0x50100000);
|
604 | 1a6c0886 | j_mayer | /* Load kernel */
|
605 | 1a6c0886 | j_mayer | linux_boot = (kernel_filename != NULL);
|
606 | 1a6c0886 | j_mayer | if (linux_boot) {
|
607 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
608 | 1a6c0886 | j_mayer | printf("%s: load kernel\n", __func__);
|
609 | 1a6c0886 | j_mayer | #endif
|
610 | 1a6c0886 | j_mayer | kernel_base = KERNEL_LOAD_ADDR; |
611 | 1a6c0886 | j_mayer | /* now we can load the kernel */
|
612 | 5c130f65 | pbrook | kernel_size = load_image_targphys(kernel_filename, kernel_base, |
613 | 5c130f65 | pbrook | ram_size - kernel_base); |
614 | 1a6c0886 | j_mayer | if (kernel_size < 0) { |
615 | 5fafdf24 | ths | fprintf(stderr, "qemu: could not load kernel '%s'\n",
|
616 | 1a6c0886 | j_mayer | kernel_filename); |
617 | 1a6c0886 | j_mayer | exit(1);
|
618 | 1a6c0886 | j_mayer | } |
619 | 1a6c0886 | j_mayer | /* load initrd */
|
620 | 1a6c0886 | j_mayer | if (initrd_filename) {
|
621 | 1a6c0886 | j_mayer | initrd_base = INITRD_LOAD_ADDR; |
622 | 5c130f65 | pbrook | initrd_size = load_image_targphys(initrd_filename, initrd_base, |
623 | 5c130f65 | pbrook | ram_size - initrd_base); |
624 | 1a6c0886 | j_mayer | if (initrd_size < 0) { |
625 | 1a6c0886 | j_mayer | fprintf(stderr, |
626 | 5fafdf24 | ths | "qemu: could not load initial ram disk '%s'\n",
|
627 | 1a6c0886 | j_mayer | initrd_filename); |
628 | 1a6c0886 | j_mayer | exit(1);
|
629 | 1a6c0886 | j_mayer | } |
630 | 1a6c0886 | j_mayer | } else {
|
631 | 1a6c0886 | j_mayer | initrd_base = 0;
|
632 | 1a6c0886 | j_mayer | initrd_size = 0;
|
633 | 1a6c0886 | j_mayer | } |
634 | 1a6c0886 | j_mayer | } else {
|
635 | 1a6c0886 | j_mayer | kernel_base = 0;
|
636 | 1a6c0886 | j_mayer | kernel_size = 0;
|
637 | 1a6c0886 | j_mayer | initrd_base = 0;
|
638 | 1a6c0886 | j_mayer | initrd_size = 0;
|
639 | 1a6c0886 | j_mayer | } |
640 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
641 | 1a6c0886 | j_mayer | printf("%s: Done\n", __func__);
|
642 | 1a6c0886 | j_mayer | #endif
|
643 | 1a6c0886 | j_mayer | } |
644 | 1a6c0886 | j_mayer | |
645 | f80f9ec9 | Anthony Liguori | static QEMUMachine taihu_machine = {
|
646 | b2ee0ce2 | pbrook | .name = "taihu",
|
647 | b2ee0ce2 | pbrook | .desc = "taihu",
|
648 | b2ee0ce2 | pbrook | .init = taihu_405ep_init, |
649 | 1a6c0886 | j_mayer | }; |
650 | f80f9ec9 | Anthony Liguori | |
651 | f80f9ec9 | Anthony Liguori | static void ppc405_machine_init(void) |
652 | f80f9ec9 | Anthony Liguori | { |
653 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&ref405ep_machine); |
654 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&taihu_machine); |
655 | f80f9ec9 | Anthony Liguori | } |
656 | f80f9ec9 | Anthony Liguori | |
657 | f80f9ec9 | Anthony Liguori | machine_init(ppc405_machine_init); |