Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
org 0x7c00
...
bits 32
contA:
cli
lgdt [endGDT] ; I have tried this here and after "mov cr0, eax"
mov eax, cr0
or eax, 1
mov cr0, eax
xor eax, eax ; I have tried with and without these four lines.
xor ebx, ebx
xor edx, edx
xor ecx, ecx
jmp 0x8:pmode ; I have used memory dumps, log files, hlt instructions, etc. and determined that this line throws an error.
...
pmode:
hlt
GDT:
align 8
dd 0
dd 0
dw 0FFFFh
dw 0
db 0
db 10011010b
db 11001111b
; db 01011001b
; db 11110011b
db 0
dw 0FFFFh
dw 0
db 0
db 10010010b
db 11001111b
db 0
endGDT:
dw endGDT - GDT - 1 ; limit (Size of GDT)
dd GDT
Programming is 80% Math, 20% Grammar, and 10% Creativity <--- Do not make fun of my joke!
If you're new, check this out.
"00045097126e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x0d)
00045097126e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x08)"
That's what's wrong. Single step through your code in a debugger and check the values of those selectors.
Shouldn't the bits 32 directive come after you've jumped into protected mode? It's generating extra 00 00 bytes which are being run as add instructions, adding whatever is in al to whatever memory location is being pointed at by ax.
[Edit: correction - that's actually what a pair of zero bytes would do in 32-bit mode, but as it's in real mode it'll add whatever's in al to whatever memory location is pointed at by bx+si.]
And since you didn't post all the code, I'm going to assume all the previous errors apply as well.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
I put the bits 32 directive right after enabling the A20 address line. As I understand it, [seemingly] random things can occur if I try to run 16 bit code after enabling a20?
Programming is 80% Math, 20% Grammar, and 10% Creativity <--- Do not make fun of my joke!
If you're new, check this out.
Because it happened... and if I put a hlt instruction right before the jump, it gives the message "The CPU has been disabled by the guest operating system." Debuggers say the problem is the GDT
Programming is 80% Math, 20% Grammar, and 10% Creativity <--- Do not make fun of my joke!
If you're new, check this out.
Are you really sure that you want to enter protected mode in a vbr given the limitations? In any case, as mentioned ealier, use bits 32 after having already performed the mode switch. The message that you received when using HLT is completely fine and does not indicate an error.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
m12 wrote:I put the bits 32 directive right after enabling the A20 address line. As I understand it, [seemingly] random things can occur if I try to run 16 bit code after enabling a20?
There is no problem running 16 bit code after enable A20. In your case the CPU stay on 16 bit mode before and after enable A20, the problem is you cannot run 32bit code(since the bits 32) in 16 bit environment.
The same way have you initialized the segments before using other bootloader stuff.
For example: mov ax, 0x7C00 ;Depends where you want it to be
mov ,etc,etc
Anyone has a idea of making a ntfs bootsector?if yes PM me , plz.
LindusSystem wrote:It got fixed in my kernel after I did
mov cs,ax
Your kernel is obviously never getting executed...
If you want a crash, use that.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]