1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 * Description: log OAM pcm producer interface 15 * Author: 16 * Create: 17 */ 18 #ifndef LOG_OAM_STATUS_H 19 #define LOG_OAM_STATUS_H 20 21 #include "log_oam_logger.h" 22 #include "log_printf.h" 23 24 #define OML_STATUS_ADD_LENGTH (13) 25 #define OM_STATUS_DATA_MAX_SIZE (60) 26 27 #if ((defined BUILD_IN_ROM) || (USE_COMPRESS_LOG_INSTEAD_OF_SDT_LOG == NO)) 28 #ifndef SDT_LOG_BY_UART 29 #define OML_BT_STATE_STORE(msg_id, length, ulparam1, ulparam2, ulparam3, ulparam4) { \ 30 log_oam_status_store(OM_STATUS_STATE, msg_id, OM_BT, length, ulparam1, ulparam2, ulparam3, ulparam4); \ 31 } 32 #define OML_BT_MESSAGE_STORE(msg_id, length, ulparam1, ulparam2, ulparam3, ulparam4) { \ 33 log_oam_status_store(OM_STATUS_MESG, msg_id, OM_BT, length, ulparam1, ulparam2, ulparam3, ulparam4); \ 34 } 35 #define OML_BT_DATA_STORE(msg_id, length, data) { \ 36 log_oml_status_write(OM_STATUS_DATA, msg_id, OM_BT, length, data); \ 37 } 38 #define OML_BT_STRUCT_STORE(prime_id, msg_id, length, data) { \ 39 log_oml_status_write(prime_id, msg_id, OM_BT, length, data); \ 40 } 41 #else 42 #define OML_BT_STATE_STORE(usmsg_id, uslength, ulparam1, ulparam2, ulparam3, ulparam4) { \ 43 oml_status_store(OM_STATUS_STATE, usmsg_id, OM_BT, uslength, ulparam1, ulparam2, ulparam3, ulparam4); \ 44 } 45 #define OML_BT_MESSAGE_STORE(usmsg_id, uslength, ulparam1, ulparam2, ulparam3, ulparam4) { \ 46 oml_status_store(OM_STATUS_MESG, usmsg_id, OM_BT, uslength, ulparam1, ulparam2, ulparam3, ulparam4); \ 47 } 48 #define OML_BT_DATA_STORE(usmsg_id, uslength, puc_data) { \ 49 oml_status_write(OM_STATUS_DATA, usmsg_id, OM_BT, uslength, puc_data); \ 50 } 51 #define OML_BT_STRUCT_STORE(ucprime_id, usmsg_id, uslength, puc_data) { \ 52 oml_status_write(ucprime_id, usmsg_id, OM_BT, uslength, puc_data); \ 53 } 54 #endif 55 #else /* (defined BUILD_IN_ROM) || (USE_COMPRESS_LOG_INSTEAD_OF_SDT_LOG == NO) */ 56 #define OML_BT_STATE_STORE(msg_id, length, ulparam1, ulparam2, ulparam3, ulparam4) \ 57 do { \ 58 compress_printf(msg_id, press_params(BTC_MAGIC_LOG_CODE, LOG_LEVEL_INFO, length), \ 59 ulparam1, ulparam2, ulparam3, ulparam4); \ 60 } while (0) 61 #define OML_BT_MESSAGE_STORE(msg_id, length, ulparam1, ulparam2, ulparam3, ulparam4) \ 62 do { \ 63 compress_printf(msg_id, press_params(BTC_MAGIC_LOG_CODE, LOG_LEVEL_INFO, length), \ 64 ulparam1, ulparam2, ulparam3, ulparam4); \ 65 } while (0) 66 #define OML_BT_DATA_STORE(msg_id, length, data) 67 #define OML_BT_STRUCT_STORE(prime_id, msg_id, length, data) 68 #endif /* (defined BUILD_IN_ROM) || (USE_COMPRESS_LOG_INSTEAD_OF_SDT_LOG == NO) */ 69 70 enum OM_STATUS_PRIME_ID { 71 OM_STATUS_STATE, 72 OM_STATUS_MESG, 73 OM_STATUS_DATA, 74 75 OM_STATUS_BUTT, 76 }; 77 78 typedef struct _om_status_data_stru_t { 79 om_msg_header_stru_t header; 80 uint16_t msg_id; 81 uint16_t data_len; 82 uint8_t data[OM_STATUS_DATA_MAX_SIZE]; 83 uint8_t frame_tail; 84 } om_status_data_stru_t; 85 86 typedef void(*log_oam_status_store_handler)(uint8_t prime_id, uint16_t msg_id, uint16_t mode, 87 uint16_t length, const uint32_t *param); 88 int32_t pf_feature_set(uint32_t feature, uint8_t set); 89 int32_t pf_feature_get(uint32_t feature); 90 void log_oml_status_packet(om_status_data_stru_t *status_entry, uint8_t prime_id, 91 uint16_t msg_id, uint16_t length, const uint8_t *buffer); 92 uint32_t log_oml_status_write(uint8_t prime_id, uint16_t msg_id, uint16_t mode, uint16_t length, const uint8_t *buffer); 93 void log_oam_status_store_init(void); 94 void log_oam_status_store(uint8_t prime_id, uint16_t msg_id, uint16_t mode, uint32_t length, ...); 95 void log_oam_status_store_deal(uint8_t prime_id, uint16_t msg_id, uint16_t mode, uint16_t length, 96 const uint32_t *param); 97 void log_oam_status_store_register_callback(log_oam_status_store_handler callback); 98 void log_oam_status_store_unregister_callback(void); 99 void log_oam_status_store_trigger_callback(uint8_t prime_id, uint16_t msg_id, uint16_t mode, 100 uint16_t length, const uint32_t *param); 101 #endif 102