aarch64: modernize
parent
b04da78fb8
commit
fb27ad693b
|
@ -1,8 +1,11 @@
|
|||
#ifndef __ARCH_AARCH64_DEFS_H
|
||||
#define __ARCH_AARCH64_DEFS_H
|
||||
|
||||
#define REGSZ 8
|
||||
#define R0_OFFSET 184
|
||||
#define REG_SZ (8)
|
||||
#define MCONTEXT_GREGS (184)
|
||||
|
||||
#define R0_OFFSET REG_OFFSET(0)
|
||||
|
||||
#define SP_OFFSET 432
|
||||
#define PC_OFFSET 440
|
||||
#define PSTATE_OFFSET 448
|
||||
|
@ -15,4 +18,6 @@
|
|||
# define ESR_MAGIC 0x45535201
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
@ -12,27 +12,28 @@
|
|||
|
||||
#include "defs.h"
|
||||
|
||||
.globl __getcontext;
|
||||
__getcontext:
|
||||
str xzr, [x0, #R0_OFFSET + (0 * REGSZ)]
|
||||
ALIAS(getcontext, __getcontext)
|
||||
|
||||
FUNC(__getcontext)
|
||||
str xzr, [x0, #REG_OFFSET(0)]
|
||||
|
||||
/* save GPRs */
|
||||
stp x0, x1, [x0, #R0_OFFSET + (0 * REGSZ)]
|
||||
stp x2, x3, [x0, #R0_OFFSET + (2 * REGSZ)]
|
||||
stp x4, x5, [x0, #R0_OFFSET + (4 * REGSZ)]
|
||||
stp x6, x7, [x0, #R0_OFFSET + (6 * REGSZ)]
|
||||
stp x8, x9, [x0, #R0_OFFSET + (8 * REGSZ)]
|
||||
stp x10, x11, [x0, #R0_OFFSET + (10 * REGSZ)]
|
||||
stp x12, x13, [x0, #R0_OFFSET + (12 * REGSZ)]
|
||||
stp x14, x15, [x0, #R0_OFFSET + (14 * REGSZ)]
|
||||
stp x16, x17, [x0, #R0_OFFSET + (16 * REGSZ)]
|
||||
stp x18, x19, [x0, #R0_OFFSET + (18 * REGSZ)]
|
||||
stp x20, x21, [x0, #R0_OFFSET + (20 * REGSZ)]
|
||||
stp x22, x23, [x0, #R0_OFFSET + (22 * REGSZ)]
|
||||
stp x24, x25, [x0, #R0_OFFSET + (24 * REGSZ)]
|
||||
stp x26, x27, [x0, #R0_OFFSET + (26 * REGSZ)]
|
||||
stp x28, x29, [x0, #R0_OFFSET + (28 * REGSZ)]
|
||||
str x30, [x0, #R0_OFFSET + (30 * REGSZ)]
|
||||
stp x0, x1, [x0, #REG_OFFSET(0)]
|
||||
stp x2, x3, [x0, #REG_OFFSET(2)]
|
||||
stp x4, x5, [x0, #REG_OFFSET(4)]
|
||||
stp x6, x7, [x0, #REG_OFFSET(6)]
|
||||
stp x8, x9, [x0, #REG_OFFSET(8)]
|
||||
stp x10, x11, [x0, #REG_OFFSET(10)]
|
||||
stp x12, x13, [x0, #REG_OFFSET(12)]
|
||||
stp x14, x15, [x0, #REG_OFFSET(14)]
|
||||
stp x16, x17, [x0, #REG_OFFSET(16)]
|
||||
stp x18, x19, [x0, #REG_OFFSET(18)]
|
||||
stp x20, x21, [x0, #REG_OFFSET(20)]
|
||||
stp x22, x23, [x0, #REG_OFFSET(22)]
|
||||
stp x24, x25, [x0, #REG_OFFSET(24)]
|
||||
stp x26, x27, [x0, #REG_OFFSET(26)]
|
||||
stp x28, x29, [x0, #REG_OFFSET(28)]
|
||||
str x30, [x0, #REG_OFFSET(30)]
|
||||
|
||||
/* save current program counter in link register */
|
||||
str x30, [x0, #PC_OFFSET]
|
||||
|
@ -48,7 +49,4 @@ __getcontext:
|
|||
|
||||
mov x0, #0
|
||||
ret
|
||||
|
||||
|
||||
.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
|
||||
|
@ -12,16 +12,17 @@
|
|||
|
||||
#include "defs.h"
|
||||
|
||||
.globl __setcontext;
|
||||
__setcontext:
|
||||
ALIAS(setcontext, __setcontext)
|
||||
|
||||
FUNC(__setcontext)
|
||||
/* restore GPRs */
|
||||
ldp x18, x19, [x0, #R0_OFFSET + (18 * REGSZ)]
|
||||
ldp x20, x21, [x0, #R0_OFFSET + (20 * REGSZ)]
|
||||
ldp x22, x23, [x0, #R0_OFFSET + (22 * REGSZ)]
|
||||
ldp x24, x25, [x0, #R0_OFFSET + (24 * REGSZ)]
|
||||
ldp x26, x27, [x0, #R0_OFFSET + (26 * REGSZ)]
|
||||
ldp x28, x29, [x0, #R0_OFFSET + (28 * REGSZ)]
|
||||
ldr x30, [x0, #R0_OFFSET + (30 * REGSZ)]
|
||||
ldp x18, x19, [x0, #REG_OFFSET(18)]
|
||||
ldp x20, x21, [x0, #REG_OFFSET(20)]
|
||||
ldp x22, x23, [x0, #REG_OFFSET(22)]
|
||||
ldp x24, x25, [x0, #REG_OFFSET(24)]
|
||||
ldp x26, x27, [x0, #REG_OFFSET(26)]
|
||||
ldp x28, x29, [x0, #REG_OFFSET(28)]
|
||||
ldr x30, [x0, #REG_OFFSET(30)]
|
||||
|
||||
/* save current stack pointer */
|
||||
ldr x2, [x0, #SP_OFFSET]
|
||||
|
@ -33,15 +34,11 @@ __setcontext:
|
|||
ldr x16, [x0, #PC_OFFSET]
|
||||
|
||||
/* restore args */
|
||||
ldp x2, x3, [x0, #R0_OFFSET + (2 * REGSZ)]
|
||||
ldp x4, x5, [x0, #R0_OFFSET + (4 * REGSZ)]
|
||||
ldp x6, x7, [x0, #R0_OFFSET + (6 * REGSZ)]
|
||||
ldp x0, x1, [x0, #R0_OFFSET + (0 * REGSZ)]
|
||||
ldp x2, x3, [x0, #REG_OFFSET(2)]
|
||||
ldp x4, x5, [x0, #REG_OFFSET(4)]
|
||||
ldp x6, x7, [x0, #REG_OFFSET(6)]
|
||||
ldp x0, x1, [x0, #REG_OFFSET(0)]
|
||||
|
||||
/* jump to new PC */
|
||||
br x16
|
||||
|
||||
|
||||
.weak setcontext;
|
||||
setcontext = __setcontext;
|
||||
|
||||
END(__setcontext)
|
||||
|
|
|
@ -10,11 +10,13 @@
|
|||
* from the use of this software.
|
||||
*/
|
||||
|
||||
.globl __start_context;
|
||||
__start_context:
|
||||
#include "defs.h"
|
||||
|
||||
FUNC(__start_context)
|
||||
/* get the proper context into position and test for NULL */
|
||||
mov x0, x19
|
||||
cbnz x0, __setcontext
|
||||
|
||||
/* something went wrong, exit */
|
||||
b exit
|
||||
END(__start_context)
|
||||
|
|
|
@ -12,26 +12,27 @@
|
|||
|
||||
#include "defs.h"
|
||||
|
||||
.globl __swapcontext;
|
||||
__swapcontext:
|
||||
str xzr, [x0, #R0_OFFSET + (0 * REGSZ)]
|
||||
ALIAS(swapcontext, __swapcontext)
|
||||
|
||||
FUNC(__swapcontext)
|
||||
str xzr, [x0, #REG_OFFSET(0)]
|
||||
|
||||
/* save GPRs */
|
||||
stp x2, x3, [x0, #R0_OFFSET + (2 * REGSZ)]
|
||||
stp x4, x5, [x0, #R0_OFFSET + (4 * REGSZ)]
|
||||
stp x6, x7, [x0, #R0_OFFSET + (6 * REGSZ)]
|
||||
stp x8, x9, [x0, #R0_OFFSET + (8 * REGSZ)]
|
||||
stp x10, x11, [x0, #R0_OFFSET + (10 * REGSZ)]
|
||||
stp x12, x13, [x0, #R0_OFFSET + (12 * REGSZ)]
|
||||
stp x14, x15, [x0, #R0_OFFSET + (14 * REGSZ)]
|
||||
stp x16, x17, [x0, #R0_OFFSET + (16 * REGSZ)]
|
||||
stp x18, x19, [x0, #R0_OFFSET + (18 * REGSZ)]
|
||||
stp x20, x21, [x0, #R0_OFFSET + (20 * REGSZ)]
|
||||
stp x22, x23, [x0, #R0_OFFSET + (22 * REGSZ)]
|
||||
stp x24, x25, [x0, #R0_OFFSET + (24 * REGSZ)]
|
||||
stp x26, x27, [x0, #R0_OFFSET + (26 * REGSZ)]
|
||||
stp x28, x29, [x0, #R0_OFFSET + (28 * REGSZ)]
|
||||
str x30, [x0, #R0_OFFSET + (30 * REGSZ)]
|
||||
stp x2, x3, [x0, #REG_OFFSET(2)]
|
||||
stp x4, x5, [x0, #REG_OFFSET(4)]
|
||||
stp x6, x7, [x0, #REG_OFFSET(6)]
|
||||
stp x8, x9, [x0, #REG_OFFSET(8)]
|
||||
stp x10, x11, [x0, #REG_OFFSET(10)]
|
||||
stp x12, x13, [x0, #REG_OFFSET(12)]
|
||||
stp x14, x15, [x0, #REG_OFFSET(14)]
|
||||
stp x16, x17, [x0, #REG_OFFSET(16)]
|
||||
stp x18, x19, [x0, #REG_OFFSET(18)]
|
||||
stp x20, x21, [x0, #REG_OFFSET(20)]
|
||||
stp x22, x23, [x0, #REG_OFFSET(22)]
|
||||
stp x24, x25, [x0, #REG_OFFSET(24)]
|
||||
stp x26, x27, [x0, #REG_OFFSET(26)]
|
||||
stp x28, x29, [x0, #REG_OFFSET(28)]
|
||||
str x30, [x0, #REG_OFFSET(30)]
|
||||
|
||||
/* save current program counter in link register */
|
||||
str x30, [x0, #PC_OFFSET]
|
||||
|
@ -54,8 +55,4 @@ __swapcontext:
|
|||
/* hmm, we came back here try to return */
|
||||
mov x30, x28
|
||||
ret
|
||||
|
||||
|
||||
|
||||
.weak swapcontext;
|
||||
swapcontext = __swapcontext;
|
||||
END(__swapcontext)
|
||||
|
|
Loading…
Reference in New Issue