fuckfuck
This commit is contained in:
@@ -41,6 +41,7 @@ switchProcess:
|
||||
mov eax, [esi + 20] ; PCB.RING находится по смещению 20
|
||||
cmp eax, 3
|
||||
je .ring3
|
||||
sti
|
||||
ret ; Для ring 0 просто возвращаемся
|
||||
.ring3:
|
||||
jmp trapret ; Для ring 3 переходим через trapret
|
||||
|
||||
+10
-7
@@ -125,21 +125,21 @@ void idle()
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
void task1(int arg1, char* arg2)
|
||||
void task1()
|
||||
{
|
||||
while (1) {
|
||||
if (arg1 == 42)
|
||||
printf("task1 0x%x %s\n", arg1, arg2);
|
||||
else
|
||||
printf("ZHOPA %s\n", arg2);
|
||||
printf("task1\n");
|
||||
}
|
||||
}
|
||||
|
||||
void task2(int arg1, int arg2)
|
||||
void task2()
|
||||
{
|
||||
while (1) { arg1++; printf("task2 %X %X\n", arg1, arg2); }
|
||||
int a = 0;
|
||||
while (1) { a++; printf("task2 %X\n", a); }
|
||||
}
|
||||
|
||||
void jump_usermode2(void) ;
|
||||
|
||||
void scheduler_init()
|
||||
{
|
||||
task_create((EntryPoint)idle, NULL, 0, 0);
|
||||
@@ -149,6 +149,7 @@ void scheduler_init()
|
||||
task_create((EntryPoint)task1, args1, 2, 0);
|
||||
void* args2[] = {(void*)69, (void*)420};
|
||||
task_create((EntryPoint)task2, args2, 2, 0);
|
||||
jump_usermode2();
|
||||
}
|
||||
|
||||
#include "../include/string.h"
|
||||
@@ -200,6 +201,8 @@ void jump_usermode2(void) {
|
||||
(uint32_t)user_code_virt, code_pte, code_pte & ~0xFFF,
|
||||
(code_pte & 0x2) ? "writable" : "read-only",
|
||||
(code_pte & 0x4) ? "user" : "supervisor");
|
||||
|
||||
task_create(user_code_virt, NULL, 0, 3);
|
||||
|
||||
// Switch to user mode with interrupts enabled
|
||||
asm volatile (
|
||||
|
||||
Reference in New Issue
Block a user