root / hw / ppc405_boards.c @ 0dad6c35
History | View | Annotate | Download (20.3 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 | c5705a77 | Avi Kivity | memory_region_init_ram(&ram_memories[0], "ef405ep.ram", 0x08000000); |
202 | c5705a77 | Avi Kivity | vmstate_register_ram_global(&ram_memories[0]);
|
203 | b6dcbe08 | Avi Kivity | ram_bases[0] = 0; |
204 | 1a6c0886 | j_mayer | ram_sizes[0] = 0x08000000; |
205 | b6dcbe08 | Avi Kivity | memory_region_init(&ram_memories[1], "ef405ep.ram1", 0); |
206 | 1a6c0886 | j_mayer | ram_bases[1] = 0x00000000; |
207 | 1a6c0886 | j_mayer | ram_sizes[1] = 0x00000000; |
208 | 1a6c0886 | j_mayer | ram_size = 128 * 1024 * 1024; |
209 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
210 | 1a6c0886 | j_mayer | printf("%s: register cpu\n", __func__);
|
211 | 1a6c0886 | j_mayer | #endif
|
212 | a682fd5c | Avi Kivity | env = ppc405ep_init(sysmem, ram_memories, ram_bases, ram_sizes, |
213 | 52ce55a1 | Richard Henderson | 33333333, &pic, kernel_filename == NULL ? 0 : 1); |
214 | 1a6c0886 | j_mayer | /* allocate SRAM */
|
215 | 5c130f65 | pbrook | sram_size = 512 * 1024; |
216 | c5705a77 | Avi Kivity | memory_region_init_ram(sram, "ef405ep.sram", sram_size);
|
217 | c5705a77 | Avi Kivity | vmstate_register_ram_global(sram); |
218 | a682fd5c | Avi Kivity | memory_region_add_subregion(sysmem, 0xFFF00000, sram);
|
219 | 1a6c0886 | j_mayer | /* allocate and load BIOS */
|
220 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
221 | 1a6c0886 | j_mayer | printf("%s: register BIOS\n", __func__);
|
222 | 1a6c0886 | j_mayer | #endif
|
223 | 1a6c0886 | j_mayer | fl_idx = 0;
|
224 | 1a6c0886 | j_mayer | #ifdef USE_FLASH_BIOS
|
225 | 751c6a17 | Gerd Hoffmann | dinfo = drive_get(IF_PFLASH, 0, fl_idx);
|
226 | 751c6a17 | Gerd Hoffmann | if (dinfo) {
|
227 | 751c6a17 | Gerd Hoffmann | bios_size = bdrv_getlength(dinfo->bdrv); |
228 | 1a6c0886 | j_mayer | fl_sectors = (bios_size + 65535) >> 16; |
229 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
230 | 093209cd | Blue Swirl | printf("Register parallel flash %d size %lx"
|
231 | cfe5f011 | Avi Kivity | " at addr %lx '%s' %d\n",
|
232 | cfe5f011 | Avi Kivity | fl_idx, bios_size, -bios_size, |
233 | 751c6a17 | Gerd Hoffmann | bdrv_get_device_name(dinfo->bdrv), fl_sectors); |
234 | 1a6c0886 | j_mayer | #endif
|
235 | cfe5f011 | Avi Kivity | pflash_cfi02_register((uint32_t)(-bios_size), |
236 | cfe5f011 | Avi Kivity | NULL, "ef405ep.bios", bios_size, |
237 | 751c6a17 | Gerd Hoffmann | dinfo->bdrv, 65536, fl_sectors, 1, |
238 | 01e0451a | Anthony Liguori | 2, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA, |
239 | 01e0451a | Anthony Liguori | 1);
|
240 | 1a6c0886 | j_mayer | fl_idx++; |
241 | 1a6c0886 | j_mayer | } else
|
242 | 1a6c0886 | j_mayer | #endif
|
243 | 1a6c0886 | j_mayer | { |
244 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
245 | 1a6c0886 | j_mayer | printf("Load BIOS from file\n");
|
246 | 1a6c0886 | j_mayer | #endif
|
247 | cfe5f011 | Avi Kivity | bios = g_new(MemoryRegion, 1);
|
248 | c5705a77 | Avi Kivity | memory_region_init_ram(bios, "ef405ep.bios", BIOS_SIZE);
|
249 | c5705a77 | Avi Kivity | vmstate_register_ram_global(bios); |
250 | 1192dad8 | j_mayer | if (bios_name == NULL) |
251 | 1192dad8 | j_mayer | bios_name = BIOS_FILENAME; |
252 | 5cea8590 | Paul Brook | filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); |
253 | 5cea8590 | Paul Brook | if (filename) {
|
254 | cfe5f011 | Avi Kivity | bios_size = load_image(filename, memory_region_get_ram_ptr(bios)); |
255 | 7267c094 | Anthony Liguori | g_free(filename); |
256 | 5cea8590 | Paul Brook | } else {
|
257 | 5cea8590 | Paul Brook | bios_size = -1;
|
258 | 5cea8590 | Paul Brook | } |
259 | 1a6c0886 | j_mayer | if (bios_size < 0 || bios_size > BIOS_SIZE) { |
260 | 5cea8590 | Paul Brook | fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n",
|
261 | 5cea8590 | Paul Brook | bios_name); |
262 | 1a6c0886 | j_mayer | exit(1);
|
263 | 1a6c0886 | j_mayer | } |
264 | 1a6c0886 | j_mayer | bios_size = (bios_size + 0xfff) & ~0xfff; |
265 | cfe5f011 | Avi Kivity | memory_region_set_readonly(bios, true);
|
266 | a682fd5c | Avi Kivity | memory_region_add_subregion(sysmem, (uint32_t)(-bios_size), bios); |
267 | 1a6c0886 | j_mayer | } |
268 | 1a6c0886 | j_mayer | /* Register FPGA */
|
269 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
270 | 1a6c0886 | j_mayer | printf("%s: register FPGA\n", __func__);
|
271 | 1a6c0886 | j_mayer | #endif
|
272 | a682fd5c | Avi Kivity | ref405ep_fpga_init(sysmem, 0xF0300000);
|
273 | 1a6c0886 | j_mayer | /* Register NVRAM */
|
274 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
275 | 1a6c0886 | j_mayer | printf("%s: register NVRAM\n", __func__);
|
276 | 1a6c0886 | j_mayer | #endif
|
277 | 1a6c0886 | j_mayer | m48t59_init(NULL, 0xF0000000, 0, 8192, 8); |
278 | 1a6c0886 | j_mayer | /* Load kernel */
|
279 | 1a6c0886 | j_mayer | linux_boot = (kernel_filename != NULL);
|
280 | 1a6c0886 | j_mayer | if (linux_boot) {
|
281 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
282 | 1a6c0886 | j_mayer | printf("%s: load kernel\n", __func__);
|
283 | 1a6c0886 | j_mayer | #endif
|
284 | 1a6c0886 | j_mayer | memset(&bd, 0, sizeof(bd)); |
285 | 1a6c0886 | j_mayer | bd.bi_memstart = 0x00000000;
|
286 | 1a6c0886 | j_mayer | bd.bi_memsize = ram_size; |
287 | 217fae2d | j_mayer | bd.bi_flashstart = -bios_size; |
288 | 1a6c0886 | j_mayer | bd.bi_flashsize = -bios_size; |
289 | 1a6c0886 | j_mayer | bd.bi_flashoffset = 0;
|
290 | 1a6c0886 | j_mayer | bd.bi_sramstart = 0xFFF00000;
|
291 | 1a6c0886 | j_mayer | bd.bi_sramsize = sram_size; |
292 | 1a6c0886 | j_mayer | bd.bi_bootflags = 0;
|
293 | 1a6c0886 | j_mayer | bd.bi_intfreq = 133333333;
|
294 | 1a6c0886 | j_mayer | bd.bi_busfreq = 33333333;
|
295 | 1a6c0886 | j_mayer | bd.bi_baudrate = 115200;
|
296 | 1a6c0886 | j_mayer | bd.bi_s_version[0] = 'Q'; |
297 | 1a6c0886 | j_mayer | bd.bi_s_version[1] = 'M'; |
298 | 1a6c0886 | j_mayer | bd.bi_s_version[2] = 'U'; |
299 | 1a6c0886 | j_mayer | bd.bi_s_version[3] = '\0'; |
300 | 1a6c0886 | j_mayer | bd.bi_r_version[0] = 'Q'; |
301 | 1a6c0886 | j_mayer | bd.bi_r_version[1] = 'E'; |
302 | 1a6c0886 | j_mayer | bd.bi_r_version[2] = 'M'; |
303 | 1a6c0886 | j_mayer | bd.bi_r_version[3] = 'U'; |
304 | 1a6c0886 | j_mayer | bd.bi_r_version[4] = '\0'; |
305 | 1a6c0886 | j_mayer | bd.bi_procfreq = 133333333;
|
306 | 1a6c0886 | j_mayer | bd.bi_plb_busfreq = 33333333;
|
307 | 1a6c0886 | j_mayer | bd.bi_pci_busfreq = 33333333;
|
308 | 1a6c0886 | j_mayer | bd.bi_opbfreq = 33333333;
|
309 | b8d3f5d1 | j_mayer | bdloc = ppc405_set_bootinfo(env, &bd, 0x00000001);
|
310 | 1a6c0886 | j_mayer | env->gpr[3] = bdloc;
|
311 | 1a6c0886 | j_mayer | kernel_base = KERNEL_LOAD_ADDR; |
312 | 1a6c0886 | j_mayer | /* now we can load the kernel */
|
313 | 5c130f65 | pbrook | kernel_size = load_image_targphys(kernel_filename, kernel_base, |
314 | 5c130f65 | pbrook | ram_size - kernel_base); |
315 | 1a6c0886 | j_mayer | if (kernel_size < 0) { |
316 | 5fafdf24 | ths | fprintf(stderr, "qemu: could not load kernel '%s'\n",
|
317 | 1a6c0886 | j_mayer | kernel_filename); |
318 | 1a6c0886 | j_mayer | exit(1);
|
319 | 1a6c0886 | j_mayer | } |
320 | 093209cd | Blue Swirl | printf("Load kernel size %ld at " TARGET_FMT_lx,
|
321 | 5c130f65 | pbrook | kernel_size, kernel_base); |
322 | 1a6c0886 | j_mayer | /* load initrd */
|
323 | 1a6c0886 | j_mayer | if (initrd_filename) {
|
324 | 1a6c0886 | j_mayer | initrd_base = INITRD_LOAD_ADDR; |
325 | 5c130f65 | pbrook | initrd_size = load_image_targphys(initrd_filename, initrd_base, |
326 | 5c130f65 | pbrook | ram_size - initrd_base); |
327 | 1a6c0886 | j_mayer | if (initrd_size < 0) { |
328 | 5fafdf24 | ths | fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
|
329 | 1a6c0886 | j_mayer | initrd_filename); |
330 | 1a6c0886 | j_mayer | exit(1);
|
331 | 1a6c0886 | j_mayer | } |
332 | 1a6c0886 | j_mayer | } else {
|
333 | 1a6c0886 | j_mayer | initrd_base = 0;
|
334 | 1a6c0886 | j_mayer | initrd_size = 0;
|
335 | 1a6c0886 | j_mayer | } |
336 | 1a6c0886 | j_mayer | env->gpr[4] = initrd_base;
|
337 | 1a6c0886 | j_mayer | env->gpr[5] = initrd_size;
|
338 | 1a6c0886 | j_mayer | if (kernel_cmdline != NULL) { |
339 | 1a6c0886 | j_mayer | len = strlen(kernel_cmdline); |
340 | 1a6c0886 | j_mayer | bdloc -= ((len + 255) & ~255); |
341 | 5c130f65 | pbrook | cpu_physical_memory_write(bdloc, (void *)kernel_cmdline, len + 1); |
342 | 1a6c0886 | j_mayer | env->gpr[6] = bdloc;
|
343 | 1a6c0886 | j_mayer | env->gpr[7] = bdloc + len;
|
344 | 1a6c0886 | j_mayer | } else {
|
345 | 1a6c0886 | j_mayer | env->gpr[6] = 0; |
346 | 1a6c0886 | j_mayer | env->gpr[7] = 0; |
347 | 1a6c0886 | j_mayer | } |
348 | 1a6c0886 | j_mayer | env->nip = KERNEL_LOAD_ADDR; |
349 | 1a6c0886 | j_mayer | } else {
|
350 | 1a6c0886 | j_mayer | kernel_base = 0;
|
351 | 1a6c0886 | j_mayer | kernel_size = 0;
|
352 | 1a6c0886 | j_mayer | initrd_base = 0;
|
353 | 1a6c0886 | j_mayer | initrd_size = 0;
|
354 | 1a6c0886 | j_mayer | bdloc = 0;
|
355 | 1a6c0886 | j_mayer | } |
356 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
357 | 1a6c0886 | j_mayer | printf("%s: Done\n", __func__);
|
358 | 1a6c0886 | j_mayer | #endif
|
359 | e5697f20 | Stefan Hajnoczi | printf("bdloc " RAM_ADDR_FMT "\n", bdloc); |
360 | 1a6c0886 | j_mayer | } |
361 | 1a6c0886 | j_mayer | |
362 | f80f9ec9 | Anthony Liguori | static QEMUMachine ref405ep_machine = {
|
363 | 4b32e168 | aliguori | .name = "ref405ep",
|
364 | 4b32e168 | aliguori | .desc = "ref405ep",
|
365 | 4b32e168 | aliguori | .init = ref405ep_init, |
366 | 1a6c0886 | j_mayer | }; |
367 | 1a6c0886 | j_mayer | |
368 | 1a6c0886 | j_mayer | /*****************************************************************************/
|
369 | 1a6c0886 | j_mayer | /* AMCC Taihu evaluation board */
|
370 | 1a6c0886 | j_mayer | /* - PowerPC 405EP processor
|
371 | 1a6c0886 | j_mayer | * - SDRAM 128 MB at 0x00000000
|
372 | 1a6c0886 | j_mayer | * - Boot flash 2 MB at 0xFFE00000
|
373 | 1a6c0886 | j_mayer | * - Application flash 32 MB at 0xFC000000
|
374 | 1a6c0886 | j_mayer | * - 2 serial ports
|
375 | 1a6c0886 | j_mayer | * - 2 ethernet PHY
|
376 | 1a6c0886 | j_mayer | * - 1 USB 1.1 device 0x50000000
|
377 | 1a6c0886 | j_mayer | * - 1 LCD display 0x50100000
|
378 | 1a6c0886 | j_mayer | * - 1 CPLD 0x50100000
|
379 | 1a6c0886 | j_mayer | * - 1 I2C EEPROM
|
380 | 1a6c0886 | j_mayer | * - 1 I2C thermal sensor
|
381 | 1a6c0886 | j_mayer | * - a set of LEDs
|
382 | 1a6c0886 | j_mayer | * - bit-bang SPI port using GPIOs
|
383 | 1a6c0886 | j_mayer | * - 1 EBC interface connector 0 0x50200000
|
384 | 1a6c0886 | j_mayer | * - 1 cardbus controller + expansion slot.
|
385 | 1a6c0886 | j_mayer | * - 1 PCI expansion slot.
|
386 | 1a6c0886 | j_mayer | */
|
387 | 1a6c0886 | j_mayer | typedef struct taihu_cpld_t taihu_cpld_t; |
388 | 1a6c0886 | j_mayer | struct taihu_cpld_t {
|
389 | 1a6c0886 | j_mayer | uint8_t reg0; |
390 | 1a6c0886 | j_mayer | uint8_t reg1; |
391 | 1a6c0886 | j_mayer | }; |
392 | 1a6c0886 | j_mayer | |
393 | c227f099 | Anthony Liguori | static uint32_t taihu_cpld_readb (void *opaque, target_phys_addr_t addr) |
394 | 1a6c0886 | j_mayer | { |
395 | 1a6c0886 | j_mayer | taihu_cpld_t *cpld; |
396 | 1a6c0886 | j_mayer | uint32_t ret; |
397 | 1a6c0886 | j_mayer | |
398 | 1a6c0886 | j_mayer | cpld = opaque; |
399 | 1a6c0886 | j_mayer | switch (addr) {
|
400 | 1a6c0886 | j_mayer | case 0x0: |
401 | 1a6c0886 | j_mayer | ret = cpld->reg0; |
402 | 1a6c0886 | j_mayer | break;
|
403 | 1a6c0886 | j_mayer | case 0x1: |
404 | 1a6c0886 | j_mayer | ret = cpld->reg1; |
405 | 1a6c0886 | j_mayer | break;
|
406 | 1a6c0886 | j_mayer | default:
|
407 | 1a6c0886 | j_mayer | ret = 0;
|
408 | 1a6c0886 | j_mayer | break;
|
409 | 1a6c0886 | j_mayer | } |
410 | 1a6c0886 | j_mayer | |
411 | 1a6c0886 | j_mayer | return ret;
|
412 | 1a6c0886 | j_mayer | } |
413 | 1a6c0886 | j_mayer | |
414 | 1a6c0886 | j_mayer | static void taihu_cpld_writeb (void *opaque, |
415 | c227f099 | Anthony Liguori | target_phys_addr_t addr, uint32_t value) |
416 | 1a6c0886 | j_mayer | { |
417 | 1a6c0886 | j_mayer | taihu_cpld_t *cpld; |
418 | 1a6c0886 | j_mayer | |
419 | 1a6c0886 | j_mayer | cpld = opaque; |
420 | 1a6c0886 | j_mayer | switch (addr) {
|
421 | 1a6c0886 | j_mayer | case 0x0: |
422 | 1a6c0886 | j_mayer | /* Read only */
|
423 | 1a6c0886 | j_mayer | break;
|
424 | 1a6c0886 | j_mayer | case 0x1: |
425 | 1a6c0886 | j_mayer | cpld->reg1 = value; |
426 | 1a6c0886 | j_mayer | break;
|
427 | 1a6c0886 | j_mayer | default:
|
428 | 1a6c0886 | j_mayer | break;
|
429 | 1a6c0886 | j_mayer | } |
430 | 1a6c0886 | j_mayer | } |
431 | 1a6c0886 | j_mayer | |
432 | c227f099 | Anthony Liguori | static uint32_t taihu_cpld_readw (void *opaque, target_phys_addr_t addr) |
433 | 1a6c0886 | j_mayer | { |
434 | 1a6c0886 | j_mayer | uint32_t ret; |
435 | 1a6c0886 | j_mayer | |
436 | 1a6c0886 | j_mayer | ret = taihu_cpld_readb(opaque, addr) << 8;
|
437 | 1a6c0886 | j_mayer | ret |= taihu_cpld_readb(opaque, addr + 1);
|
438 | 1a6c0886 | j_mayer | |
439 | 1a6c0886 | j_mayer | return ret;
|
440 | 1a6c0886 | j_mayer | } |
441 | 1a6c0886 | j_mayer | |
442 | 1a6c0886 | j_mayer | static void taihu_cpld_writew (void *opaque, |
443 | c227f099 | Anthony Liguori | target_phys_addr_t addr, uint32_t value) |
444 | 1a6c0886 | j_mayer | { |
445 | 1a6c0886 | j_mayer | taihu_cpld_writeb(opaque, addr, (value >> 8) & 0xFF); |
446 | 1a6c0886 | j_mayer | taihu_cpld_writeb(opaque, addr + 1, value & 0xFF); |
447 | 1a6c0886 | j_mayer | } |
448 | 1a6c0886 | j_mayer | |
449 | c227f099 | Anthony Liguori | static uint32_t taihu_cpld_readl (void *opaque, target_phys_addr_t addr) |
450 | 1a6c0886 | j_mayer | { |
451 | 1a6c0886 | j_mayer | uint32_t ret; |
452 | 1a6c0886 | j_mayer | |
453 | 1a6c0886 | j_mayer | ret = taihu_cpld_readb(opaque, addr) << 24;
|
454 | 1a6c0886 | j_mayer | ret |= taihu_cpld_readb(opaque, addr + 1) << 16; |
455 | 1a6c0886 | j_mayer | ret |= taihu_cpld_readb(opaque, addr + 2) << 8; |
456 | 1a6c0886 | j_mayer | ret |= taihu_cpld_readb(opaque, addr + 3);
|
457 | 1a6c0886 | j_mayer | |
458 | 1a6c0886 | j_mayer | return ret;
|
459 | 1a6c0886 | j_mayer | } |
460 | 1a6c0886 | j_mayer | |
461 | 1a6c0886 | j_mayer | static void taihu_cpld_writel (void *opaque, |
462 | c227f099 | Anthony Liguori | target_phys_addr_t addr, uint32_t value) |
463 | 1a6c0886 | j_mayer | { |
464 | 1a6c0886 | j_mayer | taihu_cpld_writel(opaque, addr, (value >> 24) & 0xFF); |
465 | 1a6c0886 | j_mayer | taihu_cpld_writel(opaque, addr + 1, (value >> 16) & 0xFF); |
466 | 1a6c0886 | j_mayer | taihu_cpld_writel(opaque, addr + 2, (value >> 8) & 0xFF); |
467 | 1a6c0886 | j_mayer | taihu_cpld_writeb(opaque, addr + 3, value & 0xFF); |
468 | 1a6c0886 | j_mayer | } |
469 | 1a6c0886 | j_mayer | |
470 | a682fd5c | Avi Kivity | static const MemoryRegionOps taihu_cpld_ops = { |
471 | a682fd5c | Avi Kivity | .old_mmio = { |
472 | a682fd5c | Avi Kivity | .read = { taihu_cpld_readb, taihu_cpld_readw, taihu_cpld_readl, }, |
473 | a682fd5c | Avi Kivity | .write = { taihu_cpld_writeb, taihu_cpld_writew, taihu_cpld_writel, }, |
474 | a682fd5c | Avi Kivity | }, |
475 | a682fd5c | Avi Kivity | .endianness = DEVICE_NATIVE_ENDIAN, |
476 | 1a6c0886 | j_mayer | }; |
477 | 1a6c0886 | j_mayer | |
478 | 1a6c0886 | j_mayer | static void taihu_cpld_reset (void *opaque) |
479 | 1a6c0886 | j_mayer | { |
480 | 1a6c0886 | j_mayer | taihu_cpld_t *cpld; |
481 | 1a6c0886 | j_mayer | |
482 | 1a6c0886 | j_mayer | cpld = opaque; |
483 | 1a6c0886 | j_mayer | cpld->reg0 = 0x01;
|
484 | 1a6c0886 | j_mayer | cpld->reg1 = 0x80;
|
485 | 1a6c0886 | j_mayer | } |
486 | 1a6c0886 | j_mayer | |
487 | a682fd5c | Avi Kivity | static void taihu_cpld_init (MemoryRegion *sysmem, uint32_t base) |
488 | 1a6c0886 | j_mayer | { |
489 | 1a6c0886 | j_mayer | taihu_cpld_t *cpld; |
490 | a682fd5c | Avi Kivity | MemoryRegion *cpld_memory = g_new(MemoryRegion, 1);
|
491 | 1a6c0886 | j_mayer | |
492 | 7267c094 | Anthony Liguori | cpld = g_malloc0(sizeof(taihu_cpld_t));
|
493 | a682fd5c | Avi Kivity | memory_region_init_io(cpld_memory, &taihu_cpld_ops, cpld, "cpld", 0x100); |
494 | a682fd5c | Avi Kivity | memory_region_add_subregion(sysmem, base, cpld_memory); |
495 | a08d4367 | Jan Kiszka | qemu_register_reset(&taihu_cpld_reset, cpld); |
496 | 1a6c0886 | j_mayer | } |
497 | 1a6c0886 | j_mayer | |
498 | c227f099 | Anthony Liguori | static void taihu_405ep_init(ram_addr_t ram_size, |
499 | 3023f332 | aliguori | const char *boot_device, |
500 | 5fafdf24 | ths | const char *kernel_filename, |
501 | 1a6c0886 | j_mayer | const char *kernel_cmdline, |
502 | 1a6c0886 | j_mayer | const char *initrd_filename, |
503 | 1a6c0886 | j_mayer | const char *cpu_model) |
504 | 1a6c0886 | j_mayer | { |
505 | 5cea8590 | Paul Brook | char *filename;
|
506 | 1a6c0886 | j_mayer | qemu_irq *pic; |
507 | a682fd5c | Avi Kivity | MemoryRegion *sysmem = get_system_memory(); |
508 | cfe5f011 | Avi Kivity | MemoryRegion *bios; |
509 | b6dcbe08 | Avi Kivity | MemoryRegion *ram_memories = g_malloc(2 * sizeof(*ram_memories)); |
510 | c227f099 | Anthony Liguori | target_phys_addr_t ram_bases[2], ram_sizes[2]; |
511 | 093209cd | Blue Swirl | long bios_size;
|
512 | 093209cd | Blue Swirl | target_ulong kernel_base, initrd_base; |
513 | 093209cd | Blue Swirl | long kernel_size, initrd_size;
|
514 | 1a6c0886 | j_mayer | int linux_boot;
|
515 | 1a6c0886 | j_mayer | int fl_idx, fl_sectors;
|
516 | 751c6a17 | Gerd Hoffmann | DriveInfo *dinfo; |
517 | 3b46e624 | ths | |
518 | 1a6c0886 | j_mayer | /* RAM is soldered to the board so the size cannot be changed */
|
519 | c5705a77 | Avi Kivity | memory_region_init_ram(&ram_memories[0],
|
520 | b6dcbe08 | Avi Kivity | "taihu_405ep.ram-0", 0x04000000); |
521 | c5705a77 | Avi Kivity | vmstate_register_ram_global(&ram_memories[0]);
|
522 | b6dcbe08 | Avi Kivity | ram_bases[0] = 0; |
523 | 1a6c0886 | j_mayer | ram_sizes[0] = 0x04000000; |
524 | c5705a77 | Avi Kivity | memory_region_init_ram(&ram_memories[1],
|
525 | b6dcbe08 | Avi Kivity | "taihu_405ep.ram-1", 0x04000000); |
526 | c5705a77 | Avi Kivity | vmstate_register_ram_global(&ram_memories[1]);
|
527 | b6dcbe08 | Avi Kivity | ram_bases[1] = 0x04000000; |
528 | 1a6c0886 | j_mayer | ram_sizes[1] = 0x04000000; |
529 | a0b753df | pbrook | ram_size = 0x08000000;
|
530 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
531 | 1a6c0886 | j_mayer | printf("%s: register cpu\n", __func__);
|
532 | 1a6c0886 | j_mayer | #endif
|
533 | a682fd5c | Avi Kivity | ppc405ep_init(sysmem, ram_memories, ram_bases, ram_sizes, |
534 | 52ce55a1 | Richard Henderson | 33333333, &pic, kernel_filename == NULL ? 0 : 1); |
535 | 1a6c0886 | j_mayer | /* allocate and load BIOS */
|
536 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
537 | 1a6c0886 | j_mayer | printf("%s: register BIOS\n", __func__);
|
538 | 1a6c0886 | j_mayer | #endif
|
539 | 1a6c0886 | j_mayer | fl_idx = 0;
|
540 | 1a6c0886 | j_mayer | #if defined(USE_FLASH_BIOS)
|
541 | 751c6a17 | Gerd Hoffmann | dinfo = drive_get(IF_PFLASH, 0, fl_idx);
|
542 | 751c6a17 | Gerd Hoffmann | if (dinfo) {
|
543 | 751c6a17 | Gerd Hoffmann | bios_size = bdrv_getlength(dinfo->bdrv); |
544 | 1a6c0886 | j_mayer | /* XXX: should check that size is 2MB */
|
545 | 1a6c0886 | j_mayer | // bios_size = 2 * 1024 * 1024;
|
546 | 1a6c0886 | j_mayer | fl_sectors = (bios_size + 65535) >> 16; |
547 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
548 | 093209cd | Blue Swirl | printf("Register parallel flash %d size %lx"
|
549 | cfe5f011 | Avi Kivity | " at addr %lx '%s' %d\n",
|
550 | cfe5f011 | Avi Kivity | fl_idx, bios_size, -bios_size, |
551 | 751c6a17 | Gerd Hoffmann | bdrv_get_device_name(dinfo->bdrv), fl_sectors); |
552 | 1a6c0886 | j_mayer | #endif
|
553 | cfe5f011 | Avi Kivity | pflash_cfi02_register((uint32_t)(-bios_size), |
554 | cfe5f011 | Avi Kivity | NULL, "taihu_405ep.bios", bios_size, |
555 | 751c6a17 | Gerd Hoffmann | dinfo->bdrv, 65536, fl_sectors, 1, |
556 | 01e0451a | Anthony Liguori | 4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA, |
557 | 01e0451a | Anthony Liguori | 1);
|
558 | 1a6c0886 | j_mayer | fl_idx++; |
559 | 1a6c0886 | j_mayer | } else
|
560 | 1a6c0886 | j_mayer | #endif
|
561 | 1a6c0886 | j_mayer | { |
562 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
563 | 1a6c0886 | j_mayer | printf("Load BIOS from file\n");
|
564 | 1a6c0886 | j_mayer | #endif
|
565 | 1192dad8 | j_mayer | if (bios_name == NULL) |
566 | 1192dad8 | j_mayer | bios_name = BIOS_FILENAME; |
567 | cfe5f011 | Avi Kivity | bios = g_new(MemoryRegion, 1);
|
568 | c5705a77 | Avi Kivity | memory_region_init_ram(bios, "taihu_405ep.bios", BIOS_SIZE);
|
569 | c5705a77 | Avi Kivity | vmstate_register_ram_global(bios); |
570 | 5cea8590 | Paul Brook | filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); |
571 | 5cea8590 | Paul Brook | if (filename) {
|
572 | cfe5f011 | Avi Kivity | bios_size = load_image(filename, memory_region_get_ram_ptr(bios)); |
573 | 7267c094 | Anthony Liguori | g_free(filename); |
574 | 5cea8590 | Paul Brook | } else {
|
575 | 5cea8590 | Paul Brook | bios_size = -1;
|
576 | 5cea8590 | Paul Brook | } |
577 | 1a6c0886 | j_mayer | if (bios_size < 0 || bios_size > BIOS_SIZE) { |
578 | 5cea8590 | Paul Brook | fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n",
|
579 | 5cea8590 | Paul Brook | bios_name); |
580 | 1a6c0886 | j_mayer | exit(1);
|
581 | 1a6c0886 | j_mayer | } |
582 | 1a6c0886 | j_mayer | bios_size = (bios_size + 0xfff) & ~0xfff; |
583 | cfe5f011 | Avi Kivity | memory_region_set_readonly(bios, true);
|
584 | a682fd5c | Avi Kivity | memory_region_add_subregion(sysmem, (uint32_t)(-bios_size), bios); |
585 | 1a6c0886 | j_mayer | } |
586 | 1a6c0886 | j_mayer | /* Register Linux flash */
|
587 | 751c6a17 | Gerd Hoffmann | dinfo = drive_get(IF_PFLASH, 0, fl_idx);
|
588 | 751c6a17 | Gerd Hoffmann | if (dinfo) {
|
589 | 751c6a17 | Gerd Hoffmann | bios_size = bdrv_getlength(dinfo->bdrv); |
590 | 1a6c0886 | j_mayer | /* XXX: should check that size is 32MB */
|
591 | 1a6c0886 | j_mayer | bios_size = 32 * 1024 * 1024; |
592 | 1a6c0886 | j_mayer | fl_sectors = (bios_size + 65535) >> 16; |
593 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
594 | 093209cd | Blue Swirl | printf("Register parallel flash %d size %lx"
|
595 | cfe5f011 | Avi Kivity | " at addr " TARGET_FMT_lx " '%s'\n", |
596 | cfe5f011 | Avi Kivity | fl_idx, bios_size, (target_ulong)0xfc000000,
|
597 | 751c6a17 | Gerd Hoffmann | bdrv_get_device_name(dinfo->bdrv)); |
598 | 1a6c0886 | j_mayer | #endif
|
599 | cfe5f011 | Avi Kivity | pflash_cfi02_register(0xfc000000, NULL, "taihu_405ep.flash", bios_size, |
600 | 751c6a17 | Gerd Hoffmann | dinfo->bdrv, 65536, fl_sectors, 1, |
601 | 01e0451a | Anthony Liguori | 4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA, |
602 | 01e0451a | Anthony Liguori | 1);
|
603 | 1a6c0886 | j_mayer | fl_idx++; |
604 | 1a6c0886 | j_mayer | } |
605 | 1a6c0886 | j_mayer | /* Register CLPD & LCD display */
|
606 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
607 | 1a6c0886 | j_mayer | printf("%s: register CPLD\n", __func__);
|
608 | 1a6c0886 | j_mayer | #endif
|
609 | a682fd5c | Avi Kivity | taihu_cpld_init(sysmem, 0x50100000);
|
610 | 1a6c0886 | j_mayer | /* Load kernel */
|
611 | 1a6c0886 | j_mayer | linux_boot = (kernel_filename != NULL);
|
612 | 1a6c0886 | j_mayer | if (linux_boot) {
|
613 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
614 | 1a6c0886 | j_mayer | printf("%s: load kernel\n", __func__);
|
615 | 1a6c0886 | j_mayer | #endif
|
616 | 1a6c0886 | j_mayer | kernel_base = KERNEL_LOAD_ADDR; |
617 | 1a6c0886 | j_mayer | /* now we can load the kernel */
|
618 | 5c130f65 | pbrook | kernel_size = load_image_targphys(kernel_filename, kernel_base, |
619 | 5c130f65 | pbrook | ram_size - kernel_base); |
620 | 1a6c0886 | j_mayer | if (kernel_size < 0) { |
621 | 5fafdf24 | ths | fprintf(stderr, "qemu: could not load kernel '%s'\n",
|
622 | 1a6c0886 | j_mayer | kernel_filename); |
623 | 1a6c0886 | j_mayer | exit(1);
|
624 | 1a6c0886 | j_mayer | } |
625 | 1a6c0886 | j_mayer | /* load initrd */
|
626 | 1a6c0886 | j_mayer | if (initrd_filename) {
|
627 | 1a6c0886 | j_mayer | initrd_base = INITRD_LOAD_ADDR; |
628 | 5c130f65 | pbrook | initrd_size = load_image_targphys(initrd_filename, initrd_base, |
629 | 5c130f65 | pbrook | ram_size - initrd_base); |
630 | 1a6c0886 | j_mayer | if (initrd_size < 0) { |
631 | 1a6c0886 | j_mayer | fprintf(stderr, |
632 | 5fafdf24 | ths | "qemu: could not load initial ram disk '%s'\n",
|
633 | 1a6c0886 | j_mayer | initrd_filename); |
634 | 1a6c0886 | j_mayer | exit(1);
|
635 | 1a6c0886 | j_mayer | } |
636 | 1a6c0886 | j_mayer | } else {
|
637 | 1a6c0886 | j_mayer | initrd_base = 0;
|
638 | 1a6c0886 | j_mayer | initrd_size = 0;
|
639 | 1a6c0886 | j_mayer | } |
640 | 1a6c0886 | j_mayer | } else {
|
641 | 1a6c0886 | j_mayer | kernel_base = 0;
|
642 | 1a6c0886 | j_mayer | kernel_size = 0;
|
643 | 1a6c0886 | j_mayer | initrd_base = 0;
|
644 | 1a6c0886 | j_mayer | initrd_size = 0;
|
645 | 1a6c0886 | j_mayer | } |
646 | 1a6c0886 | j_mayer | #ifdef DEBUG_BOARD_INIT
|
647 | 1a6c0886 | j_mayer | printf("%s: Done\n", __func__);
|
648 | 1a6c0886 | j_mayer | #endif
|
649 | 1a6c0886 | j_mayer | } |
650 | 1a6c0886 | j_mayer | |
651 | f80f9ec9 | Anthony Liguori | static QEMUMachine taihu_machine = {
|
652 | b2ee0ce2 | pbrook | .name = "taihu",
|
653 | b2ee0ce2 | pbrook | .desc = "taihu",
|
654 | b2ee0ce2 | pbrook | .init = taihu_405ep_init, |
655 | 1a6c0886 | j_mayer | }; |
656 | f80f9ec9 | Anthony Liguori | |
657 | f80f9ec9 | Anthony Liguori | static void ppc405_machine_init(void) |
658 | f80f9ec9 | Anthony Liguori | { |
659 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&ref405ep_machine); |
660 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&taihu_machine); |
661 | f80f9ec9 | Anthony Liguori | } |
662 | f80f9ec9 | Anthony Liguori | |
663 | f80f9ec9 | Anthony Liguori | machine_init(ppc405_machine_init); |