1 // SPDX-License-Identifier: BSD-3-Clause 2 // 3 // Copyright(c) 2019 Intel Corporation. All rights reserved. 4 // 5 // Author: Marcin Rajwa <marcin.rajwa@linux.intel.com> 6 7 #include <sof/debug/gdb/ringbuffer.h> 8 #include <sof/lib/mailbox.h> 9 10 #define BUFFER_OFFSET 0x120 11 12 volatile struct ring * const rx = (void *)mailbox_get_debug_base(); 13 volatile struct ring * const tx = (void *)(mailbox_get_debug_base() + 14 BUFFER_OFFSET); 15 volatile struct ring * const debug = (void *)(mailbox_get_debug_base() + 16 (2 * BUFFER_OFFSET)); 17 init_buffers(void)18void init_buffers(void) 19 { 20 rx->head = rx->tail = 0; 21 tx->head = tx->tail = 0; 22 debug->head = debug->tail = 0; 23 } 24 put_debug_char(unsigned char c)25void put_debug_char(unsigned char c) 26 { 27 while (!ring_have_space(tx)) 28 ; 29 30 tx->data[tx->head] = c; 31 tx->head = ring_next_head(tx); 32 } 33 get_debug_char(void)34unsigned char get_debug_char(void) 35 { 36 unsigned char v; 37 38 while (!ring_have_data(rx)) 39 ; 40 41 v = rx->data[rx->tail]; 42 rx->tail = ring_next_tail(rx); 43 44 return v; 45 } 46 put_exception_char(char c)47void put_exception_char(char c) 48 { 49 debug->data[debug->head] = c; 50 debug->head = ring_next_head(debug); 51 } 52