summaryrefslogtreecommitdiff
path: root/coroutine/arm32
diff options
context:
space:
mode:
Diffstat (limited to 'coroutine/arm32')
-rw-r--r--coroutine/arm32/Context.S22
-rw-r--r--coroutine/arm32/Context.h12
2 files changed, 26 insertions, 8 deletions
diff --git a/coroutine/arm32/Context.S b/coroutine/arm32/Context.S
index 4308e1d1d2..945e4f82d5 100644
--- a/coroutine/arm32/Context.S
+++ b/coroutine/arm32/Context.S
@@ -2,21 +2,31 @@
## This file is part of the "Coroutine" project and released under the MIT License.
##
## Created by Samuel Williams on 10/5/2018.
-## Copyright, 2018, by Samuel Williams. All rights reserved.
+## Copyright, 2018, by Samuel Williams.
##
+#define TOKEN_PASTE(x,y) x##y
+
+.file "Context.S"
.text
+.globl PREFIXED_SYMBOL(coroutine_transfer)
+.align 2
+.type PREFIXED_SYMBOL(coroutine_transfer),%function
+.syntax unified
-.globl coroutine_transfer
-coroutine_transfer:
+PREFIXED_SYMBOL(coroutine_transfer):
# Save caller state (8 registers + return address)
push {r4-r11,lr}
-
+
# Save caller stack pointer
str sp, [r0]
-
+
# Restore callee stack pointer
ldr sp, [r1]
-
+
# Restore callee state (8 registers program counter)
pop {r4-r11,pc}
+
+#if defined(__linux__) && defined(__ELF__)
+.section .note.GNU-stack,"",%progbits
+#endif
diff --git a/coroutine/arm32/Context.h b/coroutine/arm32/Context.h
index e29fe1bb63..7529dd2efc 100644
--- a/coroutine/arm32/Context.h
+++ b/coroutine/arm32/Context.h
@@ -1,13 +1,18 @@
+#ifndef COROUTINE_ARM32_CONTEXT_H
+#define COROUTINE_ARM32_CONTEXT_H 1
+
/*
* This file is part of the "Coroutine" project and released under the MIT License.
*
* Created by Samuel Williams on 10/5/2018.
- * Copyright, 2018, by Samuel Williams. All rights reserved.
+ * Copyright, 2018, by Samuel Williams.
*/
#pragma once
#include <assert.h>
+#include <stddef.h>
+#include <stdint.h>
#include <string.h>
#define COROUTINE __attribute__((noreturn)) void
@@ -18,6 +23,7 @@ enum {COROUTINE_REGISTERS = 8};
struct coroutine_context
{
void **stack_pointer;
+ void *argument;
};
typedef COROUTINE(* coroutine_start)(struct coroutine_context *from, struct coroutine_context *self);
@@ -38,7 +44,7 @@ static inline void coroutine_initialize(
char * top = (char*)stack + size;
context->stack_pointer = (void**)((uintptr_t)top & ~0xF);
- *--context->stack_pointer = (void*)start;
+ *--context->stack_pointer = (void*)(uintptr_t)start;
context->stack_pointer -= COROUTINE_REGISTERS;
memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS);
@@ -49,3 +55,5 @@ struct coroutine_context * coroutine_transfer(struct coroutine_context * current
static inline void coroutine_destroy(struct coroutine_context * context)
{
}
+
+#endif /* COROUTINE_ARM32_CONTEXT_H */