CE process watching WIP
This commit is contained in:
@@ -188,6 +188,7 @@ static void ps2kb_device_init (void) {
|
||||
|
||||
device_op_func_t ops[] = {
|
||||
[KB_READ_KEY] = &ps2kb_read_key,
|
||||
[KB_READ_KEY_NONBLOCK] = &ps2kb_read_key_nonblock,
|
||||
};
|
||||
device_create ("kb", ops, lengthof (ops), &ps2kb_init, &ps2kb_fini, NULL, thiscpu->kproc, &rctx);
|
||||
}
|
||||
|
||||
@@ -213,6 +213,33 @@ DEFINE_DEVICE_OP (ps2kb_read_key) {
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
DEFINE_DEVICE_OP (ps2kb_read_key_nonblock) {
|
||||
uint64_t frb, fsq;
|
||||
|
||||
uint8_t* chbuf = (uint8_t*)a1;
|
||||
|
||||
if (chbuf == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
|
||||
spin_lock (&ps2kb_ringbuffer_lock, &frb);
|
||||
|
||||
size_t prev_count = ps2kb_ringbuffer.count;
|
||||
|
||||
ringbuffer_pop (uint8_t, &ps2kb_ringbuffer, chbuf);
|
||||
|
||||
size_t new_count = ps2kb_ringbuffer.count;
|
||||
|
||||
/* didn't pop anything */
|
||||
if (prev_count == new_count) {
|
||||
spin_unlock (&ps2kb_ringbuffer_lock, frb);
|
||||
return -ST_TRY_AGAIN;
|
||||
}
|
||||
|
||||
spin_unlock (&ps2kb_ringbuffer_lock, frb);
|
||||
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
static void ps2kb_set_typematic (uint8_t delay, uint8_t rate) {
|
||||
while (inb (KB_CTL_STATUS) & 0x02)
|
||||
;
|
||||
|
||||
@@ -11,6 +11,8 @@ struct device;
|
||||
|
||||
DEFINE_DEVICE_OP (ps2kb_read_key);
|
||||
|
||||
DEFINE_DEVICE_OP (ps2kb_read_key_nonblock);
|
||||
|
||||
DEFINE_DEVICE_INIT (ps2kb_init);
|
||||
|
||||
DEFINE_DEVICE_FINI (ps2kb_fini);
|
||||
|
||||
Reference in New Issue
Block a user