2019-05-04 10:41:42 -05:00
|
|
|
#include <stdint.h>
|
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-20 10:07:46 -05:00
|
|
|
void createProcCr3(void* start,void* cr3) {
|
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-20 10:07:46 -05:00
|
|
|
"::"b"(start),"d"(0),"c"(cr3));
|
2019-05-05 13:30:01 -05:00
|
|
|
}
|
2019-05-23 20:41:33 -05:00
|
|
|
|
2020-07-20 10:07:46 -05:00
|
|
|
void createProcCr3Param(void* start,void* cr3,uint32_t param1,uint32_t param2) {
|
2019-05-23 20:41:33 -05:00
|
|
|
asm volatile(" \
|
2020-07-12 16:29:57 -05:00
|
|
|
mov $" QU(SYSCALL_CREATEPROC) ", %%eax; \
|
2019-05-23 20:41:33 -05:00
|
|
|
int $80; \
|
2020-07-20 10:07:46 -05:00
|
|
|
"::"b"(start),"c"(cr3),"d"(1),"S"(param1),"D"(param2));
|
2019-05-23 20:41:33 -05:00
|
|
|
}
|
2019-08-04 13:14:35 -05:00
|
|
|
|
|
|
|
void yieldToPID(uint32_t pid) {
|
|
|
|
asm volatile(" \
|
2020-07-12 16:29:57 -05:00
|
|
|
mov $" QU(SYSCALL_YIELD) ", %%eax; \
|
2019-08-04 13:14:35 -05:00
|
|
|
int $80; \
|
|
|
|
"::"b"(pid));
|
|
|
|
}
|
2019-08-25 17:32:08 -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-20 10:07:46 -05:00
|
|
|
void blockThread(ThreadState 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-20 10:07:46 -05:00
|
|
|
void unblockThread(pid_t pid,uint32_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));
|
|
|
|
}
|