78 lines
2.6 KiB
C
78 lines
2.6 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.
|
|
|
|
****************************************************************************/
|
|
/* os shim includes */
|
|
#include "os_types.h"
|
|
|
|
#include "iot_diag.h"
|
|
#include "iot_io_api.h"
|
|
|
|
#include "iot_cli_host_interface.h"
|
|
#include "iot_cli_tx_rx.h"
|
|
#include "iot_cli_ram_operation.h"
|
|
|
|
void cli_read_ram(uint8_t *buffer, uint32_t bufferlen, uint8_t *src_mac)
|
|
{
|
|
cli_read_ram_info *read_info = NULL;
|
|
iot_pkt_t *ram_pkt = NULL;
|
|
cli_ram_info *ram_info = NULL;
|
|
|
|
if ((!buffer) || (bufferlen < sizeof(cli_read_ram_info))) {
|
|
return;
|
|
}
|
|
|
|
read_info = (cli_read_ram_info *)buffer;
|
|
iot_printf("cli read ram %x %lu\n", read_info->addr, read_info->len);
|
|
if (read_info->len > CLI_RAM_OPERATION_MAX_SIZE) {
|
|
read_info->len = CLI_RAM_OPERATION_MAX_SIZE;
|
|
}
|
|
|
|
ram_pkt = iot_pkt_alloc(sizeof(cli_ram_info), IOT_CLI_MID);
|
|
if (!ram_pkt) {
|
|
iot_printf("cli read ram, ram_pkt NULL\n");
|
|
return;
|
|
}
|
|
|
|
ram_info = (cli_ram_info *)iot_pkt_data(ram_pkt);
|
|
ram_info->addr = read_info->addr;
|
|
ram_info->len = read_info->len;
|
|
#if (HW_PLATFORM != HW_PLATFORM_SIMU)
|
|
iot_mem_read(ram_info->ram, ram_info->addr, ram_info->len);
|
|
#endif
|
|
iot_pkt_put(ram_pkt, sizeof(cli_ram_info));
|
|
|
|
iot_cli_send_to_host(CLI_MSGID_RAM_INFO,
|
|
(uint8_t *)ram_info, sizeof(cli_ram_info), src_mac);
|
|
|
|
iot_pkt_free(ram_pkt);
|
|
}
|
|
|
|
void cli_set_ram(uint8_t *buffer, uint32_t bufferlen, uint8_t *src_mac)
|
|
{
|
|
cli_ram_info *ram_info = NULL;
|
|
cli_set_sam_ack ack;
|
|
|
|
if ((!buffer) || (bufferlen < sizeof(cli_ram_info))) {
|
|
return;
|
|
}
|
|
|
|
ram_info = (cli_ram_info *)buffer;
|
|
iot_printf("cli set ram %x %lu\n", ram_info->addr, ram_info->len);
|
|
#if (HW_PLATFORM != HW_PLATFORM_SIMU)
|
|
iot_mem_write(ram_info->ram, ram_info->addr, ram_info->len);
|
|
#endif
|
|
|
|
iot_cli_send_to_host(CLI_MSGID_SET_RAM_ACK,
|
|
(uint8_t *)&ack, sizeof(cli_set_sam_ack), src_mac);
|
|
} |