VESA in vm86

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
Joao

VESA in vm86

Post by Joao »

Hey People..

I have a little question for ya all.
As you might have guessed i'm breaking my head on creating my own little OS in order to learn the nitty gritty basics.
I'm now at a stage where i have some vm86 routines and some taskswitching.
As a next step i would like to utilize the vm86 calls to get me into a nice VESA mode. And this is where Mr. problem pops its ugly head. In my code im filling a VESA-info structure by using the command 0x4f00 and subsequently i'm using 0x4f01 to fill a mode-structure for all mode numbers found in the info structure. after wich im checking wether the mode structure contains my desired width/height and bpp values.
If all checks out i use the 0x4f02 call to set the mode.

This last step is where things go wrong.. In my bochs i end up with some weird X11 Errorcode that don't make any sense. So i have my worries on the correctness of the bochs VBE implementation. On the other hand when running the code on real PC at the point of switching to another mode it just flicks into a reboot wich is quite odd since all the other VESA calls did work out..

My question is wether anyone sees any clear mistakes in my code as supplied hereunder. also i wonder if other people get that same error from bochs when running my image below.

Thank you all in advance!


Here's my code :

http://files.freaksunited.org/file/675


Its this part where things go wrong :

Code: Select all

                /* we'll take it ! */
               memset(&regs, 0, sizeof(regs));
                regs.eax = 0x4F02;
                regs.ebx = *modep;

                /* set VESA mode */
                int86(0x10, &regs);

And my a.img image :

http://files.freaksunited.org/file/674
DruG5t0r3

Re:VESA in vm86

Post by DruG5t0r3 »

I'm not entirely sure about this since I don't see all of your code but

regs.ebx = *modep;

shouldn't it be like

regs.ebx = &modep;

unless *modep is a pointer to the value you need. Anyway, if it gives you a weird X11 error, then yeah...might have someting to do with bochs. But in another sense, thats the only way to get in Vesa mode.... ???
Joao

Re:VESA in vm86

Post by Joao »

DruG5t0r3 wrote: I'm not entirely sure about this since I don't see all of your code but

regs.ebx = *modep;

shouldn't it be like

regs.ebx = &modep;

unless *modep is a pointer to the value you need. Anyway, if it gives you a weird X11 error, then yeah...might have someting to do with bochs. But in another sense, thats the only way to get in Vesa mode.... ???
As shown in the supplied source code modep is of type :

Code: Select all

short *mode, *modep;
That would make regs.ebx = *modep; of type short. wich is just what one would expect for a mode number, right ?

b.t.w. didn't the link to my source code work ?
DruG5t0r3

Re:VESA in vm86

Post by DruG5t0r3 »

OUpsss, didn't notice the source link

modep should be "unsigned int *" which is 4 bytes which is the size of eax not "short"
Joao

Re:VESA in vm86

Post by Joao »

DruG5t0r3 wrote: OUpsss, didn't notice the source link

modep should be "unsigned int *" which is 4 bytes which is the size of eax not "short"
Hmm. the modenumbers are stored in 16 bit format.
So i guess that if modep was of type (unsigned int *) it would skip a mode with each iteration, wich is not what i want.
a cast to a unsigned int might be more correct, yes.
something like :

Code: Select all

regs.ebx = (unsigned int) *modep;
The EBX register will be narrowed to a BX register later anyway since its running in vm86. Probably the regs structure isn't that correct wrt naming/typing in this sense.
But your point is well taken.. Thank you
Post Reply