root / hw / sun4u.c @ 6908d9ce
History | View | Annotate | Download (22.9 kB)
1 | 3475187d | bellard | /*
|
---|---|---|---|
2 | c7ba218d | blueswir1 | * QEMU Sun4u/Sun4v 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 | 18e08a55 | Michael S. Tsirkin | #include "apb_pci.h" |
27 | 87ecb68b | pbrook | #include "pc.h" |
28 | 87ecb68b | pbrook | #include "nvram.h" |
29 | 87ecb68b | pbrook | #include "fdc.h" |
30 | 87ecb68b | pbrook | #include "net.h" |
31 | 87ecb68b | pbrook | #include "qemu-timer.h" |
32 | 87ecb68b | pbrook | #include "sysemu.h" |
33 | 87ecb68b | pbrook | #include "boards.h" |
34 | d2c63fc1 | blueswir1 | #include "firmware_abi.h" |
35 | 3cce6243 | blueswir1 | #include "fw_cfg.h" |
36 | 1baffa46 | Blue Swirl | #include "sysbus.h" |
37 | 977e1244 | Gerd Hoffmann | #include "ide.h" |
38 | ca20cf32 | Blue Swirl | #include "loader.h" |
39 | ca20cf32 | Blue Swirl | #include "elf.h" |
40 | 3475187d | bellard | |
41 | 9d926598 | blueswir1 | //#define DEBUG_IRQ
|
42 | b430a225 | Blue Swirl | //#define DEBUG_EBUS
|
43 | 9d926598 | blueswir1 | |
44 | 9d926598 | blueswir1 | #ifdef DEBUG_IRQ
|
45 | b430a225 | Blue Swirl | #define CPUIRQ_DPRINTF(fmt, ...) \
|
46 | 001faf32 | Blue Swirl | do { printf("CPUIRQ: " fmt , ## __VA_ARGS__); } while (0) |
47 | 9d926598 | blueswir1 | #else
|
48 | b430a225 | Blue Swirl | #define CPUIRQ_DPRINTF(fmt, ...)
|
49 | b430a225 | Blue Swirl | #endif
|
50 | b430a225 | Blue Swirl | |
51 | b430a225 | Blue Swirl | #ifdef DEBUG_EBUS
|
52 | b430a225 | Blue Swirl | #define EBUS_DPRINTF(fmt, ...) \
|
53 | b430a225 | Blue Swirl | do { printf("EBUS: " fmt , ## __VA_ARGS__); } while (0) |
54 | b430a225 | Blue Swirl | #else
|
55 | b430a225 | Blue Swirl | #define EBUS_DPRINTF(fmt, ...)
|
56 | 9d926598 | blueswir1 | #endif
|
57 | 9d926598 | blueswir1 | |
58 | 83469015 | bellard | #define KERNEL_LOAD_ADDR 0x00404000 |
59 | 83469015 | bellard | #define CMDLINE_ADDR 0x003ff000 |
60 | 83469015 | bellard | #define INITRD_LOAD_ADDR 0x00300000 |
61 | ac2e9d66 | blueswir1 | #define PROM_SIZE_MAX (4 * 1024 * 1024) |
62 | f930d07e | blueswir1 | #define PROM_VADDR 0x000ffd00000ULL |
63 | 83469015 | bellard | #define APB_SPECIAL_BASE 0x1fe00000000ULL |
64 | f930d07e | blueswir1 | #define APB_MEM_BASE 0x1ff00000000ULL |
65 | f930d07e | blueswir1 | #define VGA_BASE (APB_MEM_BASE + 0x400000ULL) |
66 | f930d07e | blueswir1 | #define PROM_FILENAME "openbios-sparc64" |
67 | 83469015 | bellard | #define NVRAM_SIZE 0x2000 |
68 | e4bcb14c | ths | #define MAX_IDE_BUS 2 |
69 | 3cce6243 | blueswir1 | #define BIOS_CFG_IOPORT 0x510 |
70 | 7589690c | Blue Swirl | #define FW_CFG_SPARC64_WIDTH (FW_CFG_ARCH_LOCAL + 0x00) |
71 | 7589690c | Blue Swirl | #define FW_CFG_SPARC64_HEIGHT (FW_CFG_ARCH_LOCAL + 0x01) |
72 | 7589690c | Blue Swirl | #define FW_CFG_SPARC64_DEPTH (FW_CFG_ARCH_LOCAL + 0x02) |
73 | 3475187d | bellard | |
74 | 9d926598 | blueswir1 | #define MAX_PILS 16 |
75 | 9d926598 | blueswir1 | |
76 | 8fa211e8 | blueswir1 | #define TICK_MAX 0x7fffffffffffffffULL |
77 | 8fa211e8 | blueswir1 | |
78 | c7ba218d | blueswir1 | struct hwdef {
|
79 | c7ba218d | blueswir1 | const char * const default_cpu_model; |
80 | 905fdcb5 | blueswir1 | uint16_t machine_id; |
81 | e87231d4 | blueswir1 | uint64_t prom_addr; |
82 | e87231d4 | blueswir1 | uint64_t console_serial_base; |
83 | c7ba218d | blueswir1 | }; |
84 | c7ba218d | blueswir1 | |
85 | 3475187d | bellard | int DMA_get_channel_mode (int nchan) |
86 | 3475187d | bellard | { |
87 | 3475187d | bellard | return 0; |
88 | 3475187d | bellard | } |
89 | 3475187d | bellard | int DMA_read_memory (int nchan, void *buf, int pos, int size) |
90 | 3475187d | bellard | { |
91 | 3475187d | bellard | return 0; |
92 | 3475187d | bellard | } |
93 | 3475187d | bellard | int DMA_write_memory (int nchan, void *buf, int pos, int size) |
94 | 3475187d | bellard | { |
95 | 3475187d | bellard | return 0; |
96 | 3475187d | bellard | } |
97 | 3475187d | bellard | void DMA_hold_DREQ (int nchan) {} |
98 | 3475187d | bellard | void DMA_release_DREQ (int nchan) {} |
99 | 3475187d | bellard | void DMA_schedule(int nchan) {} |
100 | 3475187d | bellard | void DMA_init (int high_page_enable) {} |
101 | 3475187d | bellard | void DMA_register_channel (int nchan, |
102 | 3475187d | bellard | DMA_transfer_handler transfer_handler, |
103 | 3475187d | bellard | void *opaque)
|
104 | 3475187d | bellard | { |
105 | 3475187d | bellard | } |
106 | 3475187d | bellard | |
107 | 513f789f | blueswir1 | static int fw_cfg_boot_set(void *opaque, const char *boot_device) |
108 | 81864572 | blueswir1 | { |
109 | 513f789f | blueswir1 | fw_cfg_add_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]);
|
110 | 81864572 | blueswir1 | return 0; |
111 | 81864572 | blueswir1 | } |
112 | 81864572 | blueswir1 | |
113 | c227f099 | Anthony Liguori | static int sun4u_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size, |
114 | e7fb1406 | blueswir1 | const char *arch, |
115 | c227f099 | Anthony Liguori | ram_addr_t RAM_size, |
116 | 77f193da | blueswir1 | const char *boot_devices, |
117 | d2c63fc1 | blueswir1 | uint32_t kernel_image, uint32_t kernel_size, |
118 | d2c63fc1 | blueswir1 | const char *cmdline, |
119 | d2c63fc1 | blueswir1 | uint32_t initrd_image, uint32_t initrd_size, |
120 | d2c63fc1 | blueswir1 | uint32_t NVRAM_image, |
121 | 0d31cb99 | blueswir1 | int width, int height, int depth, |
122 | 0d31cb99 | blueswir1 | const uint8_t *macaddr)
|
123 | 83469015 | bellard | { |
124 | 66508601 | blueswir1 | unsigned int i; |
125 | 66508601 | blueswir1 | uint32_t start, end; |
126 | d2c63fc1 | blueswir1 | uint8_t image[0x1ff0];
|
127 | d2c63fc1 | blueswir1 | struct OpenBIOS_nvpart_v1 *part_header;
|
128 | d2c63fc1 | blueswir1 | |
129 | d2c63fc1 | blueswir1 | memset(image, '\0', sizeof(image)); |
130 | d2c63fc1 | blueswir1 | |
131 | 513f789f | blueswir1 | start = 0;
|
132 | 83469015 | bellard | |
133 | 66508601 | blueswir1 | // OpenBIOS nvram variables
|
134 | 66508601 | blueswir1 | // Variable partition
|
135 | d2c63fc1 | blueswir1 | part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
|
136 | d2c63fc1 | blueswir1 | part_header->signature = OPENBIOS_PART_SYSTEM; |
137 | 363a37d5 | blueswir1 | pstrcpy(part_header->name, sizeof(part_header->name), "system"); |
138 | 66508601 | blueswir1 | |
139 | d2c63fc1 | blueswir1 | end = start + sizeof(struct OpenBIOS_nvpart_v1); |
140 | 66508601 | blueswir1 | for (i = 0; i < nb_prom_envs; i++) |
141 | d2c63fc1 | blueswir1 | end = OpenBIOS_set_var(image, end, prom_envs[i]); |
142 | d2c63fc1 | blueswir1 | |
143 | d2c63fc1 | blueswir1 | // End marker
|
144 | d2c63fc1 | blueswir1 | image[end++] = '\0';
|
145 | 66508601 | blueswir1 | |
146 | 66508601 | blueswir1 | end = start + ((end - start + 15) & ~15); |
147 | d2c63fc1 | blueswir1 | OpenBIOS_finish_partition(part_header, end - start); |
148 | 66508601 | blueswir1 | |
149 | 66508601 | blueswir1 | // free partition
|
150 | 66508601 | blueswir1 | start = end; |
151 | d2c63fc1 | blueswir1 | part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
|
152 | d2c63fc1 | blueswir1 | part_header->signature = OPENBIOS_PART_FREE; |
153 | 363a37d5 | blueswir1 | pstrcpy(part_header->name, sizeof(part_header->name), "free"); |
154 | 66508601 | blueswir1 | |
155 | 66508601 | blueswir1 | end = 0x1fd0;
|
156 | d2c63fc1 | blueswir1 | OpenBIOS_finish_partition(part_header, end - start); |
157 | d2c63fc1 | blueswir1 | |
158 | 0d31cb99 | blueswir1 | Sun_init_header((struct Sun_nvram *)&image[0x1fd8], macaddr, 0x80); |
159 | 0d31cb99 | blueswir1 | |
160 | d2c63fc1 | blueswir1 | for (i = 0; i < sizeof(image); i++) |
161 | d2c63fc1 | blueswir1 | m48t59_write(nvram, i, image[i]); |
162 | 66508601 | blueswir1 | |
163 | 83469015 | bellard | return 0; |
164 | 3475187d | bellard | } |
165 | 636aa70a | Blue Swirl | static unsigned long sun4u_load_kernel(const char *kernel_filename, |
166 | 636aa70a | Blue Swirl | const char *initrd_filename, |
167 | c227f099 | Anthony Liguori | ram_addr_t RAM_size, long *initrd_size)
|
168 | 636aa70a | Blue Swirl | { |
169 | 636aa70a | Blue Swirl | int linux_boot;
|
170 | 636aa70a | Blue Swirl | unsigned int i; |
171 | 636aa70a | Blue Swirl | long kernel_size;
|
172 | 6908d9ce | Blue Swirl | uint8_t *ptr; |
173 | 636aa70a | Blue Swirl | |
174 | 636aa70a | Blue Swirl | linux_boot = (kernel_filename != NULL);
|
175 | 636aa70a | Blue Swirl | |
176 | 636aa70a | Blue Swirl | kernel_size = 0;
|
177 | 636aa70a | Blue Swirl | if (linux_boot) {
|
178 | ca20cf32 | Blue Swirl | int bswap_needed;
|
179 | ca20cf32 | Blue Swirl | |
180 | ca20cf32 | Blue Swirl | #ifdef BSWAP_NEEDED
|
181 | ca20cf32 | Blue Swirl | bswap_needed = 1;
|
182 | ca20cf32 | Blue Swirl | #else
|
183 | ca20cf32 | Blue Swirl | bswap_needed = 0;
|
184 | ca20cf32 | Blue Swirl | #endif
|
185 | ca20cf32 | Blue Swirl | kernel_size = load_elf(kernel_filename, 0, NULL, NULL, NULL, |
186 | ca20cf32 | Blue Swirl | 1, ELF_MACHINE, 0); |
187 | 636aa70a | Blue Swirl | if (kernel_size < 0) |
188 | 636aa70a | Blue Swirl | kernel_size = load_aout(kernel_filename, KERNEL_LOAD_ADDR, |
189 | ca20cf32 | Blue Swirl | RAM_size - KERNEL_LOAD_ADDR, bswap_needed, |
190 | ca20cf32 | Blue Swirl | TARGET_PAGE_SIZE); |
191 | 636aa70a | Blue Swirl | if (kernel_size < 0) |
192 | 636aa70a | Blue Swirl | kernel_size = load_image_targphys(kernel_filename, |
193 | 636aa70a | Blue Swirl | KERNEL_LOAD_ADDR, |
194 | 636aa70a | Blue Swirl | RAM_size - KERNEL_LOAD_ADDR); |
195 | 636aa70a | Blue Swirl | if (kernel_size < 0) { |
196 | 636aa70a | Blue Swirl | fprintf(stderr, "qemu: could not load kernel '%s'\n",
|
197 | 636aa70a | Blue Swirl | kernel_filename); |
198 | 636aa70a | Blue Swirl | exit(1);
|
199 | 636aa70a | Blue Swirl | } |
200 | 636aa70a | Blue Swirl | |
201 | 636aa70a | Blue Swirl | /* load initrd */
|
202 | 636aa70a | Blue Swirl | *initrd_size = 0;
|
203 | 636aa70a | Blue Swirl | if (initrd_filename) {
|
204 | 636aa70a | Blue Swirl | *initrd_size = load_image_targphys(initrd_filename, |
205 | 636aa70a | Blue Swirl | INITRD_LOAD_ADDR, |
206 | 636aa70a | Blue Swirl | RAM_size - INITRD_LOAD_ADDR); |
207 | 636aa70a | Blue Swirl | if (*initrd_size < 0) { |
208 | 636aa70a | Blue Swirl | fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
|
209 | 636aa70a | Blue Swirl | initrd_filename); |
210 | 636aa70a | Blue Swirl | exit(1);
|
211 | 636aa70a | Blue Swirl | } |
212 | 636aa70a | Blue Swirl | } |
213 | 636aa70a | Blue Swirl | if (*initrd_size > 0) { |
214 | 636aa70a | Blue Swirl | for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) { |
215 | 6908d9ce | Blue Swirl | ptr = rom_ptr(KERNEL_LOAD_ADDR + i); |
216 | 6908d9ce | Blue Swirl | if (ldl_p(ptr + 8) == 0x48647253) { /* HdrS */ |
217 | 6908d9ce | Blue Swirl | stl_p(ptr + 24, INITRD_LOAD_ADDR + KERNEL_LOAD_ADDR - 0x4000); |
218 | 6908d9ce | Blue Swirl | stl_p(ptr + 28, *initrd_size);
|
219 | 636aa70a | Blue Swirl | break;
|
220 | 636aa70a | Blue Swirl | } |
221 | 636aa70a | Blue Swirl | } |
222 | 636aa70a | Blue Swirl | } |
223 | 636aa70a | Blue Swirl | } |
224 | 636aa70a | Blue Swirl | return kernel_size;
|
225 | 636aa70a | Blue Swirl | } |
226 | 3475187d | bellard | |
227 | b4950060 | blueswir1 | void pic_info(Monitor *mon)
|
228 | 3475187d | bellard | { |
229 | 3475187d | bellard | } |
230 | 3475187d | bellard | |
231 | b4950060 | blueswir1 | void irq_info(Monitor *mon)
|
232 | 3475187d | bellard | { |
233 | 3475187d | bellard | } |
234 | 3475187d | bellard | |
235 | 9d926598 | blueswir1 | void cpu_check_irqs(CPUState *env)
|
236 | 9d926598 | blueswir1 | { |
237 | d532b26c | Igor V. Kovalenko | uint32_t pil = env->pil_in | |
238 | d532b26c | Igor V. Kovalenko | (env->softint & ~(SOFTINT_TIMER | SOFTINT_STIMER)); |
239 | d532b26c | Igor V. Kovalenko | |
240 | d532b26c | Igor V. Kovalenko | /* check if TM or SM in SOFTINT are set
|
241 | d532b26c | Igor V. Kovalenko | setting these also causes interrupt 14 */
|
242 | d532b26c | Igor V. Kovalenko | if (env->softint & (SOFTINT_TIMER | SOFTINT_STIMER)) {
|
243 | d532b26c | Igor V. Kovalenko | pil |= 1 << 14; |
244 | d532b26c | Igor V. Kovalenko | } |
245 | d532b26c | Igor V. Kovalenko | |
246 | d532b26c | Igor V. Kovalenko | if (!pil) {
|
247 | d532b26c | Igor V. Kovalenko | if (env->interrupt_request & CPU_INTERRUPT_HARD) {
|
248 | d532b26c | Igor V. Kovalenko | CPUIRQ_DPRINTF("Reset CPU IRQ (current interrupt %x)\n",
|
249 | d532b26c | Igor V. Kovalenko | env->interrupt_index); |
250 | d532b26c | Igor V. Kovalenko | env->interrupt_index = 0;
|
251 | d532b26c | Igor V. Kovalenko | cpu_reset_interrupt(env, CPU_INTERRUPT_HARD); |
252 | d532b26c | Igor V. Kovalenko | } |
253 | d532b26c | Igor V. Kovalenko | return;
|
254 | d532b26c | Igor V. Kovalenko | } |
255 | d532b26c | Igor V. Kovalenko | |
256 | d532b26c | Igor V. Kovalenko | if (cpu_interrupts_enabled(env)) {
|
257 | 9d926598 | blueswir1 | |
258 | 9d926598 | blueswir1 | unsigned int i; |
259 | 9d926598 | blueswir1 | |
260 | d532b26c | Igor V. Kovalenko | for (i = 15; i > env->psrpil; i--) { |
261 | 9d926598 | blueswir1 | if (pil & (1 << i)) { |
262 | 9d926598 | blueswir1 | int old_interrupt = env->interrupt_index;
|
263 | d532b26c | Igor V. Kovalenko | int new_interrupt = TT_EXTINT | i;
|
264 | d532b26c | Igor V. Kovalenko | |
265 | d532b26c | Igor V. Kovalenko | if (env->tl > 0 && cpu_tsptr(env)->tt > new_interrupt) { |
266 | d532b26c | Igor V. Kovalenko | CPUIRQ_DPRINTF("Not setting CPU IRQ: TL=%d "
|
267 | d532b26c | Igor V. Kovalenko | "current %x >= pending %x\n",
|
268 | d532b26c | Igor V. Kovalenko | env->tl, cpu_tsptr(env)->tt, new_interrupt); |
269 | d532b26c | Igor V. Kovalenko | } else if (old_interrupt != new_interrupt) { |
270 | d532b26c | Igor V. Kovalenko | env->interrupt_index = new_interrupt; |
271 | d532b26c | Igor V. Kovalenko | CPUIRQ_DPRINTF("Set CPU IRQ %d old=%x new=%x\n", i,
|
272 | d532b26c | Igor V. Kovalenko | old_interrupt, new_interrupt); |
273 | 9d926598 | blueswir1 | cpu_interrupt(env, CPU_INTERRUPT_HARD); |
274 | 9d926598 | blueswir1 | } |
275 | 9d926598 | blueswir1 | break;
|
276 | 9d926598 | blueswir1 | } |
277 | 9d926598 | blueswir1 | } |
278 | d532b26c | Igor V. Kovalenko | } else {
|
279 | d532b26c | Igor V. Kovalenko | CPUIRQ_DPRINTF("Interrupts disabled, pil=%08x pil_in=%08x softint=%08x "
|
280 | d532b26c | Igor V. Kovalenko | "current interrupt %x\n",
|
281 | d532b26c | Igor V. Kovalenko | pil, env->pil_in, env->softint, env->interrupt_index); |
282 | 9d926598 | blueswir1 | } |
283 | 9d926598 | blueswir1 | } |
284 | 9d926598 | blueswir1 | |
285 | 9d926598 | blueswir1 | static void cpu_set_irq(void *opaque, int irq, int level) |
286 | 9d926598 | blueswir1 | { |
287 | 9d926598 | blueswir1 | CPUState *env = opaque; |
288 | 9d926598 | blueswir1 | |
289 | 9d926598 | blueswir1 | if (level) {
|
290 | b430a225 | Blue Swirl | CPUIRQ_DPRINTF("Raise CPU IRQ %d\n", irq);
|
291 | 9d926598 | blueswir1 | env->halted = 0;
|
292 | 9d926598 | blueswir1 | env->pil_in |= 1 << irq;
|
293 | 9d926598 | blueswir1 | cpu_check_irqs(env); |
294 | 9d926598 | blueswir1 | } else {
|
295 | b430a225 | Blue Swirl | CPUIRQ_DPRINTF("Lower CPU IRQ %d\n", irq);
|
296 | 9d926598 | blueswir1 | env->pil_in &= ~(1 << irq);
|
297 | 9d926598 | blueswir1 | cpu_check_irqs(env); |
298 | 9d926598 | blueswir1 | } |
299 | 9d926598 | blueswir1 | } |
300 | 9d926598 | blueswir1 | |
301 | e87231d4 | blueswir1 | typedef struct ResetData { |
302 | e87231d4 | blueswir1 | CPUState *env; |
303 | 44a99354 | Blue Swirl | uint64_t prom_addr; |
304 | e87231d4 | blueswir1 | } ResetData; |
305 | e87231d4 | blueswir1 | |
306 | c68ea704 | bellard | static void main_cpu_reset(void *opaque) |
307 | c68ea704 | bellard | { |
308 | e87231d4 | blueswir1 | ResetData *s = (ResetData *)opaque; |
309 | e87231d4 | blueswir1 | CPUState *env = s->env; |
310 | 44a99354 | Blue Swirl | static unsigned int nr_resets; |
311 | 20c9f095 | blueswir1 | |
312 | c68ea704 | bellard | cpu_reset(env); |
313 | 8fa211e8 | blueswir1 | env->tick_cmpr = TICK_INT_DIS | 0;
|
314 | 8fa211e8 | blueswir1 | ptimer_set_limit(env->tick, TICK_MAX, 1);
|
315 | 2f43e00e | blueswir1 | ptimer_run(env->tick, 1);
|
316 | 8fa211e8 | blueswir1 | env->stick_cmpr = TICK_INT_DIS | 0;
|
317 | 8fa211e8 | blueswir1 | ptimer_set_limit(env->stick, TICK_MAX, 1);
|
318 | 2f43e00e | blueswir1 | ptimer_run(env->stick, 1);
|
319 | 8fa211e8 | blueswir1 | env->hstick_cmpr = TICK_INT_DIS | 0;
|
320 | 8fa211e8 | blueswir1 | ptimer_set_limit(env->hstick, TICK_MAX, 1);
|
321 | 2f43e00e | blueswir1 | ptimer_run(env->hstick, 1);
|
322 | e87231d4 | blueswir1 | env->gregs[1] = 0; // Memory start |
323 | e87231d4 | blueswir1 | env->gregs[2] = ram_size; // Memory size |
324 | e87231d4 | blueswir1 | env->gregs[3] = 0; // Machine description XXX |
325 | 44a99354 | Blue Swirl | if (nr_resets++ == 0) { |
326 | 44a99354 | Blue Swirl | /* Power on reset */
|
327 | 44a99354 | Blue Swirl | env->pc = s->prom_addr + 0x20ULL;
|
328 | 44a99354 | Blue Swirl | } else {
|
329 | 44a99354 | Blue Swirl | env->pc = s->prom_addr + 0x40ULL;
|
330 | 44a99354 | Blue Swirl | } |
331 | e87231d4 | blueswir1 | env->npc = env->pc + 4;
|
332 | 20c9f095 | blueswir1 | } |
333 | 20c9f095 | blueswir1 | |
334 | 22548760 | blueswir1 | static void tick_irq(void *opaque) |
335 | 20c9f095 | blueswir1 | { |
336 | 20c9f095 | blueswir1 | CPUState *env = opaque; |
337 | 20c9f095 | blueswir1 | |
338 | 8fa211e8 | blueswir1 | if (!(env->tick_cmpr & TICK_INT_DIS)) {
|
339 | 8fa211e8 | blueswir1 | env->softint |= SOFTINT_TIMER; |
340 | 8fa211e8 | blueswir1 | cpu_interrupt(env, CPU_INTERRUPT_TIMER); |
341 | 8fa211e8 | blueswir1 | } |
342 | 20c9f095 | blueswir1 | } |
343 | 20c9f095 | blueswir1 | |
344 | 22548760 | blueswir1 | static void stick_irq(void *opaque) |
345 | 20c9f095 | blueswir1 | { |
346 | 20c9f095 | blueswir1 | CPUState *env = opaque; |
347 | 20c9f095 | blueswir1 | |
348 | 8fa211e8 | blueswir1 | if (!(env->stick_cmpr & TICK_INT_DIS)) {
|
349 | 8fa211e8 | blueswir1 | env->softint |= SOFTINT_STIMER; |
350 | 8fa211e8 | blueswir1 | cpu_interrupt(env, CPU_INTERRUPT_TIMER); |
351 | 8fa211e8 | blueswir1 | } |
352 | 20c9f095 | blueswir1 | } |
353 | 20c9f095 | blueswir1 | |
354 | 22548760 | blueswir1 | static void hstick_irq(void *opaque) |
355 | 20c9f095 | blueswir1 | { |
356 | 20c9f095 | blueswir1 | CPUState *env = opaque; |
357 | 20c9f095 | blueswir1 | |
358 | 8fa211e8 | blueswir1 | if (!(env->hstick_cmpr & TICK_INT_DIS)) {
|
359 | 8fa211e8 | blueswir1 | cpu_interrupt(env, CPU_INTERRUPT_TIMER); |
360 | 8fa211e8 | blueswir1 | } |
361 | c68ea704 | bellard | } |
362 | c68ea704 | bellard | |
363 | f4b1a842 | blueswir1 | void cpu_tick_set_count(void *opaque, uint64_t count) |
364 | f4b1a842 | blueswir1 | { |
365 | f4b1a842 | blueswir1 | ptimer_set_count(opaque, -count); |
366 | f4b1a842 | blueswir1 | } |
367 | f4b1a842 | blueswir1 | |
368 | f4b1a842 | blueswir1 | uint64_t cpu_tick_get_count(void *opaque)
|
369 | f4b1a842 | blueswir1 | { |
370 | f4b1a842 | blueswir1 | return -ptimer_get_count(opaque);
|
371 | f4b1a842 | blueswir1 | } |
372 | f4b1a842 | blueswir1 | |
373 | f4b1a842 | blueswir1 | void cpu_tick_set_limit(void *opaque, uint64_t limit) |
374 | f4b1a842 | blueswir1 | { |
375 | f4b1a842 | blueswir1 | ptimer_set_limit(opaque, -limit, 0);
|
376 | f4b1a842 | blueswir1 | } |
377 | f4b1a842 | blueswir1 | |
378 | c190ea07 | blueswir1 | static void ebus_mmio_mapfunc(PCIDevice *pci_dev, int region_num, |
379 | 6e355d90 | Isaku Yamahata | pcibus_t addr, pcibus_t size, int type)
|
380 | c190ea07 | blueswir1 | { |
381 | b430a225 | Blue Swirl | EBUS_DPRINTF("Mapping region %d registers at %" FMT_PCIBUS "\n", |
382 | b430a225 | Blue Swirl | region_num, addr); |
383 | c190ea07 | blueswir1 | switch (region_num) {
|
384 | c190ea07 | blueswir1 | case 0: |
385 | c190ea07 | blueswir1 | isa_mmio_init(addr, 0x1000000);
|
386 | c190ea07 | blueswir1 | break;
|
387 | c190ea07 | blueswir1 | case 1: |
388 | c190ea07 | blueswir1 | isa_mmio_init(addr, 0x800000);
|
389 | c190ea07 | blueswir1 | break;
|
390 | c190ea07 | blueswir1 | } |
391 | c190ea07 | blueswir1 | } |
392 | c190ea07 | blueswir1 | |
393 | 1387fe4a | Blue Swirl | static void dummy_isa_irq_handler(void *opaque, int n, int level) |
394 | 1387fe4a | Blue Swirl | { |
395 | 1387fe4a | Blue Swirl | } |
396 | 1387fe4a | Blue Swirl | |
397 | c190ea07 | blueswir1 | /* EBUS (Eight bit bus) bridge */
|
398 | c190ea07 | blueswir1 | static void |
399 | c190ea07 | blueswir1 | pci_ebus_init(PCIBus *bus, int devfn)
|
400 | c190ea07 | blueswir1 | { |
401 | 1387fe4a | Blue Swirl | qemu_irq *isa_irq; |
402 | 1387fe4a | Blue Swirl | |
403 | 53e3c4f9 | Blue Swirl | pci_create_simple(bus, devfn, "ebus");
|
404 | 1387fe4a | Blue Swirl | isa_irq = qemu_allocate_irqs(dummy_isa_irq_handler, NULL, 16); |
405 | 1387fe4a | Blue Swirl | isa_bus_irqs(isa_irq); |
406 | 53e3c4f9 | Blue Swirl | } |
407 | c190ea07 | blueswir1 | |
408 | 81a322d4 | Gerd Hoffmann | static int |
409 | 53e3c4f9 | Blue Swirl | pci_ebus_init1(PCIDevice *s) |
410 | 53e3c4f9 | Blue Swirl | { |
411 | 0c5b8d83 | Blue Swirl | isa_bus_new(&s->qdev); |
412 | 0c5b8d83 | Blue Swirl | |
413 | deb54399 | aliguori | pci_config_set_vendor_id(s->config, PCI_VENDOR_ID_SUN); |
414 | deb54399 | aliguori | pci_config_set_device_id(s->config, PCI_DEVICE_ID_SUN_EBUS); |
415 | c190ea07 | blueswir1 | s->config[0x04] = 0x06; // command = bus master, pci mem |
416 | c190ea07 | blueswir1 | s->config[0x05] = 0x00; |
417 | c190ea07 | blueswir1 | s->config[0x06] = 0xa0; // status = fast back-to-back, 66MHz, no error |
418 | c190ea07 | blueswir1 | s->config[0x07] = 0x03; // status = medium devsel |
419 | c190ea07 | blueswir1 | s->config[0x08] = 0x01; // revision |
420 | c190ea07 | blueswir1 | s->config[0x09] = 0x00; // programming i/f |
421 | 173a543b | blueswir1 | pci_config_set_class(s->config, PCI_CLASS_BRIDGE_OTHER); |
422 | c190ea07 | blueswir1 | s->config[0x0D] = 0x0a; // latency_timer |
423 | 6407f373 | Isaku Yamahata | s->config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type
|
424 | c190ea07 | blueswir1 | |
425 | 0392a017 | Isaku Yamahata | pci_register_bar(s, 0, 0x1000000, PCI_BASE_ADDRESS_SPACE_MEMORY, |
426 | c190ea07 | blueswir1 | ebus_mmio_mapfunc); |
427 | 0392a017 | Isaku Yamahata | pci_register_bar(s, 1, 0x800000, PCI_BASE_ADDRESS_SPACE_MEMORY, |
428 | c190ea07 | blueswir1 | ebus_mmio_mapfunc); |
429 | 81a322d4 | Gerd Hoffmann | return 0; |
430 | c190ea07 | blueswir1 | } |
431 | c190ea07 | blueswir1 | |
432 | 53e3c4f9 | Blue Swirl | static PCIDeviceInfo ebus_info = {
|
433 | 53e3c4f9 | Blue Swirl | .qdev.name = "ebus",
|
434 | 53e3c4f9 | Blue Swirl | .qdev.size = sizeof(PCIDevice),
|
435 | 53e3c4f9 | Blue Swirl | .init = pci_ebus_init1, |
436 | 53e3c4f9 | Blue Swirl | }; |
437 | 53e3c4f9 | Blue Swirl | |
438 | 53e3c4f9 | Blue Swirl | static void pci_ebus_register(void) |
439 | 53e3c4f9 | Blue Swirl | { |
440 | 53e3c4f9 | Blue Swirl | pci_qdev_register(&ebus_info); |
441 | 53e3c4f9 | Blue Swirl | } |
442 | 53e3c4f9 | Blue Swirl | |
443 | 53e3c4f9 | Blue Swirl | device_init(pci_ebus_register); |
444 | 53e3c4f9 | Blue Swirl | |
445 | 1baffa46 | Blue Swirl | /* Boot PROM (OpenBIOS) */
|
446 | c227f099 | Anthony Liguori | static void prom_init(target_phys_addr_t addr, const char *bios_name) |
447 | 1baffa46 | Blue Swirl | { |
448 | 1baffa46 | Blue Swirl | DeviceState *dev; |
449 | 1baffa46 | Blue Swirl | SysBusDevice *s; |
450 | 1baffa46 | Blue Swirl | char *filename;
|
451 | 1baffa46 | Blue Swirl | int ret;
|
452 | 1baffa46 | Blue Swirl | |
453 | 1baffa46 | Blue Swirl | dev = qdev_create(NULL, "openprom"); |
454 | e23a1b33 | Markus Armbruster | qdev_init_nofail(dev); |
455 | 1baffa46 | Blue Swirl | s = sysbus_from_qdev(dev); |
456 | 1baffa46 | Blue Swirl | |
457 | 1baffa46 | Blue Swirl | sysbus_mmio_map(s, 0, addr);
|
458 | 1baffa46 | Blue Swirl | |
459 | 1baffa46 | Blue Swirl | /* load boot prom */
|
460 | 1baffa46 | Blue Swirl | if (bios_name == NULL) { |
461 | 1baffa46 | Blue Swirl | bios_name = PROM_FILENAME; |
462 | 1baffa46 | Blue Swirl | } |
463 | 1baffa46 | Blue Swirl | filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); |
464 | 1baffa46 | Blue Swirl | if (filename) {
|
465 | ca20cf32 | Blue Swirl | ret = load_elf(filename, addr - PROM_VADDR, NULL, NULL, NULL, |
466 | ca20cf32 | Blue Swirl | 1, ELF_MACHINE, 0); |
467 | 1baffa46 | Blue Swirl | if (ret < 0 || ret > PROM_SIZE_MAX) { |
468 | 1baffa46 | Blue Swirl | ret = load_image_targphys(filename, addr, PROM_SIZE_MAX); |
469 | 1baffa46 | Blue Swirl | } |
470 | 1baffa46 | Blue Swirl | qemu_free(filename); |
471 | 1baffa46 | Blue Swirl | } else {
|
472 | 1baffa46 | Blue Swirl | ret = -1;
|
473 | 1baffa46 | Blue Swirl | } |
474 | 1baffa46 | Blue Swirl | if (ret < 0 || ret > PROM_SIZE_MAX) { |
475 | 1baffa46 | Blue Swirl | fprintf(stderr, "qemu: could not load prom '%s'\n", bios_name);
|
476 | 1baffa46 | Blue Swirl | exit(1);
|
477 | 1baffa46 | Blue Swirl | } |
478 | 1baffa46 | Blue Swirl | } |
479 | 1baffa46 | Blue Swirl | |
480 | 81a322d4 | Gerd Hoffmann | static int prom_init1(SysBusDevice *dev) |
481 | 1baffa46 | Blue Swirl | { |
482 | c227f099 | Anthony Liguori | ram_addr_t prom_offset; |
483 | 1baffa46 | Blue Swirl | |
484 | 1baffa46 | Blue Swirl | prom_offset = qemu_ram_alloc(PROM_SIZE_MAX); |
485 | 1baffa46 | Blue Swirl | sysbus_init_mmio(dev, PROM_SIZE_MAX, prom_offset | IO_MEM_ROM); |
486 | 81a322d4 | Gerd Hoffmann | return 0; |
487 | 1baffa46 | Blue Swirl | } |
488 | 1baffa46 | Blue Swirl | |
489 | 1baffa46 | Blue Swirl | static SysBusDeviceInfo prom_info = {
|
490 | 1baffa46 | Blue Swirl | .init = prom_init1, |
491 | 1baffa46 | Blue Swirl | .qdev.name = "openprom",
|
492 | 1baffa46 | Blue Swirl | .qdev.size = sizeof(SysBusDevice),
|
493 | 1baffa46 | Blue Swirl | .qdev.props = (Property[]) { |
494 | 1baffa46 | Blue Swirl | {/* end of property list */}
|
495 | 1baffa46 | Blue Swirl | } |
496 | 1baffa46 | Blue Swirl | }; |
497 | 1baffa46 | Blue Swirl | |
498 | 1baffa46 | Blue Swirl | static void prom_register_devices(void) |
499 | 1baffa46 | Blue Swirl | { |
500 | 1baffa46 | Blue Swirl | sysbus_register_withprop(&prom_info); |
501 | 1baffa46 | Blue Swirl | } |
502 | 1baffa46 | Blue Swirl | |
503 | 1baffa46 | Blue Swirl | device_init(prom_register_devices); |
504 | 1baffa46 | Blue Swirl | |
505 | bda42033 | Blue Swirl | |
506 | bda42033 | Blue Swirl | typedef struct RamDevice |
507 | bda42033 | Blue Swirl | { |
508 | bda42033 | Blue Swirl | SysBusDevice busdev; |
509 | 04843626 | Blue Swirl | uint64_t size; |
510 | bda42033 | Blue Swirl | } RamDevice; |
511 | bda42033 | Blue Swirl | |
512 | bda42033 | Blue Swirl | /* System RAM */
|
513 | 81a322d4 | Gerd Hoffmann | static int ram_init1(SysBusDevice *dev) |
514 | bda42033 | Blue Swirl | { |
515 | c227f099 | Anthony Liguori | ram_addr_t RAM_size, ram_offset; |
516 | bda42033 | Blue Swirl | RamDevice *d = FROM_SYSBUS(RamDevice, dev); |
517 | bda42033 | Blue Swirl | |
518 | bda42033 | Blue Swirl | RAM_size = d->size; |
519 | bda42033 | Blue Swirl | |
520 | bda42033 | Blue Swirl | ram_offset = qemu_ram_alloc(RAM_size); |
521 | bda42033 | Blue Swirl | sysbus_init_mmio(dev, RAM_size, ram_offset); |
522 | 81a322d4 | Gerd Hoffmann | return 0; |
523 | bda42033 | Blue Swirl | } |
524 | bda42033 | Blue Swirl | |
525 | c227f099 | Anthony Liguori | static void ram_init(target_phys_addr_t addr, ram_addr_t RAM_size) |
526 | bda42033 | Blue Swirl | { |
527 | bda42033 | Blue Swirl | DeviceState *dev; |
528 | bda42033 | Blue Swirl | SysBusDevice *s; |
529 | bda42033 | Blue Swirl | RamDevice *d; |
530 | bda42033 | Blue Swirl | |
531 | bda42033 | Blue Swirl | /* allocate RAM */
|
532 | bda42033 | Blue Swirl | dev = qdev_create(NULL, "memory"); |
533 | bda42033 | Blue Swirl | s = sysbus_from_qdev(dev); |
534 | bda42033 | Blue Swirl | |
535 | bda42033 | Blue Swirl | d = FROM_SYSBUS(RamDevice, s); |
536 | bda42033 | Blue Swirl | d->size = RAM_size; |
537 | e23a1b33 | Markus Armbruster | qdev_init_nofail(dev); |
538 | bda42033 | Blue Swirl | |
539 | bda42033 | Blue Swirl | sysbus_mmio_map(s, 0, addr);
|
540 | bda42033 | Blue Swirl | } |
541 | bda42033 | Blue Swirl | |
542 | bda42033 | Blue Swirl | static SysBusDeviceInfo ram_info = {
|
543 | bda42033 | Blue Swirl | .init = ram_init1, |
544 | bda42033 | Blue Swirl | .qdev.name = "memory",
|
545 | bda42033 | Blue Swirl | .qdev.size = sizeof(RamDevice),
|
546 | bda42033 | Blue Swirl | .qdev.props = (Property[]) { |
547 | 32a7ee98 | Gerd Hoffmann | DEFINE_PROP_UINT64("size", RamDevice, size, 0), |
548 | 32a7ee98 | Gerd Hoffmann | DEFINE_PROP_END_OF_LIST(), |
549 | bda42033 | Blue Swirl | } |
550 | bda42033 | Blue Swirl | }; |
551 | bda42033 | Blue Swirl | |
552 | bda42033 | Blue Swirl | static void ram_register_devices(void) |
553 | bda42033 | Blue Swirl | { |
554 | bda42033 | Blue Swirl | sysbus_register_withprop(&ram_info); |
555 | bda42033 | Blue Swirl | } |
556 | bda42033 | Blue Swirl | |
557 | bda42033 | Blue Swirl | device_init(ram_register_devices); |
558 | bda42033 | Blue Swirl | |
559 | 7b833f5b | Blue Swirl | static CPUState *cpu_devinit(const char *cpu_model, const struct hwdef *hwdef) |
560 | 3475187d | bellard | { |
561 | c68ea704 | bellard | CPUState *env; |
562 | 20c9f095 | blueswir1 | QEMUBH *bh; |
563 | e87231d4 | blueswir1 | ResetData *reset_info; |
564 | 3475187d | bellard | |
565 | c7ba218d | blueswir1 | if (!cpu_model)
|
566 | c7ba218d | blueswir1 | cpu_model = hwdef->default_cpu_model; |
567 | aaed909a | bellard | env = cpu_init(cpu_model); |
568 | aaed909a | bellard | if (!env) {
|
569 | 62724a37 | blueswir1 | fprintf(stderr, "Unable to find Sparc CPU definition\n");
|
570 | 62724a37 | blueswir1 | exit(1);
|
571 | 62724a37 | blueswir1 | } |
572 | 20c9f095 | blueswir1 | bh = qemu_bh_new(tick_irq, env); |
573 | 20c9f095 | blueswir1 | env->tick = ptimer_init(bh); |
574 | 20c9f095 | blueswir1 | ptimer_set_period(env->tick, 1ULL);
|
575 | 20c9f095 | blueswir1 | |
576 | 20c9f095 | blueswir1 | bh = qemu_bh_new(stick_irq, env); |
577 | 20c9f095 | blueswir1 | env->stick = ptimer_init(bh); |
578 | 20c9f095 | blueswir1 | ptimer_set_period(env->stick, 1ULL);
|
579 | 20c9f095 | blueswir1 | |
580 | 20c9f095 | blueswir1 | bh = qemu_bh_new(hstick_irq, env); |
581 | 20c9f095 | blueswir1 | env->hstick = ptimer_init(bh); |
582 | 20c9f095 | blueswir1 | ptimer_set_period(env->hstick, 1ULL);
|
583 | e87231d4 | blueswir1 | |
584 | e87231d4 | blueswir1 | reset_info = qemu_mallocz(sizeof(ResetData));
|
585 | e87231d4 | blueswir1 | reset_info->env = env; |
586 | 44a99354 | Blue Swirl | reset_info->prom_addr = hwdef->prom_addr; |
587 | a08d4367 | Jan Kiszka | qemu_register_reset(main_cpu_reset, reset_info); |
588 | c68ea704 | bellard | |
589 | 7b833f5b | Blue Swirl | return env;
|
590 | 7b833f5b | Blue Swirl | } |
591 | 7b833f5b | Blue Swirl | |
592 | c227f099 | Anthony Liguori | static void sun4uv_init(ram_addr_t RAM_size, |
593 | 7b833f5b | Blue Swirl | const char *boot_devices, |
594 | 7b833f5b | Blue Swirl | const char *kernel_filename, const char *kernel_cmdline, |
595 | 7b833f5b | Blue Swirl | const char *initrd_filename, const char *cpu_model, |
596 | 7b833f5b | Blue Swirl | const struct hwdef *hwdef) |
597 | 7b833f5b | Blue Swirl | { |
598 | 7b833f5b | Blue Swirl | CPUState *env; |
599 | c227f099 | Anthony Liguori | m48t59_t *nvram; |
600 | 7b833f5b | Blue Swirl | unsigned int i; |
601 | 7b833f5b | Blue Swirl | long initrd_size, kernel_size;
|
602 | 7b833f5b | Blue Swirl | PCIBus *pci_bus, *pci_bus2, *pci_bus3; |
603 | 7b833f5b | Blue Swirl | qemu_irq *irq; |
604 | f455e98c | Gerd Hoffmann | DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
605 | fd8014e1 | Gerd Hoffmann | DriveInfo *fd[MAX_FD]; |
606 | 7b833f5b | Blue Swirl | void *fw_cfg;
|
607 | 7b833f5b | Blue Swirl | |
608 | 7b833f5b | Blue Swirl | /* init CPUs */
|
609 | 7b833f5b | Blue Swirl | env = cpu_devinit(cpu_model, hwdef); |
610 | 7b833f5b | Blue Swirl | |
611 | bda42033 | Blue Swirl | /* set up devices */
|
612 | bda42033 | Blue Swirl | ram_init(0, RAM_size);
|
613 | 3475187d | bellard | |
614 | 1baffa46 | Blue Swirl | prom_init(hwdef->prom_addr, bios_name); |
615 | 3475187d | bellard | |
616 | 7d55273f | Igor Kovalenko | |
617 | 7d55273f | Igor Kovalenko | irq = qemu_allocate_irqs(cpu_set_irq, env, MAX_PILS); |
618 | 7d55273f | Igor Kovalenko | pci_bus = pci_apb_init(APB_SPECIAL_BASE, APB_MEM_BASE, irq, &pci_bus2, |
619 | c190ea07 | blueswir1 | &pci_bus3); |
620 | 83469015 | bellard | isa_mem_base = VGA_BASE; |
621 | fbe1b595 | Paul Brook | pci_vga_init(pci_bus, 0, 0); |
622 | 83469015 | bellard | |
623 | c190ea07 | blueswir1 | // XXX Should be pci_bus3
|
624 | c190ea07 | blueswir1 | pci_ebus_init(pci_bus, -1);
|
625 | c190ea07 | blueswir1 | |
626 | e87231d4 | blueswir1 | i = 0;
|
627 | e87231d4 | blueswir1 | if (hwdef->console_serial_base) {
|
628 | e87231d4 | blueswir1 | serial_mm_init(hwdef->console_serial_base, 0, NULL, 115200, |
629 | e87231d4 | blueswir1 | serial_hds[i], 1);
|
630 | e87231d4 | blueswir1 | i++; |
631 | e87231d4 | blueswir1 | } |
632 | e87231d4 | blueswir1 | for(; i < MAX_SERIAL_PORTS; i++) {
|
633 | 83469015 | bellard | if (serial_hds[i]) {
|
634 | ac0be998 | Gerd Hoffmann | serial_isa_init(i, serial_hds[i]); |
635 | 83469015 | bellard | } |
636 | 83469015 | bellard | } |
637 | 83469015 | bellard | |
638 | 83469015 | bellard | for(i = 0; i < MAX_PARALLEL_PORTS; i++) { |
639 | 83469015 | bellard | if (parallel_hds[i]) {
|
640 | 021f0674 | Gerd Hoffmann | parallel_init(i, parallel_hds[i]); |
641 | 83469015 | bellard | } |
642 | 83469015 | bellard | } |
643 | 83469015 | bellard | |
644 | cb457d76 | aliguori | for(i = 0; i < nb_nics; i++) |
645 | 07caea31 | Markus Armbruster | pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL); |
646 | 83469015 | bellard | |
647 | e4bcb14c | ths | if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
|
648 | e4bcb14c | ths | fprintf(stderr, "qemu: too many IDE bus\n");
|
649 | e4bcb14c | ths | exit(1);
|
650 | e4bcb14c | ths | } |
651 | e4bcb14c | ths | for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { |
652 | f455e98c | Gerd Hoffmann | hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, |
653 | 751c6a17 | Gerd Hoffmann | i % MAX_IDE_DEVS); |
654 | e4bcb14c | ths | } |
655 | e4bcb14c | ths | |
656 | 3b898dda | blueswir1 | pci_cmd646_ide_init(pci_bus, hd, 1);
|
657 | 3b898dda | blueswir1 | |
658 | 2e15e23b | Gerd Hoffmann | isa_create_simple("i8042");
|
659 | e4bcb14c | ths | for(i = 0; i < MAX_FD; i++) { |
660 | fd8014e1 | Gerd Hoffmann | fd[i] = drive_get(IF_FLOPPY, 0, i);
|
661 | e4bcb14c | ths | } |
662 | 86c86157 | Gerd Hoffmann | fdctrl_init_isa(fd); |
663 | f80237d4 | Blue Swirl | nvram = m48t59_init_isa(0x0074, NVRAM_SIZE, 59); |
664 | 636aa70a | Blue Swirl | |
665 | 636aa70a | Blue Swirl | initrd_size = 0;
|
666 | 636aa70a | Blue Swirl | kernel_size = sun4u_load_kernel(kernel_filename, initrd_filename, |
667 | 636aa70a | Blue Swirl | ram_size, &initrd_size); |
668 | 636aa70a | Blue Swirl | |
669 | 22548760 | blueswir1 | sun4u_NVRAM_set_params(nvram, NVRAM_SIZE, "Sun4u", RAM_size, boot_devices,
|
670 | 0d31cb99 | blueswir1 | KERNEL_LOAD_ADDR, kernel_size, |
671 | 0d31cb99 | blueswir1 | kernel_cmdline, |
672 | 0d31cb99 | blueswir1 | INITRD_LOAD_ADDR, initrd_size, |
673 | 0d31cb99 | blueswir1 | /* XXX: need an option to load a NVRAM image */
|
674 | 0d31cb99 | blueswir1 | 0,
|
675 | 0d31cb99 | blueswir1 | graphic_width, graphic_height, graphic_depth, |
676 | 0d31cb99 | blueswir1 | (uint8_t *)&nd_table[0].macaddr);
|
677 | 83469015 | bellard | |
678 | 3cce6243 | blueswir1 | fw_cfg = fw_cfg_init(BIOS_CFG_IOPORT, BIOS_CFG_IOPORT + 1, 0, 0); |
679 | 3cce6243 | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
|
680 | 905fdcb5 | blueswir1 | fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); |
681 | 905fdcb5 | blueswir1 | fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id); |
682 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR); |
683 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); |
684 | 513f789f | blueswir1 | if (kernel_cmdline) {
|
685 | 9c9b0512 | Blue Swirl | fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, |
686 | 9c9b0512 | Blue Swirl | strlen(kernel_cmdline) + 1);
|
687 | 6bb4ca57 | Blue Swirl | fw_cfg_add_bytes(fw_cfg, FW_CFG_CMDLINE_DATA, |
688 | 6bb4ca57 | Blue Swirl | (uint8_t*)strdup(kernel_cmdline), |
689 | 6bb4ca57 | Blue Swirl | strlen(kernel_cmdline) + 1);
|
690 | 513f789f | blueswir1 | } else {
|
691 | 9c9b0512 | Blue Swirl | fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, 0);
|
692 | 513f789f | blueswir1 | } |
693 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR); |
694 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); |
695 | 513f789f | blueswir1 | fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, boot_devices[0]);
|
696 | 7589690c | Blue Swirl | |
697 | 7589690c | Blue Swirl | fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_WIDTH, graphic_width); |
698 | 7589690c | Blue Swirl | fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_HEIGHT, graphic_height); |
699 | 7589690c | Blue Swirl | fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_DEPTH, graphic_depth); |
700 | 7589690c | Blue Swirl | |
701 | 513f789f | blueswir1 | qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); |
702 | 3475187d | bellard | } |
703 | 3475187d | bellard | |
704 | 905fdcb5 | blueswir1 | enum {
|
705 | 905fdcb5 | blueswir1 | sun4u_id = 0,
|
706 | 905fdcb5 | blueswir1 | sun4v_id = 64,
|
707 | e87231d4 | blueswir1 | niagara_id, |
708 | 905fdcb5 | blueswir1 | }; |
709 | 905fdcb5 | blueswir1 | |
710 | c7ba218d | blueswir1 | static const struct hwdef hwdefs[] = { |
711 | c7ba218d | blueswir1 | /* Sun4u generic PC-like machine */
|
712 | c7ba218d | blueswir1 | { |
713 | c7ba218d | blueswir1 | .default_cpu_model = "TI UltraSparc II",
|
714 | 905fdcb5 | blueswir1 | .machine_id = sun4u_id, |
715 | e87231d4 | blueswir1 | .prom_addr = 0x1fff0000000ULL,
|
716 | e87231d4 | blueswir1 | .console_serial_base = 0,
|
717 | c7ba218d | blueswir1 | }, |
718 | c7ba218d | blueswir1 | /* Sun4v generic PC-like machine */
|
719 | c7ba218d | blueswir1 | { |
720 | c7ba218d | blueswir1 | .default_cpu_model = "Sun UltraSparc T1",
|
721 | 905fdcb5 | blueswir1 | .machine_id = sun4v_id, |
722 | e87231d4 | blueswir1 | .prom_addr = 0x1fff0000000ULL,
|
723 | e87231d4 | blueswir1 | .console_serial_base = 0,
|
724 | e87231d4 | blueswir1 | }, |
725 | e87231d4 | blueswir1 | /* Sun4v generic Niagara machine */
|
726 | e87231d4 | blueswir1 | { |
727 | e87231d4 | blueswir1 | .default_cpu_model = "Sun UltraSparc T1",
|
728 | e87231d4 | blueswir1 | .machine_id = niagara_id, |
729 | e87231d4 | blueswir1 | .prom_addr = 0xfff0000000ULL,
|
730 | e87231d4 | blueswir1 | .console_serial_base = 0xfff0c2c000ULL,
|
731 | c7ba218d | blueswir1 | }, |
732 | c7ba218d | blueswir1 | }; |
733 | c7ba218d | blueswir1 | |
734 | c7ba218d | blueswir1 | /* Sun4u hardware initialisation */
|
735 | c227f099 | Anthony Liguori | static void sun4u_init(ram_addr_t RAM_size, |
736 | 3023f332 | aliguori | const char *boot_devices, |
737 | c7ba218d | blueswir1 | const char *kernel_filename, const char *kernel_cmdline, |
738 | c7ba218d | blueswir1 | const char *initrd_filename, const char *cpu_model) |
739 | c7ba218d | blueswir1 | { |
740 | fbe1b595 | Paul Brook | sun4uv_init(RAM_size, boot_devices, kernel_filename, |
741 | c7ba218d | blueswir1 | kernel_cmdline, initrd_filename, cpu_model, &hwdefs[0]);
|
742 | c7ba218d | blueswir1 | } |
743 | c7ba218d | blueswir1 | |
744 | c7ba218d | blueswir1 | /* Sun4v hardware initialisation */
|
745 | c227f099 | Anthony Liguori | static void sun4v_init(ram_addr_t RAM_size, |
746 | 3023f332 | aliguori | const char *boot_devices, |
747 | c7ba218d | blueswir1 | const char *kernel_filename, const char *kernel_cmdline, |
748 | c7ba218d | blueswir1 | const char *initrd_filename, const char *cpu_model) |
749 | c7ba218d | blueswir1 | { |
750 | fbe1b595 | Paul Brook | sun4uv_init(RAM_size, boot_devices, kernel_filename, |
751 | c7ba218d | blueswir1 | kernel_cmdline, initrd_filename, cpu_model, &hwdefs[1]);
|
752 | c7ba218d | blueswir1 | } |
753 | c7ba218d | blueswir1 | |
754 | e87231d4 | blueswir1 | /* Niagara hardware initialisation */
|
755 | c227f099 | Anthony Liguori | static void niagara_init(ram_addr_t RAM_size, |
756 | 3023f332 | aliguori | const char *boot_devices, |
757 | e87231d4 | blueswir1 | const char *kernel_filename, const char *kernel_cmdline, |
758 | e87231d4 | blueswir1 | const char *initrd_filename, const char *cpu_model) |
759 | e87231d4 | blueswir1 | { |
760 | fbe1b595 | Paul Brook | sun4uv_init(RAM_size, boot_devices, kernel_filename, |
761 | e87231d4 | blueswir1 | kernel_cmdline, initrd_filename, cpu_model, &hwdefs[2]);
|
762 | e87231d4 | blueswir1 | } |
763 | e87231d4 | blueswir1 | |
764 | f80f9ec9 | Anthony Liguori | static QEMUMachine sun4u_machine = {
|
765 | 66de733b | blueswir1 | .name = "sun4u",
|
766 | 66de733b | blueswir1 | .desc = "Sun4u platform",
|
767 | 66de733b | blueswir1 | .init = sun4u_init, |
768 | 1bcee014 | blueswir1 | .max_cpus = 1, // XXX for now |
769 | 0c257437 | Anthony Liguori | .is_default = 1,
|
770 | 3475187d | bellard | }; |
771 | c7ba218d | blueswir1 | |
772 | f80f9ec9 | Anthony Liguori | static QEMUMachine sun4v_machine = {
|
773 | 66de733b | blueswir1 | .name = "sun4v",
|
774 | 66de733b | blueswir1 | .desc = "Sun4v platform",
|
775 | 66de733b | blueswir1 | .init = sun4v_init, |
776 | 1bcee014 | blueswir1 | .max_cpus = 1, // XXX for now |
777 | c7ba218d | blueswir1 | }; |
778 | e87231d4 | blueswir1 | |
779 | f80f9ec9 | Anthony Liguori | static QEMUMachine niagara_machine = {
|
780 | e87231d4 | blueswir1 | .name = "Niagara",
|
781 | e87231d4 | blueswir1 | .desc = "Sun4v platform, Niagara",
|
782 | e87231d4 | blueswir1 | .init = niagara_init, |
783 | 1bcee014 | blueswir1 | .max_cpus = 1, // XXX for now |
784 | e87231d4 | blueswir1 | }; |
785 | f80f9ec9 | Anthony Liguori | |
786 | f80f9ec9 | Anthony Liguori | static void sun4u_machine_init(void) |
787 | f80f9ec9 | Anthony Liguori | { |
788 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&sun4u_machine); |
789 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&sun4v_machine); |
790 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&niagara_machine); |
791 | f80f9ec9 | Anthony Liguori | } |
792 | f80f9ec9 | Anthony Liguori | |
793 | f80f9ec9 | Anthony Liguori | machine_init(sun4u_machine_init); |