VFS mountpoint backing device system
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m24s

This commit is contained in:
2026-02-16 23:48:45 +01:00
parent 7726fd2f00
commit 9aea870159
22 changed files with 528 additions and 241 deletions

View File

@@ -1,6 +1,8 @@
#include <amd64/apic.h>
#include <amd64/intr_defs.h>
#include <amd64/io.h>
#include <device/device.h>
#include <device/ps2_kb.h>
#include <irq/irq.h>
#include <libk/ringbuffer.h>
#include <libk/std.h>
@@ -126,7 +128,7 @@ static uint8_t ctlmap[256] = {
/* clang-format on */
};
int32_t ps2kb_keycode (void) {
static int32_t ps2kb_keycode (void) {
static uint8_t shift;
static uint8_t* charcode[4] = {normalmap, shiftmap, ctlmap, ctlmap};
uint32_t st, data, c;
@@ -163,7 +165,7 @@ int32_t ps2kb_keycode (void) {
return c;
}
bool ps2kb_irq (struct cpu** reschedule_cpu, void* arg, void* regs) {
static bool ps2kb_irq (struct cpu** reschedule_cpu, void* arg, void* regs) {
int32_t keycode = ps2kb_keycode ();
if (keycode <= 0)
@@ -192,12 +194,12 @@ bool ps2kb_irq (struct cpu** reschedule_cpu, void* arg, void* regs) {
return PROC_NO_RESCHEDULE;
}
bool ps2kb_read_key (struct proc* proc, struct cpu** reschedule_cpu, int* ret, void* a1, void* a2,
void* a3, void* a4) {
if (!(proc->procgroup->capabilities & PROC_CAP_KB)) {
*ret = -ST_PERMISSION_ERROR;
return PROC_NO_RESCHEDULE;
}
int ps2kb_read_key (struct device* device, struct device_op_ctx* op_ctx, void* a1, void* a2,
void* a3, void* a4) {
(void)device;
if ((op_ctx->proc != NULL) && !(op_ctx->proc->procgroup->capabilities & PROC_CAP_KB))
return -ST_PERMISSION_ERROR;
uint8_t* chbuf = (uint8_t*)a1;
@@ -209,18 +211,21 @@ bool ps2kb_read_key (struct proc* proc, struct cpu** reschedule_cpu, int* ret, v
size_t new_count = ps2kb_ringbuffer.count;
*ret = ST_OK;
/* didn't pop anything */
if (prev_count == new_count)
return proc_sq_suspend (proc, &ps2kb_sq, &ps2kb_ringbuffer_lock, reschedule_cpu);
if (prev_count == new_count) {
*op_ctx->reschedule =
proc_sq_suspend (op_ctx->proc, &ps2kb_sq, &ps2kb_ringbuffer_lock, op_ctx->reschedule_cpu);
return ST_OK;
}
spin_unlock (&ps2kb_ringbuffer_lock);
return PROC_NO_RESCHEDULE;
return ST_OK;
}
bool ps2kb_init (void* arg) {
bool ps2kb_init (struct device* device, void* arg) {
(void)device;
amd64_ioapic_route_irq (PS2KB, 1, 0, thiscpu->lapic_id);
irq_attach (&ps2kb_irq, NULL, PS2KB);
@@ -241,7 +246,9 @@ bool ps2kb_init (void* arg) {
return true;
}
void ps2kb_fini (void) {
void ps2kb_fini (struct device* device) {
(void)device;
irq_detach (PS2KB);
ringbuffer_fini (&ps2kb_ringbuffer);
}