sc_interface.h
3.7 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
* Copyright (c) 2008-2016 Allwinner Technology Co. Ltd.
* All rights reserved.
*
* File : typedef.h
* Description :
* History :
* Author : xyliu <xyliu@allwinnertech.com>
* Date : 2016/04/13
* Comment :
*
*
*/
#ifndef SC_INTERFACE_H
#define SC_INTERFACE_H
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C"
{
#endif
struct ScMemOpsS
{
int (*open)(void);
void (*close)(void);
int (*total_size)(void);
void *(*palloc)(int /*size*/, void *, void *);
void (*pfree)(void* /*mem*/, void *, void *);
void (*flush_cache)(void * /*mem*/, int /*size*/);
void *(*ve_get_phyaddr)(void * /*viraddr*/);
void *(*ve_get_viraddr)(void * /*phyaddr*/);
void *(*cpu_get_phyaddr)(void * /*viraddr*/);
void *(*cpu_get_viraddr)(void * /*phyaddr*/);
int (*mem_set)(void * /*s*/, int /*c*/, size_t /*n*/);
int (*mem_cpy)(void * /*dest*/, void * /*src*/, size_t /*n*/);
int (*mem_read)(void * /*dest */, void * /*src*/, size_t /*n*/);
int (*mem_write)(void * /*dest*/, void * /*src*/, size_t /*n*/);
int (*setup)(void);
int (*shutdown)(void);
//*the interface just for secureAlloc.c, not used by other function
void *(*palloc_secure)(int /*size*/, void*, void*);
unsigned int (*get_ve_addr_offset)(void);
};
static inline int CdcMemOpen(struct ScMemOpsS *memops)
{
return memops->open();
}
//* close the memory adapter.
static inline void CdcMemClose(struct ScMemOpsS *memops)
{
memops->close();
}
static inline int CdcMemTotalSize(struct ScMemOpsS *memops)
{
return memops->total_size();
}
static inline void *CdcMemPalloc(struct ScMemOpsS *memops, int nSize, void *veOps, void *pVeopsSelf)
{
return memops->palloc(nSize, veOps, pVeopsSelf);
}
static inline void CdcMemPfree(struct ScMemOpsS *memops, void* pMem, void *veOps, void *pVeopsSelf)
{
memops->pfree(pMem, veOps, pVeopsSelf);
}
static inline void CdcMemFlushCache(struct ScMemOpsS *memops, void* pMem, int nSize)
{
memops->flush_cache(pMem, nSize);
}
static inline void *CdcMemGetPhysicAddress(struct ScMemOpsS *memops, void* pVirtualAddress)
{
return memops->ve_get_phyaddr(pVirtualAddress);
}
static inline void *CdcMemGetVirtualAddress(struct ScMemOpsS *memops, void* pPhysicAddress)
{
return memops->ve_get_viraddr(pPhysicAddress);
}
static inline void CdcMemSet(struct ScMemOpsS *memops, void* pMem, int nValue, int nSize)
{
memops->mem_set(pMem, nValue, nSize);
}
static inline void CdcMemCopy(struct ScMemOpsS *memops, void* pMemDst, void* pMemSrc, int nSize)
{
memops->mem_cpy(pMemDst, pMemSrc, nSize);
}
static inline int CdcMemRead(struct ScMemOpsS *memops, void* pMemDst, void* pMemSrc, int nSize)
{
memops->mem_read(pMemDst, pMemSrc, nSize);
return 0;
}
static inline int CdcMemWrite(struct ScMemOpsS *memops,void* pMemDst, void* pMemSrc, int nSize)
{
(void)memops; /*not use memops */
memops->mem_write(pMemDst, pMemSrc, nSize);
return 0;
}
static inline void *CdcMemGetPhysicAddressCpu(struct ScMemOpsS *memops, void *virt)
{
return memops->cpu_get_phyaddr(virt);
}
static inline void *CdcMemGetVirtualAddressCpu(struct ScMemOpsS *memops, void *phy)
{
return memops->cpu_get_viraddr(phy);
}
static inline int CdcMemSetup(struct ScMemOpsS *memops)
{
return memops->setup();
}
static inline int CdcMemShutdown(struct ScMemOpsS *memops)
{
return memops->shutdown();
}
static inline void *CdcMemPallocSecure(struct ScMemOpsS *memops, int nSize,
void *veOps, void *pVeopsSelf)
{
return memops->palloc_secure(nSize,veOps, pVeopsSelf);
}
static inline unsigned int CdcMemPallocGetVeAddrOffset(struct ScMemOpsS *memops)
{
return memops->get_ve_addr_offset();
}
#ifdef __cplusplus
}
#endif
#endif