Spinlock save cpu flags
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
#include <proc/reschedule.h>
|
||||
#include <status.h>
|
||||
|
||||
bool partdrv_init (struct device* device, void* arg, struct proc* proc, struct reschedule_ctx* rctx) {
|
||||
bool partdrv_init (struct device* device, void* arg, struct proc* proc,
|
||||
struct reschedule_ctx* rctx) {
|
||||
(void)proc, (void)rctx;
|
||||
|
||||
struct partdrv_init* init = arg;
|
||||
@@ -36,6 +37,7 @@ void partdrv_fini (struct device* device, struct proc* proc, struct reschedule_c
|
||||
int partdrv_read (struct device* device, struct proc* proc, struct reschedule_ctx* rctx, void* a1,
|
||||
void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a4;
|
||||
uint64_t fs;
|
||||
|
||||
if (a1 == NULL || a2 == NULL || a3 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
@@ -47,9 +49,9 @@ int partdrv_read (struct device* device, struct proc* proc, struct reschedule_ct
|
||||
size_t sector_count = *(size_t*)a2;
|
||||
uint8_t* buffer = a3;
|
||||
|
||||
spin_lock (&super->lock);
|
||||
spin_lock (&super->lock, &fs);
|
||||
int ret = device_op (super, XDRV_READ, proc, rctx, §or, §or_count, buffer);
|
||||
spin_unlock (&super->lock);
|
||||
spin_unlock (&super->lock, fs);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -57,6 +59,7 @@ int partdrv_read (struct device* device, struct proc* proc, struct reschedule_ct
|
||||
int partdrv_write (struct device* device, struct proc* proc, struct reschedule_ctx* rctx, void* a1,
|
||||
void* a2, void* a3, void* a4) {
|
||||
(void)proc, (void)rctx, (void)a4;
|
||||
uint64_t fs;
|
||||
|
||||
if (a1 == NULL || a2 == NULL || a3 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
@@ -68,9 +71,9 @@ int partdrv_write (struct device* device, struct proc* proc, struct reschedule_c
|
||||
size_t sector_count = *(size_t*)a2;
|
||||
uint8_t* buffer = a3;
|
||||
|
||||
spin_lock (&super->lock);
|
||||
spin_lock (&super->lock, &fs);
|
||||
int ret = device_op (super, XDRV_WRITE, proc, rctx, §or, §or_count, buffer);
|
||||
spin_unlock (&super->lock);
|
||||
spin_unlock (&super->lock, fs);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -92,6 +95,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) {
|
||||
(void)proc, (void)rctx, (void)a2, (void)a3, (void)a4;
|
||||
uint64_t fs;
|
||||
|
||||
if (a1 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
@@ -100,9 +104,9 @@ int partdrv_get_sector_size (struct device* device, struct proc* proc, struct re
|
||||
|
||||
struct partdrv* partdrv = device->udata;
|
||||
|
||||
spin_lock (&partdrv->super->lock);
|
||||
spin_lock (&partdrv->super->lock, &fs);
|
||||
device_op (partdrv->super, XDRV_GET_SECTOR_SIZE, proc, rctx, secsize);
|
||||
spin_unlock (&partdrv->super->lock);
|
||||
spin_unlock (&partdrv->super->lock, fs);
|
||||
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user