3 Copyright (c) 2008-2009, Apple Inc. All rights reserved.
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include <Library/BaseLib.h>
17 #include <Library/SemihostLib.h>
19 #include "SemihostPrivate.h"
22 SemihostConnectionSupported (
26 return SEMIHOST_SUPPORTED
;
33 OUT UINT32
*FileHandle
36 SEMIHOST_FILE_OPEN_BLOCK OpenBlock
;
39 if (FileHandle
== NULL
)
40 return EFI_INVALID_PARAMETER
;
42 OpenBlock
.FileName
= FileName
;
43 OpenBlock
.Mode
= Mode
;
44 OpenBlock
.NameLength
= AsciiStrLen(FileName
);
46 Result
= Semihost_SYS_OPEN(&OpenBlock
);
65 SEMIHOST_FILE_SEEK_BLOCK SeekBlock
;
68 SeekBlock
.Handle
= FileHandle
;
69 SeekBlock
.Location
= Offset
;
71 Result
= Semihost_SYS_SEEK(&SeekBlock
);
82 IN OUT UINT32
*Length
,
86 SEMIHOST_FILE_READ_WRITE_BLOCK ReadBlock
;
89 if ((Length
== NULL
) || (Buffer
== NULL
))
90 return EFI_INVALID_PARAMETER
;
92 ReadBlock
.Handle
= FileHandle
;
93 ReadBlock
.Buffer
= Buffer
;
94 ReadBlock
.Length
= *Length
;
96 Result
= Semihost_SYS_READ(&ReadBlock
);
98 if (Result
== *Length
)
111 IN UINT32 FileHandle
,
112 IN OUT UINT32
*Length
,
116 SEMIHOST_FILE_READ_WRITE_BLOCK WriteBlock
;
118 if ((Length
== NULL
) || (Buffer
== NULL
))
119 return EFI_INVALID_PARAMETER
;
121 WriteBlock
.Handle
= FileHandle
;
122 WriteBlock
.Buffer
= Buffer
;
123 WriteBlock
.Length
= *Length
;
125 *Length
= Semihost_SYS_WRITE(&WriteBlock
);
135 INT32 Result
= Semihost_SYS_CLOSE(&FileHandle
);
138 return EFI_INVALID_PARAMETER
;
145 IN UINT32 FileHandle
,
152 return EFI_INVALID_PARAMETER
;
154 Result
= Semihost_SYS_FLEN(&FileHandle
);
172 SEMIHOST_FILE_REMOVE_BLOCK RemoveBlock
;
175 RemoveBlock
.FileName
= FileName
;
176 RemoveBlock
.NameLength
= AsciiStrLen(FileName
);
178 Result
= Semihost_SYS_REMOVE(&RemoveBlock
);
187 SemihostReadCharacter (
191 return Semihost_SYS_READC();
195 SemihostWriteCharacter (
199 Semihost_SYS_WRITEC(&Character
);
203 SemihostWriteString (
207 Semihost_SYS_WRITE0(String
);
212 IN CHAR8
*CommandLine
215 SEMIHOST_SYSTEM_BLOCK SystemBlock
;
217 SystemBlock
.CommandLine
= CommandLine
;
218 SystemBlock
.CommandLength
= AsciiStrLen(CommandLine
);
220 return Semihost_SYS_SYSTEM(&SystemBlock
);