Greetings,
I'm trying to add graphics to my OS. I've choose to switch graphic modes with VESA. After a lot of reading and seeking for a best way to cooperate with BIOS via VESA int 10h interface I've stayed for this solution: every time I need to switch to graphic mode from text mode (and probably back) I'll force my kernel to drop to real mode, make needed 'int 10h' calls, go back to protected mode. The problem is that the code that will do it for me should be in a low MB of physical memory because of Rmode. My bootloader switches to Pmode and loads kernel into the high physical memory. Now I'm seeking for easy solution of placing relevant code into low physical memory. One approach that I've though about is a simple copy of relevant memory area with a code to low address at the kernel initialization stage, but this sounds a bit problematic and hackish. Can you suggest me a better way of doing that?
Load code to low physical memory
-
djmauretto
- Member

- Posts: 116
- Joined: Wed Oct 22, 2008 2:21 am
- Location: Roma,Italy
Re: Load code to low physical memory
V86 modeCan you suggest me a better way of doing that?
- Combuster
- Member

- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Load code to low physical memory
Virtual 8086 mode is meant to solve the issue of having to revert system configuration when going back to real mode, at the cost of complexity elsewhere. It does not save the OP from actually getting code running under the 1MB mark, but it can now be performed using paging rather than making a physical copy and associated memory usage constraints.
But yes, in all cases you have to copy code to under the 1M mark, and make sure it actually is capable of running there. You can hand-write position independent assembly and copy it whereever. You can also embed a fixed address in it instead. In either case, you'll want to have a start and end pointer to this code block as you'll end up moving it around.
As far as professionalism is concerned, some people believe that any use of 16-bit code is a violation of that, so you might just as well get over it.
But yes, in all cases you have to copy code to under the 1M mark, and make sure it actually is capable of running there. You can hand-write position independent assembly and copy it whereever. You can also embed a fixed address in it instead. In either case, you'll want to have a start and end pointer to this code block as you'll end up moving it around.
As far as professionalism is concerned, some people believe that any use of 16-bit code is a violation of that, so you might just as well get over it.
Re: Load code to low physical memory
Thanks for response!djmauretto wrote:V86 mode
V86 mode is very convenient for running old applications written for Rmode, because it was designed for that, but less convenient for running kernel code (switching from Pmode to V86 designed to occur in interrupts stub).
Re: Load code to low physical memory
That's exactly what I'm about to do. Just thought maybe there are some common ways of doing that (bootloader tweaks or so).Combuster wrote: But yes, in all cases you have to copy code to under the 1M mark, and make sure it actually is capable of running there. You can hand-write position independent assembly and copy it whereever. You can also embed a fixed address in it instead. In either case, you'll want to have a start and end pointer to this code block as you'll end up moving it around.
As far as professionalism is concerned, some people believe that any use of 16-bit code is a violation of that, so you might just as well get over it.
Could you please explain your last sentence? You saying that I can avoid 16bit code in my case?
- Combuster
- Member

- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Load code to low physical memory
Well, yes you can, and if you read the FAQ it has some starting pointers on that. The same page also tells you that those ways are significantly more complex and the choice not to do things the "best" way is mostly a practical one.
Re: Load code to low physical memory
Thanks for advices. Honestly, I've been seeking for some way to avoid Rmode last 3 days. The closest thing I got is VESA3.0 protected mode interface. But my card supports only VESA2.0. Another attempt is a kind of translating software, but there's nothing ready-to-use (or I've missed some?). Of course I can write some of mine, but it will take a lot of time, and I don't have it 
