DVBCore  17.9.0
Open Source DVB Engine
 All Data Structures Files Functions Typedefs Macros Pages
stbhwmem.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2004 Ocean Blue Software Ltd
4  *
5  * This file is part of a DTVKit Software Component
6  * You are permitted to copy, modify or distribute this file subject to the terms
7  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
8  *
9  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
10  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
11  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
12  *
13  * If you or your organisation is not a member of DTVKit then you have access
14  * to this source code outside of the terms of the licence agreement
15  * and you are expected to delete this and any associated files immediately.
16  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
17  *******************************************************************************/
24 // pre-processor mechanism so multiple inclusions don't cause compilation error
25 
26 #ifndef _STBHWMEM_H
27 
28 #define _STBHWMEM_H
29 
30 #include "techtype.h"
31 
32 //---Constant and macro definitions for public use-----------------------------
33 // IMPORTANT NOTE: The following definition musts comply with that defined in el_nvram.c of the loader
34 // source code. The number of NVRAM bytes that are reserved for the loader are defined in the first two
35 // bytes of NVRAM. The area immediately following those 2 bytes are the Euroloader NVM area itself
36 #define ELOAD_RESERVED_NVM_OFFSET 0 // offset of NVM reserved for Euroloader
37 #define ELOAD_RESERVED_NVM_SIZE_WIDTH 2 // width in bytes of variable denoting no.
38  // of Euroloader NVM bytes
39 
40 #define ELOAD_NVM_DATA_OFFSET ELOAD_RESERVED_NVM_SIZE_WIDTH // E'loader data starts immed. after size variable
41 
42 //---Enumerations for public use-----------------------------------------------
43 
44 /* Key values for data items that can be stored in secure NVM */
45 enum
46 {
47  SECURE_NVM_DEFAULT_ENCRYPTION_KEY, /* 0 */
48  SECURE_NVM_DEFAULT_ENC_INIT_VECTOR, /* 1 */
49  SECURE_NVM_CI_PLUS_ROOT_CERT, /* 2 */
50  SECURE_NVM_CI_PLUS_BRAND_CERT, /* 3 */
51  SECURE_NVM_CI_PLUS_DEVICE_CERT, /* 4 */
52  SECURE_NVM_CI_PLUS_DEVICE_KEY, /* 5 */
53  SECURE_NVM_CI_PLUS_DH_P, /* 6 */
54  SECURE_NVM_CI_PLUS_DH_G, /* 7 */
55  SECURE_NVM_CI_PLUS_DH_Q, /* 8 */
56  SECURE_NVM_CI_PLUS_PRNG_KEY_K, /* 9 */
57  SECURE_NVM_CI_PLUS_PRNG_SEED, /* 10 */
58  SECURE_NVM_CI_PLUS_SIV, /* 11 */
59  SECURE_NVM_CI_PLUS_SLK, /* 12 */
60  SECURE_NVM_CI_PLUS_CLK, /* 13 */
61  SECURE_NVM_CI_PLUS_CONTEXTS, /* 14 */
62  SECURE_NVM_MHEG5_PRIVATE_KEY, /* 15 */
63  SECURE_NVM_MHEG5_PRIVATE_KEY_VERSION, /* 16 */
64  SECURE_NVM_SOFTWARE_UPGRADE_PUBLIC_KEY, /* 17 */
65  SECURE_NVM_SOFTWARE_UPGRADE_SHARED_KEY /* 18 */
66 };
67 
68 //---Global type defs for public use-------------------------------------------
69 
70 //---Global Function prototypes for public use---------------------------------
71 
72 #include "stbhwdsk.h" /* for E_STB_DSK_FILE_MODE */
73 
77 void STB_MEMInitialiseRAM(void);
78 
83 void STB_MEMInitialiseNVM(void);
84 
92 BOOLEAN STB_MEMReadNVM(U32BIT addr, U32BIT bytes, U8BIT *dst_addr);
93 
101 BOOLEAN STB_MEMWriteNVM(U32BIT addr, U32BIT bytes, U8BIT *src_addr);
102 
110 void* STB_MEMReadSecureVariable(U8BIT key, U32BIT *len);
111 
116 void STB_MEMReleaseSecureVariable(void *value);
117 
125 BOOLEAN STB_MEMWriteSecureVariable(U8BIT key, void *value, U32BIT len);
126 
134 const void* STB_MEMReadSecureConstant(U8BIT key, U32BIT *len);
135 
140 U32BIT STB_MEMGetNVMSize(void);
141 
146 U32BIT STB_MEMGetNVMOffset(void);
147 
152 U8BIT STB_MEMGetNVMAlign(void);
153 
159 void* STB_MEMGetSysRAM(U32BIT bytes);
160 
168 void* STB_MEMResizeSysRAM(void *ptr, U32BIT new_num_bytes);
169 
174 void STB_MEMFreeSysRAM(void *block);
175 
180 U8BIT STB_MEMSysRAMUsed(void);
181 
188 void* STB_MEMGetAppRAM(U32BIT bytes);
189 
197 void* STB_MEMResizeAppRAM(void *ptr, U32BIT new_num_bytes);
198 
203 void STB_MEMFreeAppRAM(void *block);
204 
209 U8BIT STB_MEMAppRAMUsed(void);
210 
211 
212 BOOLEAN STB_MEMConfigMloaderForUpgrade(void *loader_data, U32BIT data_size);
213 BOOLEAN STB_MEMReadMloaderData(void *buffer, U32BIT size);
214 BOOLEAN STB_MEMWriteMloaderData(void *buffer, U32BIT size);
215 
222 BOOLEAN STB_NVMFileSize(U8BIT *filename, U32BIT *filesize);
223 
232 void* STB_NVMOpenFile(U8BIT *name, E_STB_DSK_FILE_MODE mode);
233 
238 void STB_NVMCloseFile(void *file);
239 
247 U32BIT STB_NVMReadFile(void *file, U8BIT *data, U32BIT size);
248 
256 U32BIT STB_NVMWriteFile(void *file, U8BIT *data, U32BIT size);
257 
263 BOOLEAN STB_NVMDeleteFile(U8BIT *filename);
264 
271 BOOLEAN STB_NVMMoveFile(U8BIT* oldname, U8BIT* newname);
272 
278 void* STB_NVMOpenDirectory(U8BIT *dir_name);
279 
290 BOOLEAN STB_NVMReadDirectory(void *dir, U8BIT *filename, U16BIT filename_len,
291  E_STB_DIR_ENTRY_TYPE *entry_type);
292 
297 void STB_NVMCloseDirectory(void *dir);
298 
299 #endif // _STBHWMEM_H
BOOLEAN STB_NVMDeleteFile(U8BIT *filename)
Deletes the file.
void * STB_MEMReadSecureVariable(U8BIT key, U32BIT *len)
Read variable defined by the given key from secure NVM. The data must be released using STB_MEMReleas...
BOOLEAN STB_MEMWriteNVM(U32BIT addr, U32BIT bytes, U8BIT *src_addr)
Writes data to the NVM.
void * STB_MEMResizeAppRAM(void *ptr, U32BIT new_num_bytes)
Changes the size of the given block of memory ensuring data contained within the original memory bloc...
void STB_MEMReleaseSecureVariable(void *value)
Releas the data returned by STB_MEMReadSecureVariable. This function is used for CI+.
void STB_NVMCloseFile(void *file)
Flushes and closes an open file.
BOOLEAN STB_MEMWriteSecureVariable(U8BIT key, void *value, U32BIT len)
Writes data defined by the given key to secure NVM. This function is used for CI+.
void * STB_NVMOpenFile(U8BIT *name, E_STB_DSK_FILE_MODE mode)
Opens an existing file or creates a new one.
void STB_MEMInitialiseNVM(void)
Initialises Non-Volatile memory access. For a new NVM device, this function formats it ready for use...
U8BIT STB_MEMAppRAMUsed(void)
Returns the amount of available application memory consumed.
void * STB_NVMOpenDirectory(U8BIT *dir_name)
Opens a directory in order to read the entries.
void STB_MEMInitialiseRAM(void)
Initialises the heap.
U8BIT STB_MEMSysRAMUsed(void)
Returns the amount of available system memory consumed.
void * STB_MEMGetSysRAM(U32BIT bytes)
Allocates a new block of memory for system use.
U32BIT STB_MEMGetNVMOffset(void)
Returns any offset required in NVM to avoid private data.
U8BIT STB_MEMGetNVMAlign(void)
Returns the word alignment size of the NVM device.
void * STB_MEMGetAppRAM(U32BIT bytes)
Allocates a new block of memory for application use.
void STB_MEMFreeSysRAM(void *block)
Releases a previously allocated block of system memory.
U32BIT STB_NVMWriteFile(void *file, U8BIT *data, U32BIT size)
Writes data to an open file.
U32BIT STB_MEMGetNVMSize(void)
Returns the size (capacity) of the NVM.
const void * STB_MEMReadSecureConstant(U8BIT key, U32BIT *len)
Read constant defined by the given key from secure NVM. The data must not be released (it is managed ...
System Wide Global Technical Data Type Definitions.
BOOLEAN STB_NVMReadDirectory(void *dir, U8BIT *filename, U16BIT filename_len, E_STB_DIR_ENTRY_TYPE *entry_type)
Reads the next entry from the directory, returning the name of the entry and the type of the entry...
U32BIT STB_NVMReadFile(void *file, U8BIT *data, U32BIT size)
Reads data from an open file.
void * STB_MEMResizeSysRAM(void *ptr, U32BIT new_num_bytes)
Changes the size of the given block of memory ensuring data contained within the original memory bloc...
BOOLEAN STB_NVMMoveFile(U8BIT *oldname, U8BIT *newname)
Move file or directory (and it's children).
BOOLEAN STB_NVMFileSize(U8BIT *filename, U32BIT *filesize)
Returns the size in KB of the given file.
Function prototypes for disk functions.
BOOLEAN STB_MEMReadNVM(U32BIT addr, U32BIT bytes, U8BIT *dst_addr)
Read data from the NVM.
void STB_MEMFreeAppRAM(void *block)
Releases a previously allocated block of system memory.
void STB_NVMCloseDirectory(void *dir)
Closes the directory for reading.