arcs.h 5.69 KB
typedef enum {
	SystemClass,
	ProcessorClass,
	CacheClass,
	MemoryClass,
	AdapterClass,
	ControllerClass,
	PeripheralClass
} _ConfigClass;

typedef enum {
	ARC,
	CPU,
	FPU,
	PrimaryICache,
	PrimaryDCache,
	SecondaryICache,
	SecondaryDCache,
	SecondaryCache,
	Memory,
	EISAAdapter,
	TCAdapter,
	SCSIAdapter,
	DTIAdapter,
	MultiFunctionAdapter,
	DiskController,
	TapeController,
	CDROMController,
	WORMController,
	SerialController,
	NetworkController,
	DisplayController,
	ParallelController,
	PointerController,
	KeyboardController,
	AudioController,
	OtherController,
	DiskPeripheral,
	FloppyDiskPeripheral,
	TapePeripheral,
	ModemPeripheral,
	MonitorPeripheral,
	PrinterPeripheral,
	PointerPeripheral,
	KeyboardPeripheral,
	TerminalPeripheral,
	LinePeripheral,
	NetworkPeripheral,
	OtherPeripheral
} _ConfigType;

typedef enum {
	Failed = 1,
	ReadOnly = 2,
	Removable = 4,
	ConsoleIn = 8,
	ConsoleOut = 16,
	Input = 32,
	Output = 64
} _IdentifierFlag;

typedef struct {
	_ConfigClass	Class;
	_ConfigType	Type;
	_IdentifierFlag	Flags;
	unsigned short	Version;
	unsigned short	Revision;
	unsigned long	Key;
	unsigned long	AffinityMask;
	unsigned long	ConfigurationDataSize;
	unsigned long	IdentifierLength;
	char		*Identifier;
} _Component;

typedef struct {
	long long	StartingAddress;
	long long	EndingAddress;
	long long	CurrentAddress;
	_ConfigType	Type;
	unsigned long	FilenameLength;
	unsigned char	Attributes;
	char		FileName[32];
} _FileInformation;

typedef struct {
	char VendorId[8];
	char ProductId[8];
} _SystemId;

typedef enum {
	ExceptionBlock,
	SPBPage,			/* ARCS == SystemParameterBlock */
	FreeContiguous,
	FreeMemory,
	BadMemory,
	LoadedProgram,
	FirmwareTemporary,
	FirmwarePermanent
} _MemoryType;

typedef struct {
	_MemoryType	Type;
	long		BasePage;
	long		PageCount;
} _MemoryDescriptor;

typedef struct {
	unsigned short	 Year;
	unsigned short	 Month;
	unsigned short	 Day;
	unsigned short	 Hour;
	unsigned short	 Minutes;
	unsigned short	 Seconds;
	unsigned short	Milliseconds;
} _TimeInfo;

#define StandardIn		0
#define StandardOut		1
#define FileNameLengthMax	(32)

typedef struct {
	unsigned long	FileNameLength;
	unsigned char	FileAttribute;
	char		FileName[FileNameLengthMax];
} _DirectoryEntry;

typedef enum {
	OpenReadOnly,
	OpenWriteOnly,
	OpenReadWrite,
	CreateWriteOnly,
	CreateReadWrite,
	SupersedeWriteOnly,
	SupersedeReadWrite,
	OpenDirectory,
	CreateDirectory
} _OpenMode;

typedef enum { SeekAbsolute, SeekRelative } _SeekMode;
typedef enum { LoadMedia, UnloadMedia } _MountOperation;

/* ARCS Firmware Vector */

typedef struct {
	long		(*Load)(char *, unsigned long,
				unsigned long *, unsigned long *);
	long		(*Invoke)(unsigned long, unsigned long,
				  long, char *[], char *[]);
	long		(*Execute)(char *, long, char *[], char *[]);
	void		(*Halt)(void);
	void		(*PowerDown)(void);
	void		(*Restart)(void);
	void		(*Reboot)(void);
	void		(*EnterInteractiveMode)(void);
	int		reserved1;
	_Component	*(*GetPeer)(_Component *);
	_Component	*(*GetChild)(_Component *);
	_Component	*(*GetParent)(_Component *);
	long		(*GetConfigData)(void *, _Component *);
	_Component	*(*AddChild)(_Component *, _Component *, void *);
	long		(*DeleteComponent)(_Component *);
	_Component	*(*GetComponent)(char *);
	long		(*SaveConfiguration)(void);
	_SystemId	*(*GetSystemId)(void);
	_MemoryDescriptor *(*GetMemoryDesc)(_MemoryDescriptor *);
	long		reserved2;
	_TimeInfo	*(*GetTime)(void);
	unsigned long	(*GetRelativeTime)(void);
	long		(*GetDirEntry)(unsigned long, _DirectoryEntry *,
				       unsigned long, unsigned long *);
	long		(*Open)(char *, _OpenMode, unsigned long *);
	long		(*Close)(unsigned long);
	long		(*Read)(unsigned long, void *,
				unsigned long, unsigned long *);
	long		(*GetReadStatus)(unsigned long);
	long		(*Write)(unsigned long, void *,
				 unsigned long, unsigned long *);
	long		(*Seek)(unsigned long, long long *, _SeekMode);
	long		(*Mount)(char *, _MountOperation);
	char		*(*GetEnvironmentVariable)(char *);
	long		(*SetEnvironmentVariable)(char *, char *);
	long		(*GetFileInformation)(unsigned long,
					      _FileInformation *);
	long		(*SetFileInformation)(unsigned long, unsigned long,
					      unsigned long);
	void		(*FlushAllCaches)(void);
} FirmwareVector;

/*
 * ARCS system parameter block sits at a well known location,
 * and provides a place to get system information.
 */
typedef struct {
	long 		Signature;			/* SPBMAGIC */
	unsigned long	Length;
	unsigned short	Version;
	unsigned short	Revision;
	long		*RestartBlock;
	long		*DebugBlock;
	long		*GEVector;
	long		*UTLBMissVector;
	unsigned long	TVLength;
	FirmwareVector	*TransferVector;
	unsigned long	PTVLength;
	long		*PrivateVector;
	long		AdapterCount;
	long		AdapterType0;
	long		AdapterVectorCount0;
	long		*AdapterVector0;
	long		AdapterType1;
	long		AdapterVectorCount1;
	long		*AdapterVector1;
	/* more adapter vectors up to 0x2000 (end of page) */
} _SystemParameterBlock;

typedef struct debug_block {
	unsigned int        db_magic;       /* DB_MAGIC */
	void                (*db_bpaddr)(); /* Breakpoint handler in debugger */
	unsigned int        db_idbgbase;    /* Idbg table address in client */
	int                 (*db_printf)(); /* Debugger console print routine */
	unsigned int        db_brkpttbl;    /* breakpoint list for client use */
	unsigned int        db_flush;       /* MP cache invalidate requests */
	unsigned int        db_nametab;
	unsigned int        db_symtab;
} db_t;

#define SPB	((_SystemParameterBlock *)(0x80001000))
#define __TV	SPB->TransferVector

extern long _ArcsOpen(char *, _OpenMode, unsigned long *);
extern long _ArcsClose(unsigned long);
extern long _ArcsRead(unsigned long, void *, unsigned long, unsigned long *);
extern long _ArcsWrite(unsigned long, void *, unsigned long, unsigned long *);
extern void _ArcsPerror(long, char *);