V86 returns to caller
This commit is contained in:
parent
8bfcd4fd19
commit
1545a9a790
1
Makefile
1
Makefile
@ -9,7 +9,6 @@ CFLAGS = -target "i686-elf" -m32 -ffreestanding -march=pentium-m -fno-stack-prot
|
|||||||
|
|
||||||
all: $(objects)
|
all: $(objects)
|
||||||
nasm boot.nasm -o boot.bin
|
nasm boot.nasm -o boot.bin
|
||||||
# not sure why but if interrupt.c has any optimization everything just breaks immediately
|
|
||||||
gcc -Tlink.ld -m32 -ffreestanding -nostartfiles -nostdlib -o kernel.bin\
|
gcc -Tlink.ld -m32 -ffreestanding -nostartfiles -nostdlib -o kernel.bin\
|
||||||
$(objects)
|
$(objects)
|
||||||
dd bs=256 count=1 conv=notrunc if=boot.bin of=virtdisk.bin
|
dd bs=256 count=1 conv=notrunc if=boot.bin of=virtdisk.bin
|
||||||
|
@ -20,9 +20,8 @@ and eax, 1 << 17 ; VM flag
|
|||||||
test eax, eax
|
test eax, eax
|
||||||
pop eax
|
pop eax
|
||||||
jnz gpf_handler_v86
|
jnz gpf_handler_v86
|
||||||
mov word [0xb8000], 0x0f00 | 'G'
|
mov dword [0xb8000], 0x0f000f00 | 'G' | 'P' << 16
|
||||||
mov word [0xb8002], 0x0f00 | 'P'
|
mov dword [0xb8004], 0x0f000f00 | 'F' | '!' << 16
|
||||||
mov word [0xb8004], 0x0f00 | 'F'
|
|
||||||
.hlt:
|
.hlt:
|
||||||
hlt
|
hlt
|
||||||
jmp .hlt
|
jmp .hlt
|
||||||
|
@ -128,6 +128,7 @@ void gpf_handler_v86(struct interrupt_frame *frame, unsigned long error_code) {
|
|||||||
// vga += (sizeof(uint8_t)*2)*2;
|
// vga += (sizeof(uint8_t)*2)*2;
|
||||||
//}
|
//}
|
||||||
vga = (char*)0xb8000 + (160*3);
|
vga = (char*)0xb8000 + (160*3);
|
||||||
|
uint32_t *tss_esp0 = (uint32_t*)0x20004;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
switch (ip[0]) {
|
switch (ip[0]) {
|
||||||
case 0x66: // O32
|
case 0x66: // O32
|
||||||
@ -176,7 +177,7 @@ void gpf_handler_v86(struct interrupt_frame *frame, unsigned long error_code) {
|
|||||||
vga[0] = 'I'; vga[2]++; if (vga[2] < '0') vga[2] = '0';
|
vga[0] = 'I'; vga[2]++; if (vga[2] < '0') vga[2] = '0';
|
||||||
switch (ip[1]) {
|
switch (ip[1]) {
|
||||||
case 0x30:
|
case 0x30:
|
||||||
asm ("jmp jmp_usermode_test");
|
asm ("mov %%eax, %%esp\nret"::"a"(*tss_esp0));
|
||||||
for(;;);
|
for(;;);
|
||||||
case 0x3:
|
case 0x3:
|
||||||
kbd_wait();
|
kbd_wait();
|
||||||
|
4
kernel.c
4
kernel.c
@ -52,8 +52,10 @@ void print_cr4() {
|
|||||||
printDword(reg, 0xB8000 + (160*5) + 50 + 8*4 + 4);
|
printDword(reg, 0xB8000 + (160*5) + 50 + 8*4 + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__attribute((__no_caller_saved_registers__))
|
||||||
extern void enter_v86(uint32_t ss, uint32_t esp, uint32_t cs, uint32_t eip);
|
extern void enter_v86(uint32_t ss, uint32_t esp, uint32_t cs, uint32_t eip);
|
||||||
extern void v86Code();
|
extern void v86Code();
|
||||||
|
__attribute((__no_caller_saved_registers__))
|
||||||
extern void jmp_usermode_test();
|
extern void jmp_usermode_test();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -107,6 +109,6 @@ void start() {
|
|||||||
print_cr4();
|
print_cr4();
|
||||||
FARPTR v86_entry = i386LinearToFp(v86Code);
|
FARPTR v86_entry = i386LinearToFp(v86Code);
|
||||||
enter_v86(0x8000, 0xFF00, FP_SEG(v86_entry), FP_OFF(v86_entry));
|
enter_v86(0x8000, 0xFF00, FP_SEG(v86_entry), FP_OFF(v86_entry));
|
||||||
//jmp_usermode_test();
|
jmp_usermode_test();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
v86.nasm
1
v86.nasm
@ -71,6 +71,7 @@ jmp $
|
|||||||
global enter_v86
|
global enter_v86
|
||||||
enter_v86:
|
enter_v86:
|
||||||
mov ebp, esp ; save stack pointer
|
mov ebp, esp ; save stack pointer
|
||||||
|
mov dword [0x20004], ebp ; tss ESP0
|
||||||
push dword [ebp+4] ; ss
|
push dword [ebp+4] ; ss
|
||||||
push dword [ebp+8] ; esp
|
push dword [ebp+8] ; esp
|
||||||
pushfd ; eflags
|
pushfd ; eflags
|
||||||
|
Loading…
Reference in New Issue
Block a user