Simplify ds segment register management

This commit is contained in:
Loic Guegan 2021-05-02 19:10:15 +02:00
parent 5c3e2d90b3
commit 64a17f3e06
3 changed files with 28 additions and 25 deletions

View file

@ -58,12 +58,14 @@ void configure_tss(){
void task1(){
while(1){
asm("mov $0xABC, %rax");
asm("mov $1, %rdi;int $0x30");
}
}
void task2(){
while(1){
asm("mov $0xAEBC, %rax");
asm("mov $2, %rdi;int $0x30");
}
}

View file

@ -26,6 +26,9 @@
push %rbp
push %rsi
push %rdi
mov %ds, %rax
push %rax
mov 56(%rsp), %rax # Restore %rax
push %rax
mov $0x10, %ax
mov %ax, %ds
@ -33,6 +36,8 @@
.endm
.macro RESTORE_REGS
pop %rax
mov %rax,%ds
pop %rdi
pop %rsi
pop %rbp

View file

@ -23,32 +23,28 @@ void schedule(){
// Save current task
PROC *t=&procs[active_process];
t->registers.rdi=stack[0];
t->registers.rsi=stack[1];
t->registers.rbp=stack[2];
t->registers.rdx=stack[3];
t->registers.rcx=stack[4];
t->registers.rbx=stack[5];
t->registers.rax=stack[6];
t->registers.r15=stack[7];
t->registers.r14=stack[8];
t->registers.r13=stack[9];
t->registers.r12=stack[10];
t->registers.r11=stack[11];
t->registers.r10=stack[12];
t->registers.r9=stack[13];
t->registers.r8=stack[14];
t->registers.rip=stack[15];
t->registers.cs=stack[16];
t->registers.eflags=stack[17];
t->registers.rsp=stack[18];
t->registers.ss=stack[19];
if (t->registers.cs!=0x8)
t->registers.ds=0x23;
else
t->registers.ds=0x10;
t->registers.ds=stack[0];
t->registers.rdi=stack[1];
t->registers.rsi=stack[2];
t->registers.rbp=stack[3];
t->registers.rdx=stack[4];
t->registers.rcx=stack[5];
t->registers.rbx=stack[6];
t->registers.rax=stack[7];
t->registers.r15=stack[8];
t->registers.r14=stack[9];
t->registers.r13=stack[10];
t->registers.r12=stack[11];
t->registers.r11=stack[12];
t->registers.r10=stack[13];
t->registers.r9=stack[14];
t->registers.r8=stack[15];
t->registers.rip=stack[16];
t->registers.cs=stack[17];
t->registers.eflags=stack[18];
t->registers.rsp=stack[19];
t->registers.ss=stack[20];
//printk("Old task %d cs:%x rsp:%x ds:%x\n ",active_process+1, t->registers.cs,t->registers.rsp,t->registers.ds);
// Goto next task
active_process++;
if(active_process>=nproc)