2 * Copyright (c) 1999, Stefan Esser <se@freebsd.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice unmodified, this list of conditions, and the following
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * $FreeBSD: src/sys/boot/arc/include/arcfuncs.h,v 1.2 1999/08/28 00:39:34 peter Exp $
27 * $DragonFly: src/sys/boot/arc/include/Attic/arcfuncs.h,v 1.2 2003/06/17 04:28:16 dillon Exp $
37 /* System Parameter Block holding ARC and VENDOR function vector addresses */
39 #define SPBlock ((SPB *)0xffffffff806fe000ul)
42 * Convert between 32bit (ARC) and 64bit (Alpha) pointers
48 return (void*)(int64_t)p.adr;
55 p32.adr = (int32_t)(int64_t) p;
60 * Return entry point for ARC BIOS function "funcno"
64 get_arc_vector(int funcno)
66 arcptr (*arc_vector)[] = ptr(SPBlock->FirmwareVectorP);
67 return ptr((*arc_vector)[funcno -1]);
71 * Return entry point for VENDOR function "funcno"
75 get_vendor_vector(int funcno)
77 arcptr (*arc_vector)[] = ptr(SPBlock->PrivateVectorP);
78 return ptr((*arc_vector)[funcno -1]);
82 get_vendor_vector_length(void)
84 return SPBlock->PrivateVectorLength;
88 * Macros to create inline wrappers for ARCS BIOS functions
91 * num function number (starting at 1)
94 * param parameter list (types and formal args)
95 * args parameter list (formal args only)
98 #define ARC_FN(num,result,fn,param,args) \
99 static inline result fn param { \
100 typedef result _fn_t param; \
101 _fn_t *p_ ## fn = get_arc_vector(num); \
102 return p_ ## fn args; \
105 #define VND_FN(num,result,fn,param,args) \
106 static INLINE result fn param { \
107 typedef result _fn_t param; \
108 _fn_t *p_ ## fn = get_vendor_vector(num); \
109 return p_ ## fn args; \
112 /* function codes as defined in ARC Specification Version 1.2 */
114 ARC_FN(1, int32_t, Load,
115 (char *Path, u_int32_t TopAddr, u_int32_t *ExecAddr, u_int32_t *LowAddr),
116 (Path, TopAddr, ExecAddr, LowAddr))
117 ARC_FN(2, int32_t, Invoke,
118 (u_int32_t ExecAddr, u_int32_t StackAddr, u_int32_t Argc, char *Argv[], char *Envp[]),
119 (ExecAddr, StackAddr, Argc, Argv, Envp))
120 ARC_FN(3, int32_t, Execute,
121 (char *Path, u_int32_t Argc, char *Argv[], char *Envp[]),
122 (Path, Argc, Argv, Envp))
123 ARC_FN(4, void, Halt, (void), ())
124 ARC_FN(5, void, PowerDown, (void), ())
125 ARC_FN(6, void, Restart, (void), ())
126 ARC_FN(7, void, FwReboot, (void), ())
127 ARC_FN(8, void, EnterInteractiveMode, (void), ())
128 ARC_FN(10, CONFIGURATION_COMPONENT *, GetPeer,
129 (CONFIGURATION_COMPONENT *Current),
131 ARC_FN(11, CONFIGURATION_COMPONENT *, GetChild,
132 (CONFIGURATION_COMPONENT *Current),
134 ARC_FN(12, CONFIGURATION_COMPONENT *, GetParent,
135 (CONFIGURATION_COMPONENT *Current),
137 ARC_FN(13, CONFIGURATION_COMPONENT *, AddChild,
138 (CONFIGURATION_COMPONENT *Current, CONFIGURATION_COMPONENT *Template,
139 void *ConfigurationData),
140 (Current, Template, ConfigurationData))
141 ARC_FN(14, int32_t, DeleteComponent,
142 (CONFIGURATION_COMPONENT *ComponentToDelete),
144 ARC_FN(15, CONFIGURATION_COMPONENT *, GetComponent, (char *Path), (Path))
145 ARC_FN(16, int32_t, GetConfigurationData,
146 (void *ConfigurationData, CONFIGURATION_COMPONENT *Component),
147 (ConfigurationData, Component))
148 ARC_FN(17, int32_t, SaveConfiguration, (void), ())
149 ARC_FN(18, SYSTEM_ID *, GetSystemId, (void), ())
150 ARC_FN(19, MEMORY_DESCRIPTOR *, GetMemoryDescriptor,
151 (MEMORY_DESCRIPTOR *Current),
153 ARC_FN(21, TIME_FIELDS *, GetTime, (void), ())
154 ARC_FN(22, u_int32_t, GetRelativeTime, (void), ())
155 ARC_FN(23, int32_t, GetDirectoryEntry,
156 (u_int32_t FileId, DIRECTORY_ENTRY *Buffer, u_int32_t Length, u_int32_t *Count),
157 (FileId, Buffer, Length, Count))
158 ARC_FN(24, int32_t, Open,
159 (const char *Path, OPEN_MODE OpenMode, u_int32_t *FileId),
160 (Path, OpenMode, FileId))
161 ARC_FN(25, int32_t, Close, (u_int32_t FileId), (FileId))
162 ARC_FN(26, int32_t, Read,
163 (u_int32_t FileId, void *Buffer, u_int32_t N, u_int32_t *Count),
164 (FileId, Buffer, N, Count))
165 ARC_FN(27, int32_t, GetReadStatus, (u_int32_t FileId), (FileId))
166 ARC_FN(28, int32_t, Write,
167 (u_int32_t FileId, void const *Buffer, u_int32_t N, u_int32_t *Count),
168 (FileId, Buffer, N, Count))
169 ARC_FN(29, int32_t, Seek,
170 (u_int32_t FileId, fpos_t *Position, SEEK_MODE SeekMode),
171 (FileId, Position, SeekMode))
172 ARC_FN(30, int32_t, Mount,
173 (char *Path, MOUNT_OPERATION Operation),
175 ARC_FN(31, char *, GetEnvironmentVariable, (char *Name), (Name))
176 ARC_FN(32, int32_t, SetEnvironmentVariable,
177 (char *Name, char *Value),
179 ARC_FN(33, int32_t, GetFileInformation,
180 (u_int32_t FileId, FILE_INFORMATION *Information),
181 (FileId, Information))
182 ARC_FN(34, int32_t, SetFileInformation,
183 (u_int32_t FileId, u_int32_t AttributeFlags, u_int32_t AttributeMask),
184 (FileId, AttributeFlags, AttributeMask))
185 ARC_FN(35, void, FlushAllCaches, (void), ())
186 ARC_FN(36, int32_t, TestUnicodeCharacter,
187 (u_int32_t FileId, WCHAR UnicodeCharacter),
188 (FileId, UnicodeCharacter))
189 ARC_FN(37, ARC_DISPLAY_STATUS *, GetDisplayStatus, (u_int32_t FileId), (FileId))
191 /* Vendor specific function codes have not been verified beyond function 4 */
193 VND_FN(1, void *, AllocatePool, (u_int32_t NumberOfBytes), (NumberOfBytes))
194 VND_FN(2, void, StallExecution, (u_int32_t Microseconds), (Microseconds))
195 VND_FN(3, u_int32_t, Print,
196 (char *Format, int32_t Arg1, int32_t Arg2, int32_t Arg3),
197 (Format, Arg1, Arg2, Arg3))
198 VND_FN(4, void, ReturnExtendedSystemInformation,
199 (EXTENDED_SYSTEM_INFORMATION *SystemInfo),