Revision 5fafdf24 hw/pc.c
b/hw/pc.c | ||
---|---|---|
1 | 1 |
/* |
2 | 2 |
* QEMU PC System Emulator |
3 |
*
|
|
3 |
* |
|
4 | 4 |
* Copyright (c) 2003-2004 Fabrice Bellard |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | 7 |
* of this software and associated documentation files (the "Software"), to deal |
8 | 8 |
* in the Software without restriction, including without limitation the rights |
... | ... | |
65 | 65 |
#if USE_KQEMU |
66 | 66 |
if (env->kqemu_enabled) { |
67 | 67 |
return cpu_get_real_ticks(); |
68 |
} else
|
|
68 |
} else |
|
69 | 69 |
#endif |
70 | 70 |
{ |
71 | 71 |
return cpu_get_ticks(); |
... | ... | |
89 | 89 |
if (intno >= 0) { |
90 | 90 |
/* set irq request if a PIC irq is still pending */ |
91 | 91 |
/* XXX: improve that */ |
92 |
pic_update_irq(isa_pic);
|
|
92 |
pic_update_irq(isa_pic); |
|
93 | 93 |
return intno; |
94 | 94 |
} |
95 | 95 |
/* read the irq from the PIC */ |
... | ... | |
134 | 134 |
return val; |
135 | 135 |
} |
136 | 136 |
|
137 |
static void cmos_init_hd(int type_ofs, int info_ofs, BlockDriverState *hd)
|
|
137 |
static void cmos_init_hd(int type_ofs, int info_ofs, BlockDriverState *hd) |
|
138 | 138 |
{ |
139 | 139 |
RTCState *s = rtc_state; |
140 | 140 |
int cylinders, heads, sectors; |
... | ... | |
182 | 182 |
val = 65535; |
183 | 183 |
rtc_set_memory(s, 0x34, val); |
184 | 184 |
rtc_set_memory(s, 0x35, val >> 8); |
185 |
|
|
185 |
|
|
186 | 186 |
switch(boot_device) { |
187 | 187 |
case 'a': |
188 | 188 |
case 'b': |
... | ... | |
199 | 199 |
break; |
200 | 200 |
case 'n': |
201 | 201 |
rtc_set_memory(s, 0x3d, 0x04); /* Network boot */ |
202 |
break;
|
|
202 |
break; |
|
203 | 203 |
} |
204 | 204 |
|
205 | 205 |
/* floppy type */ |
... | ... | |
209 | 209 |
|
210 | 210 |
val = (cmos_get_fd_drive_type(fd0) << 4) | cmos_get_fd_drive_type(fd1); |
211 | 211 |
rtc_set_memory(s, 0x10, val); |
212 |
|
|
212 |
|
|
213 | 213 |
val = 0; |
214 | 214 |
nb = 0; |
215 | 215 |
if (fd0 < 3) |
... | ... | |
235 | 235 |
rtc_set_memory(s, 0x12, (hd_table[0] ? 0xf0 : 0) | (hd_table[1] ? 0x0f : 0)); |
236 | 236 |
if (hd_table[0]) |
237 | 237 |
cmos_init_hd(0x19, 0x1b, hd_table[0]); |
238 |
if (hd_table[1])
|
|
238 |
if (hd_table[1]) |
|
239 | 239 |
cmos_init_hd(0x1a, 0x24, hd_table[1]); |
240 | 240 |
|
241 | 241 |
val = 0; |
... | ... | |
294 | 294 |
{ |
295 | 295 |
static const char shutdown_str[8] = "Shutdown"; |
296 | 296 |
static int shutdown_index = 0; |
297 |
|
|
297 |
|
|
298 | 298 |
switch(addr) { |
299 | 299 |
/* Bochs BIOS messages */ |
300 | 300 |
case 0x400: |
... | ... | |
404 | 404 |
bdrv_set_boot_sector(bs_table[0], bootsect, sizeof(bootsect)); |
405 | 405 |
} |
406 | 406 |
|
407 |
int load_kernel(const char *filename, uint8_t *addr,
|
|
407 |
int load_kernel(const char *filename, uint8_t *addr, |
|
408 | 408 |
uint8_t *real_addr) |
409 | 409 |
{ |
410 | 410 |
int fd, size; |
... | ... | |
420 | 420 |
setup_sects = real_addr[0x1F1]; |
421 | 421 |
if (!setup_sects) |
422 | 422 |
setup_sects = 4; |
423 |
if (read(fd, real_addr + 512, setup_sects * 512) !=
|
|
423 |
if (read(fd, real_addr + 512, setup_sects * 512) != |
|
424 | 424 |
setup_sects * 512) |
425 | 425 |
goto fail; |
426 | 426 |
|
... | ... | |
708 | 708 |
/* BIOS load */ |
709 | 709 |
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME); |
710 | 710 |
bios_size = get_image_size(buf); |
711 |
if (bios_size <= 0 ||
|
|
711 |
if (bios_size <= 0 || |
|
712 | 712 |
(bios_size % 65536) != 0) { |
713 | 713 |
goto bios_error; |
714 | 714 |
} |
... | ... | |
727 | 727 |
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME); |
728 | 728 |
} |
729 | 729 |
vga_bios_size = get_image_size(buf); |
730 |
if (vga_bios_size <= 0 || vga_bios_size > 65536)
|
|
730 |
if (vga_bios_size <= 0 || vga_bios_size > 65536) |
|
731 | 731 |
goto vga_bios_error; |
732 | 732 |
vga_bios_offset = qemu_ram_alloc(65536); |
733 | 733 |
|
... | ... | |
739 | 739 |
} |
740 | 740 |
|
741 | 741 |
/* setup basic memory access */ |
742 |
cpu_register_physical_memory(0xc0000, 0x10000,
|
|
742 |
cpu_register_physical_memory(0xc0000, 0x10000, |
|
743 | 743 |
vga_bios_offset | IO_MEM_ROM); |
744 | 744 |
|
745 | 745 |
/* map the last 128KB of the BIOS in ISA space */ |
746 | 746 |
isa_bios_size = bios_size; |
747 | 747 |
if (isa_bios_size > (128 * 1024)) |
748 | 748 |
isa_bios_size = 128 * 1024; |
749 |
cpu_register_physical_memory(0xd0000, (192 * 1024) - isa_bios_size,
|
|
749 |
cpu_register_physical_memory(0xd0000, (192 * 1024) - isa_bios_size, |
|
750 | 750 |
IO_MEM_UNASSIGNED); |
751 |
cpu_register_physical_memory(0x100000 - isa_bios_size,
|
|
752 |
isa_bios_size,
|
|
751 |
cpu_register_physical_memory(0x100000 - isa_bios_size, |
|
752 |
isa_bios_size, |
|
753 | 753 |
(bios_offset + bios_size - isa_bios_size) | IO_MEM_ROM); |
754 | 754 |
|
755 | 755 |
{ |
... | ... | |
760 | 760 |
for (i = 0; i < nb_option_roms; i++) { |
761 | 761 |
size = get_image_size(option_rom[i]); |
762 | 762 |
if (size < 0) { |
763 |
fprintf(stderr, "Could not load option rom '%s'\n",
|
|
763 |
fprintf(stderr, "Could not load option rom '%s'\n", |
|
764 | 764 |
option_rom[i]); |
765 | 765 |
exit(1); |
766 | 766 |
} |
... | ... | |
781 | 781 |
} |
782 | 782 |
|
783 | 783 |
/* map all the bios at the top of memory */ |
784 |
cpu_register_physical_memory((uint32_t)(-bios_size),
|
|
784 |
cpu_register_physical_memory((uint32_t)(-bios_size), |
|
785 | 785 |
bios_size, bios_offset | IO_MEM_ROM); |
786 |
|
|
786 |
|
|
787 | 787 |
bochs_bios_init(); |
788 | 788 |
|
789 | 789 |
if (linux_boot) |
... | ... | |
807 | 807 |
|
808 | 808 |
if (cirrus_vga_enabled) { |
809 | 809 |
if (pci_enabled) { |
810 |
pci_cirrus_vga_init(pci_bus,
|
|
811 |
ds, phys_ram_base + vga_ram_addr,
|
|
810 |
pci_cirrus_vga_init(pci_bus, |
|
811 |
ds, phys_ram_base + vga_ram_addr, |
|
812 | 812 |
vga_ram_addr, vga_ram_size); |
813 | 813 |
} else { |
814 |
isa_cirrus_vga_init(ds, phys_ram_base + vga_ram_addr,
|
|
814 |
isa_cirrus_vga_init(ds, phys_ram_base + vga_ram_addr, |
|
815 | 815 |
vga_ram_addr, vga_ram_size); |
816 | 816 |
} |
817 | 817 |
} else if (vmsvga_enabled) { |
... | ... | |
822 | 822 |
fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__); |
823 | 823 |
} else { |
824 | 824 |
if (pci_enabled) { |
825 |
pci_vga_init(pci_bus, ds, phys_ram_base + vga_ram_addr,
|
|
825 |
pci_vga_init(pci_bus, ds, phys_ram_base + vga_ram_addr, |
|
826 | 826 |
vga_ram_addr, vga_ram_size, 0, 0); |
827 | 827 |
} else { |
828 |
isa_vga_init(ds, phys_ram_base + vga_ram_addr,
|
|
828 |
isa_vga_init(ds, phys_ram_base + vga_ram_addr, |
|
829 | 829 |
vga_ram_addr, vga_ram_size); |
830 | 830 |
} |
831 | 831 |
} |
... | ... | |
914 | 914 |
smbus_eeprom_device_init(smbus, 0x50 + i, eeprom_buf + (i * 256)); |
915 | 915 |
} |
916 | 916 |
} |
917 |
|
|
917 |
|
|
918 | 918 |
if (i440fx_state) { |
919 | 919 |
i440fx_init_memory_mappings(i440fx_state); |
920 | 920 |
} |
... | ... | |
938 | 938 |
} |
939 | 939 |
|
940 | 940 |
static void pc_init_pci(int ram_size, int vga_ram_size, int boot_device, |
941 |
DisplayState *ds, const char **fd_filename,
|
|
942 |
int snapshot,
|
|
943 |
const char *kernel_filename,
|
|
941 |
DisplayState *ds, const char **fd_filename, |
|
942 |
int snapshot, |
|
943 |
const char *kernel_filename, |
|
944 | 944 |
const char *kernel_cmdline, |
945 | 945 |
const char *initrd_filename, |
946 | 946 |
const char *cpu_model) |
... | ... | |
952 | 952 |
} |
953 | 953 |
|
954 | 954 |
static void pc_init_isa(int ram_size, int vga_ram_size, int boot_device, |
955 |
DisplayState *ds, const char **fd_filename,
|
|
956 |
int snapshot,
|
|
957 |
const char *kernel_filename,
|
|
955 |
DisplayState *ds, const char **fd_filename, |
|
956 |
int snapshot, |
|
957 |
const char *kernel_filename, |
|
958 | 958 |
const char *kernel_cmdline, |
959 | 959 |
const char *initrd_filename, |
960 | 960 |
const char *cpu_model) |
Also available in: Unified diff