3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 Copyright (c) 2013 - 2014, ARM Ltd. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #ifndef __SEMIHOST_PRIVATE_H__
17 #define __SEMIHOST_PRIVATE_H__
23 } SEMIHOST_FILE_OPEN_BLOCK
;
29 } SEMIHOST_FILE_READ_WRITE_BLOCK
;
34 } SEMIHOST_FILE_SEEK_BLOCK
;
40 } SEMIHOST_FILE_TMPNAME_BLOCK
;
45 } SEMIHOST_FILE_REMOVE_BLOCK
;
51 UINTN NewFileNameLength
;
52 } SEMIHOST_FILE_RENAME_BLOCK
;
57 } SEMIHOST_SYSTEM_BLOCK
;
61 #if defined(__thumb__)
67 #define SEMIHOST_SUPPORTED TRUE
73 IN SEMIHOST_FILE_OPEN_BLOCK
*OpenBlock
101 IN OUT SEMIHOST_FILE_READ_WRITE_BLOCK
*WriteBlock
108 IN OUT SEMIHOST_FILE_READ_WRITE_BLOCK
*ReadBlock
122 IN SEMIHOST_FILE_SEEK_BLOCK
*SeekBlock
134 _Semihost_SYS_TMPNAME(
136 IN SEMIHOST_FILE_TMPNAME_BLOCK
*TmpNameBlock
141 _Semihost_SYS_REMOVE(
143 IN SEMIHOST_FILE_REMOVE_BLOCK
*RemoveBlock
148 _Semihost_SYS_RENAME(
150 IN SEMIHOST_FILE_RENAME_BLOCK
*RenameBlock
155 _Semihost_SYS_SYSTEM(
157 IN SEMIHOST_SYSTEM_BLOCK
*SystemBlock
160 #define Semihost_SYS_OPEN(OpenBlock) _Semihost_SYS_OPEN(0x01, OpenBlock)
161 #define Semihost_SYS_CLOSE(Handle) _Semihost_SYS_CLOSE(0x02, Handle)
162 #define Semihost_SYS_WRITE0(String) _Semihost_SYS_WRITE0(0x04, String)
163 #define Semihost_SYS_WRITEC(Character) _Semihost_SYS_WRITEC(0x03, Character)
164 #define Semihost_SYS_WRITE(WriteBlock) _Semihost_SYS_WRITE(0x05, WriteBlock)
165 #define Semihost_SYS_READ(ReadBlock) _Semihost_SYS_READ(0x06, ReadBlock)
166 #define Semihost_SYS_READC() _Semihost_SYS_READC(0x07, 0)
167 #define Semihost_SYS_SEEK(SeekBlock) _Semihost_SYS_SEEK(0x0A, SeekBlock)
168 #define Semihost_SYS_FLEN(Handle) _Semihost_SYS_FLEN(0x0C, Handle)
169 #define Semihost_SYS_TMPNAME(TmpNameBlock) _Semihost_SYS_TMPNAME(0x0D, TmpNameBlock)
170 #define Semihost_SYS_REMOVE(RemoveBlock) _Semihost_SYS_REMOVE(0x0E, RemoveBlock)
171 #define Semihost_SYS_RENAME(RenameBlock) _Semihost_SYS_RENAME(0x0F, RenameBlock)
172 #define Semihost_SYS_SYSTEM(SystemBlock) _Semihost_SYS_SYSTEM(0x12, SystemBlock)
174 #elif defined(__GNUC__) // __CC_ARM
176 #define SEMIHOST_SUPPORTED TRUE
181 IN UINTN SystemBlockAddress
182 ); // __attribute__ ((interrupt ("SVC")));
184 #define Semihost_SYS_OPEN(OpenBlock) GccSemihostCall(0x01, (UINTN)(OpenBlock))
185 #define Semihost_SYS_CLOSE(Handle) GccSemihostCall(0x02, (UINTN)(Handle))
186 #define Semihost_SYS_WRITE0(String) GccSemihostCall(0x04, (UINTN)(String))
187 #define Semihost_SYS_WRITEC(Character) GccSemihostCall(0x03, (UINTN)(Character))
188 #define Semihost_SYS_WRITE(WriteBlock) GccSemihostCall(0x05, (UINTN)(WriteBlock))
189 #define Semihost_SYS_READ(ReadBlock) GccSemihostCall(0x06, (UINTN)(ReadBlock))
190 #define Semihost_SYS_READC() GccSemihostCall(0x07, (UINTN)(0))
191 #define Semihost_SYS_SEEK(SeekBlock) GccSemihostCall(0x0A, (UINTN)(SeekBlock))
192 #define Semihost_SYS_FLEN(Handle) GccSemihostCall(0x0C, (UINTN)(Handle))
193 #define Semihost_SYS_TMPNAME(TmpNameBlock) GccSemihostCall(0x0D, (UINTN)(TmpNameBlock))
194 #define Semihost_SYS_REMOVE(RemoveBlock) GccSemihostCall(0x0E, (UINTN)(RemoveBlock))
195 #define Semihost_SYS_RENAME(RenameBlock) GccSemihostCall(0x0F, (UINTN)(RenameBlock))
196 #define Semihost_SYS_SYSTEM(SystemBlock) GccSemihostCall(0x12, (UINTN)(SystemBlock))
200 #define SEMIHOST_SUPPORTED FALSE
202 #define Semihost_SYS_OPEN(OpenBlock) (-1)
203 #define Semihost_SYS_CLOSE(Handle) (-1)
204 #define Semihost_SYS_WRITE0(String)
205 #define Semihost_SYS_WRITEC(Character)
206 #define Semihost_SYS_WRITE(WriteBlock) (0)
207 #define Semihost_SYS_READ(ReadBlock) ((ReadBlock)->Length)
208 #define Semihost_SYS_READC() ('x')
209 #define Semihost_SYS_SEEK(SeekBlock) (-1)
210 #define Semihost_SYS_FLEN(Handle) (-1)
211 #define Semihost_SYS_TMPNAME(TmpNameBlock) (-1)
212 #define Semihost_SYS_REMOVE(RemoveBlock) (-1)
213 #define Semihost_SYS_RENAME(RenameBlock) (-1)
214 #define Semihost_SYS_SYSTEM(SystemBlock) (-1)
218 #endif //__SEMIHOST_PRIVATE_H__