mirror of
https://github.com/drasko/codezero.git
synced 2026-01-12 10:53:16 +01:00
Added mutex_control syscall for userspace mutexes.
- Compiles and Codezero runs as normal without touching mutex implementation - Mutex implementation needs testing. The mutex control syscall allows userspace programs to declare any virtual address as a mutex lock and ask for help from the kernel syscall for resolving locking contentions.
This commit is contained in:
@@ -62,11 +62,11 @@ struct kip {
|
||||
u32 thread_switch;
|
||||
u32 schedule;
|
||||
u32 getid;
|
||||
u32 mutex_control;
|
||||
|
||||
u32 arch_syscall0;
|
||||
u32 arch_syscall1;
|
||||
u32 arch_syscall2;
|
||||
u32 arch_syscall3;
|
||||
|
||||
u32 utcb;
|
||||
|
||||
|
||||
14
include/l4/api/mutex.h
Normal file
14
include/l4/api/mutex.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef __MUTEX_CONTROL_H__
|
||||
#define __MUTEX_CONTROL_H__
|
||||
|
||||
/* Request ids for mutex_control syscall */
|
||||
|
||||
#if defined (__KERNEL__)
|
||||
#define MUTEX_CONTROL_LOCK L4_MUTEX_LOCK
|
||||
#define MUTEX_CONTROL_UNLOCK L4_MUTEX_UNLOCK
|
||||
#endif
|
||||
|
||||
#define L4_MUTEX_LOCK 0
|
||||
#define L4_MUTEX_UNLOCK 1
|
||||
|
||||
#endif /* __MUTEX_CONTROL_H__*/
|
||||
@@ -23,7 +23,8 @@
|
||||
#define sys_kread_offset 0x28
|
||||
#define sys_kmem_control_offset 0x2C
|
||||
#define sys_time_offset 0x30
|
||||
#define syscalls_end_offset sys_time_offset
|
||||
#define sys_mutex_control_offset 0x34
|
||||
#define syscalls_end_offset sys_mutex_control_offset
|
||||
#define SYSCALLS_TOTAL ((syscalls_end_offset >> 2) + 1)
|
||||
|
||||
void print_syscall_context(struct ktcb *t);
|
||||
@@ -41,5 +42,6 @@ int sys_getid(struct syscall_context *);
|
||||
int sys_kread(struct syscall_context *);
|
||||
int sys_kmem_control(struct syscall_context *);
|
||||
int sys_time(struct syscall_context *);
|
||||
int sys_mutex_control(struct syscall_context *);
|
||||
|
||||
#endif /* __SYSCALL_H__ */
|
||||
|
||||
@@ -65,9 +65,12 @@
|
||||
#define virt_to_phys(addr) ((unsigned int)(addr) - KERNEL_OFFSET)
|
||||
#endif
|
||||
|
||||
#define PAGER_ADDR(x) ((x >= INITTASK_AREA_START) && (x < INITTASK_AREA_END))
|
||||
#define KERN_ADDR(x) ((x >= KERNEL_AREA_START) && (x < KERNEL_AREA_END))
|
||||
#define USER_ADDR(x) ((x >= USER_AREA_START) && (x < USER_AREA_END))
|
||||
|
||||
#define UTCB_ADDR(x) ((x >= UTCB_AREA_START) && (x < UTCB_AREA_END))
|
||||
#define SHM_ADDR(x) ((x >= SHM_AREA_START) && (x < SHM_AREA_END))
|
||||
#define USER_ADDR(x) (((x >= USER_AREA_START) && (x < USER_AREA_END)) || \
|
||||
UTCB_ADDR(x) || SHM_ADDR(x) || PAGER_ADDR(x))
|
||||
#define PRIVILEGED_ADDR(x) (KERN_ADDR(x) || (x >= ARM_HIGH_VECTOR) || \
|
||||
(x >= IO_AREA_START && x < IO_AREA_END))
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ struct waitqueue {
|
||||
struct ktcb *task;
|
||||
};
|
||||
|
||||
#define WAKEUP_ASYNC 0
|
||||
|
||||
enum wakeup_flags {
|
||||
WAKEUP_INTERRUPT = (1 << 0),
|
||||
WAKEUP_SYNC = (1 << 1)
|
||||
@@ -74,5 +76,7 @@ void wake_up(struct waitqueue_head *wqh, unsigned int flags);
|
||||
int wake_up_task(struct ktcb *task, unsigned int flags);
|
||||
void wake_up_all(struct waitqueue_head *wqh, unsigned int flags);
|
||||
|
||||
int wait_on(struct waitqueue_head *wqh);
|
||||
|
||||
#endif /* __LIB_WAIT_H__ */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user