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