mirror of
https://github.com/86Box/86Box.git
synced 2026-02-22 01:25:33 -07:00
Merge remote-tracking branch 'upstream/master' into feature/ich2
This commit is contained in:
10
README.md
10
README.md
@@ -49,16 +49,6 @@ Licensing
|
||||
|
||||
The emulator can also optionally make use of [munt](https://github.com/munt/munt), [FluidSynth](https://www.fluidsynth.org/), [Ghostscript](https://www.ghostscript.com/) and [Discord Game SDK](https://discord.com/developers/docs/game-sdk/sdk-starter-guide), which are distributed under their respective licenses.
|
||||
|
||||
Contribution requirements
|
||||
-------------------------
|
||||
Formal codification of the project's emulated hardware contribution requirements, which all have to be met to accept an addition:
|
||||
* A ROM must be available;
|
||||
* Documentation must be available or it must be feasible to reverse engineer with a reasonable amount of time and effort;
|
||||
* It must be feasible to implement with a reasonable amount of time and effort;
|
||||
* It has to fall inside the project's scope.
|
||||
|
||||
Where unsure or for more details about the project's emulated hardware contribution requirements, contact a Contributor or higher.
|
||||
|
||||
Donations
|
||||
---------
|
||||
We do not charge you for the emulator but donations are still welcome:
|
||||
|
||||
@@ -810,14 +810,13 @@ acpi_reg_write_common_regs(int size, uint16_t addr, uint8_t val, void *p)
|
||||
}
|
||||
|
||||
if (sus_typ & SUS_RESET_PCI)
|
||||
device_reset_all_pci();
|
||||
device_reset_all(DEVICE_PCI);
|
||||
|
||||
if (sus_typ & SUS_RESET_CPU)
|
||||
cpu_alt_reset = 0;
|
||||
|
||||
if (sus_typ & SUS_RESET_PCI) {
|
||||
pci_reset();
|
||||
keyboard_at_reset();
|
||||
|
||||
mem_a20_alt = 0;
|
||||
mem_a20_recalc();
|
||||
|
||||
@@ -151,11 +151,13 @@ ali1533_write(int func, int addr, uint8_t val, void *priv)
|
||||
break;
|
||||
|
||||
case 0x41:
|
||||
/* TODO: Bit 7 selects keyboard controller type:
|
||||
0 = AT, 1 = PS/2 */
|
||||
pic_kbd_latch(!!(val & 0x80));
|
||||
pic_mouse_latch(!!(val & 0x40));
|
||||
dev->pci_conf[addr] = val & 0xbf;
|
||||
pic_kbd_latch(1);
|
||||
// pic_kbd_latch(!!(val & 0x80));
|
||||
if (dev->type == 1)
|
||||
pic_mouse_latch(!!(val & 0x40) || !(dev->pci_conf[0x78] & 0x02));
|
||||
else
|
||||
pic_mouse_latch(!!(val & 0x40));
|
||||
dev->pci_conf[addr] = val;
|
||||
break;
|
||||
|
||||
case 0x42: /* ISA Bus Speed */
|
||||
@@ -431,6 +433,7 @@ ali1533_write(int func, int addr, uint8_t val, void *priv)
|
||||
if (dev->type == 1) {
|
||||
ali1543_log("PCI78 = %02X\n", val);
|
||||
dev->pci_conf[addr] = val & 0x33;
|
||||
pic_mouse_latch(!!(dev->pci_conf[0x41] & 0x40) || !(val & 0x02));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1520,6 +1523,8 @@ ali1543_reset(void *priv)
|
||||
ali1533_write(0, 0x74, 0x00, dev);
|
||||
ali1533_write(0, 0x75, 0x00, dev);
|
||||
ali1533_write(0, 0x76, 0x00, dev);
|
||||
if (dev->type == 1)
|
||||
ali1533_write(0, 0x78, 0x00, dev);
|
||||
|
||||
unmask_a20_in_smm = 1;
|
||||
}
|
||||
|
||||
@@ -200,9 +200,11 @@ sio_write(int func, int addr, uint8_t val, void *priv)
|
||||
dev->regs[addr] = val;
|
||||
break;
|
||||
case 0x4c:
|
||||
dev->regs[addr] = (val & 0x7f);
|
||||
break;
|
||||
case 0x4d:
|
||||
dev->regs[addr] = (val & 0x7f);
|
||||
pic_mouse_latch(!!(val & 0x10));
|
||||
// pic_mouse_latch(!!(val & 0x10));
|
||||
break;
|
||||
case 0x4f:
|
||||
dev->regs[addr] = val;
|
||||
@@ -394,7 +396,7 @@ sio_reset_hard(void *priv)
|
||||
dev->regs[0x4b] = 0x0f;
|
||||
dev->regs[0x4c] = 0x56;
|
||||
dev->regs[0x4d] = 0x40;
|
||||
pic_mouse_latch(0x00);
|
||||
// pic_mouse_latch(0x00);
|
||||
dev->regs[0x4e] = 0x07;
|
||||
dev->regs[0x4f] = 0x4f;
|
||||
dev->regs[0x57] = 0x04;
|
||||
@@ -544,7 +546,19 @@ sio_init(const device_t *info)
|
||||
|
||||
// device_add(&i8254_sec_device);
|
||||
|
||||
pic_kbd_latch(0x01);
|
||||
// pic_kbd_latch(0x01);
|
||||
|
||||
/* The situation is as follow: SIO.AB has the IRQ 1 latch but SIO.IB and SIO.ZB do not,
|
||||
and I suspect that because of that, the IRQ 12 latch on SIO.IB and SIO.ZB, while
|
||||
evidently planned and documented in the datashet, was basically non-functional, and
|
||||
motherboard manufacturers had to install their own latches to use PS/2 keyboards
|
||||
and/or mice. One such example is the AMI Excalibur PCI Pentium, which never enables
|
||||
the SIO.ZB's IRQ 12 latch but clearly expects one since otherwise, the PS/2 mouse
|
||||
behaves erractically in the WinBIOS CMOS Setup. */
|
||||
if (machine_has_bus(machine, MACHINE_BUS_PS2)) {
|
||||
pic_kbd_latch(0x01);
|
||||
pic_mouse_latch(0x01);
|
||||
}
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
41
src/config.c
41
src/config.c
@@ -718,6 +718,24 @@ load_sound(void)
|
||||
|
||||
mpu401_standalone_enable = !!ini_section_get_int(cat, "mpu401_standalone", 0);
|
||||
|
||||
/* Backwards compatibility for standalone SSI-2001, CMS and GUS from v3.11 and older. */
|
||||
const char *legacy_cards[][2] = {
|
||||
{"ssi2001", "ssi2001"},
|
||||
{ "gameblaster", "cms" },
|
||||
{ "gus", "gus" }
|
||||
};
|
||||
for (int i = 0, j = 0; i < (sizeof(legacy_cards) / sizeof(legacy_cards[0])); i++) {
|
||||
if (ini_section_get_int(cat, legacy_cards[i][0], 0) == 1) {
|
||||
/* Migrate to the first available sound card slot. */
|
||||
for (; j < (sizeof(sound_card_current) / sizeof(sound_card_current[0])); j++) {
|
||||
if (!sound_card_current[j]) {
|
||||
sound_card_current[j] = sound_card_get_from_internal_name(legacy_cards[i][1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
memset(temp, '\0', sizeof(temp));
|
||||
p = ini_section_get_string(cat, "sound_type", "float");
|
||||
if (strlen(p) > 511)
|
||||
@@ -2159,7 +2177,7 @@ save_machine(void)
|
||||
else
|
||||
ini_section_delete_var(cat, "cpu_override");
|
||||
|
||||
/* Forwards compatibility with the previous CPU model system. */
|
||||
/* Downgrade compatibility with the previous CPU model system. */
|
||||
ini_section_delete_var(cat, "cpu_manufacturer");
|
||||
ini_section_delete_var(cat, "cpu");
|
||||
|
||||
@@ -2390,6 +2408,27 @@ save_sound(void)
|
||||
else
|
||||
ini_section_set_int(cat, "mpu401_standalone", mpu401_standalone_enable);
|
||||
|
||||
/* Downgrade compatibility for standalone SSI-2001, CMS and GUS from v3.11 and older. */
|
||||
const char *legacy_cards[][2] = {
|
||||
{"ssi2001", "ssi2001"},
|
||||
{ "gameblaster", "cms" },
|
||||
{ "gus", "gus" }
|
||||
};
|
||||
for (int i = 0; i < (sizeof(legacy_cards) / sizeof(legacy_cards[0])); i++) {
|
||||
int card_id = sound_card_get_from_internal_name(legacy_cards[i][1]);
|
||||
for (int j = 0; j < (sizeof(sound_card_current) / sizeof(sound_card_current[0])); j++) {
|
||||
if (sound_card_current[j] == card_id) {
|
||||
/* A special value of 2 still enables the cards on older versions,
|
||||
but lets newer versions know that they've already been migrated. */
|
||||
ini_section_set_int(cat, legacy_cards[i][0], 2);
|
||||
card_id = 0; /* mark as found */
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (card_id > 0) /* not found */
|
||||
ini_section_delete_var(cat, legacy_cards[i][0]);
|
||||
}
|
||||
|
||||
if (sound_is_float == 1)
|
||||
ini_section_delete_var(cat, "sound_type");
|
||||
else
|
||||
|
||||
@@ -780,8 +780,8 @@ smram_restore_state_p6(uint32_t *saved_state)
|
||||
cpu_state.seg_gs.ar_high = (saved_state[SMRAM_FIELD_P6_GS_SELECTOR_AR] >> 24) & 0xff;
|
||||
smm_seg_load(&cpu_state.seg_gs);
|
||||
|
||||
mem_a20_alt = 0;
|
||||
keyboard_at_set_a20_key(!saved_state[SMRAM_FIELD_P6_A20M]);
|
||||
mem_a20_alt = 0x00;
|
||||
mem_a20_key = saved_state[SMRAM_FIELD_P6_A20M] ? 0x00 : 0x02;
|
||||
mem_a20_recalc();
|
||||
|
||||
if (SMM_REVISION_ID & SMM_SMBASE_RELOCATION)
|
||||
@@ -1053,13 +1053,13 @@ enter_smm(int in_hlt)
|
||||
|
||||
memset(saved_state, 0x00, SMM_SAVE_STATE_MAP_SIZE * sizeof(uint32_t));
|
||||
|
||||
if (is_cxsmm) /* Cx6x86 */
|
||||
if (is_cxsmm) /* Cx6x86 */
|
||||
smram_save_state_cyrix(saved_state, in_hlt);
|
||||
else if (is_pentium || is_am486) /* Am486 / 5x86 / Intel P5 (Pentium) */
|
||||
smram_save_state_p5(saved_state, in_hlt);
|
||||
else if (is_k5 || is_k6) /* AMD K5 and K6 */
|
||||
else if (is_k5 || is_k6) /* AMD K5 and K6 */
|
||||
smram_save_state_amd_k(saved_state, in_hlt);
|
||||
else if (is_p6) /* Intel P6 (Pentium Pro, Pentium II, Celeron) */
|
||||
else if (is_p6) /* Intel P6 (Pentium Pro, Pentium II, Celeron) */
|
||||
smram_save_state_p6(saved_state, in_hlt);
|
||||
|
||||
cr0 &= ~0x8000000d;
|
||||
@@ -1224,13 +1224,13 @@ leave_smm(void)
|
||||
}
|
||||
|
||||
x386_common_log("New SMBASE: %08X (%08X)\n", saved_state[SMRAM_FIELD_P5_SMBASE_OFFSET], saved_state[66]);
|
||||
if (is_cxsmm) /* Cx6x86 */
|
||||
if (is_cxsmm) /* Cx6x86 */
|
||||
smram_restore_state_cyrix(saved_state);
|
||||
else if (is_pentium || is_am486) /* Am486 / 5x86 / Intel P5 (Pentium) */
|
||||
smram_restore_state_p5(saved_state);
|
||||
else if (is_k5 || is_k6) /* AMD K5 and K6 */
|
||||
else if (is_k5 || is_k6) /* AMD K5 and K6 */
|
||||
smram_restore_state_amd_k(saved_state);
|
||||
else if (is_p6) /* Intel P6 (Pentium Pro, Pentium II, Celeron) */
|
||||
else if (is_p6) /* Intel P6 (Pentium Pro, Pentium II, Celeron) */
|
||||
smram_restore_state_p6(saved_state);
|
||||
|
||||
in_smm = 0;
|
||||
@@ -1427,25 +1427,29 @@ x86illegal(void)
|
||||
}
|
||||
|
||||
int
|
||||
checkio(uint32_t port)
|
||||
checkio(uint32_t port, int mask)
|
||||
{
|
||||
uint16_t t;
|
||||
uint8_t d;
|
||||
uint32_t t;
|
||||
|
||||
cpl_override = 1;
|
||||
t = readmemw(tr.base, 0x66);
|
||||
cpl_override = 0;
|
||||
|
||||
if (cpu_state.abrt)
|
||||
if (UNLIKELY(cpu_state.abrt)) {
|
||||
cpl_override = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((t + (port >> 3UL)) > tr.limit)
|
||||
return 1;
|
||||
|
||||
cpl_override = 1;
|
||||
d = readmembl(tr.base + t + (port >> 3));
|
||||
t += (port >> 3UL);
|
||||
mask <<= (port & 7);
|
||||
if (UNLIKELY(mask & 0xff00)) {
|
||||
if (LIKELY(t < tr.limit))
|
||||
mask &= readmemwl(tr.base + t);
|
||||
} else {
|
||||
if (LIKELY(t <= tr.limit))
|
||||
mask &= readmembl(tr.base + t);
|
||||
}
|
||||
cpl_override = 0;
|
||||
return d & (1 << (port & 7));
|
||||
return mask;
|
||||
}
|
||||
|
||||
#ifdef OLD_DIVEXCP
|
||||
|
||||
@@ -97,11 +97,11 @@
|
||||
if (writelookup2[(uint32_t) ((s) + (a)) >> 12] == (uintptr_t) LOOKUP_INV || (s) == 0xFFFFFFFF || (((s) + (a)) & 3)) \
|
||||
do_mmutranslate((s) + (a), b, 4, 1)
|
||||
|
||||
int checkio(uint32_t port);
|
||||
int checkio(uint32_t port, int mask);
|
||||
|
||||
#define check_io_perm(port) \
|
||||
#define check_io_perm(port, size) \
|
||||
if (msw & 1 && ((CPL > IOPL) || (cpu_state.eflags & VM_FLAG))) { \
|
||||
int tempi = checkio(port); \
|
||||
int tempi = checkio(port, (1 << size) - 1); \
|
||||
if (cpu_state.abrt) \
|
||||
return 1; \
|
||||
if (tempi) { \
|
||||
|
||||
@@ -426,13 +426,13 @@ pfq_write(void)
|
||||
free in the queue. */
|
||||
tempw = readmemwf(pfq_ip);
|
||||
*(uint16_t *) &(pfq[pfq_pos]) = tempw;
|
||||
pfq_ip += 2;
|
||||
pfq_ip = (pfq_ip + 2) & 0xffff;
|
||||
pfq_pos += 2;
|
||||
} else if (!is8086 && (pfq_pos < pfq_size)) {
|
||||
/* The 8088 fetches 1 byte at a time, and only if there's at least 1 byte
|
||||
free in the queue. */
|
||||
pfq[pfq_pos] = readmembf(pfq_ip);
|
||||
pfq_ip++;
|
||||
pfq_ip = (pfq_ip + 1) & 0xffff;
|
||||
pfq_pos++;
|
||||
}
|
||||
}
|
||||
@@ -2248,7 +2248,7 @@ execx86(int cycs)
|
||||
|
||||
default:
|
||||
opcode = orig_opcode;
|
||||
cpu_state.pc--;
|
||||
cpu_state.pc = (cpu_state.pc - 1) & 0xffff;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
|
||||
@@ -422,7 +422,11 @@ typedef struct {
|
||||
#define CPU_STATUS_PMODE (1 << 2)
|
||||
#define CPU_STATUS_V86 (1 << 3)
|
||||
#define CPU_STATUS_SMM (1 << 4)
|
||||
#ifdef USE_NEW_DYNAREC
|
||||
#define CPU_STATUS_FLAGS 0xff
|
||||
#else
|
||||
#define CPU_STATUS_FLAGS 0xffff
|
||||
#endif
|
||||
|
||||
/*If the cpu_state.flags below are set in cpu_cur_status, they must be set in block->status.
|
||||
Otherwise they are ignored*/
|
||||
@@ -644,7 +648,7 @@ extern void cpu_CPUID(void);
|
||||
extern void cpu_RDMSR(void);
|
||||
extern void cpu_WRMSR(void);
|
||||
|
||||
extern int checkio(uint32_t port);
|
||||
extern int checkio(uint32_t port, int mask);
|
||||
extern void codegen_block_end(void);
|
||||
extern void codegen_reset(void);
|
||||
extern void cpu_set_edx(void);
|
||||
|
||||
@@ -245,7 +245,7 @@ reset_common(int hard)
|
||||
/* TODO: Hack, but will do for time being, because all AT machines currently are 286+,
|
||||
and vice-versa. */
|
||||
dma_set_at(is286);
|
||||
device_reset_all();
|
||||
device_reset_all(DEVICE_ALL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ reset_common(int hard)
|
||||
|
||||
/* If we have an AT or PS/2 keyboard controller, make sure the A20 state
|
||||
is correct. */
|
||||
kbc_at_a20_reset();
|
||||
device_reset_all(DEVICE_KBC);
|
||||
}
|
||||
|
||||
if (!is286)
|
||||
@@ -359,7 +359,7 @@ hardresetx86(void)
|
||||
/* TODO: Hack, but will do for time being, because all AT machines currently are 286+,
|
||||
and vice-versa. */
|
||||
dma_set_at(is286);
|
||||
device_reset_all();
|
||||
device_reset_all(DEVICE_ALL);
|
||||
|
||||
cpu_alt_reset = 0;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ static int
|
||||
opIN_AL_imm(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t port = (uint16_t) getbytef();
|
||||
check_io_perm(port);
|
||||
check_io_perm(port, 1);
|
||||
AL = inb(port);
|
||||
CLOCK_CYCLES(12);
|
||||
PREFETCH_RUN(12, 2, -1, 1, 0, 0, 0, 0);
|
||||
@@ -14,8 +14,7 @@ static int
|
||||
opIN_AX_imm(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t port = (uint16_t) getbytef();
|
||||
check_io_perm(port);
|
||||
check_io_perm(port + 1);
|
||||
check_io_perm(port, 2);
|
||||
AX = inw(port);
|
||||
CLOCK_CYCLES(12);
|
||||
PREFETCH_RUN(12, 2, -1, 1, 0, 0, 0, 0);
|
||||
@@ -27,10 +26,7 @@ static int
|
||||
opIN_EAX_imm(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t port = (uint16_t) getbytef();
|
||||
check_io_perm(port);
|
||||
check_io_perm(port + 1);
|
||||
check_io_perm(port + 2);
|
||||
check_io_perm(port + 3);
|
||||
check_io_perm(port, 4);
|
||||
EAX = inl(port);
|
||||
CLOCK_CYCLES(12);
|
||||
PREFETCH_RUN(12, 2, -1, 0, 1, 0, 0, 0);
|
||||
@@ -43,7 +39,7 @@ static int
|
||||
opOUT_AL_imm(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t port = (uint16_t) getbytef();
|
||||
check_io_perm(port);
|
||||
check_io_perm(port, 1);
|
||||
outb(port, AL);
|
||||
CLOCK_CYCLES(10);
|
||||
PREFETCH_RUN(10, 2, -1, 0, 0, 1, 0, 0);
|
||||
@@ -57,8 +53,7 @@ static int
|
||||
opOUT_AX_imm(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t port = (uint16_t) getbytef();
|
||||
check_io_perm(port);
|
||||
check_io_perm(port + 1);
|
||||
check_io_perm(port, 2);
|
||||
outw(port, AX);
|
||||
CLOCK_CYCLES(10);
|
||||
PREFETCH_RUN(10, 2, -1, 0, 0, 1, 0, 0);
|
||||
@@ -70,10 +65,7 @@ static int
|
||||
opOUT_EAX_imm(uint32_t fetchdat)
|
||||
{
|
||||
uint16_t port = (uint16_t) getbytef();
|
||||
check_io_perm(port);
|
||||
check_io_perm(port + 1);
|
||||
check_io_perm(port + 2);
|
||||
check_io_perm(port + 3);
|
||||
check_io_perm(port, 4);
|
||||
outl(port, EAX);
|
||||
CLOCK_CYCLES(10);
|
||||
PREFETCH_RUN(10, 2, -1, 0, 0, 0, 1, 0);
|
||||
@@ -85,7 +77,7 @@ opOUT_EAX_imm(uint32_t fetchdat)
|
||||
static int
|
||||
opIN_AL_DX(uint32_t fetchdat)
|
||||
{
|
||||
check_io_perm(DX);
|
||||
check_io_perm(DX, 1);
|
||||
AL = inb(DX);
|
||||
CLOCK_CYCLES(12);
|
||||
PREFETCH_RUN(12, 1, -1, 1, 0, 0, 0, 0);
|
||||
@@ -96,8 +88,7 @@ opIN_AL_DX(uint32_t fetchdat)
|
||||
static int
|
||||
opIN_AX_DX(uint32_t fetchdat)
|
||||
{
|
||||
check_io_perm(DX);
|
||||
check_io_perm(DX + 1);
|
||||
check_io_perm(DX, 2);
|
||||
AX = inw(DX);
|
||||
CLOCK_CYCLES(12);
|
||||
PREFETCH_RUN(12, 1, -1, 1, 0, 0, 0, 0);
|
||||
@@ -108,10 +99,7 @@ opIN_AX_DX(uint32_t fetchdat)
|
||||
static int
|
||||
opIN_EAX_DX(uint32_t fetchdat)
|
||||
{
|
||||
check_io_perm(DX);
|
||||
check_io_perm(DX + 1);
|
||||
check_io_perm(DX + 2);
|
||||
check_io_perm(DX + 3);
|
||||
check_io_perm(DX, 4);
|
||||
EAX = inl(DX);
|
||||
CLOCK_CYCLES(12);
|
||||
PREFETCH_RUN(12, 1, -1, 0, 1, 0, 0, 0);
|
||||
@@ -123,7 +111,7 @@ opIN_EAX_DX(uint32_t fetchdat)
|
||||
static int
|
||||
opOUT_AL_DX(uint32_t fetchdat)
|
||||
{
|
||||
check_io_perm(DX);
|
||||
check_io_perm(DX, 1);
|
||||
outb(DX, AL);
|
||||
CLOCK_CYCLES(11);
|
||||
PREFETCH_RUN(11, 1, -1, 0, 0, 1, 0, 0);
|
||||
@@ -134,8 +122,7 @@ opOUT_AL_DX(uint32_t fetchdat)
|
||||
static int
|
||||
opOUT_AX_DX(uint32_t fetchdat)
|
||||
{
|
||||
check_io_perm(DX);
|
||||
check_io_perm(DX + 1);
|
||||
check_io_perm(DX, 2);
|
||||
outw(DX, AX);
|
||||
CLOCK_CYCLES(11);
|
||||
PREFETCH_RUN(11, 1, -1, 0, 0, 1, 0, 0);
|
||||
@@ -146,10 +133,7 @@ opOUT_AX_DX(uint32_t fetchdat)
|
||||
static int
|
||||
opOUT_EAX_DX(uint32_t fetchdat)
|
||||
{
|
||||
check_io_perm(DX);
|
||||
check_io_perm(DX + 1);
|
||||
check_io_perm(DX + 2);
|
||||
check_io_perm(DX + 3);
|
||||
check_io_perm(DX, 4);
|
||||
outl(DX, EAX);
|
||||
PREFETCH_RUN(11, 1, -1, 0, 0, 0, 1, 0);
|
||||
if (nmi && nmi_enable && nmi_mask)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
uint8_t temp; \
|
||||
\
|
||||
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
||||
check_io_perm(DX); \
|
||||
check_io_perm(DX, 1); \
|
||||
CHECK_WRITE(&cpu_state.seg_es, DEST_REG, DEST_REG); \
|
||||
high_page = 0; \
|
||||
do_mmut_wb(es, DEST_REG, &addr64); \
|
||||
@@ -48,8 +48,7 @@
|
||||
uint16_t temp; \
|
||||
\
|
||||
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
||||
check_io_perm(DX); \
|
||||
check_io_perm(DX + 1); \
|
||||
check_io_perm(DX, 2); \
|
||||
CHECK_WRITE(&cpu_state.seg_es, DEST_REG, DEST_REG + 1UL); \
|
||||
high_page = 0; \
|
||||
do_mmut_ww(es, DEST_REG, addr64a); \
|
||||
@@ -88,10 +87,7 @@
|
||||
uint32_t temp; \
|
||||
\
|
||||
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
||||
check_io_perm(DX); \
|
||||
check_io_perm(DX + 1); \
|
||||
check_io_perm(DX + 2); \
|
||||
check_io_perm(DX + 3); \
|
||||
check_io_perm(DX, 4); \
|
||||
CHECK_WRITE(&cpu_state.seg_es, DEST_REG, DEST_REG + 3UL); \
|
||||
high_page = 0; \
|
||||
do_mmut_wl(es, DEST_REG, addr64a); \
|
||||
@@ -132,7 +128,7 @@
|
||||
temp = readmemb(cpu_state.ea_seg->base, SRC_REG); \
|
||||
if (cpu_state.abrt) \
|
||||
return 1; \
|
||||
check_io_perm(DX); \
|
||||
check_io_perm(DX, 1); \
|
||||
outb(DX, temp); \
|
||||
if (cpu_state.flags & D_FLAG) \
|
||||
SRC_REG--; \
|
||||
@@ -163,8 +159,7 @@
|
||||
temp = readmemw(cpu_state.ea_seg->base, SRC_REG); \
|
||||
if (cpu_state.abrt) \
|
||||
return 1; \
|
||||
check_io_perm(DX); \
|
||||
check_io_perm(DX + 1); \
|
||||
check_io_perm(DX, 2); \
|
||||
outw(DX, temp); \
|
||||
if (cpu_state.flags & D_FLAG) \
|
||||
SRC_REG -= 2; \
|
||||
@@ -195,10 +190,7 @@
|
||||
temp = readmeml(cpu_state.ea_seg->base, SRC_REG); \
|
||||
if (cpu_state.abrt) \
|
||||
return 1; \
|
||||
check_io_perm(DX); \
|
||||
check_io_perm(DX + 1); \
|
||||
check_io_perm(DX + 2); \
|
||||
check_io_perm(DX + 3); \
|
||||
check_io_perm(DX, 4); \
|
||||
outl(DX, temp); \
|
||||
if (cpu_state.flags & D_FLAG) \
|
||||
SRC_REG -= 4; \
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
uint8_t temp; \
|
||||
\
|
||||
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
||||
check_io_perm(DX); \
|
||||
check_io_perm(DX, 1); \
|
||||
CHECK_WRITE(&cpu_state.seg_es, DEST_REG, DEST_REG); \
|
||||
high_page = 0; \
|
||||
do_mmut_wb(es, DEST_REG, &addr64); \
|
||||
@@ -40,8 +40,7 @@
|
||||
uint16_t temp; \
|
||||
\
|
||||
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
||||
check_io_perm(DX); \
|
||||
check_io_perm(DX + 1); \
|
||||
check_io_perm(DX, 2); \
|
||||
CHECK_WRITE(&cpu_state.seg_es, DEST_REG, DEST_REG + 1UL); \
|
||||
high_page = 0; \
|
||||
do_mmut_ww(es, DEST_REG, addr64a); \
|
||||
@@ -74,10 +73,7 @@
|
||||
uint32_t temp; \
|
||||
\
|
||||
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
||||
check_io_perm(DX); \
|
||||
check_io_perm(DX + 1); \
|
||||
check_io_perm(DX + 2); \
|
||||
check_io_perm(DX + 3); \
|
||||
check_io_perm(DX, 4); \
|
||||
CHECK_WRITE(&cpu_state.seg_es, DEST_REG, DEST_REG + 3UL); \
|
||||
high_page = 0; \
|
||||
do_mmut_wl(es, DEST_REG, addr64a); \
|
||||
@@ -112,7 +108,7 @@
|
||||
temp = readmemb(cpu_state.ea_seg->base, SRC_REG); \
|
||||
if (cpu_state.abrt) \
|
||||
return 1; \
|
||||
check_io_perm(DX); \
|
||||
check_io_perm(DX, 1); \
|
||||
outb(DX, temp); \
|
||||
if (cpu_state.flags & D_FLAG) \
|
||||
SRC_REG--; \
|
||||
@@ -137,8 +133,7 @@
|
||||
temp = readmemw(cpu_state.ea_seg->base, SRC_REG); \
|
||||
if (cpu_state.abrt) \
|
||||
return 1; \
|
||||
check_io_perm(DX); \
|
||||
check_io_perm(DX + 1); \
|
||||
check_io_perm(DX, 2); \
|
||||
outw(DX, temp); \
|
||||
if (cpu_state.flags & D_FLAG) \
|
||||
SRC_REG -= 2; \
|
||||
@@ -163,10 +158,7 @@
|
||||
temp = readmeml(cpu_state.ea_seg->base, SRC_REG); \
|
||||
if (cpu_state.abrt) \
|
||||
return 1; \
|
||||
check_io_perm(DX); \
|
||||
check_io_perm(DX + 1); \
|
||||
check_io_perm(DX + 2); \
|
||||
check_io_perm(DX + 3); \
|
||||
check_io_perm(DX, 4); \
|
||||
outl(DX, temp); \
|
||||
if (cpu_state.flags & D_FLAG) \
|
||||
SRC_REG -= 4; \
|
||||
|
||||
@@ -804,7 +804,7 @@ opINSB_a16(uint32_t fetchdat)
|
||||
addr64 = 0x00000000;
|
||||
|
||||
SEG_CHECK_WRITE(&cpu_state.seg_es);
|
||||
check_io_perm(DX);
|
||||
check_io_perm(DX, 1);
|
||||
CHECK_WRITE(&cpu_state.seg_es, DI, DI);
|
||||
high_page = 0;
|
||||
do_mmut_wb(es, DI, &addr64);
|
||||
@@ -830,7 +830,7 @@ opINSB_a32(uint32_t fetchdat)
|
||||
addr64 = 0x00000000;
|
||||
|
||||
SEG_CHECK_WRITE(&cpu_state.seg_es);
|
||||
check_io_perm(DX);
|
||||
check_io_perm(DX, 1);
|
||||
high_page = 0;
|
||||
CHECK_WRITE(&cpu_state.seg_es, EDI, EDI);
|
||||
do_mmut_wb(es, EDI, &addr64);
|
||||
@@ -857,8 +857,7 @@ opINSW_a16(uint32_t fetchdat)
|
||||
addr64a[0] = addr64a[1] = 0x00000000;
|
||||
|
||||
SEG_CHECK_WRITE(&cpu_state.seg_es);
|
||||
check_io_perm(DX);
|
||||
check_io_perm(DX + 1);
|
||||
check_io_perm(DX, 2);
|
||||
CHECK_WRITE(&cpu_state.seg_es, DI, DI + 1UL);
|
||||
high_page = 0;
|
||||
do_mmut_ww(es, DI, addr64a);
|
||||
@@ -885,8 +884,7 @@ opINSW_a32(uint32_t fetchdat)
|
||||
|
||||
SEG_CHECK_WRITE(&cpu_state.seg_es);
|
||||
high_page = 0;
|
||||
check_io_perm(DX);
|
||||
check_io_perm(DX + 1);
|
||||
check_io_perm(DX, 2);
|
||||
CHECK_WRITE(&cpu_state.seg_es, EDI, EDI + 1UL);
|
||||
do_mmut_ww(es, EDI, addr64a);
|
||||
if (cpu_state.abrt)
|
||||
@@ -912,10 +910,7 @@ opINSL_a16(uint32_t fetchdat)
|
||||
addr64a[0] = addr64a[1] = addr64a[2] = addr64a[3] = 0x00000000;
|
||||
|
||||
SEG_CHECK_WRITE(&cpu_state.seg_es);
|
||||
check_io_perm(DX);
|
||||
check_io_perm(DX + 1);
|
||||
check_io_perm(DX + 2);
|
||||
check_io_perm(DX + 3);
|
||||
check_io_perm(DX, 4);
|
||||
CHECK_WRITE(&cpu_state.seg_es, DI, DI + 3UL);
|
||||
high_page = 0;
|
||||
do_mmut_wl(es, DI, addr64a);
|
||||
@@ -941,10 +936,7 @@ opINSL_a32(uint32_t fetchdat)
|
||||
addr64a[0] = addr64a[1] = addr64a[2] = addr64a[3] = 0x00000000;
|
||||
|
||||
SEG_CHECK_WRITE(&cpu_state.seg_es);
|
||||
check_io_perm(DX);
|
||||
check_io_perm(DX + 1);
|
||||
check_io_perm(DX + 2);
|
||||
check_io_perm(DX + 3);
|
||||
check_io_perm(DX, 4);
|
||||
CHECK_WRITE(&cpu_state.seg_es, EDI, EDI + 3UL);
|
||||
high_page = 0;
|
||||
do_mmut_wl(es, DI, addr64a);
|
||||
@@ -973,7 +965,7 @@ opOUTSB_a16(uint32_t fetchdat)
|
||||
temp = readmemb(cpu_state.ea_seg->base, SI);
|
||||
if (cpu_state.abrt)
|
||||
return 1;
|
||||
check_io_perm(DX);
|
||||
check_io_perm(DX, 1);
|
||||
if (cpu_state.flags & D_FLAG)
|
||||
SI--;
|
||||
else
|
||||
@@ -993,7 +985,7 @@ opOUTSB_a32(uint32_t fetchdat)
|
||||
temp = readmemb(cpu_state.ea_seg->base, ESI);
|
||||
if (cpu_state.abrt)
|
||||
return 1;
|
||||
check_io_perm(DX);
|
||||
check_io_perm(DX, 1);
|
||||
if (cpu_state.flags & D_FLAG)
|
||||
ESI--;
|
||||
else
|
||||
@@ -1014,8 +1006,7 @@ opOUTSW_a16(uint32_t fetchdat)
|
||||
temp = readmemw(cpu_state.ea_seg->base, SI);
|
||||
if (cpu_state.abrt)
|
||||
return 1;
|
||||
check_io_perm(DX);
|
||||
check_io_perm(DX + 1);
|
||||
check_io_perm(DX, 2);
|
||||
if (cpu_state.flags & D_FLAG)
|
||||
SI -= 2;
|
||||
else
|
||||
@@ -1035,8 +1026,7 @@ opOUTSW_a32(uint32_t fetchdat)
|
||||
temp = readmemw(cpu_state.ea_seg->base, ESI);
|
||||
if (cpu_state.abrt)
|
||||
return 1;
|
||||
check_io_perm(DX);
|
||||
check_io_perm(DX + 1);
|
||||
check_io_perm(DX, 2);
|
||||
if (cpu_state.flags & D_FLAG)
|
||||
ESI -= 2;
|
||||
else
|
||||
@@ -1057,10 +1047,7 @@ opOUTSL_a16(uint32_t fetchdat)
|
||||
temp = readmeml(cpu_state.ea_seg->base, SI);
|
||||
if (cpu_state.abrt)
|
||||
return 1;
|
||||
check_io_perm(DX);
|
||||
check_io_perm(DX + 1);
|
||||
check_io_perm(DX + 2);
|
||||
check_io_perm(DX + 3);
|
||||
check_io_perm(DX, 4);
|
||||
if (cpu_state.flags & D_FLAG)
|
||||
SI -= 4;
|
||||
else
|
||||
@@ -1080,10 +1067,7 @@ opOUTSL_a32(uint32_t fetchdat)
|
||||
temp = readmeml(cpu_state.ea_seg->base, ESI);
|
||||
if (cpu_state.abrt)
|
||||
return 1;
|
||||
check_io_perm(DX);
|
||||
check_io_perm(DX + 1);
|
||||
check_io_perm(DX + 2);
|
||||
check_io_perm(DX + 3);
|
||||
check_io_perm(DX, 4);
|
||||
if (cpu_state.flags & D_FLAG)
|
||||
ESI -= 4;
|
||||
else
|
||||
|
||||
18
src/device.c
18
src/device.c
@@ -315,27 +315,13 @@ device_close_all(void)
|
||||
}
|
||||
|
||||
void
|
||||
device_reset_all(void)
|
||||
device_reset_all(uint32_t match_flags)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c = 0; c < DEVICE_MAX; c++) {
|
||||
if (devices[c] != NULL) {
|
||||
if (devices[c]->reset != NULL)
|
||||
devices[c]->reset(device_priv[c]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset all attached PCI devices - needed for PCI turbo reset control. */
|
||||
void
|
||||
device_reset_all_pci(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c = 0; c < DEVICE_MAX; c++) {
|
||||
if (devices[c] != NULL) {
|
||||
if ((devices[c]->reset != NULL) && (devices[c]->flags & DEVICE_PCI))
|
||||
if ((devices[c]->reset != NULL) && (devices[c]->flags & match_flags))
|
||||
devices[c]->reset(device_priv[c]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@ add_library(dev OBJECT bugger.c cassette.c cartridge.c hasp.c hwm.c hwm_lm75.c h
|
||||
hwm_vt82c686.c ibm_5161.c intel_ich2_gpio.c intel_ich2_trap.c
|
||||
isamem.c isartc.c ../lpt.c pci_bridge.c
|
||||
postcard.c serial.c clock_ics9xxx.c isapnp.c i2c.c i2c_gpio.c
|
||||
smbus_piix4.c smbus_ali7101.c keyboard.c keyboard_xt.c keyboard_at.c
|
||||
smbus_piix4.c smbus_ali7101.c keyboard.c keyboard_xt.c
|
||||
kbc_at.c kbc_at_dev.c
|
||||
keyboard_at.c
|
||||
mouse.c mouse_bus.c mouse_serial.c mouse_ps2.c phoenix_486_jumper.c
|
||||
mouse_wacom_tablet.c serial_passthrough.c tco.c)
|
||||
|
||||
|
||||
2159
src/device/kbc_at.c
Normal file
2159
src/device/kbc_at.c
Normal file
File diff suppressed because it is too large
Load Diff
198
src/device/kbc_at_dev.c
Normal file
198
src/device/kbc_at_dev.c
Normal file
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* AT / PS/2 attached device emulation.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
* Copyright 2023 Miran Grca.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#define HAVE_STDARG_H
|
||||
#include <wchar.h>
|
||||
#include <86box/86box.h>
|
||||
#include "cpu.h"
|
||||
#include <86box/timer.h>
|
||||
#include <86box/io.h>
|
||||
#include <86box/pic.h>
|
||||
#include <86box/pit.h>
|
||||
#include <86box/ppi.h>
|
||||
#include <86box/mem.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/machine.h>
|
||||
#include <86box/m_at_t3100e.h>
|
||||
#include <86box/fdd.h>
|
||||
#include <86box/fdc.h>
|
||||
#include <86box/sound.h>
|
||||
#include <86box/snd_speaker.h>
|
||||
#include <86box/video.h>
|
||||
#include <86box/keyboard.h>
|
||||
|
||||
#ifdef ENABLE_KBC_AT_DEV_LOG
|
||||
int kbc_at_dev_do_log = ENABLE_KBC_AT_DEV_LOG;
|
||||
|
||||
static void
|
||||
kbc_at_dev_log(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (kbc_at_dev_do_log) {
|
||||
va_start(ap, fmt);
|
||||
pclog_ex(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define kbc_at_dev_log(fmt, ...)
|
||||
#endif
|
||||
|
||||
static void
|
||||
kbc_at_dev_queue_reset(atkbc_dev_t *dev, uint8_t reset_main)
|
||||
{
|
||||
if (reset_main) {
|
||||
dev->queue_start = dev->queue_end = 0;
|
||||
memset(dev->queue, 0x00, sizeof(dev->queue));
|
||||
}
|
||||
|
||||
dev->cmd_queue_start = dev->cmd_queue_end = 0;
|
||||
memset(dev->cmd_queue, 0x00, sizeof(dev->cmd_queue));
|
||||
}
|
||||
|
||||
uint8_t
|
||||
kbc_at_dev_queue_pos(atkbc_dev_t *dev, uint8_t main)
|
||||
{
|
||||
uint8_t ret;
|
||||
|
||||
if (main)
|
||||
ret = ((dev->queue_end - dev->queue_start) & 0xf);
|
||||
else
|
||||
ret = ((dev->cmd_queue_end - dev->cmd_queue_start) & 0xf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
kbc_at_dev_queue_add(atkbc_dev_t *dev, uint8_t val, uint8_t main)
|
||||
{
|
||||
if (main) {
|
||||
kbc_at_dev_log("%s: dev->queue[%02X] = %02X;\n", dev->name, dev->queue_end, val);
|
||||
dev->queue[dev->queue_end] = val;
|
||||
dev->queue_end = (dev->queue_end + 1) & 0xf;
|
||||
} else {
|
||||
kbc_at_dev_log("%s: dev->cmd_queue[%02X] = %02X;\n", dev->name, dev->cmd_queue_end, val);
|
||||
dev->cmd_queue[dev->cmd_queue_end] = val;
|
||||
dev->cmd_queue_end = (dev->cmd_queue_end + 1) & 0xf;
|
||||
}
|
||||
|
||||
/* TODO: This should be done on actual send to host. */
|
||||
if (val != 0xfe)
|
||||
dev->last_scan_code = val;
|
||||
}
|
||||
|
||||
static void
|
||||
kbc_at_dev_poll(void *priv)
|
||||
{
|
||||
atkbc_dev_t *dev = (atkbc_dev_t *) priv;
|
||||
|
||||
switch (dev->state) {
|
||||
case DEV_STATE_MAIN_1:
|
||||
/* Process the command if needed and then return to main loop #2. */
|
||||
if (dev->port->wantcmd) {
|
||||
kbc_at_dev_log("%s: Processing keyboard command %02X...\n", dev->name, dev->port->dat);
|
||||
kbc_at_dev_queue_reset(dev, 0);
|
||||
dev->process_cmd(dev);
|
||||
dev->port->wantcmd = 0;
|
||||
} else
|
||||
dev->state = DEV_STATE_MAIN_2;
|
||||
break;
|
||||
case DEV_STATE_MAIN_2:
|
||||
/* Output from scan queue if needed and then return to main loop #1. */
|
||||
if (*dev->scan && (dev->port->out_new == -1) && (dev->queue_start != dev->queue_end)) {
|
||||
kbc_at_dev_log("%s: %02X (DATA) on channel 1\n", dev->name, dev->queue[dev->queue_start]);
|
||||
dev->port->out_new = dev->queue[dev->queue_start];
|
||||
dev->queue_start = (dev->queue_start + 1) & 0xf;
|
||||
}
|
||||
if (!(*dev->scan) || dev->port->wantcmd)
|
||||
dev->state = DEV_STATE_MAIN_1;
|
||||
break;
|
||||
case DEV_STATE_MAIN_OUT:
|
||||
/* If host wants to send command while we're sending a byte to host, process the command. */
|
||||
if (dev->port->wantcmd) {
|
||||
kbc_at_dev_log("%s: Processing keyboard command %02X...\n", dev->name, dev->port->dat);
|
||||
kbc_at_dev_queue_reset(dev, 0);
|
||||
dev->process_cmd(dev);
|
||||
dev->port->wantcmd = 0;
|
||||
break;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
case DEV_STATE_MAIN_WANT_IN:
|
||||
/* Output command response and then return to main loop #2. */
|
||||
if ((dev->port->out_new == -1) && (dev->cmd_queue_start != dev->cmd_queue_end)) {
|
||||
kbc_at_dev_log("%s: %02X (CMD ) on channel 1\n", dev->name, dev->cmd_queue[dev->cmd_queue_start]);
|
||||
dev->port->out_new = dev->cmd_queue[dev->cmd_queue_start];
|
||||
dev->cmd_queue_start = (dev->cmd_queue_start + 1) & 0xf;
|
||||
}
|
||||
if (dev->cmd_queue_start == dev->cmd_queue_end)
|
||||
dev->state++;
|
||||
break;
|
||||
case DEV_STATE_MAIN_IN:
|
||||
/* Wait for host data. */
|
||||
if (dev->port->wantcmd) {
|
||||
kbc_at_dev_log("%s: Processing keyboard command %02X parameter %02X...\n", dev->name, dev->command, dev->port->dat);
|
||||
kbc_at_dev_queue_reset(dev, 0);
|
||||
dev->process_cmd(dev);
|
||||
dev->port->wantcmd = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
kbc_at_dev_reset(atkbc_dev_t *dev, int do_fa)
|
||||
{
|
||||
dev->port->out_new = -1;
|
||||
dev->port->wantcmd = 0;
|
||||
|
||||
kbc_at_dev_queue_reset(dev, 1);
|
||||
|
||||
dev->last_scan_code = 0x00;
|
||||
|
||||
*dev->scan = 1;
|
||||
|
||||
if (do_fa)
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
|
||||
dev->state = DEV_STATE_MAIN_OUT;
|
||||
|
||||
dev->execute_bat(dev);
|
||||
}
|
||||
|
||||
atkbc_dev_t *
|
||||
kbc_at_dev_init(uint8_t inst)
|
||||
{
|
||||
atkbc_dev_t *dev;
|
||||
|
||||
dev = (atkbc_dev_t *) malloc(sizeof(atkbc_dev_t));
|
||||
memset(dev, 0x00, sizeof(atkbc_dev_t));
|
||||
|
||||
dev->port = kbc_at_ports[inst];
|
||||
|
||||
if (dev->port != NULL) {
|
||||
dev->port->priv = dev;
|
||||
dev->port->poll = kbc_at_dev_poll;
|
||||
}
|
||||
|
||||
/* Return our private data to the I/O layer. */
|
||||
return (dev);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -102,6 +102,8 @@ static int mouse_nbut;
|
||||
static int (*mouse_dev_poll)(int x, int y, int z, int b, void *priv);
|
||||
static void (*mouse_poll_ex)(void) = NULL;
|
||||
|
||||
static double sample_rate = 200.0;
|
||||
|
||||
#ifdef ENABLE_MOUSE_LOG
|
||||
int mouse_do_log = ENABLE_MOUSE_LOG;
|
||||
|
||||
@@ -153,7 +155,7 @@ static void
|
||||
mouse_timer_poll(void *priv)
|
||||
{
|
||||
/* Poll at 255 Hz, maximum supported by PS/2 mic. */
|
||||
timer_on_auto(&mouse_timer, 1000000.0 / 255.0);
|
||||
timer_on_auto(&mouse_timer, 1000000.0 / sample_rate);
|
||||
|
||||
#ifdef USE_GDBSTUB /* avoid a KBC FIFO overflow when CPU emulation is stalled */
|
||||
if (gdbstub_step == GDBSTUB_EXEC)
|
||||
@@ -161,6 +163,15 @@ mouse_timer_poll(void *priv)
|
||||
mouse_process();
|
||||
}
|
||||
|
||||
void
|
||||
mouse_set_sample_rate(double new_rate)
|
||||
{
|
||||
timer_stop(&mouse_timer);
|
||||
|
||||
sample_rate = new_rate;
|
||||
timer_on_auto(&mouse_timer, 1000000.0 / sample_rate);
|
||||
}
|
||||
|
||||
void
|
||||
mouse_reset(void)
|
||||
{
|
||||
@@ -179,15 +190,16 @@ mouse_reset(void)
|
||||
if (mouse_type == 0)
|
||||
return;
|
||||
|
||||
timer_add(&mouse_timer, mouse_timer_poll, NULL, 0);
|
||||
|
||||
/* Poll at 100 Hz, the default of a PS/2 mouse. */
|
||||
sample_rate = 100.0;
|
||||
timer_on_auto(&mouse_timer, 1000000.0 / sample_rate);
|
||||
|
||||
mouse_curr = mouse_devices[mouse_type].device;
|
||||
|
||||
if (mouse_curr != NULL)
|
||||
mouse_priv = device_add(mouse_curr);
|
||||
|
||||
timer_add(&mouse_timer, mouse_timer_poll, NULL, 0);
|
||||
|
||||
/* Poll at 255 Hz, maximum supported by PS/2 mic. */
|
||||
timer_on_auto(&mouse_timer, 1000000.0 / 255.0);
|
||||
}
|
||||
|
||||
/* Callback from the hardware driver. */
|
||||
|
||||
@@ -30,22 +30,7 @@ enum {
|
||||
MODE_ECHO
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
const char *name; /* name of this device */
|
||||
int8_t type; /* type of this device */
|
||||
|
||||
int mode;
|
||||
|
||||
uint16_t flags;
|
||||
uint8_t resolution;
|
||||
uint8_t sample_rate;
|
||||
|
||||
uint8_t command;
|
||||
|
||||
int x, y, z, b;
|
||||
|
||||
uint8_t last_data[6];
|
||||
} mouse_t;
|
||||
#define FLAG_EXPLORER 0x200 /* Has 5 buttons */
|
||||
#define FLAG_5BTN 0x100 /* using Intellimouse Optical mode */
|
||||
#define FLAG_INTELLI 0x80 /* device is IntelliMouse */
|
||||
#define FLAG_INTMODE 0x40 /* using Intellimouse mode */
|
||||
@@ -76,13 +61,13 @@ mouse_ps2_log(const char *fmt, ...)
|
||||
void
|
||||
mouse_clear_data(void *priv)
|
||||
{
|
||||
mouse_t *dev = (mouse_t *) priv;
|
||||
atkbc_dev_t *dev = (atkbc_dev_t *) priv;
|
||||
|
||||
dev->flags &= ~FLAG_CTRLDAT;
|
||||
}
|
||||
|
||||
static void
|
||||
ps2_report_coordinates(mouse_t *dev, int cmd)
|
||||
ps2_report_coordinates(atkbc_dev_t *dev, int main)
|
||||
{
|
||||
uint8_t buff[3] = { 0x08, 0x00, 0x00 };
|
||||
int temp_z;
|
||||
@@ -123,15 +108,9 @@ ps2_report_coordinates(mouse_t *dev, int cmd)
|
||||
buff[1] = (dev->x & 0xff);
|
||||
buff[2] = (dev->y & 0xff);
|
||||
|
||||
if (cmd) {
|
||||
keyboard_at_adddata_mouse_cmd(buff[0]);
|
||||
keyboard_at_adddata_mouse_cmd(buff[1]);
|
||||
keyboard_at_adddata_mouse_cmd(buff[2]);
|
||||
} else {
|
||||
keyboard_at_adddata_mouse(buff[0]);
|
||||
keyboard_at_adddata_mouse(buff[1]);
|
||||
keyboard_at_adddata_mouse(buff[2]);
|
||||
}
|
||||
kbc_at_dev_queue_add(dev, buff[0], main);
|
||||
kbc_at_dev_queue_add(dev, buff[1], main);
|
||||
kbc_at_dev_queue_add(dev, buff[2], main);
|
||||
if (dev->flags & FLAG_INTMODE) {
|
||||
temp_z = dev->z & 0x0f;
|
||||
if ((dev->flags & FLAG_5BTN)) {
|
||||
@@ -144,144 +123,192 @@ ps2_report_coordinates(mouse_t *dev, int cmd)
|
||||
if (temp_z & 0x08)
|
||||
temp_z |= 0xf0;
|
||||
}
|
||||
if (cmd)
|
||||
keyboard_at_adddata_mouse_cmd(temp_z);
|
||||
else
|
||||
keyboard_at_adddata_mouse(temp_z);
|
||||
kbc_at_dev_queue_add(dev, temp_z, main);
|
||||
}
|
||||
|
||||
dev->x = dev->y = dev->z = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
ps2_write(uint8_t val, void *priv)
|
||||
ps2_set_defaults(atkbc_dev_t *dev)
|
||||
{
|
||||
mouse_t *dev = (mouse_t *) priv;
|
||||
uint8_t temp;
|
||||
dev->mode = MODE_STREAM;
|
||||
dev->rate = 100;
|
||||
mouse_set_sample_rate(100.0);
|
||||
dev->resolution = 2;
|
||||
dev->flags &= 0x88;
|
||||
mouse_scan = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
ps2_bat(void *priv)
|
||||
{
|
||||
atkbc_dev_t *dev = (atkbc_dev_t *) priv;
|
||||
|
||||
ps2_set_defaults(dev);
|
||||
|
||||
kbc_at_dev_queue_add(dev, 0xaa, 0);
|
||||
kbc_at_dev_queue_add(dev, 0x00, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
ps2_write(void *priv)
|
||||
{
|
||||
atkbc_dev_t *dev = (atkbc_dev_t *) priv;
|
||||
uint8_t temp, val;
|
||||
static uint8_t last_data[6] = { 0x00 };
|
||||
|
||||
if (dev->port == NULL)
|
||||
return;
|
||||
|
||||
val = dev->port->dat;
|
||||
|
||||
dev->state = DEV_STATE_MAIN_OUT;
|
||||
|
||||
if (dev->flags & FLAG_CTRLDAT) {
|
||||
dev->flags &= ~FLAG_CTRLDAT;
|
||||
|
||||
if (val == 0xff)
|
||||
goto mouse_reset;
|
||||
|
||||
switch (dev->command) {
|
||||
kbc_at_dev_reset(dev, 1);
|
||||
else switch (dev->command) {
|
||||
case 0xe8: /* set mouse resolution */
|
||||
dev->resolution = val;
|
||||
keyboard_at_adddata_mouse_cmd(0xfa);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
mouse_ps2_log("%s: Set mouse resolution [%02X]\n", dev->name, val);
|
||||
break;
|
||||
|
||||
case 0xf3: /* set sample rate */
|
||||
dev->sample_rate = val;
|
||||
keyboard_at_adddata_mouse_cmd(0xfa); /* Command response */
|
||||
dev->rate = val;
|
||||
mouse_set_sample_rate((double) val);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0); /* Command response */
|
||||
mouse_ps2_log("%s: Set sample rate [%02X]\n", dev->name, val);
|
||||
break;
|
||||
|
||||
default:
|
||||
keyboard_at_adddata_mouse_cmd(0xfc);
|
||||
kbc_at_dev_queue_add(dev, 0xfc, 0);
|
||||
}
|
||||
} else {
|
||||
dev->command = val;
|
||||
|
||||
switch (dev->command) {
|
||||
case 0xe6: /* set scaling to 1:1 */
|
||||
mouse_ps2_log("%s: Set scaling to 1:1\n", dev->name);
|
||||
dev->flags &= ~FLAG_SCALED;
|
||||
keyboard_at_adddata_mouse_cmd(0xfa);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
break;
|
||||
|
||||
case 0xe7: /* set scaling to 2:1 */
|
||||
mouse_ps2_log("%s: Set scaling to 2:1\n", dev->name);
|
||||
dev->flags |= FLAG_SCALED;
|
||||
keyboard_at_adddata_mouse_cmd(0xfa);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
break;
|
||||
|
||||
case 0xe8: /* set mouse resolution */
|
||||
mouse_ps2_log("%s: Set mouse resolution\n", dev->name);
|
||||
dev->flags |= FLAG_CTRLDAT;
|
||||
keyboard_at_adddata_mouse_cmd(0xfa);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
dev->state = DEV_STATE_MAIN_WANT_IN;
|
||||
break;
|
||||
|
||||
case 0xe9: /* status request */
|
||||
keyboard_at_adddata_mouse_cmd(0xfa);
|
||||
temp = (dev->flags & 0x30);
|
||||
mouse_ps2_log("%s: Status request\n", dev->name);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
temp = (dev->flags & 0x20);
|
||||
if (mouse_scan)
|
||||
temp |= FLAG_ENABLED;
|
||||
if (mouse_buttons & 1)
|
||||
temp |= 4;
|
||||
if (mouse_buttons & 2)
|
||||
temp |= 1;
|
||||
if ((mouse_buttons & 4) && (dev->flags & FLAG_INTELLI))
|
||||
temp |= 2;
|
||||
keyboard_at_adddata_mouse_cmd(temp);
|
||||
keyboard_at_adddata_mouse_cmd(dev->resolution);
|
||||
keyboard_at_adddata_mouse_cmd(dev->sample_rate);
|
||||
kbc_at_dev_queue_add(dev, temp, 0);
|
||||
kbc_at_dev_queue_add(dev, dev->resolution, 0);
|
||||
kbc_at_dev_queue_add(dev, dev->rate, 0);
|
||||
break;
|
||||
|
||||
case 0xea: /* set stream */
|
||||
mouse_ps2_log("%s: Set stream\n", dev->name);
|
||||
dev->flags &= ~FLAG_CTRLDAT;
|
||||
dev->mode = MODE_STREAM;
|
||||
mouse_scan = 1;
|
||||
keyboard_at_adddata_mouse_cmd(0xfa); /* ACK for command byte */
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0); /* ACK for command byte */
|
||||
break;
|
||||
|
||||
case 0xeb: /* Get mouse data */
|
||||
keyboard_at_adddata_mouse_cmd(0xfa);
|
||||
mouse_ps2_log("%s: Get mouse data\n", dev->name);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
|
||||
ps2_report_coordinates(dev, 1);
|
||||
ps2_report_coordinates(dev, 0);
|
||||
break;
|
||||
|
||||
case 0xf0: /* set remote */
|
||||
mouse_ps2_log("%s: Set remote\n", dev->name);
|
||||
dev->flags &= ~FLAG_CTRLDAT;
|
||||
dev->mode = MODE_REMOTE;
|
||||
mouse_scan = 1;
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0); /* ACK for command byte */
|
||||
break;
|
||||
|
||||
case 0xf2: /* read ID */
|
||||
keyboard_at_adddata_mouse_cmd(0xfa);
|
||||
mouse_ps2_log("%s: Read ID\n", dev->name);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
if (dev->flags & FLAG_INTMODE)
|
||||
keyboard_at_adddata_mouse_cmd((dev->flags & FLAG_5BTN) ? 0x04 : 0x03);
|
||||
kbc_at_dev_queue_add(dev, (dev->flags & FLAG_5BTN) ? 0x04 : 0x03, 0);
|
||||
else
|
||||
keyboard_at_adddata_mouse_cmd(0x00);
|
||||
kbc_at_dev_queue_add(dev, 0x00, 0);
|
||||
break;
|
||||
|
||||
case 0xf3: /* set command mode */
|
||||
case 0xf3: /* set sample rate */
|
||||
mouse_ps2_log("%s: Set sample rate\n", dev->name);
|
||||
dev->flags |= FLAG_CTRLDAT;
|
||||
keyboard_at_adddata_mouse_cmd(0xfa); /* ACK for command byte */
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0); /* ACK for command byte */
|
||||
dev->state = DEV_STATE_MAIN_WANT_IN;
|
||||
break;
|
||||
|
||||
case 0xf4: /* enable */
|
||||
dev->flags |= FLAG_ENABLED;
|
||||
mouse_ps2_log("%s: Enable\n", dev->name);
|
||||
mouse_scan = 1;
|
||||
keyboard_at_adddata_mouse_cmd(0xfa);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
break;
|
||||
|
||||
case 0xf5: /* disable */
|
||||
dev->flags &= ~FLAG_ENABLED;
|
||||
mouse_ps2_log("%s: Disable\n", dev->name);
|
||||
mouse_scan = 0;
|
||||
keyboard_at_adddata_mouse_cmd(0xfa);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
break;
|
||||
|
||||
case 0xf6: /* set defaults */
|
||||
mouse_ps2_log("%s: Set defaults\n", dev->name);
|
||||
ps2_set_defaults(dev);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
break;
|
||||
|
||||
case 0xff: /* reset */
|
||||
mouse_reset:
|
||||
dev->mode = MODE_STREAM;
|
||||
dev->flags &= 0x88;
|
||||
mouse_scan = 1;
|
||||
keyboard_at_mouse_reset();
|
||||
keyboard_at_adddata_mouse_cmd(0xfa);
|
||||
if (dev->command == 0xff) {
|
||||
keyboard_at_adddata_mouse_cmd(0xaa);
|
||||
keyboard_at_adddata_mouse_cmd(0x00);
|
||||
}
|
||||
mouse_ps2_log("%s: Reset\n", dev->name);
|
||||
kbc_at_dev_reset(dev, 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
keyboard_at_adddata_mouse_cmd(0xfe);
|
||||
kbc_at_dev_queue_add(dev, 0xfe, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (dev->flags & FLAG_INTELLI) {
|
||||
for (temp = 0; temp < 5; temp++)
|
||||
dev->last_data[temp] = dev->last_data[temp + 1];
|
||||
last_data[temp] = last_data[temp + 1];
|
||||
|
||||
dev->last_data[5] = val;
|
||||
last_data[5] = val;
|
||||
|
||||
if ((dev->last_data[0] == 0xf3) && (dev->last_data[1] == 0xc8) &&
|
||||
(dev->last_data[2] == 0xf3) && (dev->last_data[3] == 0x64) &&
|
||||
(dev->last_data[4] == 0xf3) && (dev->last_data[5] == 0x50))
|
||||
if ((last_data[0] == 0xf3) && (last_data[1] == 0xc8) &&
|
||||
(last_data[2] == 0xf3) && (last_data[3] == 0x64) &&
|
||||
(last_data[4] == 0xf3) && (last_data[5] == 0x50))
|
||||
dev->flags |= FLAG_INTMODE;
|
||||
|
||||
if ((dev->flags & FLAG_INTMODE) && (dev->last_data[0] == 0xf3) && (dev->last_data[1] == 0xc8) &&
|
||||
(dev->last_data[2] == 0xf3) && (dev->last_data[3] == 0xc8) &&
|
||||
(dev->last_data[4] == 0xf3) && (dev->last_data[5] == 0x50))
|
||||
if ((dev->flags & FLAG_EXPLORER) && (dev->flags & FLAG_INTMODE) &&
|
||||
(last_data[0] == 0xf3) && (last_data[1] == 0xc8) &&
|
||||
(last_data[2] == 0xf3) && (last_data[3] == 0xc8) &&
|
||||
(last_data[4] == 0xf3) && (last_data[5] == 0x50))
|
||||
dev->flags |= FLAG_5BTN;
|
||||
}
|
||||
}
|
||||
@@ -289,30 +316,18 @@ mouse_reset:
|
||||
static int
|
||||
ps2_poll(int x, int y, int z, int b, double abs_x, double abs_y, void *priv)
|
||||
{
|
||||
mouse_t *dev = (mouse_t *) priv;
|
||||
atkbc_dev_t *dev = (atkbc_dev_t *) priv;
|
||||
|
||||
if (!x && !y && !z && (b == dev->b))
|
||||
return (0xff);
|
||||
|
||||
#if 0
|
||||
if (!(dev->flags & FLAG_ENABLED))
|
||||
return(0xff);
|
||||
#endif
|
||||
|
||||
if (!mouse_scan)
|
||||
if (!mouse_scan || (!x && !y && !z && (b == dev->b)))
|
||||
return (0xff);
|
||||
|
||||
dev->x += x;
|
||||
dev->y -= y;
|
||||
dev->z -= z;
|
||||
#if 0
|
||||
if ((dev->mode == MODE_STREAM) && (dev->flags & FLAG_ENABLED) && (keyboard_at_mouse_pos() < 13)) {
|
||||
#else
|
||||
if ((dev->mode == MODE_STREAM) && (keyboard_at_mouse_pos() < 13)) {
|
||||
#endif
|
||||
if ((dev->mode == MODE_STREAM) && (kbc_at_dev_queue_pos(dev, 1) < 13)) {
|
||||
dev->b = b;
|
||||
|
||||
ps2_report_coordinates(dev, 0);
|
||||
ps2_report_coordinates(dev, 1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
@@ -326,11 +341,9 @@ ps2_poll(int x, int y, int z, int b, double abs_x, double abs_y, void *priv)
|
||||
void *
|
||||
mouse_ps2_init(const device_t *info)
|
||||
{
|
||||
mouse_t *dev;
|
||||
atkbc_dev_t *dev = kbc_at_dev_init(DEV_AUX);
|
||||
int i;
|
||||
|
||||
dev = (mouse_t *) malloc(sizeof(mouse_t));
|
||||
memset(dev, 0x00, sizeof(mouse_t));
|
||||
dev->name = info->name;
|
||||
dev->type = info->local;
|
||||
|
||||
@@ -338,18 +351,25 @@ mouse_ps2_init(const device_t *info)
|
||||
i = device_get_config_int("buttons");
|
||||
if (i > 2)
|
||||
dev->flags |= FLAG_INTELLI;
|
||||
if (i > 4)
|
||||
dev->flags |= FLAG_EXPLORER;
|
||||
|
||||
if (i == 4)
|
||||
if (i >= 4)
|
||||
i = 3;
|
||||
|
||||
/* Hook into the general AT Keyboard driver. */
|
||||
keyboard_at_set_mouse(ps2_write, dev);
|
||||
|
||||
mouse_ps2_log("%s: buttons=%d\n", dev->name, i);
|
||||
|
||||
/* Tell them how many buttons we have. */
|
||||
mouse_set_buttons(i);
|
||||
|
||||
dev->process_cmd = ps2_write;
|
||||
dev->execute_bat = ps2_bat;
|
||||
|
||||
dev->scan = &mouse_scan;
|
||||
|
||||
if (dev->port != NULL)
|
||||
kbc_at_dev_reset(dev, 0);
|
||||
|
||||
/* Return our private data to the I/O layer. */
|
||||
return (dev);
|
||||
}
|
||||
@@ -357,10 +377,7 @@ mouse_ps2_init(const device_t *info)
|
||||
static void
|
||||
ps2_close(void *priv)
|
||||
{
|
||||
mouse_t *dev = (mouse_t *) priv;
|
||||
|
||||
/* Unhook from the general AT Keyboard driver. */
|
||||
keyboard_at_set_mouse(NULL, NULL);
|
||||
atkbc_dev_t *dev = (atkbc_dev_t *) priv;
|
||||
|
||||
free(dev);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,14 @@
|
||||
#define BCD16(x) ((((x) / 1000) << 12) | (((x) / 100) << 8) | BCD8(x))
|
||||
#define BCD32(x) ((((x) / 10000000) << 28) | (((x) / 1000000) << 24) | (((x) / 100000) << 20) | (((x) / 10000) << 16) | BCD16(x))
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
# define UNLIKELY(x) __builtin_expect((x), 0)
|
||||
# define LIKELY(x) __builtin_expect((x), 1)
|
||||
#else
|
||||
# define UNLIKELY(x) (x)
|
||||
# define LIKELY(x) (x)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@@ -57,21 +57,24 @@
|
||||
#define CONFIG_SERPORT 12
|
||||
|
||||
enum {
|
||||
DEVICE_PCJR = 2, /* requires an IBM PCjr */
|
||||
DEVICE_AT = 4, /* requires an AT-compatible system */
|
||||
DEVICE_PS2 = 8, /* requires a PS/1 or PS/2 system */
|
||||
DEVICE_ISA = 0x10, /* requires the ISA bus */
|
||||
DEVICE_CBUS = 0x20, /* requires the C-BUS bus */
|
||||
DEVICE_MCA = 0x40, /* requires the MCA bus */
|
||||
DEVICE_EISA = 0x80, /* requires the EISA bus */
|
||||
DEVICE_VLB = 0x100, /* requires the PCI bus */
|
||||
DEVICE_PCI = 0x200, /* requires the VLB bus */
|
||||
DEVICE_AGP = 0x400, /* requires the AGP bus */
|
||||
DEVICE_AC97 = 0x800, /* requires the AC'97 bus */
|
||||
DEVICE_COM = 0x1000, /* requires a serial port */
|
||||
DEVICE_LPT = 0x2000, /* requires a parallel port */
|
||||
DEVICE_PCJR = 2, /* requires an IBM PCjr */
|
||||
DEVICE_AT = 4, /* requires an AT-compatible system */
|
||||
DEVICE_PS2 = 8, /* requires a PS/1 or PS/2 system */
|
||||
DEVICE_ISA = 0x10, /* requires the ISA bus */
|
||||
DEVICE_CBUS = 0x20, /* requires the C-BUS bus */
|
||||
DEVICE_MCA = 0x40, /* requires the MCA bus */
|
||||
DEVICE_EISA = 0x80, /* requires the EISA bus */
|
||||
DEVICE_VLB = 0x100, /* requires the PCI bus */
|
||||
DEVICE_PCI = 0x200, /* requires the VLB bus */
|
||||
DEVICE_AGP = 0x400, /* requires the AGP bus */
|
||||
DEVICE_AC97 = 0x800, /* requires the AC'97 bus */
|
||||
DEVICE_COM = 0x1000, /* requires a serial port */
|
||||
DEVICE_LPT = 0x2000, /* requires a parallel port */
|
||||
DEVICE_KBC = 0x4000, /* is a keyboard controller */
|
||||
|
||||
DEVICE_EXTPARAMS = 0x40000000 /* accepts extended parameters */
|
||||
DEVICE_EXTPARAMS = 0x40000000, /* accepts extended parameters */
|
||||
|
||||
DEVICE_ALL = 0xffffffff /* match all devices */
|
||||
};
|
||||
|
||||
#define BIOS_NORMAL 0
|
||||
@@ -171,8 +174,7 @@ extern void *device_cadd_inst_parameters(const device_t *d, const device_t *cd,
|
||||
extern void device_cadd_inst_ex(const device_t *d, const device_t *cd, void *priv, int inst);
|
||||
extern void device_cadd_inst_ex_parameters(const device_t *d, const device_t *cd, void *priv, int inst, void *params);
|
||||
extern void device_close_all(void);
|
||||
extern void device_reset_all(void);
|
||||
extern void device_reset_all_pci(void);
|
||||
extern void device_reset_all(uint32_t match_flags);
|
||||
extern void *device_get_priv(const device_t *d);
|
||||
extern int device_available(const device_t *d);
|
||||
extern int device_poll(const device_t *d, int x, int y, int z, int b);
|
||||
|
||||
@@ -30,26 +30,26 @@ typedef void *ini_t;
|
||||
typedef void *ini_section_t;
|
||||
|
||||
extern ini_t ini_new(void);
|
||||
extern ini_t ini_read(char *fn);
|
||||
extern void ini_write(ini_t ini, char *fn);
|
||||
extern ini_t ini_read(const char *fn);
|
||||
extern void ini_write(ini_t ini, const char *fn);
|
||||
extern void ini_dump(ini_t ini);
|
||||
extern void ini_close(ini_t ini);
|
||||
|
||||
extern void ini_section_delete_var(ini_section_t section, char *name);
|
||||
extern int ini_section_get_int(ini_section_t section, char *name, int def);
|
||||
extern double ini_section_get_double(ini_section_t section, char *name, double def);
|
||||
extern int ini_section_get_hex16(ini_section_t section, char *name, int def);
|
||||
extern int ini_section_get_hex20(ini_section_t section, char *name, int def);
|
||||
extern int ini_section_get_mac(ini_section_t section, char *name, int def);
|
||||
extern char *ini_section_get_string(ini_section_t section, char *name, char *def);
|
||||
extern wchar_t *ini_section_get_wstring(ini_section_t section, char *name, wchar_t *def);
|
||||
extern void ini_section_set_int(ini_section_t section, char *name, int val);
|
||||
extern void ini_section_set_double(ini_section_t section, char *name, double val);
|
||||
extern void ini_section_set_hex16(ini_section_t section, char *name, int val);
|
||||
extern void ini_section_set_hex20(ini_section_t section, char *name, int val);
|
||||
extern void ini_section_set_mac(ini_section_t section, char *name, int val);
|
||||
extern void ini_section_delete_var(ini_section_t section, const char *name);
|
||||
extern int ini_section_get_int(ini_section_t section, const char *name, int def);
|
||||
extern double ini_section_get_double(ini_section_t section, const char *name, double def);
|
||||
extern int ini_section_get_hex16(ini_section_t section, const char *name, int def);
|
||||
extern int ini_section_get_hex20(ini_section_t section, const char *name, int def);
|
||||
extern int ini_section_get_mac(ini_section_t section, const char *name, int def);
|
||||
extern char *ini_section_get_string(ini_section_t section, const char *name, char *def);
|
||||
extern wchar_t *ini_section_get_wstring(ini_section_t section, const char *name, wchar_t *def);
|
||||
extern void ini_section_set_int(ini_section_t section, const char *name, int val);
|
||||
extern void ini_section_set_double(ini_section_t section, const char *name, double val);
|
||||
extern void ini_section_set_hex16(ini_section_t section, const char *name, int val);
|
||||
extern void ini_section_set_hex20(ini_section_t section, const char *name, int val);
|
||||
extern void ini_section_set_mac(ini_section_t section, const char *name, int val);
|
||||
extern void ini_section_set_string(ini_section_t section, const char *name, const char *val);
|
||||
extern void ini_section_set_wstring(ini_section_t section, char *name, wchar_t *val);
|
||||
extern void ini_section_set_wstring(ini_section_t section, const char *name, wchar_t *val);
|
||||
|
||||
#define ini_delete_var(ini, head, name) ini_section_delete_var(ini_find_section(ini, head), name)
|
||||
|
||||
@@ -69,13 +69,13 @@ extern void ini_section_set_wstring(ini_section_t section, char *name, wchar
|
||||
#define ini_set_string(ini, head, name, val) ini_section_set_string(ini_find_or_create_section(ini, head), name, val)
|
||||
#define ini_set_wstring(ini, head, name, val) ini_section_set_wstring(ini_find_or_create_section(ini, head), name, val)
|
||||
|
||||
extern ini_section_t ini_find_section(ini_t ini, char *name);
|
||||
extern ini_section_t ini_find_or_create_section(ini_t ini, char *name);
|
||||
extern void ini_rename_section(ini_section_t section, char *name);
|
||||
extern ini_section_t ini_find_section(ini_t ini, const char *name);
|
||||
extern ini_section_t ini_find_or_create_section(ini_t ini, const char *name);
|
||||
extern void ini_rename_section(ini_section_t section, const char *name);
|
||||
extern void ini_delete_section_if_empty(ini_t ini, ini_section_t section);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -27,27 +27,33 @@ enum {
|
||||
DEV_AUX
|
||||
};
|
||||
|
||||
enum {
|
||||
DEV_STATE_MAIN_1 = 0,
|
||||
DEV_STATE_MAIN_OUT,
|
||||
DEV_STATE_MAIN_2,
|
||||
DEV_STATE_MAIN_CMD,
|
||||
DEV_STATE_MAIN_WANT_IN,
|
||||
DEV_STATE_MAIN_IN
|
||||
};
|
||||
|
||||
/* Used by the AT / PS/2 keyboard controller, common device, keyboard, and mouse. */
|
||||
typedef struct {
|
||||
uint8_t wantcmd, dat, pad, pad0;
|
||||
uint8_t wantcmd, dat;
|
||||
|
||||
int out_new;
|
||||
int16_t out_new;
|
||||
|
||||
void *priv;
|
||||
|
||||
void (*poll)(void *priv);
|
||||
} kbc_port_t;
|
||||
} kbc_at_port_t;
|
||||
|
||||
/* Used by the AT / PS/2 common device, keyboard, and mouse. */
|
||||
typedef struct {
|
||||
const char *name; /* name of this device */
|
||||
|
||||
uint8_t type, inst, command, wantdata,
|
||||
last_scan_code, state, resolution, rate,
|
||||
cmd_queue_start, cmd_queue_end, queue_start, queue_end;
|
||||
|
||||
/* 6 bytes needed for mouse */
|
||||
uint8_t last_data[6];
|
||||
uint8_t type, command, last_scan_code, state,
|
||||
resolution, rate, cmd_queue_start, cmd_queue_end,
|
||||
queue_start, queue_end;
|
||||
|
||||
uint16_t flags;
|
||||
|
||||
@@ -65,7 +71,7 @@ typedef struct {
|
||||
void (*process_cmd)(void *priv);
|
||||
void (*execute_bat)(void *priv);
|
||||
|
||||
kbc_port_t *port;
|
||||
kbc_at_port_t *port;
|
||||
} atkbc_dev_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -188,7 +194,7 @@ extern int mouse_queue_start, mouse_queue_end;
|
||||
extern int mouse_cmd_queue_start, mouse_cmd_queue_end;
|
||||
extern int mouse_scan;
|
||||
|
||||
extern kbc_port_t *kbc_ports[2];
|
||||
extern kbc_at_port_t *kbc_at_ports[2];
|
||||
|
||||
#ifdef EMU_DEVICE_H
|
||||
extern const device_t keyboard_pc_device;
|
||||
@@ -219,7 +225,6 @@ extern const device_t keyboard_ps2_ami_device;
|
||||
extern const device_t keyboard_ps2_tg_ami_device;
|
||||
extern const device_t keyboard_ps2_tg_ami_green_device;
|
||||
extern const device_t keyboard_ps2_olivetti_device;
|
||||
extern const device_t keyboard_ps2_mca_device;
|
||||
extern const device_t keyboard_ps2_mca_2_device;
|
||||
extern const device_t keyboard_ps2_quadtel_device;
|
||||
extern const device_t keyboard_ps2_pci_device;
|
||||
@@ -228,6 +233,8 @@ extern const device_t keyboard_ps2_intel_ami_pci_device;
|
||||
extern const device_t keyboard_ps2_acer_pci_device;
|
||||
extern const device_t keyboard_ps2_ali_pci_device;
|
||||
extern const device_t keyboard_ps2_tg_ami_pci_device;
|
||||
|
||||
extern const device_t keyboard_at_generic_device;
|
||||
#endif /*EMU_DEVICE_H*/
|
||||
|
||||
extern void keyboard_init(void);
|
||||
@@ -249,14 +256,10 @@ extern int keyboard_isfsexit_down(void);
|
||||
extern int keyboard_ismsexit(void);
|
||||
extern void keyboard_set_is_amstrad(int ams);
|
||||
|
||||
extern void keyboard_at_adddata_mouse(uint8_t val);
|
||||
extern void keyboard_at_adddata_mouse_cmd(uint8_t val);
|
||||
extern void keyboard_at_mouse_reset(void);
|
||||
extern uint8_t keyboard_at_mouse_pos(void);
|
||||
extern void keyboard_at_set_mouse(void (*mouse_write)(uint8_t val, void *), void *);
|
||||
extern void keyboard_at_set_a20_key(int state);
|
||||
extern void keyboard_at_reset(void);
|
||||
extern void kbc_at_a20_reset(void);
|
||||
extern uint8_t kbc_at_dev_queue_pos(atkbc_dev_t *dev, uint8_t main);
|
||||
extern void kbc_at_dev_queue_add(atkbc_dev_t *dev, uint8_t val, uint8_t main);
|
||||
extern void kbc_at_dev_reset(atkbc_dev_t *dev, int do_fa);
|
||||
extern atkbc_dev_t *kbc_at_dev_init(uint8_t inst);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -80,6 +80,8 @@ extern void mouse_poll(void);
|
||||
|
||||
extern void mouse_bus_set_irq(void *priv, int irq);
|
||||
|
||||
extern void mouse_set_sample_rate(double new_rate);
|
||||
|
||||
extern char *mouse_get_name(int mouse);
|
||||
extern char *mouse_get_internal_name(int mouse);
|
||||
extern int mouse_get_from_internal_name(char *s);
|
||||
|
||||
@@ -24,13 +24,13 @@
|
||||
|
||||
extern int sound_gain;
|
||||
|
||||
#define FREQ_44100 44100
|
||||
#define FREQ_48000 48000
|
||||
#define FREQ_49716 49716
|
||||
#define FREQ_88200 88200
|
||||
#define FREQ_96000 96000
|
||||
#define FREQ_44100 44100
|
||||
#define FREQ_48000 48000
|
||||
#define FREQ_49716 49716
|
||||
#define FREQ_88200 88200
|
||||
#define FREQ_96000 96000
|
||||
|
||||
#define SOUND_FREQ FREQ_48000
|
||||
#define SOUND_FREQ FREQ_48000
|
||||
#define SOUNDBUFLEN (SOUND_FREQ / 50)
|
||||
|
||||
#define CD_FREQ FREQ_44100
|
||||
@@ -62,7 +62,7 @@ extern const device_t *sound_card_getdevice(int card);
|
||||
#endif
|
||||
extern int sound_card_has_config(int card);
|
||||
extern char *sound_card_get_internal_name(int card);
|
||||
extern int sound_card_get_from_internal_name(char *s);
|
||||
extern int sound_card_get_from_internal_name(const char *s);
|
||||
extern void sound_card_init(void);
|
||||
extern void sound_set_cd_volume(unsigned int vol_l, unsigned int vol_r);
|
||||
|
||||
|
||||
46
src/ini.c
46
src/ini.c
@@ -101,10 +101,10 @@ ini_log(const char *fmt, ...)
|
||||
#endif
|
||||
|
||||
static section_t *
|
||||
find_section(list_t *head, char *name)
|
||||
find_section(list_t *head, const char *name)
|
||||
{
|
||||
section_t *sec = (section_t *) head->next;
|
||||
char blank[] = "";
|
||||
const char blank[] = "";
|
||||
|
||||
if (name == NULL)
|
||||
name = blank;
|
||||
@@ -120,7 +120,7 @@ find_section(list_t *head, char *name)
|
||||
}
|
||||
|
||||
ini_section_t
|
||||
ini_find_section(ini_t ini, char *name)
|
||||
ini_find_section(ini_t ini, const char *name)
|
||||
{
|
||||
if (ini == NULL)
|
||||
return NULL;
|
||||
@@ -129,7 +129,7 @@ ini_find_section(ini_t ini, char *name)
|
||||
}
|
||||
|
||||
void
|
||||
ini_rename_section(ini_section_t section, char *name)
|
||||
ini_rename_section(ini_section_t section, const char *name)
|
||||
{
|
||||
section_t *sec = (section_t *) section;
|
||||
|
||||
@@ -197,7 +197,7 @@ ini_delete_section_if_empty(ini_t ini, ini_section_t section)
|
||||
}
|
||||
|
||||
static section_t *
|
||||
create_section(list_t *head, char *name)
|
||||
create_section(list_t *head, const char *name)
|
||||
{
|
||||
section_t *ns = malloc(sizeof(section_t));
|
||||
|
||||
@@ -209,7 +209,7 @@ create_section(list_t *head, char *name)
|
||||
}
|
||||
|
||||
ini_section_t
|
||||
ini_find_or_create_section(ini_t ini, char *name)
|
||||
ini_find_or_create_section(ini_t ini, const char *name)
|
||||
{
|
||||
if (ini == NULL)
|
||||
return NULL;
|
||||
@@ -263,7 +263,7 @@ ini_close(ini_t ini)
|
||||
}
|
||||
|
||||
static int
|
||||
ini_detect_bom(char *fn)
|
||||
ini_detect_bom(const char *fn)
|
||||
{
|
||||
FILE *f;
|
||||
unsigned char bom[4] = { 0, 0, 0, 0 };
|
||||
@@ -311,7 +311,7 @@ ini_fgetws(wchar_t *str, int count, FILE *stream)
|
||||
|
||||
/* Read and parse the configuration file into memory. */
|
||||
ini_t
|
||||
ini_read(char *fn)
|
||||
ini_read(const char *fn)
|
||||
{
|
||||
char sname[128], ename[128];
|
||||
wchar_t buff[1024];
|
||||
@@ -438,7 +438,7 @@ ini_read(char *fn)
|
||||
|
||||
/* Write the in-memory configuration to disk. */
|
||||
void
|
||||
ini_write(ini_t ini, char *fn)
|
||||
ini_write(ini_t ini, const char *fn)
|
||||
{
|
||||
wchar_t wtemp[512];
|
||||
list_t *list = (list_t *) ini;
|
||||
@@ -521,7 +521,7 @@ ini_dump(ini_t ini)
|
||||
}
|
||||
|
||||
void
|
||||
ini_section_delete_var(ini_section_t self, char *name)
|
||||
ini_section_delete_var(ini_section_t self, const char *name)
|
||||
{
|
||||
section_t *section = (section_t *) self;
|
||||
entry_t *entry;
|
||||
@@ -537,7 +537,7 @@ ini_section_delete_var(ini_section_t self, char *name)
|
||||
}
|
||||
|
||||
int
|
||||
ini_section_get_int(ini_section_t self, char *name, int def)
|
||||
ini_section_get_int(ini_section_t self, const char *name, int def)
|
||||
{
|
||||
section_t *section = (section_t *) self;
|
||||
entry_t *entry;
|
||||
@@ -556,7 +556,7 @@ ini_section_get_int(ini_section_t self, char *name, int def)
|
||||
}
|
||||
|
||||
double
|
||||
ini_section_get_double(ini_section_t self, char *name, double def)
|
||||
ini_section_get_double(ini_section_t self, const char *name, double def)
|
||||
{
|
||||
section_t *section = (section_t *) self;
|
||||
entry_t *entry;
|
||||
@@ -575,7 +575,7 @@ ini_section_get_double(ini_section_t self, char *name, double def)
|
||||
}
|
||||
|
||||
int
|
||||
ini_section_get_hex16(ini_section_t self, char *name, int def)
|
||||
ini_section_get_hex16(ini_section_t self, const char *name, int def)
|
||||
{
|
||||
section_t *section = (section_t *) self;
|
||||
entry_t *entry;
|
||||
@@ -594,7 +594,7 @@ ini_section_get_hex16(ini_section_t self, char *name, int def)
|
||||
}
|
||||
|
||||
int
|
||||
ini_section_get_hex20(ini_section_t self, char *name, int def)
|
||||
ini_section_get_hex20(ini_section_t self, const char *name, int def)
|
||||
{
|
||||
section_t *section = (section_t *) self;
|
||||
entry_t *entry;
|
||||
@@ -613,7 +613,7 @@ ini_section_get_hex20(ini_section_t self, char *name, int def)
|
||||
}
|
||||
|
||||
int
|
||||
ini_section_get_mac(ini_section_t self, char *name, int def)
|
||||
ini_section_get_mac(ini_section_t self, const char *name, int def)
|
||||
{
|
||||
section_t *section = (section_t *) self;
|
||||
entry_t *entry;
|
||||
@@ -632,7 +632,7 @@ ini_section_get_mac(ini_section_t self, char *name, int def)
|
||||
}
|
||||
|
||||
char *
|
||||
ini_section_get_string(ini_section_t self, char *name, char *def)
|
||||
ini_section_get_string(ini_section_t self, const char *name, char *def)
|
||||
{
|
||||
section_t *section = (section_t *) self;
|
||||
entry_t *entry;
|
||||
@@ -648,7 +648,7 @@ ini_section_get_string(ini_section_t self, char *name, char *def)
|
||||
}
|
||||
|
||||
wchar_t *
|
||||
ini_section_get_wstring(ini_section_t self, char *name, wchar_t *def)
|
||||
ini_section_get_wstring(ini_section_t self, const char *name, wchar_t *def)
|
||||
{
|
||||
section_t *section = (section_t *) self;
|
||||
entry_t *entry;
|
||||
@@ -664,7 +664,7 @@ ini_section_get_wstring(ini_section_t self, char *name, wchar_t *def)
|
||||
}
|
||||
|
||||
void
|
||||
ini_section_set_int(ini_section_t self, char *name, int val)
|
||||
ini_section_set_int(ini_section_t self, const char *name, int val)
|
||||
{
|
||||
section_t *section = (section_t *) self;
|
||||
entry_t *ent;
|
||||
@@ -681,7 +681,7 @@ ini_section_set_int(ini_section_t self, char *name, int val)
|
||||
}
|
||||
|
||||
void
|
||||
ini_section_set_double(ini_section_t self, char *name, double val)
|
||||
ini_section_set_double(ini_section_t self, const char *name, double val)
|
||||
{
|
||||
section_t *section = (section_t *) self;
|
||||
entry_t *ent;
|
||||
@@ -698,7 +698,7 @@ ini_section_set_double(ini_section_t self, char *name, double val)
|
||||
}
|
||||
|
||||
void
|
||||
ini_section_set_hex16(ini_section_t self, char *name, int val)
|
||||
ini_section_set_hex16(ini_section_t self, const char *name, int val)
|
||||
{
|
||||
section_t *section = (section_t *) self;
|
||||
entry_t *ent;
|
||||
@@ -715,7 +715,7 @@ ini_section_set_hex16(ini_section_t self, char *name, int val)
|
||||
}
|
||||
|
||||
void
|
||||
ini_section_set_hex20(ini_section_t self, char *name, int val)
|
||||
ini_section_set_hex20(ini_section_t self, const char *name, int val)
|
||||
{
|
||||
section_t *section = (section_t *) self;
|
||||
entry_t *ent;
|
||||
@@ -732,7 +732,7 @@ ini_section_set_hex20(ini_section_t self, char *name, int val)
|
||||
}
|
||||
|
||||
void
|
||||
ini_section_set_mac(ini_section_t self, char *name, int val)
|
||||
ini_section_set_mac(ini_section_t self, const char *name, int val)
|
||||
{
|
||||
section_t *section = (section_t *) self;
|
||||
entry_t *ent;
|
||||
@@ -774,7 +774,7 @@ ini_section_set_string(ini_section_t self, const char *name, const char *val)
|
||||
}
|
||||
|
||||
void
|
||||
ini_section_set_wstring(ini_section_t self, char *name, wchar_t *val)
|
||||
ini_section_set_wstring(ini_section_t self, const char *name, wchar_t *val)
|
||||
{
|
||||
section_t *section = (section_t *) self;
|
||||
entry_t *ent;
|
||||
|
||||
25
src/io.c
25
src/io.c
@@ -56,7 +56,6 @@ typedef struct {
|
||||
int initialized = 0;
|
||||
io_t *io[NPORTS], *io_last[NPORTS];
|
||||
|
||||
// #define ENABLE_IO_LOG 1
|
||||
#ifdef ENABLE_IO_LOG
|
||||
int io_do_log = ENABLE_IO_LOG;
|
||||
|
||||
@@ -311,9 +310,7 @@ inb(uint16_t port)
|
||||
/* if (port == 0x1ed)
|
||||
ret = 0xfe; */
|
||||
|
||||
if (port == 0x92) {
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) in b(%04X) = %02X\n", CS, cpu_state.pc, in_smm, found, qfound, port, ret);
|
||||
}
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) in b(%04X) = %02X\n", CS, cpu_state.pc, in_smm, found, qfound, port, ret);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
@@ -344,9 +341,7 @@ outb(uint16_t port, uint8_t val)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (port == 0x92) {
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) outb(%04X, %02X)\n", CS, cpu_state.pc, in_smm, found, qfound, port, val);
|
||||
}
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) outb(%04X, %02X)\n", CS, cpu_state.pc, in_smm, found, qfound, port, val);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -400,9 +395,7 @@ inw(uint16_t port)
|
||||
if (!found)
|
||||
cycles -= io_delay;
|
||||
|
||||
if (port == 0x92) {
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) in w(%04X) = %04X\n", CS, cpu_state.pc, in_smm, found, qfound, port, ret);
|
||||
}
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) in w(%04X) = %04X\n", CS, cpu_state.pc, in_smm, found, qfound, port, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -447,9 +440,7 @@ outw(uint16_t port, uint16_t val)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (port == 0x92) {
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) outw(%04X, %04X)\n", CS, cpu_state.pc, in_smm, found, qfound, port, val);
|
||||
}
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) outw(%04X, %04X)\n", CS, cpu_state.pc, in_smm, found, qfound, port, val);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -531,9 +522,7 @@ inl(uint16_t port)
|
||||
if (!found)
|
||||
cycles -= io_delay;
|
||||
|
||||
if (port == 0x92) {
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) in l(%04X) = %08X\n", CS, cpu_state.pc, in_smm, found, qfound, port, ret);
|
||||
}
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) in l(%04X) = %08X\n", CS, cpu_state.pc, in_smm, found, qfound, port, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -593,9 +582,7 @@ outl(uint16_t port, uint32_t val)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (port == 0x92) {
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) outl(%04X, %08X)\n", CS, cpu_state.pc, in_smm, found, qfound, port, val);
|
||||
}
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) outl(%04X, %08X)\n", CS, cpu_state.pc, in_smm, found, qfound, port, val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -998,7 +998,7 @@ ps2_mca_board_model_55sx_init(int has_sec_nvram, int slots)
|
||||
}
|
||||
|
||||
mca_init(slots);
|
||||
device_add(&keyboard_ps2_mca_device);
|
||||
device_add(&keyboard_ps2_device);
|
||||
|
||||
if (has_sec_nvram == 1)
|
||||
device_add(&ps2_nvr_55ls_device);
|
||||
@@ -1162,7 +1162,7 @@ ps2_mca_board_model_70_type34_init(int is_type4, int slots)
|
||||
|
||||
ps2.split_addr = mem_size * 1024;
|
||||
mca_init(slots);
|
||||
device_add(&keyboard_ps2_mca_device);
|
||||
device_add(&keyboard_ps2_device);
|
||||
|
||||
ps2.planar_read = model_70_type3_read;
|
||||
ps2.planar_write = model_70_type3_write;
|
||||
@@ -1255,7 +1255,7 @@ ps2_mca_board_model_80_type2_init(int is486)
|
||||
|
||||
ps2.split_addr = mem_size * 1024;
|
||||
mca_init(8);
|
||||
device_add(&keyboard_ps2_mca_device);
|
||||
device_add(&keyboard_ps2_device);
|
||||
|
||||
ps2.planar_read = model_80_read;
|
||||
ps2.planar_write = model_80_write;
|
||||
|
||||
@@ -2898,7 +2898,7 @@ mem_remap_top(int kb)
|
||||
if (addr >= 0x000c0000)
|
||||
addr += 0x00010000;
|
||||
}
|
||||
if (start_addr != 0)
|
||||
if (start_addr == 0)
|
||||
start_addr = addr;
|
||||
pages[c].mem = set ? &ram[addr] : page_ff;
|
||||
pages[c].write_b = set ? mem_write_ramb_page : NULL;
|
||||
|
||||
@@ -922,12 +922,11 @@ trc_reset(uint8_t val)
|
||||
dma_reset();
|
||||
dma_set_at(1);
|
||||
|
||||
device_reset_all();
|
||||
device_reset_all(DEVICE_ALL);
|
||||
|
||||
cpu_alt_reset = 0;
|
||||
|
||||
pci_reset();
|
||||
keyboard_at_reset();
|
||||
|
||||
mem_a20_alt = 0;
|
||||
mem_a20_recalc();
|
||||
|
||||
@@ -202,7 +202,7 @@ find_best_interrupt(pic_t *dev)
|
||||
|
||||
intr = dev->interrupt = (ret == -1) ? 0x17 : ret;
|
||||
|
||||
if (dev->at && (ret != 1)) {
|
||||
if (dev->at && (ret != -1)) {
|
||||
if (dev == &pic2)
|
||||
intr += 8;
|
||||
|
||||
@@ -649,7 +649,7 @@ picint_common(uint16_t num, int level, int set)
|
||||
pic2.lines |= (num >> 8);
|
||||
|
||||
/* Latch IRQ 12 if the mouse latch is enabled. */
|
||||
if (mouse_latch && (num & 0x1000))
|
||||
if ((num & 0x1000) && mouse_latch)
|
||||
pic2.lines |= 0x10;
|
||||
|
||||
pic2.irr |= (num >> 8);
|
||||
|
||||
@@ -69,11 +69,18 @@ port_92_readw(uint16_t port, void *priv)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
This does the exact same thing as keyboard controller reset.
|
||||
TODO: ALi M1543(c) behavior.
|
||||
*/
|
||||
static void
|
||||
port_92_pulse(void *priv)
|
||||
{
|
||||
resetx86();
|
||||
softresetx86(); /* Pulse reset! */
|
||||
cpu_set_edx();
|
||||
flushmmucache();
|
||||
|
||||
cpu_alt_reset = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -166,6 +173,15 @@ port_92_remove(void *priv)
|
||||
port_92_readb, NULL, NULL, port_92_writeb, NULL, NULL, dev);
|
||||
}
|
||||
|
||||
static void
|
||||
port_92_reset(void *priv)
|
||||
{
|
||||
cpu_alt_reset = 0;
|
||||
|
||||
mem_a20_alt = 0x00;
|
||||
mem_a20_recalc();
|
||||
}
|
||||
|
||||
static void
|
||||
port_92_close(void *priv)
|
||||
{
|
||||
@@ -252,7 +268,7 @@ const device_t port_92_pci_device = {
|
||||
.local = PORT_92_PCI,
|
||||
.init = port_92_init,
|
||||
.close = port_92_close,
|
||||
.reset = NULL,
|
||||
.reset = port_92_reset,
|
||||
{ .available = NULL },
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
|
||||
@@ -24,11 +24,16 @@ D3D9Renderer::D3D9Renderer(QWidget *parent, int monitor_index)
|
||||
|
||||
windowHandle = (HWND) winId();
|
||||
surfaceInUse = true;
|
||||
finalized = true;
|
||||
|
||||
RendererCommon::parentWidget = parent;
|
||||
|
||||
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
this->m_monitor_index = monitor_index;
|
||||
|
||||
d3d9surface = nullptr;
|
||||
d3d9dev = nullptr;
|
||||
d3d9 = nullptr;
|
||||
}
|
||||
|
||||
D3D9Renderer::~D3D9Renderer()
|
||||
@@ -67,6 +72,7 @@ D3D9Renderer::hideEvent(QHideEvent *event)
|
||||
void
|
||||
D3D9Renderer::showEvent(QShowEvent *event)
|
||||
{
|
||||
if (d3d9) finalize();
|
||||
params = {};
|
||||
|
||||
if (FAILED(Direct3DCreate9Ex(D3D_SDK_VERSION, &d3d9))) {
|
||||
@@ -80,7 +86,7 @@ D3D9Renderer::showEvent(QShowEvent *event)
|
||||
params.BackBufferCount = 1;
|
||||
params.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
|
||||
params.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
params.hDeviceWindow = windowHandle;
|
||||
params.hDeviceWindow = (HWND) winId();
|
||||
|
||||
HRESULT result = d3d9->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, windowHandle, D3DCREATE_MULTITHREADED | D3DCREATE_HARDWARE_VERTEXPROCESSING, ¶ms, nullptr, &d3d9dev);
|
||||
if (FAILED(result))
|
||||
@@ -118,10 +124,10 @@ D3D9Renderer::paintEvent(QPaintEvent *event)
|
||||
srcRect.bottom = source.bottom();
|
||||
srcRect.left = source.left();
|
||||
srcRect.right = source.right();
|
||||
dstRect.top = destination.top();
|
||||
dstRect.bottom = destination.bottom();
|
||||
dstRect.left = destination.left();
|
||||
dstRect.right = destination.right();
|
||||
dstRect.top = destination.top() * devicePixelRatioF();
|
||||
dstRect.bottom = destination.bottom() * devicePixelRatioF();
|
||||
dstRect.left = destination.left() * devicePixelRatioF();
|
||||
dstRect.right = destination.right() * devicePixelRatioF();
|
||||
d3d9dev->BeginScene();
|
||||
d3d9dev->Clear(0, nullptr, D3DCLEAR_TARGET, 0xFF000000, 0, 0);
|
||||
while (surfaceInUse) { }
|
||||
|
||||
@@ -54,16 +54,26 @@
|
||||
<property name="text">
|
||||
<string>CD-ROM Controller:</string>
|
||||
</property>
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboBoxCDInterface"/>
|
||||
<widget class="QComboBox" name="comboBoxCDInterface">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="pushButtonCDInterface">
|
||||
<property name="text">
|
||||
<string>Configure</string>
|
||||
</property>
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
|
||||
@@ -174,6 +174,7 @@ ali5123_reset(ali5123_t *dev)
|
||||
serial_setup(dev->uart[1], 0x03e8, dev->ld_regs[5][0x70]);
|
||||
|
||||
/* Logical device 7: Keyboard */
|
||||
dev->ld_regs[7][0x30] = 1;
|
||||
dev->ld_regs[7][0x70] = 1;
|
||||
/* TODO: Register F0 bit 6: 0 = PS/2, 1 = AT */
|
||||
|
||||
@@ -253,6 +254,9 @@ ali5123_write(uint16_t port, uint8_t val, void *priv)
|
||||
case 0x06:
|
||||
case 0x08 ... 0x0a:
|
||||
return;
|
||||
case 0x07:
|
||||
if (dev->cur_reg == 0xf0)
|
||||
val &= 0xbf;
|
||||
}
|
||||
dev->ld_regs[cur_ld][dev->cur_reg] = val;
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ sound_card_get_internal_name(int card)
|
||||
}
|
||||
|
||||
int
|
||||
sound_card_get_from_internal_name(char *s)
|
||||
sound_card_get_from_internal_name(const char *s)
|
||||
{
|
||||
int c = 0;
|
||||
|
||||
|
||||
@@ -209,6 +209,9 @@ endif
|
||||
ifndef MINITRACE
|
||||
MINITRACE := n
|
||||
endif
|
||||
ifndef AVX
|
||||
AVX := n
|
||||
endif
|
||||
ifeq ($(DYNAREC), y)
|
||||
ifeq ($(ARM), y)
|
||||
ifeq ($(NEW_DYNAREC), n)
|
||||
@@ -314,7 +317,11 @@ else
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
AFLAGS := -msse2 -mfpmath=sse
|
||||
ifeq ($(AVX), y)
|
||||
AFLAGS := -msse2 -msse3 -mssse3 -msse4 -msse4a -mavx -mavx2 -mfpmath=sse
|
||||
else
|
||||
AFLAGS := -msse2 -mfpmath=sse
|
||||
endif
|
||||
ifeq ($(ARM), y)
|
||||
DFLAGS := -march=armv7-a
|
||||
AOPTIM :=
|
||||
@@ -583,11 +590,8 @@ MCHOBJ := machine.o machine_table.o \
|
||||
m_at_socket8.o m_at_slot1.o m_at_slot2.o m_at_socket370.o \
|
||||
m_at_misc.o
|
||||
|
||||
ifeq ($(NEW_KBC), y)
|
||||
KBCOBJ := kbc_at.o kbd_at.o
|
||||
else
|
||||
KBCOBJ := keyboard_at.o
|
||||
endif
|
||||
KBCOBJ := kbc_at.o kbc_at_dev.o \
|
||||
keyboard_at.o
|
||||
|
||||
DEVOBJ := bugger.o cartridge.o cassette.o hasp.o hwm.o hwm_lm75.o hwm_lm78.o hwm_gl518sm.o hwm_nsc366.o hwm_vt82c686.o \
|
||||
ibm_5161.o isamem.o isartc.o lpt.o pci_bridge.o postcard.o serial.o \
|
||||
|
||||
Reference in New Issue
Block a user