diff options
| author | xoviat <[email protected]> | 2023-06-21 16:34:56 -0500 |
|---|---|---|
| committer | xoviat <[email protected]> | 2023-06-21 16:34:56 -0500 |
| commit | 5247c1c795a8b37be485aeeaa99a79eece678fba (patch) | |
| tree | f61df4df496dde87a2c5a7bf436c651591a9fa31 | |
| parent | 0d67ef795e4dfecef90690bce51f2820f77fc4bc (diff) | |
stm32/wpan: fix data alignment
| -rw-r--r-- | embassy-stm32-wpan/src/cmd.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/tables.rs | 27 |
2 files changed, 20 insertions, 9 deletions
diff --git a/embassy-stm32-wpan/src/cmd.rs b/embassy-stm32-wpan/src/cmd.rs index edca82390..c8056aaa7 100644 --- a/embassy-stm32-wpan/src/cmd.rs +++ b/embassy-stm32-wpan/src/cmd.rs | |||
| @@ -37,7 +37,7 @@ pub struct CmdSerialStub { | |||
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | #[derive(Copy, Clone, Default)] | 39 | #[derive(Copy, Clone, Default)] |
| 40 | #[repr(C, packed)] | 40 | #[repr(C, packed(4))] |
| 41 | pub struct CmdPacket { | 41 | pub struct CmdPacket { |
| 42 | pub header: PacketHeader, | 42 | pub header: PacketHeader, |
| 43 | pub cmdserial: CmdSerial, | 43 | pub cmdserial: CmdSerial, |
diff --git a/embassy-stm32-wpan/src/tables.rs b/embassy-stm32-wpan/src/tables.rs index 2064910f0..3f26282c6 100644 --- a/embassy-stm32-wpan/src/tables.rs +++ b/embassy-stm32-wpan/src/tables.rs | |||
| @@ -164,6 +164,9 @@ pub struct Mac802_15_4Table { | |||
| 164 | pub evt_queue: *const u8, | 164 | pub evt_queue: *const u8, |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | #[repr(C, align(4))] | ||
| 168 | pub struct AlignedData<const L: usize>([u8; L]); | ||
| 169 | |||
| 167 | /// Reference table. Contains pointers to all other tables. | 170 | /// Reference table. Contains pointers to all other tables. |
| 168 | #[derive(Debug, Copy, Clone)] | 171 | #[derive(Debug, Copy, Clone)] |
| 169 | #[repr(C)] | 172 | #[repr(C)] |
| @@ -219,9 +222,10 @@ pub static mut FREE_BUF_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit | |||
| 219 | #[link_section = "MB_MEM1"] | 222 | #[link_section = "MB_MEM1"] |
| 220 | pub static mut TRACES_EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); | 223 | pub static mut TRACES_EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); |
| 221 | 224 | ||
| 225 | const CS_BUFFER_SIZE: usize = TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + TL_CS_EVT_SIZE; | ||
| 226 | |||
| 222 | #[link_section = "MB_MEM2"] | 227 | #[link_section = "MB_MEM2"] |
| 223 | pub static mut CS_BUFFER: MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + TL_CS_EVT_SIZE]> = | 228 | pub static mut CS_BUFFER: MaybeUninit<AlignedData<CS_BUFFER_SIZE>> = MaybeUninit::uninit(); |
| 224 | MaybeUninit::uninit(); | ||
| 225 | 229 | ||
| 226 | #[link_section = "MB_MEM2"] | 230 | #[link_section = "MB_MEM2"] |
| 227 | pub static mut EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); | 231 | pub static mut EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); |
| @@ -235,8 +239,11 @@ pub static mut SYSTEM_EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::unin | |||
| 235 | pub static mut MAC_802_15_4_CMD_BUFFER: MaybeUninit<CmdPacket> = MaybeUninit::uninit(); | 239 | pub static mut MAC_802_15_4_CMD_BUFFER: MaybeUninit<CmdPacket> = MaybeUninit::uninit(); |
| 236 | 240 | ||
| 237 | #[cfg(feature = "mac")] | 241 | #[cfg(feature = "mac")] |
| 242 | const MAC_802_15_4_NOTIF_RSP_EVT_BUFFER_SIZE: usize = TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255; | ||
| 243 | |||
| 244 | #[cfg(feature = "mac")] | ||
| 238 | #[link_section = "MB_MEM2"] | 245 | #[link_section = "MB_MEM2"] |
| 239 | pub static mut MAC_802_15_4_NOTIF_RSP_EVT_BUFFER: MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]> = | 246 | pub static mut MAC_802_15_4_NOTIF_RSP_EVT_BUFFER: MaybeUninit<AlignedData<MAC_802_15_4_NOTIF_RSP_EVT_BUFFER_SIZE>> = |
| 240 | MaybeUninit::uninit(); | 247 | MaybeUninit::uninit(); |
| 241 | 248 | ||
| 242 | #[link_section = "MB_MEM2"] | 249 | #[link_section = "MB_MEM2"] |
| @@ -245,17 +252,21 @@ pub static mut EVT_POOL: MaybeUninit<[u8; POOL_SIZE]> = MaybeUninit::uninit(); | |||
| 245 | #[link_section = "MB_MEM2"] | 252 | #[link_section = "MB_MEM2"] |
| 246 | pub static mut SYS_CMD_BUF: MaybeUninit<CmdPacket> = MaybeUninit::uninit(); | 253 | pub static mut SYS_CMD_BUF: MaybeUninit<CmdPacket> = MaybeUninit::uninit(); |
| 247 | 254 | ||
| 255 | const SYS_SPARE_EVT_BUF_SIZE: usize = TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255; | ||
| 256 | |||
| 248 | #[link_section = "MB_MEM2"] | 257 | #[link_section = "MB_MEM2"] |
| 249 | pub static mut SYS_SPARE_EVT_BUF: MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]> = | 258 | pub static mut SYS_SPARE_EVT_BUF: MaybeUninit<AlignedData<SYS_SPARE_EVT_BUF_SIZE>> = MaybeUninit::uninit(); |
| 250 | MaybeUninit::uninit(); | ||
| 251 | 259 | ||
| 252 | #[link_section = "MB_MEM1"] | 260 | #[link_section = "MB_MEM1"] |
| 253 | pub static mut BLE_CMD_BUFFER: MaybeUninit<CmdPacket> = MaybeUninit::uninit(); | 261 | pub static mut BLE_CMD_BUFFER: MaybeUninit<CmdPacket> = MaybeUninit::uninit(); |
| 254 | 262 | ||
| 263 | const BLE_SPARE_EVT_BUF_SIZE: usize = TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255; | ||
| 264 | |||
| 255 | #[link_section = "MB_MEM2"] | 265 | #[link_section = "MB_MEM2"] |
| 256 | pub static mut BLE_SPARE_EVT_BUF: MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]> = | 266 | pub static mut BLE_SPARE_EVT_BUF: MaybeUninit<AlignedData<BLE_SPARE_EVT_BUF_SIZE>> = MaybeUninit::uninit(); |
| 257 | MaybeUninit::uninit(); | 267 | |
| 268 | const HCI_ACL_DATA_BUFFER_SIZE: usize = TL_PACKET_HEADER_SIZE + 5 + 251; | ||
| 258 | 269 | ||
| 259 | #[link_section = "MB_MEM2"] | 270 | #[link_section = "MB_MEM2"] |
| 260 | // fuck these "magic" numbers from ST ---v---v | 271 | // fuck these "magic" numbers from ST ---v---v |
| 261 | pub static mut HCI_ACL_DATA_BUFFER: MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + 5 + 251]> = MaybeUninit::uninit(); | 272 | pub static mut HCI_ACL_DATA_BUFFER: MaybeUninit<[u8; HCI_ACL_DATA_BUFFER_SIZE]> = MaybeUninit::uninit(); |
