LMS 2012
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_memory.h
Go to the documentation of this file.
1 /*
2  * LEGO® MINDSTORMS EV3
3  *
4  * Copyright (C) 2010-2013 The LEGO Group
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 
21 
22 #ifndef C_MEMORY_H_
23 #define C_MEMORY_H_
24 
25 #include "lms2012.h"
26 
27 RESULT cMemoryInit(void);
28 
29 RESULT cMemoryOpen(PRGID PrgId,GBINDEX Size,void **pMemory);
30 
31 RESULT cMemoryClose(PRGID PrgId);
32 
33 RESULT cMemoryExit(void);
34 
35 RESULT cMemoryMalloc(void **ppMemory,DATA32 Size);
36 
37 RESULT cMemoryRealloc(void *pOldMemory,void **ppMemory,DATA32 Size);
38 
39 RESULT cMemoryGetPointer(PRGID PrgId,HANDLER Handle,void **pMemory);
40 
41 RESULT cMemoryArraryPointer(PRGID PrgId,HANDLER Handle,void **pMemory);
42 
44 
45 DATA8 cMemoryGetCacheName(DATA8 Item,DATA8 MaxLength,char *pFileName,char *pName);
46 
47 DATA8 cMemoryFindSubFolders(char *pFolderName);
48 
49 DATA8 cMemoryGetSubFolderName(DATA8 Item,DATA8 MaxLength,char *pFolderName,char *pSubFolderName);
50 
51 DATA8 cMemoryFindFiles(char *pFolderName);
52 
53 void cMemoryGetResourcePath(PRGID PrgId,char *pString,DATA8 MaxLength);
54 
55 RESULT cMemoryGetIcon(DATA8 *pFolderName,DATA8 Item,DATA32 *pImagePointer);
56 
57 RESULT cMemoryGetImage(DATA8 *pText,DATA16 Size,UBYTE *pBmp);
58 
60 
61 RESULT cMemoryCheckOpenWrite(char *pFileName);
62 
63 RESULT cMemoryCheckFilename(char *pFilename,char *pPath,char *pName,char *pExt);
64 
65 RESULT cMemoryGetMediaName(char *pChar,char *pName);
66 
67 
68 
69 void cMemoryFile(void);
70 
71 void cMemoryArray(void);
72 
73 void cMemoryArrayWrite(void);
74 
75 void cMemoryArrayRead(void);
76 
77 void cMemoryArrayAppend(void);
78 
79 void* cMemoryResize(PRGID PrgId,HANDLER Handle,DATA32 Elements);
80 
81 void cMemoryFileName(void);
82 
83 
84 
85 RESULT cMemoryOpenFolder(PRGID PrgId,DATA8 Type,DATA8 *pFolderName,HANDLER *pHandle);
86 
87 RESULT cMemoryGetFolderItems(PRGID PrgId,HANDLER Handle,DATA16 *pItems);
88 
89 RESULT cMemoryGetItemName(PRGID PrgId,HANDLER Handle,DATA16 Item,DATA8 Length,DATA8 *pName,DATA8 *pType,DATA8 *pPriority);
90 
91 RESULT cMemoryGetItemIcon(PRGID PrgId,HANDLER Handle,DATA16 Item,HANDLER *pHandle,DATA32 *pImagePointer);
92 
93 RESULT cMemoryGetItemText(PRGID PrgId,HANDLER Handle,DATA16 Item,DATA8 Length,DATA8 *pText);
94 
95 RESULT cMemorySetItemText(PRGID PrgId,HANDLER Handle,DATA16 Item,DATA8 *pText);
96 
97 RESULT cMemoryGetItem(PRGID PrgId,HANDLER Handle,DATA16 Item,DATA8 Length,DATA8 *pName,DATA8 *pType);
98 
99 void cMemoryCloseFolder(PRGID PrgId,HANDLER *pHandle);
100 
101 void cMemoryGetUsage(DATA32 *pTotal,DATA32 *pFree,DATA8 Force);
102 
103 void cMemoryUsage(void);
104 
105 #define POOL_TYPE_MEMORY 0
106 #define POOL_TYPE_FILE 1
107 
108 typedef struct
109 {
110  void *pPool;
113 }
114 POOL;
115 
116 
117 typedef struct
118 {
125  DATA8 pArray[]; // Must be aligned
126 }
127 DESCR;
128 
129 typedef struct
130 {
131  int hFile;
133  char Filename[vmFILENAMESIZE];
134 }
135 FDESCR;
136 
137 
138 typedef struct
139 {
140  //*****************************************************************************
141  // Memory Global variables
142  //*****************************************************************************
143 
146 
147  //DATA32 BytesUsed;
148  DATA8 PathList[MAX_PROGRAMS][vmPATHSIZE];
149  POOL pPoolList[MAX_PROGRAMS][MAX_HANDLES];
150 
151  DATA8 Cache[CACHE_DEEPT + 1][vmFILENAMESIZE];
152 
153 }
155 
156 #if (HARDWARE == SIMULATION)
158  #define MemoryInstance (*gMemoryInstance)
159 
160  void setMemoryInstance(MEMORY_GLOBALS * _Instance);
162 #else
164 #endif
165 
166 #endif /* C_MEMORY_H_ */
void cMemoryGetResourcePath(PRGID PrgId, char *pString, DATA8 MaxLength)
Definition: c_memory.c:1065
GBINDEX Size
Definition: c_memory.h:111
void cMemoryArray(void)
opARRAY byte code
Definition: c_memory.c:3392
RESULT cMemoryClose(PRGID PrgId)
Definition: c_memory.c:437
DATA8 cMemoryFindSubFolders(char *pFolderName)
Definition: c_memory.c:763
DATA8 Type
Definition: c_memory.h:122
SWORD DATA16
VM Type for 2 byte signed value.
Definition: lmstypes.h:62
DATA32 SyncTick
Definition: c_memory.h:145
SLONG DATA32
VM Type for 4 byte signed value.
Definition: lmstypes.h:63
#define MemoryInstance
Definition: c_memory.h:158
DATA8 cMemoryGetSubFolderName(DATA8 Item, DATA8 MaxLength, char *pFolderName, char *pSubFolderName)
Definition: c_memory.c:852
DATA8 cMemoryFindFiles(char *pFolderName)
Definition: c_memory.c:1038
RESULT cMemoryGetItemIcon(PRGID PrgId, HANDLER Handle, DATA16 Item, HANDLER *pHandle, DATA32 *pImagePointer)
Definition: c_memory.c:1869
DSPSTAT cMemoryCloseFile(PRGID PrgId, HANDLER Handle)
Definition: c_memory.c:1421
DATA16 HANDLER
Memory list index.
Definition: lmstypes.h:85
MEMORY_GLOBALS * getMemoryInstance()
Definition: c_memory.c:86
DATA32 SyncTime
Definition: c_memory.h:144
Definition: c_memory.h:108
RESULT cMemoryGetItemName(PRGID PrgId, HANDLER Handle, DATA16 Item, DATA8 Length, DATA8 *pName, DATA8 *pType, DATA8 *pPriority)
Definition: c_memory.c:1815
void * cMemoryResize(PRGID PrgId, HANDLER Handle, DATA32 Elements)
Definition: c_memory.c:468
RESULT cMemoryGetItemText(PRGID PrgId, HANDLER Handle, DATA16 Item, DATA8 Length, DATA8 *pText)
Definition: c_memory.c:1921
RESULT cMemoryGetItem(PRGID PrgId, HANDLER Handle, DATA16 Item, DATA8 Length, DATA8 *pName, DATA8 *pType)
Definition: c_memory.c:2023
RESULT cMemoryInit(void)
Definition: c_memory.c:375
DATA8 cMemoryGetCacheFiles(void)
Definition: c_memory.c:1021
RESULT cMemoryOpenFolder(PRGID PrgId, DATA8 Type, DATA8 *pFolderName, HANDLER *pHandle)
Definition: c_memory.c:1690
DATA8 Free2
Definition: c_memory.h:124
ULONG GBINDEX
GlobalBytes index type.
Definition: lmstypes.h:79
DATA8 Access
Definition: c_memory.h:132
DATA32 Elements
Definition: c_memory.h:119
void cMemoryArrayWrite(void)
opARRAY_WRITE byte code
Definition: c_memory.c:3935
RESULT cMemoryArraryPointer(PRGID PrgId, HANDLER Handle, void **pMemory)
Definition: c_memory.c:277
RESULT cMemoryGetImage(DATA8 *pText, DATA16 Size, UBYTE *pBmp)
Definition: c_memory.c:1480
RESULT cMemoryRealloc(void *pOldMemory, void **ppMemory, DATA32 Size)
Definition: c_memory.c:160
unsigned char UBYTE
Basic Type used to symbolise 8 bit unsigned values.
Definition: lmstypes.h:29
RESULT cMemoryGetFolderItems(PRGID PrgId, HANDLER Handle, DATA16 *pItems)
Definition: c_memory.c:1742
void * pPool
Definition: c_memory.h:110
DATA8 cMemoryGetCacheName(DATA8 Item, DATA8 MaxLength, char *pFileName, char *pName)
Definition: c_memory.c:986
DATA8 Type
Definition: c_memory.h:112
RESULT cMemoryGetIcon(DATA8 *pFolderName, DATA8 Item, DATA32 *pImagePointer)
Definition: c_memory.c:1071
RESULT cMemoryMalloc(void **ppMemory, DATA32 Size)
Definition: c_memory.c:140
RESULT cMemorySetItemText(PRGID PrgId, HANDLER Handle, DATA16 Item, DATA8 *pText)
Definition: c_memory.c:1982
MEMORY_GLOBALS * gMemoryInstance
Definition: c_memory.c:79
void cMemoryCloseFolder(PRGID PrgId, HANDLER *pHandle)
Definition: c_memory.c:2064
int hFile
Definition: c_memory.h:131
UWORD PRGID
Program id type.
Definition: lmstypes.h:71
DATA8 Free1
Definition: c_memory.h:123
SBYTE DATA8
VM Type for 1 byte signed value.
Definition: lmstypes.h:61
RESULT cMemoryGetPointer(PRGID PrgId, HANDLER Handle, void **pMemory)
Definition: c_memory.c:252
void cMemoryArrayRead(void)
opARRAY_READ byte code
Definition: c_memory.c:4047
void cMemoryFileName(void)
opFILENAME byte code
Definition: c_memory.c:4347
void cMemoryFile(void)
opFILE byte code
Definition: c_memory.c:2303
DSPSTAT
Definition: lms2012.h:665
void cMemoryArrayAppend(void)
opARRAY_APPEND byte code
Definition: c_memory.c:4134
void cMemoryUsage(void)
opMEMORY_USAGE byte code
Definition: c_memory.c:4257
RESULT cMemoryCheckFilename(char *pFilename, char *pPath, char *pName, char *pExt)
Definition: c_memory.c:552
RESULT cMemoryGetMediaName(char *pChar, char *pName)
Definition: c_memory.c:1504
void setMemoryInstance(MEMORY_GLOBALS *_Instance)
Definition: c_memory.c:81
RESULT cMemoryExit(void)
Definition: c_memory.c:448
RESULT cMemoryCheckOpenWrite(char *pFileName)
Definition: c_memory.c:1199
DATA32 UsedElements
Definition: c_memory.h:120
void cMemoryGetUsage(DATA32 *pTotal, DATA32 *pFree, DATA8 Force)
Definition: c_memory.c:104
RESULT cMemoryOpen(PRGID PrgId, GBINDEX Size, void **pMemory)
Definition: c_memory.c:426
DATA8 ElementSize
Definition: c_memory.h:121