2008-02-12 05:55:12 +00:00
|
|
|
|
2015-05-10 21:03:33 +00:00
|
|
|
#define ENABLE_FRAME_POINTER 1
|
|
|
|
|
|
|
|
#undef TRUE
|
|
|
|
//#define TRUE 1
|
|
|
|
#undef FALSE
|
|
|
|
//#define FALSE 0
|
|
|
|
|
|
|
|
//#include "kxarmunw.h"
|
2014-05-30 00:30:38 +00:00
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
|
|
|
/* Globals */
|
2015-05-10 21:03:33 +00:00
|
|
|
GBLS __FuncStartLabel
|
|
|
|
GBLS __FuncEpilog1StartLabel
|
|
|
|
GBLS __FuncEpilog2StartLabel
|
|
|
|
GBLS __FuncEpilog3StartLabel
|
|
|
|
GBLS __FuncEpilog4StartLabel
|
|
|
|
GBLS __FuncXDataLabel
|
|
|
|
GBLS __FuncXDataPrologLabel
|
|
|
|
GBLS __FuncXDataEpilog1Label
|
|
|
|
GBLS __FuncXDataEpilog2Label
|
|
|
|
GBLS __FuncXDataEpilog3Label
|
|
|
|
GBLS __FuncXDataEpilog4Label
|
|
|
|
GBLS __FuncXDataEndLabel
|
|
|
|
GBLS __FuncEndLabel
|
|
|
|
GBLS __FuncArea
|
|
|
|
GBLS __FuncExceptionHandler
|
|
|
|
|
|
|
|
MACRO
|
|
|
|
__DeriveFunctionLabels $FuncName
|
|
|
|
__FuncStartLabel SETS "|$FuncName|"
|
|
|
|
__FuncEndLabel SETS "|$FuncName._end|"
|
|
|
|
__FuncEpilog1StartLabel SETS "|$FuncName._epilog1_start|"
|
|
|
|
__FuncEpilog2StartLabel SETS "|$FuncName._epilog2_start|"
|
|
|
|
__FuncEpilog3StartLabel SETS "|$FuncName._epilog3_start|"
|
|
|
|
__FuncEpilog4StartLabel SETS "|$FuncName._epilog4_start|"
|
|
|
|
__FuncXDataLabel SETS "|$FuncName._xdata|"
|
|
|
|
__FuncXDataPrologLabel SETS "|$FuncName._xdata_prolog|"
|
|
|
|
__FuncXDataEpilog1Label SETS "|$FuncName._xdata_epilog1|"
|
|
|
|
__FuncXDataEpilog2Label SETS "|$FuncName._xdata_epilog2|"
|
|
|
|
__FuncXDataEpilog3Label SETS "|$FuncName._xdata_epilog3|"
|
|
|
|
__FuncXDataEpilog4Label SETS "|$FuncName._xdata_epilog4|"
|
|
|
|
__FuncXDataEndLabel SETS "|$FuncName._xdata_end|"
|
|
|
|
MEND
|
|
|
|
|
|
|
|
MACRO
|
|
|
|
__ExportName $FuncName
|
|
|
|
LCLS Name
|
|
|
|
Name SETS "|$FuncName|"
|
|
|
|
ALIGN 4
|
|
|
|
EXPORT $Name
|
|
|
|
$Name
|
|
|
|
MEND
|
|
|
|
|
|
|
|
MACRO
|
|
|
|
__ExportProc $FuncName
|
|
|
|
LCLS Name
|
|
|
|
Name SETS "|$FuncName|"
|
|
|
|
ALIGN 4
|
|
|
|
EXPORT $Name
|
|
|
|
$Name PROC
|
|
|
|
MEND
|
2014-05-30 00:30:38 +00:00
|
|
|
|
|
|
|
MACRO
|
|
|
|
TEXTAREA
|
2015-05-10 21:03:33 +00:00
|
|
|
#if defined(_CONTROL_FLOW_GUARD)
|
|
|
|
AREA |.text|,ALIGN=4,CODE,READONLY
|
|
|
|
#else
|
|
|
|
AREA |.text|,ALIGN=2,CODE,READONLY
|
|
|
|
#endif
|
|
|
|
MEND
|
|
|
|
|
|
|
|
MACRO
|
|
|
|
DATAAREA
|
|
|
|
AREA |.data|,DATA
|
|
|
|
MEND
|
|
|
|
|
|
|
|
MACRO
|
|
|
|
RODATAAREA
|
|
|
|
AREA |.rdata|,DATA,READONLY
|
2014-05-30 00:30:38 +00:00
|
|
|
MEND
|
|
|
|
|
|
|
|
MACRO
|
2015-05-10 21:03:33 +00:00
|
|
|
NESTED_ENTRY $FuncName, $AreaName, $ExceptHandler
|
|
|
|
__DeriveFunctionLabels $FuncName
|
|
|
|
__FuncArea SETS "|.text|"
|
|
|
|
IF "$AreaName" != ""
|
|
|
|
__FuncArea SETS "$AreaName"
|
|
|
|
ENDIF
|
|
|
|
__FuncExceptionHandler SETS ""
|
|
|
|
IF "$ExceptHandler" != ""
|
|
|
|
__FuncExceptionHandler SETS "|$ExceptHandler|"
|
|
|
|
ENDIF
|
|
|
|
AREA $__FuncArea,CODE,READONLY
|
|
|
|
__ExportProc $FuncName
|
|
|
|
ROUT
|
|
|
|
// __ResetUnwindState
|
2014-05-30 00:30:38 +00:00
|
|
|
MEND
|
|
|
|
|
2015-05-10 21:03:33 +00:00
|
|
|
// FIXME: this does not exist in native
|
2014-05-30 00:30:38 +00:00
|
|
|
MACRO
|
|
|
|
PROLOG_END
|
2015-05-10 21:03:33 +00:00
|
|
|
/* Ignore for now */
|
2014-05-30 00:30:38 +00:00
|
|
|
MEND
|
|
|
|
|
|
|
|
MACRO
|
2015-05-10 21:03:33 +00:00
|
|
|
NESTED_END $FuncName
|
|
|
|
$__FuncEndLabel
|
|
|
|
LTORG
|
|
|
|
ENDP
|
|
|
|
//AREA |.pdata|,ALIGN=2,READONLY
|
|
|
|
//DCD $__FuncStartLabel
|
|
|
|
//RELOC 2
|
|
|
|
//DCD $__FuncXDataLabel
|
|
|
|
//RELOC 2
|
|
|
|
//__EmitUnwindXData
|
|
|
|
//AREA $__FuncArea,CODE,READONLY
|
|
|
|
__FuncStartLabel SETS ""
|
|
|
|
__FuncEndLabel SETS ""
|
2014-05-30 00:30:38 +00:00
|
|
|
MEND
|
|
|
|
|
2015-05-10 21:03:33 +00:00
|
|
|
MACRO
|
|
|
|
LEAF_ENTRY $FuncName, $AreaName
|
|
|
|
NESTED_ENTRY $FuncName, $AreaName
|
|
|
|
MEND
|
2014-05-30 00:30:38 +00:00
|
|
|
|
|
|
|
MACRO
|
2015-05-10 21:03:33 +00:00
|
|
|
LEAF_END $FuncName
|
|
|
|
NESTED_END $FuncName
|
2014-05-30 00:30:38 +00:00
|
|
|
MEND
|
|
|
|
|
|
|
|
MACRO
|
2015-05-10 21:03:33 +00:00
|
|
|
LEAF_ENTRY_NO_PDATA $FuncName, $AreaName
|
|
|
|
__DeriveFunctionLabels $FuncName
|
|
|
|
__FuncArea SETS "|.text|"
|
|
|
|
IF "$AreaName" != ""
|
|
|
|
__FuncArea SETS "$AreaName"
|
|
|
|
ENDIF
|
|
|
|
AREA $__FuncArea,CODE,READONLY
|
|
|
|
__ExportProc $FuncName
|
|
|
|
ROUT
|
2014-05-30 00:30:38 +00:00
|
|
|
MEND
|
|
|
|
|
|
|
|
MACRO
|
2015-05-10 21:03:33 +00:00
|
|
|
LEAF_END_NO_PDATA $FuncName
|
|
|
|
$__FuncEndLabel
|
|
|
|
LTORG
|
|
|
|
ENDP
|
|
|
|
__FuncStartLabel SETS ""
|
|
|
|
__FuncEndLabel SETS ""
|
2014-05-30 00:30:38 +00:00
|
|
|
MEND
|
|
|
|
|
|
|
|
MACRO
|
2015-05-10 21:03:33 +00:00
|
|
|
ALTERNATE_ENTRY $FuncName
|
|
|
|
__ExportName $FuncName
|
|
|
|
ROUT
|
2014-05-30 00:30:38 +00:00
|
|
|
MEND
|
2015-04-11 12:47:29 +00:00
|
|
|
|
2015-05-10 21:03:33 +00:00
|
|
|
|
2014-10-23 09:22:45 +00:00
|
|
|
#define CR 13
|
|
|
|
#define LF 10
|
|
|
|
#define NUL 0
|
2015-04-11 12:47:29 +00:00
|
|
|
|
2014-10-23 09:22:45 +00:00
|
|
|
#define ASCII dcb
|
2015-04-11 12:47:29 +00:00
|
|
|
|
2014-10-23 09:22:45 +00:00
|
|
|
MACRO
|
|
|
|
UNIMPLEMENTED $Name
|
2015-04-11 12:47:29 +00:00
|
|
|
MEND
|
2014-05-30 00:30:38 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
/* Compatibility define */
|
|
|
|
#define EQU .equ
|
|
|
|
|
|
|
|
.macro IMPORT Name
|
|
|
|
/* Ignore */
|
|
|
|
.endm
|
|
|
|
|
2015-05-10 21:03:33 +00:00
|
|
|
.macro EXPORT Name
|
|
|
|
.global &Name
|
|
|
|
.endm
|
|
|
|
|
2008-02-12 05:55:12 +00:00
|
|
|
.macro TEXTAREA
|
2010-11-23 16:33:29 +00:00
|
|
|
.section .text, "rx"
|
2015-05-10 21:03:33 +00:00
|
|
|
#if defined(_CONTROL_FLOW_GUARD)
|
|
|
|
.align 4
|
|
|
|
#else
|
2008-02-12 05:55:12 +00:00
|
|
|
.align 2
|
2015-05-10 21:03:33 +00:00
|
|
|
#endif
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro DATAAREA
|
|
|
|
.section .data, "rw"
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro RODATAAREA
|
|
|
|
.section .rdata, "rw"
|
2008-02-12 05:55:12 +00:00
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro NESTED_ENTRY Name
|
2014-05-30 00:30:38 +00:00
|
|
|
FuncName .equ &Name
|
|
|
|
PrologName .equ &Name&_Prolog
|
|
|
|
FuncEndName .equ &Name&_end
|
|
|
|
.global &FuncName
|
2008-02-12 05:55:12 +00:00
|
|
|
.align 2
|
2014-05-30 00:30:38 +00:00
|
|
|
.func &FuncName
|
|
|
|
&FuncName:
|
2008-02-12 05:55:12 +00:00
|
|
|
.endm
|
|
|
|
|
2015-05-10 21:03:33 +00:00
|
|
|
// FIXME: should go to kxarmunw.h
|
2014-05-30 00:30:38 +00:00
|
|
|
.macro PROLOG_END
|
|
|
|
\PrologName:
|
2008-02-12 05:55:12 +00:00
|
|
|
.endm
|
|
|
|
|
2015-05-10 21:03:33 +00:00
|
|
|
.macro NESTED_END Name
|
2014-05-30 00:30:38 +00:00
|
|
|
&FuncEndName:
|
2008-02-12 05:55:12 +00:00
|
|
|
.endfunc
|
|
|
|
.endm
|
- 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
|
|
|
|
2015-05-10 21:03:33 +00:00
|
|
|
.macro LEAF_ENTRY $FuncName, $AreaName
|
|
|
|
NESTED_ENTRY $FuncName, $AreaName
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro LEAF_END $FuncName
|
|
|
|
NESTED_END $FuncName
|
|
|
|
.endm
|
|
|
|
|
|
|
|
|
|
|
|
/* Some "intrinsics", see http://codemachine.com/article_armasm.html */
|
|
|
|
|
|
|
|
.macro __debugbreak
|
|
|
|
DCD 0xDEFE
|
- 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
|
|
|
.endm
|
2014-05-30 00:30:38 +00:00
|
|
|
|
2015-05-10 21:03:33 +00:00
|
|
|
.macro __assertfail
|
|
|
|
DCD 0xDEFC
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro __fastfail
|
|
|
|
DCD 0xDEFB
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro __rdpmccntr64
|
|
|
|
DCD 0xDEFA
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro __debugservice
|
|
|
|
DCD 0xDEFD
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro __brkdiv0
|
|
|
|
DCD 0xDEF9
|
|
|
|
.endm
|
|
|
|
|
|
|
|
|
2014-05-30 00:30:38 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|