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
;
43 OpenBlock
.FileName
= FileName
;
44 OpenBlock
.Mode
= Mode
;
45 OpenBlock
.NameLength
= AsciiStrLen(FileName
);
47 Result
= Semihost_SYS_OPEN(&OpenBlock
);
63 SEMIHOST_FILE_SEEK_BLOCK SeekBlock
;
66 SeekBlock
.Handle
= FileHandle
;
67 SeekBlock
.Location
= Offset
;
69 Result
= Semihost_SYS_SEEK(&SeekBlock
);
81 IN OUT UINT32
*Length
,
85 SEMIHOST_FILE_READ_WRITE_BLOCK ReadBlock
;
88 if ((Length
== NULL
) || (Buffer
== NULL
)) {
89 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
) {
108 IN UINT32 FileHandle
,
109 IN OUT UINT32
*Length
,
113 SEMIHOST_FILE_READ_WRITE_BLOCK WriteBlock
;
115 if ((Length
== NULL
) || (Buffer
== NULL
)) {
116 return EFI_INVALID_PARAMETER
;
119 WriteBlock
.Handle
= FileHandle
;
120 WriteBlock
.Buffer
= Buffer
;
121 WriteBlock
.Length
= *Length
;
123 *Length
= Semihost_SYS_WRITE(&WriteBlock
);
133 INT32 Result
= Semihost_SYS_CLOSE(&FileHandle
);
136 return EFI_INVALID_PARAMETER
;
144 IN UINT32 FileHandle
,
150 if (Length
== NULL
) {
151 return EFI_INVALID_PARAMETER
;
154 Result
= Semihost_SYS_FLEN(&FileHandle
);
169 SEMIHOST_FILE_REMOVE_BLOCK RemoveBlock
;
172 RemoveBlock
.FileName
= FileName
;
173 RemoveBlock
.NameLength
= AsciiStrLen(FileName
);
175 Result
= Semihost_SYS_REMOVE(&RemoveBlock
);
185 SemihostReadCharacter (
189 return Semihost_SYS_READC();
193 SemihostWriteCharacter (
197 Semihost_SYS_WRITEC(&Character
);
201 SemihostWriteString (
205 Semihost_SYS_WRITE0(String
);
210 IN CHAR8
*CommandLine
213 SEMIHOST_SYSTEM_BLOCK SystemBlock
;
215 SystemBlock
.CommandLine
= CommandLine
;
216 SystemBlock
.CommandLength
= AsciiStrLen(CommandLine
);
218 return Semihost_SYS_SYSTEM(&SystemBlock
);