diff --git a/pci.c b/linux/pci.c similarity index 100% rename from pci.c rename to linux/pci.c diff --git a/linux/thread.c b/linux/thread.c new file mode 100644 index 0000000..be15c49 --- /dev/null +++ b/linux/thread.c @@ -0,0 +1,39 @@ +#include +#include +#include +#include +#include "../umka.h" + +sigjmp_buf trampoline; + + +__attribute__((__stdcall__)) +uint32_t umka_new_sys_threads(void (*func)(void), void *stack, int type) { + (void)type; + (void)func; + fprintf(stderr, "umka_new_sys_threads before\n"); +// kos_slot_base[kos_task_count].fpu_state = malloc(4096); + fprintf(stderr, "kos_task_count: %d\n", kos_task_count); + if (!sigsetjmp(trampoline, 1)) { + __asm__ __inline__ __volatile__ ( + "mov esp, eax;" + "push ecx" + : + : "a"(stack), + "c"(func) + : "memory"); + if (!sigsetjmp(*kos_slot_base[kos_task_count++].fpu_state, 1)) { + longjmp(trampoline, 1); + } else { + __asm__ __inline__ __volatile__ ( + "pop ecx;" + "call ecx" + : + : + : "memory"); + } + } + fprintf(stderr, "umka_new_sys_threads after\n"); + return 0; +} + diff --git a/linux/thread.h b/linux/thread.h new file mode 100644 index 0000000..6ef8c18 --- /dev/null +++ b/linux/thread.h @@ -0,0 +1,8 @@ +#ifndef THREAD_H_INCLUDED +#define THREAD_H_INCLUDED + +#include + +uint32_t umka_new_sys_threads(void (*func)(void), void *stack, int type); + +#endif // THREAD_H_INCLUDED