diff options
author | se <se@FreeBSD.org> | 1999-07-28 20:28:47 +0000 |
---|---|---|
committer | se <se@FreeBSD.org> | 1999-07-28 20:28:47 +0000 |
commit | 159c5d3210cc7b4754b2ac86132b396383c26b24 (patch) | |
tree | 3bf4cfd94d1357ee745ed8ea033de48fe37ecb1b /sys/boot/arc/include | |
parent | 7576b7e750de8c5aa91ace601e8b0b3e5fd621fc (diff) | |
download | FreeBSD-src-159c5d3210cc7b4754b2ac86132b396383c26b24.zip FreeBSD-src-159c5d3210cc7b4754b2ac86132b396383c26b24.tar.gz |
The ARC BIOS / AlphaBIOS specific primary boot loader. This code is the
result of a joined effort with parts contributed by Doug Rabson, Warner
Losh and Stefan Esser (hope I did not forget anybody). Part of the sources
is obtained from NetBSD with modifications.
This code is work in progress:
As of the time of the initial import, a loader.exe executable is built,
which can be loaded on an Alpha with NT only firmware, but no attempt is
made to switch to OSF PAL code as required to start an actual kernel.
Diffstat (limited to 'sys/boot/arc/include')
-rw-r--r-- | sys/boot/arc/include/arcfuncs.h | 199 | ||||
-rw-r--r-- | sys/boot/arc/include/arctypes.h | 288 | ||||
-rw-r--r-- | sys/boot/arc/include/libarc.h | 81 |
3 files changed, 568 insertions, 0 deletions
diff --git a/sys/boot/arc/include/arcfuncs.h b/sys/boot/arc/include/arcfuncs.h new file mode 100644 index 0000000..cc4e48d --- /dev/null +++ b/sys/boot/arc/include/arcfuncs.h @@ -0,0 +1,199 @@ +/* + * Copyright (c) 1999, Stefan Esser <se@freebsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ + +#ifdef __GNUC__ +#define INLINE inline +#else +#define INLINE /**/ +#endif + +/* System Parameter Block holding ARC and VENDOR function vector addresses */ + +#define SPBlock ((SPB *)0xffffffff806fe000ul) + +/* + * Convert between 32bit (ARC) and 64bit (Alpha) pointers + */ + +static INLINE void* +ptr(arcptr p) +{ + return (void*)(int64_t)p.adr; +} + +static INLINE arcptr +toarcptr(void *p) +{ + arcptr p32; + p32.adr = (int32_t)(int64_t) p; + return (p32); +} + +/* + * Return entry point for ARC BIOS function "funcno" + */ + +static INLINE void * +get_arc_vector(int funcno) +{ + arcptr (*arc_vector)[] = ptr(SPBlock->FirmwareVectorP); + return ptr((*arc_vector)[funcno -1]); +} + +/* + * Return entry point for VENDOR function "funcno" + */ + +static INLINE void * +get_vendor_vector(int funcno) +{ + arcptr (*arc_vector)[] = ptr(SPBlock->PrivateVectorP); + return ptr((*arc_vector)[funcno -1]); +} + +static INLINE int +get_vendor_vector_length(void) +{ + return SPBlock->PrivateVectorLength; +} + +/* + * Macros to create inline wrappers for ARCS BIOS functions + * + * Parameter: + * num function number (starting at 1) + * result result type + * fn function name + * param parameter list (types and formal args) + * args parameter list (formal args only) + */ + +#define ARC_FN(num,result,fn,param,args) \ +static inline result fn param { \ + typedef result _fn_t param; \ + _fn_t *p_ ## fn = get_arc_vector(num); \ + return p_ ## fn args; \ +} + +#define VND_FN(num,result,fn,param,args) \ +static INLINE result fn param { \ + typedef result _fn_t param; \ + _fn_t *p_ ## fn = get_vendor_vector(num); \ + return p_ ## fn args; \ +} + +/* function codes as defined in ARC Specification Version 1.2 */ + +ARC_FN(1, int32_t, Load, + (char *Path, u_int32_t TopAddr, u_int32_t *ExecAddr, u_int32_t *LowAddr), + (Path, TopAddr, ExecAddr, LowAddr)) +ARC_FN(2, int32_t, Invoke, + (u_int32_t ExecAddr, u_int32_t StackAddr, u_int32_t Argc, char *Argv[], char *Envp[]), + (ExecAddr, StackAddr, Argc, Argv, Envp)) +ARC_FN(3, int32_t, Execute, + (char *Path, u_int32_t Argc, char *Argv[], char *Envp[]), + (Path, Argc, Argv, Envp)) +ARC_FN(4, void, Halt, (void), ()) +ARC_FN(5, void, PowerDown, (void), ()) +ARC_FN(6, void, Restart, (void), ()) +ARC_FN(7, void, FwReboot, (void), ()) +ARC_FN(8, void, EnterInteractiveMode, (void), ()) +ARC_FN(10, CONFIGURATION_COMPONENT *, GetPeer, + (CONFIGURATION_COMPONENT *Current), + (Current)) +ARC_FN(11, CONFIGURATION_COMPONENT *, GetChild, + (CONFIGURATION_COMPONENT *Current), + (Current)) +ARC_FN(12, CONFIGURATION_COMPONENT *, GetParent, + (CONFIGURATION_COMPONENT *Current), + (Current)) +ARC_FN(13, CONFIGURATION_COMPONENT *, AddChild, + (CONFIGURATION_COMPONENT *Current, CONFIGURATION_COMPONENT *Template, + void *ConfigurationData), + (Current, Template, ConfigurationData)) +ARC_FN(14, int32_t, DeleteComponent, + (CONFIGURATION_COMPONENT *ComponentToDelete), + (ComponentToDelete)) +ARC_FN(15, CONFIGURATION_COMPONENT *, GetComponent, (char *Path), (Path)) +ARC_FN(16, int32_t, GetConfigurationData, + (void *ConfigurationData, CONFIGURATION_COMPONENT *Component), + (ConfigurationData, Component)) +ARC_FN(17, int32_t, SaveConfiguration, (void), ()) +ARC_FN(18, SYSTEM_ID *, GetSystemId, (void), ()) +ARC_FN(19, MEMORY_DESCRIPTOR *, GetMemoryDescriptor, + (MEMORY_DESCRIPTOR *Current), + (Current)) +ARC_FN(21, TIME_FIELDS *, GetTime, (void), ()) +ARC_FN(22, u_int32_t, GetRelativeTime, (void), ()) +ARC_FN(23, int32_t, GetDirectoryEntry, + (u_int32_t FileId, DIRECTORY_ENTRY *Buffer, u_int32_t Length, u_int32_t *Count), + (FileId, Buffer, Length, Count)) +ARC_FN(24, int32_t, Open, + (const char *Path, OPEN_MODE OpenMode, u_int32_t *FileId), + (Path, OpenMode, FileId)) +ARC_FN(25, int32_t, Close, (u_int32_t FileId), (FileId)) +ARC_FN(26, int32_t, Read, + (u_int32_t FileId, void *Buffer, u_int32_t N, u_int32_t *Count), + (FileId, Buffer, N, Count)) +ARC_FN(27, int32_t, GetReadStatus, (u_int32_t FileId), (FileId)) +ARC_FN(28, int32_t, Write, + (u_int32_t FileId, void const *Buffer, u_int32_t N, u_int32_t *Count), + (FileId, Buffer, N, Count)) +ARC_FN(29, int32_t, Seek, + (u_int32_t FileId, fpos_t *Position, SEEK_MODE SeekMode), + (FileId, Position, SeekMode)) +ARC_FN(30, int32_t, Mount, + (char *Path, MOUNT_OPERATION Operation), + (Path, Operation)) +ARC_FN(31, char *, GetEnvironmentVariable, (char *Name), (Name)) +ARC_FN(32, int32_t, SetEnvironmentVariable, + (char *Name, char *Value), + (Name, Value)) +ARC_FN(33, int32_t, GetFileInformation, + (u_int32_t FileId, FILE_INFORMATION *Information), + (FileId, Information)) +ARC_FN(34, int32_t, SetFileInformation, + (u_int32_t FileId, u_int32_t AttributeFlags, u_int32_t AttributeMask), + (FileId, AttributeFlags, AttributeMask)) +ARC_FN(35, void, FlushAllCaches, (void), ()) +ARC_FN(36, int32_t, TestUnicodeCharacter, + (u_int32_t FileId, WCHAR UnicodeCharacter), + (FileId, UnicodeCharacter)) +ARC_FN(37, ARC_DISPLAY_STATUS *, GetDisplayStatus, (u_int32_t FileId), (FileId)) + +/* Vendor specific function codes have not been verified beyond function 4 */ + +VND_FN(1, void *, AllocatePool, (u_int32_t NumberOfBytes), (NumberOfBytes)) +VND_FN(2, void, StallExecution, (u_int32_t Microseconds), (Microseconds)) +VND_FN(3, u_int32_t, Print, + (char *Format, int32_t Arg1, int32_t Arg2, int32_t Arg3), + (Format, Arg1, Arg2, Arg3)) +VND_FN(4, void, ReturnExtendedSystemInformation, + (EXTENDED_SYSTEM_INFORMATION *SystemInfo), + (SystemInfo)) diff --git a/sys/boot/arc/include/arctypes.h b/sys/boot/arc/include/arctypes.h new file mode 100644 index 0000000..e9c73d3 --- /dev/null +++ b/sys/boot/arc/include/arctypes.h @@ -0,0 +1,288 @@ +/* + * Copyright (c) 1999, Stefan Esser <se@freebsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id$ + * + */ + +#ifndef _ARC_TYPES_H_ +#define _ARC_TYPES_H_ + +#define ESUCCESS 0 + +typedef u_int8_t BOOLEAN; +typedef u_int16_t WCHAR; + +typedef int64_t fpos_t; + +/* XXX the following types are defined in ARC but are not currently used */ + +#if 0 + +typedef void VOID; + +typedef int8_t CHAR; +typedef int16_t SHORT; +typedef int32_t LONG; +typedef int64_t LONGLONG; + +typedef u_int8_t UCHAR; +typedef u_int16_t USHORT; +typedef u_int32_t ULONG; +typedef u_int64_t ULONGLONG; + +/* + * The following ARC types conflict with <sys/types.h> ! + * They are not used in the ARC wrapper functions or ARC structs + * currently, and thus may be left alone for now. In case the + * wrappers or structs are converted to use them, it is suggested + * to prefix them with "arc" to avoid type clashes (if linking + * against libstand.a which expects the FreeBSD declarations). + */ + +typedef u_int32_t size_t; +typedef int64_t clock_t; +typedef int64_t off_t; +typedef int32_t time_t; + +#endif /* 0 */ + +typedef struct { + int32_t adr; +} arcptr; + +typedef struct { + u_int32_t SPBSignature; + u_int32_t SPBLength; + u_int16_t Version; + u_int16_t Revision; + arcptr RestartBlockP; + arcptr DebugBlockP; + arcptr GEVectorP; + arcptr ULTBMissVectorP; + u_int32_t FirmwareVectorLength; + arcptr FirmwareVectorP; + u_int32_t PrivateVectorLength; + arcptr PrivateVectorP; + u_int32_t AdapterCount; + struct { + u_int32_t AdapterType; + u_int32_t AdapterVectorLength; + arcptr AdapterVectorP; + } Adapters[1]; +} SPB; + +/* ARC function specific data types */ + +typedef enum{ + SystemClass, + ProcessorClass, + CacheClass, + AdapterClass, + ControllerClass, + PeripheralClass, + MemoryClass, + MaximumClass +} CONFIGURATION_CLASS; + +typedef enum { + ArcSystem, + CentralProcessor, + FloatingPointProcessor, + PrimaryIcache, + PrimaryDcache, + SecondaryIcache, + SecondaryDcache, + SecondaryCache, + 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, + OtherPeripheral, + LinePeripheral, + NetworkPeripheral, + SystemMemory, + MaximumType +} CONFIGURATION_TYPE, *PCONFIGURATION_TYPE; + +typedef enum { + Failed = 0x01, + ReadOnly = 0x02, + Removable = 0x04, + ConsoleIn = 0x08, + ConsoleOut = 0x10, + Input = 0x20, + Output = 0x40 +} IDENTIFIERFLAG; + +typedef struct { + CONFIGURATION_CLASS Class; + CONFIGURATION_TYPE Type; + IDENTIFIERFLAG Flags; + u_int16_t Version; + u_int16_t Revision; + u_int32_t Key; + u_int32_t AffinityMask; + u_int32_t ConfigurationDataLength; + u_int32_t IdentifierLength; + arcptr Identifier; +} CONFIGURATION_COMPONENT, *PCONFIGURATION_COMPONENT; + +typedef struct { + int8_t VendorId[8]; + int8_t ProductId[8]; +} SYSTEM_ID; + +typedef enum { + MemoryExceptionBlock, + MemorySystemBlock, + MemoryFree, + MemoryBad, + MemoryLoadedProgram, + MemoryFirmwareTemporary, + MemoryFirmwarePermanent, + MemoryFreeContiguous, + MemorySpecialMemory, + MemoryMaximum +} MEMORY_TYPE; + +typedef struct { + MEMORY_TYPE Type; + u_int32_t BasePage; + u_int32_t PageCount; +} MEMORY_DESCRIPTOR; + +typedef struct _TIME_FIELDS{ + u_int16_t Year; /* 1601 .. */ + u_int16_t Month; /* 1 .. 12 */ + u_int16_t Day; /* 1 .. 31 */ + u_int16_t Hour; /* 0 .. 23 */ + u_int16_t Minute; /* 0 .. 59 */ + u_int16_t Second; /* 0 .. 59 */ + u_int16_t Milliseconds; /* 0 .. 999 */ + u_int16_t Weekday; /* 0 .. 6 = Sunday .. Saturday */ +} TIME_FIELDS, *PTIME_FIELDS; + +#define StandardIn 0 +#define StandardOut 1 + +#define ReadOnlyFile 0x01 +#define HiddenFile 0x02 +#define SystemFile 0x04 +#define ArchiveFile 0x08 +#define DirectoryFile 0x10 +#define DeleteFile 0x20 + +typedef struct { + u_int32_t FileNameLength; + u_int8_t FileAttribute; + int8_t FileName[32]; +} DIRECTORY_ENTRY; + +typedef enum { + OpenReadOnly, + OpenWriteOnly, + OpenReadWrite, + CreateWriteOnly, + CreateReadWrite, + SupersedeWriteOnly, + SupersedeReadWrite, + OpenDirectory, + CreateDirectory, + OpenMaximumMode +} OPEN_MODE; + +typedef enum { + SeekAbsolute, + SeekRelative, + SeekMaximum +} SEEK_MODE; + +typedef enum { + MountLoadMedia, + MountUnloadMedia, + MountMaximum +} MOUNT_OPERATION; + +typedef struct { + fpos_t StartingAddress; + fpos_t EndingAddress; + fpos_t CurrentAddress; + CONFIGURATION_TYPE Type; + u_int32_t FileNameLength; + u_int8_t Attributes; + int8_t FileName[32]; +} FILE_INFORMATION; + +typedef struct { + u_int16_t CursorXPosition; + u_int16_t CursorYPosition; + u_int16_t CursorMaxXPosition; + u_int16_t CursorMaxYPosition; + u_int8_t ForegroundColor; + u_int8_t BackgroundColor; + BOOLEAN HighIntensity; + BOOLEAN Underscored; + BOOLEAN ReverseVideo; +} ARC_DISPLAY_STATUS; + +/* vendor function specific data types */ + +typedef struct { + u_int32_t ProcessorId; + u_int32_t ProcessorRevision; + u_int32_t ProcessorPageSize; + u_int32_t NumberOfPhysicalAddressBits; + u_int32_t MaximumAddressSpaceNumber; + u_int32_t ProcessorCycleCounterPeriod; + u_int32_t SystemRevision; + u_int8_t SystemSerialNumber[16]; + u_int8_t FirmwareVersion[16]; + u_int8_t FirmwareBuildTimeStamp[12]; +} EXTENDED_SYSTEM_INFORMATION, *PEXTENDED_SYSTEM_INFORMATION; + +#endif /* _ARC_TYPES_H_ */ diff --git a/sys/boot/arc/include/libarc.h b/sys/boot/arc/include/libarc.h new file mode 100644 index 0000000..7162159 --- /dev/null +++ b/sys/boot/arc/include/libarc.h @@ -0,0 +1,81 @@ +/* $Id$ */ + +/* + * Copyright (c) 1996 + * Matthias Drochner. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed for the NetBSD Project + * by Matthias Drochner. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * ARC fully-qualified device descriptor + */ +struct arc_devdesc +{ + struct devsw *d_dev; + int d_type; +#define DEVT_NONE 0 +#define DEVT_DISK 1 +#define DEVT_NET 2 + union + { + struct + { + int unit; + int slice; + int partition; + } arcdisk; + struct + { + int unit; /* XXX net layer lives over these? */ + } netif; + } d_kind; +}; + +extern int arc_getdev(void **vdev, const char *devspec, const char **path); +extern char *arc_fmtdev(void *vdev); +extern int arc_setcurrdev(struct env_var *ev, int flags, void *value); + +#define MAXDEV 31 /* maximum number of distinct devices */ + +typedef unsigned long physaddr_t; + +/* exported devices XXX rename? */ +extern struct devsw arcdisk; +extern struct netif_driver arcnet; + +/* this is in startup code */ +extern void delay(int); +extern void reboot(void); + +extern int arc_copyin(void *src, vm_offset_t dest, size_t len); +extern int arc_copyout(vm_offset_t src, void *dest, size_t len); +extern int arc_readin(int fd, vm_offset_t dest, size_t len); + +extern int arc_boot(void); +extern int arc_autoload(void); |