root / hw / sun4u.c @ 1a14026e
History | View | Annotate | Download (12.7 kB)
1 | 3475187d | bellard | /*
|
---|---|---|---|
2 | 3475187d | bellard | * QEMU Sun4u System Emulator
|
3 | 5fafdf24 | ths | *
|
4 | 3475187d | bellard | * Copyright (c) 2005 Fabrice Bellard
|
5 | 5fafdf24 | ths | *
|
6 | 3475187d | bellard | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | 3475187d | bellard | * of this software and associated documentation files (the "Software"), to deal
|
8 | 3475187d | bellard | * in the Software without restriction, including without limitation the rights
|
9 | 3475187d | bellard | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | 3475187d | bellard | * copies of the Software, and to permit persons to whom the Software is
|
11 | 3475187d | bellard | * furnished to do so, subject to the following conditions:
|
12 | 3475187d | bellard | *
|
13 | 3475187d | bellard | * The above copyright notice and this permission notice shall be included in
|
14 | 3475187d | bellard | * all copies or substantial portions of the Software.
|
15 | 3475187d | bellard | *
|
16 | 3475187d | bellard | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | 3475187d | bellard | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | 3475187d | bellard | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | 3475187d | bellard | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | 3475187d | bellard | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | 3475187d | bellard | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | 3475187d | bellard | * THE SOFTWARE.
|
23 | 3475187d | bellard | */
|
24 | 87ecb68b | pbrook | #include "hw.h" |
25 | 87ecb68b | pbrook | #include "pci.h" |
26 | 87ecb68b | pbrook | #include "pc.h" |
27 | 87ecb68b | pbrook | #include "nvram.h" |
28 | 87ecb68b | pbrook | #include "fdc.h" |
29 | 87ecb68b | pbrook | #include "net.h" |
30 | 87ecb68b | pbrook | #include "qemu-timer.h" |
31 | 87ecb68b | pbrook | #include "sysemu.h" |
32 | 87ecb68b | pbrook | #include "boards.h" |
33 | d2c63fc1 | blueswir1 | #include "firmware_abi.h" |
34 | 3475187d | bellard | |
35 | 83469015 | bellard | #define KERNEL_LOAD_ADDR 0x00404000 |
36 | 83469015 | bellard | #define CMDLINE_ADDR 0x003ff000 |
37 | 83469015 | bellard | #define INITRD_LOAD_ADDR 0x00300000 |
38 | ac2e9d66 | blueswir1 | #define PROM_SIZE_MAX (4 * 1024 * 1024) |
39 | f930d07e | blueswir1 | #define PROM_ADDR 0x1fff0000000ULL |
40 | f930d07e | blueswir1 | #define PROM_VADDR 0x000ffd00000ULL |
41 | 83469015 | bellard | #define APB_SPECIAL_BASE 0x1fe00000000ULL |
42 | f930d07e | blueswir1 | #define APB_MEM_BASE 0x1ff00000000ULL |
43 | f930d07e | blueswir1 | #define VGA_BASE (APB_MEM_BASE + 0x400000ULL) |
44 | f930d07e | blueswir1 | #define PROM_FILENAME "openbios-sparc64" |
45 | 83469015 | bellard | #define NVRAM_SIZE 0x2000 |
46 | e4bcb14c | ths | #define MAX_IDE_BUS 2 |
47 | 3475187d | bellard | |
48 | 3475187d | bellard | int DMA_get_channel_mode (int nchan) |
49 | 3475187d | bellard | { |
50 | 3475187d | bellard | return 0; |
51 | 3475187d | bellard | } |
52 | 3475187d | bellard | int DMA_read_memory (int nchan, void *buf, int pos, int size) |
53 | 3475187d | bellard | { |
54 | 3475187d | bellard | return 0; |
55 | 3475187d | bellard | } |
56 | 3475187d | bellard | int DMA_write_memory (int nchan, void *buf, int pos, int size) |
57 | 3475187d | bellard | { |
58 | 3475187d | bellard | return 0; |
59 | 3475187d | bellard | } |
60 | 3475187d | bellard | void DMA_hold_DREQ (int nchan) {} |
61 | 3475187d | bellard | void DMA_release_DREQ (int nchan) {} |
62 | 3475187d | bellard | void DMA_schedule(int nchan) {} |
63 | 3475187d | bellard | void DMA_run (void) {} |
64 | 3475187d | bellard | void DMA_init (int high_page_enable) {} |
65 | 3475187d | bellard | void DMA_register_channel (int nchan, |
66 | 3475187d | bellard | DMA_transfer_handler transfer_handler, |
67 | 3475187d | bellard | void *opaque)
|
68 | 3475187d | bellard | { |
69 | 3475187d | bellard | } |
70 | 3475187d | bellard | |
71 | 3475187d | bellard | extern int nographic; |
72 | 3475187d | bellard | |
73 | d2c63fc1 | blueswir1 | static int sun4u_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size, |
74 | d2c63fc1 | blueswir1 | const unsigned char *arch, |
75 | 77f193da | blueswir1 | ram_addr_t RAM_size, |
76 | 77f193da | blueswir1 | const char *boot_devices, |
77 | d2c63fc1 | blueswir1 | uint32_t kernel_image, uint32_t kernel_size, |
78 | d2c63fc1 | blueswir1 | const char *cmdline, |
79 | d2c63fc1 | blueswir1 | uint32_t initrd_image, uint32_t initrd_size, |
80 | d2c63fc1 | blueswir1 | uint32_t NVRAM_image, |
81 | d2c63fc1 | blueswir1 | int width, int height, int depth) |
82 | 83469015 | bellard | { |
83 | 66508601 | blueswir1 | unsigned int i; |
84 | 66508601 | blueswir1 | uint32_t start, end; |
85 | d2c63fc1 | blueswir1 | uint8_t image[0x1ff0];
|
86 | d2c63fc1 | blueswir1 | ohwcfg_v3_t *header = (ohwcfg_v3_t *)ℑ |
87 | d2c63fc1 | blueswir1 | struct sparc_arch_cfg *sparc_header;
|
88 | d2c63fc1 | blueswir1 | struct OpenBIOS_nvpart_v1 *part_header;
|
89 | d2c63fc1 | blueswir1 | |
90 | d2c63fc1 | blueswir1 | memset(image, '\0', sizeof(image)); |
91 | d2c63fc1 | blueswir1 | |
92 | d2c63fc1 | blueswir1 | // Try to match PPC NVRAM
|
93 | d2c63fc1 | blueswir1 | strcpy(header->struct_ident, "QEMU_BIOS");
|
94 | d2c63fc1 | blueswir1 | header->struct_version = cpu_to_be32(3); /* structure v3 */ |
95 | d2c63fc1 | blueswir1 | |
96 | d2c63fc1 | blueswir1 | header->nvram_size = cpu_to_be16(NVRAM_size); |
97 | d2c63fc1 | blueswir1 | header->nvram_arch_ptr = cpu_to_be16(sizeof(ohwcfg_v3_t));
|
98 | d2c63fc1 | blueswir1 | header->nvram_arch_size = cpu_to_be16(sizeof(struct sparc_arch_cfg)); |
99 | d2c63fc1 | blueswir1 | strcpy(header->arch, arch); |
100 | d2c63fc1 | blueswir1 | header->nb_cpus = smp_cpus & 0xff;
|
101 | d2c63fc1 | blueswir1 | header->RAM0_base = 0;
|
102 | d2c63fc1 | blueswir1 | header->RAM0_size = cpu_to_be64((uint64_t)RAM_size); |
103 | d2c63fc1 | blueswir1 | strcpy(header->boot_devices, boot_devices); |
104 | d2c63fc1 | blueswir1 | header->nboot_devices = strlen(boot_devices) & 0xff;
|
105 | d2c63fc1 | blueswir1 | header->kernel_image = cpu_to_be64((uint64_t)kernel_image); |
106 | d2c63fc1 | blueswir1 | header->kernel_size = cpu_to_be64((uint64_t)kernel_size); |
107 | 3475187d | bellard | if (cmdline) {
|
108 | 293f78bc | blueswir1 | pstrcpy_targphys(CMDLINE_ADDR, TARGET_PAGE_SIZE, cmdline); |
109 | d2c63fc1 | blueswir1 | header->cmdline = cpu_to_be64((uint64_t)CMDLINE_ADDR); |
110 | d2c63fc1 | blueswir1 | header->cmdline_size = cpu_to_be64((uint64_t)strlen(cmdline)); |
111 | 3475187d | bellard | } |
112 | d2c63fc1 | blueswir1 | header->initrd_image = cpu_to_be64((uint64_t)initrd_image); |
113 | d2c63fc1 | blueswir1 | header->initrd_size = cpu_to_be64((uint64_t)initrd_size); |
114 | d2c63fc1 | blueswir1 | header->NVRAM_image = cpu_to_be64((uint64_t)NVRAM_image); |
115 | d2c63fc1 | blueswir1 | |
116 | d2c63fc1 | blueswir1 | header->width = cpu_to_be16(width); |
117 | d2c63fc1 | blueswir1 | header->height = cpu_to_be16(height); |
118 | d2c63fc1 | blueswir1 | header->depth = cpu_to_be16(depth); |
119 | d2c63fc1 | blueswir1 | if (nographic)
|
120 | d2c63fc1 | blueswir1 | header->graphic_flags = cpu_to_be16(OHW_GF_NOGRAPHICS); |
121 | 83469015 | bellard | |
122 | d2c63fc1 | blueswir1 | header->crc = cpu_to_be16(OHW_compute_crc(header, 0x00, 0xF8)); |
123 | d2c63fc1 | blueswir1 | |
124 | d2c63fc1 | blueswir1 | // Architecture specific header
|
125 | d2c63fc1 | blueswir1 | start = sizeof(ohwcfg_v3_t);
|
126 | d2c63fc1 | blueswir1 | sparc_header = (struct sparc_arch_cfg *)&image[start];
|
127 | d2c63fc1 | blueswir1 | sparc_header->valid = 0;
|
128 | d2c63fc1 | blueswir1 | start += sizeof(struct sparc_arch_cfg); |
129 | 83469015 | bellard | |
130 | 66508601 | blueswir1 | // OpenBIOS nvram variables
|
131 | 66508601 | blueswir1 | // Variable partition
|
132 | d2c63fc1 | blueswir1 | part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
|
133 | d2c63fc1 | blueswir1 | part_header->signature = OPENBIOS_PART_SYSTEM; |
134 | d2c63fc1 | blueswir1 | strcpy(part_header->name, "system");
|
135 | 66508601 | blueswir1 | |
136 | d2c63fc1 | blueswir1 | end = start + sizeof(struct OpenBIOS_nvpart_v1); |
137 | 66508601 | blueswir1 | for (i = 0; i < nb_prom_envs; i++) |
138 | d2c63fc1 | blueswir1 | end = OpenBIOS_set_var(image, end, prom_envs[i]); |
139 | d2c63fc1 | blueswir1 | |
140 | d2c63fc1 | blueswir1 | // End marker
|
141 | d2c63fc1 | blueswir1 | image[end++] = '\0';
|
142 | 66508601 | blueswir1 | |
143 | 66508601 | blueswir1 | end = start + ((end - start + 15) & ~15); |
144 | d2c63fc1 | blueswir1 | OpenBIOS_finish_partition(part_header, end - start); |
145 | 66508601 | blueswir1 | |
146 | 66508601 | blueswir1 | // free partition
|
147 | 66508601 | blueswir1 | start = end; |
148 | d2c63fc1 | blueswir1 | part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
|
149 | d2c63fc1 | blueswir1 | part_header->signature = OPENBIOS_PART_FREE; |
150 | d2c63fc1 | blueswir1 | strcpy(part_header->name, "free");
|
151 | 66508601 | blueswir1 | |
152 | 66508601 | blueswir1 | end = 0x1fd0;
|
153 | d2c63fc1 | blueswir1 | OpenBIOS_finish_partition(part_header, end - start); |
154 | d2c63fc1 | blueswir1 | |
155 | d2c63fc1 | blueswir1 | for (i = 0; i < sizeof(image); i++) |
156 | d2c63fc1 | blueswir1 | m48t59_write(nvram, i, image[i]); |
157 | 66508601 | blueswir1 | |
158 | 83469015 | bellard | return 0; |
159 | 3475187d | bellard | } |
160 | 3475187d | bellard | |
161 | 22548760 | blueswir1 | void pic_info(void) |
162 | 3475187d | bellard | { |
163 | 3475187d | bellard | } |
164 | 3475187d | bellard | |
165 | 22548760 | blueswir1 | void irq_info(void) |
166 | 3475187d | bellard | { |
167 | 3475187d | bellard | } |
168 | 3475187d | bellard | |
169 | 83469015 | bellard | void qemu_system_powerdown(void) |
170 | 3475187d | bellard | { |
171 | 3475187d | bellard | } |
172 | 3475187d | bellard | |
173 | c68ea704 | bellard | static void main_cpu_reset(void *opaque) |
174 | c68ea704 | bellard | { |
175 | c68ea704 | bellard | CPUState *env = opaque; |
176 | 20c9f095 | blueswir1 | |
177 | c68ea704 | bellard | cpu_reset(env); |
178 | 20c9f095 | blueswir1 | ptimer_set_limit(env->tick, 0x7fffffffffffffffULL, 1); |
179 | 20c9f095 | blueswir1 | ptimer_run(env->tick, 0);
|
180 | 20c9f095 | blueswir1 | ptimer_set_limit(env->stick, 0x7fffffffffffffffULL, 1); |
181 | 20c9f095 | blueswir1 | ptimer_run(env->stick, 0);
|
182 | 20c9f095 | blueswir1 | ptimer_set_limit(env->hstick, 0x7fffffffffffffffULL, 1); |
183 | 20c9f095 | blueswir1 | ptimer_run(env->hstick, 0);
|
184 | 20c9f095 | blueswir1 | } |
185 | 20c9f095 | blueswir1 | |
186 | 22548760 | blueswir1 | static void tick_irq(void *opaque) |
187 | 20c9f095 | blueswir1 | { |
188 | 20c9f095 | blueswir1 | CPUState *env = opaque; |
189 | 20c9f095 | blueswir1 | |
190 | 20c9f095 | blueswir1 | cpu_interrupt(env, CPU_INTERRUPT_TIMER); |
191 | 20c9f095 | blueswir1 | } |
192 | 20c9f095 | blueswir1 | |
193 | 22548760 | blueswir1 | static void stick_irq(void *opaque) |
194 | 20c9f095 | blueswir1 | { |
195 | 20c9f095 | blueswir1 | CPUState *env = opaque; |
196 | 20c9f095 | blueswir1 | |
197 | 20c9f095 | blueswir1 | cpu_interrupt(env, CPU_INTERRUPT_TIMER); |
198 | 20c9f095 | blueswir1 | } |
199 | 20c9f095 | blueswir1 | |
200 | 22548760 | blueswir1 | static void hstick_irq(void *opaque) |
201 | 20c9f095 | blueswir1 | { |
202 | 20c9f095 | blueswir1 | CPUState *env = opaque; |
203 | 20c9f095 | blueswir1 | |
204 | 20c9f095 | blueswir1 | cpu_interrupt(env, CPU_INTERRUPT_TIMER); |
205 | c68ea704 | bellard | } |
206 | c68ea704 | bellard | |
207 | f19e918d | blueswir1 | static void dummy_cpu_set_irq(void *opaque, int irq, int level) |
208 | f19e918d | blueswir1 | { |
209 | f19e918d | blueswir1 | } |
210 | f19e918d | blueswir1 | |
211 | 83469015 | bellard | static const int ide_iobase[2] = { 0x1f0, 0x170 }; |
212 | 83469015 | bellard | static const int ide_iobase2[2] = { 0x3f6, 0x376 }; |
213 | 83469015 | bellard | static const int ide_irq[2] = { 14, 15 }; |
214 | 3475187d | bellard | |
215 | 83469015 | bellard | static const int serial_io[MAX_SERIAL_PORTS] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; |
216 | 83469015 | bellard | static const int serial_irq[MAX_SERIAL_PORTS] = { 4, 3, 4, 3 }; |
217 | 83469015 | bellard | |
218 | 83469015 | bellard | static const int parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc }; |
219 | 83469015 | bellard | static const int parallel_irq[MAX_PARALLEL_PORTS] = { 7, 7, 7 }; |
220 | 83469015 | bellard | |
221 | 83469015 | bellard | static fdctrl_t *floppy_controller;
|
222 | 3475187d | bellard | |
223 | 3475187d | bellard | /* Sun4u hardware initialisation */
|
224 | 22548760 | blueswir1 | static void sun4u_init(ram_addr_t RAM_size, int vga_ram_size, |
225 | b881c2c6 | blueswir1 | const char *boot_devices, DisplayState *ds, |
226 | b881c2c6 | blueswir1 | const char *kernel_filename, const char *kernel_cmdline, |
227 | b881c2c6 | blueswir1 | const char *initrd_filename, const char *cpu_model) |
228 | 3475187d | bellard | { |
229 | c68ea704 | bellard | CPUState *env; |
230 | 3475187d | bellard | char buf[1024]; |
231 | 83469015 | bellard | m48t59_t *nvram; |
232 | 3475187d | bellard | int ret, linux_boot;
|
233 | 3475187d | bellard | unsigned int i; |
234 | 83469015 | bellard | long prom_offset, initrd_size, kernel_size;
|
235 | 83469015 | bellard | PCIBus *pci_bus; |
236 | 20c9f095 | blueswir1 | QEMUBH *bh; |
237 | f19e918d | blueswir1 | qemu_irq *irq; |
238 | 22548760 | blueswir1 | int drive_index;
|
239 | e4bcb14c | ths | BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
240 | e4bcb14c | ths | BlockDriverState *fd[MAX_FD]; |
241 | 3475187d | bellard | |
242 | 3475187d | bellard | linux_boot = (kernel_filename != NULL);
|
243 | 3475187d | bellard | |
244 | 62724a37 | blueswir1 | /* init CPUs */
|
245 | 62724a37 | blueswir1 | if (cpu_model == NULL) |
246 | 62724a37 | blueswir1 | cpu_model = "TI UltraSparc II";
|
247 | aaed909a | bellard | env = cpu_init(cpu_model); |
248 | aaed909a | bellard | if (!env) {
|
249 | 62724a37 | blueswir1 | fprintf(stderr, "Unable to find Sparc CPU definition\n");
|
250 | 62724a37 | blueswir1 | exit(1);
|
251 | 62724a37 | blueswir1 | } |
252 | 20c9f095 | blueswir1 | bh = qemu_bh_new(tick_irq, env); |
253 | 20c9f095 | blueswir1 | env->tick = ptimer_init(bh); |
254 | 20c9f095 | blueswir1 | ptimer_set_period(env->tick, 1ULL);
|
255 | 20c9f095 | blueswir1 | |
256 | 20c9f095 | blueswir1 | bh = qemu_bh_new(stick_irq, env); |
257 | 20c9f095 | blueswir1 | env->stick = ptimer_init(bh); |
258 | 20c9f095 | blueswir1 | ptimer_set_period(env->stick, 1ULL);
|
259 | 20c9f095 | blueswir1 | |
260 | 20c9f095 | blueswir1 | bh = qemu_bh_new(hstick_irq, env); |
261 | 20c9f095 | blueswir1 | env->hstick = ptimer_init(bh); |
262 | 20c9f095 | blueswir1 | ptimer_set_period(env->hstick, 1ULL);
|
263 | 1a14026e | blueswir1 | register_savevm("cpu", 0, 4, cpu_save, cpu_load, env); |
264 | c68ea704 | bellard | qemu_register_reset(main_cpu_reset, env); |
265 | 20c9f095 | blueswir1 | main_cpu_reset(env); |
266 | c68ea704 | bellard | |
267 | 3475187d | bellard | /* allocate RAM */
|
268 | 22548760 | blueswir1 | cpu_register_physical_memory(0, RAM_size, 0); |
269 | 3475187d | bellard | |
270 | 22548760 | blueswir1 | prom_offset = RAM_size + vga_ram_size; |
271 | 5fafdf24 | ths | cpu_register_physical_memory(PROM_ADDR, |
272 | 77f193da | blueswir1 | (PROM_SIZE_MAX + TARGET_PAGE_SIZE) & |
273 | 77f193da | blueswir1 | TARGET_PAGE_MASK, |
274 | b3783731 | bellard | prom_offset | IO_MEM_ROM); |
275 | 3475187d | bellard | |
276 | 1192dad8 | j_mayer | if (bios_name == NULL) |
277 | 1192dad8 | j_mayer | bios_name = PROM_FILENAME; |
278 | 1192dad8 | j_mayer | snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); |
279 | f19e918d | blueswir1 | ret = load_elf(buf, PROM_ADDR - PROM_VADDR, NULL, NULL, NULL); |
280 | 3475187d | bellard | if (ret < 0) { |
281 | f930d07e | blueswir1 | fprintf(stderr, "qemu: could not load prom '%s'\n",
|
282 | f930d07e | blueswir1 | buf); |
283 | f930d07e | blueswir1 | exit(1);
|
284 | 3475187d | bellard | } |
285 | 3475187d | bellard | |
286 | 3475187d | bellard | kernel_size = 0;
|
287 | 83469015 | bellard | initrd_size = 0;
|
288 | 3475187d | bellard | if (linux_boot) {
|
289 | b3783731 | bellard | /* XXX: put correct offset */
|
290 | 74287114 | ths | kernel_size = load_elf(kernel_filename, 0, NULL, NULL, NULL); |
291 | 3475187d | bellard | if (kernel_size < 0) |
292 | 293f78bc | blueswir1 | kernel_size = load_aout(kernel_filename, KERNEL_LOAD_ADDR, |
293 | 293f78bc | blueswir1 | ram_size - KERNEL_LOAD_ADDR); |
294 | f930d07e | blueswir1 | if (kernel_size < 0) |
295 | 293f78bc | blueswir1 | kernel_size = load_image_targphys(kernel_filename, |
296 | 293f78bc | blueswir1 | KERNEL_LOAD_ADDR, |
297 | 293f78bc | blueswir1 | ram_size - KERNEL_LOAD_ADDR); |
298 | 3475187d | bellard | if (kernel_size < 0) { |
299 | 5fafdf24 | ths | fprintf(stderr, "qemu: could not load kernel '%s'\n",
|
300 | 3475187d | bellard | kernel_filename); |
301 | f930d07e | blueswir1 | exit(1);
|
302 | 3475187d | bellard | } |
303 | 3475187d | bellard | |
304 | 3475187d | bellard | /* load initrd */
|
305 | 3475187d | bellard | if (initrd_filename) {
|
306 | 293f78bc | blueswir1 | initrd_size = load_image_targphys(initrd_filename, |
307 | 293f78bc | blueswir1 | INITRD_LOAD_ADDR, |
308 | 293f78bc | blueswir1 | ram_size - INITRD_LOAD_ADDR); |
309 | 3475187d | bellard | if (initrd_size < 0) { |
310 | 5fafdf24 | ths | fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
|
311 | 3475187d | bellard | initrd_filename); |
312 | 3475187d | bellard | exit(1);
|
313 | 3475187d | bellard | } |
314 | 3475187d | bellard | } |
315 | 3475187d | bellard | if (initrd_size > 0) { |
316 | f930d07e | blueswir1 | for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) { |
317 | 293f78bc | blueswir1 | if (ldl_phys(KERNEL_LOAD_ADDR + i) == 0x48647253) { // HdrS |
318 | 293f78bc | blueswir1 | stl_phys(KERNEL_LOAD_ADDR + i + 16, INITRD_LOAD_ADDR);
|
319 | 293f78bc | blueswir1 | stl_phys(KERNEL_LOAD_ADDR + i + 20, initrd_size);
|
320 | f930d07e | blueswir1 | break;
|
321 | f930d07e | blueswir1 | } |
322 | f930d07e | blueswir1 | } |
323 | 3475187d | bellard | } |
324 | 3475187d | bellard | } |
325 | 502a5395 | pbrook | pci_bus = pci_apb_init(APB_SPECIAL_BASE, APB_MEM_BASE, NULL);
|
326 | 83469015 | bellard | isa_mem_base = VGA_BASE; |
327 | 77f193da | blueswir1 | pci_cirrus_vga_init(pci_bus, ds, phys_ram_base + RAM_size, RAM_size, |
328 | 77f193da | blueswir1 | vga_ram_size); |
329 | 83469015 | bellard | |
330 | 83469015 | bellard | for(i = 0; i < MAX_SERIAL_PORTS; i++) { |
331 | 83469015 | bellard | if (serial_hds[i]) {
|
332 | cbf5c748 | blueswir1 | serial_init(serial_io[i], NULL/*serial_irq[i]*/, 115200, |
333 | cbf5c748 | blueswir1 | serial_hds[i]); |
334 | 83469015 | bellard | } |
335 | 83469015 | bellard | } |
336 | 83469015 | bellard | |
337 | 83469015 | bellard | for(i = 0; i < MAX_PARALLEL_PORTS; i++) { |
338 | 83469015 | bellard | if (parallel_hds[i]) {
|
339 | 77f193da | blueswir1 | parallel_init(parallel_io[i], NULL/*parallel_irq[i]*/, |
340 | 77f193da | blueswir1 | parallel_hds[i]); |
341 | 83469015 | bellard | } |
342 | 83469015 | bellard | } |
343 | 83469015 | bellard | |
344 | 83469015 | bellard | for(i = 0; i < nb_nics; i++) { |
345 | a41b2ff2 | pbrook | if (!nd_table[i].model)
|
346 | a41b2ff2 | pbrook | nd_table[i].model = "ne2k_pci";
|
347 | f930d07e | blueswir1 | pci_nic_init(pci_bus, &nd_table[i], -1);
|
348 | 83469015 | bellard | } |
349 | 83469015 | bellard | |
350 | f19e918d | blueswir1 | irq = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, 32); |
351 | e4bcb14c | ths | if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
|
352 | e4bcb14c | ths | fprintf(stderr, "qemu: too many IDE bus\n");
|
353 | e4bcb14c | ths | exit(1);
|
354 | e4bcb14c | ths | } |
355 | e4bcb14c | ths | for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { |
356 | 22548760 | blueswir1 | drive_index = drive_get_index(IF_IDE, i / MAX_IDE_DEVS, |
357 | 22548760 | blueswir1 | i % MAX_IDE_DEVS); |
358 | 22548760 | blueswir1 | if (drive_index != -1) |
359 | 22548760 | blueswir1 | hd[i] = drives_table[drive_index].bdrv; |
360 | e4bcb14c | ths | else
|
361 | e4bcb14c | ths | hd[i] = NULL;
|
362 | e4bcb14c | ths | } |
363 | e4bcb14c | ths | |
364 | e4bcb14c | ths | // XXX pci_cmd646_ide_init(pci_bus, hd, 1);
|
365 | e4bcb14c | ths | pci_piix3_ide_init(pci_bus, hd, -1, irq);
|
366 | d537cf6c | pbrook | /* FIXME: wire up interrupts. */
|
367 | d537cf6c | pbrook | i8042_init(NULL/*1*/, NULL/*12*/, 0x60); |
368 | e4bcb14c | ths | for(i = 0; i < MAX_FD; i++) { |
369 | 22548760 | blueswir1 | drive_index = drive_get_index(IF_FLOPPY, 0, i);
|
370 | 22548760 | blueswir1 | if (drive_index != -1) |
371 | 22548760 | blueswir1 | fd[i] = drives_table[drive_index].bdrv; |
372 | e4bcb14c | ths | else
|
373 | e4bcb14c | ths | fd[i] = NULL;
|
374 | e4bcb14c | ths | } |
375 | e4bcb14c | ths | floppy_controller = fdctrl_init(NULL/*6*/, 2, 0, 0x3f0, fd); |
376 | d537cf6c | pbrook | nvram = m48t59_init(NULL/*8*/, 0, 0x0074, NVRAM_SIZE, 59); |
377 | 22548760 | blueswir1 | sun4u_NVRAM_set_params(nvram, NVRAM_SIZE, "Sun4u", RAM_size, boot_devices,
|
378 | 83469015 | bellard | KERNEL_LOAD_ADDR, kernel_size, |
379 | 83469015 | bellard | kernel_cmdline, |
380 | 83469015 | bellard | INITRD_LOAD_ADDR, initrd_size, |
381 | 83469015 | bellard | /* XXX: need an option to load a NVRAM image */
|
382 | 83469015 | bellard | 0,
|
383 | 83469015 | bellard | graphic_width, graphic_height, graphic_depth); |
384 | 83469015 | bellard | |
385 | 3475187d | bellard | } |
386 | 3475187d | bellard | |
387 | 3475187d | bellard | QEMUMachine sun4u_machine = { |
388 | 3475187d | bellard | "sun4u",
|
389 | 3475187d | bellard | "Sun4u platform",
|
390 | 3475187d | bellard | sun4u_init, |
391 | 7fb4fdcf | balrog | PROM_SIZE_MAX + VGA_RAM_SIZE, |
392 | 3475187d | bellard | }; |