suspension queue resume process with value
This commit is contained in:
@@ -154,17 +154,19 @@ static void ps2kb_irq(void* arg, void* regs, bool user, struct reschedule_ctx* r
|
||||
if (keycode <= 0 || keycode == 0xFA)
|
||||
return;
|
||||
|
||||
ringbuffer_push(uint8_t, &ps2kb_ringbuffer, (uint8_t)keycode);
|
||||
|
||||
struct list_node_link* node = ps2kb_sq.proc_list;
|
||||
|
||||
if (node != NULL) {
|
||||
struct proc_sq_entry* sq_entry = list_entry(node, struct proc_sq_entry, sq_link);
|
||||
struct proc* resumed_proc = sq_entry->proc;
|
||||
|
||||
proc_sq_resume(resumed_proc, sq_entry, rctx);
|
||||
*(uint8_t*)sq_entry->udata = (uint8_t)keycode;
|
||||
|
||||
proc_sq_resume(resumed_proc, sq_entry, rctx, ST_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
ringbuffer_push(uint8_t, &ps2kb_ringbuffer, (uint8_t)keycode);
|
||||
}
|
||||
|
||||
DEFINE_DEVICE_OP(ps2kb_read_key) {
|
||||
@@ -173,25 +175,13 @@ DEFINE_DEVICE_OP(ps2kb_read_key) {
|
||||
if (chbuf == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
|
||||
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) {
|
||||
struct list_node_link* node = ps2kb_sq.proc_list;
|
||||
|
||||
if (node != NULL) {
|
||||
return -ST_PERMISSION_ERROR;
|
||||
}
|
||||
|
||||
proc_sq_suspend(proc, &ps2kb_sq, rctx, NULL, NULL);
|
||||
|
||||
if (ps2kb_ringbuffer.count == 0) {
|
||||
proc_sq_suspend(proc, &ps2kb_sq, rctx, chbuf, NULL);
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
ringbuffer_pop(uint8_t, &ps2kb_ringbuffer, chbuf);
|
||||
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user