|
|
@@ -8,15 +8,26 @@
|
|
|
#ifdef _MAILBOX
|
|
|
#define ACCESS_DEBUG(fmt, args...) //printf(fmt, ##args)
|
|
|
#ifdef CPU_ACCESS_MODULE_SUPPORT
|
|
|
-static int SendAccessModuleRsp(AccessModuleType type, uint32_t result, AccessModuleRespondMsgStatus msg_status)
|
|
|
+static int SendAccessModuleRsp(AccessModuleType type, uint32_t result, AccessModuleRespondMsgStatus msg_status, void *rsp_data)
|
|
|
{
|
|
|
- AccessModuleHeader header = {0};
|
|
|
+ u8 buf[26] = {0};
|
|
|
+
|
|
|
+ AccessModuleHeader *header = (AccessModuleHeader *)buf;
|
|
|
+
|
|
|
+ header->result = result;
|
|
|
+ header->type = type;
|
|
|
+ header->len = sizeof(AccessModuleHeader);
|
|
|
+ header->msg_status = msg_status;
|
|
|
+ if (rsp_data) {
|
|
|
+ if (type == AMT_RTC) {
|
|
|
+ header->len += sizeof(AccessRtcMsg);
|
|
|
+ memcpy((void *)(buf + sizeof(AccessModuleHeader)), rsp_data, sizeof(sizeof(AccessRtcMsg)));
|
|
|
+ } else {
|
|
|
+ printf("%s, para error.\n", __func__);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- header.result = result;
|
|
|
- header.type = type;
|
|
|
- header.len = sizeof(AccessModuleHeader);
|
|
|
- header.msg_status = msg_status;
|
|
|
- if (mailbox_msg_send(MB_MSG_T_CPU_MODULE_ACCESS, (const uint8_t *)&header, header.len, 50)) {
|
|
|
+ if (mailbox_msg_send(MB_MSG_T_CPU_MODULE_ACCESS, (const uint8_t *)header, header->len, 50)) {
|
|
|
printf("%s, mailbox send frame fail.\n", __func__);
|
|
|
return -1;
|
|
|
}
|
|
|
@@ -26,26 +37,31 @@ static int SendAccessModuleRsp(AccessModuleType type, uint32_t result, AccessMod
|
|
|
#ifdef ACCESS_RTC_SUPPORT
|
|
|
static void CpuAccessRtc(AccessRtcMsg *rx_msg)
|
|
|
{
|
|
|
- SystemTime_t *tm = (SystemTime_t *)rx_msg->mem_addr;
|
|
|
-
|
|
|
- if (rx_msg->mem_size != sizeof(SystemTime_t)) {
|
|
|
- printf("mailbox receive access rtc size error.\n");
|
|
|
- SendAccessModuleRsp(AMT_RTC, 0, AMRMS_PARA_ERROR);
|
|
|
- }
|
|
|
+ AccessRtcMsg tx_msg= {0};
|
|
|
|
|
|
if (rx_msg->access_type == ART_GET_TIME) {
|
|
|
- iGetLocalTime(tm);
|
|
|
- ACCESS_DEBUG("Time: %d-%.2d-%.2d %.2d:%.2d:%.2d.\n", tm->tm_year, tm->tm_mon,
|
|
|
- tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
|
|
|
+ tx_msg.rtc_cnt_h = CpuGetLocalTime();
|
|
|
+#if 0
|
|
|
+ SystemTime_t tm;
|
|
|
+ rtc_time_to_tm(tx_msg.rtc_cnt_h, &tm);
|
|
|
+ tm.tm_year += 1900;
|
|
|
+ tm.tm_mon += 1;
|
|
|
+ ACCESS_DEBUG("Time: %d-%.2d-%.2d %.2d:%.2d:%.2d.\n", tm.tm_year, tm.tm_mon,
|
|
|
+ tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
|
|
|
+
|
|
|
+ iGetLocalTime(&tm);
|
|
|
+ ACCESS_DEBUG("Time: %d-%.2d-%.2d %.2d:%.2d:%.2d.\n", tm.tm_year, tm.tm_mon,
|
|
|
+ tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
|
|
|
+#endif
|
|
|
} else if (rx_msg->access_type == ART_SET_TIME) {
|
|
|
- vSetLocalTime(tm);
|
|
|
+ CpuSetLocalTime(rx_msg->rtc_cnt_h);
|
|
|
} else {
|
|
|
printf("%s, mailbox receive access rtc type error.\n", __func__);
|
|
|
- SendAccessModuleRsp(AMT_RTC, 0, AMRMS_PARA_ERROR);
|
|
|
+ SendAccessModuleRsp(AMT_RTC, 0, AMRMS_PARA_ERROR, NULL);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- SendAccessModuleRsp(AMT_RTC, 0, AMRMS_NO_ERROR);
|
|
|
+ SendAccessModuleRsp(AMT_RTC, 0, AMRMS_NO_ERROR, &tx_msg);
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
@@ -66,7 +82,7 @@ void DetectCpuAccessModule(void)
|
|
|
header = (AccessModuleHeader *)msg.data;
|
|
|
if (header->type == AMT_RTC) {
|
|
|
msg_len = sizeof(AccessRtcMsg);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
printf("%s, unknown module type, access not supportd.\n", __func__);
|
|
|
//unknown module type, Unable to reply.
|
|
|
return;
|
|
|
@@ -74,7 +90,7 @@ void DetectCpuAccessModule(void)
|
|
|
|
|
|
if (msg.dl != header_size + msg_len) {
|
|
|
printf("%s, mailbox rev msg length err.\n", __func__);
|
|
|
- SendAccessModuleRsp(header->type, 0, AMRMS_LEN_ERROR);
|
|
|
+ SendAccessModuleRsp(header->type, 0, AMRMS_LEN_ERROR, NULL);
|
|
|
return;
|
|
|
}
|
|
|
|