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