Use BIOS funcions from long mode ---
Posted: Sun Apr 03, 2016 7:07 am
Hello,
in my OS (64bit) I would change the Displayresolution with the bios int 10h.
To switch I use the following code: http://forum.osdev.org/viewtopic.php?f=1&t=23125
The Code works fine without Bios Calls, but when i am insert a Bios Call (e.g. ), the processor shutdown.
what could be the Problem?
Another Question about the GDT:
In P-Mode VBox reads as follows:
I am grateful for every advice,
Nicky
If you need more Code let me know.
in my OS (64bit) I would change the Displayresolution with the bios int 10h.
To switch I use the following code: http://forum.osdev.org/viewtopic.php?f=1&t=23125
Code: Select all
use64 ;
bios_call:
cli ;Interrupts off
;save all GPR's
push rax
push rbx
push rcx
push rdx
push rsi
push rdi
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
mov rbx, _old_esp ;save Stackpointer
mov [rbx], rsp
mov rsp, 6800h ;new Stackpointer
sidt [System.oldidt] ;save IDT
push 40h ;Realmode Desc 64k laden
push @f
retfq
use16 ;16 Bit P-Mode
@@:
;PE und PM off
mov eax, cr0
and eax, 7FFFFFFEh
mov cr0, eax
;ESP to RM Addr
mov esp, 6700h
;ds, es, ss = NULL
xor eax, eax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
;Far Jump
jmp 0x0:@f
@@:
;Realmode IDT
lidt [System.nullidt]
;---------------------------------------------------------------------------------------------------------------------
;BIOS Calls here
;---------------------------------------------------------------------------------------------------------------------
;PE und PM on
mov eax, cr0
or eax, 80000001h
mov cr0, eax
jmp @f
@@:
; Enable long mode by setting the EFER.LME flag in MSR 0xC0000080
mov ecx, 0C0000080h
rdmsr
or eax, 100h
wrmsr
db 66h, 0eah
dd _p64_mode3
dw 28h
use64
_p64_mode3:
jmp @f
@@:
lidt [System.oldidt]
;restore Stackpointer
mov rbx, _old_esp
mov rsp, [rbx]
;restore all GPR's
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
pop rax
sti ;Interrupt on
ret ;Exit
align 16
_old_esp dq 0
align 4
_modus_old dw 0
_oldtr dw 0
Code: Select all
mov ax, 12h
int 10h
what could be the Problem?
Another Question about the GDT:
Code: Select all
System:
.GDT:
dd 0,0
._CODE32: ;0x8
dw 0xFFFF
dw 0
db 0
db 10011010b
db 11001111b ;DB und G Bit gesetzt
db 0
._DATA32: ;0x10
dw 0xFFFF
dw 0
db 0
db 10010010b
db 11001111b ;DB und G Bit gesetzt
db 0
._CODE64: ;0x28
dw 0xFFFF
dw 0
db 0
db 10011010b
db 10101111b ;DB und G Bit gesetzt
db 0
._TSS64: dw 104d ;0x30
dw 0000h
db 1h
db 10001001b
dw 00000000b
._CODE16: ;0x40
dw 0FFFFh ; compatibility mode code descriptor
dw 0
db 0
db 10011010b
db 0h
db 0
._DATA16: ;0x30
dw 0FFFFh ; compatibility mode data descriptor
dw 0
db 0
db 10010010b
db 0h
db 0
; dd 0, 0
In L-Mode VBox reads as follows:0008 CodeER Bas=00000000 Lim=fffff000 DPL=0 P A G BIG AVL=0 L=0
0010 DataRW Bas=00000000 Lim=fffff000 DPL=0 P A G BIG AVL=0 L=0
0018 CodeER Bas=00000000 Lim=fffff000 DPL=3 P NA G BIG AVL=0 L=0
0020 DataRW Bas=00000000 Lim=fffff000 DPL=3 P NA G BIG AVL=0 L=0
0028 CodeER Bas=00000000 Lim=fffff000 DPL=0 P NA G AVL=0 L=1
0030 Tss32A Bas=00010000 Lim=00000068 DPL=0 P NB AVL=0 R=0
0040 CodeER Bas=00000000 Lim=0000ffff DPL=0 P NA AVL=0 L=0
0048 VERR_INVALID_SELECTOR
Why has ._Code64 Index 0x28 and not 0x18?0008 CodeER Bas=00000000 Lim=ffffffff DPL=0 P A G BIG AVL=0 L=0
0010 DataRW Bas=00000000 Lim=ffffffff DPL=0 P A G BIG AVL=0 L=0
0018 CodeER Bas=00000000 Lim=ffffffff DPL=3 P NA G BIG AVL=0 L=0
0020 DataRW Bas=00000000 Lim=ffffffff DPL=3 P NA G BIG AVL=0 L=0
0028 CodeER Bas=00000000 Lim=ffffffff DPL=0 P A G AVL=0 L=1
0030 Tss64B Bas=0000000000010000 Lim=00000068 DPL=0 P B AVL=0 R=0
003c ConfER Bas=f053f000 Lim=0000ef57 DPL=3 P A AVL=0 L=0
0044 CodeEO Bas=f04dc000 Lim=00000022 DPL=3 P NA AVL=0 L=0
004c Ill-3 41 f8 00 f0 fe e3 00 f0 DPL=3 P
0054 CodeEO Bas=f059f000 Lim=0000e739 DPL=3 P NA AVL=0 L=0
005c Trap64 Sel:Off=f000:f000f0a4f000e82e DPL=3 P
0068 VERR_INVALID_SELECTOR
I am grateful for every advice,
Nicky
If you need more Code let me know.