Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f6190f8

Browse files
ASM: Remove use of .equ
The LLVM assembler apparently causes the .equ directive to create symbols instead of just a local and temporary variable. Work around this by using const operands with global_asm!.
1 parent f0b7f81 commit f6190f8

File tree

68 files changed

+244
-182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+244
-182
lines changed

‎01_wait_forever/src/_arch/aarch64/cpu/boot.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@
1111
//!
1212
//! crate::cpu::boot::arch_boot
1313
14+
use core::arch::global_asm;
15+
1416
// Assembly counterpart to this file.
15-
core::arch::global_asm!(include_str!("boot.s"));
17+
global_asm!(include_str!("boot.s"));

‎02_runtime_init/README.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,15 @@ diff -uNr 01_wait_forever/Makefile 02_runtime_init/Makefile
6565
diff -uNr 01_wait_forever/src/_arch/aarch64/cpu/boot.rs 02_runtime_init/src/_arch/aarch64/cpu/boot.rs
6666
--- 01_wait_forever/src/_arch/aarch64/cpu/boot.rs
6767
+++ 02_runtime_init/src/_arch/aarch64/cpu/boot.rs
68-
@@ -13,3 +13,15 @@
68+
@@ -14,4 +14,19 @@
69+
use core::arch::global_asm;
6970

7071
// Assembly counterpart to this file.
71-
core::arch::global_asm!(include_str!("boot.s"));
72+
-global_asm!(include_str!("boot.s"));
73+
+global_asm!(
74+
+ include_str!("boot.s"),
75+
+ CONST_CORE_ID_MASK = const 0b11
76+
+);
7277
+
7378
+//--------------------------------------------------------------------------------------------------
7479
+// Public Code
@@ -85,7 +90,7 @@ diff -uNr 01_wait_forever/src/_arch/aarch64/cpu/boot.rs 02_runtime_init/src/_arc
8590
diff -uNr 01_wait_forever/src/_arch/aarch64/cpu/boot.s 02_runtime_init/src/_arch/aarch64/cpu/boot.s
8691
--- 01_wait_forever/src/_arch/aarch64/cpu/boot.s
8792
+++ 02_runtime_init/src/_arch/aarch64/cpu/boot.s
88-
@@ -3,6 +3,24 @@
93+
@@ -3,6 +3,22 @@
8994
// Copyright (c) 2021-2022 Andre Richter <andre.o.richter@gmail.com>
9095

9196
//--------------------------------------------------------------------------------------------------
@@ -104,19 +109,17 @@ diff -uNr 01_wait_forever/src/_arch/aarch64/cpu/boot.s 02_runtime_init/src/_arch
104109
+ add \register, \register, #:lo12:\symbol
105110
+.endm
106111
+
107-
+.equ _core_id_mask, 0b11
108-
+
109112
+//--------------------------------------------------------------------------------------------------
110113
// Public Code
111114
//--------------------------------------------------------------------------------------------------
112115
.section .text._start
113-
@@ -11,6 +29,34 @@
116+
@@ -11,6 +27,34 @@
114117
// fn _start()
115118
//------------------------------------------------------------------------------
116119
_start:
117120
+ // Only proceed on the boot core. Park it otherwise.
118121
+ mrs x1, MPIDR_EL1
119-
+ and x1, x1, _core_id_mask
122+
+ and x1, x1, {CONST_CORE_ID_MASK}
120123
+ ldr x2, BOOT_CORE_ID // provided by bsp/__board_name__/cpu.rs
121124
+ cmp x1, x2
122125
+ b.ne .L_parking_loop
@@ -302,15 +305,17 @@ diff -uNr 01_wait_forever/src/cpu.rs 02_runtime_init/src/cpu.rs
302305
diff -uNr 01_wait_forever/src/main.rs 02_runtime_init/src/main.rs
303306
--- 01_wait_forever/src/main.rs
304307
+++ 02_runtime_init/src/main.rs
305-
@@ -104,6 +104,7 @@
308+
@@ -104,7 +104,9 @@
306309
//!
307310
//! 1. The kernel's entry point is the function `cpu::boot::arch_boot::_start()`.
308311
//! - It is implemented in `src/_arch/__arch_name__/cpu/boot.s`.
309312
+//! 2. Once finished with architectural setup, the arch code calls `kernel_init()`.
310313

314+
+#![feature(asm_const)]
311315
#![no_main]
312316
#![no_std]
313-
@@ -112,4 +113,11 @@
317+
318+
@@ -112,4 +114,11 @@
314319
mod cpu;
315320
mod panic_wait;
316321

‎02_runtime_init/src/_arch/aarch64/cpu/boot.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@
1111
//!
1212
//! crate::cpu::boot::arch_boot
1313
14+
use core::arch::global_asm;
15+
1416
// Assembly counterpart to this file.
15-
core::arch::global_asm!(include_str!("boot.s"));
17+
global_asm!(
18+
include_str!("boot.s"),
19+
CONST_CORE_ID_MASK = const 0b11
20+
);
1621

1722
//--------------------------------------------------------------------------------------------------
1823
// Public Code

