source: trunk/libs/newlib/src/libgloss/aarch64/svc.h @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 3.7 KB
Line 
1/* Copyright (c) 2009, 2010, 2011, 2012 ARM Ltd.  All rights reserved.
2
3 Redistribution and use in source and binary forms, with or without
4 modification, are permitted provided that the following conditions
5 are met:
6 1. Redistributions of source code must retain the above copyright
7    notice, this list of conditions and the following disclaimer.
8 2. Redistributions in binary form must reproduce the above copyright
9    notice, this list of conditions and the following disclaimer in the
10    documentation and/or other materials provided with the distribution.
11 3. The name of the company may not be used to endorse or promote
12    products derived from this software without specific prior written
13    permission.
14
15 THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
20 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
22 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
25
26#include <_ansi.h>
27
28/* Now the SWI numbers and reason codes for RDI (Angel) monitors.  */
29#define AngelSVC                                0xF000
30#define AngelSVCInsn                            "hlt"
31#define AngelSVCAsm                             hlt
32
33/* The reason codes:  */
34#define AngelSVC_Reason_Open                    0x01
35#define AngelSVC_Reason_Close                   0x02
36#define AngelSVC_Reason_WriteC                  0x03
37#define AngelSVC_Reason_Write0                  0x04
38#define AngelSVC_Reason_Write                   0x05
39#define AngelSVC_Reason_Read                    0x06
40#define AngelSVC_Reason_ReadC                   0x07
41#define AngelSVC_Reason_IsError                 0x08
42#define AngelSVC_Reason_IsTTY                   0x09
43#define AngelSVC_Reason_Seek                    0x0A
44#define AngelSVC_Reason_FLen                    0x0C
45#define AngelSVC_Reason_TmpNam                  0x0D
46#define AngelSVC_Reason_Remove                  0x0E
47#define AngelSVC_Reason_Rename                  0x0F
48#define AngelSVC_Reason_Clock                   0x10
49#define AngelSVC_Reason_Time                    0x11
50#define AngelSVC_Reason_System                  0x12
51#define AngelSVC_Reason_Errno                   0x13
52#define AngelSVC_Reason_GetCmdLine              0x15
53#define AngelSVC_Reason_HeapInfo                0x16
54#define AngelSVC_Reason_EnterSVC                0x17
55#define AngelSVC_Reason_ReportException         0x18
56#define AngelSVC_Reason_SyncCacheRange          0x19
57#define AngelSVC_Reason_ReportExceptionExtended 0x20
58#define AngelSVC_Reason_Elapsed                 0x30
59#define AngelSVC_Reason_TickFreq                0x31
60#define ADP_Stopped_ApplicationExit             ((2 << 16) + 38)
61#define ADP_Stopped_RunTimeError                ((2 << 16) + 35)
62
63/* Semihosting feature magic numbers.  */
64#define NUM_SHFB_MAGIC                  4
65#define SHFB_MAGIC_0                    0x53
66#define SHFB_MAGIC_1                    0x48
67#define SHFB_MAGIC_2                    0x46
68#define SHFB_MAGIC_3                    0x42
69
70/* Semihosting extensions.  */
71#define SH_EXT_EXIT_EXTENDED_BITNUM     0x0
72#define SH_EXT_STDOUT_STDERR_BITNUM     0x1
73
74#if !defined (__ASSEMBLER__)
75extern int _get_semihosting_exts (char*, int, int);
76extern int _has_ext_exit_extended (void);
77extern int _has_ext_stdout_stderr (void);
78#endif
79
80#if defined(ARM_RDI_MONITOR) && !defined(__ASSEMBLER__)
81
82/* Type of each entry in a parameter block.  */
83typedef long long param_block_t;
84
85static inline long long
86do_AngelSVC (int reason, param_block_t * arg)
87{
88  long long value;
89  asm volatile ("mov w0, %w1; mov x1, %2; " AngelSVCInsn " %3; mov %0, x0"
90                : "=r" (value) /* Outputs */
91                : "r" (reason), "r" (arg), "n" (AngelSVC) /* Inputs */
92                : "x0", "x1", "x2", "x3", "x17", "x30", "memory", "cc"
93                  /* Clobbers x0 and x1, and lr if in supervisor mode */);
94  return value;
95}
96
97#endif
Note: See TracBrowser for help on using the repository browser.