unreal-mode ????

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.
Post Reply
iota

unreal-mode ????

Post by iota »

hi all
i am a littel confused about unreal mode and have a few questions

1. i have heard that in unreal mode you can use 32bit code and bios calls is this correct?
2. if i set up interrupts in real-mode could i use them in unreal-mode?
3. how do i get into unreal-mode?

i am very intrested in unreal-mode and would like to play with some kernels and maybe write my own unreal-mode kernel and links or evan info on how to access unreal mode would be appreciated

Regards Leon Pegg aka Iota
VoidLogic

RE:unreal-mode ????

Post by VoidLogic »

Oh yes me too! This would be great, my OS is currently real mode. so how to enable A20....
PlayOS

RE:unreal-mode ????

Post by PlayOS »

To Enable the A20 Gate you have 2 options,

This is the old, but most reliable way

_ENABLE_A20:
CALL .EMPTY_8042
MOV AL, 0x0D1
OUT 0x64, AL
CALL .EMPTY_8042
MOV AL, 0x0DF
OUT 0x60, AL
CALL .EMPTY_8042
JMP .A20_GATEDONE
.EMPTY_8042:
MOV AL, 0x0D0
IN AL, 0x64
TEST AL, 2
JNZ .EMPTY_8042
.A20_GATEDONE:

This is the modern, least reliable way:

IN AL, 0x92
OR AL, 0x02
OUT 0x92, AL

Most OSes do not run completely in unreal mode, but its your OS so you can do what you like :), check this link for more info http://www.faqs.org/faqs/assembly-langu ... ion-1.html
iota

RE:unreal-mode ????

Post by iota »

1. once you have enabled the a20 gate can you switch it off again?? if yes how??
2. i have tryed loads of code to get to unreal-mode but none has worked any segestions??
i am making my second stage bootloader and it is full asm 16 bits is it posible to setup protected mode in 16 bits or do i need to use 32 bit code if so dose any one have some 32 bit code to load a binary kernel (16 bits) in 32 bit code ???
thanks all
regards Leon Pegg
MuteX

RE:unreal-mode ????

Post by MuteX »

32 bit code to load a kernel is interesting (i suppose that is possible by using the FDC or HD controller directly), im interested in that too, or if anyone can tell how to **call bios while in protected-mode** (for e.g. int 13h) that would do a lot ..

cheers..
fdyne

RE:unreal-mode ????

Post by fdyne »

1. yes.
2. yes.
3. you enter protected mode, you set base and limit for the segment selectors in the right way, you exit protected mode.

[email protected]
fdyne

RE:unreal-mode ????

Post by fdyne »

1. dunno, I think yes, maybe it depends on the hardware you have.
2. cpu can work anytime with 32 bit istructions and/or 16 bit istructions.
There's a little bit in the cpu which decide what kind of istruction is default (default=needs no prefix code in machine code). So you can screw things if cpu bit is in 32 bit mode and you code assembler in 16 bit mode or viceversa, or you can avoid screwing things if you know this...
I am developing an OS in unreal mode and it works.
Sometimes after recompiling new versions it makes strange things and these are not only bugs in my opinion (Unreal mode isn't supported by intel).
Anyway I'll investigate further.

[email protected]
fdyne

RE:unreal-mode ????

Post by fdyne »

segment registers have different meanings in real(unreal) mode and protected mode.
That's a reason why bios functions will fail to work in protected mode.
There are more reasons though (somebody say interrupts?).
MuteX

RE:unreal-mode ????

Post by MuteX »

how do you use 32 bit code (other than explictly providing an override prefix) in unreal mode, do you mean 32 bit addresses ?
or is it that the default segment size bit (16/32) does play its part even in unreal mode ?
i think the descriptors are not used anymore , are they ?
if they are not used why doesnt the limit of 64K apply now ?
fdyne

RE:unreal-mode ????

Post by fdyne »

for 'using 32 bit code' I mean for example that when you have

B80113    mov ax, 1301h
CD10      int 10h

and you put 66h in front of it, you obtain

66B80113CD10  mov Eax, 10CD1301h

if you are in CPU 16 bit mode, and you can select this mode using the code itself.
This means that 16 bit operand is the DEFAULT.
You otherwise can be in 32 bit mode, and the interpretation of the code is reversed: when you have 66h prefix you MEAN mov ax instead of mov eax.
Descriptors data INSIDE cpu are not readable or writeable in real mode, that's why you are entering initially in protected mode to change them!
The fact is that when you change them in protected mode, some informations which are hidden in real mode remain unchanged returning in the real mode.
You use this to change informations regarding the maximum address useable in real mode.
So then you have the same real mode with a little change: when the processor looks the limit of the address for that segment(and it does it also in real mode to check for 64k limit), he sees the maximum limit for a 80x86 instead of the 64k limit of real mode!
That is.
I will release my code. I found lotta bugs today and now it looks to work perfect.
Three instructions interpreted up to now: list, run, goto.

[email protected]
mikeleany

RE:unreal-mode ????

Post by mikeleany »

Yes, you can disable A20 after enabling it. When you enable it, you're really only changing bit 1 of port 0x60. To enable it you set bit 1, to disable it you clear bit 1. So you would use the same code as you do to enable A20 except you would replace this:

mov al, 0xdf
out 0x60, al

with this:

mov al, 0xdd
out 0x60, al
Post Reply