master
c 95 lines 2.82 KB
Raw
1 /*
2 * SA-1110-based Sharp Zaurus SL-5500 platform.
3 *
4 * Copyright (C) 2011 Dmitry Eremin-Solenikov
5 *
6 * This code is licensed under GNU GPL v2.
7 *
8 * Contributions after 2012-01-13 are licensed under the terms of the
9 * GNU GPL, version 2 or (at your option) any later version.
10 */
11 #include "qemu/osdep.h"
12 #include "qemu/units.h"
13 #include "qemu/cutils.h"
14 #include "hw/core/sysbus.h"
15 #include "hw/core/boards.h"
16 #include "strongarm.h"
17 #include "hw/arm/boot.h"
18 #include "hw/arm/machines-qom.h"
19 #include "hw/block/flash.h"
20 #include "system/address-spaces.h"
21 #include "qom/object.h"
22 #include "qemu/error-report.h"
23
24
25 #define RAM_SIZE (512 * MiB)
26 #define FLASH_SIZE (32 * MiB)
27 #define FLASH_SECTOR_SIZE (64 * KiB)
28
29 struct CollieMachineState {
30 MachineState parent;
31
32 StrongARMState *sa1110;
33 struct arm_boot_info bootinfo;
34 };
35
36 #define TYPE_COLLIE_MACHINE MACHINE_TYPE_NAME("collie")
37 OBJECT_DECLARE_SIMPLE_TYPE(CollieMachineState, COLLIE_MACHINE)
38
39 static void collie_init(MachineState *machine)
40 {
41 MachineClass *mc = MACHINE_GET_CLASS(machine);
42 CollieMachineState *cms = COLLIE_MACHINE(machine);
43
44 if (machine->ram_size != mc->default_ram_size) {
45 char *sz = size_to_str(mc->default_ram_size);
46 error_report("Invalid RAM size, should be %s", sz);
47 g_free(sz);
48 exit(EXIT_FAILURE);
49 }
50
51 cms->sa1110 = sa1110_init(machine->cpu_type);
52
53 memory_region_add_subregion(get_system_memory(), SA_SDCS0, machine->ram);
54
55 for (unsigned i = 0; i < 2; i++) {
56 DriveInfo *dinfo = drive_get(IF_PFLASH, 0, i);
57 pflash_cfi01_register(i ? SA_CS1 : SA_CS0,
58 i ? "collie.fl2" : "collie.fl1", FLASH_SIZE,
59 dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
60 FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0);
61 }
62
63 sysbus_create_simple("scoop", 0x40800000, NULL);
64
65 cms->bootinfo.loader_start = SA_SDCS0;
66 cms->bootinfo.ram_size = RAM_SIZE;
67 cms->bootinfo.board_id = 0x208;
68 arm_load_kernel(cms->sa1110->cpu, machine, &cms->bootinfo);
69 }
70
71 static void collie_machine_class_init(ObjectClass *oc, const void *data)
72 {
73 MachineClass *mc = MACHINE_CLASS(oc);
74
75 mc->desc = "Sharp SL-5500 (Collie) PDA (SA-1110)";
76 mc->init = collie_init;
77 mc->ignore_memory_transaction_failures = true;
78 mc->default_cpu_type = ARM_CPU_TYPE_NAME("sa1110");
79 mc->default_ram_size = RAM_SIZE;
80 mc->default_ram_id = "strongarm.sdram";
81 }
82
83 static const TypeInfo collie_machine_typeinfo = {
84 .name = TYPE_COLLIE_MACHINE,
85 .parent = TYPE_MACHINE,
86 .class_init = collie_machine_class_init,
87 .instance_size = sizeof(CollieMachineState),
88 .interfaces = arm_machine_interfaces,
89 };
90
91 static void collie_machine_register_types(void)
92 {
93 type_register_static(&collie_machine_typeinfo);
94 }
95 type_init(collie_machine_register_types);