ddk: fix w/w mutexes after removing TASKDATA

git-svn-id: svn://kolibrios.org@9833 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat 2022-06-06 22:02:32 +00:00
parent 1865c30de8
commit 98c8bda617
4 changed files with 131 additions and 45 deletions

View File

@ -26,9 +26,13 @@
.global _FreeKernelSpace
.global _FreePage
.global _FS_Service
.global _GetClockNs
.global _GetCpuFreq
.global _GetCurrSlot
.global _GetDisplay
.global _GetEvent
.global _GetPgAddr
@ -83,8 +87,6 @@
.global _WaitEvent
.global _WaitEventTimeout
.global _FS_Service
.def _AcpiGetRootPtr; .scl 2; .type 32; .endef
.def _AllocKernelSpace; .scl 2; .type 32; .endef
@ -109,10 +111,11 @@
.def _FreeKernelSpace; .scl 2; .type 32; .endef
.def _FreePage; .scl 2; .type 32; .endef
.def _FS_Service; .scl 2; .type 32; .endef
.def _GetClockNs; .scl 2; .type 32; .endef
.def _GetDisplay; .scl 2; .type 32; .endef
.def _GetCurrSlot; .scl 2; .type 32; .endef
.def _GetDisplay; .scl 2; .type 32; .endef
.def _GetEvent; .scl 2; .type 32; .endef
@ -166,9 +169,7 @@
.def _WaitEvent; .scl 2; .type 32; .endef
.def _WaitEventTimeout; .scl 2; .type 32; .endef
.def _FS_Service; .scl 2; .type 32; .endef
_AcpiGetRootPtr:
_AllocKernelSpace:
@ -195,8 +196,13 @@ _DiskMediaChanged:
_FreeKernelSpace:
_FreePage:
_FS_Service:
_GetClockNs:
_GetCpuFreq:
_GetCurrSlot:
_GetDisplay:
_GetEvent:
_GetPCIList:
@ -247,9 +253,6 @@ _UserAlloc:
_UserFree:
_WaitEvent:
_WaitEventTimeout:
_FS_Service:
ret
.section .drectve
@ -278,8 +281,13 @@ _FS_Service:
.ascii " -export:FreeKernelSpace" # stdcall
.ascii " -export:FreePage" #
.ascii " -export:FS_Service" # watch system call 70
.ascii " -export:GetClockNs" #
.ascii " -export:GetCpuFreq" #
.ascii " -export:GetCurrSlot"
.ascii " -export:GetDisplay" # stdcall
.ascii " -export:GetEvent" #
.ascii " -export:GetPCIList" #
@ -290,7 +298,6 @@ _FS_Service:
.ascii " -export:GetStackBase" #
.ascii " -export:GetWindowRect" # fastcall
.ascii " -export:KernelAlloc" # stdcall
.ascii " -export:KernelFree" # stdcall
@ -332,4 +339,3 @@ _FS_Service:
.ascii " -export:WaitEvent" # stdcall
.ascii " -export:WaitEventTimeout" # stdcall
.ascii " -export:FS_Service" # watch system call 70

View File

@ -25,22 +25,6 @@
#include <linux/spinlock.h>
#include <syscall.h>
struct kos_taskdata
{
u32 event_mask;
u32 pid;
u16 r0;
u8 state;
u8 r1;
u16 r2;
u8 wnd_number;
u8 r3;
u32 mem_start;
u32 counter_sum;
u32 counter_add;
u32 cpu_usage;
}__attribute__((packed));
static inline void mutex_set_owner(struct mutex *lock)
{
}
@ -144,11 +128,12 @@ ww_mutex_set_context_fastpath(struct ww_mutex *lock,
*/
flags = safe_cli();
list_for_each_entry(cur, &lock->base.wait_list, list) {
((struct kos_taskdata*)cur->task)->state = 0;
((struct kos_appdata*)cur->task)->state = KOS_SLOT_STATE_RUNNING;
}
safe_sti(flags);
}
static __always_inline void
ww_mutex_set_context_slowpath(struct ww_mutex *lock,
struct ww_acquire_ctx *ctx)
{
@ -162,7 +147,7 @@ ww_mutex_set_context_slowpath(struct ww_mutex *lock,
* so they can recheck if they have to back off.
*/
list_for_each_entry(cur, &lock->base.wait_list, list) {
((struct kos_taskdata*)cur->task)->state = 0;
((struct kos_appdata*)cur->task)->state = KOS_SLOT_STATE_RUNNING;
}
}
@ -170,13 +155,13 @@ int __ww_mutex_lock_slowpath(struct ww_mutex *ww, struct ww_acquire_ctx *ctx)
{
struct mutex *lock;
struct mutex_waiter waiter;
struct kos_taskdata* taskdata;
struct kos_appdata *appdata;
u32 eflags;
int ret = 0;
lock = &ww->base;
taskdata = (struct kos_taskdata*)(0x80003010);
waiter.task = (u32*)taskdata;
appdata = GetCurrSlot();
waiter.task = appdata;
eflags = safe_cli();
@ -192,7 +177,7 @@ int __ww_mutex_lock_slowpath(struct ww_mutex *ww, struct ww_acquire_ctx *ctx)
if (ret)
goto err;
};
taskdata->state = 1;
appdata->state = KOS_SLOT_STATE_SUSPENDED;
change_task();
};

