Line 21... |
Line 21... |
#include <stdio.h>
|
#include <stdio.h>
|
#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"
|
|
|
/* 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 78... |
Line 79... |
static unsigned char kbd_ccmdbyte;
|
static unsigned char kbd_ccmdbyte;
|
|
|
/* Keyboard response pending */
|
/* Keyboard response pending */
|
static unsigned long kbd_kresp;
|
static unsigned long kbd_kresp;
|
|
|
|
/* Keyboard slowdown factor */
|
|
static long kbd_slowdown;
|
|
|
static void kbd_put (unsigned char c)
|
static void kbd_put (unsigned char c)
|
{
|
{
|
if (kbd_buf_count >= KBD_MAX_BUF) {
|
if (kbd_buf_count >= KBD_MAX_BUF) {
|
fprintf (stderr, "WARNING: Keyboard buffer overflow.\n");
|
fprintf (stderr, "WARNING: Keyboard buffer overflow.\n");
|
} else {
|
} else {
|
Line 217... |
Line 221... |
cont_run = 0;
|
cont_run = 0;
|
return 0;
|
return 0;
|
}
|
}
|
}
|
}
|
|
|
|
|
|
/* Simulation hook. Must be called every couple of clock cycles to simulate incomming data. */
|
|
void kbd_job(int param)
|
|
{
|
|
int c;
|
|
int kbd_int = 0;
|
|
/* Check if there is something waiting, and decode it into kdb_buf */
|
|
if((c = fgetc(kbd_rxfs)) != EOF) {
|
|
scan_decode (c);
|
|
}
|
|
kbd_int = kbd_kresp || kbd_buf_count;
|
|
kbd_int = kbd_kresp || kbd_buf_count ? kbd_ccmdbyte & KBD_CCMDBYTE_INT : 0;
|
|
if (config.sim.verbose && kbd_int)
|
|
printf("Keyboard Interrupt.... kbd_kresp %x kbd_buf_count %x \n", kbd_kresp, kbd_buf_count);
|
|
if (kbd_int) report_interrupt(config.kbd.irq);
|
|
SCHED_ADD(kbd_job, 0, cycles + kbd_slowdown);
|
|
}
|
|
|
/* Reset all VGAs */
|
/* Reset all VGAs */
|
void kbd_reset ()
|
void kbd_reset ()
|
{
|
{
|
if (config.kbd.enabled) {
|
if (config.kbd.enabled) {
|
kbd_buf_count = 0;
|
kbd_buf_count = 0;
|
Line 233... |
Line 255... |
if (!(kbd_rxfs = fopen(config.kbd.rxfile, "r"))
|
if (!(kbd_rxfs = fopen(config.kbd.rxfile, "r"))
|
&& !(kbd_rxfs = fopen(config.kbd.rxfile, "r+"))) {
|
&& !(kbd_rxfs = fopen(config.kbd.rxfile, "r+"))) {
|
fprintf (stderr, "WARNING: Keyboard has problems with RX file stream.\n");
|
fprintf (stderr, "WARNING: Keyboard has problems with RX file stream.\n");
|
config.kbd.enabled = 0;
|
config.kbd.enabled = 0;
|
}
|
}
|
|
kbd_slowdown = (long) ((config.sim.system_kfreq * 1000.) / KBD_BAUD_RATE);
|
|
if (kbd_slowdown <= 0) kbd_slowdown = 1;
|
|
if (config.kbd.enabled) SCHED_ADD(kbd_job, 0, cycles + kbd_slowdown);
|
}
|
}
|
}
|
}
|
|
|
|
|
void kbd_info()
|
void kbd_info()
|
Line 246... |
Line 271... |
printf("kbd_ccmdbyte: %x\n", kbd_ccmdbyte);
|
printf("kbd_ccmdbyte: %x\n", kbd_ccmdbyte);
|
printf("kbd_kresp: %x\n", kbd_kresp);
|
printf("kbd_kresp: %x\n", kbd_kresp);
|
printf("kbd_buf_count: %x\n", kbd_buf_count);
|
printf("kbd_buf_count: %x\n", kbd_buf_count);
|
}
|
}
|
|
|
/* Simulation hook. Must be called every clock cycle to simulate incomming data. */
|
|
void kbd_clock()
|
|
{
|
|
int c;
|
|
int kbd_int = 0;
|
|
/* Check if there is something waiting, and decode it into kdb_buf */
|
|
if((c = fgetc(kbd_rxfs)) != EOF) {
|
|
scan_decode (c);
|
|
}
|
|
kbd_int = kbd_kresp || kbd_buf_count;
|
|
kbd_int = kbd_kresp || kbd_buf_count ? kbd_ccmdbyte & KBD_CCMDBYTE_INT : 0;
|
|
if (config.sim.verbose && kbd_int)
|
|
printf("Keyboard Interrupt.... kbd_kresp %x kbd_buf_count %x \n", kbd_kresp, kbd_buf_count);
|
|
if (kbd_int) report_interrupt(config.kbd.irq);
|
|
}
|
|
|
|
No newline at end of file
|
No newline at end of file
|