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