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)
|
||||
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\
|
||||
$(objects)
|
||||
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
|
||||
pop eax
|
||||
jnz gpf_handler_v86
|
||||
mov word [0xb8000], 0x0f00 | 'G'
|
||||
mov word [0xb8002], 0x0f00 | 'P'
|
||||
mov word [0xb8004], 0x0f00 | 'F'
|
||||
mov dword [0xb8000], 0x0f000f00 | 'G' | 'P' << 16
|
||||
mov dword [0xb8004], 0x0f000f00 | 'F' | '!' << 16
|
||||
.hlt:
|
||||
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 = (char*)0xb8000 + (160*3);
|
||||
uint32_t *tss_esp0 = (uint32_t*)0x20004;
|
||||
for(;;) {
|
||||
switch (ip[0]) {
|
||||
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';
|
||||
switch (ip[1]) {
|
||||
case 0x30:
|
||||
asm ("jmp jmp_usermode_test");
|
||||
asm ("mov %%eax, %%esp\nret"::"a"(*tss_esp0));
|
||||
for(;;);
|
||||
case 0x3:
|
||||
kbd_wait();
|
||||
|
4
kernel.c
4
kernel.c
@ -52,8 +52,10 @@ void print_cr4() {
|
||||
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 v86Code();
|
||||
__attribute((__no_caller_saved_registers__))
|
||||
extern void jmp_usermode_test();
|
||||
|
||||
/*
|
||||
@ -107,6 +109,6 @@ void start() {
|
||||
print_cr4();
|
||||
FARPTR v86_entry = i386LinearToFp(v86Code);
|
||||
enter_v86(0x8000, 0xFF00, FP_SEG(v86_entry), FP_OFF(v86_entry));
|
||||
//jmp_usermode_test();
|
||||
jmp_usermode_test();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user