Kinetis SDK v.1.2 Demo Applications User's Guide  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
freemaster_tsa.h
Go to the documentation of this file.
1 /******************************************************************************
2 *
3 * Freescale Semiconductor Inc.
4 * (c) Copyright 2004-2010 Freescale Semiconductor
5 * ALL RIGHTS RESERVED.
6 *
7 ****************************************************************************/
19 #ifndef __FREEMASTER_TSA_H
20 #define __FREEMASTER_TSA_H
21 
22 #include "freemaster.h"
23 #include "freemaster_cfg.h"
24 
25 /*****************************************************************************
26  Target-side Address translation structures and macros
27 ******************************************************************************/
28 
29 /* current TSA version */
30 #define FMSTR_TSA_VERSION 2U
31 
32 /* TSA flags carried in TSA_ENTRY.info (except the first entry in table) */
33 #define FMSTR_TSA_INFO_ENTRYTYPE_MASK 0x0003U /* flags reserved for TSA_ENTRY use */
34 #define FMSTR_TSA_INFO_STRUCT 0x0000U /* ENTRYTYPE: structure parent type */
35 #define FMSTR_TSA_INFO_RO_VAR 0x0001U /* ENTRYTYPE: read-only variable */
36 #define FMSTR_TSA_INFO_MEMBER 0x0002U /* ENTRYTYPE: structure member */
37 #define FMSTR_TSA_INFO_RW_VAR 0x0003U /* ENTRYTYPE: read-write variable */
38 #define FMSTR_TSA_INFO_VAR_FLAG 0x0001U /* ENTRYTYPE: FLAG: any variable */
39 #define FMSTR_TSA_INFO_RWV_FLAG 0x0002U /* ENTRYTYPE: FLAG: R/W access */
40 
41 /* TSA table index and size (both unsigned, at least 16 bit wide) */
44 
45 /* pointer types used in TSA tables can be overridden in freemaster.h */
46 /* (this is why macros are used instead of typedefs) */
47 #ifndef FMSTR_TSATBL_STRPTR
48 #define FMSTR_TSATBL_STRPTR const char*
49 #endif
50 #ifndef FMSTR_TSATBL_STRPTR_CAST
51 #define FMSTR_TSATBL_STRPTR_CAST(x) ((FMSTR_TSATBL_STRPTR)(x))
52 #endif
53 #ifndef FMSTR_TSATBL_VOIDPTR
54 #define FMSTR_TSATBL_VOIDPTR const void*
55 #endif
56 #ifndef FMSTR_TSATBL_VOIDPTR_CAST
57 #define FMSTR_TSATBL_VOIDPTR_CAST(x) ((FMSTR_TSATBL_VOIDPTR)(x))
58 #endif
59 
60 /* TSA table entry. The unions inside assures variables sized enough to */
61 /* accomodate both the C-pointer and the user-requested size (FMSTR_ADDR) */
62 typedef struct
63 {
64  union { FMSTR_TSATBL_STRPTR p; FMSTR_ADDR n; } name;
65  union { FMSTR_TSATBL_STRPTR p; FMSTR_ADDR n; } type;
66  union { FMSTR_TSATBL_VOIDPTR p; FMSTR_ADDR n; } addr;
67  union { FMSTR_TSATBL_VOIDPTR p; FMSTR_ADDR n; } info;
69 
70 /* TSA table allocation modifier */
71 #ifndef FMSTR_USE_TSA_INROM
72 #define FMSTR_USE_TSA_INROM 0
73 #endif
74 #if FMSTR_USE_TSA_INROM
75 #define FMSTR_TSA_CDECL const
76 #else
77 #define FMSTR_TSA_CDECL
78 #endif
79 
80 /*//////////////////////////////////////////////// */
81 /* single table-building macros */
82 
83 #define FMSTR_TSA_FUNC(id) FMSTR_TsaGetTable_##id
84 #define FMSTR_TSA_FUNC_PROTO(id) const FMSTR_TSA_ENTRY* FMSTR_TSA_FUNC(id) (FMSTR_TSA_TSIZE* pTableSize)
85 
86 #define FMSTR_TSA_TABLE_BEGIN(id) \
87  FMSTR_TSA_FUNC_PROTO(id); \
88  FMSTR_TSA_FUNC_PROTO(id) { \
89  static FMSTR_TSA_CDECL FMSTR_TSA_ENTRY fmstr_tsatable[] = {
90 
91 /* entry info */
92 #define FMSTR_TSA_INFO1(elem, flags) FMSTR_TSATBL_VOIDPTR_CAST(((sizeof(elem))<<2)|(flags))
93 #define FMSTR_TSA_INFO2(size, flags) FMSTR_TSATBL_VOIDPTR_CAST(((size)<<2)|(flags))
94 
95 #define FMSTR_TSA_STRUCT(name) \
96  { FMSTR_TSATBL_STRPTR_CAST(#name), FMSTR_TSATBL_STRPTR_CAST(NULL), FMSTR_TSATBL_VOIDPTR_CAST(NULL), FMSTR_TSA_INFO1(name, FMSTR_TSA_INFO_STRUCT) },
97 
98 #define FMSTR_TSA_MEMBER(parenttype,name,type) \
99  { FMSTR_TSATBL_STRPTR_CAST(#name), FMSTR_TSATBL_STRPTR_CAST(type), FMSTR_TSATBL_VOIDPTR_CAST(&((parenttype*)0)->name), FMSTR_TSA_INFO1(((parenttype*)0)->name, FMSTR_TSA_INFO_MEMBER) },
100 
101 #define FMSTR_TSA_RO_VAR(name,type) \
102  { FMSTR_TSATBL_STRPTR_CAST(#name), FMSTR_TSATBL_STRPTR_CAST(type), FMSTR_TSATBL_VOIDPTR_CAST(&(name)), FMSTR_TSA_INFO1(name, FMSTR_TSA_INFO_RO_VAR) },
103 
104 #define FMSTR_TSA_RW_VAR(name,type) \
105  { FMSTR_TSATBL_STRPTR_CAST(#name), FMSTR_TSATBL_STRPTR_CAST(type), FMSTR_TSATBL_VOIDPTR_CAST(&(name)), FMSTR_TSA_INFO1(name, FMSTR_TSA_INFO_RW_VAR) },
106 
107 #define FMSTR_TSA_RO_MEM(name,type,addr,size) \
108  { FMSTR_TSATBL_STRPTR_CAST(#name), FMSTR_TSATBL_STRPTR_CAST(type), FMSTR_TSATBL_VOIDPTR_CAST(addr), FMSTR_TSA_INFO2(size, FMSTR_TSA_INFO_RO_VAR) },
109 
110 #define FMSTR_TSA_RW_MEM(name,type,addr,size) \
111  { FMSTR_TSATBL_STRPTR_CAST(#name), FMSTR_TSATBL_STRPTR_CAST(type), FMSTR_TSATBL_VOIDPTR_CAST(addr), FMSTR_TSA_INFO2(size, FMSTR_TSA_INFO_RW_VAR) },
112 
113 #define FMSTR_TSA_TABLE_END() }; \
114  if(pTableSize) *pTableSize = sizeof(fmstr_tsatable); \
115  return fmstr_tsatable; }
116 
117 /*///////////////////////////////////////////////////////////////////// */
118 /* TSA "Base Types", all are implemented as a one-char strings */
119 /* retrieved by PC and parsed according to the binary scheme */
120 /* "111STTZZ" where TT=type[int,frac,fp,x] S=signed ZZ=size[1,2,4,8] */
121 
122 #define FMSTR_TSA_UINT8 "\xE0"
123 #define FMSTR_TSA_UINT16 "\xE1"
124 #define FMSTR_TSA_UINT32 "\xE2"
125 #define FMSTR_TSA_UINT64 "\xE3"
126 #define FMSTR_TSA_SINT8 "\xF0"
127 #define FMSTR_TSA_SINT16 "\xF1"
128 #define FMSTR_TSA_SINT32 "\xF2"
129 #define FMSTR_TSA_SINT64 "\xF3"
130 #define FMSTR_TSA_UFRAC16 "\xE5"
131 #define FMSTR_TSA_UFRAC32 "\xE6"
132 #define FMSTR_TSA_FRAC16 "\xF5"
133 #define FMSTR_TSA_FRAC32 "\xF6"
134 #define FMSTR_TSA_FLOAT "\xFA"
135 #define FMSTR_TSA_DOUBLE "\xFB"
136 
137 /* macro used to describe "User Type" */
138 #define FMSTR_TSA_USERTYPE(type) #type
139 
140 /* macro used to describe pure memory space */
141 #define FMSTR_TSA_MEMORY NULL
142 
143 
144 /*//////////////////////////////////////////////// */
145 /* master TSA table-retrival building macros */
146 
147 #define FMSTR_TSA_TABLE_LIST_BEGIN() \
148  const FMSTR_TSA_ENTRY* FMSTR_TsaGetTable(FMSTR_TSA_TINDEX nTableIndex, FMSTR_TSA_TSIZE* pTableSize) {
149 
150 #define FMSTR_TSA_TABLE(id) \
151  if(!nTableIndex--) { \
152  FMSTR_TSA_FUNC_PROTO(id); \
153  return FMSTR_TSA_FUNC(id)(pTableSize); \
154  } else
155 
156 #define FMSTR_TSA_TABLE_LIST_END() \
157  { return NULL; } }
158 
159 /*****************************************************************************
160  Target-side Address translation functions
161 ******************************************************************************/
162 
163 /* master TSA table-retrival function */
164 const FMSTR_TSA_ENTRY* FMSTR_TsaGetTable(FMSTR_TSA_TINDEX nTableIndex, FMSTR_TSA_TSIZE* pTableSize);
165 
166 #endif /* __FREEMASTER_TSA_H */
167 
unsigned short FMSTR_SIZE
Definition: freemaster.h:39
FMSTR_SIZE FMSTR_TSA_TINDEX
Definition: freemaster_tsa.h:42
Definition: freemaster_tsa.h:62
const FMSTR_TSA_ENTRY * FMSTR_TsaGetTable(FMSTR_TSA_TINDEX nTableIndex, FMSTR_TSA_TSIZE *pTableSize)
FMSTR_SIZE FMSTR_TSA_TSIZE
Definition: freemaster_tsa.h:43
unsigned char * FMSTR_ADDR
Definition: freemaster.h:38
FreeMASTER Driver main API header file, Kxx(40/60) platform.