summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2013-06-03 13:48:52 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2013-06-03 13:48:52 +0900
commitaed7a63b6be5e574c19ad73c214a89ad2414301c (patch)
tree49255667d5e1f916733399762875c082b780351c
parent23d3155f955344252295f99a8cce9ceb19acf6cf (diff)
fix chx_exit and join
-rw-r--r--ChangeLog4
-rw-r--r--chopstx.c15
2 files changed, 12 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 911b4cb..b4d6bcf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-06-03 Niibe Yutaka <gniibe@fsij.org>
+
+ * chopstx.c (chx_exit): Use R8.
+
2013-05-29 Niibe Yutaka <gniibe@fsij.org>
* entry.c (entry): Initialize data section.
diff --git a/chopstx.c b/chopstx.c
index acb9258..3afe4e8 100644
--- a/chopstx.c
+++ b/chopstx.c
@@ -97,6 +97,7 @@ struct chx_stack_regs {
/*
* Constants for ARM.
*/
+#define REG_EXIT 4 /* R8 */
#define REG_SP 8
#define REG_R0 0
@@ -681,14 +682,14 @@ chx_yield (void)
asm volatile ("svc #0" : : "r" (r0) : "memory");
}
-/* The RETVAL is saved into register R4. */
+/* The RETVAL is saved into register R8. */
static void __attribute__((noreturn))
chx_exit (void *retval)
{
- register uint32_t r4 asm ("r4") = (uint32_t)retval;
+ register uint32_t r8 asm ("r8") = (uint32_t)retval;
struct chx_thread *q;
- asm volatile ("cpsid i" : : : "memory");
+ asm volatile ("cpsid i" : : "r" (r8) : "memory");
if (running->flag_join_req)
{ /* wake up a thread which requests to join */
chx_LOCK (&q_join.lock);
@@ -711,7 +712,7 @@ chx_exit (void *retval)
running->state = THREAD_EXITED;
}
chx_UNLOCK (&q_exit.lock);
- asm volatile ("cpsie i" : : "r" (r4) : "memory");
+ asm volatile ("cpsie i" : : "r" (r8) : "memory");
chx_sched (NULL);
/* never comes here. */
for (;;);
@@ -1072,7 +1073,7 @@ chopstx_intr_wait (chopstx_intr_t *intr)
}
-/* The RETVAL is saved into register R4. */
+/* The RETVAL is saved into register R8. */
void __attribute__((noreturn))
chopstx_exit (void *retval)
{
@@ -1129,7 +1130,7 @@ chopstx_join (chopstx_t thd, void **ret)
tp->state = THREAD_FINISHED;
if (ret)
- *ret = (void *)tp->tc.reg[0];
+ *ret = (void *)tp->tc.reg[REG_EXIT]; /* R8 */
asm volatile ("cpsie i" : : : "memory");
}
@@ -1148,7 +1149,7 @@ chopstx_cancel (chopstx_t thd)
if (tp->state == THREAD_WAIT_CND || tp->state == THREAD_WAIT_INT
|| tp->state == THREAD_WAIT_TIME)
{
- /* Throw away registers on stack and direct to copstx_exit. */
+ /* Throw away registers on stack and direct to chopstx_exit. */
/* This is pretty much violent, but it works. */
p = (struct chx_stack_regs *)tp->tc.reg[REG_SP];
p->reg[REG_R0] = CHOPSTX_EXIT_CANCELED;