Page 1 of 1

traversing the vbe mode list

Posted: Mon Apr 11, 2005 5:41 am
by distantvoices
Ok, here we go:

I want to traverse the vbe modelist which the vbemodeptr in the vbeinfo structure (as described f. ex. in chris gieses wat32vbe.c (?)) points to.

Ok. the vm86-stuff returns the vbe_info structure - correctly. I can get hold of oem strings, the vbe version number. I can also read vbe_mode_info - which comes in handy whan traversing the mode list attached to the vbe_info structure.

My question is - as I only get rubbish by reading from the address vbemodeptr points to - what do I have to take care of? I'm changing it from real mode addressing to protected mode addressing.

Any HInts? quick pseudo code stuff to show how it can be solved? (I've looked at clicker io - vbe2 driver - it looks cool - I've also looked at Chris Gieses stuff - and still I'm kinda dumbfounded)

@DevL: Hmmm ... well, the whole past week I've been up to no good ];-> *muuuaaahahahaha*

Re:traversing the vbe mode list

Posted: Mon Apr 11, 2005 6:56 am
by Pype.Clicker
from "vbeAddDevice()" in C32/kernel/src/mods/io/vbe2/iodisplay.c ...

Code: Select all

struct VbeInfoBlock vib=vbeGetCtrlInfo();
 log(KLOG_DEBUG,0,"VBE::getCtrlInfo returned %x %s, %iKB VRAM avl.\n"
      "  oemString=%s",vib,
      vib->signature,vib->totalMemory*64,
      MK_FAR(vib->oemString));

word* modes=MK_FAR(vib->modeList);
for (nbmodes=0;modes[nbmodes]!=0xffff;nbmodes++);
for (i=0;i<nbmodes;i++) {
      struct vbeModeInfo* vmi=vbeGetModeInfo(modes[i]);
      // internal KDS stuff to register the mode in vga0.config.modes.* :)
      kprints(modename,sizeof(modename),"%ix%ix%i-%s",
      vmi->Xres, vmi->Yres, vmi->bpp,
      memmodel[vmi->memory_model>7?8:vmi->memory_model]);

      kfree(vmi);
}
with

Code: Select all

#define MK_FAR(_vbeFarPtr) a2l(_vbeFarPtr[0]+_vbeFarPtr[1]*16)
HTH.

(searching the output of "doclocate VBE :gettext" for "vbemodeptr", but no match found. What exactly do you refer to ?)

Re:traversing the vbe mode list

Posted: Mon Apr 11, 2005 7:06 am
by distantvoices
I'm referring to the "modelist".

btw, what's this a21() function doing?

thanks! ;-)

Re:traversing the vbe mode list

Posted: Mon Apr 11, 2005 7:18 am
by Pype.Clicker
ah. yes... a2l (that's AbsoluteToLogical address conversion from Clicker. it translates a linear address into a suitable pointer (since Clicker has non-zero-based datasegment).

on a zero-based system, you just have

Code: Select all

static inline void* a2l(vaddr_t va) {
   return (void*) va;
}

static inline vaddr_t l2a(void* p) {
   return (unsigned) p;
}

Re:traversing the vbe mode list

Posted: Fri Apr 22, 2005 6:20 am
by distantvoices
Thanks for the help, Pype!

It looks as if my method isn't really suited for the task of retrieving stuff & tables from the bios.

In qemu f. ex. vbe datastructures come along with indicated address - 2. That's obviously a bug by me, but I'm not likely to resolve it too soon.

I might change the whole thing: to dispatch a message to the vm86 task, which contains the requested resolution and an alternative resolution alongside with adequate bit depths, and shall the vm86 task deal with the stuff of checking for the adequate video mode.

After some weeks spent with coding some applications and searching for this stuff, I'm tempted to change some things to have it more convenient. *gg*