From bb2f1c79b7cc61c528d0ed0bb40597e88cff814b Mon Sep 17 00:00:00 2001 From: Andre Richter Date: Thu, 19 May 2022 23:19:25 +0200 Subject: [PATCH] Remove more unjustified unsafe --- 11_exceptions_part1_groundwork/README.md | 28 +++++++++---------- .../src/_arch/aarch64/exception.rs | 24 ++++++++-------- .../kernel/src/_arch/aarch64/exception.rs | 24 ++++++++-------- 13_exceptions_part2_peripheral_IRQs/README.md | 10 +++---- .../kernel/src/_arch/aarch64/exception.rs | 26 ++++++++--------- .../kernel/src/_arch/aarch64/exception.rs | 26 ++++++++--------- .../kernel/src/_arch/aarch64/exception.rs | 26 ++++++++--------- .../kernel/src/_arch/aarch64/exception.rs | 26 ++++++++--------- .../kernel/src/_arch/aarch64/exception.rs | 26 ++++++++--------- .../kernel/src/_arch/aarch64/exception.rs | 26 ++++++++--------- .../kernel/src/_arch/aarch64/exception.rs | 26 ++++++++--------- 11 files changed, 134 insertions(+), 134 deletions(-) diff --git a/11_exceptions_part1_groundwork/README.md b/11_exceptions_part1_groundwork/README.md index d0b4b7f7..4fc713a5 100644 --- a/11_exceptions_part1_groundwork/README.md +++ b/11_exceptions_part1_groundwork/README.md @@ -328,7 +328,7 @@ The actual handlers referenced from the assembly can now branch to it for the ti ```rust #[no_mangle] -unsafe extern "C" fn current_elx_irq(e: &mut ExceptionContext) { +extern "C" fn current_elx_irq(e: &mut ExceptionContext) { default_exception_handler(e); } ``` @@ -367,7 +367,7 @@ To survive this exception, the respective handler has a special demo case: ```rust #[no_mangle] -unsafe extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { +extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { if e.fault_address_valid() { let far_el1 = FAR_EL1.get(); @@ -565,17 +565,17 @@ diff -uNr 10_virtual_mem_part1_identity_mapping/src/_arch/aarch64/exception.rs 1 +//------------------------------------------------------------------------------ + +#[no_mangle] -+unsafe extern "C" fn current_el0_synchronous(_e: &mut ExceptionContext) { ++extern "C" fn current_el0_synchronous(_e: &mut ExceptionContext) { + panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") +} + +#[no_mangle] -+unsafe extern "C" fn current_el0_irq(_e: &mut ExceptionContext) { ++extern "C" fn current_el0_irq(_e: &mut ExceptionContext) { + panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") +} + +#[no_mangle] -+unsafe extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { ++extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { + panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") +} + @@ -584,7 +584,7 @@ diff -uNr 10_virtual_mem_part1_identity_mapping/src/_arch/aarch64/exception.rs 1 +//------------------------------------------------------------------------------ + +#[no_mangle] -+unsafe extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { ++extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { + if e.fault_address_valid() { + let far_el1 = FAR_EL1.get(); + @@ -601,12 +601,12 @@ diff -uNr 10_virtual_mem_part1_identity_mapping/src/_arch/aarch64/exception.rs 1 +} + +#[no_mangle] -+unsafe extern "C" fn current_elx_irq(e: &mut ExceptionContext) { ++extern "C" fn current_elx_irq(e: &mut ExceptionContext) { + default_exception_handler(e); +} + +#[no_mangle] -+unsafe extern "C" fn current_elx_serror(e: &mut ExceptionContext) { ++extern "C" fn current_elx_serror(e: &mut ExceptionContext) { + default_exception_handler(e); +} + @@ -615,17 +615,17 @@ diff -uNr 10_virtual_mem_part1_identity_mapping/src/_arch/aarch64/exception.rs 1 +//------------------------------------------------------------------------------ + +#[no_mangle] -+unsafe extern "C" fn lower_aarch64_synchronous(e: &mut ExceptionContext) { ++extern "C" fn lower_aarch64_synchronous(e: &mut ExceptionContext) { + default_exception_handler(e); +} + +#[no_mangle] -+unsafe extern "C" fn lower_aarch64_irq(e: &mut ExceptionContext) { ++extern "C" fn lower_aarch64_irq(e: &mut ExceptionContext) { + default_exception_handler(e); +} + +#[no_mangle] -+unsafe extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { ++extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { + default_exception_handler(e); +} + @@ -634,17 +634,17 @@ diff -uNr 10_virtual_mem_part1_identity_mapping/src/_arch/aarch64/exception.rs 1 +//------------------------------------------------------------------------------ + +#[no_mangle] -+unsafe extern "C" fn lower_aarch32_synchronous(e: &mut ExceptionContext) { ++extern "C" fn lower_aarch32_synchronous(e: &mut ExceptionContext) { + default_exception_handler(e); +} + +#[no_mangle] -+unsafe extern "C" fn lower_aarch32_irq(e: &mut ExceptionContext) { ++extern "C" fn lower_aarch32_irq(e: &mut ExceptionContext) { + default_exception_handler(e); +} + +#[no_mangle] -+unsafe extern "C" fn lower_aarch32_serror(e: &mut ExceptionContext) { ++extern "C" fn lower_aarch32_serror(e: &mut ExceptionContext) { + default_exception_handler(e); +} + diff --git a/11_exceptions_part1_groundwork/src/_arch/aarch64/exception.rs b/11_exceptions_part1_groundwork/src/_arch/aarch64/exception.rs index 7d3b4572..c72fb885 100644 --- a/11_exceptions_part1_groundwork/src/_arch/aarch64/exception.rs +++ b/11_exceptions_part1_groundwork/src/_arch/aarch64/exception.rs @@ -67,17 +67,17 @@ fn default_exception_handler(exc: &ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn current_el0_synchronous(_e: &mut ExceptionContext) { +extern "C" fn current_el0_synchronous(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } #[no_mangle] -unsafe extern "C" fn current_el0_irq(_e: &mut ExceptionContext) { +extern "C" fn current_el0_irq(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } #[no_mangle] -unsafe extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { +extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } @@ -86,7 +86,7 @@ unsafe extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { +extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { if e.fault_address_valid() { let far_el1 = FAR_EL1.get(); @@ -103,12 +103,12 @@ unsafe extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { } #[no_mangle] -unsafe extern "C" fn current_elx_irq(e: &mut ExceptionContext) { +extern "C" fn current_elx_irq(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn current_elx_serror(e: &mut ExceptionContext) { +extern "C" fn current_elx_serror(e: &mut ExceptionContext) { default_exception_handler(e); } @@ -117,17 +117,17 @@ unsafe extern "C" fn current_elx_serror(e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn lower_aarch64_synchronous(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_synchronous(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch64_irq(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_irq(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { default_exception_handler(e); } @@ -136,17 +136,17 @@ unsafe extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn lower_aarch32_synchronous(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_synchronous(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch32_irq(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_irq(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch32_serror(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_serror(e: &mut ExceptionContext) { default_exception_handler(e); } diff --git a/12_integrated_testing/kernel/src/_arch/aarch64/exception.rs b/12_integrated_testing/kernel/src/_arch/aarch64/exception.rs index 0f83052c..5664605e 100644 --- a/12_integrated_testing/kernel/src/_arch/aarch64/exception.rs +++ b/12_integrated_testing/kernel/src/_arch/aarch64/exception.rs @@ -67,17 +67,17 @@ fn default_exception_handler(exc: &ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn current_el0_synchronous(_e: &mut ExceptionContext) { +extern "C" fn current_el0_synchronous(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } #[no_mangle] -unsafe extern "C" fn current_el0_irq(_e: &mut ExceptionContext) { +extern "C" fn current_el0_irq(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } #[no_mangle] -unsafe extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { +extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } @@ -86,7 +86,7 @@ unsafe extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { +extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { #[cfg(feature = "test_build")] { const TEST_SVC_ID: u64 = 0x1337; @@ -102,12 +102,12 @@ unsafe extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { } #[no_mangle] -unsafe extern "C" fn current_elx_irq(e: &mut ExceptionContext) { +extern "C" fn current_elx_irq(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn current_elx_serror(e: &mut ExceptionContext) { +extern "C" fn current_elx_serror(e: &mut ExceptionContext) { default_exception_handler(e); } @@ -116,17 +116,17 @@ unsafe extern "C" fn current_elx_serror(e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn lower_aarch64_synchronous(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_synchronous(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch64_irq(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_irq(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { default_exception_handler(e); } @@ -135,17 +135,17 @@ unsafe extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn lower_aarch32_synchronous(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_synchronous(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch32_irq(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_irq(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch32_serror(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_serror(e: &mut ExceptionContext) { default_exception_handler(e); } diff --git a/13_exceptions_part2_peripheral_IRQs/README.md b/13_exceptions_part2_peripheral_IRQs/README.md index 65be428a..74eb28c3 100644 --- a/13_exceptions_part2_peripheral_IRQs/README.md +++ b/13_exceptions_part2_peripheral_IRQs/README.md @@ -367,8 +367,8 @@ the the implementation of the trait's handling function: ```rust #[no_mangle] -unsafe extern "C" fn current_elx_irq(_e: &mut ExceptionContext) { - let token = &exception::asynchronous::IRQContext::new(); +extern "C" fn current_elx_irq(_e: &mut ExceptionContext) { + let token = unsafe { &exception::asynchronous::IRQContext::new() }; exception::asynchronous::irq_manager().handle_pending_irqs(token); } ``` @@ -887,10 +887,10 @@ diff -uNr 12_integrated_testing/kernel/src/_arch/aarch64/exception.rs 13_excepti } #[no_mangle] --unsafe extern "C" fn current_elx_irq(e: &mut ExceptionContext) { +-extern "C" fn current_elx_irq(e: &mut ExceptionContext) { - default_exception_handler(e); -+unsafe extern "C" fn current_elx_irq(_e: &mut ExceptionContext) { -+ let token = &exception::asynchronous::IRQContext::new(); ++extern "C" fn current_elx_irq(_e: &mut ExceptionContext) { ++ let token = unsafe { &exception::asynchronous::IRQContext::new() }; + exception::asynchronous::irq_manager().handle_pending_irqs(token); } diff --git a/13_exceptions_part2_peripheral_IRQs/kernel/src/_arch/aarch64/exception.rs b/13_exceptions_part2_peripheral_IRQs/kernel/src/_arch/aarch64/exception.rs index fa6748a6..3aa6fb24 100644 --- a/13_exceptions_part2_peripheral_IRQs/kernel/src/_arch/aarch64/exception.rs +++ b/13_exceptions_part2_peripheral_IRQs/kernel/src/_arch/aarch64/exception.rs @@ -68,17 +68,17 @@ fn default_exception_handler(exc: &ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn current_el0_synchronous(_e: &mut ExceptionContext) { +extern "C" fn current_el0_synchronous(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } #[no_mangle] -unsafe extern "C" fn current_el0_irq(_e: &mut ExceptionContext) { +extern "C" fn current_el0_irq(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } #[no_mangle] -unsafe extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { +extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } @@ -87,7 +87,7 @@ unsafe extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { +extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { #[cfg(feature = "test_build")] { const TEST_SVC_ID: u64 = 0x1337; @@ -103,13 +103,13 @@ unsafe extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { } #[no_mangle] -unsafe extern "C" fn current_elx_irq(_e: &mut ExceptionContext) { - let token = &exception::asynchronous::IRQContext::new(); +extern "C" fn current_elx_irq(_e: &mut ExceptionContext) { + let token = unsafe { &exception::asynchronous::IRQContext::new() }; exception::asynchronous::irq_manager().handle_pending_irqs(token); } #[no_mangle] -unsafe extern "C" fn current_elx_serror(e: &mut ExceptionContext) { +extern "C" fn current_elx_serror(e: &mut ExceptionContext) { default_exception_handler(e); } @@ -118,17 +118,17 @@ unsafe extern "C" fn current_elx_serror(e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn lower_aarch64_synchronous(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_synchronous(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch64_irq(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_irq(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { default_exception_handler(e); } @@ -137,17 +137,17 @@ unsafe extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn lower_aarch32_synchronous(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_synchronous(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch32_irq(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_irq(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch32_serror(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_serror(e: &mut ExceptionContext) { default_exception_handler(e); } diff --git a/14_virtual_mem_part2_mmio_remap/kernel/src/_arch/aarch64/exception.rs b/14_virtual_mem_part2_mmio_remap/kernel/src/_arch/aarch64/exception.rs index fa6748a6..3aa6fb24 100644 --- a/14_virtual_mem_part2_mmio_remap/kernel/src/_arch/aarch64/exception.rs +++ b/14_virtual_mem_part2_mmio_remap/kernel/src/_arch/aarch64/exception.rs @@ -68,17 +68,17 @@ fn default_exception_handler(exc: &ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn current_el0_synchronous(_e: &mut ExceptionContext) { +extern "C" fn current_el0_synchronous(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } #[no_mangle] -unsafe extern "C" fn current_el0_irq(_e: &mut ExceptionContext) { +extern "C" fn current_el0_irq(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } #[no_mangle] -unsafe extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { +extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } @@ -87,7 +87,7 @@ unsafe extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { +extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { #[cfg(feature = "test_build")] { const TEST_SVC_ID: u64 = 0x1337; @@ -103,13 +103,13 @@ unsafe extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { } #[no_mangle] -unsafe extern "C" fn current_elx_irq(_e: &mut ExceptionContext) { - let token = &exception::asynchronous::IRQContext::new(); +extern "C" fn current_elx_irq(_e: &mut ExceptionContext) { + let token = unsafe { &exception::asynchronous::IRQContext::new() }; exception::asynchronous::irq_manager().handle_pending_irqs(token); } #[no_mangle] -unsafe extern "C" fn current_elx_serror(e: &mut ExceptionContext) { +extern "C" fn current_elx_serror(e: &mut ExceptionContext) { default_exception_handler(e); } @@ -118,17 +118,17 @@ unsafe extern "C" fn current_elx_serror(e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn lower_aarch64_synchronous(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_synchronous(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch64_irq(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_irq(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { default_exception_handler(e); } @@ -137,17 +137,17 @@ unsafe extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn lower_aarch32_synchronous(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_synchronous(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch32_irq(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_irq(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch32_serror(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_serror(e: &mut ExceptionContext) { default_exception_handler(e); } diff --git a/15_virtual_mem_part3_precomputed_tables/kernel/src/_arch/aarch64/exception.rs b/15_virtual_mem_part3_precomputed_tables/kernel/src/_arch/aarch64/exception.rs index fa6748a6..3aa6fb24 100644 --- a/15_virtual_mem_part3_precomputed_tables/kernel/src/_arch/aarch64/exception.rs +++ b/15_virtual_mem_part3_precomputed_tables/kernel/src/_arch/aarch64/exception.rs @@ -68,17 +68,17 @@ fn default_exception_handler(exc: &ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn current_el0_synchronous(_e: &mut ExceptionContext) { +extern "C" fn current_el0_synchronous(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } #[no_mangle] -unsafe extern "C" fn current_el0_irq(_e: &mut ExceptionContext) { +extern "C" fn current_el0_irq(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } #[no_mangle] -unsafe extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { +extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } @@ -87,7 +87,7 @@ unsafe extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { +extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { #[cfg(feature = "test_build")] { const TEST_SVC_ID: u64 = 0x1337; @@ -103,13 +103,13 @@ unsafe extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { } #[no_mangle] -unsafe extern "C" fn current_elx_irq(_e: &mut ExceptionContext) { - let token = &exception::asynchronous::IRQContext::new(); +extern "C" fn current_elx_irq(_e: &mut ExceptionContext) { + let token = unsafe { &exception::asynchronous::IRQContext::new() }; exception::asynchronous::irq_manager().handle_pending_irqs(token); } #[no_mangle] -unsafe extern "C" fn current_elx_serror(e: &mut ExceptionContext) { +extern "C" fn current_elx_serror(e: &mut ExceptionContext) { default_exception_handler(e); } @@ -118,17 +118,17 @@ unsafe extern "C" fn current_elx_serror(e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn lower_aarch64_synchronous(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_synchronous(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch64_irq(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_irq(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { default_exception_handler(e); } @@ -137,17 +137,17 @@ unsafe extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn lower_aarch32_synchronous(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_synchronous(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch32_irq(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_irq(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch32_serror(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_serror(e: &mut ExceptionContext) { default_exception_handler(e); } diff --git a/16_virtual_mem_part4_higher_half_kernel/kernel/src/_arch/aarch64/exception.rs b/16_virtual_mem_part4_higher_half_kernel/kernel/src/_arch/aarch64/exception.rs index fa6748a6..3aa6fb24 100644 --- a/16_virtual_mem_part4_higher_half_kernel/kernel/src/_arch/aarch64/exception.rs +++ b/16_virtual_mem_part4_higher_half_kernel/kernel/src/_arch/aarch64/exception.rs @@ -68,17 +68,17 @@ fn default_exception_handler(exc: &ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn current_el0_synchronous(_e: &mut ExceptionContext) { +extern "C" fn current_el0_synchronous(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } #[no_mangle] -unsafe extern "C" fn current_el0_irq(_e: &mut ExceptionContext) { +extern "C" fn current_el0_irq(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } #[no_mangle] -unsafe extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { +extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } @@ -87,7 +87,7 @@ unsafe extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { +extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { #[cfg(feature = "test_build")] { const TEST_SVC_ID: u64 = 0x1337; @@ -103,13 +103,13 @@ unsafe extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { } #[no_mangle] -unsafe extern "C" fn current_elx_irq(_e: &mut ExceptionContext) { - let token = &exception::asynchronous::IRQContext::new(); +extern "C" fn current_elx_irq(_e: &mut ExceptionContext) { + let token = unsafe { &exception::asynchronous::IRQContext::new() }; exception::asynchronous::irq_manager().handle_pending_irqs(token); } #[no_mangle] -unsafe extern "C" fn current_elx_serror(e: &mut ExceptionContext) { +extern "C" fn current_elx_serror(e: &mut ExceptionContext) { default_exception_handler(e); } @@ -118,17 +118,17 @@ unsafe extern "C" fn current_elx_serror(e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn lower_aarch64_synchronous(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_synchronous(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch64_irq(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_irq(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { default_exception_handler(e); } @@ -137,17 +137,17 @@ unsafe extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn lower_aarch32_synchronous(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_synchronous(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch32_irq(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_irq(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch32_serror(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_serror(e: &mut ExceptionContext) { default_exception_handler(e); } diff --git a/17_kernel_symbols/kernel/src/_arch/aarch64/exception.rs b/17_kernel_symbols/kernel/src/_arch/aarch64/exception.rs index 3672466c..1d720f3e 100644 --- a/17_kernel_symbols/kernel/src/_arch/aarch64/exception.rs +++ b/17_kernel_symbols/kernel/src/_arch/aarch64/exception.rs @@ -68,17 +68,17 @@ fn default_exception_handler(exc: &ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn current_el0_synchronous(_e: &mut ExceptionContext) { +extern "C" fn current_el0_synchronous(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } #[no_mangle] -unsafe extern "C" fn current_el0_irq(_e: &mut ExceptionContext) { +extern "C" fn current_el0_irq(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } #[no_mangle] -unsafe extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { +extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } @@ -87,7 +87,7 @@ unsafe extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { +extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { #[cfg(feature = "test_build")] { const TEST_SVC_ID: u64 = 0x1337; @@ -103,13 +103,13 @@ unsafe extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { } #[no_mangle] -unsafe extern "C" fn current_elx_irq(_e: &mut ExceptionContext) { - let token = &exception::asynchronous::IRQContext::new(); +extern "C" fn current_elx_irq(_e: &mut ExceptionContext) { + let token = unsafe { &exception::asynchronous::IRQContext::new() }; exception::asynchronous::irq_manager().handle_pending_irqs(token); } #[no_mangle] -unsafe extern "C" fn current_elx_serror(e: &mut ExceptionContext) { +extern "C" fn current_elx_serror(e: &mut ExceptionContext) { default_exception_handler(e); } @@ -118,17 +118,17 @@ unsafe extern "C" fn current_elx_serror(e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn lower_aarch64_synchronous(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_synchronous(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch64_irq(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_irq(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { default_exception_handler(e); } @@ -137,17 +137,17 @@ unsafe extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn lower_aarch32_synchronous(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_synchronous(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch32_irq(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_irq(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch32_serror(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_serror(e: &mut ExceptionContext) { default_exception_handler(e); } diff --git a/18_backtrace/kernel/src/_arch/aarch64/exception.rs b/18_backtrace/kernel/src/_arch/aarch64/exception.rs index 17ec3009..e03e382f 100644 --- a/18_backtrace/kernel/src/_arch/aarch64/exception.rs +++ b/18_backtrace/kernel/src/_arch/aarch64/exception.rs @@ -72,17 +72,17 @@ fn default_exception_handler(exc: &ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn current_el0_synchronous(_e: &mut ExceptionContext) { +extern "C" fn current_el0_synchronous(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } #[no_mangle] -unsafe extern "C" fn current_el0_irq(_e: &mut ExceptionContext) { +extern "C" fn current_el0_irq(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } #[no_mangle] -unsafe extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { +extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } @@ -91,7 +91,7 @@ unsafe extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { +extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { #[cfg(feature = "test_build")] { const TEST_SVC_ID: u64 = 0x1337; @@ -107,13 +107,13 @@ unsafe extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { } #[no_mangle] -unsafe extern "C" fn current_elx_irq(_e: &mut ExceptionContext) { - let token = &exception::asynchronous::IRQContext::new(); +extern "C" fn current_elx_irq(_e: &mut ExceptionContext) { + let token = unsafe { &exception::asynchronous::IRQContext::new() }; exception::asynchronous::irq_manager().handle_pending_irqs(token); } #[no_mangle] -unsafe extern "C" fn current_elx_serror(e: &mut ExceptionContext) { +extern "C" fn current_elx_serror(e: &mut ExceptionContext) { default_exception_handler(e); } @@ -122,17 +122,17 @@ unsafe extern "C" fn current_elx_serror(e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn lower_aarch64_synchronous(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_synchronous(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch64_irq(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_irq(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { default_exception_handler(e); } @@ -141,17 +141,17 @@ unsafe extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn lower_aarch32_synchronous(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_synchronous(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch32_irq(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_irq(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch32_serror(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_serror(e: &mut ExceptionContext) { default_exception_handler(e); } diff --git a/19_kernel_heap/kernel/src/_arch/aarch64/exception.rs b/19_kernel_heap/kernel/src/_arch/aarch64/exception.rs index 17ec3009..e03e382f 100644 --- a/19_kernel_heap/kernel/src/_arch/aarch64/exception.rs +++ b/19_kernel_heap/kernel/src/_arch/aarch64/exception.rs @@ -72,17 +72,17 @@ fn default_exception_handler(exc: &ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn current_el0_synchronous(_e: &mut ExceptionContext) { +extern "C" fn current_el0_synchronous(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } #[no_mangle] -unsafe extern "C" fn current_el0_irq(_e: &mut ExceptionContext) { +extern "C" fn current_el0_irq(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } #[no_mangle] -unsafe extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { +extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { panic!("Should not be here. Use of SP_EL0 in EL1 is not supported.") } @@ -91,7 +91,7 @@ unsafe extern "C" fn current_el0_serror(_e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { +extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { #[cfg(feature = "test_build")] { const TEST_SVC_ID: u64 = 0x1337; @@ -107,13 +107,13 @@ unsafe extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) { } #[no_mangle] -unsafe extern "C" fn current_elx_irq(_e: &mut ExceptionContext) { - let token = &exception::asynchronous::IRQContext::new(); +extern "C" fn current_elx_irq(_e: &mut ExceptionContext) { + let token = unsafe { &exception::asynchronous::IRQContext::new() }; exception::asynchronous::irq_manager().handle_pending_irqs(token); } #[no_mangle] -unsafe extern "C" fn current_elx_serror(e: &mut ExceptionContext) { +extern "C" fn current_elx_serror(e: &mut ExceptionContext) { default_exception_handler(e); } @@ -122,17 +122,17 @@ unsafe extern "C" fn current_elx_serror(e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn lower_aarch64_synchronous(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_synchronous(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch64_irq(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_irq(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { +extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { default_exception_handler(e); } @@ -141,17 +141,17 @@ unsafe extern "C" fn lower_aarch64_serror(e: &mut ExceptionContext) { //------------------------------------------------------------------------------ #[no_mangle] -unsafe extern "C" fn lower_aarch32_synchronous(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_synchronous(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch32_irq(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_irq(e: &mut ExceptionContext) { default_exception_handler(e); } #[no_mangle] -unsafe extern "C" fn lower_aarch32_serror(e: &mut ExceptionContext) { +extern "C" fn lower_aarch32_serror(e: &mut ExceptionContext) { default_exception_handler(e); }