DVBCore
1.0
Open source DVB engine
|
00001 /******************************************************************************* 00002 * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org) 00003 * Copyright © 2004 Ocean Blue Software Ltd 00004 * 00005 * This file is part of a DTVKit Software Component 00006 * You are permitted to copy, modify or distribute this file subject to the terms 00007 * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org 00008 * 00009 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 00010 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 00011 * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 00012 * 00013 * If you or your organisation is not a member of DTVKit then you have access 00014 * to this source code outside of the terms of the licence agreement 00015 * and you are expected to delete this and any associated files immediately. 00016 * Further information on DTVKit, membership and terms can be found at www.dtvkit.org 00017 *******************************************************************************/ 00024 // pre-processor mechanism so multiple inclusions don't cause compilation error 00025 00026 #ifndef _STBHWMEM_H 00027 00028 #define _STBHWMEM_H 00029 00030 //---Constant and macro definitions for public use----------------------------- 00031 // IMPORTANT NOTE: The following definition musts comply with that defined in el_nvram.c of the loader 00032 // source code. The number of NVRAM bytes that are reserved for the loader are defined in the first two 00033 // bytes of NVRAM. The area immediately following those 2 bytes are the Euroloader NVM area itself 00034 #define ELOAD_RESERVED_NVM_OFFSET 0 // offset of NVM reserved for Euroloader 00035 #define ELOAD_RESERVED_NVM_SIZE_WIDTH 2 // width in bytes of variable denoting no. 00036 // of Euroloader NVM bytes 00037 00038 #define ELOAD_NVM_DATA_OFFSET ELOAD_RESERVED_NVM_SIZE_WIDTH // E'loader data starts immed. after size variable 00039 00040 //---Enumerations for public use----------------------------------------------- 00041 00042 /* Key values for data items that can be stored in secure NVM */ 00043 enum 00044 { 00045 SECURE_NVM_DEFAULT_ENCRYPTION_KEY, /* 0 */ 00046 SECURE_NVM_DEFAULT_ENC_INIT_VECTOR, /* 1 */ 00047 SECURE_NVM_CI_PLUS_ROOT_CERT, /* 2 */ 00048 SECURE_NVM_CI_PLUS_BRAND_CERT, /* 3 */ 00049 SECURE_NVM_CI_PLUS_DEVICE_CERT, /* 4 */ 00050 SECURE_NVM_CI_PLUS_DEVICE_KEY, /* 5 */ 00051 SECURE_NVM_CI_PLUS_DH_P, /* 6 */ 00052 SECURE_NVM_CI_PLUS_DH_G, /* 7 */ 00053 SECURE_NVM_CI_PLUS_DH_Q, /* 8 */ 00054 SECURE_NVM_CI_PLUS_PRNG_KEY_K, /* 9 */ 00055 SECURE_NVM_CI_PLUS_PRNG_SEED, /* 10 */ 00056 SECURE_NVM_CI_PLUS_SIV, /* 11 */ 00057 SECURE_NVM_CI_PLUS_SLK, /* 12 */ 00058 SECURE_NVM_CI_PLUS_CLK, /* 13 */ 00059 SECURE_NVM_CI_PLUS_CONTEXTS, /* 14 */ 00060 SECURE_NVM_MHEG5_PRIVATE_KEY, /* 15 */ 00061 SECURE_NVM_MHEG5_PRIVATE_KEY_VERSION, /* 16 */ 00062 SECURE_NVM_SOFTWARE_UPGRADE_PUBLIC_KEY, /* 17 */ 00063 SECURE_NVM_SOFTWARE_UPGRADE_SHARED_KEY /* 18 */ 00064 }; 00065 00066 //---Global type defs for public use------------------------------------------- 00067 00068 //---Global Function prototypes for public use--------------------------------- 00069 00070 #include "stbhwdsk.h" /* for E_STB_DSK_FILE_MODE */ 00071 00075 void STB_MEMInitialiseRAM(void); 00076 00081 void STB_MEMInitialiseNVM(void); 00082 00090 BOOLEAN STB_MEMReadNVM(U32BIT addr, U32BIT bytes, U8BIT *dst_addr); 00091 00099 BOOLEAN STB_MEMWriteNVM(U32BIT addr, U32BIT bytes, U8BIT *src_addr); 00100 00108 void* STB_MEMReadSecureVariable(U8BIT key, U32BIT *len); 00109 00114 void STB_MEMReleaseSecureVariable(void *value); 00115 00123 BOOLEAN STB_MEMWriteSecureVariable(U8BIT key, void *value, U32BIT len); 00124 00132 void* STB_MEMReadSecureConstant(U8BIT key, U32BIT *len); 00133 00138 U32BIT STB_MEMGetNVMSize(void); 00139 00144 U32BIT STB_MEMGetNVMOffset(void); 00145 00150 U8BIT STB_MEMGetNVMAlign(void); 00151 00157 void* STB_MEMGetSysRAM(U32BIT bytes); 00158 00166 void* STB_MEMResizeSysRAM(void *ptr, U32BIT new_num_bytes); 00167 00172 void STB_MEMFreeSysRAM(void *block); 00173 00178 U8BIT STB_MEMSysRAMUsed(void); 00179 00186 void* STB_MEMGetAppRAM(U32BIT bytes); 00187 00195 void* STB_MEMResizeAppRAM(void *ptr, U32BIT new_num_bytes); 00196 00201 void STB_MEMFreeAppRAM(void *block); 00202 00207 U8BIT STB_MEMAppRAMUsed(void); 00208 00209 00210 BOOLEAN STB_MEMConfigMloaderForUpgrade(void *loader_data, U32BIT data_size); 00211 BOOLEAN STB_MEMReadMloaderData(void *buffer, U32BIT size); 00212 BOOLEAN STB_MEMWriteMloaderData(void *buffer, U32BIT size); 00213 00214 /****************************************************************************** 00215 * @brief Returns the size in KB of the given file 00216 * @param filename - name of the file in the nvm 00217 * @param filesize - returned value giving the file size in KB 00218 * @return TRUE if the file exists, FALSE otherwise 00219 ******************************************************************************/ 00220 BOOLEAN STB_NVMFileSize(U8BIT *filename, U32BIT *filesize); 00221 00222 /****************************************************************************** 00223 * @brief Opens an existing file or creates a new one. 00224 * @param name - The filename (including path). When the mode is 00225 * FILE_MODE_OVERWRITE, the directories in the path will be created 00226 * when they don't exist. 00227 * @param mode - The access mode 00228 * @return The file handle 00229 ******************************************************************************/ 00230 void* STB_NVMOpenFile(U8BIT *name, E_STB_DSK_FILE_MODE mode); 00231 00232 /****************************************************************************** 00233 * @brief Flushes and closes an open file 00234 * @param file - The file handle 00235 ******************************************************************************/ 00236 void STB_NVMCloseFile(void *file); 00237 00238 /****************************************************************************** 00239 * @brief Reads data from an open file 00240 * @param[in] file - The file handle 00241 * @param[out] data - The caller's buffer 00242 * @param[in] size - Number of bytes to be read 00243 * @return Number of bytes successfully read 00244 ******************************************************************************/ 00245 U32BIT STB_NVMReadFile(void *file, U8BIT *data, U32BIT size); 00246 00247 /****************************************************************************** 00248 * @brief Writes data to an open file 00249 * @param file - The file handle 00250 * @param data - Pointer to the data to be written 00251 * @param size - Number of bytes to write 00252 * @return Number of bytes successfully written 00253 ******************************************************************************/ 00254 U32BIT STB_NVMWriteFile(void *file, U8BIT *data, U32BIT size); 00255 00256 /****************************************************************************** 00257 * @brief Deletes the file. 00258 * @param filename - pathname of the file to be deleted 00259 * @retval TRUE if successful, FALSE otherwise 00260 ******************************************************************************/ 00261 BOOLEAN STB_NVMDeleteFile(U8BIT *filename); 00262 00263 /****************************************************************************** 00264 * @brief Opens a directory in order to read the entries 00265 * @param dir_name - name of the directory to open 00266 * @return Handle to be used in all other operations, NULL if the open fails 00267 ******************************************************************************/ 00268 void* STB_NVMOpenDirectory(U8BIT *dir_name); 00269 00270 /****************************************************************************** 00271 * @brief Reads the next entry from the directory, returning the name of the 00272 * entry and the type of the entry 00273 * @param dir - handle returned when the directory was opened 00274 * @param filename - array in which the name is returned 00275 * @param filename_len - size of the filename array 00276 * @param entry_type - type of entry 00277 * @return TRUE if and entry is read, FALSE otherwise which could indicate end 00278 * of the directory 00279 ******************************************************************************/ 00280 BOOLEAN STB_NVMReadDirectory(void *dir, U8BIT *filename, U16BIT filename_len, 00281 E_STB_DIR_ENTRY_TYPE *entry_type); 00282 00283 /****************************************************************************** 00284 * @brief Closes the directory for reading 00285 * @param dir - directory handle 00286 ******************************************************************************/ 00287 void STB_NVMCloseDirectory(void *dir); 00288 00289 #endif // _STBHWMEM_H