One more header fix
[mirror_edk2.git] / ArmPkg / Library / SemihostLib / Arm / SemihostPrivate.h
CommitLineData
2ef2b01e
A
1/** @file
2
3 Copyright (c) 2008-2009 Apple Inc. All rights reserved.<BR>
4
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
9
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.
12
13**/
14
15#ifndef __SEMIHOST_PRIVATE_H__
16#define __SEMIHOST_PRIVATE_H__
17
18typedef struct {
19 CHAR8 *FileName;
20 UINT32 Mode;
21 UINT32 NameLength;
22} SEMIHOST_FILE_OPEN_BLOCK;
23
24typedef struct {
25 UINT32 Handle;
26 VOID *Buffer;
27 UINT32 Length;
28} SEMIHOST_FILE_READ_WRITE_BLOCK;
29
30typedef struct {
31 UINT32 Handle;
32 UINT32 Location;
33} SEMIHOST_FILE_SEEK_BLOCK;
34
35typedef struct {
36 CHAR8 *FileName;
37 UINT32 NameLength;
38} SEMIHOST_FILE_REMOVE_BLOCK;
39
40typedef struct {
41 CHAR8 *CommandLine;
42 UINT32 CommandLength;
43} SEMIHOST_SYSTEM_BLOCK;
44
45#ifdef __CC_ARM
46
47#if defined(__thumb__)
48#define SWI 0xAB
49#else
50#define SWI 0x123456
51#endif
52
53#define SEMIHOST_SUPPORTED TRUE
54
55__swi(SWI)
56INT32
57_Semihost_SYS_OPEN(
58 IN UINTN SWI_0x01,
59 IN SEMIHOST_FILE_OPEN_BLOCK *OpenBlock
60 );
61
62__swi(SWI)
63INT32
64_Semihost_SYS_CLOSE(
65 IN UINTN SWI_0x02,
66 IN UINT32 *Handle
67 );
68
69__swi(SWI)
70VOID
71_Semihost_SYS_WRITEC(
72 IN UINTN SWI_0x03,
73 IN CHAR8 *Character
74 );
75
76__swi(SWI)
77VOID
78_Semihost_SYS_WRITE0(
79 IN UINTN SWI_0x04,
80 IN CHAR8 *String
81 );
82
83__swi(SWI)
84UINT32
85_Semihost_SYS_WRITE(
86 IN UINTN SWI_0x05,
87 IN OUT SEMIHOST_FILE_READ_WRITE_BLOCK *WriteBlock
88 );
89
90__swi(SWI)
91UINT32
92_Semihost_SYS_READ(
93 IN UINTN SWI_0x06,
94 IN OUT SEMIHOST_FILE_READ_WRITE_BLOCK *ReadBlock
95 );
96
97__swi(SWI)
98CHAR8
99_Semihost_SYS_READC(
100 IN UINTN SWI_0x07,
101 IN UINTN Zero
102 );
103
104__swi(SWI)
105INT32
106_Semihost_SYS_SEEK(
107 IN UINTN SWI_0x0A,
108 IN SEMIHOST_FILE_SEEK_BLOCK *SeekBlock
109 );
110
111__swi(SWI)
112INT32
113_Semihost_SYS_FLEN(
114 IN UINTN SWI_0x0C,
115 IN UINT32 *Handle
116 );
117
118__swi(SWI)
119UINT32
120_Semihost_SYS_REMOVE(
121 IN UINTN SWI_0x0E,
122 IN SEMIHOST_FILE_REMOVE_BLOCK *RemoveBlock
123 );
124
125__swi(SWI)
126UINT32
127_Semihost_SYS_SYSTEM(
128 IN UINTN SWI_0x12,
129 IN SEMIHOST_SYSTEM_BLOCK *SystemBlock
130 );
131
132#define Semihost_SYS_OPEN(OpenBlock) _Semihost_SYS_OPEN(0x01, OpenBlock)
133#define Semihost_SYS_CLOSE(Handle) _Semihost_SYS_CLOSE(0x02, Handle)
134#define Semihost_SYS_WRITE0(String) _Semihost_SYS_WRITE0(0x04, String)
135#define Semihost_SYS_WRITEC(Character) _Semihost_SYS_WRITEC(0x03, Character)
136#define Semihost_SYS_WRITE(WriteBlock) _Semihost_SYS_WRITE(0x05, WriteBlock)
137#define Semihost_SYS_READ(ReadBlock) _Semihost_SYS_READ(0x06, ReadBlock)
138#define Semihost_SYS_READC() _Semihost_SYS_READC(0x07, 0)
139#define Semihost_SYS_SEEK(SeekBlock) _Semihost_SYS_SEEK(0x0A, SeekBlock)
140#define Semihost_SYS_FLEN(Handle) _Semihost_SYS_FLEN(0x0C, Handle)
141#define Semihost_SYS_REMOVE(RemoveBlock) _Semihost_SYS_REMOVE(0x0E, RemoveBlock)
142#define Semihost_SYS_SYSTEM(SystemBlock) _Semihost_SYS_SYSTEM(0x12, SystemBlock)
143
144#else // __CC_ARM
145
146#define SEMIHOST_SUPPORTED FALSE
147
148#define Semihost_SYS_OPEN(OpenBlock) (-1)
149#define Semihost_SYS_CLOSE(Handle) (-1)
150#define Semihost_SYS_WRITE0(String)
151#define Semihost_SYS_WRITEC(Character)
152#define Semihost_SYS_WRITE(WriteBlock) (0)
153#define Semihost_SYS_READ(ReadBlock) ((ReadBlock)->Length)
154#define Semihost_SYS_READC() ('x')
155#define Semihost_SYS_SEEK(SeekBlock) (-1)
156#define Semihost_SYS_FLEN(Handle) (-1)
157#define Semihost_SYS_REMOVE(RemoveBlock) (-1)
158#define Semihost_SYS_SYSTEM(SystemBlock) (-1)
159
160#endif // __CC_ARM
161
162#endif //__SEMIHOST_PRIVATE_H__