Device IRQs WIP
This commit is contained in:
@@ -49,7 +49,8 @@ struct device* device_find (const char* key) {
|
||||
}
|
||||
|
||||
struct device* device_create (const char* key, device_op_func_t* ops, size_t ops_len,
|
||||
device_init_func_t init, device_fini_func_t fini, void* arg) {
|
||||
device_init_func_t init, device_fini_func_t fini, void* arg,
|
||||
struct proc* proc, struct reschedule_ctx* rctx) {
|
||||
if (ops_len >= fieldlengthof (struct device, ops))
|
||||
return NULL;
|
||||
|
||||
@@ -67,7 +68,7 @@ struct device* device_create (const char* key, device_op_func_t* ops, size_t ops
|
||||
if (ops != NULL)
|
||||
memcpy (device->ops, ops, ops_len * sizeof (device_op_func_t));
|
||||
|
||||
if (!device->init (device, arg)) {
|
||||
if (!device->init (device, arg, proc, rctx)) {
|
||||
free (device);
|
||||
return NULL;
|
||||
}
|
||||
@@ -87,21 +88,30 @@ struct device* device_create (const char* key, device_op_func_t* ops, size_t ops
|
||||
}
|
||||
|
||||
static void debugconsole_device_init (void) {
|
||||
struct reschedule_ctx rctx;
|
||||
memset (&rctx, 0, sizeof (rctx));
|
||||
|
||||
device_op_func_t ops[] = {
|
||||
[DEBUGCONSOLE_PUTSTR] = &debugconsole_putstr,
|
||||
};
|
||||
device_create ("DEBUGCONSOLE", ops, lengthof (ops), &debugconsole_init, &debugconsole_fini, NULL);
|
||||
device_create ("DEBUGCONSOLE", ops, lengthof (ops), &debugconsole_init, &debugconsole_fini, NULL, thiscpu->kproc, &rctx);
|
||||
}
|
||||
|
||||
static void terminal_device_init (void) {
|
||||
struct reschedule_ctx rctx;
|
||||
memset (&rctx, 0, sizeof (rctx));
|
||||
|
||||
device_op_func_t ops[] = {
|
||||
[TERMINAL_PUTSTR] = &terminal_putstr,
|
||||
[TERMINAL_DIMENSIONS] = &terminal_dimensions,
|
||||
};
|
||||
device_create ("TERMINAL", ops, lengthof (ops), &terminal_init, &terminal_fini, NULL);
|
||||
device_create ("TERMINAL", ops, lengthof (ops), &terminal_init, &terminal_fini, NULL, thiscpu->kproc, &rctx);
|
||||
}
|
||||
|
||||
static void ramdisk_device_init (void) {
|
||||
struct reschedule_ctx rctx;
|
||||
memset (&rctx, 0, sizeof (rctx));
|
||||
|
||||
device_op_func_t ops[] = {
|
||||
[XDRV_GET_SIZE] = &ramdrv_get_size,
|
||||
[XDRV_GET_SECTOR_SIZE] = &ramdrv_get_sector_size,
|
||||
@@ -139,12 +149,15 @@ static void ramdisk_device_init (void) {
|
||||
.sector_size = 512,
|
||||
.buffer = unpack_buffer,
|
||||
};
|
||||
device_create ("RD0", ops, lengthof (ops), &ramdrv_init, &ramdrv_fini, &init);
|
||||
device_create ("RD0", ops, lengthof (ops), &ramdrv_init, &ramdrv_fini, &init, thiscpu->kproc, &rctx);
|
||||
|
||||
LZ4F_freeDecompressionContext (dctx);
|
||||
}
|
||||
|
||||
static void temp_device_init (void) {
|
||||
struct reschedule_ctx rctx;
|
||||
memset (&rctx, 0, sizeof (rctx));
|
||||
|
||||
device_op_func_t ops[] = {
|
||||
[XDRV_GET_SIZE] = &ramdrv_get_size,
|
||||
[XDRV_GET_SECTOR_SIZE] = &ramdrv_get_sector_size,
|
||||
@@ -157,15 +170,18 @@ static void temp_device_init (void) {
|
||||
.total_size = 1024 * 1024 * 20,
|
||||
.sector_size = 512,
|
||||
};
|
||||
device_create ("TEMP0", ops, lengthof (ops), &ramdrv_init, &ramdrv_fini, &init);
|
||||
device_create ("TEMP0", ops, lengthof (ops), &ramdrv_init, &ramdrv_fini, &init, thiscpu->kproc, &rctx);
|
||||
}
|
||||
|
||||
#if defined(__x86_64__)
|
||||
static void ps2kb_device_init (void) {
|
||||
struct reschedule_ctx rctx;
|
||||
memset (&rctx, 0, sizeof (rctx));
|
||||
|
||||
device_op_func_t ops[] = {
|
||||
[KB_READ_KEY] = &ps2kb_read_key,
|
||||
};
|
||||
device_create ("KB", ops, lengthof (ops), &ps2kb_init, &ps2kb_fini, NULL);
|
||||
device_create ("KB", ops, lengthof (ops), &ps2kb_init, &ps2kb_fini, NULL, thiscpu->kproc, &rctx);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user