root / hw / pc.c @ 0d31cb99
History | View | Annotate | Download (30.1 kB)
1 | 80cabfad | bellard | /*
|
---|---|---|---|
2 | 80cabfad | bellard | * QEMU PC System Emulator
|
3 | 5fafdf24 | ths | *
|
4 | 80cabfad | bellard | * Copyright (c) 2003-2004 Fabrice Bellard
|
5 | 5fafdf24 | ths | *
|
6 | 80cabfad | bellard | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | 80cabfad | bellard | * of this software and associated documentation files (the "Software"), to deal
|
8 | 80cabfad | bellard | * in the Software without restriction, including without limitation the rights
|
9 | 80cabfad | bellard | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | 80cabfad | bellard | * copies of the Software, and to permit persons to whom the Software is
|
11 | 80cabfad | bellard | * furnished to do so, subject to the following conditions:
|
12 | 80cabfad | bellard | *
|
13 | 80cabfad | bellard | * The above copyright notice and this permission notice shall be included in
|
14 | 80cabfad | bellard | * all copies or substantial portions of the Software.
|
15 | 80cabfad | bellard | *
|
16 | 80cabfad | bellard | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | 80cabfad | bellard | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | 80cabfad | bellard | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | 80cabfad | bellard | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | 80cabfad | bellard | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | 80cabfad | bellard | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | 80cabfad | bellard | * THE SOFTWARE.
|
23 | 80cabfad | bellard | */
|
24 | 87ecb68b | pbrook | #include "hw.h" |
25 | 87ecb68b | pbrook | #include "pc.h" |
26 | 87ecb68b | pbrook | #include "fdc.h" |
27 | 87ecb68b | pbrook | #include "pci.h" |
28 | 87ecb68b | pbrook | #include "block.h" |
29 | 87ecb68b | pbrook | #include "sysemu.h" |
30 | 87ecb68b | pbrook | #include "audio/audio.h" |
31 | 87ecb68b | pbrook | #include "net.h" |
32 | 87ecb68b | pbrook | #include "smbus.h" |
33 | 87ecb68b | pbrook | #include "boards.h" |
34 | cfa2af1f | aurel32 | #include "console.h" |
35 | 80cabfad | bellard | |
36 | b41a2cd1 | bellard | /* output Bochs bios info messages */
|
37 | b41a2cd1 | bellard | //#define DEBUG_BIOS
|
38 | b41a2cd1 | bellard | |
39 | 80cabfad | bellard | #define BIOS_FILENAME "bios.bin" |
40 | 80cabfad | bellard | #define VGABIOS_FILENAME "vgabios.bin" |
41 | de9258a8 | bellard | #define VGABIOS_CIRRUS_FILENAME "vgabios-cirrus.bin" |
42 | 80cabfad | bellard | |
43 | 7fb4fdcf | balrog | #define PC_MAX_BIOS_SIZE (4 * 1024 * 1024) |
44 | 7fb4fdcf | balrog | |
45 | a80274c3 | pbrook | /* Leave a chunk of memory at the top of RAM for the BIOS ACPI tables. */
|
46 | a80274c3 | pbrook | #define ACPI_DATA_SIZE 0x10000 |
47 | 80cabfad | bellard | |
48 | e4bcb14c | ths | #define MAX_IDE_BUS 2 |
49 | e4bcb14c | ths | |
50 | baca51fa | bellard | static fdctrl_t *floppy_controller;
|
51 | b0a21b53 | bellard | static RTCState *rtc_state;
|
52 | ec844b96 | bellard | static PITState *pit;
|
53 | d592d303 | bellard | static IOAPICState *ioapic;
|
54 | a5954d5c | bellard | static PCIDevice *i440fx_state;
|
55 | 80cabfad | bellard | |
56 | b41a2cd1 | bellard | static void ioport80_write(void *opaque, uint32_t addr, uint32_t data) |
57 | 80cabfad | bellard | { |
58 | 80cabfad | bellard | } |
59 | 80cabfad | bellard | |
60 | f929aad6 | bellard | /* MSDOS compatibility mode FPU exception support */
|
61 | d537cf6c | pbrook | static qemu_irq ferr_irq;
|
62 | f929aad6 | bellard | /* XXX: add IGNNE support */
|
63 | f929aad6 | bellard | void cpu_set_ferr(CPUX86State *s)
|
64 | f929aad6 | bellard | { |
65 | d537cf6c | pbrook | qemu_irq_raise(ferr_irq); |
66 | f929aad6 | bellard | } |
67 | f929aad6 | bellard | |
68 | f929aad6 | bellard | static void ioportF0_write(void *opaque, uint32_t addr, uint32_t data) |
69 | f929aad6 | bellard | { |
70 | d537cf6c | pbrook | qemu_irq_lower(ferr_irq); |
71 | f929aad6 | bellard | } |
72 | f929aad6 | bellard | |
73 | 28ab0e2e | bellard | /* TSC handling */
|
74 | 28ab0e2e | bellard | uint64_t cpu_get_tsc(CPUX86State *env) |
75 | 28ab0e2e | bellard | { |
76 | 1dce7c3c | bellard | /* Note: when using kqemu, it is more logical to return the host TSC
|
77 | 1dce7c3c | bellard | because kqemu does not trap the RDTSC instruction for
|
78 | 1dce7c3c | bellard | performance reasons */
|
79 | 1dce7c3c | bellard | #if USE_KQEMU
|
80 | 1dce7c3c | bellard | if (env->kqemu_enabled) {
|
81 | 1dce7c3c | bellard | return cpu_get_real_ticks();
|
82 | 5fafdf24 | ths | } else
|
83 | 1dce7c3c | bellard | #endif
|
84 | 1dce7c3c | bellard | { |
85 | 1dce7c3c | bellard | return cpu_get_ticks();
|
86 | 1dce7c3c | bellard | } |
87 | 28ab0e2e | bellard | } |
88 | 28ab0e2e | bellard | |
89 | a5954d5c | bellard | /* SMM support */
|
90 | a5954d5c | bellard | void cpu_smm_update(CPUState *env)
|
91 | a5954d5c | bellard | { |
92 | a5954d5c | bellard | if (i440fx_state && env == first_cpu)
|
93 | a5954d5c | bellard | i440fx_set_smm(i440fx_state, (env->hflags >> HF_SMM_SHIFT) & 1);
|
94 | a5954d5c | bellard | } |
95 | a5954d5c | bellard | |
96 | a5954d5c | bellard | |
97 | 3de388f6 | bellard | /* IRQ handling */
|
98 | 3de388f6 | bellard | int cpu_get_pic_interrupt(CPUState *env)
|
99 | 3de388f6 | bellard | { |
100 | 3de388f6 | bellard | int intno;
|
101 | 3de388f6 | bellard | |
102 | 3de388f6 | bellard | intno = apic_get_interrupt(env); |
103 | 3de388f6 | bellard | if (intno >= 0) { |
104 | 3de388f6 | bellard | /* set irq request if a PIC irq is still pending */
|
105 | 3de388f6 | bellard | /* XXX: improve that */
|
106 | 5fafdf24 | ths | pic_update_irq(isa_pic); |
107 | 3de388f6 | bellard | return intno;
|
108 | 3de388f6 | bellard | } |
109 | 3de388f6 | bellard | /* read the irq from the PIC */
|
110 | 0e21e12b | ths | if (!apic_accept_pic_intr(env))
|
111 | 0e21e12b | ths | return -1; |
112 | 0e21e12b | ths | |
113 | 3de388f6 | bellard | intno = pic_read_irq(isa_pic); |
114 | 3de388f6 | bellard | return intno;
|
115 | 3de388f6 | bellard | } |
116 | 3de388f6 | bellard | |
117 | d537cf6c | pbrook | static void pic_irq_request(void *opaque, int irq, int level) |
118 | 3de388f6 | bellard | { |
119 | a5b38b51 | aurel32 | CPUState *env = first_cpu; |
120 | a5b38b51 | aurel32 | |
121 | a5b38b51 | aurel32 | if (!level)
|
122 | a5b38b51 | aurel32 | return;
|
123 | a5b38b51 | aurel32 | |
124 | a5b38b51 | aurel32 | while (env) {
|
125 | a5b38b51 | aurel32 | if (apic_accept_pic_intr(env))
|
126 | a5b38b51 | aurel32 | apic_local_deliver(env, APIC_LINT0); |
127 | a5b38b51 | aurel32 | env = env->next_cpu; |
128 | a5b38b51 | aurel32 | } |
129 | 3de388f6 | bellard | } |
130 | 3de388f6 | bellard | |
131 | b0a21b53 | bellard | /* PC cmos mappings */
|
132 | b0a21b53 | bellard | |
133 | 80cabfad | bellard | #define REG_EQUIPMENT_BYTE 0x14 |
134 | 80cabfad | bellard | |
135 | 777428f2 | bellard | static int cmos_get_fd_drive_type(int fd0) |
136 | 777428f2 | bellard | { |
137 | 777428f2 | bellard | int val;
|
138 | 777428f2 | bellard | |
139 | 777428f2 | bellard | switch (fd0) {
|
140 | 777428f2 | bellard | case 0: |
141 | 777428f2 | bellard | /* 1.44 Mb 3"5 drive */
|
142 | 777428f2 | bellard | val = 4;
|
143 | 777428f2 | bellard | break;
|
144 | 777428f2 | bellard | case 1: |
145 | 777428f2 | bellard | /* 2.88 Mb 3"5 drive */
|
146 | 777428f2 | bellard | val = 5;
|
147 | 777428f2 | bellard | break;
|
148 | 777428f2 | bellard | case 2: |
149 | 777428f2 | bellard | /* 1.2 Mb 5"5 drive */
|
150 | 777428f2 | bellard | val = 2;
|
151 | 777428f2 | bellard | break;
|
152 | 777428f2 | bellard | default:
|
153 | 777428f2 | bellard | val = 0;
|
154 | 777428f2 | bellard | break;
|
155 | 777428f2 | bellard | } |
156 | 777428f2 | bellard | return val;
|
157 | 777428f2 | bellard | } |
158 | 777428f2 | bellard | |
159 | 5fafdf24 | ths | static void cmos_init_hd(int type_ofs, int info_ofs, BlockDriverState *hd) |
160 | ba6c2377 | bellard | { |
161 | ba6c2377 | bellard | RTCState *s = rtc_state; |
162 | ba6c2377 | bellard | int cylinders, heads, sectors;
|
163 | ba6c2377 | bellard | bdrv_get_geometry_hint(hd, &cylinders, &heads, §ors); |
164 | ba6c2377 | bellard | rtc_set_memory(s, type_ofs, 47);
|
165 | ba6c2377 | bellard | rtc_set_memory(s, info_ofs, cylinders); |
166 | ba6c2377 | bellard | rtc_set_memory(s, info_ofs + 1, cylinders >> 8); |
167 | ba6c2377 | bellard | rtc_set_memory(s, info_ofs + 2, heads);
|
168 | ba6c2377 | bellard | rtc_set_memory(s, info_ofs + 3, 0xff); |
169 | ba6c2377 | bellard | rtc_set_memory(s, info_ofs + 4, 0xff); |
170 | ba6c2377 | bellard | rtc_set_memory(s, info_ofs + 5, 0xc0 | ((heads > 8) << 3)); |
171 | ba6c2377 | bellard | rtc_set_memory(s, info_ofs + 6, cylinders);
|
172 | ba6c2377 | bellard | rtc_set_memory(s, info_ofs + 7, cylinders >> 8); |
173 | ba6c2377 | bellard | rtc_set_memory(s, info_ofs + 8, sectors);
|
174 | ba6c2377 | bellard | } |
175 | ba6c2377 | bellard | |
176 | 6ac0e82d | balrog | /* convert boot_device letter to something recognizable by the bios */
|
177 | 6ac0e82d | balrog | static int boot_device2nibble(char boot_device) |
178 | 6ac0e82d | balrog | { |
179 | 6ac0e82d | balrog | switch(boot_device) {
|
180 | 6ac0e82d | balrog | case 'a': |
181 | 6ac0e82d | balrog | case 'b': |
182 | 6ac0e82d | balrog | return 0x01; /* floppy boot */ |
183 | 6ac0e82d | balrog | case 'c': |
184 | 6ac0e82d | balrog | return 0x02; /* hard drive boot */ |
185 | 6ac0e82d | balrog | case 'd': |
186 | 6ac0e82d | balrog | return 0x03; /* CD-ROM boot */ |
187 | 6ac0e82d | balrog | case 'n': |
188 | 6ac0e82d | balrog | return 0x04; /* Network boot */ |
189 | 6ac0e82d | balrog | } |
190 | 6ac0e82d | balrog | return 0; |
191 | 6ac0e82d | balrog | } |
192 | 6ac0e82d | balrog | |
193 | 0ecdffbb | aurel32 | /* copy/pasted from cmos_init, should be made a general function
|
194 | 0ecdffbb | aurel32 | and used there as well */
|
195 | 3b4366de | blueswir1 | static int pc_boot_set(void *opaque, const char *boot_device) |
196 | 0ecdffbb | aurel32 | { |
197 | 0ecdffbb | aurel32 | #define PC_MAX_BOOT_DEVICES 3 |
198 | 3b4366de | blueswir1 | RTCState *s = (RTCState *)opaque; |
199 | 0ecdffbb | aurel32 | int nbds, bds[3] = { 0, }; |
200 | 0ecdffbb | aurel32 | int i;
|
201 | 0ecdffbb | aurel32 | |
202 | 0ecdffbb | aurel32 | nbds = strlen(boot_device); |
203 | 0ecdffbb | aurel32 | if (nbds > PC_MAX_BOOT_DEVICES) {
|
204 | 0ecdffbb | aurel32 | term_printf("Too many boot devices for PC\n");
|
205 | 0ecdffbb | aurel32 | return(1); |
206 | 0ecdffbb | aurel32 | } |
207 | 0ecdffbb | aurel32 | for (i = 0; i < nbds; i++) { |
208 | 0ecdffbb | aurel32 | bds[i] = boot_device2nibble(boot_device[i]); |
209 | 0ecdffbb | aurel32 | if (bds[i] == 0) { |
210 | 0ecdffbb | aurel32 | term_printf("Invalid boot device for PC: '%c'\n",
|
211 | 0ecdffbb | aurel32 | boot_device[i]); |
212 | 0ecdffbb | aurel32 | return(1); |
213 | 0ecdffbb | aurel32 | } |
214 | 0ecdffbb | aurel32 | } |
215 | 0ecdffbb | aurel32 | rtc_set_memory(s, 0x3d, (bds[1] << 4) | bds[0]); |
216 | 0ecdffbb | aurel32 | rtc_set_memory(s, 0x38, (bds[2] << 4)); |
217 | 0ecdffbb | aurel32 | return(0); |
218 | 0ecdffbb | aurel32 | } |
219 | 0ecdffbb | aurel32 | |
220 | ba6c2377 | bellard | /* hd_table must contain 4 block drivers */
|
221 | 00f82b8a | aurel32 | static void cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, |
222 | 00f82b8a | aurel32 | const char *boot_device, BlockDriverState **hd_table) |
223 | 80cabfad | bellard | { |
224 | b0a21b53 | bellard | RTCState *s = rtc_state; |
225 | 28c5af54 | j_mayer | int nbds, bds[3] = { 0, }; |
226 | 80cabfad | bellard | int val;
|
227 | b41a2cd1 | bellard | int fd0, fd1, nb;
|
228 | ba6c2377 | bellard | int i;
|
229 | b0a21b53 | bellard | |
230 | b0a21b53 | bellard | /* various important CMOS locations needed by PC/Bochs bios */
|
231 | 80cabfad | bellard | |
232 | 80cabfad | bellard | /* memory size */
|
233 | 333190eb | bellard | val = 640; /* base memory in K */ |
234 | 333190eb | bellard | rtc_set_memory(s, 0x15, val);
|
235 | 333190eb | bellard | rtc_set_memory(s, 0x16, val >> 8); |
236 | 333190eb | bellard | |
237 | 80cabfad | bellard | val = (ram_size / 1024) - 1024; |
238 | 80cabfad | bellard | if (val > 65535) |
239 | 80cabfad | bellard | val = 65535;
|
240 | b0a21b53 | bellard | rtc_set_memory(s, 0x17, val);
|
241 | b0a21b53 | bellard | rtc_set_memory(s, 0x18, val >> 8); |
242 | b0a21b53 | bellard | rtc_set_memory(s, 0x30, val);
|
243 | b0a21b53 | bellard | rtc_set_memory(s, 0x31, val >> 8); |
244 | 80cabfad | bellard | |
245 | 00f82b8a | aurel32 | if (above_4g_mem_size) {
|
246 | 00f82b8a | aurel32 | rtc_set_memory(s, 0x5b, (unsigned int)above_4g_mem_size >> 16); |
247 | 00f82b8a | aurel32 | rtc_set_memory(s, 0x5c, (unsigned int)above_4g_mem_size >> 24); |
248 | 00f82b8a | aurel32 | rtc_set_memory(s, 0x5d, (uint64_t)above_4g_mem_size >> 32); |
249 | 00f82b8a | aurel32 | } |
250 | 00f82b8a | aurel32 | |
251 | 9da98861 | bellard | if (ram_size > (16 * 1024 * 1024)) |
252 | 9da98861 | bellard | val = (ram_size / 65536) - ((16 * 1024 * 1024) / 65536); |
253 | 9da98861 | bellard | else
|
254 | 9da98861 | bellard | val = 0;
|
255 | 80cabfad | bellard | if (val > 65535) |
256 | 80cabfad | bellard | val = 65535;
|
257 | b0a21b53 | bellard | rtc_set_memory(s, 0x34, val);
|
258 | b0a21b53 | bellard | rtc_set_memory(s, 0x35, val >> 8); |
259 | 3b46e624 | ths | |
260 | 298e01b6 | aurel32 | /* set the number of CPU */
|
261 | 298e01b6 | aurel32 | rtc_set_memory(s, 0x5f, smp_cpus - 1); |
262 | 298e01b6 | aurel32 | |
263 | 6ac0e82d | balrog | /* set boot devices, and disable floppy signature check if requested */
|
264 | 28c5af54 | j_mayer | #define PC_MAX_BOOT_DEVICES 3 |
265 | 28c5af54 | j_mayer | nbds = strlen(boot_device); |
266 | 28c5af54 | j_mayer | if (nbds > PC_MAX_BOOT_DEVICES) {
|
267 | 28c5af54 | j_mayer | fprintf(stderr, "Too many boot devices for PC\n");
|
268 | 28c5af54 | j_mayer | exit(1);
|
269 | 28c5af54 | j_mayer | } |
270 | 28c5af54 | j_mayer | for (i = 0; i < nbds; i++) { |
271 | 28c5af54 | j_mayer | bds[i] = boot_device2nibble(boot_device[i]); |
272 | 28c5af54 | j_mayer | if (bds[i] == 0) { |
273 | 28c5af54 | j_mayer | fprintf(stderr, "Invalid boot device for PC: '%c'\n",
|
274 | 28c5af54 | j_mayer | boot_device[i]); |
275 | 28c5af54 | j_mayer | exit(1);
|
276 | 28c5af54 | j_mayer | } |
277 | 28c5af54 | j_mayer | } |
278 | 28c5af54 | j_mayer | rtc_set_memory(s, 0x3d, (bds[1] << 4) | bds[0]); |
279 | 28c5af54 | j_mayer | rtc_set_memory(s, 0x38, (bds[2] << 4) | (fd_bootchk ? 0x0 : 0x1)); |
280 | 80cabfad | bellard | |
281 | b41a2cd1 | bellard | /* floppy type */
|
282 | b41a2cd1 | bellard | |
283 | baca51fa | bellard | fd0 = fdctrl_get_drive_type(floppy_controller, 0);
|
284 | baca51fa | bellard | fd1 = fdctrl_get_drive_type(floppy_controller, 1);
|
285 | 80cabfad | bellard | |
286 | 777428f2 | bellard | val = (cmos_get_fd_drive_type(fd0) << 4) | cmos_get_fd_drive_type(fd1);
|
287 | b0a21b53 | bellard | rtc_set_memory(s, 0x10, val);
|
288 | 3b46e624 | ths | |
289 | b0a21b53 | bellard | val = 0;
|
290 | b41a2cd1 | bellard | nb = 0;
|
291 | 80cabfad | bellard | if (fd0 < 3) |
292 | 80cabfad | bellard | nb++; |
293 | 80cabfad | bellard | if (fd1 < 3) |
294 | 80cabfad | bellard | nb++; |
295 | 80cabfad | bellard | switch (nb) {
|
296 | 80cabfad | bellard | case 0: |
297 | 80cabfad | bellard | break;
|
298 | 80cabfad | bellard | case 1: |
299 | b0a21b53 | bellard | val |= 0x01; /* 1 drive, ready for boot */ |
300 | 80cabfad | bellard | break;
|
301 | 80cabfad | bellard | case 2: |
302 | b0a21b53 | bellard | val |= 0x41; /* 2 drives, ready for boot */ |
303 | 80cabfad | bellard | break;
|
304 | 80cabfad | bellard | } |
305 | b0a21b53 | bellard | val |= 0x02; /* FPU is there */ |
306 | b0a21b53 | bellard | val |= 0x04; /* PS/2 mouse installed */ |
307 | b0a21b53 | bellard | rtc_set_memory(s, REG_EQUIPMENT_BYTE, val); |
308 | b0a21b53 | bellard | |
309 | ba6c2377 | bellard | /* hard drives */
|
310 | ba6c2377 | bellard | |
311 | ba6c2377 | bellard | rtc_set_memory(s, 0x12, (hd_table[0] ? 0xf0 : 0) | (hd_table[1] ? 0x0f : 0)); |
312 | ba6c2377 | bellard | if (hd_table[0]) |
313 | ba6c2377 | bellard | cmos_init_hd(0x19, 0x1b, hd_table[0]); |
314 | 5fafdf24 | ths | if (hd_table[1]) |
315 | ba6c2377 | bellard | cmos_init_hd(0x1a, 0x24, hd_table[1]); |
316 | ba6c2377 | bellard | |
317 | ba6c2377 | bellard | val = 0;
|
318 | 40b6ecc6 | bellard | for (i = 0; i < 4; i++) { |
319 | ba6c2377 | bellard | if (hd_table[i]) {
|
320 | 46d4767d | bellard | int cylinders, heads, sectors, translation;
|
321 | 46d4767d | bellard | /* NOTE: bdrv_get_geometry_hint() returns the physical
|
322 | 46d4767d | bellard | geometry. It is always such that: 1 <= sects <= 63, 1
|
323 | 46d4767d | bellard | <= heads <= 16, 1 <= cylinders <= 16383. The BIOS
|
324 | 46d4767d | bellard | geometry can be different if a translation is done. */
|
325 | 46d4767d | bellard | translation = bdrv_get_translation_hint(hd_table[i]); |
326 | 46d4767d | bellard | if (translation == BIOS_ATA_TRANSLATION_AUTO) {
|
327 | 46d4767d | bellard | bdrv_get_geometry_hint(hd_table[i], &cylinders, &heads, §ors); |
328 | 46d4767d | bellard | if (cylinders <= 1024 && heads <= 16 && sectors <= 63) { |
329 | 46d4767d | bellard | /* No translation. */
|
330 | 46d4767d | bellard | translation = 0;
|
331 | 46d4767d | bellard | } else {
|
332 | 46d4767d | bellard | /* LBA translation. */
|
333 | 46d4767d | bellard | translation = 1;
|
334 | 46d4767d | bellard | } |
335 | 40b6ecc6 | bellard | } else {
|
336 | 46d4767d | bellard | translation--; |
337 | ba6c2377 | bellard | } |
338 | ba6c2377 | bellard | val |= translation << (i * 2);
|
339 | ba6c2377 | bellard | } |
340 | 40b6ecc6 | bellard | } |
341 | ba6c2377 | bellard | rtc_set_memory(s, 0x39, val);
|
342 | 80cabfad | bellard | } |
343 | 80cabfad | bellard | |
344 | 59b8ad81 | bellard | void ioport_set_a20(int enable) |
345 | 59b8ad81 | bellard | { |
346 | 59b8ad81 | bellard | /* XXX: send to all CPUs ? */
|
347 | 59b8ad81 | bellard | cpu_x86_set_a20(first_cpu, enable); |
348 | 59b8ad81 | bellard | } |
349 | 59b8ad81 | bellard | |
350 | 59b8ad81 | bellard | int ioport_get_a20(void) |
351 | 59b8ad81 | bellard | { |
352 | 59b8ad81 | bellard | return ((first_cpu->a20_mask >> 20) & 1); |
353 | 59b8ad81 | bellard | } |
354 | 59b8ad81 | bellard | |
355 | e1a23744 | bellard | static void ioport92_write(void *opaque, uint32_t addr, uint32_t val) |
356 | e1a23744 | bellard | { |
357 | 59b8ad81 | bellard | ioport_set_a20((val >> 1) & 1); |
358 | e1a23744 | bellard | /* XXX: bit 0 is fast reset */
|
359 | e1a23744 | bellard | } |
360 | e1a23744 | bellard | |
361 | e1a23744 | bellard | static uint32_t ioport92_read(void *opaque, uint32_t addr) |
362 | e1a23744 | bellard | { |
363 | 59b8ad81 | bellard | return ioport_get_a20() << 1; |
364 | e1a23744 | bellard | } |
365 | e1a23744 | bellard | |
366 | 80cabfad | bellard | /***********************************************************/
|
367 | 80cabfad | bellard | /* Bochs BIOS debug ports */
|
368 | 80cabfad | bellard | |
369 | 9596ebb7 | pbrook | static void bochs_bios_write(void *opaque, uint32_t addr, uint32_t val) |
370 | 80cabfad | bellard | { |
371 | a2f659ee | bellard | static const char shutdown_str[8] = "Shutdown"; |
372 | a2f659ee | bellard | static int shutdown_index = 0; |
373 | 3b46e624 | ths | |
374 | 80cabfad | bellard | switch(addr) {
|
375 | 80cabfad | bellard | /* Bochs BIOS messages */
|
376 | 80cabfad | bellard | case 0x400: |
377 | 80cabfad | bellard | case 0x401: |
378 | 80cabfad | bellard | fprintf(stderr, "BIOS panic at rombios.c, line %d\n", val);
|
379 | 80cabfad | bellard | exit(1);
|
380 | 80cabfad | bellard | case 0x402: |
381 | 80cabfad | bellard | case 0x403: |
382 | 80cabfad | bellard | #ifdef DEBUG_BIOS
|
383 | 80cabfad | bellard | fprintf(stderr, "%c", val);
|
384 | 80cabfad | bellard | #endif
|
385 | 80cabfad | bellard | break;
|
386 | a2f659ee | bellard | case 0x8900: |
387 | a2f659ee | bellard | /* same as Bochs power off */
|
388 | a2f659ee | bellard | if (val == shutdown_str[shutdown_index]) {
|
389 | a2f659ee | bellard | shutdown_index++; |
390 | a2f659ee | bellard | if (shutdown_index == 8) { |
391 | a2f659ee | bellard | shutdown_index = 0;
|
392 | a2f659ee | bellard | qemu_system_shutdown_request(); |
393 | a2f659ee | bellard | } |
394 | a2f659ee | bellard | } else {
|
395 | a2f659ee | bellard | shutdown_index = 0;
|
396 | a2f659ee | bellard | } |
397 | a2f659ee | bellard | break;
|
398 | 80cabfad | bellard | |
399 | 80cabfad | bellard | /* LGPL'ed VGA BIOS messages */
|
400 | 80cabfad | bellard | case 0x501: |
401 | 80cabfad | bellard | case 0x502: |
402 | 80cabfad | bellard | fprintf(stderr, "VGA BIOS panic, line %d\n", val);
|
403 | 80cabfad | bellard | exit(1);
|
404 | 80cabfad | bellard | case 0x500: |
405 | 80cabfad | bellard | case 0x503: |
406 | 80cabfad | bellard | #ifdef DEBUG_BIOS
|
407 | 80cabfad | bellard | fprintf(stderr, "%c", val);
|
408 | 80cabfad | bellard | #endif
|
409 | 80cabfad | bellard | break;
|
410 | 80cabfad | bellard | } |
411 | 80cabfad | bellard | } |
412 | 80cabfad | bellard | |
413 | 9596ebb7 | pbrook | static void bochs_bios_init(void) |
414 | 80cabfad | bellard | { |
415 | b41a2cd1 | bellard | register_ioport_write(0x400, 1, 2, bochs_bios_write, NULL); |
416 | b41a2cd1 | bellard | register_ioport_write(0x401, 1, 2, bochs_bios_write, NULL); |
417 | b41a2cd1 | bellard | register_ioport_write(0x402, 1, 1, bochs_bios_write, NULL); |
418 | b41a2cd1 | bellard | register_ioport_write(0x403, 1, 1, bochs_bios_write, NULL); |
419 | a2f659ee | bellard | register_ioport_write(0x8900, 1, 1, bochs_bios_write, NULL); |
420 | b41a2cd1 | bellard | |
421 | b41a2cd1 | bellard | register_ioport_write(0x501, 1, 2, bochs_bios_write, NULL); |
422 | b41a2cd1 | bellard | register_ioport_write(0x502, 1, 2, bochs_bios_write, NULL); |
423 | b41a2cd1 | bellard | register_ioport_write(0x500, 1, 1, bochs_bios_write, NULL); |
424 | b41a2cd1 | bellard | register_ioport_write(0x503, 1, 1, bochs_bios_write, NULL); |
425 | 80cabfad | bellard | } |
426 | 80cabfad | bellard | |
427 | 642a4f96 | ths | /* Generate an initial boot sector which sets state and jump to
|
428 | 642a4f96 | ths | a specified vector */
|
429 | 3f6c925f | balrog | static void generate_bootsect(uint32_t gpr[8], uint16_t segs[6], uint16_t ip) |
430 | 642a4f96 | ths | { |
431 | 642a4f96 | ths | uint8_t bootsect[512], *p;
|
432 | 642a4f96 | ths | int i;
|
433 | e4bcb14c | ths | int hda;
|
434 | 642a4f96 | ths | |
435 | e4bcb14c | ths | hda = drive_get_index(IF_IDE, 0, 0); |
436 | e4bcb14c | ths | if (hda == -1) { |
437 | 642a4f96 | ths | fprintf(stderr, "A disk image must be given for 'hda' when booting "
|
438 | 642a4f96 | ths | "a Linux kernel\n");
|
439 | 642a4f96 | ths | exit(1);
|
440 | 642a4f96 | ths | } |
441 | 642a4f96 | ths | |
442 | 642a4f96 | ths | memset(bootsect, 0, sizeof(bootsect)); |
443 | 642a4f96 | ths | |
444 | 642a4f96 | ths | /* Copy the MSDOS partition table if possible */
|
445 | e4bcb14c | ths | bdrv_read(drives_table[hda].bdrv, 0, bootsect, 1); |
446 | 642a4f96 | ths | |
447 | 642a4f96 | ths | /* Make sure we have a partition signature */
|
448 | 642a4f96 | ths | bootsect[510] = 0x55; |
449 | 642a4f96 | ths | bootsect[511] = 0xaa; |
450 | 642a4f96 | ths | |
451 | 642a4f96 | ths | /* Actual code */
|
452 | 642a4f96 | ths | p = bootsect; |
453 | 642a4f96 | ths | *p++ = 0xfa; /* CLI */ |
454 | 642a4f96 | ths | *p++ = 0xfc; /* CLD */ |
455 | 642a4f96 | ths | |
456 | 642a4f96 | ths | for (i = 0; i < 6; i++) { |
457 | 642a4f96 | ths | if (i == 1) /* Skip CS */ |
458 | 642a4f96 | ths | continue;
|
459 | 642a4f96 | ths | |
460 | 642a4f96 | ths | *p++ = 0xb8; /* MOV AX,imm16 */ |
461 | 642a4f96 | ths | *p++ = segs[i]; |
462 | 642a4f96 | ths | *p++ = segs[i] >> 8;
|
463 | 642a4f96 | ths | *p++ = 0x8e; /* MOV <seg>,AX */ |
464 | 642a4f96 | ths | *p++ = 0xc0 + (i << 3); |
465 | 642a4f96 | ths | } |
466 | 642a4f96 | ths | |
467 | 642a4f96 | ths | for (i = 0; i < 8; i++) { |
468 | 642a4f96 | ths | *p++ = 0x66; /* 32-bit operand size */ |
469 | 642a4f96 | ths | *p++ = 0xb8 + i; /* MOV <reg>,imm32 */ |
470 | 642a4f96 | ths | *p++ = gpr[i]; |
471 | 642a4f96 | ths | *p++ = gpr[i] >> 8;
|
472 | 642a4f96 | ths | *p++ = gpr[i] >> 16;
|
473 | 642a4f96 | ths | *p++ = gpr[i] >> 24;
|
474 | 642a4f96 | ths | } |
475 | 642a4f96 | ths | |
476 | 642a4f96 | ths | *p++ = 0xea; /* JMP FAR */ |
477 | 642a4f96 | ths | *p++ = ip; /* IP */
|
478 | 642a4f96 | ths | *p++ = ip >> 8;
|
479 | 642a4f96 | ths | *p++ = segs[1]; /* CS */ |
480 | 642a4f96 | ths | *p++ = segs[1] >> 8; |
481 | 642a4f96 | ths | |
482 | e4bcb14c | ths | bdrv_set_boot_sector(drives_table[hda].bdrv, bootsect, sizeof(bootsect));
|
483 | 642a4f96 | ths | } |
484 | 80cabfad | bellard | |
485 | 642a4f96 | ths | static long get_file_size(FILE *f) |
486 | 642a4f96 | ths | { |
487 | 642a4f96 | ths | long where, size;
|
488 | 642a4f96 | ths | |
489 | 642a4f96 | ths | /* XXX: on Unix systems, using fstat() probably makes more sense */
|
490 | 642a4f96 | ths | |
491 | 642a4f96 | ths | where = ftell(f); |
492 | 642a4f96 | ths | fseek(f, 0, SEEK_END);
|
493 | 642a4f96 | ths | size = ftell(f); |
494 | 642a4f96 | ths | fseek(f, where, SEEK_SET); |
495 | 642a4f96 | ths | |
496 | 642a4f96 | ths | return size;
|
497 | 642a4f96 | ths | } |
498 | 642a4f96 | ths | |
499 | 642a4f96 | ths | static void load_linux(const char *kernel_filename, |
500 | 642a4f96 | ths | const char *initrd_filename, |
501 | 642a4f96 | ths | const char *kernel_cmdline) |
502 | 642a4f96 | ths | { |
503 | 642a4f96 | ths | uint16_t protocol; |
504 | 642a4f96 | ths | uint32_t gpr[8];
|
505 | 642a4f96 | ths | uint16_t seg[6];
|
506 | 642a4f96 | ths | uint16_t real_seg; |
507 | 642a4f96 | ths | int setup_size, kernel_size, initrd_size, cmdline_size;
|
508 | 642a4f96 | ths | uint32_t initrd_max; |
509 | 642a4f96 | ths | uint8_t header[1024];
|
510 | a37af289 | blueswir1 | target_phys_addr_t real_addr, prot_addr, cmdline_addr, initrd_addr; |
511 | 642a4f96 | ths | FILE *f, *fi; |
512 | 642a4f96 | ths | |
513 | 642a4f96 | ths | /* Align to 16 bytes as a paranoia measure */
|
514 | 642a4f96 | ths | cmdline_size = (strlen(kernel_cmdline)+16) & ~15; |
515 | 642a4f96 | ths | |
516 | 642a4f96 | ths | /* load the kernel header */
|
517 | 642a4f96 | ths | f = fopen(kernel_filename, "rb");
|
518 | 642a4f96 | ths | if (!f || !(kernel_size = get_file_size(f)) ||
|
519 | 642a4f96 | ths | fread(header, 1, 1024, f) != 1024) { |
520 | 642a4f96 | ths | fprintf(stderr, "qemu: could not load kernel '%s'\n",
|
521 | 642a4f96 | ths | kernel_filename); |
522 | 642a4f96 | ths | exit(1);
|
523 | 642a4f96 | ths | } |
524 | 642a4f96 | ths | |
525 | 642a4f96 | ths | /* kernel protocol version */
|
526 | bc4edd79 | bellard | #if 0
|
527 | 642a4f96 | ths | fprintf(stderr, "header magic: %#x\n", ldl_p(header+0x202));
|
528 | bc4edd79 | bellard | #endif
|
529 | 642a4f96 | ths | if (ldl_p(header+0x202) == 0x53726448) |
530 | 642a4f96 | ths | protocol = lduw_p(header+0x206);
|
531 | 642a4f96 | ths | else
|
532 | 642a4f96 | ths | protocol = 0;
|
533 | 642a4f96 | ths | |
534 | 642a4f96 | ths | if (protocol < 0x200 || !(header[0x211] & 0x01)) { |
535 | 642a4f96 | ths | /* Low kernel */
|
536 | a37af289 | blueswir1 | real_addr = 0x90000;
|
537 | a37af289 | blueswir1 | cmdline_addr = 0x9a000 - cmdline_size;
|
538 | a37af289 | blueswir1 | prot_addr = 0x10000;
|
539 | 642a4f96 | ths | } else if (protocol < 0x202) { |
540 | 642a4f96 | ths | /* High but ancient kernel */
|
541 | a37af289 | blueswir1 | real_addr = 0x90000;
|
542 | a37af289 | blueswir1 | cmdline_addr = 0x9a000 - cmdline_size;
|
543 | a37af289 | blueswir1 | prot_addr = 0x100000;
|
544 | 642a4f96 | ths | } else {
|
545 | 642a4f96 | ths | /* High and recent kernel */
|
546 | a37af289 | blueswir1 | real_addr = 0x10000;
|
547 | a37af289 | blueswir1 | cmdline_addr = 0x20000;
|
548 | a37af289 | blueswir1 | prot_addr = 0x100000;
|
549 | 642a4f96 | ths | } |
550 | 642a4f96 | ths | |
551 | bc4edd79 | bellard | #if 0
|
552 | 642a4f96 | ths | fprintf(stderr,
|
553 | 642a4f96 | ths | "qemu: real_addr = %#zx\n"
|
554 | 642a4f96 | ths | "qemu: cmdline_addr = %#zx\n"
|
555 | 642a4f96 | ths | "qemu: prot_addr = %#zx\n",
|
556 | a37af289 | blueswir1 | real_addr,
|
557 | a37af289 | blueswir1 | cmdline_addr,
|
558 | a37af289 | blueswir1 | prot_addr);
|
559 | bc4edd79 | bellard | #endif
|
560 | 642a4f96 | ths | |
561 | 642a4f96 | ths | /* highest address for loading the initrd */
|
562 | 642a4f96 | ths | if (protocol >= 0x203) |
563 | 642a4f96 | ths | initrd_max = ldl_p(header+0x22c);
|
564 | 642a4f96 | ths | else
|
565 | 642a4f96 | ths | initrd_max = 0x37ffffff;
|
566 | 642a4f96 | ths | |
567 | 642a4f96 | ths | if (initrd_max >= ram_size-ACPI_DATA_SIZE)
|
568 | 642a4f96 | ths | initrd_max = ram_size-ACPI_DATA_SIZE-1;
|
569 | 642a4f96 | ths | |
570 | 642a4f96 | ths | /* kernel command line */
|
571 | a37af289 | blueswir1 | pstrcpy_targphys(cmdline_addr, 4096, kernel_cmdline);
|
572 | 642a4f96 | ths | |
573 | 642a4f96 | ths | if (protocol >= 0x202) { |
574 | a37af289 | blueswir1 | stl_p(header+0x228, cmdline_addr);
|
575 | 642a4f96 | ths | } else {
|
576 | 642a4f96 | ths | stw_p(header+0x20, 0xA33F); |
577 | 642a4f96 | ths | stw_p(header+0x22, cmdline_addr-real_addr);
|
578 | 642a4f96 | ths | } |
579 | 642a4f96 | ths | |
580 | 642a4f96 | ths | /* loader type */
|
581 | 642a4f96 | ths | /* High nybble = B reserved for Qemu; low nybble is revision number.
|
582 | 642a4f96 | ths | If this code is substantially changed, you may want to consider
|
583 | 642a4f96 | ths | incrementing the revision. */
|
584 | 642a4f96 | ths | if (protocol >= 0x200) |
585 | 642a4f96 | ths | header[0x210] = 0xB0; |
586 | 642a4f96 | ths | |
587 | 642a4f96 | ths | /* heap */
|
588 | 642a4f96 | ths | if (protocol >= 0x201) { |
589 | 642a4f96 | ths | header[0x211] |= 0x80; /* CAN_USE_HEAP */ |
590 | 642a4f96 | ths | stw_p(header+0x224, cmdline_addr-real_addr-0x200); |
591 | 642a4f96 | ths | } |
592 | 642a4f96 | ths | |
593 | 642a4f96 | ths | /* load initrd */
|
594 | 642a4f96 | ths | if (initrd_filename) {
|
595 | 642a4f96 | ths | if (protocol < 0x200) { |
596 | 642a4f96 | ths | fprintf(stderr, "qemu: linux kernel too old to load a ram disk\n");
|
597 | 642a4f96 | ths | exit(1);
|
598 | 642a4f96 | ths | } |
599 | 642a4f96 | ths | |
600 | 642a4f96 | ths | fi = fopen(initrd_filename, "rb");
|
601 | 642a4f96 | ths | if (!fi) {
|
602 | 642a4f96 | ths | fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
|
603 | 642a4f96 | ths | initrd_filename); |
604 | 642a4f96 | ths | exit(1);
|
605 | 642a4f96 | ths | } |
606 | 642a4f96 | ths | |
607 | 642a4f96 | ths | initrd_size = get_file_size(fi); |
608 | a37af289 | blueswir1 | initrd_addr = (initrd_max-initrd_size) & ~4095;
|
609 | 642a4f96 | ths | |
610 | 642a4f96 | ths | fprintf(stderr, "qemu: loading initrd (%#x bytes) at %#zx\n",
|
611 | a37af289 | blueswir1 | initrd_size, initrd_addr); |
612 | 642a4f96 | ths | |
613 | a37af289 | blueswir1 | if (!fread_targphys_ok(initrd_addr, initrd_size, fi)) {
|
614 | 642a4f96 | ths | fprintf(stderr, "qemu: read error on initial ram disk '%s'\n",
|
615 | 642a4f96 | ths | initrd_filename); |
616 | 642a4f96 | ths | exit(1);
|
617 | 642a4f96 | ths | } |
618 | 642a4f96 | ths | fclose(fi); |
619 | 642a4f96 | ths | |
620 | a37af289 | blueswir1 | stl_p(header+0x218, initrd_addr);
|
621 | 642a4f96 | ths | stl_p(header+0x21c, initrd_size);
|
622 | 642a4f96 | ths | } |
623 | 642a4f96 | ths | |
624 | 642a4f96 | ths | /* store the finalized header and load the rest of the kernel */
|
625 | a37af289 | blueswir1 | cpu_physical_memory_write(real_addr, header, 1024);
|
626 | 642a4f96 | ths | |
627 | 642a4f96 | ths | setup_size = header[0x1f1];
|
628 | 642a4f96 | ths | if (setup_size == 0) |
629 | 642a4f96 | ths | setup_size = 4;
|
630 | 642a4f96 | ths | |
631 | 642a4f96 | ths | setup_size = (setup_size+1)*512; |
632 | 642a4f96 | ths | kernel_size -= setup_size; /* Size of protected-mode code */
|
633 | 642a4f96 | ths | |
634 | a37af289 | blueswir1 | if (!fread_targphys_ok(real_addr+1024, setup_size-1024, f) || |
635 | a37af289 | blueswir1 | !fread_targphys_ok(prot_addr, kernel_size, f)) { |
636 | 642a4f96 | ths | fprintf(stderr, "qemu: read error on kernel '%s'\n",
|
637 | 642a4f96 | ths | kernel_filename); |
638 | 642a4f96 | ths | exit(1);
|
639 | 642a4f96 | ths | } |
640 | 642a4f96 | ths | fclose(f); |
641 | 642a4f96 | ths | |
642 | 642a4f96 | ths | /* generate bootsector to set up the initial register state */
|
643 | a37af289 | blueswir1 | real_seg = real_addr >> 4;
|
644 | 642a4f96 | ths | seg[0] = seg[2] = seg[3] = seg[4] = seg[4] = real_seg; |
645 | 642a4f96 | ths | seg[1] = real_seg+0x20; /* CS */ |
646 | 642a4f96 | ths | memset(gpr, 0, sizeof gpr); |
647 | 642a4f96 | ths | gpr[4] = cmdline_addr-real_addr-16; /* SP (-16 is paranoia) */ |
648 | 642a4f96 | ths | |
649 | 642a4f96 | ths | generate_bootsect(gpr, seg, 0);
|
650 | 642a4f96 | ths | } |
651 | 642a4f96 | ths | |
652 | 59b8ad81 | bellard | static void main_cpu_reset(void *opaque) |
653 | 59b8ad81 | bellard | { |
654 | 59b8ad81 | bellard | CPUState *env = opaque; |
655 | 59b8ad81 | bellard | cpu_reset(env); |
656 | 59b8ad81 | bellard | } |
657 | 59b8ad81 | bellard | |
658 | b41a2cd1 | bellard | static const int ide_iobase[2] = { 0x1f0, 0x170 }; |
659 | b41a2cd1 | bellard | static const int ide_iobase2[2] = { 0x3f6, 0x376 }; |
660 | b41a2cd1 | bellard | static const int ide_irq[2] = { 14, 15 }; |
661 | b41a2cd1 | bellard | |
662 | b41a2cd1 | bellard | #define NE2000_NB_MAX 6 |
663 | b41a2cd1 | bellard | |
664 | 8d11df9e | bellard | static int ne2000_io[NE2000_NB_MAX] = { 0x300, 0x320, 0x340, 0x360, 0x280, 0x380 }; |
665 | b41a2cd1 | bellard | static int ne2000_irq[NE2000_NB_MAX] = { 9, 10, 11, 3, 4, 5 }; |
666 | b41a2cd1 | bellard | |
667 | 8d11df9e | bellard | static int serial_io[MAX_SERIAL_PORTS] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; |
668 | 8d11df9e | bellard | static int serial_irq[MAX_SERIAL_PORTS] = { 4, 3, 4, 3 }; |
669 | 8d11df9e | bellard | |
670 | 6508fe59 | bellard | static int parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc }; |
671 | 6508fe59 | bellard | static int parallel_irq[MAX_PARALLEL_PORTS] = { 7, 7, 7 }; |
672 | 6508fe59 | bellard | |
673 | 6a36d84e | bellard | #ifdef HAS_AUDIO
|
674 | d537cf6c | pbrook | static void audio_init (PCIBus *pci_bus, qemu_irq *pic) |
675 | 6a36d84e | bellard | { |
676 | 6a36d84e | bellard | struct soundhw *c;
|
677 | 6a36d84e | bellard | int audio_enabled = 0; |
678 | 6a36d84e | bellard | |
679 | 6a36d84e | bellard | for (c = soundhw; !audio_enabled && c->name; ++c) {
|
680 | 6a36d84e | bellard | audio_enabled = c->enabled; |
681 | 6a36d84e | bellard | } |
682 | 6a36d84e | bellard | |
683 | 6a36d84e | bellard | if (audio_enabled) {
|
684 | 6a36d84e | bellard | AudioState *s; |
685 | 6a36d84e | bellard | |
686 | 6a36d84e | bellard | s = AUD_init (); |
687 | 6a36d84e | bellard | if (s) {
|
688 | 6a36d84e | bellard | for (c = soundhw; c->name; ++c) {
|
689 | 6a36d84e | bellard | if (c->enabled) {
|
690 | 6a36d84e | bellard | if (c->isa) {
|
691 | d537cf6c | pbrook | c->init.init_isa (s, pic); |
692 | 6a36d84e | bellard | } |
693 | 6a36d84e | bellard | else {
|
694 | 6a36d84e | bellard | if (pci_bus) {
|
695 | 6a36d84e | bellard | c->init.init_pci (pci_bus, s); |
696 | 6a36d84e | bellard | } |
697 | 6a36d84e | bellard | } |
698 | 6a36d84e | bellard | } |
699 | 6a36d84e | bellard | } |
700 | 6a36d84e | bellard | } |
701 | 6a36d84e | bellard | } |
702 | 6a36d84e | bellard | } |
703 | 6a36d84e | bellard | #endif
|
704 | 6a36d84e | bellard | |
705 | d537cf6c | pbrook | static void pc_init_ne2k_isa(NICInfo *nd, qemu_irq *pic) |
706 | a41b2ff2 | pbrook | { |
707 | a41b2ff2 | pbrook | static int nb_ne2k = 0; |
708 | a41b2ff2 | pbrook | |
709 | a41b2ff2 | pbrook | if (nb_ne2k == NE2000_NB_MAX)
|
710 | a41b2ff2 | pbrook | return;
|
711 | d537cf6c | pbrook | isa_ne2000_init(ne2000_io[nb_ne2k], pic[ne2000_irq[nb_ne2k]], nd); |
712 | a41b2ff2 | pbrook | nb_ne2k++; |
713 | a41b2ff2 | pbrook | } |
714 | a41b2ff2 | pbrook | |
715 | 80cabfad | bellard | /* PC hardware initialisation */
|
716 | 00f82b8a | aurel32 | static void pc_init1(ram_addr_t ram_size, int vga_ram_size, |
717 | b881c2c6 | blueswir1 | const char *boot_device, DisplayState *ds, |
718 | b5ff2d6e | bellard | const char *kernel_filename, const char *kernel_cmdline, |
719 | 3dbbdc25 | bellard | const char *initrd_filename, |
720 | a049de61 | bellard | int pci_enabled, const char *cpu_model) |
721 | 80cabfad | bellard | { |
722 | 80cabfad | bellard | char buf[1024]; |
723 | 642a4f96 | ths | int ret, linux_boot, i;
|
724 | 970ac5a3 | bellard | ram_addr_t ram_addr, vga_ram_addr, bios_offset, vga_bios_offset; |
725 | 00f82b8a | aurel32 | ram_addr_t below_4g_mem_size, above_4g_mem_size = 0;
|
726 | 970ac5a3 | bellard | int bios_size, isa_bios_size, vga_bios_size;
|
727 | 46e50e9d | bellard | PCIBus *pci_bus; |
728 | 5c3ff3a7 | pbrook | int piix3_devfn = -1; |
729 | 59b8ad81 | bellard | CPUState *env; |
730 | a41b2ff2 | pbrook | NICInfo *nd; |
731 | d537cf6c | pbrook | qemu_irq *cpu_irq; |
732 | d537cf6c | pbrook | qemu_irq *i8259; |
733 | e4bcb14c | ths | int index;
|
734 | e4bcb14c | ths | BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
735 | e4bcb14c | ths | BlockDriverState *fd[MAX_FD]; |
736 | d592d303 | bellard | |
737 | 00f82b8a | aurel32 | if (ram_size >= 0xe0000000 ) { |
738 | 00f82b8a | aurel32 | above_4g_mem_size = ram_size - 0xe0000000;
|
739 | 00f82b8a | aurel32 | below_4g_mem_size = 0xe0000000;
|
740 | 00f82b8a | aurel32 | } else {
|
741 | 00f82b8a | aurel32 | below_4g_mem_size = ram_size; |
742 | 00f82b8a | aurel32 | } |
743 | 00f82b8a | aurel32 | |
744 | 80cabfad | bellard | linux_boot = (kernel_filename != NULL);
|
745 | 80cabfad | bellard | |
746 | 59b8ad81 | bellard | /* init CPUs */
|
747 | a049de61 | bellard | if (cpu_model == NULL) { |
748 | a049de61 | bellard | #ifdef TARGET_X86_64
|
749 | a049de61 | bellard | cpu_model = "qemu64";
|
750 | a049de61 | bellard | #else
|
751 | a049de61 | bellard | cpu_model = "qemu32";
|
752 | a049de61 | bellard | #endif
|
753 | a049de61 | bellard | } |
754 | a049de61 | bellard | |
755 | 59b8ad81 | bellard | for(i = 0; i < smp_cpus; i++) { |
756 | aaed909a | bellard | env = cpu_init(cpu_model); |
757 | aaed909a | bellard | if (!env) {
|
758 | aaed909a | bellard | fprintf(stderr, "Unable to find x86 CPU definition\n");
|
759 | aaed909a | bellard | exit(1);
|
760 | aaed909a | bellard | } |
761 | 59b8ad81 | bellard | if (i != 0) |
762 | ce5232c5 | bellard | env->halted = 1;
|
763 | 59b8ad81 | bellard | if (smp_cpus > 1) { |
764 | 59b8ad81 | bellard | /* XXX: enable it in all cases */
|
765 | 59b8ad81 | bellard | env->cpuid_features |= CPUID_APIC; |
766 | 59b8ad81 | bellard | } |
767 | 59b8ad81 | bellard | qemu_register_reset(main_cpu_reset, env); |
768 | 59b8ad81 | bellard | if (pci_enabled) {
|
769 | 59b8ad81 | bellard | apic_init(env); |
770 | 59b8ad81 | bellard | } |
771 | 59b8ad81 | bellard | } |
772 | 59b8ad81 | bellard | |
773 | 26fb5e48 | aurel32 | vmport_init(); |
774 | 26fb5e48 | aurel32 | |
775 | 80cabfad | bellard | /* allocate RAM */
|
776 | 970ac5a3 | bellard | ram_addr = qemu_ram_alloc(ram_size); |
777 | 00f82b8a | aurel32 | cpu_register_physical_memory(0, below_4g_mem_size, ram_addr);
|
778 | 00f82b8a | aurel32 | |
779 | 00f82b8a | aurel32 | /* above 4giga memory allocation */
|
780 | 00f82b8a | aurel32 | if (above_4g_mem_size > 0) { |
781 | 00f82b8a | aurel32 | cpu_register_physical_memory(0x100000000ULL, above_4g_mem_size,
|
782 | 00f82b8a | aurel32 | ram_addr + below_4g_mem_size); |
783 | 00f82b8a | aurel32 | } |
784 | 80cabfad | bellard | |
785 | 970ac5a3 | bellard | /* allocate VGA RAM */
|
786 | 970ac5a3 | bellard | vga_ram_addr = qemu_ram_alloc(vga_ram_size); |
787 | 7587cf44 | bellard | |
788 | 970ac5a3 | bellard | /* BIOS load */
|
789 | 1192dad8 | j_mayer | if (bios_name == NULL) |
790 | 1192dad8 | j_mayer | bios_name = BIOS_FILENAME; |
791 | 1192dad8 | j_mayer | snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); |
792 | 7587cf44 | bellard | bios_size = get_image_size(buf); |
793 | 5fafdf24 | ths | if (bios_size <= 0 || |
794 | 970ac5a3 | bellard | (bios_size % 65536) != 0) { |
795 | 7587cf44 | bellard | goto bios_error;
|
796 | 7587cf44 | bellard | } |
797 | 970ac5a3 | bellard | bios_offset = qemu_ram_alloc(bios_size); |
798 | 7587cf44 | bellard | ret = load_image(buf, phys_ram_base + bios_offset); |
799 | 7587cf44 | bellard | if (ret != bios_size) {
|
800 | 7587cf44 | bellard | bios_error:
|
801 | 970ac5a3 | bellard | fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", buf);
|
802 | 80cabfad | bellard | exit(1);
|
803 | 80cabfad | bellard | } |
804 | 7587cf44 | bellard | |
805 | 80cabfad | bellard | /* VGA BIOS load */
|
806 | de9258a8 | bellard | if (cirrus_vga_enabled) {
|
807 | de9258a8 | bellard | snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_CIRRUS_FILENAME); |
808 | de9258a8 | bellard | } else {
|
809 | de9258a8 | bellard | snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME); |
810 | de9258a8 | bellard | } |
811 | 970ac5a3 | bellard | vga_bios_size = get_image_size(buf); |
812 | 5fafdf24 | ths | if (vga_bios_size <= 0 || vga_bios_size > 65536) |
813 | 970ac5a3 | bellard | goto vga_bios_error;
|
814 | 970ac5a3 | bellard | vga_bios_offset = qemu_ram_alloc(65536);
|
815 | 970ac5a3 | bellard | |
816 | 7587cf44 | bellard | ret = load_image(buf, phys_ram_base + vga_bios_offset); |
817 | 970ac5a3 | bellard | if (ret != vga_bios_size) {
|
818 | 970ac5a3 | bellard | vga_bios_error:
|
819 | 970ac5a3 | bellard | fprintf(stderr, "qemu: could not load VGA BIOS '%s'\n", buf);
|
820 | 970ac5a3 | bellard | exit(1);
|
821 | 970ac5a3 | bellard | } |
822 | 970ac5a3 | bellard | |
823 | 80cabfad | bellard | /* setup basic memory access */
|
824 | 5fafdf24 | ths | cpu_register_physical_memory(0xc0000, 0x10000, |
825 | 7587cf44 | bellard | vga_bios_offset | IO_MEM_ROM); |
826 | 7587cf44 | bellard | |
827 | 7587cf44 | bellard | /* map the last 128KB of the BIOS in ISA space */
|
828 | 7587cf44 | bellard | isa_bios_size = bios_size; |
829 | 7587cf44 | bellard | if (isa_bios_size > (128 * 1024)) |
830 | 7587cf44 | bellard | isa_bios_size = 128 * 1024; |
831 | 5fafdf24 | ths | cpu_register_physical_memory(0xd0000, (192 * 1024) - isa_bios_size, |
832 | 7587cf44 | bellard | IO_MEM_UNASSIGNED); |
833 | 5fafdf24 | ths | cpu_register_physical_memory(0x100000 - isa_bios_size,
|
834 | 5fafdf24 | ths | isa_bios_size, |
835 | 7587cf44 | bellard | (bios_offset + bios_size - isa_bios_size) | IO_MEM_ROM); |
836 | 9ae02555 | ths | |
837 | 970ac5a3 | bellard | { |
838 | 970ac5a3 | bellard | ram_addr_t option_rom_offset; |
839 | 970ac5a3 | bellard | int size, offset;
|
840 | 970ac5a3 | bellard | |
841 | 970ac5a3 | bellard | offset = 0;
|
842 | 970ac5a3 | bellard | for (i = 0; i < nb_option_roms; i++) { |
843 | 970ac5a3 | bellard | size = get_image_size(option_rom[i]); |
844 | 970ac5a3 | bellard | if (size < 0) { |
845 | 5fafdf24 | ths | fprintf(stderr, "Could not load option rom '%s'\n",
|
846 | 970ac5a3 | bellard | option_rom[i]); |
847 | 970ac5a3 | bellard | exit(1);
|
848 | 970ac5a3 | bellard | } |
849 | 970ac5a3 | bellard | if (size > (0x10000 - offset)) |
850 | 970ac5a3 | bellard | goto option_rom_error;
|
851 | 970ac5a3 | bellard | option_rom_offset = qemu_ram_alloc(size); |
852 | 970ac5a3 | bellard | ret = load_image(option_rom[i], phys_ram_base + option_rom_offset); |
853 | 970ac5a3 | bellard | if (ret != size) {
|
854 | 970ac5a3 | bellard | option_rom_error:
|
855 | 970ac5a3 | bellard | fprintf(stderr, "Too many option ROMS\n");
|
856 | 970ac5a3 | bellard | exit(1);
|
857 | 970ac5a3 | bellard | } |
858 | 970ac5a3 | bellard | size = (size + 4095) & ~4095; |
859 | 970ac5a3 | bellard | cpu_register_physical_memory(0xd0000 + offset,
|
860 | 970ac5a3 | bellard | size, option_rom_offset | IO_MEM_ROM); |
861 | 970ac5a3 | bellard | offset += size; |
862 | 970ac5a3 | bellard | } |
863 | 9ae02555 | ths | } |
864 | 9ae02555 | ths | |
865 | 7587cf44 | bellard | /* map all the bios at the top of memory */
|
866 | 5fafdf24 | ths | cpu_register_physical_memory((uint32_t)(-bios_size), |
867 | 7587cf44 | bellard | bios_size, bios_offset | IO_MEM_ROM); |
868 | 3b46e624 | ths | |
869 | 80cabfad | bellard | bochs_bios_init(); |
870 | 80cabfad | bellard | |
871 | 642a4f96 | ths | if (linux_boot)
|
872 | 642a4f96 | ths | load_linux(kernel_filename, initrd_filename, kernel_cmdline); |
873 | 80cabfad | bellard | |
874 | a5b38b51 | aurel32 | cpu_irq = qemu_allocate_irqs(pic_irq_request, NULL, 1); |
875 | d537cf6c | pbrook | i8259 = i8259_init(cpu_irq[0]);
|
876 | d537cf6c | pbrook | ferr_irq = i8259[13];
|
877 | d537cf6c | pbrook | |
878 | 69b91039 | bellard | if (pci_enabled) {
|
879 | d537cf6c | pbrook | pci_bus = i440fx_init(&i440fx_state, i8259); |
880 | 8f1c91d8 | ths | piix3_devfn = piix3_init(pci_bus, -1);
|
881 | 46e50e9d | bellard | } else {
|
882 | 46e50e9d | bellard | pci_bus = NULL;
|
883 | 69b91039 | bellard | } |
884 | 69b91039 | bellard | |
885 | 80cabfad | bellard | /* init basic PC hardware */
|
886 | b41a2cd1 | bellard | register_ioport_write(0x80, 1, 1, ioport80_write, NULL); |
887 | 80cabfad | bellard | |
888 | f929aad6 | bellard | register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL); |
889 | f929aad6 | bellard | |
890 | 1f04275e | bellard | if (cirrus_vga_enabled) {
|
891 | 1f04275e | bellard | if (pci_enabled) {
|
892 | 5fafdf24 | ths | pci_cirrus_vga_init(pci_bus, |
893 | 5fafdf24 | ths | ds, phys_ram_base + vga_ram_addr, |
894 | 970ac5a3 | bellard | vga_ram_addr, vga_ram_size); |
895 | 1f04275e | bellard | } else {
|
896 | 5fafdf24 | ths | isa_cirrus_vga_init(ds, phys_ram_base + vga_ram_addr, |
897 | 970ac5a3 | bellard | vga_ram_addr, vga_ram_size); |
898 | 1f04275e | bellard | } |
899 | d34cab9f | ths | } else if (vmsvga_enabled) { |
900 | d34cab9f | ths | if (pci_enabled)
|
901 | 45e4522e | balrog | pci_vmsvga_init(pci_bus, ds, phys_ram_base + vga_ram_addr, |
902 | 45e4522e | balrog | vga_ram_addr, vga_ram_size); |
903 | d34cab9f | ths | else
|
904 | d34cab9f | ths | fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__);
|
905 | 1f04275e | bellard | } else {
|
906 | 89b6b508 | bellard | if (pci_enabled) {
|
907 | 5fafdf24 | ths | pci_vga_init(pci_bus, ds, phys_ram_base + vga_ram_addr, |
908 | 970ac5a3 | bellard | vga_ram_addr, vga_ram_size, 0, 0); |
909 | 89b6b508 | bellard | } else {
|
910 | 5fafdf24 | ths | isa_vga_init(ds, phys_ram_base + vga_ram_addr, |
911 | 970ac5a3 | bellard | vga_ram_addr, vga_ram_size); |
912 | 89b6b508 | bellard | } |
913 | 1f04275e | bellard | } |
914 | 80cabfad | bellard | |
915 | d537cf6c | pbrook | rtc_state = rtc_init(0x70, i8259[8]); |
916 | 80cabfad | bellard | |
917 | 3b4366de | blueswir1 | qemu_register_boot_set(pc_boot_set, rtc_state); |
918 | 3b4366de | blueswir1 | |
919 | e1a23744 | bellard | register_ioport_read(0x92, 1, 1, ioport92_read, NULL); |
920 | e1a23744 | bellard | register_ioport_write(0x92, 1, 1, ioport92_write, NULL); |
921 | e1a23744 | bellard | |
922 | d592d303 | bellard | if (pci_enabled) {
|
923 | d592d303 | bellard | ioapic = ioapic_init(); |
924 | d592d303 | bellard | } |
925 | d537cf6c | pbrook | pit = pit_init(0x40, i8259[0]); |
926 | fd06c375 | bellard | pcspk_init(pit); |
927 | d592d303 | bellard | if (pci_enabled) {
|
928 | d592d303 | bellard | pic_set_alt_irq_func(isa_pic, ioapic_set_irq, ioapic); |
929 | d592d303 | bellard | } |
930 | b41a2cd1 | bellard | |
931 | 8d11df9e | bellard | for(i = 0; i < MAX_SERIAL_PORTS; i++) { |
932 | 8d11df9e | bellard | if (serial_hds[i]) {
|
933 | b6cd0ea1 | aurel32 | serial_init(serial_io[i], i8259[serial_irq[i]], 115200,
|
934 | b6cd0ea1 | aurel32 | serial_hds[i]); |
935 | 8d11df9e | bellard | } |
936 | 8d11df9e | bellard | } |
937 | b41a2cd1 | bellard | |
938 | 6508fe59 | bellard | for(i = 0; i < MAX_PARALLEL_PORTS; i++) { |
939 | 6508fe59 | bellard | if (parallel_hds[i]) {
|
940 | d537cf6c | pbrook | parallel_init(parallel_io[i], i8259[parallel_irq[i]], |
941 | d537cf6c | pbrook | parallel_hds[i]); |
942 | 6508fe59 | bellard | } |
943 | 6508fe59 | bellard | } |
944 | 6508fe59 | bellard | |
945 | a41b2ff2 | pbrook | for(i = 0; i < nb_nics; i++) { |
946 | a41b2ff2 | pbrook | nd = &nd_table[i]; |
947 | a41b2ff2 | pbrook | if (!nd->model) {
|
948 | a41b2ff2 | pbrook | if (pci_enabled) {
|
949 | a41b2ff2 | pbrook | nd->model = "ne2k_pci";
|
950 | a41b2ff2 | pbrook | } else {
|
951 | a41b2ff2 | pbrook | nd->model = "ne2k_isa";
|
952 | a41b2ff2 | pbrook | } |
953 | 69b91039 | bellard | } |
954 | a41b2ff2 | pbrook | if (strcmp(nd->model, "ne2k_isa") == 0) { |
955 | d537cf6c | pbrook | pc_init_ne2k_isa(nd, i8259); |
956 | a41b2ff2 | pbrook | } else if (pci_enabled) { |
957 | c4a7060c | blueswir1 | if (strcmp(nd->model, "?") == 0) |
958 | c4a7060c | blueswir1 | fprintf(stderr, "qemu: Supported ISA NICs: ne2k_isa\n");
|
959 | abcebc7e | ths | pci_nic_init(pci_bus, nd, -1);
|
960 | c4a7060c | blueswir1 | } else if (strcmp(nd->model, "?") == 0) { |
961 | c4a7060c | blueswir1 | fprintf(stderr, "qemu: Supported ISA NICs: ne2k_isa\n");
|
962 | c4a7060c | blueswir1 | exit(1);
|
963 | a41b2ff2 | pbrook | } else {
|
964 | a41b2ff2 | pbrook | fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model);
|
965 | a41b2ff2 | pbrook | exit(1);
|
966 | 69b91039 | bellard | } |
967 | a41b2ff2 | pbrook | } |
968 | b41a2cd1 | bellard | |
969 | e4bcb14c | ths | if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
|
970 | e4bcb14c | ths | fprintf(stderr, "qemu: too many IDE bus\n");
|
971 | e4bcb14c | ths | exit(1);
|
972 | e4bcb14c | ths | } |
973 | e4bcb14c | ths | |
974 | e4bcb14c | ths | for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { |
975 | e4bcb14c | ths | index = drive_get_index(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); |
976 | e4bcb14c | ths | if (index != -1) |
977 | e4bcb14c | ths | hd[i] = drives_table[index].bdrv; |
978 | e4bcb14c | ths | else
|
979 | e4bcb14c | ths | hd[i] = NULL;
|
980 | e4bcb14c | ths | } |
981 | e4bcb14c | ths | |
982 | a41b2ff2 | pbrook | if (pci_enabled) {
|
983 | e4bcb14c | ths | pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1, i8259);
|
984 | a41b2ff2 | pbrook | } else {
|
985 | e4bcb14c | ths | for(i = 0; i < MAX_IDE_BUS; i++) { |
986 | d537cf6c | pbrook | isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]], |
987 | e4bcb14c | ths | hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
|
988 | 69b91039 | bellard | } |
989 | b41a2cd1 | bellard | } |
990 | 69b91039 | bellard | |
991 | d537cf6c | pbrook | i8042_init(i8259[1], i8259[12], 0x60); |
992 | 7c29d0c0 | bellard | DMA_init(0);
|
993 | 6a36d84e | bellard | #ifdef HAS_AUDIO
|
994 | d537cf6c | pbrook | audio_init(pci_enabled ? pci_bus : NULL, i8259);
|
995 | fb065187 | bellard | #endif
|
996 | 80cabfad | bellard | |
997 | e4bcb14c | ths | for(i = 0; i < MAX_FD; i++) { |
998 | e4bcb14c | ths | index = drive_get_index(IF_FLOPPY, 0, i);
|
999 | e4bcb14c | ths | if (index != -1) |
1000 | e4bcb14c | ths | fd[i] = drives_table[index].bdrv; |
1001 | e4bcb14c | ths | else
|
1002 | e4bcb14c | ths | fd[i] = NULL;
|
1003 | e4bcb14c | ths | } |
1004 | e4bcb14c | ths | floppy_controller = fdctrl_init(i8259[6], 2, 0, 0x3f0, fd); |
1005 | b41a2cd1 | bellard | |
1006 | 00f82b8a | aurel32 | cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device, hd); |
1007 | 69b91039 | bellard | |
1008 | bb36d470 | bellard | if (pci_enabled && usb_enabled) {
|
1009 | afcc3cdf | ths | usb_uhci_piix3_init(pci_bus, piix3_devfn + 2);
|
1010 | bb36d470 | bellard | } |
1011 | bb36d470 | bellard | |
1012 | 6515b203 | bellard | if (pci_enabled && acpi_enabled) {
|
1013 | 3fffc223 | ths | uint8_t *eeprom_buf = qemu_mallocz(8 * 256); /* XXX: make this persistent */ |
1014 | 0ff596d0 | pbrook | i2c_bus *smbus; |
1015 | 0ff596d0 | pbrook | |
1016 | 0ff596d0 | pbrook | /* TODO: Populate SPD eeprom data. */
|
1017 | cf7a2fe2 | aurel32 | smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100, i8259[9]); |
1018 | 3fffc223 | ths | for (i = 0; i < 8; i++) { |
1019 | 0ff596d0 | pbrook | smbus_eeprom_device_init(smbus, 0x50 + i, eeprom_buf + (i * 256)); |
1020 | 3fffc223 | ths | } |
1021 | 6515b203 | bellard | } |
1022 | 3b46e624 | ths | |
1023 | a5954d5c | bellard | if (i440fx_state) {
|
1024 | a5954d5c | bellard | i440fx_init_memory_mappings(i440fx_state); |
1025 | a5954d5c | bellard | } |
1026 | e4bcb14c | ths | |
1027 | 7d8406be | pbrook | if (pci_enabled) {
|
1028 | e4bcb14c | ths | int max_bus;
|
1029 | e4bcb14c | ths | int bus, unit;
|
1030 | 7d8406be | pbrook | void *scsi;
|
1031 | 96d30e48 | ths | |
1032 | e4bcb14c | ths | max_bus = drive_get_max_bus(IF_SCSI); |
1033 | e4bcb14c | ths | |
1034 | e4bcb14c | ths | for (bus = 0; bus <= max_bus; bus++) { |
1035 | e4bcb14c | ths | scsi = lsi_scsi_init(pci_bus, -1);
|
1036 | e4bcb14c | ths | for (unit = 0; unit < LSI_MAX_DEVS; unit++) { |
1037 | e4bcb14c | ths | index = drive_get_index(IF_SCSI, bus, unit); |
1038 | e4bcb14c | ths | if (index == -1) |
1039 | e4bcb14c | ths | continue;
|
1040 | e4bcb14c | ths | lsi_scsi_attach(scsi, drives_table[index].bdrv, unit); |
1041 | e4bcb14c | ths | } |
1042 | e4bcb14c | ths | } |
1043 | 7d8406be | pbrook | } |
1044 | 80cabfad | bellard | } |
1045 | b5ff2d6e | bellard | |
1046 | 00f82b8a | aurel32 | static void pc_init_pci(ram_addr_t ram_size, int vga_ram_size, |
1047 | b881c2c6 | blueswir1 | const char *boot_device, DisplayState *ds, |
1048 | 5fafdf24 | ths | const char *kernel_filename, |
1049 | 3dbbdc25 | bellard | const char *kernel_cmdline, |
1050 | 94fc95cd | j_mayer | const char *initrd_filename, |
1051 | 94fc95cd | j_mayer | const char *cpu_model) |
1052 | 3dbbdc25 | bellard | { |
1053 | b881c2c6 | blueswir1 | pc_init1(ram_size, vga_ram_size, boot_device, ds, |
1054 | 3dbbdc25 | bellard | kernel_filename, kernel_cmdline, |
1055 | a049de61 | bellard | initrd_filename, 1, cpu_model);
|
1056 | 3dbbdc25 | bellard | } |
1057 | 3dbbdc25 | bellard | |
1058 | 00f82b8a | aurel32 | static void pc_init_isa(ram_addr_t ram_size, int vga_ram_size, |
1059 | b881c2c6 | blueswir1 | const char *boot_device, DisplayState *ds, |
1060 | 5fafdf24 | ths | const char *kernel_filename, |
1061 | 3dbbdc25 | bellard | const char *kernel_cmdline, |
1062 | 94fc95cd | j_mayer | const char *initrd_filename, |
1063 | 94fc95cd | j_mayer | const char *cpu_model) |
1064 | 3dbbdc25 | bellard | { |
1065 | b881c2c6 | blueswir1 | pc_init1(ram_size, vga_ram_size, boot_device, ds, |
1066 | 3dbbdc25 | bellard | kernel_filename, kernel_cmdline, |
1067 | a049de61 | bellard | initrd_filename, 0, cpu_model);
|
1068 | 3dbbdc25 | bellard | } |
1069 | 3dbbdc25 | bellard | |
1070 | b5ff2d6e | bellard | QEMUMachine pc_machine = { |
1071 | b5ff2d6e | bellard | "pc",
|
1072 | b5ff2d6e | bellard | "Standard PC",
|
1073 | 3dbbdc25 | bellard | pc_init_pci, |
1074 | 7fb4fdcf | balrog | VGA_RAM_SIZE + PC_MAX_BIOS_SIZE, |
1075 | 3dbbdc25 | bellard | }; |
1076 | 3dbbdc25 | bellard | |
1077 | 3dbbdc25 | bellard | QEMUMachine isapc_machine = { |
1078 | 3dbbdc25 | bellard | "isapc",
|
1079 | 3dbbdc25 | bellard | "ISA-only PC",
|
1080 | 3dbbdc25 | bellard | pc_init_isa, |
1081 | 7fb4fdcf | balrog | VGA_RAM_SIZE + PC_MAX_BIOS_SIZE, |
1082 | b5ff2d6e | bellard | }; |