TianoCore EDK2 master
Loading...
Searching...
No Matches
SemihostPrivate.h
Go to the documentation of this file.
1
10#ifndef SEMIHOST_PRIVATE_H_
11#define SEMIHOST_PRIVATE_H_
12
13typedef struct {
14 CHAR8 *FileName;
15 UINTN Mode;
16 UINTN NameLength;
18
19typedef struct {
20 UINTN Handle;
21 VOID *Buffer;
22 UINTN Length;
24
25typedef struct {
26 UINTN Handle;
27 UINTN Location;
29
30typedef struct {
31 VOID *Buffer;
32 UINTN Identifier;
33 UINTN Length;
35
36typedef struct {
37 CHAR8 *FileName;
38 UINTN NameLength;
40
41typedef struct {
42 CHAR8 *FileName;
43 UINTN FileNameLength;
44 CHAR8 *NewFileName;
45 UINTN NewFileNameLength;
47
48typedef struct {
49 CHAR8 *CommandLine;
50 UINTN CommandLength;
52
53#if defined (__CC_ARM)
54
55 #if defined (__thumb__)
56#define SWI 0xAB
57 #else
58#define SWI 0x123456
59 #endif
60
61#define SEMIHOST_SUPPORTED TRUE
62
63__swi (SWI)
64INT32
65_Semihost_SYS_OPEN (
66 IN UINTN SWI_0x01,
68 );
69
70__swi (SWI)
71INT32
72_Semihost_SYS_CLOSE (
73 IN UINTN SWI_0x02,
74 IN UINT32 *Handle
75 );
76
77__swi (SWI)
78VOID
79_Semihost_SYS_WRITEC (
80 IN UINTN SWI_0x03,
81 IN CHAR8 *Character
82 );
83
84__swi (SWI)
85VOID
86_Semihost_SYS_WRITE0 (
87 IN UINTN SWI_0x04,
88 IN CHAR8 *String
89 );
90
91__swi (SWI)
92UINT32
93_Semihost_SYS_WRITE (
94 IN UINTN SWI_0x05,
96 );
97
98__swi (SWI)
99UINT32
100_Semihost_SYS_READ (
101 IN UINTN SWI_0x06,
103 );
104
105__swi (SWI)
106CHAR8
107_Semihost_SYS_READC (
108 IN UINTN SWI_0x07,
109 IN UINTN Zero
110 );
111
112__swi (SWI)
113INT32
114_Semihost_SYS_SEEK (
115 IN UINTN SWI_0x0A,
117 );
118
119__swi (SWI)
120INT32
121_Semihost_SYS_FLEN (
122 IN UINTN SWI_0x0C,
123 IN UINT32 *Handle
124 );
125
126__swi (SWI)
127UINT32
128_Semihost_SYS_TMPNAME (
129 IN UINTN SWI_0x0D,
130 IN SEMIHOST_FILE_TMPNAME_BLOCK *TmpNameBlock
131 );
132
133__swi (SWI)
134UINT32
135_Semihost_SYS_REMOVE (
136 IN UINTN SWI_0x0E,
137 IN SEMIHOST_FILE_REMOVE_BLOCK *RemoveBlock
138 );
139
140__swi (SWI)
141UINT32
142_Semihost_SYS_RENAME (
143 IN UINTN SWI_0x0F,
144 IN SEMIHOST_FILE_RENAME_BLOCK *RenameBlock
145 );
146
147__swi (SWI)
148UINT32
149_Semihost_SYS_SYSTEM (
150 IN UINTN SWI_0x12,
151 IN SEMIHOST_SYSTEM_BLOCK *SystemBlock
152 );
153
154#define SEMIHOST_SYS_OPEN(OpenBlock) _Semihost_SYS_OPEN(0x01, OpenBlock)
155#define SEMIHOST_SYS_CLOSE(Handle) _Semihost_SYS_CLOSE(0x02, Handle)
156#define SEMIHOST_SYS_WRITE0(String) _Semihost_SYS_WRITE0(0x04, String)
157#define SEMIHOST_SYS_WRITEC(Character) _Semihost_SYS_WRITEC(0x03, Character)
158#define SEMIHOST_SYS_WRITE(WriteBlock) _Semihost_SYS_WRITE(0x05, WriteBlock)
159#define SEMIHOST_SYS_READ(ReadBlock) _Semihost_SYS_READ(0x06, ReadBlock)
160#define SEMIHOST_SYS_READC() _Semihost_SYS_READC(0x07, 0)
161#define SEMIHOST_SYS_SEEK(SeekBlock) _Semihost_SYS_SEEK(0x0A, SeekBlock)
162#define SEMIHOST_SYS_FLEN(Handle) _Semihost_SYS_FLEN(0x0C, Handle)
163#define SEMIHOST_SYS_TMPNAME(TmpNameBlock) _Semihost_SYS_TMPNAME(0x0D, TmpNameBlock)
164#define SEMIHOST_SYS_REMOVE(RemoveBlock) _Semihost_SYS_REMOVE(0x0E, RemoveBlock)
165#define SEMIHOST_SYS_RENAME(RenameBlock) _Semihost_SYS_RENAME(0x0F, RenameBlock)
166#define SEMIHOST_SYS_SYSTEM(SystemBlock) _Semihost_SYS_SYSTEM(0x12, SystemBlock)
167
168#elif defined (__GNUC__) // __CC_ARM
169
170#define SEMIHOST_SUPPORTED TRUE
171
172UINT32
173GccSemihostCall (
174 IN UINT32 Operation,
175 IN UINTN SystemBlockAddress
176 ); // __attribute__ ((interrupt ("SVC")));
177
178#define SEMIHOST_SYS_OPEN(OpenBlock) GccSemihostCall(0x01, (UINTN)(OpenBlock))
179#define SEMIHOST_SYS_CLOSE(Handle) GccSemihostCall(0x02, (UINTN)(Handle))
180#define SEMIHOST_SYS_WRITE0(String) GccSemihostCall(0x04, (UINTN)(String))
181#define SEMIHOST_SYS_WRITEC(Character) GccSemihostCall(0x03, (UINTN)(Character))
182#define SEMIHOST_SYS_WRITE(WriteBlock) GccSemihostCall(0x05, (UINTN)(WriteBlock))
183#define SEMIHOST_SYS_READ(ReadBlock) GccSemihostCall(0x06, (UINTN)(ReadBlock))
184#define SEMIHOST_SYS_READC() GccSemihostCall(0x07, (UINTN)(0))
185#define SEMIHOST_SYS_SEEK(SeekBlock) GccSemihostCall(0x0A, (UINTN)(SeekBlock))
186#define SEMIHOST_SYS_FLEN(Handle) GccSemihostCall(0x0C, (UINTN)(Handle))
187#define SEMIHOST_SYS_TMPNAME(TmpNameBlock) GccSemihostCall(0x0D, (UINTN)(TmpNameBlock))
188#define SEMIHOST_SYS_REMOVE(RemoveBlock) GccSemihostCall(0x0E, (UINTN)(RemoveBlock))
189#define SEMIHOST_SYS_RENAME(RenameBlock) GccSemihostCall(0x0F, (UINTN)(RenameBlock))
190#define SEMIHOST_SYS_SYSTEM(SystemBlock) GccSemihostCall(0x12, (UINTN)(SystemBlock))
191
192#else // __CC_ARM
193
194#define SEMIHOST_SUPPORTED FALSE
195
196#define SEMIHOST_SYS_OPEN(OpenBlock) (-1)
197#define SEMIHOST_SYS_CLOSE(Handle) (-1)
198#define SEMIHOST_SYS_WRITE0(String)
199#define SEMIHOST_SYS_WRITEC(Character)
200#define SEMIHOST_SYS_WRITE(WriteBlock) (0)
201#define SEMIHOST_SYS_READ(ReadBlock) ((ReadBlock)->Length)
202#define SEMIHOST_SYS_READC() ('x')
203#define SEMIHOST_SYS_SEEK(SeekBlock) (-1)
204#define SEMIHOST_SYS_FLEN(Handle) (-1)
205#define SEMIHOST_SYS_TMPNAME(TmpNameBlock) (-1)
206#define SEMIHOST_SYS_REMOVE(RemoveBlock) (-1)
207#define SEMIHOST_SYS_RENAME(RenameBlock) (-1)
208#define SEMIHOST_SYS_SYSTEM(SystemBlock) (-1)
209
210#endif // __CC_ARM
211
212#endif // SEMIHOST_PRIVATE_H_
UINT64 UINTN
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284