Line 22... |
Line 22... |
#include <string.h>
|
#include <string.h>
|
#include "ps2kbd.h"
|
#include "ps2kbd.h"
|
#include "sim-config.h"
|
#include "sim-config.h"
|
#include "abstract.h"
|
#include "abstract.h"
|
#include "sched.h"
|
#include "sched.h"
|
|
#include "pic.h"
|
|
|
/* ASCII to scan code conversion table */
|
/* ASCII to scan code conversion table */
|
const static struct {
|
const static struct {
|
/* Whether shift must be pressed */
|
/* Whether shift must be pressed */
|
unsigned char shift;
|
unsigned char shift;
|
Line 128... |
Line 129... |
if (kbd_ccmd == KBD_CCMD_DKI)
|
if (kbd_ccmd == KBD_CCMD_DKI)
|
kbd_ccmdbyte |= KBD_CCMDBYTE_EN;
|
kbd_ccmdbyte |= KBD_CCMDBYTE_EN;
|
if (kbd_ccmd == KBD_CCMD_EKI)
|
if (kbd_ccmd == KBD_CCMD_EKI)
|
kbd_ccmdbyte &= ~KBD_CCMDBYTE_EN;
|
kbd_ccmdbyte &= ~KBD_CCMDBYTE_EN;
|
if (config.sim.verbose)
|
if (config.sim.verbose)
|
PRINTF("kbd_write8(%x) %x\n", addr, value);
|
PRINTF("kbd_write8(%lx) %lx\n", addr, value);
|
break;
|
break;
|
case KBD_DATA:
|
case KBD_DATA:
|
if (kbd_ccmd == KBD_CCMD_WCB) {
|
if (kbd_ccmd == KBD_CCMD_WCB) {
|
kbd_ccmdbyte = value & 0xff;
|
kbd_ccmdbyte = value & 0xff;
|
kbd_ccmd = 0x00;
|
kbd_ccmd = 0x00;
|
Line 143... |
Line 144... |
if (kbd_kcmd == KBD_KCMD_EK)
|
if (kbd_kcmd == KBD_KCMD_EK)
|
kbd_ccmdbyte &= ~KBD_CCMDBYTE_EN;
|
kbd_ccmdbyte &= ~KBD_CCMDBYTE_EN;
|
kbd_kresp = 0x1;
|
kbd_kresp = 0x1;
|
kbd_ccmd = 0x00;
|
kbd_ccmd = 0x00;
|
if (config.sim.verbose)
|
if (config.sim.verbose)
|
PRINTF("kbd_write8(%x) %x\n", addr, value);
|
PRINTF("kbd_write8(%lx) %lx\n", addr, value);
|
break;
|
break;
|
default:
|
default:
|
fprintf (stderr, "Write out of keyboard space (0x%08x)!\n", addr);
|
fprintf (stderr, "Write out of keyboard space (0x%08lx)!\n", addr);
|
runtime.sim.cont_run = 0;
|
runtime.sim.cont_run = 0;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
|
|
Line 164... |
Line 165... |
if (kbd_kresp || kbd_buf_count)
|
if (kbd_kresp || kbd_buf_count)
|
c |= KBD_STATUS_OBF;
|
c |= KBD_STATUS_OBF;
|
c |= kbd_ccmdbyte & KBD_CCMDBYTE_SYS;
|
c |= kbd_ccmdbyte & KBD_CCMDBYTE_SYS;
|
c |= KBD_STATUS_INH;
|
c |= KBD_STATUS_INH;
|
if (config.sim.verbose)
|
if (config.sim.verbose)
|
PRINTF("kbd_read8(%x) %x\n", addr, c);
|
PRINTF("kbd_read8(%lx) %lx\n", addr, c);
|
return c;
|
return c;
|
}
|
}
|
case KBD_DATA:
|
case KBD_DATA:
|
if (kbd_ccmd) {
|
if (kbd_ccmd) {
|
unsigned long rc;
|
unsigned long rc;
|
Line 179... |
Line 180... |
if (kbd_ccmd == KBD_CCMD_ST2)
|
if (kbd_ccmd == KBD_CCMD_ST2)
|
rc = 0x00;
|
rc = 0x00;
|
kbd_ccmd = 0x00;
|
kbd_ccmd = 0x00;
|
kbd_kresp = 0x0;
|
kbd_kresp = 0x0;
|
if (config.sim.verbose)
|
if (config.sim.verbose)
|
PRINTF("kbd_read8(%x) %x\n", addr, rc);
|
PRINTF("kbd_read8(%lx) %lx\n", addr, rc);
|
return rc;
|
return rc;
|
}
|
}
|
else if (kbd_kresp) {
|
else if (kbd_kresp) {
|
unsigned long rc;
|
unsigned long rc;
|
if (kbd_kresp == 0x2) {
|
if (kbd_kresp == 0x2) {
|
Line 199... |
Line 200... |
kbd_kresp = 0x0;
|
kbd_kresp = 0x0;
|
rc = KBD_KRESP_ACK;
|
rc = KBD_KRESP_ACK;
|
}
|
}
|
kbd_kcmd = 0x00;
|
kbd_kcmd = 0x00;
|
if (config.sim.verbose)
|
if (config.sim.verbose)
|
PRINTF("kbd_read8(%x) %x\n", addr, rc);
|
PRINTF("kbd_read8(%lx) %lx\n", addr, rc);
|
return rc;
|
return rc;
|
} else if (kbd_buf_count) {
|
} else if (kbd_buf_count) {
|
unsigned long c = kbd_buf[kbd_buf_tail];
|
unsigned long c = kbd_buf[kbd_buf_tail];
|
kbd_buf_tail = (kbd_buf_tail + 1) % KBD_MAX_BUF;
|
kbd_buf_tail = (kbd_buf_tail + 1) % KBD_MAX_BUF;
|
kbd_buf_count--;
|
kbd_buf_count--;
|
kbd_kresp = 0x0;
|
kbd_kresp = 0x0;
|
if (config.sim.verbose)
|
if (config.sim.verbose)
|
PRINTF("kbd_read8(%x) %x\n", addr, c);
|
PRINTF("kbd_read8(%lx) %lx\n", addr, c);
|
return c;
|
return c;
|
}
|
}
|
kbd_kresp = 0x0;
|
kbd_kresp = 0x0;
|
if (config.sim.verbose)
|
if (config.sim.verbose)
|
PRINTF("kbd_read8(%x) fifo empty\n", addr);
|
PRINTF("kbd_read8(%lx) fifo empty\n", addr);
|
return 0;
|
return 0;
|
default:
|
default:
|
fprintf (stderr, "Read out of keyboard space (0x%08x)!\n", addr);
|
fprintf (stderr, "Read out of keyboard space (0x%08lx)!\n", addr);
|
runtime.sim.cont_run = 0;
|
runtime.sim.cont_run = 0;
|
return 0;
|
return 0;
|
}
|
}
|
}
|
}
|
|
|
Line 234... |
Line 235... |
scan_decode (c);
|
scan_decode (c);
|
}
|
}
|
kbd_int = kbd_kresp || kbd_buf_count;
|
kbd_int = kbd_kresp || kbd_buf_count;
|
kbd_int = kbd_kresp || kbd_buf_count ? kbd_ccmdbyte & KBD_CCMDBYTE_INT : 0;
|
kbd_int = kbd_kresp || kbd_buf_count ? kbd_ccmdbyte & KBD_CCMDBYTE_INT : 0;
|
if (config.sim.verbose && kbd_int)
|
if (config.sim.verbose && kbd_int)
|
PRINTF("Keyboard Interrupt.... kbd_kresp %x kbd_buf_count %x \n", kbd_kresp, kbd_buf_count);
|
PRINTF("Keyboard Interrupt.... kbd_kresp %lx kbd_buf_count %lx \n",
|
|
kbd_kresp, kbd_buf_count);
|
if (kbd_int) report_interrupt(config.kbd.irq);
|
if (kbd_int) report_interrupt(config.kbd.irq);
|
SCHED_ADD(kbd_job, 0, runtime.sim.cycles + kbd_slowdown);
|
SCHED_ADD(kbd_job, 0, runtime.sim.cycles + kbd_slowdown);
|
}
|
}
|
|
|
/* Reset all VGAs */
|
/* Reset all VGAs */
|
Line 267... |
Line 269... |
void kbd_info()
|
void kbd_info()
|
{
|
{
|
PRINTF("kbd_kcmd: %x\n", kbd_kcmd);
|
PRINTF("kbd_kcmd: %x\n", kbd_kcmd);
|
PRINTF("kbd_ccmd: %x\n", kbd_ccmd);
|
PRINTF("kbd_ccmd: %x\n", kbd_ccmd);
|
PRINTF("kbd_ccmdbyte: %x\n", kbd_ccmdbyte);
|
PRINTF("kbd_ccmdbyte: %x\n", kbd_ccmdbyte);
|
PRINTF("kbd_kresp: %x\n", kbd_kresp);
|
PRINTF("kbd_kresp: %lx\n", kbd_kresp);
|
PRINTF("kbd_buf_count: %x\n", kbd_buf_count);
|
PRINTF("kbd_buf_count: %lx\n", kbd_buf_count);
|
}
|
}
|
|
|
No newline at end of file
|
No newline at end of file
|