static fdctrl_t *floppy_controller;
static RTCState *rtc_state;
static PITState *pit;
+static IOAPICState *ioapic;
static void ioport80_write(void *opaque, uint32_t addr, uint32_t data)
{
return qemu_get_clock(vm_clock);
}
+/* IRQ handling */
+int cpu_get_pic_interrupt(CPUState *env)
+{
+ int intno;
+
+ intno = apic_get_interrupt(env);
+ if (intno >= 0) {
+ /* set irq request if a PIC irq is still pending */
+ /* XXX: improve that */
+ pic_update_irq(isa_pic);
+ return intno;
+ }
+ /* read the irq from the PIC */
+ intno = pic_read_irq(isa_pic);
+ return intno;
+}
+
+static void pic_irq_request(void *opaque, int level)
+{
+ if (level)
+ cpu_interrupt(cpu_single_env, CPU_INTERRUPT_HARD);
+ else
+ cpu_reset_interrupt(cpu_single_env, CPU_INTERRUPT_HARD);
+}
+
/* PC cmos mappings */
#define REG_EQUIPMENT_BYTE 0x14
val = 0;
for (i = 0; i < 4; i++) {
if (hd_table[i]) {
- int cylinders, heads, sectors;
- uint8_t translation;
- /* NOTE: bdrv_get_geometry_hint() returns the geometry
- that the hard disk returns. It is always such that: 1 <=
- sects <= 63, 1 <= heads <= 16, 1 <= cylinders <=
- 16383. The BIOS geometry can be different. */
- bdrv_get_geometry_hint(hd_table[i], &cylinders, &heads, §ors);
- if (cylinders <= 1024 && heads <= 16 && sectors <= 63) {
- /* No translation. */
- translation = 0;
+ int cylinders, heads, sectors, translation;
+ /* NOTE: bdrv_get_geometry_hint() returns the physical
+ geometry. It is always such that: 1 <= sects <= 63, 1
+ <= heads <= 16, 1 <= cylinders <= 16383. The BIOS
+ geometry can be different if a translation is done. */
+ translation = bdrv_get_translation_hint(hd_table[i]);
+ if (translation == BIOS_ATA_TRANSLATION_AUTO) {
+ bdrv_get_geometry_hint(hd_table[i], &cylinders, &heads, §ors);
+ if (cylinders <= 1024 && heads <= 16 && sectors <= 63) {
+ /* No translation. */
+ translation = 0;
+ } else {
+ /* LBA translation. */
+ translation = 1;
+ }
} else {
- /* LBA translation. */
- translation = 1;
+ translation--;
}
val |= translation << (i * 2);
}
static int serial_io[MAX_SERIAL_PORTS] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
static int serial_irq[MAX_SERIAL_PORTS] = { 4, 3, 4, 3 };
+static int parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc };
+static int parallel_irq[MAX_PARALLEL_PORTS] = { 7, 7, 7 };
+
/* PC hardware initialisation */
-void pc_init(int ram_size, int vga_ram_size, int boot_device,
- DisplayState *ds, const char **fd_filename, int snapshot,
- const char *kernel_filename, const char *kernel_cmdline,
- const char *initrd_filename)
+static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
+ DisplayState *ds, const char **fd_filename, int snapshot,
+ const char *kernel_filename, const char *kernel_cmdline,
+ const char *initrd_filename)
{
char buf[1024];
int ret, linux_boot, initrd_size, i, nb_nics1;
unsigned long bios_offset, vga_bios_offset;
int bios_size, isa_bios_size;
PCIBus *pci_bus;
-
+
linux_boot = (kernel_filename != NULL);
/* allocate RAM */
}
} else {
vga_initialize(pci_bus, ds, phys_ram_base + ram_size, ram_size,
- vga_ram_size);
+ vga_ram_size, 0, 0);
}
rtc_state = rtc_init(0x70, 8);
register_ioport_read(0x92, 1, 1, ioport92_read, NULL);
register_ioport_write(0x92, 1, 1, ioport92_write, NULL);
- pic_init();
+ if (pci_enabled) {
+ apic_init(cpu_single_env);
+ ioapic = ioapic_init();
+ }
+ isa_pic = pic_init(pic_irq_request, cpu_single_env);
pit = pit_init(0x40, 0);
+ if (pci_enabled) {
+ pic_set_alt_irq_func(isa_pic, ioapic_set_irq, ioapic);
+ }
for(i = 0; i < MAX_SERIAL_PORTS; i++) {
if (serial_hds[i]) {
}
}
+ for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
+ if (parallel_hds[i]) {
+ parallel_init(parallel_io[i], parallel_irq[i], parallel_hds[i]);
+ }
+ }
+
if (pci_enabled) {
for(i = 0; i < nb_nics; i++) {
pci_ne2000_init(pci_bus, &nd_table[i]);
kbd_init();
DMA_init(0);
-#ifndef _WIN32
if (audio_enabled) {
- /* no audio supported yet for win32 */
AUD_init();
- SB16_init();
- }
+#ifdef USE_SB16
+ if (sb16_enabled)
+ SB16_init ();
+#endif
+#ifdef CONFIG_ADLIB
+ if (adlib_enabled)
+ Adlib_init ();
+#endif
+#ifdef USE_GUS
+ if (gus_enabled)
+ GUS_init ();
#endif
+ }
floppy_controller = fdctrl_init(6, 2, 0, 0x3f0, fd_table);
pci_bios_init();
}
}
+
+QEMUMachine pc_machine = {
+ "pc",
+ "Standard PC",
+ pc_init1,
+};