1eda14cbcSMatt Macy/*- 2eda14cbcSMatt Macy * Copyright 2004-2014 Olivier Houchard <cognet@FreeBSD.org> 3eda14cbcSMatt Macy * Copyright 2012-2014 Ian Lepore <ian@FreeBSD.org> 4eda14cbcSMatt Macy * Copyright 2013-2014 Andrew Turner <andrew@FreeBSD.org> 5eda14cbcSMatt Macy * Copyright 2014 Svatopluk Kraus <onwahe@gmail.com> 6eda14cbcSMatt Macy * Copyright 2014 Michal Meloun <meloun@miracle.cz> 7eda14cbcSMatt Macy * All rights reserved. 8eda14cbcSMatt Macy * 9eda14cbcSMatt Macy * Redistribution and use in source and binary forms, with or without 10eda14cbcSMatt Macy * modification, are permitted provided that the following conditions 11eda14cbcSMatt Macy * are met: 12eda14cbcSMatt Macy * 1. Redistributions of source code must retain the above copyright 13eda14cbcSMatt Macy * notice, this list of conditions and the following disclaimer. 14eda14cbcSMatt Macy * 2. Redistributions in binary form must reproduce the above copyright 15eda14cbcSMatt Macy * notice, this list of conditions and the following disclaimer in the 16eda14cbcSMatt Macy * documentation and/or other materials provided with the distribution. 17eda14cbcSMatt Macy * 18eda14cbcSMatt Macy * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19eda14cbcSMatt Macy * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20eda14cbcSMatt Macy * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21eda14cbcSMatt Macy * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22eda14cbcSMatt Macy * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23eda14cbcSMatt Macy * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24eda14cbcSMatt Macy * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25eda14cbcSMatt Macy * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26eda14cbcSMatt Macy * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27eda14cbcSMatt Macy * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28eda14cbcSMatt Macy * SUCH DAMAGE. 29eda14cbcSMatt Macy */ 30eda14cbcSMatt Macy 31eda14cbcSMatt Macy 32eda14cbcSMatt Macy#if defined(__arm__) && !defined(__aarch64__) 33eda14cbcSMatt Macy 34eda14cbcSMatt Macy#if defined(__thumb2__) 35eda14cbcSMatt Macy#define _FUNC_MODE .code 16; .thumb_func 36eda14cbcSMatt Macy#else 37eda14cbcSMatt Macy#define _FUNC_MODE .code 32 38eda14cbcSMatt Macy#endif 39eda14cbcSMatt Macy 40eda14cbcSMatt Macy#define ENTRY(x) \ 41eda14cbcSMatt Macy .text; \ 42eda14cbcSMatt Macy .syntax unified; \ 43*15f0b8c3SMartin Matuska .balign 2; \ 44eda14cbcSMatt Macy .global x; \ 45eda14cbcSMatt Macy .type x,#function; \ 46eda14cbcSMatt Macy _FUNC_MODE; \ 47eda14cbcSMatt Macyx: 48eda14cbcSMatt Macy 49eda14cbcSMatt Macy#define END(x) \ 50eda14cbcSMatt Macy .size x, . - x; 51eda14cbcSMatt Macy 52eda14cbcSMatt Macy#define RET bx lr 53eda14cbcSMatt Macy 54eda14cbcSMatt Macy 55eda14cbcSMatt Macy/* 56eda14cbcSMatt Macy * setjump + longjmp 57eda14cbcSMatt Macy */ 58eda14cbcSMatt MacyENTRY(setjmp) 59eda14cbcSMatt Macy#if defined(__thumb2__) 60eda14cbcSMatt Macy mov ip, sp 61eda14cbcSMatt Macy stmia r0, {r4-r12,r14} 62eda14cbcSMatt Macy#else 63eda14cbcSMatt Macy stmia r0, {r4-r14} 64eda14cbcSMatt Macy#endif 65eda14cbcSMatt Macy mov r0, #0x00000000 66eda14cbcSMatt Macy RET 67eda14cbcSMatt MacyEND(setjmp) 68eda14cbcSMatt Macy 69eda14cbcSMatt MacyENTRY(longjmp) 70eda14cbcSMatt Macy#if defined(__thumb2__) 71eda14cbcSMatt Macy ldmia r0, {r4-r12,r14} 72eda14cbcSMatt Macy mov sp, ip 73eda14cbcSMatt Macy#else 74eda14cbcSMatt Macy ldmia r0, {r4-r14} 75eda14cbcSMatt Macy#endif 76eda14cbcSMatt Macy mov r0, #0x00000001 77eda14cbcSMatt Macy RET 78eda14cbcSMatt MacyEND(longjmp) 79eda14cbcSMatt Macy 80eda14cbcSMatt Macy#ifdef __ELF__ 81eda14cbcSMatt Macy.section .note.GNU-stack,"",%progbits 82eda14cbcSMatt Macy#endif 83eda14cbcSMatt Macy 84eda14cbcSMatt Macy#endif 85