Skip to content

Commit 6a7f9b5

Browse files
committed
add a lot of register derives + serde support for cortex-ar
1 parent 02c2bdf commit 6a7f9b5

File tree

239 files changed

+706
-36
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

239 files changed

+706
-36
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
rustup target add ${{ matrix.target }}
3939
- name: Build
4040
run: |
41-
cargo build --target ${{ matrix.target }}
41+
cargo build --target ${{ matrix.target }} --features "serde, defmt"
4242
cargo build --target ${{ matrix.target }} --no-default-features
4343
4444
build-versatileab:

cortex-ar/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1717
maintenance by MVA (specific address).
1818
- Added new `L1Section::set_section_attrs` and `L1Section::section_attrs` method. Also added
1919
low-level `L1Section::new_with_addr_upper_bits_and_attrs` constructor.
20+
- optional `serde` derives behind a `serde` feature gate
21+
- lots of missing `Debug`, `Copy`, `Clone`, `defmt::Format` derives.
2022

2123
### Changed
2224

cortex-ar/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ version = "0.2.0"
2626

2727
[dependencies]
2828
arbitrary-int = "2"
29-
bitbybit = "1.3.3"
29+
bitbybit = "1.4"
3030
num_enum = { version = "0.7", default-features = false }
3131
critical-section = {version = "1.2.0", features = ["restore-state-u8"], optional = true}
3232
thiserror = { version = "2", default-features = false }
33-
defmt = {version = "1", optional = true}
33+
defmt = { version = "1", optional = true }
34+
serde = { version = "1", features = ["derive"], default-features = false, optional = true }
3435

3536
[build-dependencies]
3637
arm-targets = {version = "0.2.0", path = "../arm-targets"}
@@ -44,6 +45,7 @@ critical-section-single-core = ["critical-section"]
4445
critical-section-multi-core = ["critical-section"]
4546
# Adds defmt::Format implementation for the register types
4647
defmt = ["dep:defmt", "arbitrary-int/defmt"]
48+
serde = ["dep:serde", "arbitrary-int/serde"]
4749

4850
[package.metadata.docs.rs]
4951
targets = ["armv7r-none-eabihf", "armv7r-none-eabi", "armv7a-none-eabihf"]

cortex-ar/src/mmu.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ use arbitrary_int::{u12, u2, u3, u4};
22

33
#[derive(Debug, thiserror::Error)]
44
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
5+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
56
#[error("invalid L1 entry type {0:?}")]
67
pub struct InvalidL1EntryType(pub L1EntryType);
78

89
#[bitbybit::bitenum(u3, exhaustive = true)]
910
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
11+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1012
#[derive(Debug, PartialEq, Eq)]
1113
pub enum AccessPermissions {
1214
PermissionFault = 0b000,
@@ -40,6 +42,7 @@ impl AccessPermissions {
4042

4143
#[bitbybit::bitenum(u2, exhaustive = true)]
4244
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
45+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4346
#[derive(Debug, PartialEq, Eq)]
4447
#[repr(u8)]
4548
pub enum L1EntryType {
@@ -60,6 +63,7 @@ pub enum L1EntryType {
6063
/// of the B, C, and TEX bits.
6164
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
6265
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
66+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6367
pub struct MemoryRegionAttributesRaw {
6468
/// TEX bits
6569
type_extensions: u3,
@@ -80,6 +84,7 @@ impl MemoryRegionAttributesRaw {
8084

8185
#[bitbybit::bitenum(u2, exhaustive = true)]
8286
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
87+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8388
#[derive(Debug)]
8489
pub enum CacheableMemoryAttribute {
8590
NonCacheable = 0b00,
@@ -90,6 +95,7 @@ pub enum CacheableMemoryAttribute {
9095

9196
#[derive(Debug, Copy, Clone)]
9297
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
98+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9399
pub enum MemoryRegionAttributes {
94100
StronglyOrdered,
95101
ShareableDevice,
@@ -142,6 +148,7 @@ impl MemoryRegionAttributes {
142148
/// Individual section attributes for a L1 section.
143149
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
144150
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
151+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
145152
pub struct SectionAttributes {
146153
/// NG bit
147154
pub non_global: bool,
@@ -205,7 +212,8 @@ impl SectionAttributes {
205212
///
206213
/// The ARM Cortex-A architecture programmers manual chapter 9.4 (p.163) or the ARMv7-A and ArmV7-R
207214
/// architecture reference manual p.1323 specify these attributes in more detail.
208-
#[bitbybit::bitfield(u32, default = 0x00)]
215+
#[bitbybit::bitfield(u32, default = 0, defmt_fields(feature = "defmt"))]
216+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
209217
#[derive(PartialEq, Eq)]
210218
pub struct L1Section {
211219
/// Section base address upper bits.

cortex-ar/src/pmsav7.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub use register::drsr::RegionSize;
1313

1414
/// Ways this API can fail
1515
#[derive(Debug, Clone, PartialEq, Eq)]
16+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
1617
pub enum Error {
1718
/// Found too many regions
1819
TooManyRegions,

cortex-ar/src/register/actlr.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
use crate::register::{SysReg, SysRegRead, SysRegWrite};
44

55
/// ACTLR (*Auxiliary Control Register*)
6+
#[derive(Debug, Copy, Clone)]
7+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
8+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
69
pub struct Actlr(pub u32);
710
impl SysReg for Actlr {
811
const CP: u32 = 15;

cortex-ar/src/register/actlr2.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
use crate::register::{SysReg, SysRegRead, SysRegWrite};
44

55
/// ACTLR2 (*Auxiliary Control Register 2*)
6+
#[derive(Debug, Copy, Clone)]
7+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
8+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
69
pub struct Actlr2(pub u32);
710
impl SysReg for Actlr2 {
811
const CP: u32 = 15;

cortex-ar/src/register/adfsr.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
use crate::register::{SysReg, SysRegRead, SysRegWrite};
44

55
/// ADFSR (*Auxiliary Data Fault Status Register*)
6+
#[derive(Debug, Copy, Clone)]
7+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
8+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
69
pub struct Adfsr(pub u32);
710
impl SysReg for Adfsr {
811
const CP: u32 = 15;

cortex-ar/src/register/aidr.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
use crate::register::{SysReg, SysRegRead};
44

55
/// AIDR (*Auxiliary ID Register*)
6+
#[derive(Debug, Copy, Clone)]
7+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
8+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
69
pub struct Aidr(pub u32);
710
impl SysReg for Aidr {
811
const CP: u32 = 15;

cortex-ar/src/register/aifsr.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
use crate::register::{SysReg, SysRegRead, SysRegWrite};
44

55
/// AIFSR (*Auxiliary Instruction Fault Status Register*)
6+
#[derive(Debug, Copy, Clone)]
7+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
8+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
69
pub struct Aifsr(pub u32);
710
impl SysReg for Aifsr {
811
const CP: u32 = 15;

0 commit comments

Comments
 (0)