IDE interrupt based driver
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m36s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m36s
This commit is contained in:
@@ -62,6 +62,10 @@ void bootmain (void) {
|
||||
|
||||
bsp_cpu->kproc = kproc_create ();
|
||||
|
||||
lapic_init (1000);
|
||||
|
||||
__asm__ volatile ("sti");
|
||||
|
||||
devices_init ();
|
||||
vfs_init ();
|
||||
|
||||
|
||||
@@ -106,6 +106,8 @@ static void smp_bootstrap (struct limine_mp_info* mp_info) {
|
||||
|
||||
cpu->kproc = kproc_create ();
|
||||
|
||||
__asm__ volatile ("sti");
|
||||
|
||||
struct reschedule_ctx rctx;
|
||||
memset (&rctx, 0, sizeof (rctx));
|
||||
|
||||
@@ -118,8 +120,6 @@ static void smp_bootstrap (struct limine_mp_info* mp_info) {
|
||||
|
||||
/// Initialize SMP subsystem for AMD64. Start AP CPUs
|
||||
void smp_init (void) {
|
||||
lapic_init (1000);
|
||||
|
||||
struct limine_mp_response* mp = limine_mp_request.response;
|
||||
|
||||
cpu_counter = mp->cpu_count - 1;
|
||||
|
||||
@@ -17,7 +17,7 @@ void debugconsole_fini (struct device* device, struct proc* proc, struct resched
|
||||
}
|
||||
|
||||
int debugconsole_putstr (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4) {
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)a2, (void)a3, (void)a4, (void)device, (void)rctx;
|
||||
uint64_t fp;
|
||||
|
||||
|
||||
@@ -13,6 +13,6 @@ bool debugconsole_init (struct device* device, void* arg, struct proc* proc,
|
||||
void debugconsole_fini (struct device* device, struct proc* proc, struct reschedule_ctx* rctx);
|
||||
|
||||
int debugconsole_putstr (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4);
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
#endif // _KERNEL_DEVICE_DEBUGCONSOLE_H
|
||||
|
||||
@@ -11,16 +11,16 @@
|
||||
|
||||
#define DEVICES_MAX 1024
|
||||
|
||||
#define device_op1(d, op, proc, rctx, a1, a2, a3, a4, ...) \
|
||||
(d)->ops[(op)]((d), (proc), (rctx), (void*)(a1), (void*)(a2), (void*)(a3), (void*)(a4))
|
||||
#define device_op1(d, op, proc, rctx, lockflags, a1, a2, a3, a4, ...) \
|
||||
(d)->ops[(op)]((d), (proc), (rctx), lockflags, (void*)(a1), (void*)(a2), (void*)(a3), (void*)(a4))
|
||||
|
||||
#define device_op(d, op, proc, rctx, ...) \
|
||||
device_op1 (d, op, proc, rctx, __VA_ARGS__, NULL, NULL, NULL, NULL)
|
||||
#define device_op(d, op, proc, rctx, lockflags, ...) \
|
||||
device_op1 (d, op, proc, rctx, lockflags, __VA_ARGS__, NULL, NULL, NULL, NULL)
|
||||
|
||||
struct device;
|
||||
|
||||
typedef int (*device_op_func_t) (struct device* device, struct proc*, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4);
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
typedef bool (*device_init_func_t) (struct device* device, void* arg, struct proc* proc,
|
||||
struct reschedule_ctx* rctx);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <proc/proc.h>
|
||||
#include <proc/reschedule.h>
|
||||
#include <status.h>
|
||||
#include <sys/debug.h>
|
||||
|
||||
#define IDE_REG_DATA 0x00
|
||||
#define IDE_REG_ERROR 0x01
|
||||
@@ -38,6 +39,10 @@
|
||||
#define IDE_CMD_FLUSH28 0xE7
|
||||
#define IDE_CMD_IDENTIFY 0xEC
|
||||
|
||||
#define IDE_READ 1
|
||||
#define IDE_WRITE 2
|
||||
#define IDE_FLUSH 3
|
||||
|
||||
static bool ide_wait (uint16_t io, uint32_t timeout, bool drq, bool errcheck) {
|
||||
uint32_t i = 0;
|
||||
uint8_t status;
|
||||
@@ -54,14 +59,14 @@ static bool ide_wait (uint16_t io, uint32_t timeout, bool drq, bool errcheck) {
|
||||
|
||||
if (drq) {
|
||||
i = 0;
|
||||
while (!(status & IDE_DRQ)) {
|
||||
while (!(status & IDE_DRQ) || (status & IDE_BSY)) {
|
||||
if (status & IDE_ERR)
|
||||
return false;
|
||||
|
||||
status = inb (io + IDE_REG_STATUS);
|
||||
|
||||
if (status == 0xFF)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
if (++i >= timeout)
|
||||
return false;
|
||||
@@ -83,13 +88,6 @@ static void ide_delay (uint16_t ctrl) {
|
||||
}
|
||||
#pragma clang optimize on
|
||||
|
||||
static void ide_flush (struct idedrv* idedrv) {
|
||||
if (idedrv->lba48)
|
||||
outb (idedrv->io + IDE_REG_CMD, IDE_CMD_FLUSH48);
|
||||
else
|
||||
outb (idedrv->io + IDE_REG_CMD, IDE_CMD_FLUSH28);
|
||||
}
|
||||
|
||||
static void ide_irq (void* arg, void* regs, bool user, struct reschedule_ctx* rctx) {
|
||||
uint64_t fd, fp;
|
||||
|
||||
@@ -106,51 +104,47 @@ static void ide_irq (void* arg, void* regs, bool user, struct reschedule_ctx* rc
|
||||
}
|
||||
|
||||
struct idedrv_request* req = list_entry (node, struct idedrv_request, requests_link);
|
||||
struct list_node_link* sqlist_node = req->sq.proc_list;
|
||||
struct proc_sq_entry* sq_entry = list_entry (sqlist_node, struct proc_sq_entry, sq_link);
|
||||
struct proc* resumed_proc = sq_entry->proc;
|
||||
|
||||
uint8_t status = inb (idedrv->io + IDE_REG_STATUS);
|
||||
|
||||
if ((status & (IDE_ERR | IDE_DRQ))) {
|
||||
if (req->type == IDE_FLUSH) {
|
||||
list_remove (idedrv->requests, &req->requests_link);
|
||||
spin_unlock (&idedrv->device->lock, fd);
|
||||
proc_sq_resume (resumed_proc, sq_entry, rctx);
|
||||
free (req);
|
||||
atomic_store (&req->done, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
spin_lock (&resumed_proc->lock, &fp);
|
||||
if ((status & (IDE_ERR | IDE_DF))) {
|
||||
list_remove (idedrv->requests, &req->requests_link);
|
||||
spin_unlock (&idedrv->device->lock, fd);
|
||||
atomic_store (&req->done, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (req->rw == 1) {
|
||||
if ((status & IDE_DRQ)) {
|
||||
uint16_t* p = req->outbuffer + (req->sector_done_count * (idedrv->sector_size / 2));
|
||||
if (!(status & IDE_BSY) && (status & IDE_DRQ)) {
|
||||
switch (req->type) {
|
||||
case IDE_READ: {
|
||||
uint16_t* p = req->buffer + (req->sector_done_count * (idedrv->sector_size / 2));
|
||||
insw (idedrv->io + IDE_REG_DATA, p, idedrv->sector_size / 2);
|
||||
req->sector_done_count++;
|
||||
}
|
||||
} else if (req->rw == 2) {
|
||||
req->sector_done_count++;
|
||||
if (req->sector_done_count < req->sector_count) {
|
||||
uint16_t* p = req->outbuffer + (req->sector_done_count * (idedrv->sector_size / 2));
|
||||
outsw (idedrv->io + IDE_REG_DATA, p, idedrv->sector_size / 2);
|
||||
} break;
|
||||
case IDE_WRITE: {
|
||||
req->sector_done_count++;
|
||||
if (req->sector_done_count < req->sector_count) {
|
||||
uint16_t* p = req->buffer + (req->sector_done_count * (idedrv->sector_size / 2));
|
||||
outsw (idedrv->io + IDE_REG_DATA, p, idedrv->sector_size / 2);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
if (req->sector_done_count >= req->sector_count) {
|
||||
if (req->rw == 2)
|
||||
ide_flush (idedrv);
|
||||
|
||||
list_remove (idedrv->requests, &req->requests_link);
|
||||
|
||||
spin_unlock (&resumed_proc->lock, fp);
|
||||
spin_unlock (&idedrv->device->lock, fd);
|
||||
|
||||
free (req);
|
||||
proc_sq_resume (resumed_proc, sq_entry, rctx);
|
||||
atomic_store (&req->done, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
spin_unlock (&resumed_proc->lock, fp);
|
||||
spin_unlock (&idedrv->device->lock, fd);
|
||||
}
|
||||
|
||||
@@ -286,8 +280,6 @@ void idedrv_fini (struct device* device, struct proc* proc, struct reschedule_ct
|
||||
list_foreach (idedrv->requests, req_link, tmp_req_link) {
|
||||
struct idedrv_request* req = list_entry (req_link, struct idedrv_request, requests_link);
|
||||
list_remove (idedrv->requests, &req->requests_link);
|
||||
struct proc_sq_entry* sq_entry = list_entry (req->sq.proc_list, struct proc_sq_entry, sq_link);
|
||||
proc_sq_resume (proc, sq_entry, rctx);
|
||||
free (req);
|
||||
}
|
||||
|
||||
@@ -295,10 +287,9 @@ 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, void* a1,
|
||||
void* a2, void* a3, void* a4) {
|
||||
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;
|
||||
uint64_t fp;
|
||||
|
||||
if (a1 == NULL || a2 == NULL || a3 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
@@ -312,52 +303,48 @@ int idedrv_read (struct device* device, struct proc* proc, struct reschedule_ctx
|
||||
if (sector + sector_count > idedrv->sector_count)
|
||||
return -ST_OOB_ERROR;
|
||||
|
||||
spin_lock (&proc->lock, &fp);
|
||||
bool is_kproc = (proc->flags & PROC_KPROC) != 0;
|
||||
spin_unlock (&proc->lock, fp);
|
||||
struct idedrv_request* req = malloc (sizeof (*req));
|
||||
|
||||
/* /1* polling *1/ */
|
||||
/* if (is_kproc) { */
|
||||
ide_prepare (idedrv, sector, sector_count, false);
|
||||
if (req == NULL)
|
||||
return -ST_OOM_ERROR;
|
||||
|
||||
memset (req, 0, sizeof (*req));
|
||||
req->buffer = buffer;
|
||||
req->sector_count = sector_count;
|
||||
req->sector_done_count = 0;
|
||||
req->type = IDE_READ;
|
||||
|
||||
list_append (idedrv->requests, &req->requests_link);
|
||||
|
||||
ide_prepare (idedrv, sector, sector_count, true);
|
||||
|
||||
uint8_t cmd = idedrv->lba48 ? IDE_CMD_READ48 : IDE_CMD_READ28;
|
||||
outb (idedrv->io + IDE_REG_CMD, cmd);
|
||||
|
||||
for (uint16_t s = 0; s < sector_count; s++) {
|
||||
if (!ide_wait (idedrv->io, 100000, true, true))
|
||||
return -ST_XDRV_READ_ERROR;
|
||||
|
||||
insw (idedrv->io + IDE_REG_DATA, buffer + (s * (idedrv->sector_size / 2)),
|
||||
(idedrv->sector_size / 2));
|
||||
if (!ide_wait (idedrv->io, 100000, true, true)) {
|
||||
list_remove (idedrv->requests, &req->requests_link);
|
||||
free (req);
|
||||
return -ST_XDRV_READ_ERROR;
|
||||
}
|
||||
|
||||
insw (idedrv->io + IDE_REG_DATA, buffer, idedrv->sector_size / 2);
|
||||
|
||||
req->sector_done_count = 1;
|
||||
|
||||
spin_unlock (&device->lock, *lockflags);
|
||||
|
||||
while (!atomic_load (&req->done))
|
||||
spin_lock_relax ();
|
||||
|
||||
spin_lock (&device->lock, lockflags);
|
||||
|
||||
free (req);
|
||||
|
||||
return ST_OK;
|
||||
/* } else { /1* IRQ *1/ */
|
||||
/* struct idedrv_request* req = malloc (sizeof (*req)); */
|
||||
|
||||
/* if (req == NULL) */
|
||||
/* return -ST_OOM_ERROR; */
|
||||
|
||||
/* memset (req, 0, sizeof (*req)); */
|
||||
/* req->outbuffer = buffer; */
|
||||
/* req->sector_count = sector_count; */
|
||||
/* req->sector_done_count = 0; */
|
||||
/* req->rw = 1; */
|
||||
|
||||
/* list_append (idedrv->requests, &req->requests_link); */
|
||||
/* proc_sq_suspend (proc, &req->sq, NULL, rctx); */
|
||||
|
||||
/* ide_prepare (idedrv, sector, sector_count, true); */
|
||||
|
||||
/* uint8_t cmd = idedrv->lba48 ? IDE_CMD_READ48 : IDE_CMD_READ28; */
|
||||
/* outb (idedrv->io + IDE_REG_CMD, cmd); */
|
||||
|
||||
/* return ST_OK; */
|
||||
/* } */
|
||||
}
|
||||
|
||||
int idedrv_write (struct device* device, struct proc* proc, struct reschedule_ctx* rctx, void* a1,
|
||||
void* a2, void* a3, void* a4) {
|
||||
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;
|
||||
|
||||
@@ -373,63 +360,76 @@ int idedrv_write (struct device* device, struct proc* proc, struct reschedule_ct
|
||||
if (sector + sector_count > idedrv->sector_count)
|
||||
return -ST_OOB_ERROR;
|
||||
|
||||
spin_lock (&proc->lock, &fp);
|
||||
bool is_kproc = (proc->flags & PROC_KPROC) != 0;
|
||||
spin_unlock (&proc->lock, fp);
|
||||
struct idedrv_request* req = malloc (sizeof (*req));
|
||||
|
||||
/* /1* polling *1/ */
|
||||
/* if (is_kproc) { */
|
||||
ide_prepare (idedrv, sector, sector_count, false);
|
||||
struct idedrv_request* flushreq = malloc (sizeof (*req));
|
||||
|
||||
if (req == NULL)
|
||||
return -ST_OOM_ERROR;
|
||||
|
||||
if (flushreq == NULL) {
|
||||
free (req);
|
||||
return -ST_OOM_ERROR;
|
||||
}
|
||||
|
||||
memset (req, 0, sizeof (*req));
|
||||
req->buffer = buffer;
|
||||
req->sector_count = sector_count;
|
||||
req->sector_done_count = 0;
|
||||
req->type = IDE_WRITE;
|
||||
|
||||
list_append (idedrv->requests, &req->requests_link);
|
||||
|
||||
memset (flushreq, 0, sizeof (*flushreq));
|
||||
flushreq->buffer = NULL;
|
||||
flushreq->sector_count = 0;
|
||||
flushreq->sector_done_count = 0;
|
||||
flushreq->type = IDE_FLUSH;
|
||||
|
||||
list_append (idedrv->requests, &flushreq->requests_link);
|
||||
|
||||
ide_prepare (idedrv, sector, sector_count, true);
|
||||
|
||||
uint8_t cmd = idedrv->lba48 ? IDE_CMD_WRITE48 : IDE_CMD_WRITE28;
|
||||
outb (idedrv->io + IDE_REG_CMD, cmd);
|
||||
|
||||
for (uint16_t s = 0; s < sector_count; s++) {
|
||||
if (!ide_wait (idedrv->io, 100000, true, true))
|
||||
return -ST_XDRV_WRITE_ERROR;
|
||||
|
||||
outsw (idedrv->io + IDE_REG_DATA, buffer + (s * (idedrv->sector_size / 2)),
|
||||
(idedrv->sector_size / 2));
|
||||
if (!ide_wait (idedrv->io, 100000, true, true)) {
|
||||
list_remove (idedrv->requests, &req->requests_link);
|
||||
free (req);
|
||||
return -ST_XDRV_WRITE_ERROR;
|
||||
}
|
||||
|
||||
outsw (idedrv->io + IDE_REG_DATA, buffer, idedrv->sector_size / 2);
|
||||
|
||||
req->sector_done_count = 1;
|
||||
|
||||
spin_unlock (&device->lock, *lockflags);
|
||||
|
||||
while (!atomic_load (&req->done))
|
||||
spin_lock_relax ();
|
||||
|
||||
spin_lock (&device->lock, lockflags);
|
||||
|
||||
if (idedrv->lba48)
|
||||
outb (idedrv->io + IDE_REG_CMD, IDE_CMD_FLUSH48);
|
||||
else
|
||||
outb (idedrv->io + IDE_REG_CMD, IDE_CMD_FLUSH28);
|
||||
|
||||
spin_unlock (&device->lock, *lockflags);
|
||||
|
||||
while (!atomic_load (&flushreq->done))
|
||||
spin_lock_relax ();
|
||||
|
||||
spin_lock (&device->lock, lockflags);
|
||||
|
||||
free (req);
|
||||
free (flushreq);
|
||||
|
||||
return ST_OK;
|
||||
/* } else { /1* IRQ *1/ */
|
||||
/* struct idedrv_request* req = malloc (sizeof (*req)); */
|
||||
|
||||
/* if (req == NULL) */
|
||||
/* return -ST_OOM_ERROR; */
|
||||
|
||||
/* memset (req, 0, sizeof (*req)); */
|
||||
/* req->outbuffer = buffer; */
|
||||
/* req->sector_count = sector_count; */
|
||||
/* req->sector_done_count = 0; */
|
||||
/* req->rw = 2; */
|
||||
|
||||
/* list_append (idedrv->requests, &req->requests_link); */
|
||||
/* proc_sq_suspend (proc, &req->sq, NULL, rctx); */
|
||||
|
||||
/* ide_prepare (idedrv, sector, sector_count, true); */
|
||||
|
||||
/* uint8_t cmd = idedrv->lba48 ? IDE_CMD_WRITE48 : IDE_CMD_WRITE28; */
|
||||
/* outb (idedrv->io + IDE_REG_CMD, cmd); */
|
||||
|
||||
/* if (!ide_wait (idedrv->io, 100000, true, true)) { */
|
||||
/* list_remove (idedrv->requests, &req->requests_link); */
|
||||
/* struct proc_sq_entry* sq_entry = list_entry (req->sq.proc_list, struct proc_sq_entry,
|
||||
* sq_link); */
|
||||
/* proc_sq_resume (proc, sq_entry, rctx); */
|
||||
/* free (req); */
|
||||
/* return -ST_XDRV_WRITE_ERROR; */
|
||||
/* } */
|
||||
|
||||
/* outsw (idedrv->io + IDE_REG_DATA, buffer, idedrv->sector_size / 2); */
|
||||
|
||||
/* return ST_OK; */
|
||||
/* } */
|
||||
}
|
||||
|
||||
int idedrv_get_device_type (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4) {
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)device, (void)a2, (void)a3, (void)a4;
|
||||
|
||||
if (a1 == NULL)
|
||||
@@ -443,7 +443,7 @@ int idedrv_get_device_type (struct device* device, struct proc* proc, struct res
|
||||
}
|
||||
|
||||
int idedrv_get_sector_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4) {
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a2, (void)a3, (void)a4;
|
||||
|
||||
if (a1 == NULL)
|
||||
@@ -459,7 +459,7 @@ int idedrv_get_sector_size (struct device* device, struct proc* proc, struct res
|
||||
}
|
||||
|
||||
int idedrv_get_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4) {
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a2, (void)a3, (void)a4;
|
||||
|
||||
if (a1 == NULL)
|
||||
|
||||
@@ -23,12 +23,12 @@ struct idedrv_init {
|
||||
};
|
||||
|
||||
struct idedrv_request {
|
||||
uint16_t* outbuffer;
|
||||
uint16_t* buffer;
|
||||
size_t sector_done_count;
|
||||
size_t sector_count;
|
||||
struct list_node_link requests_link;
|
||||
struct proc_suspension_q sq;
|
||||
int rw;
|
||||
int type;
|
||||
atomic_int done;
|
||||
};
|
||||
|
||||
struct idedrv {
|
||||
@@ -56,20 +56,20 @@ bool idedrv_init (struct device* device, void* arg, struct proc* proc, struct re
|
||||
|
||||
void idedrv_fini (struct device* device, struct proc* proc, struct reschedule_ctx* rctx);
|
||||
|
||||
int idedrv_read (struct device* device, struct proc* proc, struct reschedule_ctx* rctx, void* a1,
|
||||
void* a2, void* a3, void* a4);
|
||||
int idedrv_read (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
int idedrv_write (struct device* device, struct proc* proc, struct reschedule_ctx* rctx, void* a1,
|
||||
void* a2, void* a3, void* a4);
|
||||
int idedrv_write (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
int idedrv_get_device_type (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4);
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
int idedrv_get_sector_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4);
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
int idedrv_get_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4);
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
void ide_probe (uint16_t io, uint16_t ctrl, uint8_t devno, struct ide_probe* probe);
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ void partdrv_fini (struct device* device, struct proc* proc, struct reschedule_c
|
||||
free (partdrv);
|
||||
}
|
||||
|
||||
int partdrv_read (struct device* device, struct proc* proc, struct reschedule_ctx* rctx, void* a1,
|
||||
void* a2, void* a3, void* a4) {
|
||||
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;
|
||||
uint64_t fs;
|
||||
|
||||
@@ -50,14 +50,14 @@ int partdrv_read (struct device* device, struct proc* proc, struct reschedule_ct
|
||||
uint8_t* buffer = a3;
|
||||
|
||||
spin_lock (&super->lock, &fs);
|
||||
int ret = device_op (super, XDRV_READ, proc, rctx, §or, §or_count, buffer);
|
||||
int ret = device_op (super, XDRV_READ, proc, rctx, &fs, §or, §or_count, buffer);
|
||||
spin_unlock (&super->lock, fs);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int partdrv_write (struct device* device, struct proc* proc, struct reschedule_ctx* rctx, void* a1,
|
||||
void* a2, void* a3, void* a4) {
|
||||
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;
|
||||
uint64_t fs;
|
||||
|
||||
@@ -72,14 +72,14 @@ int partdrv_write (struct device* device, struct proc* proc, struct reschedule_c
|
||||
uint8_t* buffer = a3;
|
||||
|
||||
spin_lock (&super->lock, &fs);
|
||||
int ret = device_op (super, XDRV_WRITE, proc, rctx, §or, §or_count, buffer);
|
||||
int ret = device_op (super, XDRV_WRITE, proc, rctx, &fs, §or, §or_count, buffer);
|
||||
spin_unlock (&super->lock, fs);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int partdrv_get_device_type (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4) {
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)device, (void)a2, (void)a3, (void)a4;
|
||||
|
||||
if (a1 == NULL)
|
||||
@@ -93,7 +93,7 @@ int partdrv_get_device_type (struct device* device, struct proc* proc, struct re
|
||||
}
|
||||
|
||||
int partdrv_get_sector_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4) {
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a2, (void)a3, (void)a4;
|
||||
uint64_t fs;
|
||||
|
||||
@@ -105,14 +105,14 @@ int partdrv_get_sector_size (struct device* device, struct proc* proc, struct re
|
||||
struct partdrv* partdrv = device->udata;
|
||||
|
||||
spin_lock (&partdrv->super->lock, &fs);
|
||||
device_op (partdrv->super, XDRV_GET_SECTOR_SIZE, proc, rctx, secsize);
|
||||
device_op (partdrv->super, XDRV_GET_SECTOR_SIZE, proc, rctx, &fs, secsize);
|
||||
spin_unlock (&partdrv->super->lock, fs);
|
||||
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
int partdrv_get_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4) {
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a2, (void)a3, (void)a4;
|
||||
|
||||
if (a1 == NULL)
|
||||
|
||||
@@ -24,19 +24,19 @@ bool partdrv_init (struct device* device, void* arg, struct proc* proc,
|
||||
|
||||
void partdrv_fini (struct device* device, struct proc* proc, struct reschedule_ctx* rctx);
|
||||
|
||||
int partdrv_read (struct device* device, struct proc* proc, struct reschedule_ctx* rctx, void* a1,
|
||||
void* a2, void* a3, void* a4);
|
||||
int partdrv_read (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
int partdrv_write (struct device* device, struct proc* proc, struct reschedule_ctx* rctx, void* a1,
|
||||
void* a2, void* a3, void* a4);
|
||||
int partdrv_write (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
int partdrv_get_device_type (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4);
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
int partdrv_get_sector_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4);
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
int partdrv_get_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4);
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
#endif // _KERNEL_DEVICE_PARTDRV_H
|
||||
|
||||
@@ -32,9 +32,9 @@ static int device_probe_partitions_dos (struct proc* proc, struct reschedule_ctx
|
||||
|
||||
spin_lock (&device->lock, &fd);
|
||||
|
||||
device_op (device, XDRV_GET_SECTOR_SIZE, proc, rctx, §or_size);
|
||||
device_op (device, XDRV_GET_SECTOR_SIZE, proc, rctx, &fd, §or_size);
|
||||
|
||||
int ret = device_op (device, XDRV_READ, proc, rctx, §or, §or_count, &mbr);
|
||||
int ret = device_op (device, XDRV_READ, proc, rctx, &fd, §or, §or_count, &mbr);
|
||||
|
||||
if (ret < 0) {
|
||||
spin_unlock (&device->lock, fd);
|
||||
|
||||
@@ -177,8 +177,8 @@ 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, void* a1,
|
||||
void* a2, void* a3, void* a4) {
|
||||
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;
|
||||
uint64_t frb, fsq;
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
struct device;
|
||||
|
||||
int ps2kb_read_key (struct device* device, struct proc* proc, struct reschedule_ctx* rctx, void* a1,
|
||||
void* a2, void* a3, void* a4);
|
||||
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);
|
||||
|
||||
bool ps2kb_init (struct device* device, void* arg, struct proc* proc, struct reschedule_ctx* rctx);
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ void ramdrv_fini (struct device* device, struct proc* proc, struct reschedule_ct
|
||||
}
|
||||
|
||||
int ramdrv_get_device_type (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4) {
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)device, (void)a2, (void)a3, (void)a4;
|
||||
|
||||
if (a1 == NULL)
|
||||
@@ -63,7 +63,7 @@ int ramdrv_get_device_type (struct device* device, struct proc* proc, struct res
|
||||
}
|
||||
|
||||
int ramdrv_get_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4) {
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a2, (void)a3, (void)a4;
|
||||
|
||||
if (a1 == NULL)
|
||||
@@ -79,7 +79,7 @@ int ramdrv_get_size (struct device* device, struct proc* proc, struct reschedule
|
||||
}
|
||||
|
||||
int ramdrv_get_sector_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4) {
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a2, (void)a3, (void)a4;
|
||||
|
||||
if (a1 == NULL)
|
||||
@@ -94,8 +94,8 @@ 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, void* a1,
|
||||
void* a2, void* a3, void* a4) {
|
||||
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;
|
||||
|
||||
if (a1 == NULL || a2 == NULL || a3 == NULL)
|
||||
@@ -114,8 +114,8 @@ 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, void* a1,
|
||||
void* a2, void* a3, void* a4) {
|
||||
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;
|
||||
|
||||
if (a1 == NULL || a2 == NULL || a3 == NULL)
|
||||
|
||||
@@ -24,19 +24,19 @@ bool ramdrv_init (struct device* device, void* arg, struct proc* proc, struct re
|
||||
|
||||
void ramdrv_fini (struct device* device, struct proc* proc, struct reschedule_ctx* rctx);
|
||||
|
||||
int ramdrv_read (struct device* device, struct proc* proc, struct reschedule_ctx* rctx, void* a1,
|
||||
void* a2, void* a3, void* a4);
|
||||
int ramdrv_read (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
int ramdrv_write (struct device* device, struct proc* proc, struct reschedule_ctx* rctx, void* a1,
|
||||
void* a2, void* a3, void* a4);
|
||||
int ramdrv_write (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
uint64_t* lockflags, 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);
|
||||
uint64_t* lockflags, 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);
|
||||
uint64_t* lockflags, 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);
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
#endif // _KERNEL_DEVICE_RAMDRV_H
|
||||
|
||||
@@ -39,7 +39,7 @@ void terminal_fini (struct device* device, struct proc* proc, struct reschedule_
|
||||
}
|
||||
|
||||
int terminal_putstr (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4) {
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)a2, (void)a3, (void)a4, (void)device, (void)rctx;
|
||||
|
||||
if (!(proc->procgroup->capabilities & PROC_CAP_TERMINAL))
|
||||
@@ -57,7 +57,7 @@ int terminal_putstr (struct device* device, struct proc* proc, struct reschedule
|
||||
}
|
||||
|
||||
int terminal_dimensions (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4) {
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a3, (void)a4, (void)device;
|
||||
|
||||
if (a1 == NULL || a2 == NULL)
|
||||
|
||||
@@ -14,9 +14,9 @@ bool terminal_init (struct device* device, void* arg, struct proc* proc,
|
||||
void terminal_fini (struct device* device, struct proc* proc, struct reschedule_ctx* rctx);
|
||||
|
||||
int terminal_putstr (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4);
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
int terminal_dimensions (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
|
||||
void* a1, void* a2, void* a3, void* a4);
|
||||
uint64_t* lockflags, void* a1, void* a2, void* a3, void* a4);
|
||||
|
||||
#endif // _KERNEL_DEVICE_TERMINAL_H
|
||||
|
||||
@@ -34,7 +34,7 @@ static int fat1_diskio_read (struct fatfs_ctx* ctx, uint32_t sector, uint8_t* bu
|
||||
|
||||
spin_lock (&back_device->lock, &fd);
|
||||
|
||||
ret = device_op (back_device, XDRV_GET_SECTOR_SIZE, ctx->proc, ctx->rctx, §or_size);
|
||||
ret = device_op (back_device, XDRV_GET_SECTOR_SIZE, ctx->proc, ctx->rctx, &fd, §or_size);
|
||||
if (ret < 0) {
|
||||
spin_unlock (&back_device->lock, fd);
|
||||
return 0;
|
||||
@@ -43,8 +43,8 @@ static int fat1_diskio_read (struct fatfs_ctx* ctx, uint32_t sector, uint8_t* bu
|
||||
vfs_translate (sector, sector_count, FAT_SECTOR_SIZE, sector_size, &phys_sector,
|
||||
&phys_sector_count);
|
||||
|
||||
ret = device_op (back_device, XDRV_READ, ctx->proc, ctx->rctx, &phys_sector, &phys_sector_count,
|
||||
buffer);
|
||||
ret = device_op (back_device, XDRV_READ, ctx->proc, ctx->rctx, &fd, &phys_sector,
|
||||
&phys_sector_count, buffer);
|
||||
if (ret < 0) {
|
||||
spin_unlock (&back_device->lock, fd);
|
||||
return 0;
|
||||
@@ -73,7 +73,7 @@ static int fat1_diskio_write (struct fatfs_ctx* ctx, uint32_t sector, uint8_t* b
|
||||
|
||||
spin_lock (&back_device->lock, &fd);
|
||||
|
||||
ret = device_op (back_device, XDRV_GET_SECTOR_SIZE, ctx->proc, ctx->rctx, §or_size);
|
||||
ret = device_op (back_device, XDRV_GET_SECTOR_SIZE, ctx->proc, ctx->rctx, &fd, §or_size);
|
||||
if (ret < 0) {
|
||||
spin_unlock (&back_device->lock, fd);
|
||||
return 0;
|
||||
@@ -82,8 +82,8 @@ static int fat1_diskio_write (struct fatfs_ctx* ctx, uint32_t sector, uint8_t* b
|
||||
vfs_translate (sector, sector_count, FAT_SECTOR_SIZE, sector_size, &phys_sector,
|
||||
&phys_sector_count);
|
||||
|
||||
ret = device_op (back_device, XDRV_WRITE, ctx->proc, ctx->rctx, &phys_sector, &phys_sector_count,
|
||||
buffer);
|
||||
ret = device_op (back_device, XDRV_WRITE, ctx->proc, ctx->rctx, &fd, &phys_sector,
|
||||
&phys_sector_count, buffer);
|
||||
if (ret < 0) {
|
||||
spin_unlock (&back_device->lock, fd);
|
||||
return 0;
|
||||
@@ -137,7 +137,7 @@ int fatfs16_format (struct vfs_volume* volume, struct proc* proc, struct resched
|
||||
fatfs_ctx->rctx = rctx;
|
||||
|
||||
spin_lock (&back_device->lock, &fd);
|
||||
device_op (back_device, XDRV_GET_SIZE, proc, rctx, &total_size);
|
||||
device_op (back_device, XDRV_GET_SIZE, proc, rctx, &fd, &total_size);
|
||||
spin_unlock (&back_device->lock, fd);
|
||||
|
||||
size_t sectors = div_align_up (total_size, FAT_SECTOR_SIZE);
|
||||
@@ -155,7 +155,7 @@ int fatfs32_format (struct vfs_volume* volume, struct proc* proc, struct resched
|
||||
fatfs_ctx->rctx = rctx;
|
||||
|
||||
spin_lock (&back_device->lock, &fd);
|
||||
device_op (back_device, XDRV_GET_SIZE, proc, rctx, &total_size);
|
||||
device_op (back_device, XDRV_GET_SIZE, proc, rctx, &fd, &total_size);
|
||||
spin_unlock (&back_device->lock, fd);
|
||||
|
||||
size_t sectors = div_align_up (total_size, FAT_SECTOR_SIZE);
|
||||
|
||||
@@ -85,14 +85,14 @@ int tarfs_mount (struct vfs_volume* volume, struct proc* proc, struct reschedule
|
||||
|
||||
spin_lock (&back_device->lock, &fd);
|
||||
|
||||
ret = device_op (back_device, XDRV_GET_SIZE, NULL, NULL, &total_size);
|
||||
ret = device_op (back_device, XDRV_GET_SIZE, proc, rctx, &fd, &total_size);
|
||||
if (ret < 0) {
|
||||
spin_unlock (&back_device->lock, fd);
|
||||
free (volume->udata);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = device_op (back_device, XDRV_GET_SECTOR_SIZE, NULL, NULL, §or_size);
|
||||
ret = device_op (back_device, XDRV_GET_SECTOR_SIZE, proc, rctx, &fd, §or_size);
|
||||
if (ret < 0) {
|
||||
spin_unlock (&back_device->lock, fd);
|
||||
free (volume->udata);
|
||||
@@ -111,7 +111,7 @@ int tarfs_mount (struct vfs_volume* volume, struct proc* proc, struct reschedule
|
||||
size_t sector_count = 1;
|
||||
for (size_t sector = 0; sector < total_size / sector_size; sector++) {
|
||||
uint8_t* dest = (uint8_t*)((uintptr_t)buffer + (sector * sector_size));
|
||||
ret = device_op (back_device, XDRV_READ, proc, rctx, §or, §or_count, dest);
|
||||
ret = device_op (back_device, XDRV_READ, proc, rctx, &fd, §or, §or_count, dest);
|
||||
}
|
||||
|
||||
spin_unlock (&back_device->lock, fd);
|
||||
|
||||
@@ -336,7 +336,7 @@ DEFINE_SYSCALL (sys_device_do) {
|
||||
return SYSRESULT (-ST_NOT_FOUND);
|
||||
}
|
||||
|
||||
int ret = device_op (device, cmd, proc, rctx, ka1, ka2, ka3, ka4);
|
||||
int ret = device_op (device, cmd, proc, rctx, &fd, ka1, ka2, ka3, ka4);
|
||||
|
||||
spin_unlock (&device->lock, fd);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user