CE process watching WIP

This commit is contained in:
2026-03-18 15:30:41 +01:00
parent 76b1533ad0
commit 77ab25bcee
18 changed files with 110 additions and 39 deletions

View File

@@ -27,9 +27,11 @@ uintptr_t syscall_dispatch (void* stack_ptr) {
spin_lock (&thiscpu->lock, &fc);
struct proc* caller = thiscpu->proc_current;
int caller_pid = caller->pid;
spin_lock (&caller->lock, &fp);
int caller_pid = caller->pid;
memcpy (&caller->pdata.regs, regs, sizeof (struct saved_regs));
fx_save (caller->pdata.fx_env);

View File

@@ -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);
}

View File

@@ -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)
;

View File

@@ -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);