Files
2022-02-17 11:37:06 +01:00

168 lines
5.2 KiB
C

/*----------------------------------------------------------------------------*/
/* Copyright(C) NXP N.V. 2016, 2017 */
/* */
/* All rights are reserved. Reproduction in whole or in part is prohibited */
/* without the prior written consent of the copy-right owner. */
/* This source code and any compilation or derivative thereof is the sole */
/* property of NXP N.V. and is provided pursuant to a Software License */
/* Agreement. This code is the proprietary information of NXP N.V. and */
/* is confidential in nature. Its use and dissemination by any party other */
/* than NXP N.V. is strictly limited by the confidential information */
/* provisions of the agreement referenced above. */
/* */
/*----------------------------------------------------------------------------*/
#include <ph_TypeDefs.h>
#ifndef SECUREBOX_MEM_CONFIG_H_
#define SECUREBOX_MEM_CONFIG_H_
//Native lib memory addresses
#define APDU_BUFFER_START 0x3010
#define SB_WORKSPACE_START (SB_INFO_STRUCT_START + SB_INFO_STRUCT_SIZE)
#define SB_TRANSIENT_STATE_START 0x100
#define SB_PERSISTENT_STATE_START 0x8000
#define SB_INFO_STRUCT_START 0x4000
#define SB_INFO_STRUCT_SIZE 0x30
/* Open/Close resource masks */
#define NATIVELIB_OPEN_CRC_MASK 0x0001
#define NATIVELIB_OPEN_RNG_MASK 0x0002
#define NATIVELIB_OPEN_TIMER_MASK 0x0004
#define NATIVELIB_OPEN_FAME_MASK 0x0008
#define NATIVELIB_OPEN_CRYPTO_MASK 0x0010
/******************************************************************************
* typedefs
******************************************************************************/
typedef uint8_t _DM32 * puint8_uni_t;
typedef uint8_t const _DM32 * pcuint8_uni_t;
typedef uint8_t * puint8_med_t;
/*===========================================================================*
* Defines:
*===========================================================================*/
#define PH_MAX_NUM_PERS_ARRAY 0x04
/*===========================================================================*
* Structures:
*===========================================================================*/
/* Definition of persistent array parameter */
typedef struct
{
puint8_uni_t slPersistentArrayAddress;
uint16_t siPersistentArraySize;
} phNativeLibPersArrayParameter_t;
/* Definition Securebox parameter area */
typedef struct
{
uint16_t siApduBufferSize;
uint16_t siTransientStateSize;
uint32_t siPersistentStateSize;
phNativeLibPersArrayParameter_t saPersistentArray[PH_MAX_NUM_PERS_ARRAY];
puint8_uni_t siCopyBackAddress;
uint16_t siCopyBackSize;
uint8_t scCopyBackAtomic;
uint8_t saRFU[9];
} phNativeLibParameterArea_t;
/******************************************************************************
* SysCalls
******************************************************************************/
/* Base address of SYS call table. */
#define SYS_BASE_ADDR (0x88040)
#define Exception_SYS( \
liExceptionType, \
liExceptionReason \
) \
__builtin_esys((SYS_BASE_ADDR + 1*8)/2, liExceptionType, liExceptionReason);
#define Exit_OK_SYS( \
riReturnValue \
) \
__builtin_esys((SYS_BASE_ADDR + 2*8)/2, riReturnValue);
#define OpenTransaction_SYS() \
__builtin_esys((SYS_BASE_ADDR + 3*8)/2);
#define GetTransactionDepth_SYS() \
__builtin_esys((SYS_BASE_ADDR + 4*8)/2);
#define CommitTransaction_SYS() \
__builtin_esys((SYS_BASE_ADDR + 5*8)/2);
#define AbortTransaction_SYS() \
__builtin_esys((SYS_BASE_ADDR + 6*8)/2);
#define GetRemainingTransactionCapacity_SYS() \
__builtin_esys((SYS_BASE_ADDR + 7*8)/2);
#define ArrayCopyToPersistentState_SYS( \
pSrc, \
len, \
offset \
) \
__builtin_esys((SYS_BASE_ADDR + 8*8)/2, pSrc, len, offset);
#define ArrayCopyToPersistentStateNonAtomic_SYS( \
pSrc, \
len, \
offset \
) \
__builtin_esys((SYS_BASE_ADDR + 9*8)/2, pSrc, len, offset);
#define ArrayCopyToPersistentStateAndCommit_SYS( \
pSrc, \
len, \
offset \
) \
__builtin_esys((SYS_BASE_ADDR + 10*8)/2, pSrc, len, offset);
#define ArrayFillToPersistentState_SYS( \
val, \
len, \
offset \
) \
__builtin_esys((SYS_BASE_ADDR + 11*8)/2, val, len, offset);
#define ArrayFillToPersistentStateNonAtomic_SYS( \
val, \
len, \
offset \
) \
__builtin_esys((SYS_BASE_ADDR + 12*8)/2, val, len, offset);
#define ArrayFillToPersistentStateAndCommit_SYS( \
val, \
len, \
offset \
) \
__builtin_esys((SYS_BASE_ADDR + 13*8)/2, val, len, offset);
#define OpenResources_SYS( \
wResources \
) \
__builtin_esys((SYS_BASE_ADDR + 25*8)/2, wResources);
#define CloseResources_SYS( \
wResources \
) \
__builtin_esys((SYS_BASE_ADDR + 26*8)/2, wResources);
#define GetResourceStatus_SYS( \
pResources \
) \
__builtin_esys((SYS_BASE_ADDR + 27*8)/2, pResources);
#endif /* SECUREBOX_MEM_CONFIG_H_ */