s390x: modernize assembly code
parent
ef42ad682a
commit
d7d746f44e
|
@ -1,8 +1,15 @@
|
||||||
#ifndef __ARCH_S390X_DEFS_H
|
#ifndef __ARCH_S390X_DEFS_H
|
||||||
#define __ARCH_S390X_DEFS_H
|
#define __ARCH_S390X_DEFS_H
|
||||||
|
|
||||||
#define OFFSET_GREGS (56)
|
#define REG_SZ (8)
|
||||||
#define OFFSET_AREGS (184)
|
#define AREG_SZ (4)
|
||||||
#define OFFSET_FPREGS (248)
|
|
||||||
|
#define MCONTEXT_GREGS (56)
|
||||||
|
#define MCONTEXT_AREGS (184)
|
||||||
|
#define MCONTEXT_FPREGS (248)
|
||||||
|
|
||||||
|
#define AREG_OFFSET(__reg) (MCONTEXT_AREGS + ((__reg) * AREG_SZ))
|
||||||
|
|
||||||
|
#include "common-defs.h"
|
||||||
|
|
||||||
#endif
|
#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
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -12,17 +12,14 @@
|
||||||
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
|
||||||
|
ALIAS(getcontext, __getcontext)
|
||||||
|
|
||||||
.globl __getcontext;
|
FUNC(__getcontext)
|
||||||
__getcontext:
|
|
||||||
lgr %r1, %r2 /* use %r1 as our working register */
|
lgr %r1, %r2 /* use %r1 as our working register */
|
||||||
la %r2, 0 /* we will return 0 */
|
la %r2, 0 /* we will return 0 */
|
||||||
|
|
||||||
stam %a0, %a15, OFFSET_AREGS(%r1) /* store access registers */
|
stam %a0, %a15, AREG_OFFSET(0)(%r1) /* store access registers */
|
||||||
stmg %r0, %r15, OFFSET_GREGS(%r1) /* store general-purpose registers */
|
stmg %r0, %r15, REG_OFFSET(0)(%r1) /* store general-purpose registers */
|
||||||
|
|
||||||
br %r14 /* return to where we came from */
|
br %r14 /* return to where we came from */
|
||||||
|
END(__getcontext)
|
||||||
|
|
||||||
.weak getcontext;
|
|
||||||
getcontext = __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
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
|
|
@ -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
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -12,16 +12,13 @@
|
||||||
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
|
||||||
|
ALIAS(setcontext, __setcontext)
|
||||||
|
|
||||||
.globl __setcontext;
|
FUNC(__setcontext)
|
||||||
__setcontext:
|
|
||||||
lgr %r1, %r2 /* use %r1 as our working register */
|
lgr %r1, %r2 /* use %r1 as our working register */
|
||||||
|
|
||||||
lam %a2, %a15, OFFSET_AREGS+8(%r1) /* load access registers, but skip %a0 and %a1 which are for TLS */
|
lam %a2, %a15, AREG_OFFSET(2)(%r1) /* load access registers, but skip %a0 and %a1 which are for TLS */
|
||||||
lmg %r0, %r15, OFFSET_GREGS(%r1) /* store general-purpose registers */
|
lmg %r0, %r15, REG_OFFSET(0)(%r1) /* store general-purpose registers */
|
||||||
|
|
||||||
br %r14 /* return to new link register address */
|
br %r14 /* return to new link register address */
|
||||||
|
END(__setcontext)
|
||||||
|
|
||||||
.weak setcontext;
|
|
||||||
setcontext = __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
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -12,9 +12,7 @@
|
||||||
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
|
||||||
|
FUNC(__start_context)
|
||||||
.globl __start_context;
|
|
||||||
__start_context:
|
|
||||||
basr %r14, %r7 /* run function pointer (%r7) and return here */
|
basr %r14, %r7 /* run function pointer (%r7) and return here */
|
||||||
ltgr %r8, %r8 /* check to see if uc_link (%r8) is null */
|
ltgr %r8, %r8 /* check to see if uc_link (%r8) is null */
|
||||||
|
|
||||||
|
@ -28,3 +26,4 @@ no_linked_context:
|
||||||
brasl %r14, exit@plt /* call exit */
|
brasl %r14, exit@plt /* call exit */
|
||||||
|
|
||||||
j .+2 /* crash if exit returns */
|
j .+2 /* crash if exit returns */
|
||||||
|
END(__start_context)
|
||||||
|
|
|
@ -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
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -12,21 +12,18 @@
|
||||||
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
|
||||||
|
ALIAS(swapcontext, __swapcontext)
|
||||||
|
|
||||||
.globl __swapcontext;
|
FUNC(__swapcontext)
|
||||||
__swapcontext:
|
|
||||||
lgr %r1, %r2 /* use %r1 to save current context to */
|
lgr %r1, %r2 /* use %r1 to save current context to */
|
||||||
lgr %r0, %r3 /* use %r0 for source context */
|
lgr %r0, %r3 /* use %r0 for source context */
|
||||||
|
|
||||||
stam %a0, %a15, OFFSET_AREGS(%r1) /* store access registers */
|
stam %a0, %a15, AREG_OFFSET(0)(%r1) /* store access registers */
|
||||||
stmg %r0, %r15, OFFSET_GREGS(%r1) /* store general-purpose registers */
|
stmg %r0, %r15, REG_OFFSET(0)(%r1) /* store general-purpose registers */
|
||||||
|
|
||||||
lgr %r2, %r0 /* swap %r0 to %r2 (XXX: figure out why it hates loading from %r0) */
|
lgr %r2, %r0 /* swap %r0 to %r2 (XXX: figure out why it hates loading from %r0) */
|
||||||
lam %a2, %a15, OFFSET_AREGS+8(%r2) /* load access registers, but skip %a0 and %a1 which are for TLS */
|
lam %a2, %a15, AREG_OFFSET(2)(%r2) /* load access registers, but skip %a0 and %a1 which are for TLS */
|
||||||
lmg %r0, %r15, OFFSET_GREGS(%r2) /* load general-purpose registers */
|
lmg %r0, %r15, REG_OFFSET(0)(%r2) /* load general-purpose registers */
|
||||||
|
|
||||||
br %r14 /* return to new link register address */
|
br %r14 /* return to new link register address */
|
||||||
|
END(__swapcontext)
|
||||||
|
|
||||||
.weak swapcontext;
|
|
||||||
swapcontext = __swapcontext;
|
|
||||||
|
|
Loading…
Reference in New Issue