From 2348172240f59017b4e1f4e2ee87868e03f2b42e Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Mon, 4 Jul 2022 21:33:58 +0300 Subject: [PATCH] switched to 16bit mode, but int 10h hangs --- efitest.asm | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/efitest.asm b/efitest.asm index bae6aa2..ae804dd 100644 --- a/efitest.asm +++ b/efitest.asm @@ -116,7 +116,7 @@ mmapbuf: times 4096 db 0 str_hello db 'hello!',13,10,0 align 4 -gdtlim dw 23 +gdtlim dw 31 gdtbase dq gdt align 8 @@ -128,7 +128,9 @@ gdt: ; 0: null segment ; 2: data - base:0, lim:4g, G:4k, 32bit, avl, pres|app, dpl:0, type:data/rw dd 0x0000ffff dd 0x00cf9200 - + ; 3: code16 + dd 0x0000ffff + dd 0x00009a00 bits 32 start32: @@ -151,13 +153,8 @@ start32: and eax, 0fffffeffh wrmsr - mov edi, 0a0000h - mov ecx, 16000 - mov eax, 00ff0000h - rep stosd - - mov esi, str_hello - call ser_putstr + ; load 16bit code segment and jump to 16bit code + jmp 0x18:start16 .hang: hlt jmp .hang @@ -186,4 +183,44 @@ ser_putstr: align 4 + ; real mode IDTR pseudo-descriptor pointing to the IVT at addr 0 + dw 0 +rmidt: dw 3ffh + dd 0 + + bits 16 +start16: + ; disable protection + mov eax, cr0 + and eax, 0fffffffeh + mov cr0, eax + ; load cs <- 0 + jmp 0:.loadcs0 +.loadcs0: + ; zero data segments + xor ax, ax + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + ; move stack to the top of 640k + mov ax, 9000h + mov ss, ax + xor sp, sp + + ; run 16bit video bios test + mov ax, 13h + ;int 10h + + mov ax, 0a000h + mov es, ax + xor di, di + mov cx, 32000 + mov ax, 6767h + rep stosw + +.hang: hlt + jmp .hang + + align 4 end: -- 1.7.10.4