More sys_uart packets (#11332)

* Additional sys_uart packets added
This commit is contained in:
Vestrel 2022-01-10 09:43:54 +09:00 committed by GitHub
parent 83026fd263
commit 1adc408ad7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 2457 additions and 127 deletions

View file

@ -5,6 +5,34 @@ simple_ringbuf::simple_ringbuf(u32 size)
set_buf_size(size);
}
simple_ringbuf::simple_ringbuf(simple_ringbuf&& other)
{
rw_ptr = other.rw_ptr.load();
buf_size = other.buf_size;
buf = std::move(other.buf);
initialized = other.initialized.observe();
other.buf_size = 0;
other.rw_ptr = 0;
other.initialized = false;
}
simple_ringbuf& simple_ringbuf::operator=(simple_ringbuf&& other)
{
if (this == &other) return *this;
rw_ptr = other.rw_ptr.load();
buf_size = other.buf_size;
buf = std::move(other.buf);
initialized = other.initialized.observe();
other.buf_size = 0;
other.rw_ptr = 0;
other.initialized = false;
return *this;
}
u32 simple_ringbuf::get_free_size()
{
const u64 _rw_ptr = rw_ptr;
@ -19,6 +47,11 @@ u32 simple_ringbuf::get_used_size()
return buf_size - 1 - get_free_size();
}
u32 simple_ringbuf::get_total_size()
{
return buf_size;
}
void simple_ringbuf::set_buf_size(u32 size)
{
ensure(size);