這就是 copy 自 tcpmp getcpuid 的 code 後,run 起來:
- 我們的: 4117B362,1D152152,0,0
- 測試的: 410FB764,1D992992,0,0
4117B362:ref(http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0360f/CACEDHJG.html)
所以是 ARM1136, rev2
410FB764: ref (http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0360f/CACEDHJG.html)
所以是 ARM1176 , rev 4
第二個,cache type register
ref : http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0211k/I67616.html
- [31:29] : always 0
- [28:25] : ctype - cache type b1110 means "write back","register 7 operation","format C"
- [24] : separate D and I cache
- [23:12] : D cache size
- [11:0] : I cache size
- [11] : P
- [10:9] : always 0
- [8:6] : size
- [5:3] : association (way)
- [2] : M
- [1:0] Length
1D152152 : 16K, 4 way, len=32 bytes.
1D992992: 32K, 4 way, len=32 bytes.
driver code
GETID.C:
#include <windows.h>
#include <drvlib.h>
//----- Code Control -----
#define GID_DEBUG
#ifdef DEBUG
DBGPARAM dpCurSettings = { TEXT("Getid"), {
TEXT("Verbose"), TEXT(""), TEXT(""), TEXT(""),
TEXT(""), TEXT(""), TEXT(""), TEXT(""),
TEXT(""), TEXT(""), TEXT(""), TEXT(""),
TEXT(""), TEXT(""), TEXT(""), TEXT("")},
0x00000000
};
#endif
extern void GetCpuId(int,DWORD*);
void SafeGetCpuId(int Id, DWORD* p)
{
memset(p,0,4*sizeof(DWORD));
GetCpuId(Id,p);
}
//--- GID_Init
DWORD GID_Init(DWORD dwContext)
{
DWORD CpuId[4];
DWORD dwErr;
TCHAR outmsg[60];
RETAILMSG(1, (TEXT("[GID] GID_Init+\r\n")));
SafeGetCpuId(0,CpuId);
RETAILMSG(1,(TEXT("%X,%X,%X,%X\r\n"),CpuId[0],CpuId[1],CpuId[2],CpuId[3]));
swprintf(outmsg,TEXT("%X,%X,%X,%X"),CpuId[0],CpuId[1],CpuId[2],CpuId[3]);
MessageBox(NULL,outmsg,TEXT("GID"),MB_OK);
RETAILMSG(1, (TEXT("[GID] GID_Init OK \r\n")));
return TRUE;
}
//--- GID_Deinit
BOOL GID_Deinit(DWORD dwContext)
{
RETAILMSG(1, (TEXT("[GID] GID_Deinit+\r\n")));
return TRUE;
}
//--- GID_Open
DWORD GID_Open(DWORD dwData, DWORD dwAccess, DWORD dwShareMode)
{
RETAILMSG(1, (TEXT("[GID] GID_Open+\r\n")));
return dwData;
}
//--- GID_Close
BOOL GID_Close(DWORD Handle)
{
RETAILMSG(1, (TEXT("[GID] GID_Close+\r\n")));
return TRUE;
}
//--- GID_Read
DWORD GID_Read(DWORD Handle, LPVOID pBuffer, DWORD dwNumBytes)
{
RETAILMSG(1, (TEXT("[GID] GID_Read+\r\n")));
return 0;
}
//--- GID_Write
DWORD GID_Write(DWORD Handle, LPCVOID pBuffer, DWORD dwNumBytes)
{
RETAILMSG(1, (TEXT("[GID] GID_Write+\r\n")));
return 0;
}
//--- GID_Seek
DWORD GID_Seek(DWORD Handle, long lDistance, DWORD dwMoveMethod)
{
RETAILMSG(1, (TEXT("[GID] GID_Seek+\r\n")));
return (DWORD) -1;
}
//--- GID_IOControl
BOOL GID_IOControl(
DWORD Handle,
DWORD dwCode,
PBYTE pBufIn,
DWORD dwLenIn,
PBYTE pBufOut,
DWORD dwLenOut,
PDWORD pdwActualOut
)
{
RETAILMSG(1, (TEXT("[GID] GID_IOControl+\r\n")));
return (FALSE);
}
BOOL
GID_DllEntry(
HINSTANCE hinstDll, /*@parm Instance pointer. */
DWORD dwReason, /*@parm Reason routine is called. */
LPVOID lpReserved /*@parm system parameter. */
)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls((HMODULE) hinstDll);
}
return (TRUE);
}
arm.s
INCLUDE kxarm.h
EXPORT GetCpuId
TEXTAREA
LEAF_ENTRY GetCpuId
export GetCpuId
mrs r0,cpsr
and r0,r0,#15
cmp r0,#15
bne UserMode
mrc p15,0,r0,c0,c0,0
nop
nop
mrc p15,0,r2,c0,c0,1
nop
nop
str r0,[r1,#0]
str r2,[r1,#4]
UserMode
mov pc,lr
ref (http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0360f/CACEDHJG.html) CpuID 取的是 opcode2 = 0 和 1 : cpu id 跟 cache type.
GETID.DEF
LIBRARY getid
EXPORTS
GID_Init
GID_Deinit
GID_Open
GID_Close
GID_Read
GID_Write
GID_IOControl
sources
TARGETNAME=getid
TARGETTYPE=DYNLINK
RELEASETYPE=PLATFORM
DLLENTRY=GID_DllEntry
DEFFILE=$(_TARGETPLATROOT)\SRC\DRIVERS\getid\getid.def
PREPROCESSDEFFILE=1
SYNCHRONIZE_DRAIN=1
WINCEREL=1
TARGETLIBS= \
$(_COMMONSDKROOT)\LIB\$(_CPUINDPATH)\coredll.lib \
SOURCELIBS= \
SOURCES= \
getid.c \
arm.s
load driver 的程式就是以前哪個 activedriverex( ). 改一下 dll name 就可以
ref http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0211k/I67616.html
用
沒有留言:
張貼留言