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