]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Library/SemihostLib/SemihostPrivate.h
ArmPkg: Moved ARMv7 specific files to a 'Arm' subdirectory
[mirror_edk2.git] / ArmPkg / Library / SemihostLib / SemihostPrivate.h
CommitLineData
1e57a462 1/** @file\r
2\r
3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
4\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef __SEMIHOST_PRIVATE_H__\r
16#define __SEMIHOST_PRIVATE_H__\r
17\r
18typedef struct {\r
19 CHAR8 *FileName;\r
20 UINT32 Mode;\r
21 UINT32 NameLength;\r
22} SEMIHOST_FILE_OPEN_BLOCK;\r
23\r
24typedef struct {\r
25 UINT32 Handle;\r
26 VOID *Buffer;\r
27 UINT32 Length;\r
28} SEMIHOST_FILE_READ_WRITE_BLOCK;\r
29\r
30typedef struct {\r
31 UINT32 Handle;\r
32 UINT32 Location;\r
33} SEMIHOST_FILE_SEEK_BLOCK;\r
34\r
35typedef struct {\r
36 CHAR8 *FileName;\r
37 UINT32 NameLength;\r
38} SEMIHOST_FILE_REMOVE_BLOCK;\r
39\r
40typedef struct {\r
41 CHAR8 *CommandLine;\r
42 UINT32 CommandLength;\r
43} SEMIHOST_SYSTEM_BLOCK;\r
44\r
45#if defined(__CC_ARM) \r
46\r
47#if defined(__thumb__)\r
48#define SWI 0xAB\r
49#else\r
50#define SWI 0x123456\r
51#endif\r
52\r
53#define SEMIHOST_SUPPORTED TRUE\r
54\r
55__swi(SWI)\r
56INT32\r
57_Semihost_SYS_OPEN(\r
58 IN UINTN SWI_0x01,\r
59 IN SEMIHOST_FILE_OPEN_BLOCK *OpenBlock\r
60 );\r
61\r
62__swi(SWI)\r
63INT32\r
64_Semihost_SYS_CLOSE(\r
65 IN UINTN SWI_0x02,\r
66 IN UINT32 *Handle\r
67 );\r
68\r
69__swi(SWI)\r
70VOID\r
71_Semihost_SYS_WRITEC(\r
72 IN UINTN SWI_0x03,\r
73 IN CHAR8 *Character\r
74 );\r
75\r
76__swi(SWI)\r
77VOID\r
78_Semihost_SYS_WRITE0(\r
79 IN UINTN SWI_0x04,\r
80 IN CHAR8 *String\r
81 );\r
82\r
83__swi(SWI)\r
84UINT32\r
85_Semihost_SYS_WRITE(\r
86 IN UINTN SWI_0x05,\r
87 IN OUT SEMIHOST_FILE_READ_WRITE_BLOCK *WriteBlock\r
88 );\r
89\r
90__swi(SWI)\r
91UINT32\r
92_Semihost_SYS_READ(\r
93 IN UINTN SWI_0x06,\r
94 IN OUT SEMIHOST_FILE_READ_WRITE_BLOCK *ReadBlock\r
95 );\r
96\r
97__swi(SWI)\r
98CHAR8\r
99_Semihost_SYS_READC(\r
100 IN UINTN SWI_0x07,\r
101 IN UINTN Zero\r
102 );\r
103\r
104__swi(SWI)\r
105INT32\r
106_Semihost_SYS_SEEK(\r
107 IN UINTN SWI_0x0A,\r
108 IN SEMIHOST_FILE_SEEK_BLOCK *SeekBlock\r
109 );\r
110\r
111__swi(SWI)\r
112INT32\r
113_Semihost_SYS_FLEN(\r
114 IN UINTN SWI_0x0C,\r
115 IN UINT32 *Handle\r
116 );\r
117\r
118__swi(SWI)\r
119UINT32\r
120_Semihost_SYS_REMOVE(\r
121 IN UINTN SWI_0x0E,\r
122 IN SEMIHOST_FILE_REMOVE_BLOCK *RemoveBlock\r
123 );\r
124\r
125__swi(SWI)\r
126UINT32\r
127_Semihost_SYS_SYSTEM(\r
128 IN UINTN SWI_0x12,\r
129 IN SEMIHOST_SYSTEM_BLOCK *SystemBlock\r
130 );\r
131\r
132#define Semihost_SYS_OPEN(OpenBlock) _Semihost_SYS_OPEN(0x01, OpenBlock)\r
133#define Semihost_SYS_CLOSE(Handle) _Semihost_SYS_CLOSE(0x02, Handle)\r
134#define Semihost_SYS_WRITE0(String) _Semihost_SYS_WRITE0(0x04, String)\r
135#define Semihost_SYS_WRITEC(Character) _Semihost_SYS_WRITEC(0x03, Character)\r
136#define Semihost_SYS_WRITE(WriteBlock) _Semihost_SYS_WRITE(0x05, WriteBlock)\r
137#define Semihost_SYS_READ(ReadBlock) _Semihost_SYS_READ(0x06, ReadBlock)\r
138#define Semihost_SYS_READC() _Semihost_SYS_READC(0x07, 0)\r
139#define Semihost_SYS_SEEK(SeekBlock) _Semihost_SYS_SEEK(0x0A, SeekBlock)\r
140#define Semihost_SYS_FLEN(Handle) _Semihost_SYS_FLEN(0x0C, Handle)\r
141#define Semihost_SYS_REMOVE(RemoveBlock) _Semihost_SYS_REMOVE(0x0E, RemoveBlock)\r
142#define Semihost_SYS_SYSTEM(SystemBlock) _Semihost_SYS_SYSTEM(0x12, SystemBlock)\r
143\r
144#elif defined(__GNUC__) // __CC_ARM\r
145\r
146#define SEMIHOST_SUPPORTED TRUE\r
147\r
148UINT32\r
149GccSemihostCall (\r
150 IN UINT32 Operation,\r
151 IN UINTN SystemBlockAddress\r
152 ); // __attribute__ ((interrupt ("SVC")));\r
153\r
154#define Semihost_SYS_OPEN(OpenBlock) GccSemihostCall(0x01, (UINTN)(OpenBlock))\r
155#define Semihost_SYS_CLOSE(Handle) GccSemihostCall(0x02, (UINTN)(Handle))\r
156#define Semihost_SYS_WRITE0(String) GccSemihostCall(0x04, (UINTN)(String))\r
157#define Semihost_SYS_WRITEC(Character) GccSemihostCall(0x03, (UINTN)(Character))\r
158#define Semihost_SYS_WRITE(WriteBlock) GccSemihostCall(0x05, (UINTN)(WriteBlock))\r
159#define Semihost_SYS_READ(ReadBlock) GccSemihostCall(0x06, (UINTN)(ReadBlock))\r
160#define Semihost_SYS_READC() GccSemihostCall(0x07, (UINTN)(0))\r
161#define Semihost_SYS_SEEK(SeekBlock) GccSemihostCall(0x0A, (UINTN)(SeekBlock))\r
162#define Semihost_SYS_FLEN(Handle) GccSemihostCall(0x0C, (UINTN)(Handle))\r
163#define Semihost_SYS_REMOVE(RemoveBlock) GccSemihostCall(0x0E, (UINTN)(RemoveBlock))\r
164#define Semihost_SYS_SYSTEM(SystemBlock) GccSemihostCall(0x12, (UINTN)(SystemBlock))\r
165\r
166#else // __CC_ARM\r
167\r
168#define SEMIHOST_SUPPORTED FALSE\r
169\r
170#define Semihost_SYS_OPEN(OpenBlock) (-1)\r
171#define Semihost_SYS_CLOSE(Handle) (-1)\r
172#define Semihost_SYS_WRITE0(String)\r
173#define Semihost_SYS_WRITEC(Character)\r
174#define Semihost_SYS_WRITE(WriteBlock) (0)\r
175#define Semihost_SYS_READ(ReadBlock) ((ReadBlock)->Length)\r
176#define Semihost_SYS_READC() ('x')\r
177#define Semihost_SYS_SEEK(SeekBlock) (-1)\r
178#define Semihost_SYS_FLEN(Handle) (-1)\r
179#define Semihost_SYS_REMOVE(RemoveBlock) (-1)\r
180#define Semihost_SYS_SYSTEM(SystemBlock) (-1)\r
181\r
182#endif // __CC_ARM\r
183\r
184#endif //__SEMIHOST_PRIVATE_H__\r