‎02_runtime_init/src/_arch/aarch64/cpu/boot.s

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
add \register, \register, #:lo12:\symbol
1919
.endm
2020

21-
.equ _core_id_mask, 0b11
22-
2321
//--------------------------------------------------------------------------------------------------
2422
// Public Code
2523
//--------------------------------------------------------------------------------------------------
@@ -31,7 +29,7 @@
3129
_start:
3230
// Only proceed on the boot core. Park it otherwise.
3331
mrs x1, MPIDR_EL1
34-
and x1, x1, _core_id_mask
32+
and x1, x1, {CONST_CORE_ID_MASK}
3533
ldr x2, BOOT_CORE_ID // provided by bsp/__board_name__/cpu.rs
3634
cmp x1, x2
3735
b.ne .L_parking_loop

‎02_runtime_init/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
//! - It is implemented in `src/_arch/__arch_name__/cpu/boot.s`.
107107
//! 2. Once finished with architectural setup, the arch code calls `kernel_init()`.
108108
109+
#![feature(asm_const)]
109110
#![no_main]
110111
#![no_std]
111112

‎03_hacky_hello_world/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,10 @@ diff -uNr 02_runtime_init/src/console.rs 03_hacky_hello_world/src/console.rs
212212
diff -uNr 02_runtime_init/src/main.rs 03_hacky_hello_world/src/main.rs
213213
--- 02_runtime_init/src/main.rs
214214
+++ 03_hacky_hello_world/src/main.rs
215-
@@ -106,12 +106,16 @@
216-
//! - It is implemented in `src/_arch/__arch_name__/cpu/boot.s`.
215+
@@ -107,12 +107,16 @@
217216
//! 2. Once finished with architectural setup, the arch code calls `kernel_init()`.
218217

218+
#![feature(asm_const)]
219219
+#![feature(format_args_nl)]
220220
+#![feature(panic_info_message)]
221221
#![no_main]
@@ -229,7 +229,7 @@ diff -uNr 02_runtime_init/src/main.rs 03_hacky_hello_world/src/main.rs
229229

230230
/// Early init code.
231231
///
232-
@@ -119,5 +123,7 @@
232+
@@ -120,5 +124,7 @@
233233
///
234234
/// - Only a single core must be active and running this function.
235235
unsafe fn kernel_init() -> ! {

‎03_hacky_hello_world/src/_arch/aarch64/cpu/boot.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@
1111
//!
1212
//! crate::cpu::boot::arch_boot
1313
14+
use core::arch::global_asm;
15+
1416
// Assembly counterpart to this file.
15-
core::arch::global_asm!(include_str!("boot.s"));
17+
global_asm!(
18+
include_str!("boot.s"),
19+
CONST_CORE_ID_MASK = const 0b11
20+
);
1621

1722
//--------------------------------------------------------------------------------------------------
1823
// Public Code

‎03_hacky_hello_world/src/_arch/aarch64/cpu/boot.s

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
add \register, \register, #:lo12:\symbol
1919
.endm
2020

21-
.equ _core_id_mask, 0b11
22-
2321
//--------------------------------------------------------------------------------------------------
2422
// Public Code
2523
//--------------------------------------------------------------------------------------------------
@@ -31,7 +29,7 @@
3129
_start:
3230
// Only proceed on the boot core. Park it otherwise.
3331
mrs x1, MPIDR_EL1
34-
and x1, x1, _core_id_mask
32+
and x1, x1, {CONST_CORE_ID_MASK}
3533
ldr x2, BOOT_CORE_ID // provided by bsp/__board_name__/cpu.rs
3634
cmp x1, x2
3735
b.ne .L_parking_loop

‎03_hacky_hello_world/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
//! - It is implemented in `src/_arch/__arch_name__/cpu/boot.s`.
107107
//! 2. Once finished with architectural setup, the arch code calls `kernel_init()`.
108108
109+
#![feature(asm_const)]
109110
#![feature(format_args_nl)]
110111
#![feature(panic_info_message)]
111112
#![no_main]

‎04_safe_globals/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,23 +224,23 @@ diff -uNr 03_hacky_hello_world/src/console.rs 04_safe_globals/src/console.rs
224224
diff -uNr 03_hacky_hello_world/src/main.rs 04_safe_globals/src/main.rs
225225
--- 03_hacky_hello_world/src/main.rs
226226
+++ 04_safe_globals/src/main.rs
227-
@@ -108,6 +108,7 @@
228-
227+
@@ -109,6 +109,7 @@
228+
#![feature(asm_const)]
229229
#![feature(format_args_nl)]
230230
#![feature(panic_info_message)]
231231
+#![feature(trait_alias)]
232232
#![no_main]
233233
#![no_std]
234234

235-
@@ -116,6 +117,7 @@
235+
@@ -117,6 +118,7 @@
236236
mod cpu;
237237
mod panic_wait;
238238
mod print;
239239
+mod synchronization;
240240

241241
/// Early init code.
242242
///
243-
@@ -123,7 +125,15 @@
243+
@@ -124,7 +126,15 @@
244244
///
245245
/// - Only a single core must be active and running this function.
246246
unsafe fn kernel_init() -> ! {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /