224 lines
4.7 KiB
C
Raw Normal View History

#pragma once
#include<hgl/TypeFunc.h>
2023-07-13 21:10:46 +08:00
#include<hgl/CompOperator.h>
namespace hgl
{
enum class SOCVendor
{
Unknow=0,
Qualcomm, ///<高通
Hisilicon, ///<海思
Samsung, ///<三星
MediaTek, ///<联发科
Unisoc, ///<展锐
Spreadtrum, ///<展讯
JLQ, ///<瓴盛
2023-07-13 00:58:57 +08:00
//Maxvell, ///<马维尔
//Broadcom, ///<博通
//TI, ///<德州仪器
2023-07-13 00:58:57 +08:00
//Rockchip, ///<瑞芯微
//Intel, ///<英特尔
//nVidia, ///<英伟达
//AMD, ///<AMD
//Google, ///<谷歌
ENUM_CLASS_RANGE(Unknow,JLQ)
};
2023-07-28 18:13:32 +08:00
constexpr const char *SOCVendorName[]=
2023-07-26 22:30:49 +08:00
{
"Unknow",
"Qualcomm",
"Hisilicon",
"Samsung",
"MediaTek",
"Unisoc",
"Spreadtrum",
"JLQ",
};
2023-07-28 18:13:32 +08:00
const SOCVendor ParseSOCVendor(const char *str);
2023-07-17 20:36:05 +08:00
enum class CpuArch
{
Unknow=0,
ARMv7, ///<ARMv7
ARMv8, ///<ARMv8
ARMv9, ///<ARMv9
MIPS,
X86_32,
X86_64,
ENUM_CLASS_RANGE(Unknow,X86_64)
};
enum class ARMArch
{
Unknow=0,
ARMv7, ///<ARMv7A
ARMv8,
ARMv8_2,
ARMv9,
ARMv9_2,
ENUM_CLASS_RANGE(Unknow,ARMv9_2)
};
union ARMCpuName
{
//如A76level为7,gen为6
//A710level为7,gen为10
struct
{
char family; ///<A或X
uint8 level; ///<级别,目前就0,1,3,5,7
uint8 gen; ///<代数
bool ae:1;
bool c:1;
};
uint32 value;
};
2023-07-28 10:34:27 +08:00
/**
* ARM CPU
*/
struct ARMCpuCoreInfo
2023-07-17 20:36:05 +08:00
{
ARMCpuName name;
ARMArch arch;
bool support_32bit;
bool support_64bit;
};
2023-08-01 15:40:02 +08:00
const uint32 ParseARMCpuName(ARMCpuName &,const char *); ///<根据字符串解晰ARM CPU名称ID
2023-07-17 20:36:05 +08:00
2023-07-28 10:34:27 +08:00
bool ParseARMCpuCoreInfo(ARMCpuCoreInfo *,const uint32 &cpu_name_id); ///<根据ARM CPU名字ID解晰CPU信息
2023-07-17 20:36:05 +08:00
enum class KryoArchLevel
{
Prime,
Gold,
Silver,
ENUM_CLASS_RANGE(Prime,Silver)
};
/**
2023-07-28 10:34:27 +08:00
* ARM CPU簇信息<br>
2023-07-17 20:36:05 +08:00
* MHz
*/
2023-07-28 10:34:27 +08:00
struct ARMCpuClusterInfo
2023-07-17 20:36:05 +08:00
{
2023-07-28 10:34:27 +08:00
ARMCpuCoreInfo arm; ///<对应的ARM核心信息
2023-07-17 20:36:05 +08:00
uint core_count; ///<核心数量
uint base_freq; ///<基础频率
uint boost_freq; ///<最高频率
};
2023-07-28 10:34:27 +08:00
struct SOCInfo
{
SOCVendor vendor;
2023-07-13 21:10:46 +08:00
char model[32];
public:
2023-07-28 10:34:27 +08:00
CompOperatorMemcmp(const SOCInfo &);
};
/**
* SOC信息SOC厂商和主要型号
*/
2023-07-28 10:34:27 +08:00
bool ParseSOCInfo(SOCInfo &,const char *);
2023-07-28 10:36:42 +08:00
2023-07-28 18:13:32 +08:00
enum class SOCGPUVendor
{
Unknow=0,
PowerVR,
Mali,
Adreno,
Vivante,
Intel,
Radeon,
Tegra,
ENUM_CLASS_RANGE(Unknow,Tegra)
};
constexpr const char *SOCGPUVendorName[]=
2023-07-28 10:36:42 +08:00
{
2023-07-28 18:13:32 +08:00
"Unknow",
"PowerVR",
"Mali",
"Adreno",
"Vivante",
"Intel",
"Radeon",
"Tegra",
};
2023-07-28 10:36:42 +08:00
2023-07-28 18:13:32 +08:00
const SOCGPUVendor ParseSOCGPUVendor(const char *str);
struct SOCGPUInfo
{
SOCGPUVendor vendor;
char model[32];
uint core_count;
uint freq;
2023-08-02 20:03:13 +08:00
public:
int Comp(const SOCGPUInfo &info)const
{
int result;
result=int(vendor)-int(info.vendor);
if(result)return result;
result=strcmp(model,info.model);
if(result)return result;
return core_count-info.core_count;
}
CompOperator(const SOCGPUInfo &,Comp);
2023-07-28 18:13:32 +08:00
};
/**
* SOC
*/
struct SOCProductInfo
{
char product_name[64]; ///<产品名称
SOCInfo soc_info; ///<SOC基本信息
SOCGPUInfo gpu_info; ///<GPU信息
uint cpu_cluster_count; ///<CPU簇数量
struct
{
char core[32]; ///<CPU核心名称
uint count; ///<核心数量
float freq; ///<频率
}cpu_cluster[4]; ///<CPU簇信息
};//struct SOCProductInfo
}//namespace hgl