Mail Archives: djgpp/2004/09/26/22:00:34
On 26 Sep 2004 19:29:03 GMT in comp.os.msdos.djgpp, jbs30000 AT aol DOT com
(JBS30000) wrote:
>>It would help if you posted all the relevant parts of the real code.
^^^^^^ ^^^^^^^^^
Perhaps I should have said pasted?
>I thought I did. The method I use to get and display the other strings, such
>as the OEM Vender Name, and so fourth are the same. But, if you want more
>code...
>Here's the struct in its entirety:
>struct VBE_VgaInfo
>{
> char VESA_Signature[4] __attribute__((packed));
> short VESA_Version __attribute__((packed));
> long OEM_String_PTR __attribute__((packed));
> unsigned long Capabilities __attribute__((packed));
> long Video_Mode_PTR __attribute__((packed));
> short Total_Memory __attribute__((packed));
> //VBE 2.0
> short OEM_Software_Rev __attribute__((packed));
> long OEM_Vendor_Name_PTR __attribute__((packed));
> long OEM_Product_Name_PTR __attribute__((packed));
> long OEM_Product_Rev_PTR __attribute__((packed));
> char reserved[222] __attribute__((packed));
> char OEM_Data[256] __attribute__((packed));
>}vesainfo;
Good idea to declare all the OEM_*_PTR pointer variables as unsigned
long.
>After using functin 0 to get the information and fill the struct, I use these
>variables to hold the strings:
>char OEM_String[255], OEM_Vendor_Name[256],
^^^ ^^^
> OEM_Product_Name[256], OEM_Product_Rev[256];
^^^ ^^^
Safer to keep the sizes the same and maybe define a constant symbol
such as STR_LEN to set them. It might be a good idea to initialize
these arrays to nul chars, or at least put a nul char in the last
position, as you only copy 255 chars; this will avoid problems if a
string is not nul terminated.
#define STR_LEN 256
char OEM_String[STR_LEN] = "";
char OEM_Vendor_Name[STR_LEN] = "";
char OEM_Product_Name[STR_LEN] = "";
char OEM_Product_Rev[STR_LEN] = "";
>And, for the real mode offset I have:
>short Real_Mode_PTR
^ ?
Indication that this *may* not be a paste of the real code, or may be
a selective cut/paste.
>Now, to get the strings, I go:
> Real_Mode_PTR = ((vesainfo.OEM_String_PTR >> 16) << 4) +
>(vesainfo.OEM_String_PTR & 0xFFFF);
> dosmemget(Real_Mode_PTR & 0xFFFF, 255, OEM_String);
Shouldn't even look at the pointers unless the version is high enough.
if(vesainfo.VESA_Version >= 0x0200)
{
> Real_Mode_PTR = ((vesainfo.OEM_Vendor_Name_PTR >> 16) << 4) +
>(vesainfo.OEM_Vendor_Name_PTR & 0xFFFF);
> dosmemget(Real_Mode_PTR & 0xFFFF, 256, OEM_Vendor_Name);
> Real_Mode_PTR = ((vesainfo.OEM_Product_Name_PTR >> 16) << 4) +
>(vesainfo.OEM_Product_Name_PTR & 0xFFFF);
> dosmemget(Real_Mode_PTR & 0xFFFF, 256, OEM_Product_Name);
> Real_Mode_PTR = ((vesainfo.OEM_Product_Rev_PTR >> 16) << 4) +
>(vesainfo.OEM_Product_Rev_PTR & 0xFFFF);
> dosmemget(Real_Mode_PTR & 0xFFFF, 256, OEM_Product_Rev);
Below is dupe of above.
> Real_Mode_PTR = ((vesainfo.OEM_Product_Rev_PTR >> 16) << 4) +
>(vesainfo.OEM_Product_Rev_PTR & 0xFFFF);
> dosmemget(Real_Mode_PTR & 0xFFFF, 256, OEM_Product_Rev);
}
else /* don't need this if initialized to all nul chars */
{
OEM_Vendor_Name[0] = '\0';
OEM_Product_Name[0] = '\0';
OEM_Product_Rev[0] = '\0';
}
Good idea to wrap the pointer conversion and string fetches in a macro
or function, so you have only one place to change the operations, e.g.
#define REAL_PTR(p) (((((p) >> 16) & 0xFFFF) << 4) + ((p) & 0xFFFF))
dosmemget( REAL_PTR( vesainfo.OEM_Product_Rev_PTR ),
STR_LEN - 1, OEM_Product_Rev);
>And to print them:
> printf("Chipset or OEM %s \n", OEM_String);
> if(vesainfo.VESA_Version >= 0x0200)
> {
> printf("OEM Software Revision No. %x\n", vesainfo.OEM_Software_Rev);
> printf("OEM Vendor Name %s\n", OEM_Vendor_Name);
> printf("OEM Product Name %s\n", OEM_Product_Name);
> printf("OEM Product Revision No. %s\n", OEM_Product_Rev);
>And there, that's all of the RELEVANT code. Don't see what good this did, but
>anyway, I'll try your changes. Thanks.
--
Thanks. Take care, Brian Inglis Calgary, Alberta, Canada
Brian DOT Inglis AT CSi DOT com (Brian[dot]Inglis{at}SystematicSW[dot]ab[dot]ca)
fake address use address above to reply
- Raw text -