Another Test-Things-Then-Get-To-PM-code that doesn't work...
Another Test-Things-Then-Get-To-PM-code that doesn't work...
[attachment deleted by admin]
Re:Another Test-Things-Then-Get-To-PM-code that doesn't work
Hm... I think that I know in what area the problem is...
I've been testing the code and come to the following result:
Everything works fine before this comment:
;;;;; Load the Global Descriptor Table and the Interrupt Descriptor Table ;;;;;
After that one, I load the GDT and IDT so I can't output any character to show where I am. My guess is that it is something with the jmp to Protected Mode. I came to this conclusion since I, directly after the code has gotten to PM, did put code to triple fault the processor (by loading Cs with an invalid selector). Normally, this would reset the computer but it doesn't. So it seems that the jmp is wrong. And it is probably nothing wrong with the GDT since a invalid GDT also triple fault the processor...
Please help... :-\
I've been testing the code and come to the following result:
Everything works fine before this comment:
;;;;; Load the Global Descriptor Table and the Interrupt Descriptor Table ;;;;;
After that one, I load the GDT and IDT so I can't output any character to show where I am. My guess is that it is something with the jmp to Protected Mode. I came to this conclusion since I, directly after the code has gotten to PM, did put code to triple fault the processor (by loading Cs with an invalid selector). Normally, this would reset the computer but it doesn't. So it seems that the jmp is wrong. And it is probably nothing wrong with the GDT since a invalid GDT also triple fault the processor...
Please help... :-\
Re:Another Test-Things-Then-Get-To-PM-code that doesn't work
I noticed this in your code:
Shouldnt your gdt look like this: This is just an example.
I'm referring to the -1 that you left out of your code.
Code: Select all
;;;;; Global Descriptor Table (GDT) ;;;;;
GlobalDescriptorTableRegister
dw GlobalDescriptorTableEnding -GlobalDescriptorTableBeginning
dd GlobalDescriptorTableBeginning
I'm referring to the -1 that you left out of your code.
Code: Select all
gdt:
dw gdt_end - gdt - 1
db gdt
Re:Another Test-Things-Then-Get-To-PM-code that doesn't work
Why should it be a -1?? In codes I've seen, I haven't noticed that...
Re:Another Test-Things-Then-Get-To-PM-code that doesn't work
Yeah its minus 1 in mine as well.
Im not sure why this is though
Im not sure this matters anyway as this only specifys teh limit of the GDT and i have seen soem boot loaders where this has been set to 0xFFFF.
Peter
Im not sure why this is though
Im not sure this matters anyway as this only specifys teh limit of the GDT and i have seen soem boot loaders where this has been set to 0xFFFF.
Peter
Re:Another Test-Things-Then-Get-To-PM-code that doesn't work
It didn't help... and I prefer to have the "- 1" removed from the code until I understand what it does and if it is needed...
But I really don't understand why the code doesn't work...
But I really don't understand why the code doesn't work...
Re:Another Test-Things-Then-Get-To-PM-code that doesn't work
It is -1 because that is the last byte. For example, an 8-byte descriptor starting at 0x00001000 doesn't end at 0x00001008, it ends at 0x00010007... 0-7 = 8 bytes.
Example of mine...
Example of mine...
Code: Select all
GDT0 DW 0x0000,0x0000,0x0000,0x0000
GDT1 DW 0xFFFF,0x0000,0x9A00,0x00CF
GDT2 DW 0xFFFF,0x0000,0x9200,0x00CF
GDTR DW GDTR-GDT0-1,GDT0,0x0000
IDT:
DW IH0,0x0008,0xEE00,0x0000
DW IH1,0x0008,0xEE00,0x0000
DW IH2,0x0008,0x8E00,0x0000
DW IH3,0x0008,0xEE00,0x0000
DW IH4,0x0008,0xEE00,0x0000
DW IH5,0x0008,0xEE00,0x0000
DW IH6,0x0008,0xEE00,0x0000
DW IH7,0x0008,0xEE00,0x0000
DW IH8,0x0008,0xEE00,0x0000
DW IH9,0x0008,0xEE00,0x0000
DW IHA,0x0008,0xEE00,0x0000
DW IHB,0x0008,0xEE00,0x0000
DW IHC,0x0008,0xEE00,0x0000
DW IHD,0x0008,0xEE00,0x0000
DW IHE,0x0008,0xEE00,0x0000
DW IHF,0x0008,0x0E00,0x0000
DW IH10,0x0008,0xEE00,0x0000
DW IH11,0x0008,0xEE00,0x0000
DW IH12,0x0008,0xEE00,0x0000
DW IH13,0x0008,0xEE00,0x0000
DW IH14,0x0008,0x0E00,0x0000
DW IH15,0x0008,0x0E00,0x0000
DW IH16,0x0008,0x0E00,0x0000
DW IH17,0x0008,0x0E00,0x0000
DW IH18,0x0008,0x0E00,0x0000
DW IH19,0x0008,0x0E00,0x0000
DW IH1A,0x0008,0x0E00,0x0000
DW IH1B,0x0008,0x0E00,0x0000
DW IH1C,0x0008,0x0E00,0x0000
DW IH1D,0x0008,0x0E00,0x0000
DW IH1E,0x0008,0x0E00,0x0000
DW IH1F,0x0008,0x0E00,0x0000
IDTR DW IDTR-IDT-1,IDT,0x0001
Re:Another Test-Things-Then-Get-To-PM-code that doesn't work
Okay... I think I understand... However, the code still doesn't work right... And I still think it is something wrong with the jmp to PM... But then again, it works perfectly to call a sub routine so the addressing may not be the problem... Oh God... ???DynatOS wrote: It is -1 because that is the last byte. For example, an 8-byte descriptor starting at 0x00001000 doesn't end at 0x00001008, it ends at 0x00010007... 0-7 = 8 bytes.
Re:Another Test-Things-Then-Get-To-PM-code that doesn't work
Nope, I don't use any emulators.DynatOS wrote: Are you using bochs?
Re:Another Test-Things-Then-Get-To-PM-code that doesn't work
Try this...
Code: Select all
;;;;; Enter Protected Mode ;;;;;
mov eax,cr0
inc ax ; This instead of Or Al,1 saves 1 byte
mov cr0,eax
jmp CLEAR ;Clear instruction prefetch cache
CLEAR:
DB 0x66
DB 0xEA
DD EnterProtectedMode
DW SystemCodeSelector
Re:Another Test-Things-Then-Get-To-PM-code that doesn't work
I can try it... but I don't really get it... Is that opcodes for a far jmp or?DynatOS wrote: Try this...
Code: Select all
;;;;; Enter Protected Mode ;;;;; mov eax,cr0 inc ax??????; This instead of Or Al,1 saves 1 byte mov cr0,eax jmp CLEAR ;Clear instruction prefetch cache CLEAR: DB 0x66 DB 0xEA DD EnterProtectedMode DW SystemCodeSelector
Re:Another Test-Things-Then-Get-To-PM-code that doesn't work
Yes, 0x66 is a 32-bit operand override, 0xEA is the far-jump code.