Hm, you are right - It does provide the same tactic the BIOS uses (alot of them, anyways) for the OS to use for its own purposes. Also, removing this "feature" would break alot of existing software which I dont see Intel or AMD wanting to do. I personally still would not use it though (no need) but considering the above I suppose it doesnt matter if it gets used or not.tom9876543 wrote:Unreal mode IS documented by Intel and AMD. They just call it SMM mode. BIOSes rely on it to operate. SMM was officially implemented with the 386. Unreal mode is simply the OS taking advantage of the 4gb limit in the same way the BIOS does under SMM mode.
Unreal mode
Re: Unreal mode
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Unreal mode
I can't even begin to say how wrong this is...tom9876543 wrote:Unreal mode IS documented by Intel and AMD. They just call it SMM mode. BIOSes rely on it to operate. SMM was officially implemented with the 386. Unreal mode is simply the OS taking advantage of the 4gb limit in the same way the BIOS does under SMM mode.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: Unreal mode
That is not wrong per se. SMM uses the unreal mode "trick", afaik. And as for everyone claiming support for unreal mode will maybe disappear, and that's why you shouldn't use it: that's a fallacy. Intel and/or AMD can remove any support, even documented ones. v86 / 64-bit anyone? As far as I am aware, it is documented that when switching from real to protected mode, the CPU does not flush its TLBs, which is what unreal mode relies on. So stop complaining about use of unreal mode: it is a perfectly acceptable way of copying your OS to > 1MB, especially in a boot loader since that is a limited piece of software that can be replaced if needed. Other ways are loading the OS below 1MB, then copying it to upper after switching to protected mode, or constantly switching between real and protected mode.Love4Boobies wrote:I can't even begin to say how wrong this is...
JAL
Re: Unreal mode
Since unreal mode relies on documented behaviour, unless you did not have an Intel/AMD/VIA CPU, I believe that statement is false.XanClic wrote:When I wrote my own bootloader, I used the unreal mode first. But it didn't work on my computer
JAL
Re: Unreal mode
Unreal mode allows you to specify a 32 bit offset to any segment, instead of just 16 bit. So you'll always have segment:offset working as in real mode (in fact, unreal mode is real mode). If you want to use "physical addresses", set your segment(s) to 0. There is no difference between the first MB and other memory, so the most direct answer to your question is "no".Karlosoft wrote:Hi! I'm trying to support the unreal mode in my bootloader. Is there a way to use the old segment:offest notation up to the first megabyte and the physical for the upper addresses?
JAL
Re: Unreal mode
Yes, it is:jal wrote:I believe that statement is false.
I wrote:I still found that old piece of code but it was only the "switch" version (switching from real to protected mode and back). That worked as expected. Then I changed that code to do everything in unreal mode and... It still worked. So it was the usual stuff, just a bug made by me and not an unusual CPU behaviour. Though I don't have the original code to locate that bug.
Re: Unreal mode
Right, that'll teach me to post before reading the entire thread. My apologies!XanClic wrote:Yes, it is
JAL
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Unreal mode
It is wrong par se. SMM is a mode it can't "use" anything; as for firmware code running in SMM it makes just as little sense. Some BIOSes do make use of unreal mode at boot time but it's not SMM code.jal wrote:That is not wrong per se. SMM uses the unreal mode "trick", afaik.Love4Boobies wrote:I can't even begin to say how wrong this is...
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
- Firestryke31
- Member
- Posts: 550
- Joined: Sat Nov 29, 2008 1:07 pm
- Location: Throw a dart at central Texas
- Contact:
Re: Unreal mode
Not an extension on whether or not to use unreal mode, but an explanation as to why it may fail on some computers even with AMD and Intel CPUs:
The BIOS can load the segment registers when it gets called (either via HW or user INT) and when it tries to "restore" the segments it doesn't properly restore the hidden fields (because it can't) meaning that segment register is no longer in unreal mode.
The BIOS can load the segment registers when it gets called (either via HW or user INT) and when it tries to "restore" the segments it doesn't properly restore the hidden fields (because it can't) meaning that segment register is no longer in unreal mode.
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
- Masterkiller
- Member
- Posts: 153
- Joined: Sat May 05, 2007 6:20 pm
Re: Unreal mode
We had a discussion once of what you (original topic poster) are trying to do. You just need to go to protected mode, overwrite the hidden potion of segment registers to allow read/write (and for CS read/execute) to all of the 4GB address space, go back into real mode and overwrite the segments visible portion (and of course unlock gateA20). In this way addressing will be segment*16:offset, where offset can be 16-bit or 32-bit number and the limit will be 4GB.
ALCA OS: Project temporarity suspended!
Current state: real-mode kernel-FS reader...
Current state: real-mode kernel-FS reader...
Re: Unreal mode
Thanks to everyone who has replied
However I'm going to work in unreal mode because it's the simplest way.
And If one day it won't work, rewrite a bootloader isn't very difficult.
There is just an other problem. I'm writing this bootloader in Assembly and C. My compiler (TCC) use pointers with a lenght of 16bits. So I am limited in a space of just 64k. Is there any way to use (or force the use of) 32bit pointers in the C code? I know it's a little different problem but I prefer post it here
However I'm going to work in unreal mode because it's the simplest way.
And If one day it won't work, rewrite a bootloader isn't very difficult.
There is just an other problem. I'm writing this bootloader in Assembly and C. My compiler (TCC) use pointers with a lenght of 16bits. So I am limited in a space of just 64k. Is there any way to use (or force the use of) 32bit pointers in the C code? I know it's a little different problem but I prefer post it here
Re: Unreal mode
You may try inline assembly.This needs an external assembler (TASM). I haven't tried it, so please test it first.
Code: Select all
#pragma inline
typedef unsigned int word;
typedef unsigned long dword;
word peek(dword address)
{
asm mov edx, address
asm mov ax, word ptr [edx]
return _AX;
}
void poke(word value, dword address)
{
asm mov edx, address
asm mov ax, value
asm mov word ptr [edx], ax
}
Re: Unreal mode
Unless the BIOS switches to PM, there's no way to touch the "hidden parts" of the segments. Although not really BIOS, HIMEM.SYS switches to PM iirc for doing XMS copying of memory chunks. Your plain old standard BIOS does not though, afaik.Firestryke31 wrote:The BIOS can load the segment registers when it gets called (either via HW or user INT) and when it tries to "restore" the segments it doesn't properly restore the hidden fields (because it can't) meaning that segment register is no longer in unreal mode.
JAL
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: Unreal mode
My (admittedly limited) understanding was that XMS managers ran the system in v8086 mode with paging - though of course this may be wrong - which therefore necessitated the introduction of VCPI to enter protected mode. (Then DPMI came along which is an altogether much cleaner solution)jal wrote:Unless the BIOS switches to PM, there's no way to touch the "hidden parts" of the segments. Although not really BIOS, HIMEM.SYS switches to PM iirc for doing XMS copying of memory chunks. Your plain old standard BIOS does not though, afaik.Firestryke31 wrote:The BIOS can load the segment registers when it gets called (either via HW or user INT) and when it tries to "restore" the segments it doesn't properly restore the hidden fields (because it can't) meaning that segment register is no longer in unreal mode.
JAL
- Firestryke31
- Member
- Posts: 550
- Joined: Sat Nov 29, 2008 1:07 pm
- Location: Throw a dart at central Texas
- Contact:
Re: Unreal mode
I thought reloading the segment registers in real mode flushed the "hidden parts" with the real mode compatible values (i.e. limit of 0xFFFFF and byte granularity). Perhaps I should read up on it though.jal wrote:Unless the BIOS switches to PM, there's no way to touch the "hidden parts" of the segments. Although not really BIOS, HIMEM.SYS switches to PM iirc for doing XMS copying of memory chunks. Your plain old standard BIOS does not though, afaik.Firestryke31 wrote:The BIOS can load the segment registers when it gets called (either via HW or user INT) and when it tries to "restore" the segments it doesn't properly restore the hidden fields (because it can't) meaning that segment register is no longer in unreal mode.
JAL
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?