GernotFrisch
Member
- Joined
- Jan 2, 2007
- Messages
- 445
Hi,
how can I get a unique device ID for the wiz?
how can I get a unique device ID for the wiz?
int memfd = open("/dev/mem", O_RDWR);
volatile unsigned int *memregs32;
memregs32 = (volatile unsigned int*) mmap(0, 0x20000, PROT_READ|PROT_WRITE, MAP_SHARED, memfd, 0xC0000000);
int rv = 0;
typedef struct regStruct_guid {
unsigned long Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[8];
}regStruct_guid;
regStruct_guid *guid_reg;
guid_reg = (regStruct_guid*) memregs32[0x1F844];
rv = guid_reg -> Data1;
close(memfd);
return rv;
typedef struct regStruct_guid {
unsigned long Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[8];
} regStruct_guid;
regStruct_guid guid_reg;
guid_reg.Data1 = (unsigned long)memregs32[0x1F844>>2];
guid_reg.Data2 = (unsigned short)(memregs32[0x1F848>>2] >> 16);
guid_reg.Data3 = (unsigned short)memregs32[0x1F848>>2];
guid_reg.Data4[0] = (unsigned char)memregs32[0x1F84C>>2];
guid_reg.Data4[1] = (unsigned char)(memregs32[0x1F84C>>2] >> 8);
guid_reg.Data4[2] = (unsigned char)(memregs32[0x1F84C>>2] >> 16);
guid_reg.Data4[3] = (unsigned char)(memregs32[0x1F84C>>2] >> 24);
guid_reg.Data4[4] = (unsigned char)memregs32[0x1F850>>2];
guid_reg.Data4[5] = (unsigned char)(memregs32[0x1F850>>2] >> 8);
guid_reg.Data4[6] = (unsigned char)(memregs32[0x1F850>>2] >> 16);
guid_reg.Data4[7] = (unsigned char)(memregs32[0x1F850>>2] >> 24);
int memfd = open("/dev/mem", O_RDWR);
volatile unsigned int *memregs32;
memregs32 = (volatile unsigned int*) mmap(0, 0x20000, PROT_READ|PROT_WRITE, MAP_SHARED, memfd, 0xC0000000);
typedef struct regStruct_guid {
unsigned long Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[8];
} regStruct_guid;
regStruct_guid guid_reg;
guid_reg.Data1 = (unsigned long)memregs32[0x1F844>>2];
guid_reg.Data2 = (unsigned short)(memregs32[0x1F848>>2] >> 16);
guid_reg.Data3 = (unsigned short)memregs32[0x1F848>>2];
guid_reg.Data4[0] = (unsigned char)memregs32[0x1F84C>>2];
guid_reg.Data4[1] = (unsigned char)(memregs32[0x1F84C>>2] >> 8);
guid_reg.Data4[2] = (unsigned char)(memregs32[0x1F84C>>2] >> 16);
guid_reg.Data4[3] = (unsigned char)(memregs32[0x1F84C>>2] >> 24);
guid_reg.Data4[4] = (unsigned char)memregs32[0x1F850>>2];
guid_reg.Data4[5] = (unsigned char)(memregs32[0x1F850>>2] >> 8);
guid_reg.Data4[6] = (unsigned char)(memregs32[0x1F850>>2] >> 16);
guid_reg.Data4[7] = (unsigned char)(memregs32[0x1F850>>2] >> 24);
close(memfd);
int id = guid_reg.Data1 + (guid_reg.Data2<<16) + guid_reg.Data3;
for(int i=0; i<8; ++i)
{
id+=guid_reg.Data4[i] * (1<<(i*8));
}
return id;