1 /*
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * Copyright © 2019 Keith Packard
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above
14  *    copyright notice, this list of conditions and the following
15  *    disclaimer in the documentation and/or other materials provided
16  *    with the distribution.
17  *
18  * 3. Neither the name of the copyright holder nor the names of its
19  *    contributors may be used to endorse or promote products derived
20  *    from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
33  * OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #pragma once
37 
38 #include <stdint.h>
39 #include <semihost.h>
40 
41 #define SYS_CLOCK		(0x10)
42 #define SYS_CLOSE		(0x02)
43 #define SYS_ELAPSED		(0x30)
44 #define SYS_ERRNO		(0x13)
45 #define SYS_EXIT		(0x18)
46 #define SYS_EXIT_EXTENDED	(0x20)
47 #define SYS_FLEN		(0x0C)
48 #define SYS_GET_CMDLINE		(0x15)
49 #define SYS_HEAPINFO		(0x16)
50 #define SYS_ISERROR		(0x08)
51 #define SYS_ISTTY		(0x09)
52 #define SYS_OPEN		(0x01)
53 #define SYS_READ		(0x06)
54 #define SYS_READC		(0x07)
55 #define SYS_REMOVE		(0x0E)
56 #define SYS_RENAME		(0x0F)
57 #define SYS_SEEK		(0x0A)
58 #define SYS_SYSTEM		(0x12)
59 #define SYS_TICKFREQ		(0x31)
60 #define SYS_TIME		(0x11)
61 #define SYS_TMPNAM		(0x0D)
62 #define SYS_WRITE		(0x05)
63 #define SYS_WRITEC		(0x03)
64 #define SYS_WRITE0		(0x04)
65 
66 #define ADP_Stopped_BranchThroughZero	0x20000
67 #define ADP_Stopped_UndefinedInstr	0x20001
68 #define ADP_Stopped_SoftwareInterrupt	0x20002
69 #define ADP_Stopped_PrefetchAbort	0x20003
70 #define ADP_Stopped_DataAbort		0x20004
71 #define ADP_Stopped_AddressException	0x20005
72 #define ADP_Stopped_IRQ			0x20006
73 #define ADP_Stopped_FIQ			0x20007
74 #define ADP_Stopped_BreakPoint		0x20020
75 #define ADP_Stopped_WatchPoint		0x20021
76 #define ADP_Stopped_StepComplete	0x20022
77 #define ADP_Stopped_RunTimeErrorUnknown	0x20023
78 #define ADP_Stopped_InternalError	0x20024
79 #define ADP_Stopped_UserInterruption	0x20025
80 #define ADP_Stopped_ApplicationExit	0x20026
81 #define ADP_Stopped_StackOverflow	0x20027
82 #define ADP_Stopped_DivisionByZero	0x20028
83 #define ADP_Stopped_OSSpecific		0x20029
84 
85 #define SH_EXT_EXIT_EXTENDED		0
86 #define SH_EXT_STDOUT_STDERR		1
87 #define SH_EXT_NUM			2
88 
89 #define SHFB_MAGIC_0	0x53
90 #define SHFB_MAGIC_1	0x48
91 #define SHFB_MAGIC_2	0x46
92 #define SHFB_MAGIC_3	0x42
93 
94 uintptr_t
95 sys_semihost(uintptr_t op, uintptr_t param);
96 
97