VESA Pmode Entry Point

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
MattC

VESA Pmode Entry Point

Post by MattC »

HEllo, I need some help (ASM source code). I've read the VBE 3 documentation and it told roughly (no source) how to obtain the Vesa protected mode entry point. It said you had to copy the bios code into a protected mode buffer and do a whole bunch of crap. I couldn't possibly know how to do all it said to do. Could somebody tell me where I could get the actual source for this (or an easier way to switch banks in protected mode without DPMI)
Thankyou :D
carbonBased

RE:VESA Pmode Entry Point

Post by carbonBased »

So you have no issues stealing someone's vesa code, without even knowing what it does?

Anyway...

Do you at least know how to get a copy of the Vesa protected mode interface?  Theoretically, you don't have to do anything else (I don't think..?) but you _should_ copy this memory into your pmode address space, and protect it somehow.

in a nutshell:
  ax = 0x4f0a
  bx = 0
  int 0x10 ; in real mode!

  if(ah) error

  pmBuffer = alloc cx bytes in pmode
  make memory (pmBuffer) executable/read-only (if need be)

  copy real mode memory (es:di) to new buffer (cx bytes long, as above)

  Done.

Now all pmode interface functions (setWindow, setDisplayStart, setPalette, and IOPrivInfo) can be called as offsets from your newly allocated pmode buffer...

ie: bankRoutine = (pmBuffer + pmBuffer->setWindow);

I'm not gonna bother with an assembly implementation... I don't have the time ;)

This is not trivial.  If you don't have a memory management system in place, you'll have to improvise on the malloc, etc part... I'd reccomend getting a memory management system in place first, actually.  You'll also need methods of switching to and from real-mode or (better yet) a vm86 task.

Jeff

PS: the protected mode interface is part of VBE _2_
MattC

RE:VESA Pmode Entry Point

Post by MattC »

Thanks. THis psudo code makes much more sense than the vbe 3 documentation :D
One question though, how do I figgure out the offset of the vesa functions?
carbonBased

RE:VESA Pmode Entry Point

Post by carbonBased »

That's actually exactly what's returned by the Vesa function 0x4f0a

Pointed to by es:di is a structure like this:

vbe4f0aBuffer:
   dw setWindow        ; These are all offsets,
   dw setDisplayStart  ; into this buffer, for
   dw setPalette       ; each of these pmode
   dw IOPrivInfo       ; routines
   ; actual code is located here

You'll notice, after the call, that cx will be _much_ larger than 4*2 (ie, 4 * sizeof(dw) ).  That's because the call also returns the actual pmode code for the above four routines... they are, however, offsets _into_ this memory buffer... they aren't physical or linear addresses of any kind.

Therefore, in order to find the offset for any function, add its offset to the location of your vbe4f0aBuffer structure.

Hopefully that doesn't sound too loopy... I "may have" had "a few" beers :)
Jeff
MattC

RE:VESA Pmode Entry Point

Post by MattC »

So, in this line of code "bankRoutine = (pmBuffer + pmBuffer->setWindow);", would bankRoutine be a function (ie. bankRoutine(banknumber); )?

Thanks a lot for the help. I wonder why I havn't found anything on the internet that tells how to do this. This is pretty simple :)
carbonBased

RE:VESA Pmode Entry Point

Post by carbonBased »

www.neuraldk.org/cgi-bin/document.pl?djgppGraphics

I wrote it six years ago, but it covers almost everything... although, from the DJGPP point of view.

bankRoutine is a function, but of type (void)(*)(void).  In other words, it accepts no arguments, and returns nothing.

Banking is done, just like in real mode, but instead of "int 0x10, ax = 0x4f05", you call bankRoutine:

xor ebx, ebx
mov edx, [bankNum]
call [bankRoutine]

Jeff
MattC

RE:VESA Pmode Entry Point

Post by MattC »

thanks :D
Post Reply