arm: modernize
parent
fb27ad693b
commit
f708c95659
|
@ -0,0 +1,10 @@
|
|||
#ifndef __ARCH_ARM_DEFS_H
|
||||
|
||||
#define REG_SZ (4)
|
||||
#define MCONTEXT_GREGS (32)
|
||||
|
||||
#define TYPE(__proc)
|
||||
|
||||
#include "common-defs.h"
|
||||
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Ariadne Conill <ariadne@dereferenced.org>
|
||||
* Copyright (c) 2018, 2020 Ariadne Conill <ariadne@dereferenced.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -10,18 +10,18 @@
|
|||
* from the use of this software.
|
||||
*/
|
||||
|
||||
.globl __getcontext;
|
||||
__getcontext:
|
||||
#include "defs.h"
|
||||
|
||||
ALIAS(getcontext, __getcontext)
|
||||
|
||||
FUNC(__getcontext)
|
||||
/* copy all of the current registers into the ucontext structure */
|
||||
add r1, r0, #48
|
||||
add r1, r0, #REG_OFFSET(4)
|
||||
stmia r1, {r4-r12}
|
||||
str r13, [r0,#84]
|
||||
str r14, [r0,#92]
|
||||
str r13, [r0, #REG_OFFSET(13)]
|
||||
str r14, [r0, #REG_OFFSET(15)]
|
||||
|
||||
/* return 0 */
|
||||
mov r0, #0
|
||||
mov pc, lr
|
||||
|
||||
|
||||
.weak getcontext;
|
||||
getcontext = __getcontext;
|
||||
END(__getcontext)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Ariadne Conill <ariadne@dereferenced.org>
|
||||
* Copyright (c) 2018, 2020 Ariadne Conill <ariadne@dereferenced.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -19,6 +19,9 @@
|
|||
#include <stdio.h>
|
||||
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
|
||||
extern void __start_context(void);
|
||||
|
||||
|
||||
|
@ -52,13 +55,6 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
|
|||
*sp++ = va_arg (va, unsigned long);
|
||||
|
||||
va_end(va);
|
||||
|
||||
/*
|
||||
printf("R4 offset = %d\n", offsetof(ucontext_t, uc_mcontext.arm_r4));
|
||||
printf("SP offset = %d\n", offsetof(ucontext_t, uc_mcontext.arm_sp));
|
||||
printf("LR offset = %d\n", offsetof(ucontext_t, uc_mcontext.arm_lr));
|
||||
printf("PC offset = %d\n", offsetof(ucontext_t, uc_mcontext.arm_pc));
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Ariadne Conill <ariadne@dereferenced.org>
|
||||
* Copyright (c) 2018, 2020 Ariadne Conill <ariadne@dereferenced.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -10,17 +10,17 @@
|
|||
* from the use of this software.
|
||||
*/
|
||||
|
||||
.globl __setcontext;
|
||||
__setcontext:
|
||||
#include "defs.h"
|
||||
|
||||
ALIAS(setcontext, __setcontext)
|
||||
|
||||
FUNC(__setcontext)
|
||||
/* copy all of the current registers into the ucontext structure */
|
||||
add r14, r0, #32
|
||||
add r14, r0, #REG_OFFSET(0)
|
||||
ldmia r14, {r0-r12}
|
||||
ldr r13, [r14, #52]
|
||||
add r14, r14, #56
|
||||
|
||||
/* load link register and jump to new context */
|
||||
ldmia r14, {r14, pc}
|
||||
|
||||
|
||||
.weak setcontext;
|
||||
setcontext = __setcontext;
|
||||
END(__setcontext)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Ariadne Conill <ariadne@dereferenced.org>
|
||||
* Copyright (c) 2018, 2020 Ariadne Conill <ariadne@dereferenced.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -10,21 +10,21 @@
|
|||
* from the use of this software.
|
||||
*/
|
||||
|
||||
.globl __swapcontext;
|
||||
__swapcontext:
|
||||
#include "defs.h"
|
||||
|
||||
ALIAS(swapcontext, __swapcontext)
|
||||
|
||||
FUNC(__swapcontext)
|
||||
/* copy all of the current registers into the ucontext structure */
|
||||
add r2, r0, #32
|
||||
add r2, r0, #REG_OFFSET(0)
|
||||
stmia r2, {r0-r12}
|
||||
str r13, [r0,#84]
|
||||
str r14, [r0,#92]
|
||||
str r13, [r0,#REG_OFFSET(13)]
|
||||
str r14, [r0,#REG_OFFSET(15)]
|
||||
|
||||
/* load new registers from the second ucontext structure */
|
||||
add r14, r1, #32
|
||||
add r14, r1, #REG_OFFSET(0)
|
||||
ldmia r14, {r0-r12}
|
||||
ldr r13, [r14, #52]
|
||||
add r14, r14, #56
|
||||
ldmia r14, {r14, pc}
|
||||
|
||||
|
||||
.weak swapcontext;
|
||||
swapcontext = __swapcontext;
|
||||
END(__swapcontext)
|
||||
|
|
|
@ -17,10 +17,14 @@
|
|||
# define ENT(__proc)
|
||||
#endif
|
||||
|
||||
#ifndef TYPE
|
||||
# define TYPE(__proc) .type __proc, @function;
|
||||
#endif
|
||||
|
||||
#define FUNC(__proc) \
|
||||
.global __proc; \
|
||||
.align 2; \
|
||||
.type __proc, @function; \
|
||||
TYPE(__proc) \
|
||||
ENT(__proc) \
|
||||
__proc: \
|
||||
SETUP_FRAME(__proc)
|
||||
|
|
Loading…
Reference in New Issue