Data Fields
debug_ring_resources_t Struct Reference

Data Fields

uint64_t epos
 
uint64_t spos
 
uint64_t tag1
 
char buf [DEBUG_RING_SIZE]
 
uint64_t tag2
 

Detailed Description

Debug Ring Resources

Each driver entry needs to allocate some memory for the debug ring, and then cast this structure over the allocated memory to access the bits used by the ring.

Prior to providing this structure to the debug ring, the memory should be cleared, and the len of the buffer should be set to the total length of memory allocated minus the size of debug_ring_resources_t.

int len = PAGE_SIZE * 100;
struct debug_ring_resources_t *drr = valloc(len);
memset(drr, 0, len);
drr->len = len - sizeof(debug_ring_resources_t);
<give to vmm and do stuff>
int ret;
char read_buf[len]
ret = debug_ring_read(drr, read_buf, len);
if(ret < 0)
<report error>

Note there are many different designs for cicular buffers, but all of the designs have to face the same problem. How to detect when the buffer is full vs when it is empty. This design uses two counters the grow forever. The current position in the buffer is then pos % len. If the counters are 64bit, it would take a life time for the counters to overflow.

Definition at line 95 of file debug_ring_interface.h.

Field Documentation

◆ epos

debug_ring_resources_t::epos

the end position in the circular buffer

Definition at line 97 of file debug_ring_interface.h.

◆ spos

debug_ring_resources_t::spos

the start position in the circular buffer

Definition at line 98 of file debug_ring_interface.h.

◆ tag1

uint64_t debug_ring_resources_t::tag1

Definition at line 100 of file debug_ring_interface.h.

◆ buf

debug_ring_resources_t::buf

the circular buffer that stores the debug strings.

Definition at line 101 of file debug_ring_interface.h.

◆ tag2

uint64_t debug_ring_resources_t::tag2

Definition at line 102 of file debug_ring_interface.h.


The documentation for this struct was generated from the following file: