reactos/ntoskrnl/ke/arm/trap.s

157 lines
3.7 KiB
ArmAsm
Raw Normal View History

/*
* PROJECT: ReactOS Kernel
* LICENSE: BSD - See COPYING.ARM in the top level directory
* FILE: ntoskrnl/ke/arm/trap.s
* PURPOSE: Support for exceptions and interrupts on ARM machines
* PROGRAMMERS: ReactOS Portable Systems Group
*/
#include <ksarm.h>
IMPORT KiUndefinedExceptionHandler
IMPORT KiSoftwareInterruptHandler
IMPORT KiPrefetchAbortHandler
IMPORT KiDataAbortHandler
IMPORT KiInterruptHandler
TEXTAREA
EXPORT KiArmVectorTable
KiArmVectorTable
b . // Reset
ldr pc, _KiUndefinedInstructionJump // Undefined Instruction
ldr pc, _KiSoftwareInterruptJump // Software Interrupt
ldr pc, _KiPrefetchAbortJump // Prefetch Abort
ldr pc, _KiDataAbortJump // Data Abort
b . // Reserved
ldr pc, _KiInterruptJump // Interrupt
ldr pc, _KiFastInterruptJump // Fast Interrupt
_KiUndefinedInstructionJump DCD KiUndefinedInstructionException
_KiSoftwareInterruptJump DCD KiSoftwareInterruptException
_KiPrefetchAbortJump DCD KiPrefetchAbortException
_KiDataAbortJump DCD KiDataAbortException
_KiInterruptJump DCD KiInterruptException
_KiFastInterruptJump DCD KiFastInterruptException
// Might need to move these to a custom header, when used by HAL as well
MACRO
TRAP_PROLOG $Abort
__debugbreak
MEND
MACRO
SYSCALL_PROLOG $Abort
__debugbreak
MEND
MACRO
TRAP_EPILOG $SystemCall
__debugbreak
MEND
NESTED_ENTRY KiUndefinedInstructionException
PROLOG_END KiUndefinedInstructionException
/* Handle trap entry */
TRAP_PROLOG 0 // NotFromAbort
/* Call the C handler */
ldr lr, =KiExceptionExit
mov r0, sp
ldr pc, =KiUndefinedExceptionHandler
NESTED_END KiUndefinedInstructionException
NESTED_ENTRY KiSoftwareInterruptException
PROLOG_END KiSoftwareInterruptException
/* Handle trap entry */
- Rewrite the low-level trap/exception/system call code from the ground up: - Do not corrupt the stack anymore - Use a consistent trap frame layout (enable OldIrql and PreviousMode, and set the 0xBADB0D00 debug mark) - Use slower but more correct trap prolog/epilog code for now. - Generalize all prolog/epilog code into macros just like on x86. As a result, traps are now 6 lines of code. - Rewrite the system call interface from the ground up: - System calls didn't actually work: a debug print made the stack layout magical enough so that they didn't normally crush, but only slowly ate the stack. - Copying arguments from caller to system call was, as the comment on the original code so aptly put it, "total shit". - Due to ABI concerns, and to provide an actual template on how you're -supposed- to implement something like system calls on RISC processors, we now use a model similar to BSD, but about ten times better (with that much less code too). We'll document it later on the RosPSG Wiki. - This code probably contains some of the most vile-yet-elegant macro magic ever written for such low-level code as system call dispatching. - The result of all this is that we're at the same place as before (RamdiskAddDevice needs to be implemented by the Ramdisk guys) but with a sane low-level backend that isn't slowly eating away the stack, corrupting data, and basically working through random chance. - Move timebase code from stubs.c to its own file, time.c. - Silence multiple debug prints and fix a corrupted debug print in KiSystemStartup. svn path=/trunk/; revision=34366
2008-07-08 09:11:44 +00:00
SYSCALL_PROLOG
/* Call the C handler */
ldr lr, =KiServiceExit
mov r0, sp
- Rewrite the low-level trap/exception/system call code from the ground up: - Do not corrupt the stack anymore - Use a consistent trap frame layout (enable OldIrql and PreviousMode, and set the 0xBADB0D00 debug mark) - Use slower but more correct trap prolog/epilog code for now. - Generalize all prolog/epilog code into macros just like on x86. As a result, traps are now 6 lines of code. - Rewrite the system call interface from the ground up: - System calls didn't actually work: a debug print made the stack layout magical enough so that they didn't normally crush, but only slowly ate the stack. - Copying arguments from caller to system call was, as the comment on the original code so aptly put it, "total shit". - Due to ABI concerns, and to provide an actual template on how you're -supposed- to implement something like system calls on RISC processors, we now use a model similar to BSD, but about ten times better (with that much less code too). We'll document it later on the RosPSG Wiki. - This code probably contains some of the most vile-yet-elegant macro magic ever written for such low-level code as system call dispatching. - The result of all this is that we're at the same place as before (RamdiskAddDevice needs to be implemented by the Ramdisk guys) but with a sane low-level backend that isn't slowly eating away the stack, corrupting data, and basically working through random chance. - Move timebase code from stubs.c to its own file, time.c. - Silence multiple debug prints and fix a corrupted debug print in KiSystemStartup. svn path=/trunk/; revision=34366
2008-07-08 09:11:44 +00:00
ldr pc, =KiSoftwareInterruptHandler
NESTED_END KiSoftwareInterruptException
NESTED_ENTRY KiPrefetchAbortException
PROLOG_END KiPrefetchAbortException
/* Handle trap entry */
TRAP_PROLOG 0 // NotFromAbort
/* Call the C handler */
ldr lr, =KiExceptionExit
mov r0, sp
ldr pc, =KiPrefetchAbortHandler
NESTED_END KiPrefetchAbortException
NESTED_ENTRY KiDataAbortException
PROLOG_END KiDataAbortException
/* Handle trap entry */
- Rewrite the low-level trap/exception/system call code from the ground up: - Do not corrupt the stack anymore - Use a consistent trap frame layout (enable OldIrql and PreviousMode, and set the 0xBADB0D00 debug mark) - Use slower but more correct trap prolog/epilog code for now. - Generalize all prolog/epilog code into macros just like on x86. As a result, traps are now 6 lines of code. - Rewrite the system call interface from the ground up: - System calls didn't actually work: a debug print made the stack layout magical enough so that they didn't normally crush, but only slowly ate the stack. - Copying arguments from caller to system call was, as the comment on the original code so aptly put it, "total shit". - Due to ABI concerns, and to provide an actual template on how you're -supposed- to implement something like system calls on RISC processors, we now use a model similar to BSD, but about ten times better (with that much less code too). We'll document it later on the RosPSG Wiki. - This code probably contains some of the most vile-yet-elegant macro magic ever written for such low-level code as system call dispatching. - The result of all this is that we're at the same place as before (RamdiskAddDevice needs to be implemented by the Ramdisk guys) but with a sane low-level backend that isn't slowly eating away the stack, corrupting data, and basically working through random chance. - Move timebase code from stubs.c to its own file, time.c. - Silence multiple debug prints and fix a corrupted debug print in KiSystemStartup. svn path=/trunk/; revision=34366
2008-07-08 09:11:44 +00:00
TRAP_PROLOG 1 // FromAbort
/* Call the C handler */
ldr lr, =KiExceptionExit
mov r0, sp
ldr pc, =KiDataAbortHandler
NESTED_END KiDataAbortException
NESTED_ENTRY KiInterruptException
PROLOG_END KiInterruptException
/* Handle trap entry */
- Rewrite the low-level trap/exception/system call code from the ground up: - Do not corrupt the stack anymore - Use a consistent trap frame layout (enable OldIrql and PreviousMode, and set the 0xBADB0D00 debug mark) - Use slower but more correct trap prolog/epilog code for now. - Generalize all prolog/epilog code into macros just like on x86. As a result, traps are now 6 lines of code. - Rewrite the system call interface from the ground up: - System calls didn't actually work: a debug print made the stack layout magical enough so that they didn't normally crush, but only slowly ate the stack. - Copying arguments from caller to system call was, as the comment on the original code so aptly put it, "total shit". - Due to ABI concerns, and to provide an actual template on how you're -supposed- to implement something like system calls on RISC processors, we now use a model similar to BSD, but about ten times better (with that much less code too). We'll document it later on the RosPSG Wiki. - This code probably contains some of the most vile-yet-elegant macro magic ever written for such low-level code as system call dispatching. - The result of all this is that we're at the same place as before (RamdiskAddDevice needs to be implemented by the Ramdisk guys) but with a sane low-level backend that isn't slowly eating away the stack, corrupting data, and basically working through random chance. - Move timebase code from stubs.c to its own file, time.c. - Silence multiple debug prints and fix a corrupted debug print in KiSystemStartup. svn path=/trunk/; revision=34366
2008-07-08 09:11:44 +00:00
TRAP_PROLOG 0 // NotFromAbort
/* Call the C handler */
ldr lr, =KiExceptionExit
mov r0, sp
mov r1, #0
ldr pc, =KiInterruptHandler
NESTED_END KiInterruptException
NESTED_ENTRY KiFastInterruptException
PROLOG_END KiFastInterruptException
// FIXME-PERF: Implement FIQ exception
__debugbreak
NESTED_END KiFastInterruptException
NESTED_ENTRY KiExceptionExit
PROLOG_END KiExceptionExit
/* Handle trap exit */
TRAP_EPILOG 0 // NotFromSystemCall
NESTED_END KiExceptionExit
NESTED_ENTRY KiServiceExit
PROLOG_END KiServiceExit
/* Handle trap exit */
TRAP_EPILOG 1 // FromSystemCall
NESTED_END KiServiceExit
LEAF_ENTRY KiInterruptTemplate
DCD 0
LEAF_END KiInterruptTemplate
END
/* EOF */