Skip to content

Commit 5887503

Browse files
committed
Fix explanation
1 parent 223989a commit 5887503

File tree

11 files changed

+62
-48
lines changed

11 files changed

+62
-48
lines changed

11_virtual_mem_part1_identity_mapping/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,16 +1018,15 @@ diff -uNr 10_privilege_level/src/main.rs 11_virtual_mem_part1_identity_mapping/s
10181018
#![feature(format_args_nl)]
10191019
#![feature(panic_info_message)]
10201020
#![feature(trait_alias)]
1021-
@@ -132,9 +136,18 @@
1021+
@@ -132,9 +136,17 @@
10221022
/// # Safety
10231023
///
10241024
/// - Only a single core must be active and running this function.
10251025
-/// - The init calls in this function must appear in the correct order.
10261026
+/// - The init calls in this function must appear in the correct order:
1027-
+/// - Caching must be activated before the device drivers.
1028-
+/// - Without it, any atomic operations, e.g. the yet-to-be-introduced spinlocks in the device
1029-
+/// drivers (which currently employ NullLocks instead of spinlocks), will fail to work on
1030-
+/// the RPi SoCs.
1027+
+/// - MMU + Data caching must be activated at the earliest. Without it, any atomic operations,
1028+
+/// e.g. the yet-to-be-introduced spinlocks in the device drivers (which currently employ
1029+
+/// NullLocks instead of spinlocks), will fail to work (properly) on the RPi SoCs.
10311030
unsafe fn kernel_init() -> ! {
10321031
use driver::interface::DriverManager;
10331032
+ use memory::mmu::interface::MMU;
@@ -1038,7 +1037,7 @@ diff -uNr 10_privilege_level/src/main.rs 11_virtual_mem_part1_identity_mapping/s
10381037
10391038
for i in bsp::driver::driver_manager().all_device_drivers().iter() {
10401039
if let Err(x) = i.init() {
1041-
@@ -158,6 +171,9 @@
1040+
@@ -158,6 +170,9 @@
10421041
10431042
info!("Booting on: {}", bsp::board_name());
10441043
@@ -1048,7 +1047,7 @@ diff -uNr 10_privilege_level/src/main.rs 11_virtual_mem_part1_identity_mapping/s
10481047
let (_, privilege_level) = exception::current_privilege_level();
10491048
info!("Current privilege level: {}", privilege_level);
10501049
1051-
@@ -181,6 +197,13 @@
1050+
@@ -181,6 +196,13 @@
10521051
info!("Timer test, spinning for 1 second");
10531052
time::time_manager().spin_for(Duration::from_secs(1));
10541053

11_virtual_mem_part1_identity_mapping/src/main.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,9 @@ mod time;
137137
///
138138
/// - Only a single core must be active and running this function.
139139
/// - The init calls in this function must appear in the correct order:
140-
/// - Caching must be activated before the device drivers.
141-
/// - Without it, any atomic operations, e.g. the yet-to-be-introduced spinlocks in the device
142-
/// drivers (which currently employ NullLocks instead of spinlocks), will fail to work on
143-
/// the RPi SoCs.
140+
/// - MMU + Data caching must be activated at the earliest. Without it, any atomic operations,
141+
/// e.g. the yet-to-be-introduced spinlocks in the device drivers (which currently employ
142+
/// NullLocks instead of spinlocks), will fail to work (properly) on the RPi SoCs.
144143
unsafe fn kernel_init() -> ! {
145144
use driver::interface::DriverManager;
146145
use memory::mmu::interface::MMU;

12_exceptions_part1_groundwork/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ diff -uNr 11_virtual_mem_part1_identity_mapping/src/main.rs 12_exceptions_part1_
953953
#![feature(panic_info_message)]
954954
#![feature(trait_alias)]
955955
#![no_main]
956-
@@ -145,6 +146,8 @@
956+
@@ -144,6 +145,8 @@
957957
use driver::interface::DriverManager;
958958
use memory::mmu::interface::MMU;
959959

@@ -962,7 +962,7 @@ diff -uNr 11_virtual_mem_part1_identity_mapping/src/main.rs 12_exceptions_part1_
962962
if let Err(string) = memory::mmu::mmu().enable_mmu_and_caching() {
963963
panic!("MMU: {}", string);
964964
}
965-
@@ -197,13 +200,28 @@
965+
@@ -196,13 +199,28 @@
966966
info!("Timer test, spinning for 1 second");
967967
time::time_manager().spin_for(Duration::from_secs(1));
968968

12_exceptions_part1_groundwork/src/main.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,9 @@ mod time;
138138
///
139139
/// - Only a single core must be active and running this function.
140140
/// - The init calls in this function must appear in the correct order:
141-
/// - Caching must be activated before the device drivers.
142-
/// - Without it, any atomic operations, e.g. the yet-to-be-introduced spinlocks in the device
143-
/// drivers (which currently employ NullLocks instead of spinlocks), will fail to work on
144-
/// the RPi SoCs.
141+
/// - MMU + Data caching must be activated at the earliest. Without it, any atomic operations,
142+
/// e.g. the yet-to-be-introduced spinlocks in the device drivers (which currently employ
143+
/// NullLocks instead of spinlocks), will fail to work (properly) on the RPi SoCs.
145144
unsafe fn kernel_init() -> ! {
146145
use driver::interface::DriverManager;
147146
use memory::mmu::interface::MMU;

13_integrated_testing/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,15 +1505,15 @@ diff -uNr 12_exceptions_part1_groundwork/src/main.rs 13_integrated_testing/src/m
15051505

15061506
/// Early init code.
15071507
///
1508-
@@ -142,6 +23,7 @@
1509-
/// - Without it, any atomic operations, e.g. the yet-to-be-introduced spinlocks in the device
1510-
/// drivers (which currently employ NullLocks instead of spinlocks), will fail to work on
1511-
/// the RPi SoCs.
1508+
@@ -141,6 +22,7 @@
1509+
/// - MMU + Data caching must be activated at the earliest. Without it, any atomic operations,
1510+
/// e.g. the yet-to-be-introduced spinlocks in the device drivers (which currently employ
1511+
/// NullLocks instead of spinlocks), will fail to work (properly) on the RPi SoCs.
15121512
+#[no_mangle]
15131513
unsafe fn kernel_init() -> ! {
15141514
use driver::interface::DriverManager;
15151515
use memory::mmu::interface::MMU;
1516-
@@ -168,9 +50,7 @@
1516+
@@ -167,9 +49,7 @@
15171517
fn kernel_main() -> ! {
15181518
use bsp::console::console;
15191519
use console::interface::All;
@@ -1523,7 +1523,7 @@ diff -uNr 12_exceptions_part1_groundwork/src/main.rs 13_integrated_testing/src/m
15231523

15241524
info!("Booting on: {}", bsp::board_name());
15251525

1526-
@@ -197,31 +77,6 @@
1526+
@@ -196,31 +76,6 @@
15271527
info!(" {}. {}", i + 1, driver.compatible());
15281528
}
15291529

13_integrated_testing/src/main.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ use libkernel::{bsp, console, driver, exception, info, memory, time};
1919
///
2020
/// - Only a single core must be active and running this function.
2121
/// - The init calls in this function must appear in the correct order:
22-
/// - Caching must be activated before the device drivers.
23-
/// - Without it, any atomic operations, e.g. the yet-to-be-introduced spinlocks in the device
24-
/// drivers (which currently employ NullLocks instead of spinlocks), will fail to work on
25-
/// the RPi SoCs.
22+
/// - MMU + Data caching must be activated at the earliest. Without it, any atomic operations,
23+
/// e.g. the yet-to-be-introduced spinlocks in the device drivers (which currently employ
24+
/// NullLocks instead of spinlocks), will fail to work (properly) on the RPi SoCs.
2625
#[no_mangle]
2726
unsafe fn kernel_init() -> ! {
2827
use driver::interface::DriverManager;

14_exceptions_part2_peripheral_IRQs/README.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,19 @@ diff -uNr 13_integrated_testing/src/_arch/aarch64/exception.rs 14_exceptions_par
857857

858858
#[no_mangle]
859859

860+
diff -uNr 13_integrated_testing/src/_arch/aarch64/memory/mmu.rs 14_exceptions_part2_peripheral_IRQs/src/_arch/aarch64/memory/mmu.rs
861+
--- 13_integrated_testing/src/_arch/aarch64/memory/mmu.rs
862+
+++ 14_exceptions_part2_peripheral_IRQs/src/_arch/aarch64/memory/mmu.rs
863+
@@ -149,7 +149,7 @@
864+
barrier::isb(barrier::SY);
865+
866+
// Enable the MMU and turn on data and instruction caching.
867+
- SCTLR_EL1.modify(SCTLR_EL1::M::Enable + SCTLR_EL1::C::Cacheable + SCTLR_EL1::I::Cacheable);
868+
+ SCTLR_EL1.modify(SCTLR_EL1::M::Enable);
869+
870+
// Force MMU init to complete before next instruction.
871+
barrier::isb(barrier::SY);
872+
860873
diff -uNr 13_integrated_testing/src/bsp/device_driver/arm/gicv2/gicc.rs 14_exceptions_part2_peripheral_IRQs/src/bsp/device_driver/arm/gicv2/gicc.rs
861874
--- 13_integrated_testing/src/bsp/device_driver/arm/gicv2/gicc.rs
862875
+++ 14_exceptions_part2_peripheral_IRQs/src/bsp/device_driver/arm/gicv2/gicc.rs
@@ -2325,18 +2338,16 @@ diff -uNr 13_integrated_testing/src/main.rs 14_exceptions_part2_peripheral_IRQs/
23252338

23262339
/// Early init code.
23272340
///
2328-
@@ -21,8 +21,8 @@
2341+
@@ -21,7 +21,7 @@
23292342
/// - The init calls in this function must appear in the correct order:
2330-
/// - Caching must be activated before the device drivers.
2331-
/// - Without it, any atomic operations, e.g. the yet-to-be-introduced spinlocks in the device
2332-
-/// drivers (which currently employ NullLocks instead of spinlocks), will fail to work on
2333-
-/// the RPi SoCs.
2334-
+/// drivers (which currently employ IRQSafeNullLocks instead of spinlocks), will fail to
2335-
+/// work on the RPi SoCs.
2343+
/// - MMU + Data caching must be activated at the earliest. Without it, any atomic operations,
2344+
/// e.g. the yet-to-be-introduced spinlocks in the device drivers (which currently employ
2345+
-/// NullLocks instead of spinlocks), will fail to work (properly) on the RPi SoCs.
2346+
+/// IRQSafeNullLocks instead of spinlocks), will fail to work (properly) on the RPi SoCs.
23362347
#[no_mangle]
23372348
unsafe fn kernel_init() -> ! {
23382349
use driver::interface::DriverManager;
2339-
@@ -42,15 +42,27 @@
2350+
@@ -41,15 +41,27 @@
23402351
bsp::driver::driver_manager().post_device_driver_init();
23412352
// println! is usable from here on.
23422353

@@ -2366,7 +2377,7 @@ diff -uNr 13_integrated_testing/src/main.rs 14_exceptions_part2_peripheral_IRQs/
23662377

23672378
info!("Booting on: {}", bsp::board_name());
23682379

2369-
@@ -77,12 +89,9 @@
2380+
@@ -76,12 +88,9 @@
23702381
info!(" {}. {}", i + 1, driver.compatible());
23712382
}
23722383

14_exceptions_part2_peripheral_IRQs/src/_arch/aarch64/memory/mmu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl memory::mmu::interface::MMU for MemoryManagementUnit {
149149
barrier::isb(barrier::SY);
150150

151151
// Enable the MMU and turn on data and instruction caching.
152-
SCTLR_EL1.modify(SCTLR_EL1::M::Enable + SCTLR_EL1::C::Cacheable + SCTLR_EL1::I::Cacheable);
152+
SCTLR_EL1.modify(SCTLR_EL1::M::Enable);
153153

154154
// Force MMU init to complete before next instruction.
155155
barrier::isb(barrier::SY);

14_exceptions_part2_peripheral_IRQs/src/main.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ use libkernel::{bsp, cpu, driver, exception, info, memory, state, time, warn};
1919
///
2020
/// - Only a single core must be active and running this function.
2121
/// - The init calls in this function must appear in the correct order:
22-
/// - Caching must be activated before the device drivers.
23-
/// - Without it, any atomic operations, e.g. the yet-to-be-introduced spinlocks in the device
24-
/// drivers (which currently employ IRQSafeNullLocks instead of spinlocks), will fail to
25-
/// work on the RPi SoCs.
22+
/// - MMU + Data caching must be activated at the earliest. Without it, any atomic operations,
23+
/// e.g. the yet-to-be-introduced spinlocks in the device drivers (which currently employ
24+
/// IRQSafeNullLocks instead of spinlocks), will fail to work (properly) on the RPi SoCs.
2625
#[no_mangle]
2726
unsafe fn kernel_init() -> ! {
2827
use driver::interface::DriverManager;

15_virtual_mem_part2_mmio_remap/README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,15 @@ diff -uNr 14_exceptions_part2_peripheral_IRQs/src/_arch/aarch64/memory/mmu.rs 15
805805

806806
self.configure_translation_control();
807807

808+
@@ -149,7 +140,7 @@
809+
barrier::isb(barrier::SY);
810+
811+
// Enable the MMU and turn on data and instruction caching.
812+
- SCTLR_EL1.modify(SCTLR_EL1::M::Enable);
813+
+ SCTLR_EL1.modify(SCTLR_EL1::M::Enable + SCTLR_EL1::C::Cacheable + SCTLR_EL1::I::Cacheable);
814+
815+
// Force MMU init to complete before next instruction.
816+
barrier::isb(barrier::SY);
808817
@@ -162,22 +153,3 @@
809818
SCTLR_EL1.matches_all(SCTLR_EL1::M::Enable)
810819
}
@@ -1800,7 +1809,7 @@ diff -uNr 14_exceptions_part2_peripheral_IRQs/src/bsp/raspberrypi/memory.rs 15_v
18001809
+//! | .got |
18011810
+//! | | rx_end_inclusive
18021811
+//! +---------------------------------------------+
1803-
+//! | | rw_start == ro_end
1812+
+//! | | rw_start == rx_end
18041813
+//! | .data |
18051814
+//! | .bss |
18061815
+//! | | rw_end_inclusive
@@ -2150,7 +2159,7 @@ diff -uNr 14_exceptions_part2_peripheral_IRQs/src/lib.rs 15_virtual_mem_part2_mm
21502159
diff -uNr 14_exceptions_part2_peripheral_IRQs/src/main.rs 15_virtual_mem_part2_mmio_remap/src/main.rs
21512160
--- 14_exceptions_part2_peripheral_IRQs/src/main.rs
21522161
+++ 15_virtual_mem_part2_mmio_remap/src/main.rs
2153-
@@ -26,21 +26,39 @@
2162+
@@ -25,21 +25,39 @@
21542163
#[no_mangle]
21552164
unsafe fn kernel_init() -> ! {
21562165
use driver::interface::DriverManager;
@@ -2196,7 +2205,7 @@ diff -uNr 14_exceptions_part2_peripheral_IRQs/src/main.rs 15_virtual_mem_part2_m
21962205

21972206
// Let device drivers register and enable their handlers with the interrupt controller.
21982207
for i in bsp::driver::driver_manager().all_device_drivers() {
2199-
@@ -66,8 +84,8 @@
2208+
@@ -65,8 +83,8 @@
22002209

22012210
info!("Booting on: {}", bsp::board_name());
22022211

15_virtual_mem_part2_mmio_remap/src/main.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ use libkernel::{bsp, cpu, driver, exception, info, memory, state, time, warn};
1919
///
2020
/// - Only a single core must be active and running this function.
2121
/// - The init calls in this function must appear in the correct order:
22-
/// - Caching must be activated before the device drivers.
23-
/// - Without it, any atomic operations, e.g. the yet-to-be-introduced spinlocks in the device
24-
/// drivers (which currently employ IRQSafeNullLocks instead of spinlocks), will fail to
25-
/// work on the RPi SoCs.
22+
/// - MMU + Data caching must be activated at the earliest. Without it, any atomic operations,
23+
/// e.g. the yet-to-be-introduced spinlocks in the device drivers (which currently employ
24+
/// IRQSafeNullLocks instead of spinlocks), will fail to work (properly) on the RPi SoCs.
2625
#[no_mangle]
2726
unsafe fn kernel_init() -> ! {
2827
use driver::interface::DriverManager;

0 commit comments

Comments
 (0)