51 lines
1.9 KiB
C
51 lines
1.9 KiB
C
/****************************************************************************
|
|
|
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
|
|
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
|
be copied by any method or incorporated into another program without
|
|
the express written consent of Aerospace C.Power. This Information or any portion
|
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
|
liability for its use in any way and conveys no license or title under
|
|
any patent or copyright and makes no representation or warranty that this
|
|
Information is free from patent or copyright infringement.
|
|
|
|
****************************************************************************/
|
|
#include "mac_key.h"
|
|
#include "mac_sys_reg.h"
|
|
#include "hw_reg_api.h"
|
|
/* logic key related function placed here */
|
|
|
|
/* key init function
|
|
* return 0 if successul, else failed.
|
|
*/
|
|
uint32_t mac_key_set(mac_key_entry *key_t, uint32_t key_value0,\
|
|
uint32_t key_value1, uint32_t key_value2, uint32_t key_value3)
|
|
{
|
|
IOT_ASSERT(key_t);
|
|
key_t->key.k[0] = key_value0;
|
|
key_t->key.k[1] = key_value1;
|
|
key_t->key.k[2] = key_value2;
|
|
key_t->key.k[3] = key_value3;
|
|
return 0;
|
|
}
|
|
|
|
/* key table init function
|
|
* return 0 if successul, else failed.
|
|
*/
|
|
uint32_t mac_key_tbl_init(mac_key_table_t *key_tbl, uint32_t key_num)
|
|
{
|
|
IOT_ASSERT(key_tbl && (key_num <= MAX_KEY_ENTRY_NUM));
|
|
key_tbl->key_allocated = key_num;
|
|
mac_key_entry *key_array = \
|
|
(mac_key_entry *)os_mem_malloc(PLC_MAC_KEY_MID, \
|
|
key_num * sizeof(mac_key_entry));
|
|
IOT_ASSERT(key_array);
|
|
for(uint8_t key_idx = 0; key_idx < key_num; key_idx++)
|
|
{
|
|
mac_key_set(key_array + key_idx, 0, 0, 0, 0);
|
|
}
|
|
key_tbl->key_array = (mac_key_entry *)key_array;
|
|
return 0;
|
|
} |