View File

@ -58,7 +58,7 @@ struct mutex {
*/
struct mutex_waiter {
struct list_head list;
int *task;
void *task;
};

View File

@ -3,21 +3,23 @@
#include <ddk.h>
#define ASSERT_CONCAT_(a, b) a##b
#define ASSERT_CONCAT(a, b) ASSERT_CONCAT_(a, b)
#define STATIC_ASSERT(e) enum { ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(e)) }
typedef u32 addr_t;
typedef u32 count_t;
#pragma pack(push, 1)
typedef struct
{
int width;
int height;
int bpp;
int freq;
}videomode_t;
typedef struct {
int width;
int height;
int bpp;
int freq;
} videomode_t;
struct kos32_pdev
{
struct kos32_pdev {
struct kos32_pdev *prev;
struct kos32_pdev *next;
u32 devid;
@ -28,6 +30,96 @@ struct kos32_pdev
u32 owner;
};
// struct BOX in const.inc
struct kos_wnd_box {
u32 left;
u32 top;
u32 width;
u32 height;
};
// struct DBG_REGS in const.inc
struct kos_dbg_regs {
u32 dr0;
u32 dr1;
u32 dr2;
u32 dr3;
u32 dr7;
};
struct kos_lhead {
struct kos_lhead *prev;
struct kos_lhead *next;
};
enum KOS_SLOT_STATES {
KOS_SLOT_STATE_RUNNING = 0,
KOS_SLOT_STATE_SUSPENDED = 1,
KOS_SLOT_STATE_SUSPENDED_WAIT_EVENT = 2,
KOS_SLOT_STATE_NORMAL_TERM = 3,
KOS_SLOT_STATE_EXCEPT_TERM = 4,
KOS_SLOT_STATE_WAIT_EVENT = 5,
KOS_SLOT_STATE_FREE = 9
};
struct kos_appdata {
char app_name[16];
struct kos_lhead list;
u32 process;
u32 fpu_state;
u32 exc_handler;
u32 except_mask;
u32 pl0_stack;
u32 cursor;
u32 fd_ev;
u32 bk_ev;
u32 fd_obj;
u32 bk_obj;
u32 saved_esp;
u32 io_map[2];
u32 dbg_state;
char* cur_dir;
u32 wait_timeout;
u32 saved_esp0;
u32 wait_begin;
u32 wait_test;
u32 wait_param;
u32 tls_base;
u32 event_mask;
u32 tid;
u32 draw_bgr_x;
u32 draw_bgr_y;
u8 state;
u8 wnd_number;
u16 __reserved1;
u32 wnd_shape;
u32 wnd_shape_scale;
u32 __reserved2;
u32 counter_sum;
struct kos_wnd_box saved_box;
u32 ipc_start;
u32 ipc_size;
u32 occurred_events;
u32 debugger_slot;
u32 terminate_protection;
u8 keyboard_mode;
u8 captionEncoding;
u8 __reserved3[2];
char* exec_params;
u32 dbg_event_mem;
struct kos_dbg_regs dbg_regs;
char* wnd_caption;
struct kos_wnd_box wnd_clientbox;
u32 priority;
struct kos_lhead in_schedule;
u32 counter_add;
u32 cpu_usage;
u32 __reserved4;
};
#define KOS_APPDATA_SIZE 256
STATIC_ASSERT(sizeof(struct kos_appdata) == KOS_APPDATA_SIZE);
typedef struct {
unsigned p00;
union{
@ -47,7 +139,7 @@ typedef struct {
};
char p20;
const char *p21;
}ksys70_t;
} ksys70_t;
#pragma pack(pop)
@ -133,6 +225,8 @@ u32 STDCALL PciWrite8 (u32 bus, u32 devfn, u32 reg,u8 val) __asm__("PciWrite8");
u32 STDCALL PciWrite16(u32 bus, u32 devfn, u32 reg,u16 val)__asm__("PciWrite16");
u32 STDCALL PciWrite32(u32 bus, u32 devfn, u32 reg,u32 val)__asm__("PciWrite32");
struct kos_appdata* IMPORT GetCurrSlot(void) __asm__("GetCurrSlot");
#define pciReadByte(tag, reg) \
PciRead8(PCI_BUS_FROM_TAG(tag),PCI_DFN_FROM_TAG(tag),(reg))
@ -534,7 +628,8 @@ static inline void *KernelZeroAlloc(unsigned long size)
static inline int power_supply_is_system_supplied(void) { return -1; };
static inline int FS_Service(ksys70_t *k, int* err){
static inline int FS_Service(ksys70_t *k, int* err)
{
int status;
__asm__ __volatile__(
"call *__imp__FS_Service"