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