Spinlock save cpu flags
This commit is contained in:
@@ -148,14 +148,15 @@ static int32_t ps2kb_keycode (void) {
|
||||
|
||||
static void ps2kb_irq (void* arg, void* regs, struct reschedule_ctx* rctx) {
|
||||
(void)arg, (void)regs;
|
||||
uint64_t frb, fsq;
|
||||
|
||||
int32_t keycode = ps2kb_keycode ();
|
||||
|
||||
if (keycode <= 0 || keycode == 0xFA)
|
||||
return;
|
||||
|
||||
spin_lock (&ps2kb_ringbuffer_lock);
|
||||
spin_lock (&ps2kb_sq.lock);
|
||||
spin_lock (&ps2kb_ringbuffer_lock, &frb);
|
||||
spin_lock (&ps2kb_sq.lock, &fsq);
|
||||
|
||||
ringbuffer_push (uint8_t, &ps2kb_ringbuffer, (uint8_t)keycode);
|
||||
|
||||
@@ -165,20 +166,21 @@ static void ps2kb_irq (void* arg, void* regs, struct reschedule_ctx* rctx) {
|
||||
struct proc_sq_entry* sq_entry = list_entry (node, struct proc_sq_entry, sq_link);
|
||||
struct proc* resumed_proc = sq_entry->proc;
|
||||
|
||||
spin_unlock (&ps2kb_sq.lock);
|
||||
spin_unlock (&ps2kb_ringbuffer_lock);
|
||||
spin_unlock (&ps2kb_sq.lock, fsq);
|
||||
spin_unlock (&ps2kb_ringbuffer_lock, frb);
|
||||
|
||||
proc_sq_resume (resumed_proc, sq_entry, rctx);
|
||||
return;
|
||||
}
|
||||
|
||||
spin_unlock (&ps2kb_sq.lock);
|
||||
spin_unlock (&ps2kb_ringbuffer_lock);
|
||||
spin_unlock (&ps2kb_sq.lock, fsq);
|
||||
spin_unlock (&ps2kb_ringbuffer_lock, frb);
|
||||
}
|
||||
|
||||
int ps2kb_read_key (struct device* device, struct proc* proc, struct reschedule_ctx* rctx, void* a1,
|
||||
void* a2, void* a3, void* a4) {
|
||||
(void)device, (void)a2, (void)a3, (void)a4;
|
||||
uint64_t frb, fsq;
|
||||
|
||||
if (!(proc->procgroup->capabilities & PROC_CAP_KB))
|
||||
return -ST_PERMISSION_ERROR;
|
||||
@@ -188,7 +190,7 @@ int ps2kb_read_key (struct device* device, struct proc* proc, struct reschedule_
|
||||
if (chbuf == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
|
||||
spin_lock (&ps2kb_ringbuffer_lock);
|
||||
spin_lock (&ps2kb_ringbuffer_lock, &frb);
|
||||
|
||||
size_t prev_count = ps2kb_ringbuffer.count;
|
||||
|
||||
@@ -198,21 +200,21 @@ int ps2kb_read_key (struct device* device, struct proc* proc, struct reschedule_
|
||||
|
||||
/* didn't pop anything */
|
||||
if (prev_count == new_count) {
|
||||
spin_lock (&ps2kb_sq.lock);
|
||||
spin_lock (&ps2kb_sq.lock, &fsq);
|
||||
struct list_node_link* node = ps2kb_sq.proc_list;
|
||||
spin_unlock (&ps2kb_sq.lock);
|
||||
spin_unlock (&ps2kb_sq.lock, fsq);
|
||||
|
||||
if (node != NULL) {
|
||||
spin_unlock (&ps2kb_ringbuffer_lock);
|
||||
spin_unlock (&ps2kb_ringbuffer_lock, frb);
|
||||
return -ST_PERMISSION_ERROR;
|
||||
}
|
||||
|
||||
proc_sq_suspend (proc, &ps2kb_sq, &ps2kb_ringbuffer_lock, rctx);
|
||||
proc_sq_suspend (proc, &ps2kb_sq, &ps2kb_ringbuffer_lock, frb, rctx);
|
||||
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
spin_unlock (&ps2kb_ringbuffer_lock);
|
||||
spin_unlock (&ps2kb_ringbuffer_lock, frb);
|
||||
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user