Redesign reschedule points, allow one operation to reschedule many cpus at once
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m12s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m12s
This commit is contained in:
@@ -1,22 +1,18 @@
|
||||
#ifndef _KERNEL_DEVICE_DEVICE_H
|
||||
#define _KERNEL_DEVICE_DEVICE_H
|
||||
|
||||
#include <libk/list.h>
|
||||
#include <libk/rbtree.h>
|
||||
#include <libk/std.h>
|
||||
#include <proc/proc.h>
|
||||
#include <proc/reschedule.h>
|
||||
#include <sync/spin_lock.h>
|
||||
#include <sys/smp.h>
|
||||
|
||||
struct device;
|
||||
|
||||
struct device_op_ctx {
|
||||
struct proc* proc;
|
||||
struct cpu** reschedule_cpu;
|
||||
bool* reschedule;
|
||||
};
|
||||
|
||||
typedef int (*device_op_func_t) (struct device* device, struct device_op_ctx* op_ctx, void* a1,
|
||||
void* a2, void* a3, void* a4);
|
||||
typedef int (*device_op_func_t) (struct device* device, struct proc*, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
typedef bool (*device_init_func_t) (struct device* device, void* arg);
|
||||
typedef void (*device_fini_func_t) (struct device* device);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <m/status.h>
|
||||
#include <proc/capability.h>
|
||||
#include <proc/proc.h>
|
||||
#include <proc/reschedule.h>
|
||||
#include <proc/suspension_q.h>
|
||||
#include <sync/spin_lock.h>
|
||||
#include <sys/debug.h>
|
||||
@@ -165,13 +166,13 @@ static int32_t ps2kb_keycode (void) {
|
||||
return c;
|
||||
}
|
||||
|
||||
static bool ps2kb_irq (struct cpu** reschedule_cpu, void* arg, void* regs) {
|
||||
static void ps2kb_irq (void* arg, void* regs, struct reschedule_ctx* rctx) {
|
||||
(void)arg, (void)regs;
|
||||
|
||||
int32_t keycode = ps2kb_keycode ();
|
||||
|
||||
if (keycode <= 0)
|
||||
return PROC_NO_RESCHEDULE;
|
||||
return;
|
||||
|
||||
spin_lock (&ps2kb_ringbuffer_lock);
|
||||
spin_lock (&ps2kb_sq.lock);
|
||||
@@ -187,20 +188,19 @@ static bool ps2kb_irq (struct cpu** reschedule_cpu, void* arg, void* regs) {
|
||||
spin_unlock (&ps2kb_sq.lock);
|
||||
spin_unlock (&ps2kb_ringbuffer_lock);
|
||||
|
||||
return proc_sq_resume (resumed_proc, sq_entry, reschedule_cpu);
|
||||
proc_sq_resume (resumed_proc, sq_entry, rctx);
|
||||
return;
|
||||
}
|
||||
|
||||
spin_unlock (&ps2kb_sq.lock);
|
||||
spin_unlock (&ps2kb_ringbuffer_lock);
|
||||
|
||||
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) {
|
||||
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;
|
||||
|
||||
if ((op_ctx->proc != NULL) && !(op_ctx->proc->procgroup->capabilities & PROC_CAP_KB))
|
||||
if (!(proc->procgroup->capabilities & PROC_CAP_KB))
|
||||
return -ST_PERMISSION_ERROR;
|
||||
|
||||
uint8_t* chbuf = (uint8_t*)a1;
|
||||
@@ -224,8 +224,7 @@ int ps2kb_read_key (struct device* device, struct device_op_ctx* op_ctx, void* a
|
||||
return -ST_PERMISSION_ERROR;
|
||||
}
|
||||
|
||||
*op_ctx->reschedule =
|
||||
proc_sq_suspend (op_ctx->proc, &ps2kb_sq, &ps2kb_ringbuffer_lock, op_ctx->reschedule_cpu);
|
||||
proc_sq_suspend (proc, &ps2kb_sq, &ps2kb_ringbuffer_lock, rctx);
|
||||
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
#ifndef _KERNEL_DEVICE_PS2_KB_H
|
||||
#define _KERNEL_DEVICE_PS2_KB_H
|
||||
|
||||
#include <libk/list.h>
|
||||
#include <libk/std.h>
|
||||
#include <proc/proc.h>
|
||||
#include <proc/reschedule.h>
|
||||
|
||||
struct device;
|
||||
struct device_op_ctx;
|
||||
|
||||
int ps2kb_read_key (struct device* device, struct device_op_ctx* op_ctx, void* a1, void* a2,
|
||||
void* a3, void* a4);
|
||||
int ps2kb_read_key (struct device* device, struct proc* proc, struct reschedule_ctx* rctx, void* a1,
|
||||
void* a2, void* a3, void* a4);
|
||||
|
||||
bool ps2kb_init (struct device* device, void* arg);
|
||||
|
||||
void ps2kb_fini (struct device* device);
|
||||
|
||||
#endif // _KERNEL_DEVICE_PS2_KB_H
|
||||
|
||||
@@ -43,9 +43,9 @@ void ramdrv_fini (struct device* device) {
|
||||
free (ramdrv);
|
||||
}
|
||||
|
||||
int ramdrv_get_device_type (struct device* device, struct device_op_ctx* op_ctx, void* a1, void* a2,
|
||||
void* a3, void* a4) {
|
||||
(void)device, (void)a2, (void)a3, (void)a4, (void)op_ctx;
|
||||
int ramdrv_get_device_type (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;
|
||||
|
||||
if (a1 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
@@ -57,9 +57,9 @@ int ramdrv_get_device_type (struct device* device, struct device_op_ctx* op_ctx,
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
int ramdrv_get_size (struct device* device, struct device_op_ctx* op_ctx, void* a1, void* a2,
|
||||
void* a3, void* a4) {
|
||||
(void)a2, (void)a3, (void)a4, (void)op_ctx;
|
||||
int ramdrv_get_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)a2, (void)a3, (void)a4;
|
||||
|
||||
if (a1 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
@@ -73,9 +73,9 @@ int ramdrv_get_size (struct device* device, struct device_op_ctx* op_ctx, void*
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
int ramdrv_get_sector_size (struct device* device, struct device_op_ctx* op_ctx, void* a1, void* a2,
|
||||
void* a3, void* a4) {
|
||||
(void)a2, (void)a3, (void)a4, (void)op_ctx;
|
||||
int ramdrv_get_sector_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)a2, (void)a3, (void)a4;
|
||||
|
||||
if (a1 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
@@ -89,9 +89,9 @@ int ramdrv_get_sector_size (struct device* device, struct device_op_ctx* op_ctx,
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
int ramdrv_read (struct device* device, struct device_op_ctx* op_ctx, void* a1, void* a2, void* a3,
|
||||
void* a4) {
|
||||
(void)op_ctx, (void)a4;
|
||||
int ramdrv_read (struct device* device, struct proc* proc, struct reschedule_ctx* rctx, void* a1,
|
||||
void* a2, void* a3, void* a4) {
|
||||
(void)a4;
|
||||
|
||||
if (a1 == NULL || a2 == NULL || a3 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
#ifndef _KERNEL_DEVICE_RAMDRV_H
|
||||
#define _KERNEL_DEVICE_RAMDRV_H
|
||||
|
||||
#include <libk/list.h>
|
||||
#include <libk/std.h>
|
||||
#include <proc/proc.h>
|
||||
#include <proc/reschedule.h>
|
||||
|
||||
struct device;
|
||||
struct device_op_ctx;
|
||||
@@ -23,16 +26,16 @@ bool ramdrv_init (struct device* device, void* arg);
|
||||
|
||||
void ramdrv_fini (struct device* device);
|
||||
|
||||
int ramdrv_read (struct device* device, struct device_op_ctx* op_ctx, void* a1, void* a2, void* a3,
|
||||
void* a4);
|
||||
int ramdrv_read (struct device* device, struct proc* proc, struct reschedule_ctx* rctx, void* a1,
|
||||
void* a2, void* a3, void* a4);
|
||||
|
||||
int ramdrv_get_device_type (struct device* device, struct device_op_ctx* op_ctx, void* a1, void* a2,
|
||||
void* a3, void* a4);
|
||||
int ramdrv_get_device_type (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
int ramdrv_get_sector_size (struct device* device, struct device_op_ctx* op_ctx, void* a1, void* a2,
|
||||
void* a3, void* a4);
|
||||
int ramdrv_get_sector_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
int ramdrv_get_size (struct device* device, struct device_op_ctx* op_ctx, void* a1, void* a2,
|
||||
void* a3, void* a4);
|
||||
int ramdrv_get_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
#endif // _KERNEL_DEVICE_RAMDRV_H
|
||||
|
||||
@@ -35,11 +35,11 @@ bool terminal_init (struct device* device, void* arg) {
|
||||
|
||||
void terminal_fini (struct device* device) { (void)device; }
|
||||
|
||||
int terminal_putstr (struct device* device, struct device_op_ctx* op_ctx, void* a1, void* a2,
|
||||
void* a3, void* a4) {
|
||||
int terminal_putstr (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)a2, (void)a3, (void)a4, (void)device;
|
||||
|
||||
if ((op_ctx->proc != NULL) && !(op_ctx->proc->procgroup->capabilities & PROC_CAP_TERMINAL))
|
||||
if (!(proc->procgroup->capabilities & PROC_CAP_TERMINAL))
|
||||
return -ST_PERMISSION_ERROR;
|
||||
|
||||
char* string = (char*)a1;
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
#ifndef _KERNEL_DEVICE_TERMINAL_H
|
||||
#define _KERNEL_DEVICE_TERMINAL_H
|
||||
|
||||
#include <libk/list.h>
|
||||
#include <libk/std.h>
|
||||
#include <proc/proc.h>
|
||||
#include <proc/reschedule.h>
|
||||
|
||||
struct device;
|
||||
struct device_op_ctx;
|
||||
|
||||
bool terminal_init (struct device* device, void* arg);
|
||||
|
||||
void terminal_fini (struct device* device);
|
||||
int terminal_putstr (struct device* device, struct device_op_ctx* op_ctx, void* a1, void* a2,
|
||||
void* a3, void* a4);
|
||||
|
||||
int terminal_putstr (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
#endif // _KERNEL_DEVICE_TERMINAL_H
|
||||
|
||||
Reference in New Issue
Block a user