fat_io_lib port WIP
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m12s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m12s
This commit is contained in:
@@ -9,6 +9,12 @@
|
||||
#include <sync/spin_lock.h>
|
||||
#include <sys/smp.h>
|
||||
|
||||
#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_op(d, op, proc, rctx, ...) \
|
||||
device_op1 (d, op, proc, rctx, __VA_ARGS__, NULL, NULL, NULL, NULL)
|
||||
|
||||
struct device;
|
||||
|
||||
typedef int (*device_op_func_t) (struct device* device, struct proc*, struct reschedule_ctx* rctx,
|
||||
|
||||
@@ -91,16 +91,18 @@ int ramdrv_get_sector_size (struct device* device, struct proc* proc, struct res
|
||||
|
||||
int ramdrv_read (struct device* device, struct proc* proc, struct reschedule_ctx* rctx, void* a1,
|
||||
void* a2, void* a3, void* a4) {
|
||||
if (a1 == NULL || a2 == NULL || a3 == NULL || a4 == NULL)
|
||||
(void)proc, (void)rctx, (void)a4;
|
||||
|
||||
if (a1 == NULL || a2 == NULL || a3 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
|
||||
size_t sector = *(size_t*)a1;
|
||||
size_t off = *(size_t*)a2;
|
||||
size_t size = *(size_t*)a3;
|
||||
uint8_t* buffer = a4;
|
||||
size_t sector_count = *(size_t*)a2;
|
||||
uint8_t* buffer = a3;
|
||||
|
||||
struct ramdrv* ramdrv = device->udata;
|
||||
size_t pos = sector * ramdrv->sector_size + off;
|
||||
size_t pos = sector * ramdrv->sector_size;
|
||||
size_t size = sector_count * ramdrv->sector_size;
|
||||
|
||||
memcpy (buffer, (void*)(((uintptr_t)ramdrv->buffer) + pos), size);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user