From 5a1ea7706f24c1bb2c1cfbe46b4dac1bfc8263c0 Mon Sep 17 00:00:00 2001 From: kubodera_yuichi Date: Wed, 6 Jan 2010 00:45:24 +0000 Subject: [PATCH] =?UTF-8?q?=E3=83=A1=E3=83=A2=E3=83=AA=E3=83=AA=E3=83=BC?= =?UTF-8?q?=E3=82=AF=E5=AF=BE=E7=AD=96=E3=80=81HSM=E9=96=A2=E9=80=A3?= =?UTF-8?q?=E3=81=AE=E3=82=A2=E3=83=AD=E3=82=B1=E3=83=BC=E3=82=BF=E3=82=92?= =?UTF-8?q?=E8=87=AA=E5=89=8D=E3=81=A7=E7=94=A8=E6=84=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_eFuse@138 ff987cc8-cf2f-4642-8568-d52cce064691 --- cr_hsm_alloc.c | 13 +++++++++++++ cr_hsm_alloc.h | 2 ++ cr_hsm_code.c | 4 +++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/cr_hsm_alloc.c b/cr_hsm_alloc.c index f4bfd0c..5ded3df 100644 --- a/cr_hsm_alloc.c +++ b/cr_hsm_alloc.c @@ -17,6 +17,10 @@ /* --------------------- */ +static int alloc_counter = 0; + +/* --------------------- */ + const NFast_MallocUpcalls my_hsm_malloc_upcalls = { my_hsm_malloc, my_hsm_realloc, my_hsm_free @@ -27,6 +31,7 @@ const NFast_MallocUpcalls my_hsm_malloc_upcalls = void *my_hsm_malloc( size_t nbytes, struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx ) { + alloc_counter++; return malloc( nbytes ); } @@ -44,6 +49,14 @@ void my_hsm_free( void *ptr, struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx ) { free( ptr ); + alloc_counter--; +} + +/* --------------------- */ + +int my_hsm_get_alloc_counter( void ) +{ + return alloc_counter; } #endif // HSM diff --git a/cr_hsm_alloc.h b/cr_hsm_alloc.h index c7c85a6..74e09f9 100644 --- a/cr_hsm_alloc.h +++ b/cr_hsm_alloc.h @@ -22,6 +22,8 @@ void *my_hsm_realloc( void *ptr, size_t nbytes, void my_hsm_free( void *ptr, struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx ); +int my_hsm_get_alloc_counter( void ); + #ifdef __cplusplus } #endif diff --git a/cr_hsm_code.c b/cr_hsm_code.c index a285923..c8070e3 100644 --- a/cr_hsm_code.c +++ b/cr_hsm_code.c @@ -119,6 +119,7 @@ #ifdef USE_HSM #include "cr_hsm_code.h" +#include "cr_hsm_alloc.h" #include "cr_hsm_bignum.h" #include "cr_generate_id.h" #include "cr_generate_id_private.h" @@ -179,7 +180,8 @@ int hsm_initialize( void ) #endif // init HSM - ret_code = NFastApp_InitEx( &hsmHandle, NULL, NULL ); + ret_code = NFastApp_Init( &hsmHandle, my_hsm_alloc, my_hsm_realloc, my_hsm_free, NULL ); + //ret_code = NFastApp_InitEx( &hsmHandle, NULL, NULL ); if ( ret_code != CR_GENID_SUCCESS ) { SetErrorInfo( __FUNCTION__, __LINE__ );