Rearchitecture PS2KB driver using event buffers
This commit is contained in:
@ -21,12 +21,8 @@ void tb_runinitscript(void) {
|
||||
r = ipcpipe(tb, IPCPIPE_OUT, IPCPIPE_READ, (uint8_t *)buf, sizeof(buf)-1);
|
||||
if (r > 0) {
|
||||
devctl(&termdev, DEV_TERMDEV_PUTCH, (uint8_t *)buf, string_len(buf), 0);
|
||||
}
|
||||
|
||||
r = devctl(&ps2kbdev, DEV_PS2KBDEV_READCH, NULL, 0, 0);
|
||||
if (r != E_NOTYET) {
|
||||
uint8_t b = r;
|
||||
ipcpipe(tb, IPCPIPE_IN, IPCPIPE_WRITE, &b, 1);
|
||||
} else {
|
||||
schedrelease();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -34,6 +30,7 @@ void tb_runinitscript(void) {
|
||||
void main(void) {
|
||||
PID = (uint64_t)processctl(-1, PCTL_GETPID, 0, 0, 0);
|
||||
devctl(&ps2kbdev, DEVCTL_GET_HANDLE, (uint8_t *)"ps2kbdev", 0, 0);
|
||||
devctl(&ps2kbdev, DEV_PS2KBDEV_ATTCHCONS, (uint8_t *)PID, 0, 0);
|
||||
|
||||
tb_runinitscript();
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#define LINEBUF_MAX 1024
|
||||
|
||||
PID_t PID;
|
||||
Dev_t ps2kbdev;
|
||||
|
||||
struct {
|
||||
char *modestr;
|
||||
@ -106,8 +107,9 @@ void do_mode_interactive(void) {
|
||||
|
||||
uint8_t b = 0;
|
||||
for (;;) {
|
||||
int32_t nrd = ipcpipe(PID, IPCPIPE_IN, IPCPIPE_READ, &b, 1);
|
||||
if (nrd > 0) {
|
||||
int32_t key = devctl(&ps2kbdev, DEV_PS2KBDEV_READCH, (uint8_t *)PID, 0, 0);
|
||||
if (key > 0) {
|
||||
b = (uint8_t)key;
|
||||
switch (b) {
|
||||
case C('C'):
|
||||
case 0xE9:
|
||||
@ -155,6 +157,8 @@ void main(void) {
|
||||
}
|
||||
|
||||
if (CONFIG.mode == MODE_INTERACTIVE) {
|
||||
devctl(&ps2kbdev, DEVCTL_GET_HANDLE, (uint8_t *)"ps2kbdev", 0, 0);
|
||||
devctl(&ps2kbdev, DEV_PS2KBDEV_ATTCHCONS, (uint8_t *)PID, 0, 0);
|
||||
do_mode_interactive();
|
||||
} else if (CONFIG.mode == MODE_RUNFILE) {
|
||||
if (CONFIG.filepath == NULL) {
|
||||
|
Reference in New Issue
Block a user