Skip to content

RFC: Even higher-level cache maintenance operations #47

Closed
@adamgreig

Description

@adamgreig

#40 landed CMSIS-style DCache cleaning and invalidating by address and size, both usize. This maps well to the actual hardware operations but is inconvenient to use.

We could add some convenience methods that operate on normal Rust objects:

  • clean_dcache_by_slice<T>(slice: &[T]) which passes slice.as_ptr() as usize and core::mem::size_of<T>() * slice.len() to the underlying methods,
  • clean_dcache_by_ref<T>(obj: &T), which passes T as *const _ as usize and core::mem::size_of<T>() to the underlying methods.
  • As above for invalidate_dcache and clean_invalidate_dcache

Big safety issue: all the cache methods operate on cache lines of 32 bytes. If you pass something whose size is not a multiple of 32, then some extra bytes after that object will be cleaned or invalidated. In general this is definitely unsafe. Perhaps these methods could panic on non-32-byte-multiple sizes?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions