-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/emulator_actual_emb' into develop
- Loading branch information
Showing
61 changed files
with
10,659 additions
and
2,984 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
gcc sa-aes-128.c hal/win-lnx-common/sa-commlayer.c sa-eax-128.c hal/win-lnx-common/sa-eeprom.c hal/win-lnx-common/sa-hal-time-provider.c saccp_protocol.c sagdp_protocol.c saoudp_protocol.c sasp_protocol.c sa_client_comm_stack.c test-counters.c test-generator.c zepto-mem-mngmt.c -D USED_AS_MASTER -D USED_AS_MASTER_COMMSTACK -o ../cs.bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
gcc hal/win-lnx-common/sa-commlayer.c sa_client_central_unit.c sa_test_control_prog.c test-counters.c test-generator.c zepto-mem-mngmt.c -D USED_AS_MASTER -D USED_AS_MASTER_CORE -o ../cu.bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
gcc sa-aes-128.c hal/win-lnx-common/sa-commlayer.c sa-eax-128.c hal/win-lnx-common/sa-eeprom.c hal/win-lnx-common/sa-hal-time-provider.c saccp_protocol.c sagdp_protocol.c saoudp_protocol.c sasp_protocol.c sa_server.c sa_test_plugins.c test-counters.c test-generator.c yoctovm_protocol.c zepto-mem-mngmt.c -o ../slv.bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/******************************************************************************* | ||
Copyright (C) 2015 OLogN Technologies AG | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License version 2 as | ||
published by the Free Software Foundation. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License along | ||
with this program; if not, write to the Free Software Foundation, Inc., | ||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*******************************************************************************/ | ||
|
||
#if !defined __HAL_EEPROM_H__ | ||
#define __HAL_EEPROM_H__ | ||
|
||
#include "../sa-common.h" | ||
|
||
|
||
// calls | ||
bool hal_init_eeprom_access(); | ||
bool hal_eeprom_write( const uint8_t* data, uint16_t size, uint16_t address ); | ||
bool hal_eeprom_read( uint8_t* data, uint16_t size, uint16_t address); | ||
void hal_eeprom_flush(); | ||
|
||
#endif // __HAL_EEPROM_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/******************************************************************************* | ||
Copyright (C) 2015 OLogN Technologies AG | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License version 2 as | ||
published by the Free Software Foundation. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License along | ||
with this program; if not, write to the Free Software Foundation, Inc., | ||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*******************************************************************************/ | ||
|
||
#if !defined __SA_COMMLAYER_H__ | ||
#define __SA_COMMLAYER_H__ | ||
|
||
#include "../sa-common.h" | ||
#include "zepto-mem-mngmt-hal-spec.h" | ||
#include "../zepto-mem-mngmt.h" | ||
|
||
bool communication_initialize(); | ||
void communication_terminate(); | ||
|
||
|
||
// RET codes | ||
#define COMMLAYER_RET_FAILED 0 | ||
#define COMMLAYER_RET_OK 1 | ||
#define COMMLAYER_RET_PENDING 2 | ||
|
||
#define COMMLAYER_RET_FROM_CENTRAL_UNIT 10 | ||
#define COMMLAYER_RET_FROM_DEV 11 | ||
#define COMMLAYER_RET_TIMEOUT 12 | ||
|
||
#define COMMLAYER_RET_FROM_COMMM_STACK 10 | ||
|
||
|
||
|
||
uint8_t sendMessage( MEMORY_HANDLE mem_h ); | ||
|
||
//uint8_t wait_for_communication_event( MEMORY_HANDLE mem_h, uint16_t timeout ); | ||
//uint8_t wait_for_communication_event( uint16_t timeout ); | ||
#ifdef USED_AS_MASTER | ||
#ifdef USED_AS_MASTER_COMMSTACK | ||
uint8_t send_to_central_unit( MEMORY_HANDLE mem_h ); | ||
#elif defined USED_AS_MASTER_CORE | ||
uint8_t send_to_commm_stack( MEMORY_HANDLE mem_h ); | ||
#else | ||
#error unknown configuration | ||
#endif | ||
#endif | ||
|
||
|
||
|
||
#endif // __SA_COMMLAYER_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/******************************************************************************* | ||
Copyright (C) 2015 OLogN Technologies AG | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License version 2 as | ||
published by the Free Software Foundation. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License along | ||
with this program; if not, write to the Free Software Foundation, Inc., | ||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*******************************************************************************/ | ||
|
||
#if !defined __SA_HAL_TIME_PROVIDER_H__ | ||
#define __SA_HAL_TIME_PROVIDER_H__ | ||
|
||
#include "../sa-common.h" | ||
#include <hal-time-convertions.h> | ||
|
||
typedef struct _sa_time_struct | ||
{ | ||
uint16_t low_t; | ||
uint16_t high_t; | ||
} sa_time_struct; | ||
// NOTE: the struct above is not to be used directly | ||
// use typedef below instead | ||
typedef sa_time_struct sa_time_val; | ||
|
||
#define TIME_MILLISECONDS16_TO_TIMEVAL( mslow, timeval ) HAL_TIME_MILLISECONDS16_TO_TIMEVAL( mslow, timeval ) | ||
#define TIME_MILLISECONDS32_TO_TIMEVAL( mslow, mshigh, timeval ) HAL_TIME_MILLISECONDS32_TO_TIMEVAL( mslow, mshigh, timeval ) | ||
|
||
void sa_get_time( sa_time_val* t ); // PLATFORM-SPECIFIC IMPLEMENTATION | ||
|
||
|
||
|
||
// operations (to be added upon necessity) | ||
|
||
INLINE void sa_hal_time_val_copy_from( sa_time_val* t1, const sa_time_val* t2 ) | ||
{ | ||
t1->high_t = t2->high_t; | ||
t1->low_t = t2->low_t; | ||
} | ||
|
||
INLINE bool sa_hal_time_val_is_less( sa_time_val* t1, sa_time_val* t2 ) | ||
{ | ||
if ( t1->high_t < t2->high_t ) return true; | ||
if ( t1->high_t > t2->high_t ) return false; | ||
return t1->low_t < t2->low_t; | ||
} | ||
|
||
#define SA_TIME_LOAD_TICKS_FOR_1_SEC( x ) {(x).low_t = 1000; (x).high_t = 0;} | ||
#define SA_TIME_INCREMENT_BY_TICKS( x, y ) {(x).low_t += (y).low_t; (x).high_t += (y).high_t; (x).high_t += (x).low_t < (y).low_t ? 1 : 0;} | ||
#define SA_TIME_SUBTRACT_TICKS_OR_ZERO( x, y ) {if ( sa_hal_time_val_is_less( &(x), (y) ) ) {(x).low_t = 0; (x).high_t = 0;} else {(x).low_t -= (y).low_t; (x).high_t -= (y).high_t; (x).high_t -= (x).low_t < (y).low_t ? 1 : 0;} } | ||
#define SA_TIME_MUL_TICKS_BY_2( x ) {uint16_t tmp = ((x).low_t) >> 15; (x).low_t <<= 1; (x).high_t = ((x).high_t << 1) | tmp;} | ||
#define SA_TIME_MUL_TICKS_BY_1_AND_A_HALF( x ) {uint16_t lo = (x).low_t, hi = (x).high_t; uint16_t tmp = ((x).high_t) & 1; (x).low_t >>= 15; (x).low_t |= tmp << 15; (x).high_t = ((x).high_t << 1) | tmp; (x).low_t += lo; (x).high_t += hi; (x).high_t += (x).low_t < lo ? 1 : 0;} | ||
|
||
#endif // __SA_HAL_TIME_PROVIDER_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/******************************************************************************* | ||
Copyright (C) 2015 OLogN Technologies AG | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License version 2 as | ||
published by the Free Software Foundation. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License along | ||
with this program; if not, write to the Free Software Foundation, Inc., | ||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*******************************************************************************/ | ||
|
||
#include "../hal-eeprom.h" | ||
#include <sys/stat.h> | ||
#include <fcntl.h> | ||
#include <stdio.h> | ||
#ifdef _MSC_VER | ||
#include <windows.h> | ||
#include <io.h> | ||
#endif | ||
|
||
|
||
// Interface is implemented based on file IO | ||
// File has a standard name | ||
|
||
//FILE* f = NULL; | ||
int efile = -1; | ||
#ifdef _MSC_VER | ||
HANDLE hfile = INVALID_HANDLE_VALUE; | ||
#endif | ||
|
||
bool hal_init_eeprom_access() | ||
{ | ||
// f = fopen( MASTER_SLAVE_BIT == 1 ? "sa-eeprom-master": "sa-eeprom-slave", "rw+b" ); | ||
efile = open( MASTER_SLAVE_BIT == 1 ? "sa-eeprom-master": "sa-eeprom-slave.dat", O_RDWR | O_CREAT | O_BINARY, S_IWRITE | S_IREAD ); | ||
#ifdef _MSC_VER | ||
hfile = (HANDLE) _get_osfhandle (efile); | ||
if ( hfile == INVALID_HANDLE_VALUE ) | ||
return false; | ||
#endif | ||
return efile != -1; | ||
} | ||
|
||
bool hal_eeprom_write( const uint8_t* data, uint16_t size, uint16_t address ) | ||
{ | ||
int res; | ||
res = lseek( efile, address, SEEK_SET); | ||
if ( res == -1 ) | ||
return false; | ||
res = write( efile, data, size ); | ||
if ( res != size ) | ||
return false; | ||
return true; | ||
} | ||
|
||
bool hal_eeprom_read( uint8_t* data, uint16_t size, uint16_t address) | ||
{ | ||
int res; | ||
res = lseek( efile, address, SEEK_SET); | ||
if ( res == -1 ) | ||
return false; | ||
res = read( efile, data, size ); | ||
if ( res != size ) | ||
return false; | ||
return true; | ||
} | ||
|
||
void hal_eeprom_flush() | ||
{ | ||
#ifdef _MSC_VER | ||
FlushFileBuffers(hfile); | ||
#else | ||
fsync( efile ); | ||
#endif | ||
} | ||
|
||
/* | ||
void eeprom_write( uint8_t id, uint8_t* data, uint8_t size) | ||
{ | ||
char filename[256]; | ||
prepareFileName( filename, id ); | ||
FILE* f = fopen( filename, "wb" ); | ||
assert( f ); | ||
int written = fwrite( data, 1, size, f ); | ||
assert( written == size ); | ||
fclose( f ); | ||
} | ||
void eeprom_read_fixed_size( uint8_t id, uint8_t* data, uint8_t size) | ||
{ | ||
char filename[256]; | ||
prepareFileName( filename, id ); | ||
FILE* f = fopen( filename, "rb" ); | ||
assert( f ); | ||
int retrieved = fread ( data, 1, size, f ); | ||
assert( retrieved == size ); | ||
fclose( f ); | ||
} | ||
uint8_t eeprom_read_size( uint8_t id ) | ||
{ | ||
char filename[256]; | ||
prepareFileName( filename, id ); | ||
FILE* f = fopen( filename, "wb" ); | ||
assert( f ); | ||
fseek ( f, 0, SEEK_END ); | ||
int size = ftell( f ); | ||
fclose( f ); | ||
return size; | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/******************************************************************************* | ||
Copyright (C) 2015 OLogN Technologies AG | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License version 2 as | ||
published by the Free Software Foundation. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License along | ||
with this program; if not, write to the Free Software Foundation, Inc., | ||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*******************************************************************************/ | ||
|
||
#if !defined __HAL_TIME_CONVERTIONS_H__ | ||
#define __HAL_TIME_CONVERTIONS_H__ | ||
|
||
// present implementation assumes that resolution of h/w timer is 1 ms | ||
// macros below must be reimplemented if this is not the case | ||
#define HAL_TIME_MILLISECONDS16_TO_TIMEVAL( mslow, timeval ) {(timeval).low_t = (mslow); (timeval).high_t = 0;} | ||
#define HAL_TIME_MILLISECONDS32_TO_TIMEVAL( mslow, mshigh, timeval ) {(timeval).low_t = (mslow); (timeval).high_t = mshigh;} | ||
|
||
|
||
#endif // __HAL_TIME_CONVERTIONS_H__ |
Oops, something went wrong.