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
1212understand this in detail -- the takeaway is that typically some low-level setup
1313is 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 >
0 commit comments