More Probs with PMode
Re:More Probs with PMode
I think I answered this already.
Try using ORG 0x7c00, which will be added to your offset. Once you switch the processor, the CS value is what you put in the GDT (specifically the base address of 0).
You need to put some code in your 32-bit 'section'. Even jmp $ would prevent the processor from walking through the RAM and resetting.
As far as triple-faulting goes, clean up some of this other stuff and see where you are.
Try using ORG 0x7c00, which will be added to your offset. Once you switch the processor, the CS value is what you put in the GDT (specifically the base address of 0).
You need to put some code in your 32-bit 'section'. Even jmp $ would prevent the processor from walking through the RAM and resetting.
As far as triple-faulting goes, clean up some of this other stuff and see where you are.
Re:More Probs with PMode
No, they are unrelated issues. It is possible to set the a20 line in real mode and access the so-called 'high memory area' (the 64K-16k area above the first 1M. A system running in real mode which has 21 or more address lines (i.e., the 80286 and later) is capable of addressing this due to a quirk of the segment:offset scheme which is explained in detail elsewhere). This is, in fact, the primary function of the MS-DOS 'himem.sys' driver.Tom wrote: doesn't A20 have to be done after pmode?
You might want to see my explanation/rant on segmentation and another explanation gave of the a20 line to help clarify things (though each has a few embarassing typos and errors, they are mostly correct).
Re:More Probs with PMode
Hey Guys
I think you did say this before crazy budda but i tried it then and again when you posted again and i just can't get it to work for the life of me. Is it a problem with my GDT Tables cos thats all i can think it is or do i have to set up all segments as soon as i switch to PMode?
Cheers
Peter
I think you did say this before crazy budda but i tried it then and again when you posted again and i just can't get it to work for the life of me. Is it a problem with my GDT Tables cos thats all i can think it is or do i have to set up all segments as soon as i switch to PMode?
Cheers
Peter
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:More Probs with PMode
Code: Select all
mov ax, 0
mov cs, ax
This is what could've happened if your jump reached your PMODECODE.
however, your bootcode is assembled with org 0 -> thus PMODECODE is an offset within [0..511], and your LINEAR_CODE_SELECTOR has a base address of 0, thus the physical address you jump to is somewhere in realmode Interrupt vector Table, not your own code! thus chances are that the behaviour is even more strange ...
try
Code: Select all
jmp LINEAR_CODE_SELECTOR:PMODECODE+0x7c00
Re:More Probs with PMode
Tryed the Jmp LINEAR_CODE_SEL:PMODECODE + 0x7c00 with little luck still triple faults teh CPU, God PMode is a pain.
Peter
Peter
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:More Probs with PMode
Code: Select all
[org 0x0000]
jmp BOOT
Code: Select all
GDTptr:
dw GDT_END - GDT - 1 ; GDT limit
dd GDT ; linear, physical address of GDT
Code: Select all
cli
mov ax,0x9000
mov ss,ax
mov sp,0xFFFF
Code: Select all
jmp LINEAR_CODE_SEL:PMODECODE
Code: Select all
[BITS 32]
PMODECODE:
mov ax,0x0
mov cs,ax
mov ds,ax
mov es,ax
mov fs,ax
mov ax,0x10
mov gs,ax
try
Code: Select all
[BITS 32]
PMODECODE:
mov ax, LINEAR_DATA_SEL
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
here: jmp here
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:More Probs with PMode
now, if - as crazybuddah wisely suggested - you turn into
and thus assuming that you'll be loaded with CS = 0 and IP = 7C00, you should
to force CS = 0 if you were actually loaded with CS = 7c0.
No GDTPTR conversion is required, and your JMP CODE_SELECTOR:PMODE_CODE should be valid.
however, you should then
so that you use the proper data segment
Code: Select all
[ORG 0x7c00]
Code: Select all
jmp 0x0000:BOOT
No GDTPTR conversion is required, and your JMP CODE_SELECTOR:PMODE_CODE should be valid.
however, you should then
Code: Select all
BOOT:
mov ax,0
mov ds,ax
Re:More Probs with PMode
Whay its seems to finally be working and gets into PMode without rebootingg. I ended up rewriting it and going through bit bit.
I have it in PMode without the FAR jump and it works is that alright.
Peter
I have it in PMode without the FAR jump and it works is that alright.
Peter
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:More Probs with PMode
it would be nice if you also post the *working* code after all these debugging sessions
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:More Probs with PMode
there is a slight error in your code, imho:
you made the jmp 0x7c0:0 and org 0000, thus when you assemble offset 0, you're actually addressing absolute 0x00007c00.
Unfortunately, you patch your GDT register with +7c0 (which is the code segment), but remember segments are *16 in address formation.
so
should be
In the same kind of idea, as your GDT has CS.base == 0, and as your code assumes to be loaded from offset 0, your jump command should not be
but rather
you made the jmp 0x7c0:0 and org 0000, thus when you assemble offset 0, you're actually addressing absolute 0x00007c00.
Unfortunately, you patch your GDT register with +7c0 (which is the code segment), but remember segments are *16 in address formation.
so
Code: Select all
GDTptr:
dw GDT_END - GDT - 1 ; GDT limit
dd 0x07C0 + GDT ; linear, physical address of GDT
Code: Select all
GDTptr:
dw GDT_END - GDT - 1 ; GDT limit
dd 0x07C00 + GDT ; linear, physical address of GDT
Code: Select all
jmp LINEAR_CODE_SEL:PMODECODE + 0x7c0
Code: Select all
jmp LINEAR_CODE_SEL:PMODECODE + 0x7c00
Re:More Probs with PMode
I have a bootsector that works and its set up just like yours.
I found one obsevation that might give you a problem later on.
I suggest putting the reset disk and read function before you enable the a20 gate. It will save you some head ache. If you decide to add more stuff in your bootsector, you will have to adjust the read sectors function. If not, when you enable a20 it will get wacked and halt.
Also you wont have to enable the interrupts after enabling the a20 gate and then having to then clear it again for entering protected mode.
Hope this helps!
I found one obsevation that might give you a problem later on.
I suggest putting the reset disk and read function before you enable the a20 gate. It will save you some head ache. If you decide to add more stuff in your bootsector, you will have to adjust the read sectors function. If not, when you enable a20 it will get wacked and halt.
Also you wont have to enable the interrupts after enabling the a20 gate and then having to then clear it again for entering protected mode.
Hope this helps!