-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSTi5518_SearchDB.h
76 lines (67 loc) · 2.87 KB
/
STi5518_SearchDB.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//////////////////////////////////////////////////////////////////////////
// 16/12/2011 MrCODE
// Method for a more descriptive system added to "st20emu2.exe"
//////////////////////////////////////////////////////////////////////////
#include <stdlib.h> //this for bsearch()
#include "STi5518_RegisterDB.h"
#include "STi5518_Region0.h"
//////////////////////////////////////////////////////////////////////////
typedef int (*fptr)(const void*, const void*);
//////////////////////////////////////////////////////////////////////////
int compareRegs (const unsigned long *reg, const REGDESCR *regdescr) {
return(*reg-regdescr->addr);
}
//////////////////////////////////////////////////////////////////////////
int SearchForReg(FILE* outFp, unsigned long reg){
char found=FALSE,recogn=FALSE;
int i;
REGDESCR* regdescr;
/*FIRST THING FIRST. Check in what memory range we are*/
if(reg<=0xc0800000 && reg>=0xc0000000) //Shared SDRAM
fprintf(outFp,"DESCR: Address is into Shared SDRAM (Region 1)\n");
if(reg<=0x80001800 && reg>=0x80001000) //2Kb SRAM
fprintf(outFp,"DESCR: Internal SRAM if data cache is not enabled.User-code, data and stack (Region 0)\n");
if(reg<=0x80000fff && reg>=0x80000000) {//4Kb SRAM
for(i=0;i<=(sizeof(REG0_Entry)/sizeof(REG0DESCR));i++){
if(reg>=REG0_Entry[i].lbaddr && reg<=REG0_Entry[i].hbaddr){
fprintf(outFp,"DESCR: %s\n",REG0_Entry[i].description);
recogn=TRUE;break;
}
}
if(!recogn) fprintf(outFp,"DESCR: Address is into 4Kbyte SRAM (Region 0)\n");
};
if(reg<=0x7fffffff && reg>=0x70000000) //EMI Bank 3
fprintf(outFp,"DESCR: Address is into EMI BANK 3 (Region 3)\n");
if(reg<=0x6fffffff && reg>=0x60000000) //EMI Bank 2
fprintf(outFp,"DESCR: Address is into EMI BANK 2 (Region 3)\n");
if(reg<=0x5fffffff && reg>=0x50000000) //EMI Bank 1
fprintf(outFp,"DESCR: Address is into EMI BANK 1 (Region 3)\n");
if(reg<=0x4fffffff && reg>=0x40000000) //EMI Bank 0
fprintf(outFp,"DESCR: Address is into EMI BANK 0 (Region 3)\n");
if(reg<=0x3fffffff && reg>=0x20040000) //Reserved
fprintf(outFp,"DESCR: Address is into Reserved Memory Area(Region 2)\n");
if(reg<=0x2003ffff) //Peripheral configuration registers (Region 2)
{
/* find the description in the register database */
regdescr = (REGDESCR *) bsearch ( (void *) ®, (void *) DBREGS_Entry,
(size_t) sizeof(DBREGS_Entry) / sizeof (REGDESCR),
(size_t) sizeof (REGDESCR), (fptr) compareRegs );
if (regdescr == NULL ) {
fprintf(outFp,"Sorry, no match for 0x%08x in Registers DB\n",reg);
found = FALSE;
}
else
{
//printout of info's
fprintf (outFp, "REGN: %s bits:%d access:%s\nDESC: %s\n",
regdescr->regname,
regdescr->bits,
regdescr->access,
regdescr->description
);
found=TRUE;
}
}
return found;
}
//////////////////////////////////////////////////////////////////////////