1 /* 2 * Copyright (c) 2019 - 2023 Intel Corporation 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef MIPI_SYST_PLATFORM_INCLUDED 8 #define MIPI_SYST_PLATFORM_INCLUDED 9 10 #include <zephyr/logging/log_output.h> 11 12 #ifdef __cplusplus 13 extern "C" { 14 #endif 15 16 #if defined(CONFIG_LOG_MIPI_SYST_DISABLE_TIMESTAMP) 17 #undef MIPI_SYST_PCFG_ENABLE_TIMESTAMP 18 #endif 19 20 #define MIPI_SYST_PCFG_PRINTF_ARGBUF_SIZE CONFIG_LOG_MIPI_SYST_ARGS_BUFFER_SIZE 21 22 #if defined(CONFIG_MIPI_SYST_STP) 23 /* 24 * Structure generating STP protocol data 25 */ 26 struct stp_writer_data { 27 mipi_syst_u8 byteDone; 28 mipi_syst_u8 current; 29 mipi_syst_u16 master; 30 mipi_syst_u16 channel; 31 mipi_syst_u64 recordCount; 32 mipi_syst_u64 timestamp; 33 }; 34 #endif 35 36 #if defined(MIPI_SYST_PCFG_ENABLE_PLATFORM_STATE_DATA) 37 /* 38 * Platform specific SyS-T global state extension 39 */ 40 struct mipi_syst_platform_state { 41 #if defined(CONFIG_MIPI_SYST_STP) 42 struct stp_writer_data *stpWriter; 43 #endif 44 45 void (*write_d8)(struct mipi_syst_handle *systh, mipi_syst_u8 v); 46 void (*write_d16)(struct mipi_syst_handle *systh, mipi_syst_u16 v); 47 void (*write_d32)(struct mipi_syst_handle *systh, mipi_syst_u32 v); 48 #if defined(MIPI_SYST_PCFG_ENABLE_64BIT_IO) 49 void (*write_d64)(struct mipi_syst_handle *systh, mipi_syst_u64 v); 50 #endif 51 void (*write_d32ts)(struct mipi_syst_handle *systh, mipi_syst_u32 v); 52 void (*write_d32mts)(struct mipi_syst_handle *systh, mipi_syst_u32 v); 53 void (*write_d64mts)(struct mipi_syst_handle *systh, mipi_syst_u64 v); 54 void (*write_flag)(struct mipi_syst_handle *systh); 55 }; 56 57 /* 58 * Platform specific SyS-T handle state extension 59 */ 60 struct mipi_syst_platform_handle { 61 mipi_syst_u32 flag; 62 #if defined(CONFIG_MIPI_SYST_STP) 63 mipi_syst_u32 master; 64 mipi_syst_u32 channel; 65 #endif 66 struct log_output *log_output; 67 }; 68 69 /* 70 * IO output routine mapping 71 * Call the function pointers in the global state 72 */ 73 #define MIPI_SYST_OUTPUT_D8(syst_handle, data) \ 74 ((syst_handle)->systh_header-> \ 75 systh_platform.write_d8((syst_handle), (data))) 76 #define MIPI_SYST_OUTPUT_D16(syst_handle, data) \ 77 ((syst_handle)->systh_header-> \ 78 systh_platform.write_d16((syst_handle), (data))) 79 #define MIPI_SYST_OUTPUT_D32(syst_handle, data) \ 80 ((syst_handle)->systh_header-> \ 81 systh_platform.write_d32((syst_handle), (data))) 82 #if defined(MIPI_SYST_PCFG_ENABLE_64BIT_IO) 83 #define MIPI_SYST_OUTPUT_D64(syst_handle, data) \ 84 ((syst_handle)->systh_header-> \ 85 systh_platform.write_d64((syst_handle), (data))) 86 #endif 87 #define MIPI_SYST_OUTPUT_D32TS(syst_handle, data) \ 88 ((syst_handle)->systh_header-> \ 89 systh_platform.write_d32ts((syst_handle), (data))) 90 #define MIPI_SYST_OUTPUT_D32MTS(syst_handle, data) \ 91 ((syst_handle)->systh_header-> \ 92 systh_platform.write_d32mts((syst_handle), (data))) 93 #define MIPI_SYST_OUTPUT_D64MTS(syst_handle, data) \ 94 ((syst_handle)->systh_header-> \ 95 systh_platform.write_d64mts((syst_handle), (data))) 96 #define MIPI_SYST_OUTPUT_FLAG(syst_handle) \ 97 ((syst_handle)->systh_header-> \ 98 systh_platform.write_flag((syst_handle))) 99 100 #else 101 102 #define MIPI_SYST_OUTPUT_D8(syst_handle, data) 103 #define MIPI_SYST_OUTPUT_D16(syst_handle, data) 104 #define MIPI_SYST_OUTPUT_D32(syst_handle, data) 105 #if defined(MIPI_SYST_PCFG_ENABLE_64BIT_IO) 106 #define MIPI_SYST_OUTPUT_D64(syst_handle, data) 107 #endif 108 #define MIPI_SYST_OUTPUT_D32TS(syst_handle, data) 109 #define MIPI_SYST_OUTPUT_FLAG(syst_handle) 110 111 #endif 112 113 #if defined(MIPI_SYST_PCFG_ENABLE_HEAP_MEMORY) 114 #define MIPI_SYST_HEAP_MALLOC(s) 115 #define MIPI_SYST_HEAP_FREE(p) 116 #endif 117 118 #if defined(MIPI_SYST_PCFG_ENABLE_TIMESTAMP) 119 #define MIPI_SYST_PLATFORM_CLOCK() mipi_syst_get_epoch() 120 #define MIPI_SYST_PLATFORM_FREQ() CONFIG_SYS_CLOCK_TICKS_PER_SEC 121 122 mipi_syst_u64 mipi_syst_get_epoch(void); 123 #endif 124 125 #ifdef __cplusplus 126 } 127 #endif 128 129 #endif 130