* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <getopt.h>
-#include <inttypes.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <time.h>
-#include <sys/time.h>
-#include <malloc.h>
-#include <termios.h>
-#include <sys/poll.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include <netinet/in.h>
-
-#include "cpu.h"
#include "vl.h"
/* output Bochs bios info messages */
int dummy_refresh_clock;
static fdctrl_t *floppy_controller;
static RTCState *rtc_state;
+static PITState *pit;
static void ioport80_write(void *opaque, uint32_t addr, uint32_t data)
{
}
+/* MSDOS compatibility mode FPU exception support */
+/* XXX: add IGNNE support */
+void cpu_set_ferr(CPUX86State *s)
+{
+ pic_set_irq(13, 1);
+}
+
+static void ioportF0_write(void *opaque, uint32_t addr, uint32_t data)
+{
+ pic_set_irq(13, 0);
+}
+
/* PC cmos mappings */
#define REG_EQUIPMENT_BYTE 0x14
/* various important CMOS locations needed by PC/Bochs bios */
/* memory size */
+ val = 640; /* base memory in K */
+ rtc_set_memory(s, 0x15, val);
+ rtc_set_memory(s, 0x16, val >> 8);
+
val = (ram_size / 1024) - 1024;
if (val > 65535)
val = 65535;
static void speaker_ioport_write(void *opaque, uint32_t addr, uint32_t val)
{
speaker_data_on = (val >> 1) & 1;
- pit_set_gate(&pit_channels[2], val & 1);
+ pit_set_gate(pit, 2, val & 1);
}
static uint32_t speaker_ioport_read(void *opaque, uint32_t addr)
{
int out;
- out = pit_get_out(&pit_channels[2], qemu_get_clock(vm_clock));
+ out = pit_get_out(pit, 2, qemu_get_clock(vm_clock));
dummy_refresh_clock ^= 1;
- return (speaker_data_on << 1) | pit_channels[2].gate | (out << 5) |
+ return (speaker_data_on << 1) | pit_get_gate(pit, 2) | (out << 5) |
(dummy_refresh_clock << 4);
}
+static void ioport92_write(void *opaque, uint32_t addr, uint32_t val)
+{
+ cpu_x86_set_a20(cpu_single_env, (val >> 1) & 1);
+ /* XXX: bit 0 is fast reset */
+}
+
+static uint32_t ioport92_read(void *opaque, uint32_t addr)
+{
+ return ((cpu_single_env->a20_mask >> 20) & 1) << 1;
+}
+
/***********************************************************/
/* Bochs BIOS debug ports */
/* setup basic memory access */
cpu_register_physical_memory(0xc0000, 0x10000, 0xc0000 | IO_MEM_ROM);
+ cpu_register_physical_memory(0xd0000, 0x20000, IO_MEM_UNASSIGNED);
cpu_register_physical_memory(0xf0000, 0x10000, 0xf0000 | IO_MEM_ROM);
bochs_bios_init();
if (linux_boot) {
uint8_t bootsect[512];
+ uint8_t old_bootsect[512];
if (bs_table[0] == NULL) {
fprintf(stderr, "A disk image must be given for 'hda' when booting a Linux kernel\n");
exit(1);
}
+ if (bdrv_read(bs_table[0], 0, old_bootsect, 1) >= 0) {
+ /* copy the MSDOS partition table */
+ memcpy(bootsect + 0x1be, old_bootsect + 0x1be, 0x40);
+ }
+
bdrv_set_boot_sector(bs_table[0], bootsect, sizeof(bootsect));
/* now we can load the kernel */
stw_raw(phys_ram_base + KERNEL_PARAMS_ADDR + 0x210, 0x01);
}
+ if (pci_enabled) {
+ i440fx_init();
+ piix3_init();
+ }
+
/* init basic PC hardware */
register_ioport_write(0x80, 1, 1, ioport80_write, NULL);
+ register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);
+
vga_initialize(ds, phys_ram_base + ram_size, ram_size,
vga_ram_size);
register_ioport_read(0x61, 1, 1, speaker_ioport_read, NULL);
register_ioport_write(0x61, 1, 1, speaker_ioport_write, NULL);
+ register_ioport_read(0x92, 1, 1, ioport92_read, NULL);
+ register_ioport_write(0x92, 1, 1, ioport92_write, NULL);
+
pic_init();
- pit_init(0x40, 0);
+ pit = pit_init(0x40, 0);
fd = serial_open_device();
serial_init(0x3f8, 4, fd);
- nb_nics1 = nb_nics;
- if (nb_nics1 > NE2000_NB_MAX)
- nb_nics1 = NE2000_NB_MAX;
- for(i = 0; i < nb_nics1; i++) {
- ne2000_init(ne2000_io[i], ne2000_irq[i], &nd_table[i]);
- }
+ if (pci_enabled) {
+ for(i = 0; i < nb_nics; i++) {
+ pci_ne2000_init(&nd_table[i]);
+ }
+ pci_ide_init(bs_table);
+ } else {
+ nb_nics1 = nb_nics;
+ if (nb_nics1 > NE2000_NB_MAX)
+ nb_nics1 = NE2000_NB_MAX;
+ for(i = 0; i < nb_nics1; i++) {
+ isa_ne2000_init(ne2000_io[i], ne2000_irq[i], &nd_table[i]);
+ }
- for(i = 0; i < 2; i++) {
- ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
- bs_table[2 * i], bs_table[2 * i + 1]);
+ for(i = 0; i < 2; i++) {
+ isa_ide_init(ide_iobase[i], ide_iobase2[i], ide_irq[i],
+ bs_table[2 * i], bs_table[2 * i + 1]);
+ }
}
+
kbd_init();
- AUD_init();
DMA_init();
- SB16_init();
+
+#ifndef _WIN32
+ if (audio_enabled) {
+ /* no audio supported yet for win32 */
+ AUD_init();
+ SB16_init();
+ }
+#endif
floppy_controller = fdctrl_init(6, 2, 0, 0x3f0, fd_table);
cmos_init(ram_size, boot_device);
+
+ /* must be done after all PCI devices are instanciated */
+ /* XXX: should be done in the Bochs BIOS */
+ if (pci_enabled) {
+ pci_bios_init();
+ }
}