2020-07-12 14:30:16 -05:00
|
|
|
#include <sys/syscalls.h>
|
2020-07-22 19:35:23 -05:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <tasking.h>
|
2020-07-12 14:30:16 -05:00
|
|
|
|
|
|
|
#define QUAUX(X) #X
|
|
|
|
#define QU(X) QUAUX(X)
|
2019-05-04 10:41:42 -05:00
|
|
|
|
2019-02-11 09:47:28 -06:00
|
|
|
void yield() {
|
|
|
|
asm volatile(" \
|
2020-07-12 16:29:57 -05:00
|
|
|
mov $" QU(SYSCALL_YIELD) ", %%eax; \
|
2019-02-11 09:47:28 -06:00
|
|
|
int $80; \
|
2020-07-12 16:29:57 -05:00
|
|
|
"::"b"(0));
|
2019-02-11 09:47:28 -06:00
|
|
|
}
|
2019-02-11 09:48:50 -06:00
|
|
|
|
2020-07-29 10:35:04 -05:00
|
|
|
void create_proc(void* start,void* address_space,void* param1,void* param2) {
|
2019-05-05 13:30:01 -05:00
|
|
|
asm volatile(" \
|
2020-07-12 16:29:57 -05:00
|
|
|
mov $" QU(SYSCALL_CREATEPROC) ", %%eax; \
|
2019-05-05 13:30:01 -05:00
|
|
|
int $80; \
|
2020-07-29 10:35:04 -05:00
|
|
|
"::"b"(start),"c"(address_space),"d"(param1),"S"(param2));
|
2019-05-23 20:41:33 -05:00
|
|
|
}
|
2019-08-04 13:14:35 -05:00
|
|
|
|
2019-08-26 07:43:25 -05:00
|
|
|
__attribute__((noreturn)) void exit(int code) {
|
|
|
|
code=code&0xff;
|
2019-08-25 17:32:08 -05:00
|
|
|
asm volatile(" \
|
2020-07-12 14:30:16 -05:00
|
|
|
mov $" QU(SYSCALL_EXIT) ", %%eax; \
|
2019-08-25 17:32:08 -05:00
|
|
|
int $80; \
|
|
|
|
"::"b"(code));
|
2019-08-26 07:43:25 -05:00
|
|
|
for(;;);
|
2019-08-25 17:32:08 -05:00
|
|
|
}
|
2020-07-12 14:28:58 -05:00
|
|
|
|
|
|
|
|
2020-07-29 08:09:53 -05:00
|
|
|
void block_thread(thread_state state) {
|
2020-07-12 14:28:58 -05:00
|
|
|
asm volatile(" \
|
2020-07-12 14:30:16 -05:00
|
|
|
mov $" QU(SYSCALL_BLOCK) ", %%eax; \
|
2020-07-12 14:28:58 -05:00
|
|
|
int $80; \
|
|
|
|
"::"b"(state));
|
|
|
|
}
|
|
|
|
|
2020-07-29 08:09:53 -05:00
|
|
|
void unblock_thread(pid_t pid,pid_t tid) {
|
2020-07-12 14:28:58 -05:00
|
|
|
asm volatile(" \
|
2020-07-12 14:30:16 -05:00
|
|
|
mov $" QU(SYSCALL_UNBLOCK) ", %%eax; \
|
2020-07-12 14:28:58 -05:00
|
|
|
int $80; \
|
2020-07-20 09:51:30 -05:00
|
|
|
"::"b"(pid),"c"(tid));
|
|
|
|
}
|
2020-08-02 14:37:23 -05:00
|
|
|
|
|
|
|
char check_proc_exists(pid_t pid) {
|
|
|
|
char exists;
|
|
|
|
asm volatile(" \
|
|
|
|
mov $" QU(SYSCALL_CHECK_PROC_EXISTS) ", %%eax; \
|
|
|
|
int $80; \
|
|
|
|
":"=c"(exists):"b"(pid));
|
|
|
|
return exists;
|
|
|
|
}
|