Skip to content

Commit d0910d8

Browse files
committed
Synchronized Register State Handling
1 parent 674a3c5 commit d0910d8

5 files changed

Lines changed: 36 additions & 7 deletions

File tree

include/idt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ typedef struct {
1717
} __attribute__((packed)) idt_ptr_t;
1818

1919
typedef struct {
20-
uint32_t ds;
20+
uint32_t gs, fs, es, ds;
2121
uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax;
2222
uint32_t int_no, err_code;
2323
uint32_t eip, cs, eflags, useresp, ss;

src/ai/ai_model.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "timer.h"
1111
#include "types.h"
1212
#include "util.h"
13+
#include "vga.h"
1314
#include "smp_rally.h"
1415
#include "sched.h"
1516

src/cpu/isr.s

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ isr_common_stub:
8484
pusha
8585
mov ax, ds
8686
push eax
87+
mov ax, es
88+
push eax
89+
mov ax, fs
90+
push eax
91+
mov ax, gs
92+
push eax
93+
8794
mov ax, 0x10
8895
mov ds, ax
8996
mov es, ax
@@ -93,11 +100,16 @@ isr_common_stub:
93100
call isr_handler
94101
add esp, 4
95102
mov esp, eax
103+
96104
pop eax
97-
mov ds, ax
98-
mov es, ax
99-
mov fs, ax
100105
mov gs, ax
106+
pop eax
107+
mov fs, ax
108+
pop eax
109+
mov es, ax
110+
pop eax
111+
mov ds, ax
112+
101113
popa
102114
add esp, 8
103115
sti
@@ -107,6 +119,13 @@ irq_common_stub:
107119
pusha
108120
mov ax, ds
109121
push eax
122+
mov ax, es
123+
push eax
124+
mov ax, fs
125+
push eax
126+
mov ax, gs
127+
push eax
128+
110129
mov ax, 0x10
111130
mov ds, ax
112131
mov es, ax
@@ -116,11 +135,16 @@ irq_common_stub:
116135
call irq_handler
117136
add esp, 4
118137
mov esp, eax
138+
119139
pop eax
120-
mov ds, ax
121-
mov es, ax
122-
mov fs, ax
123140
mov gs, ax
141+
pop eax
142+
mov fs, ax
143+
pop eax
144+
mov es, ax
145+
pop eax
146+
mov ds, ax
147+
124148
popa
125149
add esp, 8
126150
sti

src/cpu/syscall.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "types.h"
1414
#include "util.h"
1515
#include "vfs.h"
16+
#include "heap.h"
1617

1718
#define SYS_COPY_LIMIT 4096u
1819

src/kernel/sched.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,9 @@ process_t* switch_task(registers_t* saved_stack, process_t** previous) {
669669
current->eip = saved_stack->eip;
670670
current->cs = saved_stack->cs;
671671
current->ds = saved_stack->ds;
672+
current->es = saved_stack->es;
673+
current->fs = saved_stack->fs;
674+
current->gs = saved_stack->gs;
672675
current->ss = saved_stack->ss;
673676

674677
if (current->state == PROCESS_RUNNING) {

0 commit comments

Comments
 (0)