#include #include #include /* 128Kb */ #define BIOS_SIZE 131072 char BIOS[BIOS_SIZE]; enum ELEMENT_TYPES{ STRING=0, CLOCK_INFO, }; typedef struct { int type; void *data; char *desc; unsigned int offset; unsigned int length; }Element; typedef struct { unsigned int vcore; unsigned int ram; unsigned int gpu; }ClockInfo; Element *HD48xx_vbios[] = { &(Element){ STRING ,NULL,"Bios Date/Time" ,0x0050, 16}, &(Element){ STRING ,NULL,"Bios Version String" ,0x0094, 14}, &(Element){ STRING ,NULL,"Reported Chip Type" ,0x00A3, 5}, &(Element){ STRING ,NULL,"Interface" ,0x00A9, 12}, &(Element){ STRING ,NULL,"RAM Type" ,0x00B5, 6}, &(Element){ STRING ,NULL,"Hardware Spec" ,0x00BD, 76}, &(Element){ STRING ,NULL,"Power Cable Error Message" ,0x010E,164}, &(Element){ STRING ,NULL,"Copyright" ,0x01B2, 38}, &(Element){ STRING ,NULL,"ATOMBios Version" ,0x01D8, 41}, &(Element){ CLOCK_INFO ,NULL,"Clock Info 00" ,0xAD3E, 9}, &(Element){ CLOCK_INFO ,NULL,"Clock Info 01" ,0xAD4E, 9}, &(Element){ CLOCK_INFO ,NULL,"Clock Info 02" ,0xAD5E, 9}, &(Element){ CLOCK_INFO ,NULL,"Clock Info 03" ,0xAD6E, 9}, &(Element){ CLOCK_INFO ,NULL,"Clock Info 04" ,0xAD7E, 9}, &(Element){ CLOCK_INFO ,NULL,"Clock Info 05" ,0xAD8E, 9}, &(Element){ CLOCK_INFO ,NULL,"Clock Info 06" ,0xAD9E, 9}, &(Element){ CLOCK_INFO ,NULL,"Clock Info 07" ,0xADAE, 9}, &(Element){ CLOCK_INFO ,NULL,"Clock Info 08" ,0xADBE, 9}, &(Element){ CLOCK_INFO ,NULL,"Clock Info 09" ,0xADCE, 9}, NULL }; void print_hex(char *ptr, size_t size){ int i; for(i=0;i1;i++){ copy = bytes[i]; bytes[i] = bytes[length]; bytes[length] = copy; } } void parse_vbios(Element **vbios){ int i; char *cptr; ClockInfo *clk; unsigned int number; for(i=0;vbios[i];i++){ if(vbios[i]->type == STRING){ cptr = malloc(vbios[i]->length); memcpy(cptr, BIOS+vbios[i]->offset, vbios[i]->length); vbios[i]->data = cptr; }else if(vbios[i]->type == CLOCK_INFO){ clk = malloc(sizeof(ClockInfo)); cptr = malloc(vbios[i]->length); memcpy(cptr, BIOS+vbios[i]->offset, vbios[i]->length); number=0; memcpy(&number,cptr,3); clk->gpu = number/100; number =0; memcpy(&number,cptr+3,3); clk->ram = number/100; number =0; memcpy(&number,cptr+6,3); clk->vcore = number; free(cptr); vbios[i]->data = clk; } }; } void dump_vbios(Element **vbios){ int i; ClockInfo *clk; for(i=0;vbios[i];i++){ printf("[%04x:%04x] %s\n", vbios[i]->offset, vbios[i]->length, vbios[i]->desc); if(vbios[i]->type == STRING){ printf("%s\n",(char*)vbios[i]->data); }else if(vbios[i]->type == CLOCK_INFO){ clk = (ClockInfo*) vbios[i]->data; printf("GPU = %05u Mhz | MEM = %05u Mhz | Vcore = %04u mV\n", clk->gpu,clk->ram,clk->vcore); } } } int main(int argc, char **argv){ FILE *fptr; if(argc != 2 ){ printf("Specify file\n"); return 1; } fptr = fopen(argv[1],"r"); fread(BIOS,BIOS_SIZE,1,fptr); fclose(fptr); parse_vbios(HD48xx_vbios); dump_vbios(HD48xx_vbios); return 0; }