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