mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-22 06:42:32 +00:00
wpan: update alignment control
This commit is contained in:
parent
37c103b5f3
commit
735d676a72
@ -37,7 +37,7 @@ pub struct CmdSerialStub {
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Default)]
|
||||
#[repr(C, packed(4))]
|
||||
#[repr(C, packed)]
|
||||
pub struct CmdPacket {
|
||||
pub header: PacketHeader,
|
||||
pub cmdserial: CmdSerial,
|
||||
|
@ -79,6 +79,7 @@ pub const CFG_TL_BLE_MOST_EVENT_PAYLOAD_SIZE: usize = 255;
|
||||
pub const TL_BLE_EVENT_FRAME_SIZE: usize = TL_EVT_HEADER_SIZE + CFG_TL_BLE_MOST_EVENT_PAYLOAD_SIZE;
|
||||
|
||||
pub const POOL_SIZE: usize = CFG_TL_BLE_EVT_QUEUE_LENGTH * 4 * divc(TL_PACKET_HEADER_SIZE + TL_BLE_EVENT_FRAME_SIZE, 4);
|
||||
pub const C_SIZE_CMD_STRING: usize = 256;
|
||||
|
||||
pub const fn divc(x: usize, y: usize) -> usize {
|
||||
(x + y - 1) / y
|
||||
|
@ -60,9 +60,9 @@ impl<'d> TlMbox<'d> {
|
||||
mem_manager_table: TL_MEM_MANAGER_TABLE.as_ptr(),
|
||||
traces_table: TL_TRACES_TABLE.as_ptr(),
|
||||
mac_802_15_4_table: TL_MAC_802_15_4_TABLE.as_ptr(),
|
||||
// zigbee_table: TL_ZIGBEE_TABLE.as_ptr(),
|
||||
// lld_tests_table: TL_LLD_TESTS_TABLE.as_ptr(),
|
||||
// ble_lld_table: TL_BLE_LLD_TABLE.as_ptr(),
|
||||
zigbee_table: TL_ZIGBEE_TABLE.as_ptr(),
|
||||
lld_tests_table: TL_LLD_TESTS_TABLE.as_ptr(),
|
||||
ble_lld_table: TL_BLE_LLD_TABLE.as_ptr(),
|
||||
});
|
||||
|
||||
TL_SYS_TABLE
|
||||
@ -87,15 +87,15 @@ impl<'d> TlMbox<'d> {
|
||||
TL_MAC_802_15_4_TABLE
|
||||
.as_mut_ptr()
|
||||
.write_volatile(MaybeUninit::zeroed().assume_init());
|
||||
// TL_ZIGBEE_TABLE
|
||||
// .as_mut_ptr()
|
||||
// .write_volatile(MaybeUninit::zeroed().assume_init());
|
||||
// TL_LLD_TESTS_TABLE
|
||||
// .as_mut_ptr()
|
||||
// .write_volatile(MaybeUninit::zeroed().assume_init());
|
||||
// TL_BLE_LLD_TABLE
|
||||
// .as_mut_ptr()
|
||||
// .write_volatile(MaybeUninit::zeroed().assume_init());
|
||||
TL_ZIGBEE_TABLE
|
||||
.as_mut_ptr()
|
||||
.write_volatile(MaybeUninit::zeroed().assume_init());
|
||||
TL_LLD_TESTS_TABLE
|
||||
.as_mut_ptr()
|
||||
.write_volatile(MaybeUninit::zeroed().assume_init());
|
||||
TL_BLE_LLD_TABLE
|
||||
.as_mut_ptr()
|
||||
.write_volatile(MaybeUninit::zeroed().assume_init());
|
||||
|
||||
EVT_POOL
|
||||
.as_mut_ptr()
|
||||
@ -103,18 +103,30 @@ impl<'d> TlMbox<'d> {
|
||||
SYS_SPARE_EVT_BUF
|
||||
.as_mut_ptr()
|
||||
.write_volatile(MaybeUninit::zeroed().assume_init());
|
||||
BLE_SPARE_EVT_BUF
|
||||
CS_BUFFER
|
||||
.as_mut_ptr()
|
||||
.write_volatile(MaybeUninit::zeroed().assume_init());
|
||||
|
||||
#[cfg(feature = "ble")]
|
||||
{
|
||||
BLE_SPARE_EVT_BUF
|
||||
.as_mut_ptr()
|
||||
.write_volatile(MaybeUninit::zeroed().assume_init());
|
||||
|
||||
BLE_CMD_BUFFER
|
||||
.as_mut_ptr()
|
||||
.write_volatile(MaybeUninit::zeroed().assume_init());
|
||||
HCI_ACL_DATA_BUFFER
|
||||
.as_mut_ptr()
|
||||
.write_volatile(MaybeUninit::zeroed().assume_init());
|
||||
CS_BUFFER
|
||||
}
|
||||
|
||||
#[cfg(feature = "mac")]
|
||||
{
|
||||
MAC_802_15_4_CMD_BUFFER
|
||||
.as_mut_ptr()
|
||||
.write_volatile(MaybeUninit::zeroed().assume_init());
|
||||
MAC_802_15_4_NOTIF_RSP_EVT_BUFFER
|
||||
.as_mut_ptr()
|
||||
.write_volatile(MaybeUninit::zeroed().assume_init());
|
||||
}
|
||||
|
@ -4,20 +4,21 @@ use core::marker::PhantomData;
|
||||
use core::mem::MaybeUninit;
|
||||
use core::task::Poll;
|
||||
|
||||
use aligned::{Aligned, A4};
|
||||
use cortex_m::interrupt;
|
||||
use embassy_stm32::ipcc::Ipcc;
|
||||
use embassy_sync::waitqueue::AtomicWaker;
|
||||
|
||||
use crate::consts::POOL_SIZE;
|
||||
use crate::evt::EvtPacket;
|
||||
use crate::tables::{
|
||||
MemManagerTable, BLE_SPARE_EVT_BUF, EVT_POOL, FREE_BUF_QUEUE, SYS_SPARE_EVT_BUF, TL_MEM_MANAGER_TABLE,
|
||||
};
|
||||
#[cfg(feature = "ble")]
|
||||
use crate::tables::BLE_SPARE_EVT_BUF;
|
||||
use crate::tables::{MemManagerTable, EVT_POOL, FREE_BUF_QUEUE, SYS_SPARE_EVT_BUF, TL_MEM_MANAGER_TABLE};
|
||||
use crate::unsafe_linked_list::LinkedListNode;
|
||||
use crate::{channels, evt};
|
||||
|
||||
static MM_WAKER: AtomicWaker = AtomicWaker::new();
|
||||
static mut LOCAL_FREE_BUF_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit();
|
||||
static mut LOCAL_FREE_BUF_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit());
|
||||
|
||||
pub struct MemoryManager {
|
||||
phantom: PhantomData<MemoryManager>,
|
||||
@ -30,7 +31,10 @@ impl MemoryManager {
|
||||
LinkedListNode::init_head(LOCAL_FREE_BUF_QUEUE.as_mut_ptr());
|
||||
|
||||
TL_MEM_MANAGER_TABLE.as_mut_ptr().write_volatile(MemManagerTable {
|
||||
#[cfg(feature = "ble")]
|
||||
spare_ble_buffer: BLE_SPARE_EVT_BUF.as_ptr().cast(),
|
||||
#[cfg(not(feature = "ble"))]
|
||||
spare_ble_buffer: core::ptr::null(),
|
||||
spare_sys_buffer: SYS_SPARE_EVT_BUF.as_ptr().cast(),
|
||||
blepool: EVT_POOL.as_ptr().cast(),
|
||||
blepoolsize: POOL_SIZE as u32,
|
||||
|
@ -4,6 +4,8 @@ use aligned::{Aligned, A4};
|
||||
use bit_field::BitField;
|
||||
|
||||
use crate::cmd::{AclDataPacket, CmdPacket};
|
||||
#[cfg(feature = "mac")]
|
||||
use crate::consts::C_SIZE_CMD_STRING;
|
||||
use crate::consts::{POOL_SIZE, TL_CS_EVT_SIZE, TL_EVT_HEADER_SIZE, TL_PACKET_HEADER_SIZE};
|
||||
use crate::unsafe_linked_list::LinkedListNode;
|
||||
|
||||
@ -80,7 +82,7 @@ impl WirelessFwInfoTable {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[repr(C, align(4))]
|
||||
#[repr(C)]
|
||||
pub struct DeviceInfoTable {
|
||||
pub safe_boot_info_table: SafeBootInfoTable,
|
||||
pub rss_info_table: RssInfoTable,
|
||||
@ -88,7 +90,7 @@ pub struct DeviceInfoTable {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[repr(C, align(4))]
|
||||
#[repr(C)]
|
||||
pub struct BleTable {
|
||||
pub pcmd_buffer: *mut CmdPacket,
|
||||
pub pcs_buffer: *const u8,
|
||||
@ -97,16 +99,15 @@ pub struct BleTable {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[repr(C, align(4))]
|
||||
#[repr(C)]
|
||||
pub struct ThreadTable {
|
||||
pub nostack_buffer: *const u8,
|
||||
pub clicmdrsp_buffer: *const u8,
|
||||
pub otcmdrsp_buffer: *const u8,
|
||||
}
|
||||
|
||||
// TODO: use later
|
||||
#[derive(Debug)]
|
||||
#[repr(C, align(4))]
|
||||
#[repr(C)]
|
||||
pub struct LldTestsTable {
|
||||
pub clicmdrsp_buffer: *const u8,
|
||||
pub m0cmd_buffer: *const u8,
|
||||
@ -114,7 +115,7 @@ pub struct LldTestsTable {
|
||||
|
||||
// TODO: use later
|
||||
#[derive(Debug)]
|
||||
#[repr(C, align(4))]
|
||||
#[repr(C)]
|
||||
pub struct BleLldTable {
|
||||
pub cmdrsp_buffer: *const u8,
|
||||
pub m0cmd_buffer: *const u8,
|
||||
@ -122,7 +123,7 @@ pub struct BleLldTable {
|
||||
|
||||
// TODO: use later
|
||||
#[derive(Debug)]
|
||||
#[repr(C, align(4))]
|
||||
#[repr(C)]
|
||||
pub struct ZigbeeTable {
|
||||
pub notif_m0_to_m4_buffer: *const u8,
|
||||
pub appli_cmd_m4_to_m0_bufer: *const u8,
|
||||
@ -130,14 +131,14 @@ pub struct ZigbeeTable {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[repr(C, align(4))]
|
||||
#[repr(C)]
|
||||
pub struct SysTable {
|
||||
pub pcmd_buffer: *mut CmdPacket,
|
||||
pub sys_queue: *const LinkedListNode,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[repr(C, align(4))]
|
||||
#[repr(C)]
|
||||
pub struct MemManagerTable {
|
||||
pub spare_ble_buffer: *const u8,
|
||||
pub spare_sys_buffer: *const u8,
|
||||
@ -152,13 +153,13 @@ pub struct MemManagerTable {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[repr(C, align(4))]
|
||||
#[repr(C)]
|
||||
pub struct TracesTable {
|
||||
pub traces_queue: *const u8,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[repr(C, align(4))]
|
||||
#[repr(C)]
|
||||
pub struct Mac802_15_4Table {
|
||||
pub p_cmdrsp_buffer: *const u8,
|
||||
pub p_notack_buffer: *const u8,
|
||||
@ -176,6 +177,9 @@ pub struct RefTable {
|
||||
pub mem_manager_table: *const MemManagerTable,
|
||||
pub traces_table: *const TracesTable,
|
||||
pub mac_802_15_4_table: *const Mac802_15_4Table,
|
||||
pub zigbee_table: *const ZigbeeTable,
|
||||
pub lld_tests_table: *const LldTestsTable,
|
||||
pub ble_lld_table: *const BleLldTable,
|
||||
}
|
||||
|
||||
// --------------------- ref table ---------------------
|
||||
@ -183,57 +187,57 @@ pub struct RefTable {
|
||||
pub static mut TL_REF_TABLE: MaybeUninit<RefTable> = MaybeUninit::uninit();
|
||||
|
||||
#[link_section = "MB_MEM1"]
|
||||
pub static mut TL_DEVICE_INFO_TABLE: MaybeUninit<DeviceInfoTable> = MaybeUninit::uninit();
|
||||
pub static mut TL_DEVICE_INFO_TABLE: Aligned<A4, MaybeUninit<DeviceInfoTable>> = Aligned(MaybeUninit::uninit());
|
||||
|
||||
#[link_section = "MB_MEM1"]
|
||||
pub static mut TL_BLE_TABLE: MaybeUninit<BleTable> = MaybeUninit::uninit();
|
||||
pub static mut TL_BLE_TABLE: Aligned<A4, MaybeUninit<BleTable>> = Aligned(MaybeUninit::uninit());
|
||||
|
||||
#[link_section = "MB_MEM1"]
|
||||
pub static mut TL_THREAD_TABLE: MaybeUninit<ThreadTable> = MaybeUninit::uninit();
|
||||
|
||||
// #[link_section = "MB_MEM1"]
|
||||
// pub static mut TL_LLD_TESTS_TABLE: MaybeUninit<LldTestTable> = MaybeUninit::uninit();
|
||||
|
||||
// #[link_section = "MB_MEM1"]
|
||||
// pub static mut TL_BLE_LLD_TABLE: MaybeUninit<BleLldTable> = MaybeUninit::uninit();
|
||||
pub static mut TL_THREAD_TABLE: Aligned<A4, MaybeUninit<ThreadTable>> = Aligned(MaybeUninit::uninit());
|
||||
|
||||
#[link_section = "MB_MEM1"]
|
||||
pub static mut TL_SYS_TABLE: MaybeUninit<SysTable> = MaybeUninit::uninit();
|
||||
pub static mut TL_LLD_TESTS_TABLE: Aligned<A4, MaybeUninit<LldTestsTable>> = Aligned(MaybeUninit::uninit());
|
||||
|
||||
#[link_section = "MB_MEM1"]
|
||||
pub static mut TL_MEM_MANAGER_TABLE: MaybeUninit<MemManagerTable> = MaybeUninit::uninit();
|
||||
pub static mut TL_BLE_LLD_TABLE: Aligned<A4, MaybeUninit<BleLldTable>> = Aligned(MaybeUninit::uninit());
|
||||
|
||||
#[link_section = "MB_MEM1"]
|
||||
pub static mut TL_TRACES_TABLE: MaybeUninit<TracesTable> = MaybeUninit::uninit();
|
||||
pub static mut TL_SYS_TABLE: Aligned<A4, MaybeUninit<SysTable>> = Aligned(MaybeUninit::uninit());
|
||||
|
||||
#[link_section = "MB_MEM1"]
|
||||
pub static mut TL_MAC_802_15_4_TABLE: MaybeUninit<Mac802_15_4Table> = MaybeUninit::uninit();
|
||||
pub static mut TL_MEM_MANAGER_TABLE: Aligned<A4, MaybeUninit<MemManagerTable>> = Aligned(MaybeUninit::uninit());
|
||||
|
||||
// #[link_section = "MB_MEM1"]
|
||||
// pub static mut TL_ZIGBEE_TABLE: MaybeUninit<ZigbeeTable> = MaybeUninit::uninit();
|
||||
#[link_section = "MB_MEM1"]
|
||||
pub static mut TL_TRACES_TABLE: Aligned<A4, MaybeUninit<TracesTable>> = Aligned(MaybeUninit::uninit());
|
||||
|
||||
#[link_section = "MB_MEM1"]
|
||||
pub static mut TL_MAC_802_15_4_TABLE: Aligned<A4, MaybeUninit<Mac802_15_4Table>> = Aligned(MaybeUninit::uninit());
|
||||
|
||||
#[link_section = "MB_MEM1"]
|
||||
pub static mut TL_ZIGBEE_TABLE: Aligned<A4, MaybeUninit<ZigbeeTable>> = Aligned(MaybeUninit::uninit());
|
||||
|
||||
// --------------------- tables ---------------------
|
||||
#[link_section = "MB_MEM1"]
|
||||
pub static mut FREE_BUF_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit();
|
||||
pub static mut FREE_BUF_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit());
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[link_section = "MB_MEM1"]
|
||||
pub static mut TRACES_EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit();
|
||||
pub static mut TRACES_EVT_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit());
|
||||
|
||||
#[link_section = "MB_MEM2"]
|
||||
pub static mut CS_BUFFER: MaybeUninit<Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + TL_CS_EVT_SIZE]>> =
|
||||
MaybeUninit::uninit();
|
||||
pub static mut CS_BUFFER: Aligned<A4, MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + TL_CS_EVT_SIZE]>> =
|
||||
Aligned(MaybeUninit::uninit());
|
||||
|
||||
#[link_section = "MB_MEM2"]
|
||||
pub static mut EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit();
|
||||
pub static mut EVT_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit());
|
||||
|
||||
#[link_section = "MB_MEM2"]
|
||||
pub static mut SYSTEM_EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit();
|
||||
pub static mut SYSTEM_EVT_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit());
|
||||
|
||||
// --------------------- app tables ---------------------
|
||||
#[cfg(feature = "mac")]
|
||||
#[link_section = "MB_MEM2"]
|
||||
pub static mut MAC_802_15_4_CMD_BUFFER: MaybeUninit<CmdPacket> = MaybeUninit::uninit();
|
||||
pub static mut MAC_802_15_4_CMD_BUFFER: Aligned<A4, MaybeUninit<CmdPacket>> = Aligned(MaybeUninit::uninit());
|
||||
|
||||
#[cfg(feature = "mac")]
|
||||
#[link_section = "MB_MEM2"]
|
||||
@ -242,23 +246,31 @@ pub static mut MAC_802_15_4_NOTIF_RSP_EVT_BUFFER: MaybeUninit<
|
||||
> = MaybeUninit::uninit();
|
||||
|
||||
#[link_section = "MB_MEM2"]
|
||||
pub static mut EVT_POOL: MaybeUninit<Aligned<A4, [u8; POOL_SIZE]>> = MaybeUninit::uninit();
|
||||
pub static mut EVT_POOL: Aligned<A4, MaybeUninit<[u8; POOL_SIZE]>> = Aligned(MaybeUninit::uninit());
|
||||
|
||||
#[link_section = "MB_MEM2"]
|
||||
pub static mut SYS_CMD_BUF: MaybeUninit<CmdPacket> = MaybeUninit::uninit();
|
||||
pub static mut SYS_CMD_BUF: Aligned<A4, MaybeUninit<CmdPacket>> = Aligned(MaybeUninit::uninit());
|
||||
|
||||
#[link_section = "MB_MEM2"]
|
||||
pub static mut SYS_SPARE_EVT_BUF: MaybeUninit<Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>> =
|
||||
MaybeUninit::uninit();
|
||||
pub static mut SYS_SPARE_EVT_BUF: Aligned<A4, MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>> =
|
||||
Aligned(MaybeUninit::uninit());
|
||||
|
||||
#[cfg(feature = "mac")]
|
||||
#[link_section = "MB_MEM2"]
|
||||
pub static mut MAC_802_15_4_CNFINDNOT: Aligned<A4, MaybeUninit<[u8; C_SIZE_CMD_STRING]>> =
|
||||
Aligned(MaybeUninit::uninit());
|
||||
|
||||
#[cfg(feature = "ble")]
|
||||
#[link_section = "MB_MEM1"]
|
||||
pub static mut BLE_CMD_BUFFER: MaybeUninit<CmdPacket> = MaybeUninit::uninit();
|
||||
pub static mut BLE_CMD_BUFFER: Aligned<A4, MaybeUninit<CmdPacket>> = Aligned(MaybeUninit::uninit());
|
||||
|
||||
#[cfg(feature = "ble")]
|
||||
#[link_section = "MB_MEM2"]
|
||||
pub static mut BLE_SPARE_EVT_BUF: MaybeUninit<Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>> =
|
||||
MaybeUninit::uninit();
|
||||
pub static mut BLE_SPARE_EVT_BUF: Aligned<A4, MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>> =
|
||||
Aligned(MaybeUninit::uninit());
|
||||
|
||||
#[cfg(feature = "ble")]
|
||||
#[link_section = "MB_MEM2"]
|
||||
// fuck these "magic" numbers from ST ---v---v
|
||||
pub static mut HCI_ACL_DATA_BUFFER: MaybeUninit<Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + 5 + 251]>> =
|
||||
MaybeUninit::uninit();
|
||||
pub static mut HCI_ACL_DATA_BUFFER: Aligned<A4, MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + 5 + 251]>> =
|
||||
Aligned(MaybeUninit::uninit());
|
||||
|
Loading…
Reference in New Issue
Block a user