4 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
7 * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
8 * DongKyun Yun <dk77.yun@samsung.com>
9 * DoHyung Hong <don.hong@samsung.com>
10 * SeokYeon Hwang <syeon.hwang@samsung.com>
11 * Hyunjun Son <hj79.son@samsung.com>
12 * SangJin Kim <sangjin3.kim@samsung.com>
13 * KiTae Kim <kt920.kim@samsung.com>
14 * JinHyung Jo <jinhyung.jo@samsung.com>
15 * SungMin Ha <sungmin82.ha@samsung.com>
16 * MunKyu Im <munkyu.im@samsung.com>
17 * JiHye Kim <jihye1128.kim@samsung.com>
18 * GiWoong Kim <giwoong.kim@samsung.com>
20 * This program is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU General Public License
22 * as published by the Free Software Foundation; either version 2
23 * of the License, or (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
37 * x86 board from pc_piix.c...
38 * add some TIZEN-speciaized device...
54 #include "arch_init.h"
60 static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
61 static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
62 static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
64 static void ioapic_init(IsaIrqState *isa_irq_state)
70 dev = qdev_create(NULL, "ioapic");
71 qdev_init_nofail(dev);
72 d = sysbus_from_qdev(dev);
73 sysbus_mmio_map(d, 0, 0xfec00000);
75 for (i = 0; i < IOAPIC_NUM_PINS; i++) {
76 isa_irq_state->ioapic[i] = qdev_get_gpio_in(dev, i);
80 static void tizen_x86_machine_init(ram_addr_t ram_size,
81 const char *boot_device,
82 const char *kernel_filename,
83 const char *kernel_cmdline,
84 const char *initrd_filename,
85 const char *cpu_model)
89 ram_addr_t below_4g_mem_size, above_4g_mem_size;
91 PCII440FXState *i440fx_state;
98 IsaIrqState *isa_irq_state;
99 DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
100 FDCtrl *floppy_controller;
101 BusState *idebus[MAX_IDE_BUS];
102 ISADevice *rtc_state;
104 pc_cpus_init(cpu_model);
108 /* allocate ram and load rom/bios */
109 pc_memory_init(ram_size, kernel_filename, kernel_cmdline, initrd_filename,
110 &below_4g_mem_size, &above_4g_mem_size);
112 cpu_irq = pc_allocate_cpu_irq();
113 i8259 = i8259_init(cpu_irq[0]);
114 isa_irq_state = qemu_mallocz(sizeof(*isa_irq_state));
115 isa_irq_state->i8259 = i8259;
117 ioapic_init(isa_irq_state);
119 isa_irq = qemu_allocate_irqs(isa_irq_handler, isa_irq_state, 24);
122 pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, isa_irq, ram_size);
128 isa_bus_irqs(isa_irq);
130 pc_register_ferr_irq(isa_get_irq(13));
132 pc_vga_init(pci_enabled? pci_bus: NULL);
134 /* init basic PC hardware */
135 pc_basic_device_init(isa_irq, &floppy_controller, &rtc_state);
137 for(i = 0; i < nb_nics; i++) {
138 NICInfo *nd = &nd_table[i];
140 if (!pci_enabled || (nd->model && strcmp(nd->model, "ne2k_isa") == 0))
141 pc_init_ne2k_isa(nd);
143 pci_nic_init_nofail(nd, "e1000", NULL);
146 if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
147 fprintf(stderr, "qemu: too many IDE bus\n");
151 for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) {
152 hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS);
157 dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
158 idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
159 idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
161 for(i = 0; i < MAX_IDE_BUS; i++) {
163 dev = isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
164 hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
165 idebus[i] = qdev_get_child_bus(&dev->qdev, "ide.0");
169 // commented out by caramis... for use 'tizen-ac97'...
170 // audio_init(isa_irq, pci_enabled ? pci_bus : NULL);
172 pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
173 idebus[0], idebus[1], floppy_controller, rtc_state);
175 if (pci_enabled && usb_enabled) {
176 usb_uhci_piix3_init(pci_bus, piix3_devfn + 2);
179 if (pci_enabled && acpi_enabled) {
180 uint8_t *eeprom_buf = qemu_mallocz(8 * 256); /* XXX: make this persistent */
183 cmos_s3 = qemu_allocate_irqs(pc_cmos_set_s3_resume, rtc_state, 1);
184 smi_irq = qemu_allocate_irqs(pc_acpi_smi_interrupt, first_cpu, 1);
185 /* TODO: Populate SPD eeprom data. */
187 // commented out for tizen acpi
188 // smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
189 // isa_get_irq(9), *cmos_s3, *smi_irq,
191 smbus = maru_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
192 isa_get_irq(9), *cmos_s3, *smi_irq,
194 for (i = 0; i < 8; i++) {
196 eeprom = qdev_create((BusState *)smbus, "smbus-eeprom");
197 qdev_prop_set_uint8(eeprom, "address", 0x50 + i);
198 qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (i * 256));
199 qdev_init_nofail(eeprom);
204 i440fx_init_memory_mappings(i440fx_state);
208 pc_pci_device_init(pci_bus);
211 // TIZEN-specialized device init...
213 svcamera_pci_init(pci_bus);
214 tizen_ac97_init(pci_bus);
219 pci_codec_init(pci_bus);
224 static void tizen_arm_machine_init(ram_addr_t ram_size,
225 const char *boot_device,
226 const char *kernel_filename,
227 const char *kernel_cmdline,
228 const char *initrd_filename,
229 const char *cpu_model)
233 static void tizen_common_init(ram_addr_t ram_size,
234 const char *boot_device,
235 const char *kernel_filename,
236 const char *kernel_cmdline,
237 const char *initrd_filename,
238 const char *cpu_model)
240 // prepare for universal virtual board...
241 #if defined(TARGET_I386)
242 #elif defined(TARGET_ARM)
246 static void tizen_x86_board_init(ram_addr_t ram_size,
247 const char *boot_device,
248 const char *kernel_filename,
249 const char *kernel_cmdline,
250 const char *initrd_filename,
251 const char *cpu_model)
253 tizen_x86_machine_init(ram_size, boot_device, kernel_filename,
254 kernel_cmdline, initrd_filename, cpu_model);
255 tizen_common_init(ram_size, boot_device, kernel_filename,
256 kernel_cmdline, initrd_filename, cpu_model);
258 static void tizen_arm_board_init(ram_addr_t ram_size,
259 const char *boot_device,
260 const char *kernel_filename,
261 const char *kernel_cmdline,
262 const char *initrd_filename,
263 const char *cpu_model)
265 tizen_arm_machine_init(ram_size, boot_device, kernel_filename,
266 kernel_cmdline, initrd_filename, cpu_model);
267 tizen_common_init(ram_size, boot_device, kernel_filename,
268 kernel_cmdline, initrd_filename, cpu_model);
271 static QEMUMachine tizen_x86_machine = {
272 .name = "tizen-x86-machine",
273 .desc = "TIZEN base board(x86)",
274 .init = tizen_x86_board_init,
278 static QEMUMachine tizen_arm_machine = {
279 .name = "tizen-arm-machine",
280 .desc = "TIZEN base board(ARM)",
281 .init = tizen_arm_board_init,
285 static void tizen_machine_init(void)
287 #if defined(TARGET_I386)
288 qemu_register_machine(&tizen_x86_machine);
289 #elif defined(TARGET_ARM)
290 qemu_register_machine(&tizen_arm_machine);
296 machine_init(tizen_machine_init);