Skip to content

Commit

Permalink
updates for review
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Dec 28, 2024
1 parent 31003d5 commit 5bba6e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
19 changes: 6 additions & 13 deletions src/bare-metal/aps/mmio.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,12 @@
reference.

```rust,compile_fail
#[unsafe(no_mangle)]
extern "C" fn main(_x0: u64, _x1: u64, _x2: u64, _x3: u64) {
const SOME_DEVICE_BASE_ADDRESS: *mut u64 = 0x800_0000 as _;
const REGISTER_OFFSET: usize = 16;
// SAFETY: Some device is mapped at this address.
unsafe {
SOME_DEVICE_BASE_ADDRESS.add(REGISTER_OFFSET).write_volatile(0xff);
SOME_DEVICE_BASE_ADDRESS.add(REGISTER_OFFSET).write_volatile(0x80);
assert_eq!(
SOME_DEVICE_BASE_ADDRESS.add(REGISTER_OFFSET).read_volatile(),
0xaa
);
}
const SOME_DEVICE_BASE_ADDRESS: *mut u64 = 0x800_0000 as _;
// SAFETY: Some device is mapped at this address.
unsafe {
SOME_DEVICE_BASE_ADDRESS.write_volatile(0xff);
SOME_DEVICE_BASE_ADDRESS.write_volatile(0x80);
assert_eq!(SOME_DEVICE_BASE_ADDRESS.read_volatile(), 0xaa);
}
```

Expand Down
3 changes: 1 addition & 2 deletions src/bare-metal/aps/uart/using.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Using it

Let's write a small program using our driver to write to the serial console, and
echo incoming bytes.
Let's write a small program using our driver to write to the serial console.

```rust,editable,compile_fail
{{#include ../examples/src/main_minimal.rs:main}}
Expand Down

0 comments on commit 5bba6e3

Please sign in to comment.