Handle cli/sti in scheduler: fake i flag with id flag.

This commit is contained in:
Ivan Baravy 2020-05-09 06:41:32 +03:00
parent 0d07b5810f
commit 90d1aaaccc
3 changed files with 25 additions and 15 deletions

View File

@ -6,13 +6,15 @@
sigjmp_buf trampoline; sigjmp_buf trampoline;
__attribute__((__stdcall__)) __attribute__((__stdcall__))
uint32_t umka_sched_add_thread(appdata_t *app) { uint32_t umka_sched_add_thread(appdata_t *app) {
fprintf(stderr, "umka_new_sys_threads before\n"); fprintf(stderr, "umka_new_sys_threads before\n");
fprintf(stderr, "kos_task_count: %d\n", kos_task_count); fprintf(stderr, "kos_task_count: %d\n", kos_task_count);
if (!sigsetjmp(trampoline, 1)) { if (!sigsetjmp(trampoline, 1)) {
__asm__ __inline__ __volatile__ ( __asm__ __inline__ __volatile__ (
"pushfd;"
"bts dword ptr [esp], 21;"
"popfd;"
"mov esp, eax" "mov esp, eax"
: :
: "a"(app->saved_esp) : "a"(app->saved_esp)

View File

@ -41,7 +41,18 @@ public kos_acpi_ssdt_size
public stack_init public stack_init
public net_add_device public net_add_device
cli equ nop macro cli {
pushfd
btr dword[esp], 21
popfd
}
macro sti {
pushfd
bts dword[esp], 21
popfd
}
iretd equ retd iretd equ retd
lang fix en lang fix en
@ -287,8 +298,6 @@ public umka_os
proc umka_os uses ebx esi edi proc umka_os uses ebx esi edi
call kos_init call kos_init
; mov [fdd_motor_status], 0
mov eax, -1 mov eax, -1
mov edi, thr_slot_map+4 mov edi, thr_slot_map+4
mov [edi-4], dword 0xFFFFFFF8 mov [edi-4], dword 0xFFFFFFF8
@ -365,14 +374,6 @@ proc umka_os uses ebx esi edi
ret ret
endp endp
; in: edx -> APPDATA for OS/IDLE slot
; in: ebx = stack base
proc s2etup_os_slot
ret
endp
extrn pci_read extrn pci_read
proc pci_read_reg uses ebx esi edi proc pci_read_reg uses ebx esi edi
mov ecx, eax mov ecx, eax

View File

@ -1,4 +1,5 @@
#include <setjmp.h> #include <setjmp.h>
#define __USE_GNU
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <sys/time.h> #include <sys/time.h>
@ -7,16 +8,22 @@
struct itimerval timeout = {.it_value = {.tv_sec = 0, .tv_usec = 10000}}; struct itimerval timeout = {.it_value = {.tv_sec = 0, .tv_usec = 10000}};
void scheduler(int signo, siginfo_t *info, void *context) { void scheduler(int signo, siginfo_t *info, void *context) {
(void)signo; (void)signo;
(void)info; (void)info;
(void)context; (void)context;
// printf("##### switching from task %u\n", kos_current_task); // printf("##### switching from task %u\n", kos_current_task);
ucontext_t *ctx = context;
if (!sigsetjmp(*kos_slot_base[kos_current_task].fpu_state, 1)) { if (!sigsetjmp(*kos_slot_base[kos_current_task].fpu_state, 1)) {
// printf("##### saved\n"); // printf("##### saved\n");
kos_current_task += 1; if (ctx->uc_mcontext.__gregs[REG_EFL] & (1 << 21)) {
if (kos_current_task == kos_task_count) { kos_current_task += 1;
kos_current_task = 1; if (kos_current_task == kos_task_count) {
kos_current_task = 1;
}
} else {
printf("########## cli ############\n");
} }
kos_current_slot = kos_slot_base + kos_current_task; kos_current_slot = kos_slot_base + kos_current_task;
printf("##### kos_current_task: %u\n", kos_current_task); printf("##### kos_current_task: %u\n", kos_current_task);