1 /* $NetBSD: arcbios.h,v 1.13 2011/02/20 08:02:46 matt Exp $ */ 2 3 /*- 4 * Copyright (c) 2001 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Jason R. Thorpe. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 /* 33 * The ARC BIOS (which is similar, but not 100% compatible with SGI ARCS) 34 * specification can be found at: 35 * 36 * http://www.microsoft.com/hwdev/download/respec/riscspec.zip 37 */ 38 39 #ifndef _ARCBIOS_H_ 40 #define _ARCBIOS_H_ 41 42 #define ARCBIOS_STDIN 0 43 #define ARCBIOS_STDOUT 1 44 45 #define ARCBIOS_PAGESIZE 4096 46 47 /* ARC BIOS status codes. */ 48 #define ARCBIOS_ESUCCESS 0 /* Success */ 49 #define ARCBIOS_E2BIG 1 /* argument list too long */ 50 #define ARCBIOS_EACCES 2 /* permission denied */ 51 #define ARCBIOS_EAGAIN 3 /* resource temporarily unavailable */ 52 #define ARCBIOS_EBADF 4 /* bad file number */ 53 #define ARCBIOS_EBUSY 5 /* device or resource busy */ 54 #define ARCBIOS_EFAULT 6 /* bad address */ 55 #define ARCBIOS_EINVAL 7 /* invalid argument */ 56 #define ARCBIOS_EIO 8 /* I/O error */ 57 #define ARCBIOS_EISDIR 9 /* is a directory */ 58 #define ARCBIOS_EMFILE 10 /* too many open files */ 59 #define ARCBIOS_EMLINK 11 /* too many links */ 60 #define ARCBIOS_ENAMETOOLONG 12 /* file name too long */ 61 #define ARCBIOS_ENODEV 13 /* no such device */ 62 #define ARCBIOS_ENOENT 14 /* no such file or directory */ 63 #define ARCBIOS_ENOEXEC 15 /* exec format error */ 64 #define ARCBIOS_ENOMEM 16 /* out of memory */ 65 #define ARCBIOS_ENOSPC 17 /* no space left on device */ 66 #define ARCBIOS_ENOTDIR 18 /* not a directory */ 67 #define ARCBIOS_ENOTTY 19 /* not a typewriter */ 68 #define ARCBIOS_ENXIO 20 /* media not loaded */ 69 #define ARCBIOS_EROFS 21 /* read-only file system */ 70 #if defined(sgimips) 71 #define ARCBIOS_EADDRNOTAVAIL 31 /* address not available */ 72 #define ARCBIOS_ETIMEDOUT 32 /* operation timed out */ 73 #define ARCBIOS_ECONNABORTED 33 /* connection aborted */ 74 #define ARCBIOS_ENOCONNECT 34 /* not connected */ 75 #endif /* sgimips */ 76 77 /* 78 * 4.2.2: System Parameter Block 79 */ 80 struct arcbios_spb { 81 uint32_t SPBSignature; 82 uint32_t SPBLength; 83 uint16_t Version; 84 uint16_t Revision; 85 int32_t RestartBlock; 86 int32_t DebugBlock; 87 int32_t GEVector; 88 int32_t UTLBMissVector; 89 uint32_t FirmwareVectorLength; 90 int32_t FirmwareVector; 91 uint32_t PrivateVectorLength; 92 int32_t PrivateVector; 93 uint32_t AdapterCount; 94 uint32_t AdapterType; 95 uint32_t AdapterVectorLength; 96 int32_t AdapterVector; 97 }; 98 99 #define ARCBIOS_SPB_SIGNATURE 0x53435241 /* A R C S */ 100 #define ARCBIOS_SPB_SIGNATURE_1 0x41524353 /* S C R A */ 101 102 /* 103 * 4.2.5: System Configuration Data 104 */ 105 struct arcbios_component { 106 uint32_t Class; 107 uint32_t Type; 108 uint32_t Flags; 109 uint16_t Version; 110 uint16_t Revision; 111 uint32_t Key; 112 uint32_t AffinityMask; 113 uint32_t ConfigurationDataSize; 114 uint32_t IdentifierLength; 115 int32_t Identifier; 116 }; 117 118 /* 119 * SGI ARCS likes to be `special', so it moved some of the class/type 120 * numbers around from the ARC standard definitions. 121 */ 122 #if defined(sgimips) 123 /* Component Class */ 124 #define COMPONENT_CLASS_SystemClass 0 125 #define COMPONENT_CLASS_ProcessorClass 1 126 #define COMPONENT_CLASS_CacheClass 2 127 #define COMPONENT_CLASS_MemoryClass 3 128 #define COMPONENT_CLASS_AdapterClass 4 129 #define COMPONENT_CLASS_ControllerClass 5 130 #define COMPONENT_CLASS_PeripheralClass 6 131 #else 132 /* Component Class */ 133 #define COMPONENT_CLASS_SystemClass 0 134 #define COMPONENT_CLASS_ProcessorClass 1 135 #define COMPONENT_CLASS_CacheClass 2 136 #define COMPONENT_CLASS_AdapterClass 3 137 #define COMPONENT_CLASS_ControllerClass 4 138 #define COMPONENT_CLASS_PeripheralClass 5 139 #define COMPONENT_CLASS_MemoryClass 6 140 #endif 141 142 /* Component Types */ 143 #if defined(sgimips) 144 /* System Class */ 145 #define COMPONENT_TYPE_ARC 0 146 147 /* Processor Class */ 148 #define COMPONENT_TYPE_CPU 1 149 #define COMPONENT_TYPE_FPU 2 150 151 /* Cache Class */ 152 #define COMPONENT_TYPE_PrimaryICache 3 153 #define COMPONENT_TYPE_PrimaryDCache 4 154 #define COMPONENT_TYPE_SecondaryICache 5 155 #define COMPONENT_TYPE_SecondaryDCache 6 156 #define COMPONENT_TYPE_SecondaryCache 7 157 158 /* Memory Class */ 159 #define COMPONENT_TYPE_MemoryUnit 8 160 161 /* Adapter Class */ 162 #define COMPONENT_TYPE_EISAAdapter 9 163 #define COMPONENT_TYPE_TCAdapter 10 164 #define COMPONENT_TYPE_SCSIAdapter 11 165 #define COMPONENT_TYPE_DTIAdapter 12 166 #define COMPONENT_TYPE_MultiFunctionAdapter 13 167 168 /* Controller Class */ 169 #define COMPONENT_TYPE_DiskController 14 170 #define COMPONENT_TYPE_TapeController 15 171 #define COMPONENT_TYPE_CDROMController 16 172 #define COMPONENT_TYPE_WORMController 17 173 #define COMPONENT_TYPE_SerialController 18 174 #define COMPONENT_TYPE_NetworkController 19 175 #define COMPONENT_TYPE_DisplayController 20 176 #define COMPONENT_TYPE_ParallelController 21 177 #define COMPONENT_TYPE_PointerController 22 178 #define COMPONENT_TYPE_KeyboardController 23 179 #define COMPONENT_TYPE_AudioController 24 180 #define COMPONENT_TYPE_OtherController 25 181 182 /* Peripheral Class */ 183 #define COMPONENT_TYPE_DiskPeripheral 26 184 #define COMPONENT_TYPE_FloppyDiskPeripheral 27 185 #define COMPONENT_TYPE_TapePeripheral 28 186 #define COMPONENT_TYPE_ModemPeripheral 29 187 #define COMPONENT_TYPE_MonitorPeripheral 30 188 #define COMPONENT_TYPE_PrinterPeripheral 31 189 #define COMPONENT_TYPE_PointerPeripheral 32 190 #define COMPONENT_TYPE_KeyboardPeripheral 33 191 #define COMPONENT_TYPE_TerminalPeripheral 34 192 #define COMPONENT_TYPE_LinePeripheral 35 193 #define COMPONENT_TYPE_NetworkPeripheral 36 194 #define COMPONENT_TYPE_OtherPeripheral 37 195 #else /* not sgimips */ 196 /* System Class */ 197 #define COMPONENT_TYPE_ARC 0 198 199 /* Processor Class */ 200 #define COMPONENT_TYPE_CPU 1 201 #define COMPONENT_TYPE_FPU 2 202 203 /* Cache Class */ 204 #define COMPONENT_TYPE_PrimaryICache 3 205 #define COMPONENT_TYPE_PrimaryDCache 4 206 #define COMPONENT_TYPE_SecondaryICache 5 207 #define COMPONENT_TYPE_SecondaryDCache 6 208 #define COMPONENT_TYPE_SecondaryCache 7 209 210 /* Adapter Class */ 211 #define COMPONENT_TYPE_EISAAdapter 8 212 #define COMPONENT_TYPE_TCAdapter 9 213 #define COMPONENT_TYPE_SCSIAdapter 10 214 #define COMPONENT_TYPE_DTIAdapter 11 215 #define COMPONENT_TYPE_MultiFunctionAdapter 12 216 217 /* Controller Class */ 218 #define COMPONENT_TYPE_DiskController 13 219 #define COMPONENT_TYPE_TapeController 14 220 #define COMPONENT_TYPE_CDROMController 15 221 #define COMPONENT_TYPE_WORMController 16 222 #define COMPONENT_TYPE_SerialController 17 223 #define COMPONENT_TYPE_NetworkController 18 224 #define COMPONENT_TYPE_DisplayController 19 225 #define COMPONENT_TYPE_ParallelController 20 226 #define COMPONENT_TYPE_PointerController 21 227 #define COMPONENT_TYPE_KeyboardController 22 228 #define COMPONENT_TYPE_AudioController 23 229 #define COMPONENT_TYPE_OtherController 24 230 231 /* Peripheral Class */ 232 #define COMPONENT_TYPE_DiskPeripheral 25 233 #define COMPONENT_TYPE_FloppyDiskPeripheral 26 234 #define COMPONENT_TYPE_TapePeripheral 27 235 #define COMPONENT_TYPE_ModemPeripheral 28 236 #define COMPONENT_TYPE_MonitorPeripheral 29 237 #define COMPONENT_TYPE_PrinterPeripheral 30 238 #define COMPONENT_TYPE_PointerPeripheral 31 239 #define COMPONENT_TYPE_KeyboardPeripheral 32 240 #define COMPONENT_TYPE_TerminalPeripheral 33 241 #define COMPONENT_TYPE_OtherPeripheral 34 242 #define COMPONENT_TYPE_LinePeripheral 35 243 #define COMPONENT_TYPE_NetworkPeripheral 36 244 245 /* Memory Class */ 246 #define COMPONENT_TYPE_MemoryUnit 37 247 #endif 248 249 /* Component flags */ 250 #define COMPONENT_FLAG_Failed 1 251 #define COMPONENT_FLAG_ReadOnly 2 252 #define COMPONENT_FLAG_Removable 4 253 #define COMPONENT_FLAG_ConsoleIn 8 254 #define COMPONENT_FLAG_ConsoleOut 16 255 #define COMPONENT_FLAG_Input 32 256 #define COMPONENT_FLAG_Output 64 257 258 /* Key for Cache: */ 259 #define COMPONENT_KEY_Cache_CacheSize(x) \ 260 (ARCBIOS_PAGESIZE << ((x) & 0xffff)) 261 #define COMPONENT_KEY_Cache_LineSize(x) \ 262 (1U << (((x) >> 16) & 0xff)) 263 #define COMPONENT_KEY_Cache_RefillSize(x) \ 264 (((x) >> 24) & 0xff) 265 266 /* 267 * ARC system ID 268 */ 269 #define ARCBIOS_SYSID_FIELDLEN 8 270 struct arcbios_sysid { 271 char VendorId[ARCBIOS_SYSID_FIELDLEN]; 272 char ProductId[ARCBIOS_SYSID_FIELDLEN]; 273 }; 274 275 /* 276 * ARC memory descriptor 277 */ 278 struct arcbios_mem { 279 uint32_t Type; 280 uint32_t BasePage; 281 uint32_t PageCount; 282 }; 283 284 #if defined(sgimips) 285 #define ARCBIOS_MEM_ExceptionBlock 0 286 #define ARCBIOS_MEM_SystemParameterBlock 1 287 #define ARCBIOS_MEM_FreeContiguous 2 288 #define ARCBIOS_MEM_FreeMemory 3 289 #define ARCBIOS_MEM_BadMemory 4 290 #define ARCBIOS_MEM_LoadedProgram 5 291 #define ARCBIOS_MEM_FirmwareTemporary 6 292 #define ARCBIOS_MEM_FirmwarePermanent 7 293 #elif defined(arc) 294 #define ARCBIOS_MEM_ExceptionBlock 0 295 #define ARCBIOS_MEM_SystemParameterBlock 1 296 #define ARCBIOS_MEM_FreeMemory 2 297 #define ARCBIOS_MEM_BadMemory 3 298 #define ARCBIOS_MEM_LoadedProgram 4 299 #define ARCBIOS_MEM_FirmwareTemporary 5 300 #define ARCBIOS_MEM_FirmwarePermanent 6 301 #define ARCBIOS_MEM_FreeContiguous 7 302 #endif 303 304 /* 305 * ARC display status 306 */ 307 struct arcbios_dsp_stat { 308 uint16_t CursorXPosition; 309 uint16_t CursorYPosition; 310 uint16_t CursorMaxXPosition; 311 uint16_t CursorMaxYPosition; 312 uint8_t ForegroundColor; 313 uint8_t BackgroundColor; 314 uint8_t HighIntensity; 315 uint8_t Underscored; 316 uint8_t ReverseVideo; 317 }; 318 319 /* 320 * ARC firmware vector 321 */ 322 struct arcbios_fv { 323 int32_t Load; 324 int32_t Invoke; 325 int32_t Execute; 326 int32_t Halt; 327 int32_t PowerDown; 328 int32_t Restart; 329 int32_t Reboot; 330 int32_t EnterInteractiveMode; 331 int32_t ReturnFromMain; /* not on sgimips */ 332 int32_t GetPeer; 333 int32_t GetChild; 334 int32_t GetParent; 335 int32_t GetConfigurationData; 336 int32_t AddChild; 337 int32_t DeleteComponent; 338 int32_t GetComponent; 339 int32_t SaveConfiguration; 340 int32_t GetSystemId; 341 int32_t GetMemoryDescriptor; 342 int32_t Signal; /* not on sgimips */ 343 int32_t GetTime; 344 int32_t GetRelativeTime; 345 int32_t GetDirectoryEntry; 346 int32_t Open; 347 int32_t Close; 348 int32_t Read; 349 int32_t GetReadStatus; 350 int32_t Write; 351 int32_t Seek; 352 int32_t Mount; 353 int32_t GetEnvironmentVariable; 354 int32_t SetEnvironmentVariable; 355 int32_t GetFileInformation; 356 int32_t SetFileInformation; 357 int32_t FlushAllCaches; 358 int32_t TestUnicode; /* not on sgimips */ 359 int32_t GetDisplayStatus; /* not on sgimips */ 360 }; 361 362 #if defined(_KERNEL) || defined(_STANDALONE) 363 /* 364 * ARC firmware vector calls 365 */ 366 long arcbios_Load(char *, u_long, u_long, u_long *); 367 long arcbios_Invoke(u_long, u_long, u_long, char **, char **); 368 long arcbios_Execute(char *, u_long, char **, char **); 369 void arcbios_Halt(void) __dead; 370 void arcbios_PowerDown(void) __dead; 371 void arcbios_Restart(void) __dead; 372 void arcbios_Reboot(void) __dead; 373 void arcbios_EnterInteractiveMode(void) __dead; 374 void arcbios_ReturnFromMain(void) __dead; /* not on sgimips */ 375 void * arcbios_GetPeer(void *); 376 void * arcbios_GetChild(void *); 377 void * arcbios_GetParent(void *); 378 long arcbios_GetConfigurationData(void *, void *); 379 void * arcbios_AddChild(void *, void *); 380 long arcbios_DeleteComponent(void *); 381 void * arcbios_GetComponent(char *); 382 long arcbios_SaveConfiguration(void); 383 void * arcbios_GetSystemId(void); 384 void * arcbios_GetMemoryDescriptor(void *); 385 void arcbios_Signal(u_long, void *); /* not on sgimips */ 386 void * arcbios_GetTime(void); 387 u_long arcbios_GetRelativeTime(void); 388 389 long arcbios_GetDirectoryEntry(u_long, void *, u_long, u_long *); 390 long arcbios_Open(const char *, u_long, u_long *); 391 long arcbios_Close(u_long); 392 long arcbios_Read(u_long, void *, u_long, u_long *); 393 long arcbios_GetReadStatus(u_long); 394 long arcbios_Write(u_long, void *, u_long, u_long *); 395 long arcbios_Seek(u_long, int64_t *, u_long); 396 long arcbios_Mount(char *, u_long); 397 const char * 398 arcbios_GetEnvironmentVariable(const char *); 399 long arcbios_SetEnvironmentVariable(const char *, const char *); 400 long arcbios_GetFileInformation(u_long, void *); 401 long arcbios_SetFileInformation(u_long, u_long, u_long); 402 void arcbios_FlushAllCaches(void); 403 paddr_t arcbios_TestUnicode(u_long, uint16_t); /* not on sgimips */ 404 void * arcbios_GetDisplayStatus(u_long); /* not on sgimips */ 405 406 #endif /* _KERNEL || _STANDALONE */ 407 408 #endif /* _ARCBIOS_H_ */ 409