Skip to content

Commit d7dc934

Browse files
mgeislergribozavr
andauthored
docs: improve language in bare-metal section (#2891)
I asked Gemini to review the English for inconsistencies and grammar mistakes. This is the result and I hope it's useful! As a non-native speaker, it is hard for me to evaluate the finer details, so let me know if you would like to see changes (or even better: make them directly in the PR with the suggestion function). --------- Co-authored-by: Dmitri Gribenko <[email protected]>
1 parent 16c960d commit d7dc934

17 files changed

+46
-47
lines changed

src/bare-metal/aps/better-uart.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# A better UART driver
22

3-
The PL011 actually has [a bunch more registers][1], and adding offsets to
4-
construct pointers to access them is error-prone and hard to read. Plus, some of
5-
them are bit fields which would be nice to access in a structured way.
3+
The PL011 actually has [more registers][1], and adding offsets to construct
4+
pointers to access them is error-prone and hard to read. Additionally, some of
5+
them are bit fields, which would be nice to access in a structured way.
66

77
| Offset | Register name | Width |
88
| ------ | ------------- | ----- |
@@ -23,7 +23,7 @@ them are bit fields which would be nice to access in a structured way.
2323

2424
<details>
2525

26-
- There are also some ID registers which have been omitted for brevity.
26+
- There are also some ID registers that have been omitted for brevity.
2727

2828
</details>
2929

src/bare-metal/aps/entry-point.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Getting Ready to Rust
22

3-
Before we can start running Rust code, we need to do some initialisation.
3+
Before we can start running Rust code, we need to do some initialization.
44

55
```armasm
66
{{#include examples/src/entry.S:entry}}
@@ -12,36 +12,36 @@ This code is in `src/bare-metal/aps/examples/src/entry.S`. It's not necessary to
1212
understand this in detail -- the takeaway is that typically some low-level setup
1313
is needed to meet Rust's expectations of the system.
1414

15-
- This is the same as it would be for C: initialising the processor state,
15+
- This is the same as it would be for C: initializing the processor state,
1616
zeroing the BSS, and setting up the stack pointer.
1717
- The BSS (block starting symbol, for historical reasons) is the part of the
18-
object file which containing statically allocated variables which are
19-
initialised to zero. They are omitted from the image, to avoid wasting space
18+
object file that contains statically allocated variables that are
19+
initialized to zero. They are omitted from the image, to avoid wasting space
2020
on zeroes. The compiler assumes that the loader will take care of zeroing
2121
them.
22-
- The BSS may already be zeroed, depending on how memory is initialised and the
22+
- The BSS may already be zeroed, depending on how memory is initialized and the
2323
image is loaded, but we zero it to be sure.
2424
- We need to enable the MMU and cache before reading or writing any memory. If
2525
we don't:
2626
- Unaligned accesses will fault. We build the Rust code for the
27-
`aarch64-unknown-none` target which sets `+strict-align` to prevent the
28-
compiler generating unaligned accesses, so it should be fine in this case,
29-
but this is not necessarily the case in general.
27+
`aarch64-unknown-none` target that sets `+strict-align` to prevent the
28+
compiler from generating unaligned accesses, so it should be fine in this
29+
case, but this is not necessarily the case in general.
3030
- If it were running in a VM, this can lead to cache coherency issues. The
3131
problem is that the VM is accessing memory directly with the cache disabled,
3232
while the host has cacheable aliases to the same memory. Even if the host
3333
doesn't explicitly access the memory, speculative accesses can lead to cache
3434
fills, and then changes from one or the other will get lost when the cache
3535
is cleaned or the VM enables the cache. (Cache is keyed by physical address,
3636
not VA or IPA.)
37-
- For simplicity, we just use a hardcoded pagetable (see `idmap.S`) which
37+
- For simplicity, we just use a hardcoded pagetable (see `idmap.S`) that
3838
identity maps the first 1 GiB of address space for devices, the next 1 GiB for
3939
DRAM, and another 1 GiB higher up for more devices. This matches the memory
4040
layout that QEMU uses.
4141
- We also set up the exception vector (`vbar_el1`), which we'll see more about
4242
later.
4343
- All examples this afternoon assume we will be running at exception level 1
44-
(EL1). If you need to run at a different exception level you'll need to modify
45-
`entry.S` accordingly.
44+
(EL1). If you need to run at a different exception level, you'll need to
45+
modify `entry.S` accordingly.
4646

4747
</details>

src/bare-metal/aps/inline-assembly.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ for all these functions.)
1616
- PSCI is the Arm Power State Coordination Interface, a standard set of
1717
functions to manage system and CPU power states, among other things. It is
1818
implemented by EL3 firmware and hypervisors on many systems.
19-
- The `0 => _` syntax means initialise the register to 0 before running the
19+
- The `0 => _` syntax means initialize the register to 0 before running the
2020
inline assembly code, and ignore its contents afterwards. We need to use
2121
`inout` rather than `in` because the call could potentially clobber the
2222
contents of the registers.
2323
- This `main` function needs to be `#[unsafe(no_mangle)]` and `extern "C"`
2424
because it is called from our entry point in `entry.S`.
2525
- Just `#[no_mangle]` would be sufficient but
2626
[RFC3325](https://rust-lang.github.io/rfcs/3325-unsafe-attributes.html) uses
27-
this notation to draw reviewer attention to attributes which might cause
27+
this notation to draw reviewer attention to attributes that might cause
2828
undefined behavior if used incorrectly.
2929
- `_x0``_x3` are the values of registers `x0``x3`, which are conventionally
3030
used by the bootloader to pass things like a pointer to the device tree.

src/bare-metal/aps/logging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ We can do this by implementing the `Log` trait.
99

1010
<details>
1111

12-
- The first unwrap in `log` will succeed because we initialise `LOGGER` before
12+
- The first unwrap in `log` will succeed because we initialize `LOGGER` before
1313
calling `set_logger`. The second will succeed because `Uart::write_str` always
1414
returns `Ok`.
1515

src/bare-metal/aps/mmio.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ unsafe {
2828
compiler may assume that the value read is the same as the value just
2929
written, and not bother actually reading memory.
3030
- Some existing crates for volatile access to hardware do hold references, but
31-
this is unsound. Whenever a reference exist, the compiler may choose to
31+
this is unsound. Whenever a reference exists, the compiler may choose to
3232
dereference it.
3333
- Use `&raw` to get struct field pointers from a pointer to the struct.
3434
- For compatibility with old versions of Rust you can use the [`addr_of!`] macro

src/bare-metal/aps/other-projects.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
- Supports x86, aarch64 and RISC-V.
66
- Relies on LinuxBoot rather than having many drivers itself.
77
- [Rust RaspberryPi OS tutorial](https://github.com/rust-embedded/rust-raspberrypi-OS-tutorials)
8-
- Initialisation, UART driver, simple bootloader, JTAG, exception levels,
8+
- Initialization, UART driver, simple bootloader, JTAG, exception levels,
99
exception handling, page tables.
10-
- Some dodginess around cache maintenance and initialisation in Rust, not
10+
- Some caveats around cache maintenance and initialization in Rust, not
1111
necessarily a good example to copy for production code.
1212
- [`cargo-call-stack`](https://crates.io/crates/cargo-call-stack)
1313
- Static analysis to determine maximum stack usage.

src/bare-metal/aps/safemmio/driver.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ Now let's use the new `Registers` struct in our driver.
1717
- These MMIO accesses are generally a wrapper around `read_volatile` and
1818
`write_volatile`, though on aarch64 they are instead implemented in assembly
1919
to work around a bug where the compiler can emit instructions that prevent
20-
MMIO virtualisation.
20+
MMIO virtualization.
2121
- The `field!` and `field_shared!` macros internally use `&raw mut` and
2222
`&raw const` to get pointers to individual fields without creating an
2323
intermediate reference, which would be unsound.
2424
- `field!` needs a mutable reference to a `UniqueMmioPointer`, and returns a
25-
`UniqueMmioPointer` which allows reads with side effects and writes.
25+
`UniqueMmioPointer` that allows reads with side effects and writes.
2626
- `field_shared!` works with a shared reference to either a `UniqueMmioPointer`
27-
or a `SharedMmioPointer`. It returns a `SharedMmioPointer` which only allows
27+
or a `SharedMmioPointer`. It returns a `SharedMmioPointer` that only allows
2828
pure reads.
2929

3030
</details>

src/bare-metal/aps/safemmio/registers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# safe-mmio
22

3-
The [`safe-mmio`] crate provides types to wrap registers which can be read or
3+
The [`safe-mmio`] crate provides types to wrap registers that can be read or
44
written safely.
55

66
| | Can't read | Read has no side-effects | Read has side-effects |
@@ -23,7 +23,7 @@ written safely.
2323
operations; we recommend the `safe-mmio` crate.
2424
- The difference between `ReadPure` or `ReadOnly` (and likewise between
2525
`ReadPureWrite` and `ReadWrite`) is whether reading a register can have
26-
side-effects which change the state of the device. E.g. reading the data
26+
side-effects that change the state of the device, e.g., reading the data
2727
register pops a byte from the receive FIFO. `ReadPure` means that reads have
2828
no side-effects, they are purely reading data.
2929

src/bare-metal/microcontrollers/board-support.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ for convenience.
1212
<details>
1313

1414
- In this case the board support crate is just providing more useful names, and
15-
a bit of initialisation.
15+
a bit of initialization.
1616
- The crate may also include drivers for some on-board devices outside of the
1717
microcontroller itself.
1818
- `microbit-v2` includes a simple driver for the LED matrix.

src/bare-metal/microcontrollers/embedded-hal.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ accelerometer driver might need an I2C or SPI device instance.
1616

1717
<details>
1818

19-
- The traits cover using the peripherals but not initialising or configuring
20-
them, as initialisation and configuration is usually highly platform-specific.
19+
- The traits cover using the peripherals but not initializing or configuring
20+
them, as initialization and configuration is usually highly platform-specific.
2121
- There are implementations for many microcontrollers, as well as other
2222
platforms such as Linux on Raspberry Pi.
2323
- [`embedded-hal-async`] provides async versions of the traits.

0 commit comments

Comments
 (0)