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