@@ -47,20 +47,23 @@ extern "C" {
4747 * The structure contains configuration data.
4848 */
4949struct pbuf_cfg {
50- volatile uint32_t * rd_idx_loc ; /* Address of the variable holding
51- * index value of the first valid byte
52- * in data[].
53- */
54- volatile uint32_t * wr_idx_loc ; /* Address of the variable holding
55- * index value of the first free byte
56- * in data[].
57- */
58- uint32_t dcache_alignment ; /* CPU data cache line size in bytes.
59- * Used for validation - TODO: To be
60- * replaced by flags.
61- */
62- uint32_t len ; /* Length of data[] in bytes. */
63- uint8_t * data_loc ; /* Location of the data[]. */
50+ volatile uint32_t * rd_idx_loc ; /* Address of the variable holding
51+ * index value of the first valid byte
52+ * in data[].
53+ */
54+ volatile uint32_t * handshake_loc ;/* Address of the variable holding
55+ * handshake information.
56+ */
57+ volatile uint32_t * wr_idx_loc ; /* Address of the variable holding
58+ * index value of the first free byte
59+ * in data[].
60+ */
61+ uint32_t dcache_alignment ; /* CPU data cache line size in bytes.
62+ * Used for validation - TODO: To be
63+ * replaced by flags.
64+ */
65+ uint32_t len ; /* Length of data[] in bytes. */
66+ uint8_t * data_loc ; /* Location of the data[]. */
6467};
6568
6669/**
@@ -112,14 +115,16 @@ struct pbuf {
112115 * @param size Size of the memory.
113116 * @param dcache_align Data cache alignment.
114117 */
115- #define PBUF_CFG_INIT (mem_addr , size , dcache_align ) \
118+ #define PBUF_CFG_INIT (mem_addr , size , dcache_align , use_handshake ) \
116119{ \
117120 .rd_idx_loc = (uint32_t *)(mem_addr), \
118- .wr_idx_loc = (uint32_t *)((uint8_t *)(mem_addr) + \
119- MAX(dcache_align, _PBUF_IDX_SIZE)), \
121+ .handshake_loc = use_handshake ? (uint32_t *)((uint8_t *)(mem_addr) + \
122+ _PBUF_IDX_SIZE) : NULL, \
123+ .wr_idx_loc = (uint32_t *)((uint8_t *)(mem_addr) + MAX(dcache_align, \
124+ (use_handshake ? 2 : 1) * _PBUF_IDX_SIZE)), \
120125 .data_loc = (uint8_t *)((uint8_t *)(mem_addr) + \
121- MAX(dcache_align, _PBUF_IDX_SIZE) + _PBUF_IDX_SIZE), \
122- .len = (uint32_t)((uint32_t)(size) - MAX(dcache_align, _PBUF_IDX_SIZE) - \
126+ MAX(dcache_align, (use_handshake ? 2 : 1) * _PBUF_IDX_SIZE) + _PBUF_IDX_SIZE), \
127+ .len = (uint32_t)((uint32_t)(size) - MAX(dcache_align, (use_handshake ? 2 : 1) * _PBUF_IDX_SIZE) - \
123128 _PBUF_IDX_SIZE), \
124129 .dcache_alignment = (dcache_align), \
125130}
@@ -142,7 +147,7 @@ struct pbuf {
142147 * @param size Size of the memory.
143148 * @param dcache_align Data cache line size.
144149 */
145- #define PBUF_DEFINE (name , mem_addr , size , dcache_align ) \
150+ #define PBUF_DEFINE (name , mem_addr , size , dcache_align , use_handshake , compatibility ) \
146151 BUILD_ASSERT(dcache_align >= 0, \
147152 "Cache line size must be non negative."); \
148153 BUILD_ASSERT((size) > 0 && IS_PTR_ALIGNED_BYTES(size, _PBUF_IDX_SIZE), \
@@ -151,8 +156,10 @@ struct pbuf {
151156 "Misaligned memory."); \
152157 BUILD_ASSERT(size >= (MAX(dcache_align, _PBUF_IDX_SIZE) + _PBUF_IDX_SIZE + \
153158 _PBUF_MIN_DATA_LEN), "Insufficient size."); \
159+ BUILD_ASSERT(!(compatibility) || (dcache_align) >= 8, \
160+ "Data cache alignment must be at least 8 if compatibility is enabled.");\
154161 static PBUF_MAYBE_CONST struct pbuf_cfg cfg_##name = \
155- PBUF_CFG_INIT(mem_addr, size, dcache_align); \
162+ PBUF_CFG_INIT(mem_addr, size, dcache_align, use_handshake); \
156163 static struct pbuf name = { \
157164 .cfg = &cfg_##name, \
158165 }
@@ -223,6 +230,9 @@ int pbuf_write(struct pbuf *pb, const char *buf, uint16_t len);
223230 */
224231int pbuf_read (struct pbuf * pb , char * buf , uint16_t len );
225232
233+ uint32_t pbuf_handshake_read (struct pbuf * pb );
234+ void pbuf_handshake_write (struct pbuf * pb , uint32_t value );
235+
226236/**
227237 * @}
228238 */
0 commit comments