]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/SemihostLib/Arm/SemihostPrivate.h
e82111430a6b290cdcd840a822d0360e77f21a38
[mirror_edk2.git] / ArmPkg / Library / SemihostLib / Arm / SemihostPrivate.h
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
18 typedef struct {
19 CHAR8 *FileName;
20 UINT32 Mode;
21 UINT32 NameLength;
22 } SEMIHOST_FILE_OPEN_BLOCK;
23
24 typedef struct {
25 UINT32 Handle;
26 VOID *Buffer;
27 UINT32 Length;
28 } SEMIHOST_FILE_READ_WRITE_BLOCK;
29
30 typedef struct {
31 UINT32 Handle;
32 UINT32 Location;
33 } SEMIHOST_FILE_SEEK_BLOCK;
34
35 typedef struct {
36 CHAR8 *FileName;
37 UINT32 NameLength;
38 } SEMIHOST_FILE_REMOVE_BLOCK;
39
40 typedef 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)
56 INT32
57 _Semihost_SYS_OPEN(
58 IN UINTN SWI_0x01,
59 IN SEMIHOST_FILE_OPEN_BLOCK *OpenBlock
60 );
61
62 __swi(SWI)
63 INT32
64 _Semihost_SYS_CLOSE(
65 IN UINTN SWI_0x02,
66 IN UINT32 *Handle
67 );
68
69 __swi(SWI)
70 VOID
71 _Semihost_SYS_WRITEC(
72 IN UINTN SWI_0x03,
73 IN CHAR8 *Character
74 );
75
76 __swi(SWI)
77 VOID
78 _Semihost_SYS_WRITE0(
79 IN UINTN SWI_0x04,
80 IN CHAR8 *String
81 );
82
83 __swi(SWI)
84 UINT32
85 _Semihost_SYS_WRITE(
86 IN UINTN SWI_0x05,
87 IN OUT SEMIHOST_FILE_READ_WRITE_BLOCK *WriteBlock
88 );
89
90 __swi(SWI)
91 UINT32
92 _Semihost_SYS_READ(
93 IN UINTN SWI_0x06,
94 IN OUT SEMIHOST_FILE_READ_WRITE_BLOCK *ReadBlock
95 );
96
97 __swi(SWI)
98 CHAR8
99 _Semihost_SYS_READC(
100 IN UINTN SWI_0x07,
101 IN UINTN Zero
102 );
103
104 __swi(SWI)
105 INT32
106 _Semihost_SYS_SEEK(
107 IN UINTN SWI_0x0A,
108 IN SEMIHOST_FILE_SEEK_BLOCK *SeekBlock
109 );
110
111 __swi(SWI)
112 INT32
113 _Semihost_SYS_FLEN(
114 IN UINTN SWI_0x0C,
115 IN UINT32 *Handle
116 );
117
118 __swi(SWI)
119 UINT32
120 _Semihost_SYS_REMOVE(
121 IN UINTN SWI_0x0E,
122 IN SEMIHOST_FILE_REMOVE_BLOCK *RemoveBlock
123 );
124
125 __swi(SWI)
126 UINT32
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__