stm32/ipcc: cleanup naming

This commit is contained in:
xoviat 2023-05-20 10:11:29 -05:00
parent 661b1f3373
commit 5e86188c25
4 changed files with 108 additions and 106 deletions

View File

@ -5,7 +5,7 @@ use embassy_futures::block_on;
use super::cmd::CmdSerial;
use super::consts::TlPacketType;
use super::evt::EvtBox;
use super::unsafe_linked_list::{LST_init_head, LST_is_empty, LST_remove_head};
use super::unsafe_linked_list::LinkedListNode;
use super::{
channels, BleTable, BLE_CMD_BUFFER, CS_BUFFER, EVT_QUEUE, HCI_ACL_DATA_BUFFER, TL_BLE_TABLE, TL_CHANNEL,
TL_REF_TABLE,
@ -18,7 +18,7 @@ pub struct Ble;
impl Ble {
pub(crate) fn new(ipcc: &mut Ipcc) -> Self {
unsafe {
LST_init_head(EVT_QUEUE.as_mut_ptr());
LinkedListNode::init_head(EVT_QUEUE.as_mut_ptr());
TL_BLE_TABLE = MaybeUninit::new(BleTable {
pcmd_buffer: BLE_CMD_BUFFER.as_mut_ptr().cast(),
@ -38,8 +38,8 @@ impl Ble {
let mut node_ptr = core::ptr::null_mut();
let node_ptr_ptr: *mut _ = &mut node_ptr;
while !LST_is_empty(EVT_QUEUE.as_mut_ptr()) {
LST_remove_head(EVT_QUEUE.as_mut_ptr(), node_ptr_ptr);
while !LinkedListNode::is_empty(EVT_QUEUE.as_mut_ptr()) {
LinkedListNode::remove_head(EVT_QUEUE.as_mut_ptr(), node_ptr_ptr);
let event = node_ptr.cast();
let event = EvtBox::new(event);

View File

@ -1,7 +1,7 @@
use core::mem::MaybeUninit;
use super::evt::EvtPacket;
use super::unsafe_linked_list::{LST_init_head, LST_insert_tail, LST_is_empty, LST_remove_head};
use super::unsafe_linked_list::LinkedListNode;
use super::{
channels, MemManagerTable, BLE_SPARE_EVT_BUF, EVT_POOL, FREE_BUFF_QUEUE, LOCAL_FREE_BUF_QUEUE, POOL_SIZE,
SYS_SPARE_EVT_BUF, TL_MEM_MANAGER_TABLE, TL_REF_TABLE,
@ -13,8 +13,8 @@ pub struct MemoryManager;
impl MemoryManager {
pub fn new() -> Self {
unsafe {
LST_init_head(FREE_BUFF_QUEUE.as_mut_ptr());
LST_init_head(LOCAL_FREE_BUF_QUEUE.as_mut_ptr());
LinkedListNode::init_head(FREE_BUFF_QUEUE.as_mut_ptr());
LinkedListNode::init_head(LOCAL_FREE_BUF_QUEUE.as_mut_ptr());
TL_MEM_MANAGER_TABLE = MaybeUninit::new(MemManagerTable {
spare_ble_buffer: BLE_SPARE_EVT_BUF.as_ptr().cast(),
@ -40,7 +40,7 @@ impl MemoryManager {
unsafe {
let list_node = evt.cast();
LST_insert_tail(LOCAL_FREE_BUF_QUEUE.as_mut_ptr(), list_node);
LinkedListNode::remove_tail(LOCAL_FREE_BUF_QUEUE.as_mut_ptr(), list_node);
}
let channel_is_busy = ipcc.c1_is_active_flag(channels::cpu1::IPCC_MM_RELEASE_BUFFER_CHANNEL);
@ -59,9 +59,9 @@ impl MemoryManager {
let mut node_ptr = core::ptr::null_mut();
let node_ptr_ptr: *mut _ = &mut node_ptr;
while !LST_is_empty(LOCAL_FREE_BUF_QUEUE.as_mut_ptr()) {
LST_remove_head(LOCAL_FREE_BUF_QUEUE.as_mut_ptr(), node_ptr_ptr);
LST_insert_tail(
while !LinkedListNode::is_empty(LOCAL_FREE_BUF_QUEUE.as_mut_ptr()) {
LinkedListNode::remove_head(LOCAL_FREE_BUF_QUEUE.as_mut_ptr(), node_ptr_ptr);
LinkedListNode::insert_tail(
(*(*TL_REF_TABLE.as_ptr()).mem_manager_table).pevt_free_buffer_queue,
node_ptr,
);

View File

@ -5,7 +5,7 @@ use embassy_futures::block_on;
use super::cmd::{CmdPacket, CmdSerial};
use super::consts::TlPacketType;
use super::evt::{CcEvt, EvtBox, EvtSerial};
use super::unsafe_linked_list::{LST_init_head, LST_is_empty, LST_remove_head};
use super::unsafe_linked_list::LinkedListNode;
use super::{channels, SysTable, SYSTEM_EVT_QUEUE, SYS_CMD_BUF, TL_CHANNEL, TL_REF_TABLE, TL_SYS_TABLE};
use crate::ipcc::Ipcc;
@ -14,7 +14,7 @@ pub struct Sys;
impl Sys {
pub(crate) fn new(ipcc: &mut Ipcc) -> Self {
unsafe {
LST_init_head(SYSTEM_EVT_QUEUE.as_mut_ptr());
LinkedListNode::init_head(SYSTEM_EVT_QUEUE.as_mut_ptr());
TL_SYS_TABLE = MaybeUninit::new(SysTable {
pcmd_buffer: SYS_CMD_BUF.as_mut_ptr(),
@ -32,8 +32,8 @@ impl Sys {
let mut node_ptr = core::ptr::null_mut();
let node_ptr_ptr: *mut _ = &mut node_ptr;
while !LST_is_empty(SYSTEM_EVT_QUEUE.as_mut_ptr()) {
LST_remove_head(SYSTEM_EVT_QUEUE.as_mut_ptr(), node_ptr_ptr);
while !LinkedListNode::is_empty(SYSTEM_EVT_QUEUE.as_mut_ptr()) {
LinkedListNode::remove_head(SYSTEM_EVT_QUEUE.as_mut_ptr(), node_ptr_ptr);
let event = node_ptr.cast();
let event = EvtBox::new(event);

View File

@ -29,73 +29,74 @@ impl Default for LinkedListNode {
}
}
pub unsafe fn LST_init_head(mut listHead: *mut LinkedListNode) {
impl LinkedListNode {
pub unsafe fn init_head(mut listHead: *mut LinkedListNode) {
(*listHead).next = listHead;
(*listHead).prev = listHead;
}
}
pub unsafe fn LST_is_empty(mut listHead: *mut LinkedListNode) -> bool {
pub unsafe fn is_empty(mut listHead: *mut LinkedListNode) -> bool {
interrupt::free(|_| ((*listHead).next) == listHead)
}
}
pub unsafe fn LST_insert_head(mut listHead: *mut LinkedListNode, mut node: *mut LinkedListNode) {
pub unsafe fn insert_head(mut listHead: *mut LinkedListNode, mut node: *mut LinkedListNode) {
interrupt::free(|_| {
(*node).next = (*listHead).next;
(*node).prev = listHead;
(*listHead).next = node;
(*(*node).next).prev = node;
});
}
}
pub unsafe fn LST_insert_tail(mut listHead: *mut LinkedListNode, mut node: *mut LinkedListNode) {
pub unsafe fn insert_tail(mut listHead: *mut LinkedListNode, mut node: *mut LinkedListNode) {
interrupt::free(|_| {
(*node).next = listHead;
(*node).prev = (*listHead).prev;
(*listHead).prev = node;
(*(*node).prev).next = node;
});
}
}
pub unsafe fn LST_remove_node(mut node: *mut LinkedListNode) {
pub unsafe fn remove_node(mut node: *mut LinkedListNode) {
interrupt::free(|_| {
(*(*node).prev).next = (*node).next;
(*(*node).next).prev = (*node).prev;
});
}
}
pub unsafe fn LST_remove_head(mut listHead: *mut LinkedListNode, mut node: *mut *mut LinkedListNode) {
pub unsafe fn remove_head(mut listHead: *mut LinkedListNode, mut node: *mut *mut LinkedListNode) {
interrupt::free(|_| {
*node = (*listHead).next;
LST_remove_node((*listHead).next);
Self::remove_node((*listHead).next);
});
}
}
pub unsafe fn LST_remove_tail(mut listHead: *mut LinkedListNode, mut node: *mut *mut LinkedListNode) {
pub unsafe fn remove_tail(mut listHead: *mut LinkedListNode, mut node: *mut *mut LinkedListNode) {
interrupt::free(|_| {
*node = (*listHead).prev;
LST_remove_node((*listHead).prev);
Self::remove_node((*listHead).prev);
});
}
}
pub unsafe fn LST_insert_node_after(mut node: *mut LinkedListNode, mut ref_node: *mut LinkedListNode) {
pub unsafe fn insert_node_after(mut node: *mut LinkedListNode, mut ref_node: *mut LinkedListNode) {
interrupt::free(|_| {
(*node).next = (*ref_node).next;
(*node).prev = ref_node;
(*ref_node).next = node;
(*(*node).next).prev = node;
});
}
}
pub unsafe fn LST_insert_node_before(mut node: *mut LinkedListNode, mut ref_node: *mut LinkedListNode) {
pub unsafe fn insert_node_before(mut node: *mut LinkedListNode, mut ref_node: *mut LinkedListNode) {
interrupt::free(|_| {
(*node).next = ref_node;
(*node).prev = (*ref_node).prev;
(*ref_node).prev = node;
(*(*node).prev).next = node;
});
}
}
pub unsafe fn LST_get_size(mut listHead: *mut LinkedListNode) -> usize {
pub unsafe fn get_size(mut listHead: *mut LinkedListNode) -> usize {
interrupt::free(|_| {
let mut size = 0;
let mut temp: *mut LinkedListNode = core::ptr::null_mut::<LinkedListNode>();
@ -108,16 +109,17 @@ pub unsafe fn LST_get_size(mut listHead: *mut LinkedListNode) -> usize {
size
})
}
}
pub unsafe fn LST_get_next_node(mut ref_node: *mut LinkedListNode, mut node: *mut *mut LinkedListNode) {
pub unsafe fn get_next_node(mut ref_node: *mut LinkedListNode, mut node: *mut *mut LinkedListNode) {
interrupt::free(|_| {
*node = (*ref_node).next;
});
}
}
pub unsafe fn LST_get_prev_node(mut ref_node: *mut LinkedListNode, mut node: *mut *mut LinkedListNode) {
pub unsafe fn get_prev_node(mut ref_node: *mut LinkedListNode, mut node: *mut *mut LinkedListNode) {
interrupt::free(|_| {
*node = (*ref_node).prev;
});
}
}