paging in realmode

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
Techel
Member
Member
Posts: 215
Joined: Fri Jan 30, 2015 4:57 pm
Location: Germany
Contact:

paging in realmode

Post by Techel »

Do I really have to switch to P-Mode and use VM8086 to utilize Paging in Real-Mode? Or are there other possibilities?
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Re: paging in realmode

Post by Roman »

Intel wrote:Paging (bit 31 of CR0) — Enables paging when set; disables paging when clear. When paging is disabled, all linear addresses are treated as physical addresses. The PG flag has no effect if the PE flag (bit 0 of register CR0) is not also set; setting the PG flag when the PE flag is clear causes a general-protection exception (#GP). See also: Chapter 4, “Paging.”
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
Techel
Member
Member
Posts: 215
Joined: Fri Jan 30, 2015 4:57 pm
Location: Germany
Contact:

Re: paging in realmode

Post by Techel »

I know this and thought of 16 bit P-Mode but that would not work, so I only have the possibility I mentioned above, right?
Techel
Member
Member
Posts: 215
Joined: Fri Jan 30, 2015 4:57 pm
Location: Germany
Contact:

Re: paging in realmode

Post by Techel »

Another question: When changing a segment register in realmode the base field in the shadow descriptor register is updated accordingly (ie. multiplying the value by 16 and storing it). Does this only affect the lower 16 bit (as the base field is 32 bit in size) or are the upper bits set to 0?
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: paging in realmode

Post by Kevin »

Roflo wrote:Do I really have to switch to P-Mode and use VM8086 to utilize Paging in Real-Mode? Or are there other possibilities?
In theory, you could switch to PM and use VMX/SVM instead of VM86. I doubt this is going to make it any easier, though, while restricting your code to relatively new hardware. I imagine there might be obscure use cases for doing something like this with a LM kernel, but not when you explicitly switch to PM just in order to get paging.
Developer of tyndur - community OS of Lowlevel (German)
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: paging in realmode

Post by alexfru »

Roflo wrote:Another question: When changing a segment register in realmode the base field in the shadow descriptor register is updated accordingly (ie. multiplying the value by 16 and storing it). Does this only affect the lower 16 bit (as the base field is 32 bit in size) or are the upper bits set to 0?
You're still limited to a 20-bit base address (do the math: 16-bit segment selector shifted left 4 positions), irrespective of the details of hardware implementation. About the only thing you can do with memory addressing in real mode is extending the segment limit beyond 65535 bytes (look up Big Real Mode / Unreal Mode).
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: paging in realmode

Post by alexfru »

Kevin wrote:In theory, you could switch to PM and use VMX/SVM instead of VM86. I doubt this is going to make it any easier, though, while restricting your code to relatively new hardware. I imagine there might be obscure use cases for doing something like this with a LM kernel, but not when you explicitly switch to PM just in order to get paging.
Yep, VMX/SVM comes with lots of flexibility and complexity (not to mention the obvious necessity of having to implement separate versions (or abstraction layers) for both as VMX and SVM aren't compatible). Writing a lot of boilerplate code and debugging the whole thing isn't going to be fun. And it's much less known than virtual 8086 mode (few people have on-hand knowledge (I myself didn't study in depth everything in VMX/SVM while working on Hyper-V)), meaning there's going to be little help on this or another forum. Reading the dull manuals and experimenting won't be cheap or pleasant.
Post Reply