Skip to content

Commit dfff928

Browse files
authored
Merge pull request #2094 from hermit-os/arch-scheduler-fn-ptr
fix(arch/scheduler): don't cast task_start to pointer
2 parents c26afdd + bddee3b commit dfff928

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/arch/aarch64/kernel/scheduler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub(crate) struct State {
2525
/// stack selector
2626
pub spsel: u64,
2727
/// Exception Link Register
28-
pub elr_el1: u64,
28+
pub elr_el1: extern "C" fn(extern "C" fn(usize), usize) -> !,
2929
/// Program Status Register
3030
pub spsr_el1: u64,
3131
/// User-level stack
@@ -317,7 +317,7 @@ impl TaskFrame for Task {
317317
* The elr_el1 needs to hold the address of the
318318
* first function to be called when returning from exception handler.
319319
*/
320-
(*state).elr_el1 = task_start as *const () as usize as u64;
320+
(*state).elr_el1 = task_start;
321321
(*state).x0 = func as usize as u64; // use second argument to transfer the entry point
322322
(*state).x1 = arg as u64;
323323
(*state).spsel = 1;

src/arch/riscv64/kernel/scheduler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::{DEFAULT_STACK_SIZE, KERNEL_STACK_SIZE};
1515
#[derive(Clone, Copy, Debug)]
1616
pub struct State {
1717
/// return address register
18-
ra: usize,
18+
ra: unsafe extern "C" fn(extern "C" fn(usize), usize, u64),
1919
/// stack pointer register
2020
sp: usize,
2121
/// global pointer register
@@ -331,7 +331,7 @@ impl TaskFrame for Task {
331331
if let Some(tls) = &self.tls {
332332
(*state).tp = tls.thread_ptr() as usize;
333333
}
334-
(*state).ra = task_start as *const () as usize;
334+
(*state).ra = task_start;
335335
(*state).a0 = func as usize;
336336
(*state).a1 = arg;
337337

src/arch/x86_64/kernel/scheduler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct State {
5959
/// status flags
6060
rflags: u64,
6161
/// instruction pointer
62-
rip: u64,
62+
rip: extern "C" fn(extern "C" fn(usize), usize, u64) -> !,
6363
}
6464

6565
pub struct BootStack {
@@ -303,7 +303,7 @@ impl TaskFrame for Task {
303303
if let Some(tls) = &self.tls {
304304
(*state).fs = tls.thread_ptr().addr() as u64;
305305
}
306-
(*state).rip = task_start as *const () as usize as u64;
306+
(*state).rip = task_start;
307307
(*state).rdi = func as usize as u64;
308308
(*state).rsi = arg as u64;
309309

0 commit comments

Comments
 (0)