Linux C 乌班图环境CHECK 显卡信息

10 篇文章 0 订阅
#ifndef _DELETE_FILE
#define _DELETE_FILE
#define FALSE 0
#define TRUE 1
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#include <limits.h>
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>


typedef struct biosinfo
{
char Product_Name[255];
char Bios_Config_File[255];
char Bios_P_N[255];
char Bios_Version[255];
char Bios_Date[255];
}BISIF;




void ReadLogInfo(char *FileName,BISIF &Bisinfo);
bool ReadLineStr(char *FccStr,char *LineStr);
char *ProStr(char *str);
bool WriteLog(BISIF &Bisinfo,char *LgFileName);
bool BisInfoStrCmp(char *str,char *cmpstr);
void title();
void help();
int main(int argc,char *argv[])
{
   /*title();*/
   if(argc==3)
   {
       BISIF str={NULL,NULL,NULL,NULL,NULL};
       ReadLogInfo("BiosInfo.log",str);
       if(WriteLog(str,"BsIf.log")==FALSE)return 1;
       if(strcmp(argv[1],"/PN")==0)
       {
           if(BisInfoStrCmp(str.Product_Name,argv[2])==TRUE)
           {
               printf("\033[32m Bios Name:%s Check Pass\n\033[0m",argv[2]);
               return 0;
           }
           else
           {
               printf("\033[31m Bios Name:%s Check Fail\n\033[0m",argv[2]);
               return 1;
           }
       }
       else if(strcmp(argv[1],"/BC")==0)
       {
           if(BisInfoStrCmp(str.Bios_Config_File,argv[2])==TRUE)
           {
               printf("\033[32m Bios Config:%s Check Pass\n\033[0m",argv[2]);
               return 0;
           }
           else
           {
               printf("\033[31m Bios Config:%s Check Fail\n\033[0m",argv[2]);
               return 1;
           }
       }
       else if(strcmp(argv[1],"/BPN")==0)
       {
           if(BisInfoStrCmp(str.Bios_P_N,argv[2])==TRUE)
           {
               printf("\033[32m Bios P_N %s Check Pass\n\033[0m",argv[2]);
               return 0;
           }
           else
           {
               printf("\033[31m Bios P_N %s Check Fail\n\033[0m",argv[2]);
               return 1;
           }
       }
       else if(strcmp(argv[1],"/BV")==0)
       {
           if(BisInfoStrCmp(str.Bios_Version,argv[2])==TRUE)
           {
               printf("\033[32m Bios Version %s Check Pass\n\033[0m",argv[2]);
               return 0;
           }
           else
           {
               printf("\033[31m Bios Date %s Check Fail\n\033[0m",argv[2]);
               return 1;
           }
       }
       else if(strcmp(argv[1],"/BD")==0)
       {
           if(BisInfoStrCmp(str.Bios_Date,argv[2])==TRUE)
           {
               printf("\033[32m Bios Date %s Check Pass\n\033[0m",argv[2]);
               return 0;
           }
           else
           {
               printf("\033[31m Bios Date %s Check Fail\n\033[0m",argv[2]);
               return 1;
           }
       }
       return 1;
   }
   title();
   help();
   return 1;
}


void help()
{
    system("clear");
    printf("==========================================================================================================\n");
    printf("LINUX GPU CHECKBIOS Program Tool -Ferex Incorporation,By Shenbo,2008-03-19\n");
    printf("Usage :CHKBIOS[Parameter]\n");
    printf("[Command]:\n");
    printf("            \033[37;44m CHKBIOS /PN String   ------------>Check Bios Name.       \033[0m\n");
    printf("            \033[37;44m CHKBIOS /BC String   ------------>Check Bios Config File.\033[0m\n");
    printf("            \033[37;44m CHKBIOS /BPN String  ------------>Check Bios P/N.        \033[0m\n");
    printf("            \033[37;44m CHKBIOS /BV String   ------------>Check Bios Version.    \033[0m\n");
    printf("            \033[37;44m CHKBIOS /BD String   ------------>Check Bios Date.       \033[0m\n");
    printf("[Example]:\n");
    printf("           CHKBIOS /PN \"E366 Polaris20 XTX A1 GDDR5 256Mx32 8GB\"\n");
}


void title()
{
    system("clear");
    printf("                          Build Date:2018-03-19\n");
    printf("FEREX                EnvirSet Copyright by SHENBO CHECKBIOS V1.00\n");
    printf("=========================================================================================================\n");
}


bool BisInfoStrCmp(char *str,char *cmpstr)
{
    int n=0,y=0;
    char cmpstr2[255];
    memset(cmpstr2,0,sizeof(cmpstr));
    while(str[n]!=':')n++;
    n=n+3;
    for(y=0;y<strlen(str);y++,n++)
    {
        cmpstr2[y]=str[n];
    }
    cmpstr2[strlen(cmpstr)]='\0';
    if(strcmp(cmpstr2,cmpstr)==0)return TRUE;
    return FALSE;
}


char *ProStr(char *str)
{
     int n,x,total=0;
     char buffstr[255];
     memset(buffstr,0,sizeof(buffstr));
     while(str[total]!='\n')total++;
     for(n=0,x=4;x<total;x++,n++)
     {
         buffstr[n]=str[x];
     }
     buffstr[n]='\0';
     return buffstr;
}


bool WriteLog(BISIF &Bisinfo,char *LgFileName)
{
    FILE *fp;
    fp=fopen(LgFileName,"w");
    if(fp==NULL)
    {
        printf("\033[31m Write Bios Log File %s Err!!\n\033[0m",LgFileName);
        getchar();
        return FALSE;
    }
    fputs(Bisinfo.Product_Name,fp);
    fputs("\n",fp);
    fputs(Bisinfo.Bios_Config_File,fp);
    fputs("\n",fp);
    fputs(Bisinfo.Bios_P_N,fp);
    fputs("\n",fp);
    fputs(Bisinfo.Bios_Version,fp);
    fputs("\n",fp);
    fputs(Bisinfo.Bios_Date,fp);
    fclose(fp);
    return TRUE;
}


void ReadLogInfo(char *FileName,BISIF &Bisinfo)
{
FILE *fp;
char Temp[255];
memset(Temp,0,sizeof(Temp));
        fp=fopen(FileName,"r");
if(fp==NULL)
{
printf("\033[31m Read File %s Not Found\n\033[0m",FileName);
getchar();
exit(1);
}
while((fgets(Temp,sizeof(Temp),fp))!=NULL)
{
   if(ReadLineStr("Product Name",Temp)==TRUE)
   {
                 strcpy(Bisinfo.Product_Name,ProStr(Temp));
   }
   else if(ReadLineStr("Bios Config File",Temp)==TRUE)
   {
strcpy(Bisinfo.Bios_Config_File,ProStr(Temp));
   }
   else if(ReadLineStr("Bios P/N",Temp)==TRUE)
   {
       strcpy(Bisinfo.Bios_P_N,ProStr(Temp));
   }
   else if(ReadLineStr("Bios Version",Temp)==TRUE)
   {
                strcpy(Bisinfo.Bios_Version,ProStr(Temp));
   }
   else if(ReadLineStr("Bios Date",Temp)==TRUE)
   {
                 strcpy(Bisinfo.Bios_Date,ProStr(Temp));
   }
}
fclose(fp);
}


bool ReadLineStr(char *FccStr,char *LineStr)
{
int Flen=0;
int n,x;
char buf[255];
Flen=strlen(FccStr);
for(x=0,n=4;x<Flen;x++,n++)
{
buf[x]=LineStr[n];
}
buf[Flen]='\0';
        if(strcmp(buf,FccStr)==0) return TRUE;
return FALSE;

}


refail ()
{
    echo -e "\033[31m ******************************************* \033[0m"
    echo -e "\033[31m *********** $BiosInfo Read Fail *********** \033[0m"
    echo -e "\033[31m ******************************************* \033[0m"
    read -n 1
    exit 0
}


bffail ()
{
    echo -e "\033[31m ****************************************** \033[0m"
    echo -e "\033[31m *********** Check Bios Info Fail ********* \033[0m"
    echo -e "\033[31m ****************************************** \033[0m"
    read -n 1
    exit 0
}


bfpass ()
{
    echo -e "\033[32m ******************************************* \033[0m"
    echo -e "\033[32m ********** Check Bios_1 Info Pass ********* \033[0m"
    echo -e "\033[32m ******************************************* \033[0m"
    exit 0
}


chmod 777 agt atiflash chkbios.sh CHKBIOS CHKBIOS.C
clear
path1=$PWD/BiosInfo.log
if [ -f $path1 ];then
    rm $path1
fi


#-----------------------------------------Read Bios Info
BiosInfo=ReadBiosInfo
./atiflash -ai>BiosInfo.log
if [ $? -ne 0 ];then
    refail
fi


#----------------------------------------Read vctfstatus
BiosInfo=vctfstatus
./agt -vctfstatus>>BiosInfo.log
if [ $? -ne 0 ];then
    refail
fi


#---------------------------------------Read pciestatus
BiosInfo=pcestatus
./agt -pciestatus>>BiosInfo.log
if [ $? -ne 0 ];then
    refail
fi


#-------------------------------------Read pplist
BiosInfo=pplist
./agt -pplist=short>>BiosInfo.log
if [ $? -ne 0 ];then
    refail
fi


#------------------------------------Check Bios Info
./CHKBIOS /PN "E366 Polaris20 XTX A1 GDDR5 256Mx32 8GB"
if [ $? -ne 0 ];then
    bffail
fi
./CHKBIOS /BC "366Y6MBU.S5S"
if [ $? -ne 0 ];then
    bffail
fi
./CHKBIOS /BPN "113-1E366CU-S5S"
if [ $? -ne 0 ];then
    bffail
fi
./CHKBIOS /BV "015.050.002.001.000000"
if [ $? -ne 0 ];then
    bffail
fi
./CHKBIOS /BD "10/19/17 06:37"
if [ $? -ne 0 ];then
    bffail
else 
    bfpass
fi

GPU Device Id: 0x1002 0x67DF 113-58085STD1-M81 C940 Polaris20 XTX A1 GDDR5 256Mx32 8GB 300e/300m (C) 1988-2010, Advanced Micro Devices, Inc. ATOMBIOSBK-AMD VER015.050.002.001.000000 5808STD1.M81 CCC Overdrive Limits GPU Clock: 2000 MHz Memory Clock: 2250 MHz PowerTune Limit: -50% to +50% Limits TDP: 145 W TDC Power: 142 A Battery Power: 145 W Small Power Power: 145 W Max. Power Limit: 145 W Max. Temp: 90°C GPU Clocks 300 MHz, 600 MHz, 900 MHz, 997 MHz 1021 MHz, 1052 MHz, 1091 MHz, 1150 MHz Memory Clocks 300 MHz, 1000 MHz, 2050 MHz Temperature Target: 75 °C Memory Support 8192 MB, GDDR5, Autodetect 8192 MB, GDDR5, Samsung K4G80325FB 8192 MB, GDDR5, Micron MT51J256M32HFB Memory Timings (Samsung) tRCDW-tRCDWA-tRCDR-tRCDRA-tRC-tCL-tRFC 250 MHz: 2-3-3-3-11-8-27 400 MHz: 3-3-5-5-17-9-43 600 MHz: 5-5-8-8-26-11-65 900 MHz: 7-7-13-13-39-15-98 1000 MHz: 8-8-14-14-43-16-109 1125 MHz: 9-9-16-16-49-17-123 1250 MHz: 10-10-18-18-55-18-137 1375 MHz: 12-12-20-20-61-19-151 1500 MHz: 13-13-22-22-65-20-164 1625 MHz: 14-14-24-24-71-21-178 1750 MHz: 16-16-26-26-77-22-192 2000 MHz: 17-17-29-29-87-24-219 Memory Timings (Micron) tRCDW-tRCDWA-tRCDR-tRCDRA-tRC-tCL-tRFC 200 MHz: 0-3-2-3-7-7-21 300 MHz: 0-3-4-4-12-7-32 400 MHz: 0-3-5-5-15-7-43 800 MHz: 5-5-11-11-31-11-87 1000 MHz: 9-9-14-14-39-13-109 1250 MHz: 13-13-18-18-50-16-137 1375 MHz: 15-15-20-20-55-17-151 1500 MHz: 17-17-22-22-60-18-164 1625 MHz: 19-19-24-24-65-19-178 1750 MHz: 17-17-22-22-60-18-164 1875 MHz: 21-21-26-26-70-20-192 2000 MHz: 19-19-24-24-65-19-178
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值