[haiku-development] Re: vm86 Question

  • From: Gerald Zajac <zajacg@xxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Tue, 30 Sep 2008 19:24:48 -0400

Jan Klötzke wrote:
Gerald Zajac <zajacg@xxxxxxxxxxxxx> wrote:
My question:  Is there any particular reason that 0x1000 is used as the
address for vbeModeInfo which is then set in the es & edi regs.?  From
trial & error with the EDID code in the S3 driver, it appears that any
address can be used as long as the address and the data are completely
within the ram area set up by a previous call to vm86_prepare().  Is
this correct?  The ram area has a starting address of 0.

The lowest possible address for such buffers is actually 0x1000. This is because of the interrupt vector table and the "BIOS Data Area" which goes up to 0x4ff. The rest until 0x1000 is used as real mode stack and therefore shouldn't be used. Beginning from 0x1000 you can then use any address up to the memory size given to vm86_prepare().

Are you sure that this is correct? I'm currently using an address of 0x0 when fetching an edid1_raw struct, and it works fine. The following is the code that fetches the EDID info:

   edid1_raw* edid = (edid1_raw*)0x0;

   vmState.regs.eax = 0x4f15;
   vmState.regs.ebx = 1;        // 1 = read EDID
   vmState.regs.ecx = 0;
   vmState.regs.edx = 0;
   vmState.regs.es  = ADDRESS_SEGMENT(edid);
   vmState.regs.edi = ADDRESS_OFFSET(edid);

   status = vm86_do_int(&vmState, 0x10);
   if (status == B_OK) {
       if (vmState.regs.eax == 0x4f)
           memcpy(&edidRaw, edid, sizeof(edid));
       else
           status = B_NOT_SUPPORTED;
   }

The ADDRESS macros are defined as:

#define ADDRESS_SEGMENT(address) ((addr_t)(address) >> 4)
#define ADDRESS_OFFSET(address) ((addr_t)(address) & 0xf)

Best regards,
Gerald


Other related posts: