Use macro wrappers for device op prototypes
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m35s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m35s
This commit is contained in:
@@ -61,8 +61,6 @@ void debugprintf (const char* fmt, ...) {
|
||||
}
|
||||
|
||||
void debugprintf_nolock (const char* fmt, ...) {
|
||||
uint64_t f1;
|
||||
|
||||
if (!debug_is_init)
|
||||
return;
|
||||
|
||||
|
||||
@@ -6,19 +6,14 @@
|
||||
#include <status.h>
|
||||
#include <sys/debug.h>
|
||||
|
||||
bool debugconsole_init (struct device* device, void* arg, struct proc* proc,
|
||||
struct reschedule_ctx* rctx) {
|
||||
DEFINE_DEVICE_INIT (debugconsole_init) {
|
||||
(void)device, (void)arg, (void)proc, (void)rctx;
|
||||
return true;
|
||||
}
|
||||
|
||||
void debugconsole_fini (struct device* device, struct proc* proc, struct reschedule_ctx* rctx) {
|
||||
(void)device, (void)proc, (void)rctx;
|
||||
}
|
||||
DEFINE_DEVICE_FINI (debugconsole_fini) {}
|
||||
|
||||
int debugconsole_putstr (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)a2, (void)a3, (void)a4, (void)device, (void)rctx;
|
||||
DEFINE_DEVICE_OP (debugconsole_putstr) {
|
||||
uint64_t fp;
|
||||
|
||||
char* string = (char*)a1;
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
#ifndef _KERNEL_DEVICE_DEBUGCONSOLE_H
|
||||
#define _KERNEL_DEVICE_DEBUGCONSOLE_H
|
||||
|
||||
#include <device/def_device_op.h>
|
||||
#include <libk/std.h>
|
||||
#include <proc/proc.h>
|
||||
#include <proc/reschedule.h>
|
||||
|
||||
struct device;
|
||||
|
||||
bool debugconsole_init (struct device* device, void* arg, struct proc* proc,
|
||||
struct reschedule_ctx* rctx);
|
||||
DEFINE_DEVICE_OP (debugconsole_putstr);
|
||||
|
||||
void debugconsole_fini (struct device* device, struct proc* proc, struct reschedule_ctx* rctx);
|
||||
DEFINE_DEVICE_INIT (debugconsole_init);
|
||||
|
||||
int debugconsole_putstr (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
DEFINE_DEVICE_FINI (debugconsole_fini);
|
||||
|
||||
#endif // _KERNEL_DEVICE_DEBUGCONSOLE_H
|
||||
|
||||
19
kernel/device/def_device_op.h
Normal file
19
kernel/device/def_device_op.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef _KERNEL_DEVICE_DEF_DEVICE_OP_H
|
||||
#define _KERNEL_DEVICE_DEF_DEVICE_OP_H
|
||||
|
||||
#include <aux/compiler.h>
|
||||
|
||||
#define DEFINE_DEVICE_OP(name) \
|
||||
int name (struct device* UNUSED device, struct proc* UNUSED proc, \
|
||||
struct reschedule_ctx* UNUSED rctx, uint64_t* UNUSED lockflags, void* UNUSED a1, \
|
||||
void* UNUSED a2, void* UNUSED a3, void* UNUSED a4)
|
||||
|
||||
#define DEFINE_DEVICE_INIT(name) \
|
||||
bool name (struct device* UNUSED device, void* UNUSED arg, struct proc* UNUSED proc, \
|
||||
struct reschedule_ctx* UNUSED rctx)
|
||||
|
||||
#define DEFINE_DEVICE_FINI(name) \
|
||||
void name (struct device* UNUSED device, struct proc* UNUSED proc, \
|
||||
struct reschedule_ctx* UNUSED rctx)
|
||||
|
||||
#endif // _KERNEL_DEVICE_DEF_DEVICE_OP_H
|
||||
@@ -88,7 +88,9 @@ static void ide_delay (uint16_t ctrl) {
|
||||
#pragma clang optimize on
|
||||
|
||||
static void ide_irq (void* arg, void* regs, bool user, struct reschedule_ctx* rctx) {
|
||||
uint64_t fd, fp;
|
||||
(void)user, (void)regs, (void)rctx;
|
||||
|
||||
uint64_t fd;
|
||||
|
||||
struct idedrv* idedrv = arg;
|
||||
|
||||
@@ -229,10 +231,7 @@ static void ide_prepare (struct idedrv* idedrv, size_t sector, uint16_t sector_c
|
||||
}
|
||||
}
|
||||
|
||||
bool idedrv_init (struct device* device, void* arg, struct proc* proc,
|
||||
struct reschedule_ctx* rctx) {
|
||||
(void)proc, (void)rctx;
|
||||
|
||||
DEFINE_DEVICE_INIT (idedrv_init) {
|
||||
struct idedrv_init* init = arg;
|
||||
|
||||
struct idedrv* idedrv = malloc (sizeof (*idedrv));
|
||||
@@ -259,7 +258,7 @@ bool idedrv_init (struct device* device, void* arg, struct proc* proc,
|
||||
return true;
|
||||
}
|
||||
|
||||
void idedrv_fini (struct device* device, struct proc* proc, struct reschedule_ctx* rctx) {
|
||||
DEFINE_DEVICE_FINI (idedrv_fini) {
|
||||
struct idedrv* idedrv = device->udata;
|
||||
|
||||
if (idedrv->current_req != NULL) {
|
||||
@@ -273,10 +272,7 @@ void idedrv_fini (struct device* device, struct proc* proc, struct reschedule_ct
|
||||
free (idedrv);
|
||||
}
|
||||
|
||||
int idedrv_read (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a4;
|
||||
|
||||
DEFINE_DEVICE_OP (idedrv_read) {
|
||||
if (a1 == NULL || a2 == NULL || a3 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
|
||||
@@ -337,11 +333,7 @@ int idedrv_read (struct device* device, struct proc* proc, struct reschedule_ctx
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
int idedrv_write (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a4;
|
||||
uint64_t fp;
|
||||
|
||||
DEFINE_DEVICE_OP (idedrv_write) {
|
||||
if (a1 == NULL || a2 == NULL || a3 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
|
||||
@@ -429,9 +421,8 @@ int idedrv_write (struct device* device, struct proc* proc, struct reschedule_ct
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
int idedrv_get_device_type (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)device, (void)a2, (void)a3, (void)a4;
|
||||
DEFINE_DEVICE_OP (idedrv_get_device_type) {
|
||||
(void)proc, (void)rctx, (void)device, (void)a2, (void)a3, (void)a4, (void)lockflags;
|
||||
|
||||
if (a1 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
@@ -443,9 +434,8 @@ int idedrv_get_device_type (struct device* device, struct proc* proc, struct res
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
int idedrv_get_sector_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a2, (void)a3, (void)a4;
|
||||
DEFINE_DEVICE_OP (idedrv_get_sector_size) {
|
||||
(void)proc, (void)rctx, (void)a2, (void)a3, (void)a4, (void)lockflags;
|
||||
|
||||
if (a1 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
@@ -459,9 +449,8 @@ int idedrv_get_sector_size (struct device* device, struct proc* proc, struct res
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
int idedrv_get_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a2, (void)a3, (void)a4;
|
||||
DEFINE_DEVICE_OP (idedrv_get_size) {
|
||||
(void)proc, (void)rctx, (void)a2, (void)a3, (void)a4, (void)lockflags;
|
||||
|
||||
if (a1 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef _KERNEL_DEVICE_IDEDRV_H
|
||||
#define _KERNEL_DEVICE_IDEDRV_H
|
||||
|
||||
#include <device/def_device_op.h>
|
||||
#include <libk/list.h>
|
||||
#include <libk/std.h>
|
||||
#include <proc/proc.h>
|
||||
@@ -53,24 +54,19 @@ struct ide_probe {
|
||||
bool irqs_support;
|
||||
};
|
||||
|
||||
bool idedrv_init (struct device* device, void* arg, struct proc* proc, struct reschedule_ctx* rctx);
|
||||
DEFINE_DEVICE_INIT (idedrv_init);
|
||||
|
||||
void idedrv_fini (struct device* device, struct proc* proc, struct reschedule_ctx* rctx);
|
||||
DEFINE_DEVICE_FINI (idedrv_fini);
|
||||
|
||||
int idedrv_read (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
DEFINE_DEVICE_OP (idedrv_read);
|
||||
|
||||
int idedrv_write (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
DEFINE_DEVICE_OP (idedrv_write);
|
||||
|
||||
int idedrv_get_device_type (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
DEFINE_DEVICE_OP (idedrv_get_device_type);
|
||||
|
||||
int idedrv_get_sector_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
DEFINE_DEVICE_OP (idedrv_get_sector_size);
|
||||
|
||||
int idedrv_get_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
DEFINE_DEVICE_OP (idedrv_get_size);
|
||||
|
||||
void ide_probe (uint16_t io, uint16_t ctrl, uint8_t devno, struct ide_probe* probe);
|
||||
|
||||
|
||||
@@ -7,10 +7,7 @@
|
||||
#include <proc/reschedule.h>
|
||||
#include <status.h>
|
||||
|
||||
bool partdrv_init (struct device* device, void* arg, struct proc* proc,
|
||||
struct reschedule_ctx* rctx) {
|
||||
(void)proc, (void)rctx;
|
||||
|
||||
DEFINE_DEVICE_INIT (partdrv_init) {
|
||||
struct partdrv_init* init = arg;
|
||||
|
||||
struct partdrv* partdrv = malloc (sizeof (*partdrv));
|
||||
@@ -27,16 +24,13 @@ bool partdrv_init (struct device* device, void* arg, struct proc* proc,
|
||||
return true;
|
||||
}
|
||||
|
||||
void partdrv_fini (struct device* device, struct proc* proc, struct reschedule_ctx* rctx) {
|
||||
(void)proc, (void)rctx;
|
||||
DEFINE_DEVICE_FINI (partdrv_fini) {
|
||||
struct partdrv* partdrv = device->udata;
|
||||
|
||||
free (partdrv);
|
||||
}
|
||||
|
||||
int partdrv_read (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a4;
|
||||
DEFINE_DEVICE_OP (partdrv_read) {
|
||||
uint64_t fs;
|
||||
|
||||
if (a1 == NULL || a2 == NULL || a3 == NULL)
|
||||
@@ -56,9 +50,7 @@ int partdrv_read (struct device* device, struct proc* proc, struct reschedule_ct
|
||||
return ret;
|
||||
}
|
||||
|
||||
int partdrv_write (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a4;
|
||||
DEFINE_DEVICE_OP (partdrv_write) {
|
||||
uint64_t fs;
|
||||
|
||||
if (a1 == NULL || a2 == NULL || a3 == NULL)
|
||||
@@ -78,10 +70,7 @@ int partdrv_write (struct device* device, struct proc* proc, struct reschedule_c
|
||||
return ret;
|
||||
}
|
||||
|
||||
int partdrv_get_device_type (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)device, (void)a2, (void)a3, (void)a4;
|
||||
|
||||
DEFINE_DEVICE_OP (partdrv_get_device_type) {
|
||||
if (a1 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
|
||||
@@ -92,9 +81,7 @@ int partdrv_get_device_type (struct device* device, struct proc* proc, struct re
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
int partdrv_get_sector_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a2, (void)a3, (void)a4;
|
||||
DEFINE_DEVICE_OP (partdrv_get_sector_size) {
|
||||
uint64_t fs;
|
||||
|
||||
if (a1 == NULL)
|
||||
@@ -111,10 +98,7 @@ int partdrv_get_sector_size (struct device* device, struct proc* proc, struct re
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
int partdrv_get_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a2, (void)a3, (void)a4;
|
||||
|
||||
DEFINE_DEVICE_OP (partdrv_get_size) {
|
||||
if (a1 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef _KERNEL_DEVICE_PARTDRV_H
|
||||
#define _KERNEL_DEVICE_PARTDRV_H
|
||||
|
||||
#include <device/def_device_op.h>
|
||||
#include <libk/std.h>
|
||||
#include <proc/proc.h>
|
||||
#include <proc/reschedule.h>
|
||||
@@ -19,24 +20,18 @@ struct partdrv {
|
||||
size_t total_size;
|
||||
};
|
||||
|
||||
bool partdrv_init (struct device* device, void* arg, struct proc* proc,
|
||||
struct reschedule_ctx* rctx);
|
||||
DEFINE_DEVICE_INIT (partdrv_init);
|
||||
|
||||
void partdrv_fini (struct device* device, struct proc* proc, struct reschedule_ctx* rctx);
|
||||
DEFINE_DEVICE_FINI (partdrv_fini);
|
||||
|
||||
int partdrv_read (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
DEFINE_DEVICE_OP (partdrv_read);
|
||||
|
||||
int partdrv_write (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
DEFINE_DEVICE_OP (partdrv_write);
|
||||
|
||||
int partdrv_get_device_type (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
DEFINE_DEVICE_OP (partdrv_get_device_type);
|
||||
|
||||
int partdrv_get_sector_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
DEFINE_DEVICE_OP (partdrv_get_sector_size);
|
||||
|
||||
int partdrv_get_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
DEFINE_DEVICE_OP (partdrv_get_size);
|
||||
|
||||
#endif // _KERNEL_DEVICE_PARTDRV_H
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include <sys/debug.h>
|
||||
|
||||
static int ide_counter = 0;
|
||||
/* static bool ide_legacy_claimed = false; */
|
||||
|
||||
static const char* progif_msg[] = {
|
||||
[0x00] = "ISA Compatibility mode-only controller",
|
||||
|
||||
@@ -147,7 +147,7 @@ static int32_t ps2kb_keycode (void) {
|
||||
}
|
||||
|
||||
static void ps2kb_irq (void* arg, void* regs, bool user, struct reschedule_ctx* rctx) {
|
||||
(void)arg, (void)regs;
|
||||
(void)arg, (void)regs, (void)user;
|
||||
uint64_t frb, fsq;
|
||||
|
||||
int32_t keycode = ps2kb_keycode ();
|
||||
@@ -177,9 +177,7 @@ static void ps2kb_irq (void* arg, void* regs, bool user, struct reschedule_ctx*
|
||||
spin_unlock (&ps2kb_ringbuffer_lock, frb);
|
||||
}
|
||||
|
||||
int ps2kb_read_key (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)device, (void)a2, (void)a3, (void)a4;
|
||||
DEFINE_DEVICE_OP (ps2kb_read_key) {
|
||||
uint64_t frb, fsq;
|
||||
|
||||
if (!(proc->procgroup->capabilities & PROC_CAP_KB))
|
||||
@@ -231,9 +229,7 @@ static void ps2kb_set_typematic (uint8_t delay, uint8_t rate) {
|
||||
outb (KB_DATA, (delay << 5) | (rate & 0x1F));
|
||||
}
|
||||
|
||||
bool ps2kb_init (struct device* device, void* arg, struct proc* proc, struct reschedule_ctx* rctx) {
|
||||
(void)device, (void)arg, (void)proc, (void)rctx;
|
||||
|
||||
DEFINE_DEVICE_INIT (ps2kb_init) {
|
||||
ioapic_route_irq (PS2KB, 1, 0, thiscpu->lapic_id);
|
||||
irq_attach (&ps2kb_irq, NULL, PS2KB);
|
||||
|
||||
@@ -257,7 +253,7 @@ bool ps2kb_init (struct device* device, void* arg, struct proc* proc, struct res
|
||||
return true;
|
||||
}
|
||||
|
||||
void ps2kb_fini (struct device* device, struct proc* proc, struct reschedule_ctx* rctx) {
|
||||
DEFINE_DEVICE_FINI (ps2kb_fini) {
|
||||
(void)device, (void)proc, (void)rctx;
|
||||
|
||||
irq_detach (PS2KB);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef _KERNEL_DEVICE_PS2_KB_H
|
||||
#define _KERNEL_DEVICE_PS2_KB_H
|
||||
|
||||
#include <device/def_device_op.h>
|
||||
#include <libk/list.h>
|
||||
#include <libk/std.h>
|
||||
#include <proc/proc.h>
|
||||
@@ -8,11 +9,10 @@
|
||||
|
||||
struct device;
|
||||
|
||||
int ps2kb_read_key (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
DEFINE_DEVICE_OP (ps2kb_read_key);
|
||||
|
||||
bool ps2kb_init (struct device* device, void* arg, struct proc* proc, struct reschedule_ctx* rctx);
|
||||
DEFINE_DEVICE_INIT (ps2kb_init);
|
||||
|
||||
void ps2kb_fini (struct device* device, struct proc* proc, struct reschedule_ctx* rctx);
|
||||
DEFINE_DEVICE_FINI (ps2kb_fini);
|
||||
|
||||
#endif // _KERNEL_DEVICE_PS2_KB_H
|
||||
|
||||
@@ -9,9 +9,7 @@
|
||||
#include <status.h>
|
||||
#include <sys/debug.h>
|
||||
|
||||
bool ramdrv_init (struct device* device, void* arg, struct proc* proc,
|
||||
struct reschedule_ctx* rctx) {
|
||||
(void)proc, (void)rctx;
|
||||
DEFINE_DEVICE_INIT (ramdrv_init) {
|
||||
struct ramdrv_init* init = arg;
|
||||
|
||||
struct ramdrv* ramdrv = malloc (sizeof (*ramdrv));
|
||||
@@ -39,19 +37,14 @@ bool ramdrv_init (struct device* device, void* arg, struct proc* proc,
|
||||
return true;
|
||||
}
|
||||
|
||||
void ramdrv_fini (struct device* device, struct proc* proc, struct reschedule_ctx* rctx) {
|
||||
(void)proc, (void)rctx;
|
||||
|
||||
DEFINE_DEVICE_FINI (ramdrv_fini) {
|
||||
struct ramdrv* ramdrv = device->udata;
|
||||
|
||||
free (ramdrv->buffer);
|
||||
free (ramdrv);
|
||||
}
|
||||
|
||||
int ramdrv_get_device_type (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)device, (void)a2, (void)a3, (void)a4;
|
||||
|
||||
DEFINE_DEVICE_OP (ramdrv_get_device_type) {
|
||||
if (a1 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
|
||||
@@ -62,10 +55,7 @@ int ramdrv_get_device_type (struct device* device, struct proc* proc, struct res
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
int ramdrv_get_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a2, (void)a3, (void)a4;
|
||||
|
||||
DEFINE_DEVICE_OP (ramdrv_get_size) {
|
||||
if (a1 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
|
||||
@@ -78,10 +68,7 @@ int ramdrv_get_size (struct device* device, struct proc* proc, struct reschedule
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
int ramdrv_get_sector_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a2, (void)a3, (void)a4;
|
||||
|
||||
DEFINE_DEVICE_OP (ramdrv_get_sector_size) {
|
||||
if (a1 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
|
||||
@@ -94,10 +81,7 @@ int ramdrv_get_sector_size (struct device* device, struct proc* proc, struct res
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
int ramdrv_read (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a4;
|
||||
|
||||
DEFINE_DEVICE_OP (ramdrv_read) {
|
||||
if (a1 == NULL || a2 == NULL || a3 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
|
||||
@@ -114,10 +98,7 @@ int ramdrv_read (struct device* device, struct proc* proc, struct reschedule_ctx
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
int ramdrv_write (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a4;
|
||||
|
||||
DEFINE_DEVICE_OP (ramdrv_write) {
|
||||
if (a1 == NULL || a2 == NULL || a3 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef _KERNEL_DEVICE_RAMDRV_H
|
||||
#define _KERNEL_DEVICE_RAMDRV_H
|
||||
|
||||
#include <device/def_device_op.h>
|
||||
#include <libk/list.h>
|
||||
#include <libk/std.h>
|
||||
#include <proc/proc.h>
|
||||
@@ -20,23 +21,18 @@ struct ramdrv {
|
||||
uint8_t* buffer;
|
||||
};
|
||||
|
||||
bool ramdrv_init (struct device* device, void* arg, struct proc* proc, struct reschedule_ctx* rctx);
|
||||
DEFINE_DEVICE_INIT (ramdrv_init);
|
||||
|
||||
void ramdrv_fini (struct device* device, struct proc* proc, struct reschedule_ctx* rctx);
|
||||
DEFINE_DEVICE_FINI (ramdrv_fini);
|
||||
|
||||
int ramdrv_read (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
DEFINE_DEVICE_OP (ramdrv_read);
|
||||
|
||||
int ramdrv_write (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
DEFINE_DEVICE_OP (ramdrv_write);
|
||||
|
||||
int ramdrv_get_device_type (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
DEFINE_DEVICE_OP (ramdrv_get_device_type);
|
||||
|
||||
int ramdrv_get_sector_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
DEFINE_DEVICE_OP (ramdrv_get_sector_size);
|
||||
|
||||
int ramdrv_get_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
DEFINE_DEVICE_OP (ramdrv_get_size);
|
||||
|
||||
#endif // _KERNEL_DEVICE_RAMDRV_H
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <Flanterm/src/flanterm.h>
|
||||
#include <Flanterm/src/flanterm_backends/fb.h>
|
||||
#include <device/def_device_op.h>
|
||||
#include <device/device.h>
|
||||
#include <device/terminal.h>
|
||||
#include <libk/std.h>
|
||||
@@ -19,10 +20,7 @@ void ft_free (void* ptr, size_t size) {
|
||||
free (ptr);
|
||||
}
|
||||
|
||||
bool terminal_init (struct device* device, void* arg, struct proc* proc,
|
||||
struct reschedule_ctx* rctx) {
|
||||
(void)arg, (void)device, (void)proc, (void)rctx;
|
||||
|
||||
DEFINE_DEVICE_INIT (terminal_init) {
|
||||
struct limine_framebuffer_response* fb_r = limine_framebuffer_request.response;
|
||||
struct limine_framebuffer* fb = fb_r->framebuffers[0];
|
||||
|
||||
@@ -34,14 +32,9 @@ bool terminal_init (struct device* device, void* arg, struct proc* proc,
|
||||
return true;
|
||||
}
|
||||
|
||||
void terminal_fini (struct device* device, struct proc* proc, struct reschedule_ctx* rctx) {
|
||||
(void)device, (void)proc, (void)rctx;
|
||||
}
|
||||
|
||||
int terminal_putstr (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)a2, (void)a3, (void)a4, (void)device, (void)rctx;
|
||||
DEFINE_DEVICE_FINI (terminal_fini) {}
|
||||
|
||||
DEFINE_DEVICE_OP (terminal_putstr) {
|
||||
if (!(proc->procgroup->capabilities & PROC_CAP_TERMINAL))
|
||||
return -ST_PERMISSION_ERROR;
|
||||
|
||||
@@ -56,10 +49,7 @@ int terminal_putstr (struct device* device, struct proc* proc, struct reschedule
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
int terminal_dimensions (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a3, (void)a4, (void)device;
|
||||
|
||||
DEFINE_DEVICE_OP (terminal_dimensions) {
|
||||
if (a1 == NULL || a2 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef _KERNEL_DEVICE_TERMINAL_H
|
||||
#define _KERNEL_DEVICE_TERMINAL_H
|
||||
|
||||
#include <device/def_device_op.h>
|
||||
#include <libk/list.h>
|
||||
#include <libk/std.h>
|
||||
#include <proc/proc.h>
|
||||
@@ -8,15 +9,12 @@
|
||||
|
||||
struct device;
|
||||
|
||||
bool terminal_init (struct device* device, void* arg, struct proc* proc,
|
||||
struct reschedule_ctx* rctx);
|
||||
DEFINE_DEVICE_INIT (terminal_init);
|
||||
|
||||
void terminal_fini (struct device* device, struct proc* proc, struct reschedule_ctx* rctx);
|
||||
DEFINE_DEVICE_FINI (terminal_fini);
|
||||
|
||||
int terminal_putstr (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
DEFINE_DEVICE_OP (terminal_putstr);
|
||||
|
||||
int terminal_dimensions (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
DEFINE_DEVICE_OP (terminal_dimensions);
|
||||
|
||||
#endif // _KERNEL_DEVICE_TERMINAL_H
|
||||
|
||||
Reference in New Issue
Block a user