summaryrefslogtreecommitdiffstats
path: root/utils/hwstub/stub/asm
diff options
context:
space:
mode:
Diffstat (limited to 'utils/hwstub/stub/asm')
-rw-r--r--utils/hwstub/stub/asm/arm/system.S57
-rw-r--r--utils/hwstub/stub/asm/mips/atomic_rw.S2
-rw-r--r--utils/hwstub/stub/asm/mips/system.S51
3 files changed, 109 insertions, 1 deletions
diff --git a/utils/hwstub/stub/asm/arm/system.S b/utils/hwstub/stub/asm/arm/system.S
new file mode 100644
index 0000000000..df6b5a2e81
--- /dev/null
+++ b/utils/hwstub/stub/asm/arm/system.S
@@ -0,0 +1,57 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2014 by Amaury Pouly
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+/* Handling of data abort:
+ * the code can register a "longjmp" buffer to restore the context in case of
+ * fault */
+.data
+data_abort_jmp_ctx_ptr:
+/* buffer contains in order: cpsr,r4-r11,sp,lr,pc */
+.skip 48 /* = 4 * (cpsr + 11 registers) */
+
+.text
+/* Prototype: int set_data_abort_jmp()
+ * Return: 1 in case of data abort, 0 otherwise */
+.global set_data_abort_jmp
+set_data_abort_jmp:
+ mrs r2, cpsr
+ ldr r1, =data_abort_jmp_ctx_ptr
+ mov r0, #0
+ stmia r1, {r2,r4-r11,sp,lr,pc} /* see PC note below */
+ bx lr
+ mov r0, #1 /* <-- PC points here in stmia */
+ bx lr
+
+.global data_abort_handler
+data_abort_handler:
+ /* restore everything from context */
+ ldr r1, =data_abort_jmp_ctx_ptr
+ /* NOTE: we need to restore sp_sys and lr_sys, for this we need the
+ * LDM Rn, {}^
+ * variant, but we cannot restore PC from it because ^ has a different
+ * meaning and won't restore user/sys registers. On top of that, the
+ * non-PC ^ variant cannot do the register writeback, so on the PC restore,
+ * we reload all registers once again to avoid manually offseting the base
+ * register, it will trash sp_abt and lr_abr but those are unused anyway
+ * because we do not save the abort address and we don't use an abort stack */
+ ldmia r1, {r0,r4-r11,sp,lr}^ /* this variant cannot have writeback (r1!) */
+ msr spsr, r0
+ ldmia r1, {r0,r4-r11,sp,lr,pc}^ /* reload some registers but we don't care */
diff --git a/utils/hwstub/stub/asm/mips/atomic_rw.S b/utils/hwstub/stub/asm/mips/atomic_rw.S
index 47c4213a5d..db766af857 100644
--- a/utils/hwstub/stub/asm/mips/atomic_rw.S
+++ b/utils/hwstub/stub/asm/mips/atomic_rw.S
@@ -20,7 +20,7 @@
#include "mips.h"
.set noreorder
- .section .text, "ax", %progbits
+ .section .icode, "ax", %progbits
.global target_read8
.type target_read8, %function
.global target_read16
diff --git a/utils/hwstub/stub/asm/mips/system.S b/utils/hwstub/stub/asm/mips/system.S
new file mode 100644
index 0000000000..ab134aed48
--- /dev/null
+++ b/utils/hwstub/stub/asm/mips/system.S
@@ -0,0 +1,51 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2015 by Marcin Bukat
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include "mips.h"
+
+/* Handling of data abort:
+ * the code can register a "longjmp" buffer to restore the context in case of
+ * fault */
+.data
+.global data_abort_jmp_ctx_ptr
+data_abort_jmp_ctx_ptr:
+/* buffer contains in order: s0-s7, sp, s8, ra */
+.skip 44 /* = 4 * (9 callee saved registers + sp + ra) */
+
+.set noreorder
+.section .icode, "ax", %progbits
+/* Prototype: int set_data_abort_jmp()
+ * Return: 1 in case of data abort, 0 otherwise */
+.global set_data_abort_jmp
+set_data_abort_jmp:
+ la v0, data_abort_jmp_ctx_ptr
+ sw s0, 0(v0)
+ sw s1, 4(v0)
+ sw s2, 8(v0)
+ sw s3, 12(v0)
+ sw s4, 16(v0)
+ sw s5, 20(v0)
+ sw s6, 24(v0)
+ sw s7, 28(v0)
+ sw sp, 32(v0)
+ sw s8, 36(v0)
+ sw ra, 40(v0)
+ jr ra
+ move v0, zero
+.set reorder