2017-09-02 20:39:57 +02:00
|
|
|
/*
|
|
|
|
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
|
|
|
|
* running old operating systems and software designed for IBM
|
|
|
|
|
* PC systems and compatibles from 1981 through fairly recent
|
|
|
|
|
* system designs based on the PCI bus.
|
|
|
|
|
*
|
|
|
|
|
* This file is part of the 86Box distribution.
|
|
|
|
|
*
|
|
|
|
|
* Handling of the emulated machines.
|
|
|
|
|
*
|
2018-10-22 04:22:00 +02:00
|
|
|
* Version: @(#)machine.c 1.0.35 2018/10/22
|
2017-09-02 20:39:57 +02:00
|
|
|
*
|
|
|
|
|
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
|
|
|
|
* Miran Grca, <mgrca8@gmail.com>
|
2017-10-07 22:18:30 -04:00
|
|
|
* Fred N. van Kempen, <decwiz@yahoo.com>
|
|
|
|
|
*
|
2018-01-01 02:57:39 +01:00
|
|
|
* Copyright 2008-2018 Sarah Walker.
|
2018-01-13 22:56:13 +01:00
|
|
|
* Copyright 2016-2018 Miran Grca.
|
2018-01-17 18:43:36 +01:00
|
|
|
* Copyright 2017,2018 Fred N. van Kempen.
|
2017-09-02 20:39:57 +02:00
|
|
|
*/
|
2018-05-21 19:04:05 +02:00
|
|
|
#include <stdarg.h>
|
2017-09-25 04:31:20 -04:00
|
|
|
#include <stdint.h>
|
2018-05-21 19:04:05 +02:00
|
|
|
#include <stdio.h>
|
2017-09-25 04:31:20 -04:00
|
|
|
#include <string.h>
|
|
|
|
|
#include <wchar.h>
|
2018-05-21 19:04:05 +02:00
|
|
|
#define HAVE_STDARG_H
|
2017-10-17 01:59:09 -04:00
|
|
|
#include "../86box.h"
|
2018-01-01 02:57:39 +01:00
|
|
|
#include "../device.h"
|
2017-11-08 16:27:10 -05:00
|
|
|
#include "../dma.h"
|
|
|
|
|
#include "../pic.h"
|
|
|
|
|
#include "../pit.h"
|
2017-09-25 04:31:20 -04:00
|
|
|
#include "../mem.h"
|
|
|
|
|
#include "../rom.h"
|
2017-11-08 16:27:10 -05:00
|
|
|
#include "../lpt.h"
|
|
|
|
|
#include "../serial.h"
|
2018-04-25 23:51:13 +02:00
|
|
|
#include "../cpu/cpu.h"
|
2018-09-19 20:13:32 +02:00
|
|
|
#include "../video/video.h"
|
2017-09-02 20:39:57 +02:00
|
|
|
#include "machine.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int machine;
|
2017-11-05 01:57:04 -05:00
|
|
|
int AT, PCI;
|
2017-09-02 20:39:57 +02:00
|
|
|
int romset;
|
|
|
|
|
|
|
|
|
|
|
2018-05-21 19:04:05 +02:00
|
|
|
#ifdef ENABLE_MACHINE_LOG
|
|
|
|
|
int machine_do_log = ENABLE_MACHINE_LOG;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
machine_log(const char *fmt, ...)
|
|
|
|
|
{
|
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
|
|
if (machine_do_log)
|
|
|
|
|
{
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
|
pclog_ex(fmt, ap);
|
|
|
|
|
va_end(ap);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-10-22 04:22:00 +02:00
|
|
|
#else
|
|
|
|
|
#define machine_log(fmt, ...)
|
|
|
|
|
#endif
|
2018-05-21 19:04:05 +02:00
|
|
|
|
|
|
|
|
|
2017-09-25 04:31:20 -04:00
|
|
|
void
|
|
|
|
|
machine_init(void)
|
2017-09-02 20:39:57 +02:00
|
|
|
{
|
2018-09-19 20:13:32 +02:00
|
|
|
int MCA;
|
2018-05-21 19:04:05 +02:00
|
|
|
machine_log("Initializing as \"%s\"\n", machine_getname());
|
2017-09-02 20:39:57 +02:00
|
|
|
|
2017-10-13 02:41:17 -04:00
|
|
|
/* Set up the architecture flags. */
|
|
|
|
|
AT = IS_ARCH(machine, MACHINE_AT);
|
|
|
|
|
PCI = IS_ARCH(machine, MACHINE_PCI);
|
2018-09-19 20:13:32 +02:00
|
|
|
MCA = IS_ARCH(machine, MACHINE_MCA);
|
2017-09-02 20:39:57 +02:00
|
|
|
|
2018-03-15 22:57:24 +01:00
|
|
|
/* Resize the memory. */
|
2018-03-19 08:01:13 +01:00
|
|
|
mem_reset();
|
2018-03-15 22:57:24 +01:00
|
|
|
|
2017-10-07 00:46:54 -04:00
|
|
|
/* Load the machine's ROM BIOS. */
|
|
|
|
|
rom_load_bios(romset);
|
|
|
|
|
mem_add_bios();
|
2017-09-25 04:31:20 -04:00
|
|
|
|
2018-09-19 20:13:32 +02:00
|
|
|
/* If it's not a PCI or MCA machine, reset the video card
|
|
|
|
|
before initializing the machine, to please the EuroPC. */
|
|
|
|
|
if (!PCI && !MCA)
|
|
|
|
|
video_reset(gfxcard);
|
|
|
|
|
|
2017-11-05 20:43:01 -05:00
|
|
|
/* All good, boot the machine! */
|
|
|
|
|
machines[machine].init(&machines[machine]);
|
2018-09-19 20:13:32 +02:00
|
|
|
|
|
|
|
|
/* If it's a PCI or MCA machine, reset the video card
|
|
|
|
|
after initializing the machine, so the slots work correctly. */
|
|
|
|
|
if (PCI || MCA)
|
|
|
|
|
video_reset(gfxcard);
|
2017-09-02 20:39:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-11-08 16:27:10 -05:00
|
|
|
void
|
2018-03-19 01:02:04 +01:00
|
|
|
machine_common_init(const machine_t *model)
|
2017-09-02 20:39:57 +02:00
|
|
|
{
|
2017-11-08 16:27:10 -05:00
|
|
|
/* System devices first. */
|
|
|
|
|
pic_init();
|
2018-04-25 23:51:13 +02:00
|
|
|
dma_init();
|
2017-11-08 16:27:10 -05:00
|
|
|
pit_init();
|
2017-09-02 20:39:57 +02:00
|
|
|
|
2018-04-25 23:51:13 +02:00
|
|
|
cpu_set();
|
2018-07-15 01:41:53 +02:00
|
|
|
if (machines[machine].cpu[cpu_manufacturer].cpus[cpu_effective].cpu_type >= CPU_286)
|
2018-04-25 23:51:13 +02:00
|
|
|
setrtcconst(machines[machine].cpu[cpu_manufacturer].cpus[cpu_effective].rspeed);
|
|
|
|
|
else
|
|
|
|
|
setrtcconst(14318184.0);
|
|
|
|
|
|
2017-11-08 16:27:10 -05:00
|
|
|
if (lpt_enabled)
|
|
|
|
|
lpt_init();
|
2017-09-02 20:39:57 +02:00
|
|
|
|
2017-11-08 16:27:10 -05:00
|
|
|
if (serial_enabled[0])
|
|
|
|
|
serial_setup(1, SERIAL1_ADDR, SERIAL1_IRQ);
|
2017-09-02 20:39:57 +02:00
|
|
|
|
2017-11-08 16:27:10 -05:00
|
|
|
if (serial_enabled[1])
|
|
|
|
|
serial_setup(2, SERIAL2_ADDR, SERIAL2_IRQ);
|
2017-09-02 20:39:57 +02:00
|
|
|
}
|