Index: cvs2svn/tags/initial/sys/boot/arc/Makefile =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/Makefile (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/Makefile (revision 49189) @@ -0,0 +1,6 @@ +# $Id: Makefile,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $ + +SUBDIR= lib +SUBDIR+= loader + +.include Property changes on: cvs2svn/tags/initial/sys/boot/arc/Makefile ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/Makefile.inc =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/Makefile.inc (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/Makefile.inc (revision 49189) @@ -0,0 +1,6 @@ +# Options used when building app-specific libalpha components +LOAD_ADDRESS= 0xffffffff80900000 +DPADD+= ${DESTDIR}/${LIBDIR}/libstand.a +LIBSTANDDIR= ${.CURDIR}/../../../../lib/libstand +LIBSTAND= -lstand +LIBARC= ${.OBJDIR}/../lib/libarc.a Property changes on: cvs2svn/tags/initial/sys/boot/arc/Makefile.inc ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/include/arcfuncs.h =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/include/arcfuncs.h (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/include/arcfuncs.h (revision 49189) @@ -0,0 +1,199 @@ +/* + * Copyright (c) 1999, Stefan Esser + * 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)) Property changes on: cvs2svn/tags/initial/sys/boot/arc/include/arcfuncs.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/include/arctypes.h =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/include/arctypes.h (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/include/arctypes.h (revision 49189) @@ -0,0 +1,288 @@ +/* + * Copyright (c) 1999, Stefan Esser + * 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 ! + * 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_ */ Property changes on: cvs2svn/tags/initial/sys/boot/arc/include/arctypes.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/include/libarc.h =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/include/libarc.h (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/include/libarc.h (revision 49189) @@ -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); Property changes on: cvs2svn/tags/initial/sys/boot/arc/include/libarc.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/lib/Makefile =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/lib/Makefile (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/lib/Makefile (revision 49189) @@ -0,0 +1,38 @@ +# $Id: Makefile,v 1.6 1998/10/16 19:26:11 msmith Exp $ + +LIB= arc +NOPIC= true +NOPROFILE= true +INTERNALLIB= true + +.PATH: arch/${MACHINE} +# XXX hack to pick up stand.h +LIBSTANDDIR= ${.CURDIR}/../../../../lib/libstand +CFLAGS= -I${LIBSTANDDIR} +CFLAGS+= -DDEBUG + +# Pick up the bootstrap header for some interface items +CFLAGS+= -I${.CURDIR}/../../common -mno-fp-regs \ + -I${.CURDIR}/../../.. -I../include + +#CFLAGS+= -DDISK_DEBUG +#CPPFLAGS+= -DNO_DISKLABEL +#CPPFLAGS+= -DSAVE_MEMORY + +SRCS= delay.c time.c abort.c setjmperr.c copy.c devicename.c module.c \ + arcconsole.c arcdisk.c elf_freebsd.c bootinfo.c + +.if ${MACHINE} == "alpha" +SRCS+= rpb.c +.endif + +all: libarc.a + +CLEANFILES+= machine + +machine: + ln -sf ${.CURDIR}/../../../alpha/include machine + +.include + +beforedepend ${OBJS}: machine Property changes on: cvs2svn/tags/initial/sys/boot/arc/lib/Makefile ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/lib/abort.c =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/lib/abort.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/lib/abort.c (revision 49189) @@ -0,0 +1,38 @@ +/*- + * Copyright (c) 1998 Doug Rabson + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +#include +#include +#include "arctypes.h" +#include "arcfuncs.h" + +void +abort() +{ + FwReboot(); +} Property changes on: cvs2svn/tags/initial/sys/boot/arc/lib/abort.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/lib/arcconsole.c =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/lib/arcconsole.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/lib/arcconsole.c (revision 49189) @@ -0,0 +1,107 @@ +/* $Id$ */ +/* $NetBSD: prom.c,v 1.3 1997/09/06 14:03:58 drochner Exp $ */ + +/* + * Mach Operating System + * Copyright (c) 1992 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ + +#include + +#include "bootstrap.h" +#include "arctypes.h" +#include "arcfuncs.h" + +int console; + +static void arc_probe(struct console *cp); +static int arc_init(int); +static void arc_putchar(int); +static int arc_getchar(void); +static int arc_poll(void); + +struct console arcconsole = { + "arc", + "ARC firmware console", + 0, + arc_probe, + arc_init, + arc_putchar, + arc_getchar, + arc_poll, +}; + +static void +arc_probe(struct console *cp) +{ + cp->c_flags |= C_PRESENTIN|C_PRESENTOUT; +} + +static int +arc_init(int arg) +{ + return 0; +} + +static void +arc_putchar(int c) +{ + char cbuf = c; + u_int32_t count; + + Write(StandardOut, &cbuf, 1, &count); +} + +static int saved_char = -1; + +int +arc_getchar() +{ + char cbuf; + u_int32_t count; + + arc_putchar('_'); + arc_putchar('\b'); + Read(StandardIn, &cbuf, 1, &count); + arc_putchar(' '); + arc_putchar('\b'); + if (count == 1) + return cbuf; + else + return -1; +} + +int +arc_poll() +{ + return GetReadStatus(StandardIn) == ESUCCESS; +} + +int +arc_open(dev, len) + char *dev; + int len; +{ + return 0; +} Property changes on: cvs2svn/tags/initial/sys/boot/arc/lib/arcconsole.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/lib/arcdisk.c =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/lib/arcdisk.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/lib/arcdisk.c (revision 49189) @@ -0,0 +1,357 @@ +/*- + * Copyright (c) 1998 Michael Smith + * Copyright (c) 1998 Doug Rabson + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +/* + * ARC disk device handling. + * + * Ideas and algorithms from: + * + * - NetBSD libi386/biosdisk.c + * - FreeBSD biosboot/disk.c + * + * XXX Todo: add bad144 support. + */ + +#include + +#include +#include + +#include + +#include "bootstrap.h" +#include "libarc.h" +#include "arctypes.h" +#include "arcfuncs.h" + +#define ARCDISK_SECSIZE 512 + +#define BUFSIZE (1 * ARCDISK_SECSIZE) +#define MAXBDDEV MAXDEV + +#ifdef DISK_DEBUG +# define D(x) x +#else +# define D(x) +#endif + +static int bd_init(void); +static int bd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, void *buf, size_t *rsize); +static int bd_realstrategy(void *devdata, int flag, daddr_t dblk, size_t size, void *buf, size_t *rsize); +static int bd_open(struct open_file *f, void *vdev); +static int bd_close(struct open_file *f); +static void bd_print(int verbose); + +struct open_disk { + int od_fd; + int od_unit; /* our unit number */ + int od_boff; /* block offset from beginning of ARC disk */ + int od_flags; +#define BD_FLOPPY (1<<2) + u_char od_buf[BUFSIZE]; /* transfer buffer (do we want/need this?) */ +}; + +struct devsw arcdisk = { + "disk", + DEVT_DISK, + bd_init, + bd_strategy, + bd_open, + bd_close, + noioctl, + bd_print +}; + +/* + * List of ARC devices, translation from disk unit number to + * ARC unit number. + */ +static struct +{ + char bd_name[64]; + int bd_unit; /* ARC unit number */ + int bd_namelen; + int bd_flags; +} bdinfo [MAXBDDEV]; +static int nbdinfo = 0; + +/* + * Quiz ARC for disk devices, save a little info about them. + */ +static int +bd_init(void) +{ + nbdinfo++; + + return (0); +} + +/* + * Print information about disks + */ +static void +bd_print(int verbose) +{ + int i; + char line[80]; + + for (i = 0; i < nbdinfo; i++) { + sprintf(line, " disk%d: ARC drive %s", i, bdinfo[i].bd_name); + pager_output(line); + /* XXX more detail? */ + pager_output("\n"); + } +} + +/* + * Attempt to open the disk described by (dev) for use by (f). + * + * Note that the philosophy here is "give them exactly what + * they ask for". This is necessary because being too "smart" + * about what the user might want leads to complications. + * (eg. given no slice or partition value, with a disk that is + * sliced - are they after the first BSD slice, or the DOS + * slice before it?) + */ +static int +bd_open(struct open_file *f, void *vdev) +{ + struct arc_devdesc *dev = vdev; + struct dos_partition *dptr; + struct open_disk *od; + struct disklabel *lp; + int sector, slice, i; + int error; + int unit; + u_int32_t fd; + + unit = dev->d_kind.arcdisk.unit; + if (unit >= nbdinfo) { + D(printf("attempt to open nonexistent disk\n")); + return(ENXIO); + } + + if (Open("scsi(0)disk(0)rdisk(0)partition(0)", + OpenReadOnly, &fd) != ESUCCESS) + if (Open("scsi(0)disk(1)rdisk(0)partition(0)", + OpenReadOnly, &fd) != ESUCCESS) + if (Open("multi(0)disk(0)fdisk(0)partition(0)", + OpenReadOnly, &fd) != ESUCCESS) + return(ENXIO); + + od = (struct open_disk *) malloc(sizeof(struct open_disk)); + if (!od) { + D(printf("arcdiskopen: no memory\n")); + return (ENOMEM); + } + + /* Look up ARC unit number, intialise open_disk structure */ + od->od_fd = fd; + od->od_unit = dev->d_kind.arcdisk.unit; + od->od_flags = bdinfo[od->od_unit].bd_flags; + od->od_boff = 0; + error = 0; + +#if 0 + /* Get geometry for this open (removable device may have changed) */ + if (set_geometry(&od->od_ll)) { + D(printf("bd_open: can't get geometry\n")); + error = ENXIO; + goto out; + } +#endif + + /* + * Following calculations attempt to determine the correct value + * for d->od_boff by looking for the slice and partition specified, + * or searching for reasonable defaults. + */ + +#if 0 + /* + * Find the slice in the DOS slice table. + */ + if (readsects(&od->od_ll, 0, 1, od->od_buf, 0)) { + D(printf("bd_open: error reading MBR\n")); + error = EIO; + goto out; + } + + /* + * Check the slice table magic. + */ + if ((od->od_buf[0x1fe] != 0xff) || (od->od_buf[0x1ff] != 0xaa)) { + /* If a slice number was explicitly supplied, this is an error */ + if (dev->d_kind.arcdisk.slice > 0) { + D(printf("bd_open: no slice table/MBR (no magic)\n")); + error = ENOENT; + goto out; + } + sector = 0; + goto unsliced; /* may be a floppy */ + } + dptr = (struct dos_partition *) & od->od_buf[DOSPARTOFF]; + + /* + * XXX No support here for 'extended' slices + */ + if (dev->d_kind.arcdisk.slice <= 0) { + /* + * Search for the first FreeBSD slice; this also works on "unsliced" + * disks, as they contain a "historically bogus" MBR. + */ + for (i = 0; i < NDOSPART; i++, dptr++) + if (dptr->dp_typ == DOSPTYP_386BSD) { + sector = dptr->dp_start; + break; + } + /* Did we find something? */ + if (sector == -1) { + error = ENOENT; + goto out; + } + } else { + /* + * Accept the supplied slice number unequivocally (we may be looking + * for a DOS partition) if we can handle it. + */ + if ((dev->d_kind.arcdisk.slice > NDOSPART) || (dev->d_kind.arcdisk.slice < 1)) { + error = ENOENT; + goto out; + } + dptr += (dev->d_kind.arcdisk.slice - 1); + sector = dptr->dp_start; + } + unsliced: + +#else + sector = 0; +#endif + /* + * Now we have the slice, look for the partition in the disklabel if we have + * a partition to start with. + */ + if (dev->d_kind.arcdisk.partition < 0) { + od->od_boff = sector; /* no partition, must be after the slice */ + } else { + if (bd_strategy(od, F_READ, sector + LABELSECTOR, 512, od->od_buf, 0)) { + D(printf("bd_open: error reading disklabel\n")); + error = EIO; + goto out; + } + lp = (struct disklabel *) (od->od_buf + LABELOFFSET); + if (lp->d_magic != DISKMAGIC) { + D(printf("bd_open: no disklabel\n")); + error = ENOENT; + goto out; + + } else if (dev->d_kind.arcdisk.partition >= lp->d_npartitions) { + + /* + * The partition supplied is out of bounds; this is fatal. + */ + D(printf("partition '%c' exceeds partitions in table (a-'%c')\n", + 'a' + dev->d_kind.arcdisk.partition, 'a' + lp->d_npartitions)); + error = EPART; + goto out; + + } else { + + /* + * Complain if the partition type is wrong and it shouldn't be, but + * regardless accept this partition. + */ + D(if ((lp->d_partitions[dev->d_kind.arcdisk.partition].p_fstype == FS_UNUSED) && + !(od->od_flags & BD_FLOPPY)) /* Floppies often have bogus fstype */ + printf("bd_open: warning, partition marked as unused\n");); + + od->od_boff = lp->d_partitions[dev->d_kind.arcdisk.partition].p_offset; + } + } + /* + * Save our context + */ + f->f_devdata = od; + + out: + if (error) + free(od); + return(error); +} + +static int +bd_close(struct open_file *f) +{ + struct open_disk *od = f->f_devdata; + + Close(od->od_fd); + + free(od); + f->f_devdata = NULL; + return(0); +} + +static int +bd_strategy(void *devdata, int rw, daddr_t dblk, size_t size, void *buf, size_t *rsize) +{ + struct bcache_devdata bcd; + + bcd.dv_strategy = bd_realstrategy; + bcd.dv_devdata = devdata; + return(bcache_strategy(&bcd, rw, dblk, size, buf, rsize)); +} + +static int +bd_realstrategy(void *devdata, int flag, daddr_t dblk, size_t size, void *buf, size_t *rsize) +{ + struct open_disk *od = (struct open_disk *)devdata; + fpos_t seek; + u_int32_t count; + + if (size % ARCDISK_SECSIZE) + panic("bd_strategy: I/O not block multiple"); + + if (flag != F_READ) + return(EROFS); + + if (rsize) + *rsize = 0; + + seek = 512 * (dblk + od->od_boff); + Seek(od->od_fd, &seek, SeekAbsolute); + if (Read(od->od_fd, buf, size, &count) != ESUCCESS) { + D(printf("read error\n")); + return (EIO); + } + + if (rsize) + *rsize = count; + return (0); +} + Property changes on: cvs2svn/tags/initial/sys/boot/arc/lib/arcdisk.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/lib/arch/alpha/copy.c =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/lib/arch/alpha/copy.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/lib/arch/alpha/copy.c (revision 49189) @@ -0,0 +1,71 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: alpha_copy.c,v 1.3 1998/09/20 21:46:19 dfr Exp $ + */ +/* + * MD primitives supporting placement of module data + * + * XXX should check load address/size against memory top. + */ +#include +#include + +#include "libarc.h" + +/* + * Convert from a 64bit superpage address to a 32bit arc superpage address. + */ +static void * +convert_superpage(vm_offset_t p) +{ + if (p < ALPHA_K0SEG_BASE || p >= ALPHA_K0SEG_END) { + printf("stupid address %p\n", (void *)p); + panic("broken"); + } + return (void *) (0xffffffff80000000 + (p - ALPHA_K0SEG_BASE)); +} + +int +arc_copyin(void *src, vm_offset_t dest, size_t len) +{ + bcopy(src, convert_superpage(dest), len); + return(len); +} + +int +arc_copyout(vm_offset_t src, void *dest, size_t len) +{ + bcopy(convert_superpage(src), dest, len); + return(len); +} + +int +arc_readin(int fd, vm_offset_t dest, size_t len) +{ + return(read(fd, convert_superpage(dest), len)); +} + + Property changes on: cvs2svn/tags/initial/sys/boot/arc/lib/arch/alpha/copy.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/lib/arch/alpha/rpb.c =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/lib/arch/alpha/rpb.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/lib/arch/alpha/rpb.c (revision 49189) @@ -0,0 +1,196 @@ +/*- + * Copyright (c) 1998 Doug Rabson + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +#include +#include +#include "arctypes.h" +#include "arcfuncs.h" + +struct rpb RPB = { + 0, /* rpb_phys */ + {"HWRPB"}, /* rpb_magic */ + HWRPB_DSRDB_MINVERS, /* rpb_version */ + sizeof(struct rpb), /* rpb_size */ + 0, /* rpb_primary_cpu_id */ + 8192, /* rpb_page_size */ + 43, /* rpb_phys_addr_size */ + 0, /* rpb_max_asn */ + {0}, /* rpb_ssn */ + ST_EB164, /* rpb_type */ + SV_ST_ALPHAPC164LX_533, /* rpb_variation */ + {"0000"}, /* rpb_revision */ + 1024*4096, /* rpb_intr_freq */ + 533*1024*1024, /* rpb_cc_freq */ + 0, /* rpb_vptb */ + 0, /* rpb_reserved_arch */ + 0, /* rpb_tbhint_off */ + 0, /* rpb_pcs_cnt */ + 0, /* rpb_pcs_size */ + 0, /* rpb_pcs_off */ + 0, /* rpb_ctb_cnt */ + 0, /* rpb_ctb_size */ + 0, /* rpb_ctb_off */ + 0, /* rpb_crb_off */ + 0, /* rpb_memdat_off */ + 0, /* rpb_condat_off */ + 0, /* rpb_fru_off */ + 0, /* rpb_save_term */ + 0, /* rpb_save_term_val */ + 0, /* rpb_rest_term */ + 0, /* rpb_rest_term_val */ + 0, /* rpb_restart */ + 0, /* rpb_restart_val */ + 0, /* rpb_reserve_os */ + 0, /* rpb_reserve_hw */ + 0, /* rpb_checksum */ + 0, /* rpb_rxrdy */ + 0, /* rpb_txrdy */ + 0, /* rpb_dsrdb_off */ + {0}, /* rpb_rpb_tbhint */ +}; + +#define ROUNDUP(x) (((x) + sizeof(u_int64_t) - 1) \ + & ~(sizeof(u_int64_t) - 1)) + +u_int64_t +checksum(void *p, size_t size) +{ + u_int64_t sum = 0; + u_int64_t *lp = (u_int64_t *)p; + int i; + + printf("checksum(%p, %d)\n", p, size); + size = ROUNDUP(size) / sizeof(u_int64_t); + for (i = 0; i < size; i++) + sum += lp[i]; +} + +size_t +size_mddt() +{ + int count = 0; + MEMORY_DESCRIPTOR *desc; + + for (desc = GetMemoryDescriptor(NULL); desc; + desc = GetMemoryDescriptor(desc)) { + count++; + } + + return ROUNDUP(sizeof(struct mddt) + + (count - 1) * sizeof(struct mddt_cluster)); +} + +void +write_mddt(struct mddt *mddt, size_t size) +{ + int count = 0, i; + MEMORY_DESCRIPTOR *desc; + u_int64_t *p; + + memset(mddt, 0, sizeof(struct mddt)); + for (desc = GetMemoryDescriptor(NULL); desc; + desc = GetMemoryDescriptor(desc)) { + struct mddt_cluster *mc; + mc = &mddt->mddt_clusters[count]; + mc->mddt_pfn = desc->BasePage; + mc->mddt_pg_cnt = desc->PageCount; + mc->mddt_pg_test = 0; + mc->mddt_v_bitaddr = 0; + mc->mddt_p_bitaddr = 0; + mc->mddt_bit_cksum = 0; + + /* + * Not sure about the FirmwareTemporary bit but my 164LX has + * about 60Mb marked this way. + */ + if (desc->Type == MemoryFree || desc->Type == MemoryFirmwareTemporary) + mc->mddt_usage = MDDT_SYSTEM; + else if (desc->Type == MemorySpecialMemory) + mc->mddt_usage = MDDT_NONVOLATILE; /* ?? */ + else + mc->mddt_usage = MDDT_PALCODE; + count++; + } + mddt->mddt_cluster_cnt = count; + mddt->mddt_cksum = checksum(mddt, size); +} + +size_t +size_rpb() +{ + return sizeof(struct rpb) + size_mddt(); +} + +void +write_rpb(struct rpb *rpb) +{ + EXTENDED_SYSTEM_INFORMATION sysinfo; + SYSTEM_ID *sysid; + + ReturnExtendedSystemInformation(&sysinfo); + + memset(rpb, 0, sizeof(struct rpb)); + rpb->rpb_phys = 0; /* XXX */ + strcpy(rpb->rpb_magic, "HWRPB"); + rpb->rpb_version = HWRPB_DSRDB_MINVERS; + rpb->rpb_size = sizeof(struct rpb); + rpb->rpb_primary_cpu_id = 0; /* XXX */ + rpb->rpb_page_size = sysinfo.ProcessorPageSize; + rpb->rpb_phys_addr_size = sysinfo.NumberOfPhysicalAddressBits; + rpb->rpb_max_asn = sysinfo.MaximumAddressSpaceNumber; + rpb->rpb_type = ST_EB164; /* XXX */ + rpb->rpb_variation = SV_ST_ALPHAPC164LX_533; /* XXX */ + rpb->rpb_intr_freq = 1024*4096; /* XXX */ + rpb->rpb_cc_freq = 533000000; /* XXX */ + rpb->rpb_memdat_off = sizeof(struct rpb); + write_mddt((struct mddt *)((caddr_t) rpb + rpb->rpb_memdat_off), + size_mddt()); + rpb->rpb_checksum = checksum(rpb, 280); /* only sum first 280 bytes */ +} + +struct rpb * +make_rpb() +{ + EXTENDED_SYSTEM_INFORMATION sysinfo; + struct rpb *rpb; + + ReturnExtendedSystemInformation(&sysinfo); + printf("sysinfo.ProcessorId = %x\n", sysinfo.ProcessorId); + printf("sysinfo.ProcessorRevision = %d\n", sysinfo.ProcessorRevision); + printf("sysinfo.ProcessorPageSize = %d\n", sysinfo.ProcessorPageSize); + printf("sysinfo.NumberOfPhysicalAddressBits = %d\n", sysinfo.NumberOfPhysicalAddressBits); + printf("sysinfo.MaximumAddressSpaceNumber = %d\n", sysinfo.MaximumAddressSpaceNumber); + printf("sysinfo.ProcessorCycleCounterPeriod = %d\n", sysinfo.ProcessorCycleCounterPeriod); + printf("sysinfo.SystemRevision = %d\n", sysinfo.SystemRevision); + printf("sysinfo.SystemSerialNumber = %s\n", sysinfo.SystemSerialNumber); + printf("sysinfo.FirmwareVersion = %s\n", sysinfo.FirmwareVersion); + + rpb = malloc(size_rpb()); + write_rpb(rpb); + return rpb; +} Property changes on: cvs2svn/tags/initial/sys/boot/arc/lib/arch/alpha/rpb.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/lib/arch/alpha/setjmp.S =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/lib/arch/alpha/setjmp.S (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/lib/arch/alpha/setjmp.S (revision 49189) @@ -0,0 +1,95 @@ +/* $Id$ */ +/* + * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include + + .text +/* + * Kernel setjmp and longjmp. Rather minimalist. + * + * longjmp(label_t *a) + * will generate a "return (1)" from the last call to + * setjmp(label_t *a) + * by restoring registers from the stack, + */ + + .set noreorder + +LEAF(setjmp, 1) + LDGP(pv) + + stq ra, (0 * 8)(a0) /* return address */ + stq s0, (1 * 8)(a0) /* callee-saved registers */ + stq s1, (2 * 8)(a0) + stq s2, (3 * 8)(a0) + stq s3, (4 * 8)(a0) + stq s4, (5 * 8)(a0) + stq s5, (6 * 8)(a0) + stq s6, (7 * 8)(a0) + stq sp, (8 * 8)(a0) + + ldiq t0, 0xbeeffedadeadbabe /* set magic number */ + stq t0, (9 * 8)(a0) + + mov zero, v0 /* return zero */ + RET +END(setjmp) + +LEAF(longjmp, 1) + LDGP(pv) + + ldiq t0, 0xbeeffedadeadbabe /* check magic number */ + ldq t1, (9 * 8)(a0) + cmpeq t0, t1, t0 + beq t0, longjmp_botch /* if bad, punt */ + + ldq ra, (0 * 8)(a0) /* return address */ + ldq s0, (1 * 8)(a0) /* callee-saved registers */ + ldq s1, (2 * 8)(a0) + ldq s2, (3 * 8)(a0) + ldq s3, (4 * 8)(a0) + ldq s4, (5 * 8)(a0) + ldq s5, (6 * 8)(a0) + ldq s6, (7 * 8)(a0) + ldq sp, (8 * 8)(a0) + + ldiq v0, 1 + RET + +longjmp_botch: + lda a0, longjmp_botchmsg + mov ra, a1 + CALL(panic) + call_pal PAL_bugchk + + .data +longjmp_botchmsg: + .asciz "longjmp botch from %p" + .text + +END(longjmp) Property changes on: cvs2svn/tags/initial/sys/boot/arc/lib/arch/alpha/setjmp.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/lib/arch/alpha/start.S =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/lib/arch/alpha/start.S (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/lib/arch/alpha/start.S (revision 49189) @@ -0,0 +1,63 @@ +/* + * Copyright (c) 1999, Stefan Esser + * 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$ + * + */ + +/* + * Based on /sys/boot/alpha/libalpha/start.S + * Copyright (c) 1992 Carnegie Mellon University + */ + +#include + + .text + +#define ENTRY_FRAME 32 + +NESTED(_start, 1, ENTRY_FRAME, ra, 0, 0) + br pv,Lstartgp +Lstartgp: + LDGP(pv) + + lda a0,_edata + lda a1,_end + subq a1,a0,a1 + CALL(bzero) + + lda sp, -8(sp) + stq ra, 0(sp) + + CALL(main) /* transfer to C */ + + ldq ra, 0(sp) + lda sp, 8(sp) + RET /* XXX */ + +XLEAF(_rtt, 0) +XLEAF(halt, 0) + call_pal PAL_halt /* halt if we ever return */ +END(_start) Property changes on: cvs2svn/tags/initial/sys/boot/arc/lib/arch/alpha/start.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/lib/bootinfo.c =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/lib/bootinfo.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/lib/bootinfo.c (revision 49189) @@ -0,0 +1,204 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: bootinfo.c,v 1.3 1998/10/15 21:55:58 dfr Exp $ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "bootstrap.h" + +/* + * Copy the environment into the load area starting at (addr). + * Each variable is formatted as =, with a single nul + * separating each variable, and a double nul terminating the environment. + */ +vm_offset_t +bi_copyenv(vm_offset_t addr) +{ + struct env_var *ep; + + /* traverse the environment */ + for (ep = environ; ep != NULL; ep = ep->ev_next) { + alpha_copyin(ep->ev_name, addr, strlen(ep->ev_name)); + addr += strlen(ep->ev_name); + alpha_copyin("=", addr, 1); + addr++; + if (ep->ev_value != NULL) { + alpha_copyin(ep->ev_value, addr, strlen(ep->ev_value)); + addr += strlen(ep->ev_value); + } + alpha_copyin("", addr, 1); + addr++; + } + alpha_copyin("", addr, 1); + addr++; + return(addr); +} + +/* + * Copy module-related data into the load area, where it can be + * used as a directory for loaded modules. + * + * Module data is presented in a self-describing format. Each datum + * is preceeded by a 32-bit identifier and a 32-bit size field. + * + * Currently, the following data are saved: + * + * MOD_NAME (variable) module name (string) + * MOD_TYPE (variable) module type (string) + * MOD_ADDR sizeof(vm_offset_t) module load address + * MOD_SIZE sizeof(size_t) module size + * MOD_METADATA (variable) type-specific metadata + */ +#define COPY32(v, a) { \ + u_int32_t x = (v); \ + alpha_copyin(&x, a, sizeof(x)); \ + a += sizeof(x); \ +} + +#define MOD_STR(t, a, s) { \ + COPY32(t, a); \ + COPY32(strlen(s) + 1, a); \ + alpha_copyin(s, a, strlen(s) + 1); \ + a += roundup(strlen(s) + 1, sizeof(u_int64_t));\ +} + +#define MOD_NAME(a, s) MOD_STR(MODINFO_NAME, a, s) +#define MOD_TYPE(a, s) MOD_STR(MODINFO_TYPE, a, s) + +#define MOD_VAR(t, a, s) { \ + COPY32(t, a); \ + COPY32(sizeof(s), a); \ + alpha_copyin(&s, a, sizeof(s)); \ + a += roundup(sizeof(s), sizeof(u_int64_t)); \ +} + +#define MOD_ADDR(a, s) MOD_VAR(MODINFO_ADDR, a, s) +#define MOD_SIZE(a, s) MOD_VAR(MODINFO_SIZE, a, s) + +#define MOD_METADATA(a, mm) { \ + COPY32(MODINFO_METADATA | mm->md_type, a); \ + COPY32(mm->md_size, a); \ + alpha_copyin(mm->md_data, a, mm->md_size); \ + a += roundup(mm->md_size, sizeof(u_int64_t));\ +} + +#define MOD_END(a) { \ + COPY32(MODINFO_END, a); \ + COPY32(0, a); \ +} + +vm_offset_t +bi_copymodules(vm_offset_t addr) +{ + struct loaded_module *mp; + struct module_metadata *md; + + /* start with the first module on the list, should be the kernel */ + for (mp = mod_findmodule(NULL, NULL); mp != NULL; mp = mp->m_next) { + + MOD_NAME(addr, mp->m_name); /* this field must come first */ + MOD_TYPE(addr, mp->m_type); + MOD_ADDR(addr, mp->m_addr); + MOD_SIZE(addr, mp->m_size); + for (md = mp->m_metadata; md != NULL; md = md->md_next) + if (!(md->md_type & MODINFOMD_NOCOPY)) + MOD_METADATA(addr, md); + } + MOD_END(addr); + return(addr); +} + +/* + * Load the information expected by an alpha kernel. + * + * - The kernel environment is copied into kernel space. + * - Module metadata are formatted and placed in kernel space. + */ +int +bi_load(struct bootinfo_v1 *bi, vm_offset_t *ffp_save, + struct loaded_module *mp) +{ + struct loaded_module *xp; + vm_offset_t addr, bootinfo_addr; + u_int pad; + vm_offset_t ssym, esym; + struct module_metadata *md; + + ssym = esym = 0; + if ((md = mod_findmetadata(mp, MODINFOMD_SSYM)) != NULL) + ssym = *((vm_offset_t *)&(md->md_data)); + if ((md = mod_findmetadata(mp, MODINFOMD_ESYM)) != NULL) + esym = *((vm_offset_t *)&(md->md_data)); + if (ssym == 0 || esym == 0) + ssym = esym = 0; /* sanity */ + + bi->ssym = ssym; + bi->esym = esym; + + /* find the last module in the chain */ + addr = 0; + for (xp = mod_findmodule(NULL, NULL); xp != NULL; xp = xp->m_next) { + if (addr < (xp->m_addr + xp->m_size)) + addr = xp->m_addr + xp->m_size; + } + /* pad to a page boundary */ + pad = (u_int)addr & PAGE_MASK; + if (pad != 0) { + pad = PAGE_SIZE - pad; + addr += pad; + } + + /* copy our environment */ + bi->envp = (char *)addr; + addr = bi_copyenv(addr); + + /* pad to a page boundary */ + pad = (u_int)addr & PAGE_MASK; + if (pad != 0) { + pad = PAGE_SIZE - pad; + addr += pad; + } + /* copy module list and metadata */ + bi->modptr = addr; + addr = bi_copymodules(addr); + + /* all done copying stuff in, save end of loaded object space */ + bi->kernend = addr; + + *ffp_save = ALPHA_K0SEG_TO_PHYS((addr + PAGE_MASK) & ~PAGE_MASK) + >> PAGE_SHIFT; + *ffp_save += 2; /* XXX OSF/1 does this, no idea why. */ + + return(0); +} Property changes on: cvs2svn/tags/initial/sys/boot/arc/lib/bootinfo.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/lib/delay.c =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/lib/delay.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/lib/delay.c (revision 49189) @@ -0,0 +1,38 @@ +/*- + * Copyright (c) 1998 Doug Rabson + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +#include +#include +#include "arctypes.h" +#include "arcfuncs.h" + +void +delay(int usecs) +{ + StallExecution(usecs); +} Property changes on: cvs2svn/tags/initial/sys/boot/arc/lib/delay.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/lib/devicename.c =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/lib/devicename.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/lib/devicename.c (revision 49189) @@ -0,0 +1,236 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: devicename.c,v 1.3 1998/09/26 10:51:37 dfr Exp $ + */ + +#include +#include +#include +#include "bootstrap.h" +#include "libarc.h" + +static int arc_parsedev(struct arc_devdesc **dev, const char *devspec, const char **path); + +/* + * Point (dev) at an allocated device specifier for the device matching the + * path in (devspec). If it contains an explicit device specification, + * use that. If not, use the default device. + */ +int +arc_getdev(void **vdev, const char *devspec, const char **path) +{ + struct arc_devdesc **dev = (struct arc_devdesc **)vdev; + int rv; + + /* + * If it looks like this is just a path and no + * device, go with the current device. + */ + if ((devspec == NULL) || + (devspec[0] == '/') || + (strchr(devspec, ':') == NULL)) { + + if (((rv = arc_parsedev(dev, getenv("currdev"), NULL)) == 0) && + (path != NULL)) + *path = devspec; + return(rv); + } + + /* + * Try to parse the device name off the beginning of the devspec + */ + return(arc_parsedev(dev, devspec, path)); +} + +/* + * Point (dev) at an allocated device specifier matching the string version + * at the beginning of (devspec). Return a pointer to the remaining + * text in (path). + * + * In all cases, the beginning of (devspec) is compared to the names + * of known devices in the device switch, and then any following text + * is parsed according to the rules applied to the device type. + * + * For disk-type devices, the syntax is: + * + * disk[s][]: + * + */ +static int +arc_parsedev(struct arc_devdesc **dev, const char *devspec, const char **path) +{ + struct arc_devdesc *idev; + struct devsw *dv; + int i, unit, slice, partition, err; + char *cp; + const char *np; + + /* minimum length check */ + if (strlen(devspec) < 2) + return(EINVAL); + + /* look for a device that matches */ + for (i = 0, dv = NULL; devsw[i] != NULL; i++) { + if (!strncmp(devspec, devsw[i]->dv_name, strlen(devsw[i]->dv_name))) { + dv = devsw[i]; + break; + } + } + + if (dv == NULL) + return(ENOENT); + idev = malloc(sizeof(struct arc_devdesc)); + err = 0; + np = (devspec + strlen(dv->dv_name)); + + switch(dv->dv_type) { + case DEVT_NONE: /* XXX what to do here? Do we care? */ + break; + + case DEVT_DISK: + unit = -1; + slice = -1; + partition = -1; + if (*np && (*np != ':')) { + unit = strtol(np, &cp, 10); /* next comes the unit number */ + if (cp == np) { + err = EUNIT; + goto fail; + } + if (*cp == 's') { /* got a slice number */ + np = cp + 1; + slice = strtol(np, &cp, 10); + if (cp == np) { + err = ESLICE; + goto fail; + } + } + if (*cp && (*cp != ':')) { + partition = *cp - 'a'; /* get a partition number */ + if ((partition < 0) || (partition >= MAXPARTITIONS)) { + err = EPART; + goto fail; + } + cp++; + } + } + if (*cp && (*cp != ':')) { + err = EINVAL; + goto fail; + } + + idev->d_kind.arcdisk.unit = unit; + idev->d_kind.arcdisk.slice = slice; + idev->d_kind.arcdisk.partition = partition; + if (path != NULL) + *path = (*cp == 0) ? cp : cp + 1; + break; + + case DEVT_NET: + unit = 0; + + if (*np && (*np != ':')) { + unit = strtol(np, &cp, 0); /* get unit number if present */ + if (cp == np) { + err = EUNIT; + goto fail; + } + } + if (*cp && (*cp != ':')) { + err = EINVAL; + goto fail; + } + + idev->d_kind.netif.unit = unit; + if (path != NULL) + *path = (*cp == 0) ? cp : cp + 1; + break; + + default: + err = EINVAL; + goto fail; + } + idev->d_dev = dv; + idev->d_type = dv->dv_type; + if (dev == NULL) { + free(idev); + } else { + *dev = idev; + } + return(0); + + fail: + free(idev); + return(err); +} + + +char * +arc_fmtdev(void *vdev) +{ + struct arc_devdesc *dev = (struct arc_devdesc *)vdev; + static char buf[128]; /* XXX device length constant? */ + char *cp; + + switch(dev->d_type) { + case DEVT_NONE: + strcpy(buf, "(no device)"); + break; + + case DEVT_DISK: + cp = buf; + cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_kind.arcdisk.unit); + if (dev->d_kind.arcdisk.slice > 0) + cp += sprintf(cp, "s%d", dev->d_kind.arcdisk.slice); + if (dev->d_kind.arcdisk.partition >= 0) + cp += sprintf(cp, "%c", dev->d_kind.arcdisk.partition + 'a'); + strcat(cp, ":"); + break; + + case DEVT_NET: + sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_kind.netif.unit); + break; + } + return(buf); +} + + +/* + * Set currdev to suit the value being supplied in (value) + */ +int +arc_setcurrdev(struct env_var *ev, int flags, void *value) +{ + struct arc_devdesc *ncurr; + int rv; + + if ((rv = arc_parsedev(&ncurr, value, NULL)) != 0) + return(rv); + free(ncurr); + env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); + return(0); +} + Property changes on: cvs2svn/tags/initial/sys/boot/arc/lib/devicename.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/lib/elf_freebsd.c =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/lib/elf_freebsd.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/lib/elf_freebsd.c (revision 49189) @@ -0,0 +1,143 @@ +/* $Id: elf_freebsd.c,v 1.6 1998/10/15 21:55:58 dfr Exp $ */ +/* $NetBSD: loadfile.c,v 1.10 1998/06/25 06:45:46 ross Exp $ */ + +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center. + * + * 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 by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``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 FOUNDATION OR CONTRIBUTORS + * 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. + */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)boot.c 8.1 (Berkeley) 6/10/93 + */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "bootstrap.h" + +#define _KERNEL + +static int elf_exec(struct loaded_module *amp); +int bi_load(struct bootinfo_v1 *, vm_offset_t *, + struct loaded_module *); + +struct module_format alpha_elf = { elf_loadmodule, elf_exec }; + +vm_offset_t ffp_save, ptbr_save; + +static int +elf_exec(struct loaded_module *mp) +{ +#if 0 + static struct bootinfo_v1 bootinfo_v1; + struct module_metadata *md; + Elf_Ehdr *hdr; + int err; + + if ((md = mod_findmetadata(mp, MODINFOMD_ELFHDR)) == NULL) + return(EFTYPE); /* XXX actually EFUCKUP */ + hdr = (Elf_Ehdr *)&(md->md_data); + + /* XXX ffp_save does not appear to be used in the kernel.. */ + bzero(&bootinfo_v1, sizeof(bootinfo_v1)); + err = bi_load(&bootinfo_v1, &ffp_save, mp); + if (err) + return(err); + + /* + * Fill in the bootinfo for the kernel. + */ + strncpy(bootinfo_v1.booted_kernel, mp->m_name, + sizeof(bootinfo_v1.booted_kernel)); + prom_getenv(PROM_E_BOOTED_OSFLAGS, bootinfo_v1.boot_flags, + sizeof(bootinfo_v1.boot_flags)); + bootinfo_v1.hwrpb = (void *)HWRPB_ADDR; + bootinfo_v1.hwrpbsize = ((struct rpb *)HWRPB_ADDR)->rpb_size; + bootinfo_v1.cngetc = NULL; + bootinfo_v1.cnputc = NULL; + bootinfo_v1.cnpollc = NULL; + + printf("Entering %s at 0x%lx...\n", mp->m_name, hdr->e_entry); + exit(0); + closeall(); + alpha_pal_imb(); + (*(void (*)())hdr->e_entry)(ffp_save, ptbr_save, + BOOTINFO_MAGIC, &bootinfo_v1, 1, 0); +#endif +} + + + Property changes on: cvs2svn/tags/initial/sys/boot/arc/lib/elf_freebsd.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/lib/module.c =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/lib/module.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/lib/module.c (revision 49189) @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: alpha_module.c,v 1.2 1998/08/31 21:10:40 msmith Exp $ + */ + +/* + * alpha-specific module functionality. + * + */ + +#include +#include + +#include "bootstrap.h" +#include "libarc.h" + +/* + * Use voodoo to load modules required by current hardware. + */ +int +arc_autoload(void) +{ + /* XXX use PnP to locate stuff here */ + return(0); +} Property changes on: cvs2svn/tags/initial/sys/boot/arc/lib/module.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/lib/prom.c =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/lib/prom.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/lib/prom.c (revision 49189) @@ -0,0 +1,39 @@ +/* + * Copyright (c) 1999, Stefan Esser + * 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$ + * + */ + +#define PROM_E_BOOTED_DEV "XXX1" +#define PROM_E_BOOTED_FILE "XXX2" +#define PROM_E_BOOTED_OSFLAGS "XXX3" +#define PROM_E_TTY_DEV "XXX4" + +u_int64_t +prom_getenv(PROM_E_BOOTED_FILE, bootfile, sizeof(bootfile)) +{ + +} Property changes on: cvs2svn/tags/initial/sys/boot/arc/lib/prom.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/lib/setjmperr.c =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/lib/setjmperr.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/lib/setjmperr.c (revision 49189) @@ -0,0 +1,38 @@ +/*- + * Copyright (c) 1998 Doug Rabson + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +#include +#include +#include "arctypes.h" +#include "arcfuncs.h" + +void +longjmperror() +{ + panic("longjmp botch.\n"); +} Property changes on: cvs2svn/tags/initial/sys/boot/arc/lib/setjmperr.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/lib/time.c =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/lib/time.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/lib/time.c (revision 49189) @@ -0,0 +1,41 @@ +/*- + * Copyright (c) 1998 Doug Rabson + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +#include +#include +#include "arctypes.h" +#include "arcfuncs.h" + +time_t +time(time_t *tloc) +{ + int secs = GetRelativeTime(); + if (tloc) + *tloc = secs; + return secs; +} Property changes on: cvs2svn/tags/initial/sys/boot/arc/lib/time.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/loader/Makefile =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/loader/Makefile (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/loader/Makefile (revision 49189) @@ -0,0 +1,90 @@ +# $NetBSD: Makefile,v 1.12 1998/02/19 14:18:36 drochner Exp $ + +BASE= loader +PROG= ${BASE} +NOMAN= +NEWVERSWHAT= "ARC disk boot" ${MACHINE_ARCH} + +.PATH: ${.CURDIR}/../common + +# i386-specific bootstrap sources +SRCS+= main.c conf.c + +# Always add MI sources +.PATH: ${.CURDIR}/../../common +.include <${.CURDIR}/../../common/Makefile.inc> +CFLAGS+= -mno-fp-regs +CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR} +CFLAGS+= -I${.CURDIR}/../../.. -I. +CFLAGS+= -DLOADER + +CLEANFILES+= vers.c vers.o gensetdefs.o gensetdefs setdef0.o setdef1.o \ + setdefs.h start.o +CLEANFILES+= ${BASE} ${BASE}.sym ${BASE}.list + +CFLAGS+= -Wall + +CFLAGS+= -I${LIBSTANDDIR} +CFLAGS+= -I${.CURDIR}/../include +CRT= start.o +STRIP= +BINDIR?= /boot +LOAD_ADDRESS?= 0xffffffff80900000 + +all: ${BASE}.exe + +vers.o: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version + sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} + ${CC} -c vers.c + +${BASE}.exe: ${BASE} ${BASE}.help + elf2exe ${BASE}.sym ${BASE}.exe + +#${BASE}: ${OBJS} ${LIBSTAND} ${LIBARC} ${CRT} vers.o setdef0.o setdef1.o +# ${LD} -o ${BASE}.sym -M -e __start -N -Ttext ${LOAD_ADDRESS} \ +# ${CRT} setdef0.o ${OBJS} setdef1.o \ +# vers.o ${LIBSTAND} ${LIBARC} ${LIBSTAND} >${.OBJDIR}/${BASE}.list + +${BASE}: ${OBJS} ${LIBSTAND} ${LIBARC} ${CRT} vers.o setdef0.o setdef1.o + ${LD} -o ${BASE}.sym -M -N -Ttext ${LOAD_ADDRESS} \ + ${CRT} setdef0.o ${OBJS} setdef1.o \ + vers.o ${LIBSTAND} ${LIBARC} ${LIBSTAND} >${.OBJDIR}/${BASE}.list + +${BASE}.help: help.common help.alpha + cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} + +beforeinstall: +.if exists(${.OBJDIR}/loader.help) + ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ + ${.OBJDIR}/${BASE}.help ${DESTDIR}/boot +.else + ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ + ${.CURDIR}/${BASE}.help ${DESTDIR}/boot +.endif + +# Other fragments still to be brought in from ../Makfile.booters? +start.o: ${.CURDIR}/../lib/arch/${MACHINE}/start.S + ${CC} -c ${CFLAGS} $< + +setdef0.o: setdefs.h + +setdef1.o: setdefs.h + +machine: + ln -sf ${.CURDIR}/../../../alpha/include machine + +CLEANFILES+= machine setdefs.h gensetdefs ${BASE} ${BASE}.exe loader.help + +.include + +setdefs.h: gensetdefs ${OBJS} + @echo Generating linker sets + @./gensetdefs ${OBJS} >setdefs.h + +gensetdefs: gensetdefs.o + ${CC} -static gensetdefs.o -o $@ + +gensetdefs.o: gensetdefs.c + ${CC} -c $< + +beforedepend ${OBJS}: machine Property changes on: cvs2svn/tags/initial/sys/boot/arc/loader/Makefile ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/loader/conf.c =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/loader/conf.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/loader/conf.c (revision 49189) @@ -0,0 +1,85 @@ +/* + * $Id: conf.c,v 1.2 1998/08/31 21:10:36 msmith Exp $ + * From $NetBSD: conf.c,v 1.2 1997/03/22 09:03:29 thorpej Exp $ + */ + +/* + * Copyright (c) 1997 + * 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. + */ + + +#include +#include "libarc.h" + +/* + * We could use linker sets for some or all of these, but + * then we would have to control what ended up linked into + * the bootstrap. So it's easier to conditionalise things + * here. + * + * XXX rename these arrays to be consistent and less namespace-hostile + */ + +/* Exported for libstand */ +struct devsw *devsw[] = { + &arcdisk, + NULL +}; + +struct fs_ops *file_system[] = { + &ufs_fsops, + &zipfs_fsops, + NULL +}; + +/* Exported for alpha only */ +/* + * Sort formats so that those that can detect based on arguments + * rather than reading the file go first. + */ +extern struct module_format alpha_elf; + +struct module_format *module_formats[] = { + &alpha_elf, + NULL +}; + +/* + * Consoles + * + * We don't prototype these in libalpha.h because they require + * data structures from bootstrap.h as well. + */ +extern struct console arcconsole; + +struct console *consoles[] = { + &arcconsole, + NULL +}; Property changes on: cvs2svn/tags/initial/sys/boot/arc/loader/conf.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/loader/help.alpha =================================================================== Property changes on: cvs2svn/tags/initial/sys/boot/arc/loader/help.alpha ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/loader/main.c =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/loader/main.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/loader/main.c (revision 49189) @@ -0,0 +1,405 @@ +/*- + * Copyright (c) 1998 Michael Smith + * Copyright (c) 1998 Doug Rabson + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + + +#include +#include +#include + +#include +#include "bootstrap.h" +#include "libarc.h" +#include "arctypes.h" +#include "arcfuncs.h" + +extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; + +struct arc_devdesc currdev; /* our current device */ +struct arch_switch archsw; /* MI/MD interface boundary */ + +extern char end[]; +extern void halt(void); + +#define ARCENV_BOOTFILE "OSLoadFilename" + +static char *MemoryTypes[] = { + "MemoryExceptionBlock", + "MemorySystemBlock", + "MemoryFree", + "MemoryBad", + "MemoryLoadedProgram", + "MemoryFirmwareTemporary", + "MemoryFirmwarePermanent", + "MemoryFreeContiguous", + "MemorySpecialMemory", + "MemoryMaximum", +}; + +#ifdef __alpha__ +#define ptob(p) ((p) << 13) +#endif + +unsigned long +memsize() +{ + unsigned long amount = 0; + MEMORY_DESCRIPTOR *desc; + + for (desc = GetMemoryDescriptor(NULL); desc; + desc = GetMemoryDescriptor(desc)) { + printf("%s at %x-%x\n", MemoryTypes[desc->Type], + ptob(desc->BasePage), + ptob(desc->BasePage + desc->PageCount)); + if (desc->Type == MemoryFree + || desc->Type == MemoryFirmwareTemporary) + amount += (desc->PageCount << 13); /* XXX pagesize */ + } + + return amount; +} + +static char *ConfigurationClasses[] = { + "SystemClass", + "ProcessorClass", + "CacheClass", + "AdapterClass", + "ControllerClass", + "PeripheralClass", + "MemoryClass", + "MaximumClass", +}; + + +static char *ConfigurationTypes[] = { + "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", +}; + +static char *ConfigurationTypeCodes[] = { + "ARC", + "CPU", + "FPC", + "PrimaryIcache", + "PrimaryDcache", + "SecondaryIcache", + "SecondaryDcache", + "SecondaryCache", + "eisa", + "TcAdapter", /* XXX ? */ + "scsi", + "DtiAdapter", /* XXX ? */ + "multi", + "disk", + "TapeController", /* XXX ? */ + "CdromController", /* XXX ? */ + "WormController", /* XXX ? */ + "serial", + "NetworkController", /* XXX ? */ + "video", + "par", + "PointerController", /* XXX ? */ + "key", + "AudioController", /* XXX ? */ + "OtherController", /* XXX ? */ + "rdisk", + "fdisk", + "TapePeripheral", /* XXX ? */ + "ModemPeripheral", /* XXX ? */ + "MonitorPeripheral", /* XXX ? */ + "PrinterPeripheral", /* XXX ? */ + "PointerPeripheral", /* XXX ? */ + "keyboard", + "TerminalPeripheral", /* XXX ? */ + "OtherPeripheral", /* XXX ? */ + "LinePeripheral", /* XXX ? */ + "NetworkPeripheral", /* XXX ? */ + "Memory", + "MaximumType" +}; + +static void +indent(int level) +{ + while (level--) + putchar(' '); +} + +void +printconfig(unsigned int level, CONFIGURATION_COMPONENT *component) +{ + CONFIGURATION_COMPONENT *child; + + indent(level); + printf("%s(%s,%d)", + ConfigurationClasses[component->Class], + ConfigurationTypes[component->Type], + component->Key); +#if 1 + if (component->IdentifierLength) + printf("=%d,%s\n", component->IdentifierLength, + ptr(component->Identifier)); + else + putchar('\n'); +#endif + getchar(); + + for (child = GetChild(component); child; child = GetPeer(child)) { + printconfig(level + 2, child); + } +} + +void +dumpdisk(const char *name) +{ + u_int32_t fd, count; + unsigned char buf[512]; + int i, j; + + printf("dump first sector of %s\n", name); + if (Open(name, OpenReadOnly, &fd) != ESUCCESS) { + printf("can't open disk\n"); + return; + } + if (Read(fd, buf, 512, &count) != ESUCCESS) { + printf("can't read from disk\n"); + Close(fd); + return; + } + for (i = 0; i < 16; i++) { + for (j = 0; j < 32; j++) + printf("%02x", buf[i*32 + j]); + putchar('\n'); + } + Close(fd); +} + +void +listdisks(char *path, CONFIGURATION_COMPONENT *component) +{ + CONFIGURATION_COMPONENT *child; + char newpath[80]; + char keybuf[20]; + + if (path == NULL) { + printf("\nARC disk devices:\n"); + newpath[0] = '\0'; + } else { + strcpy(newpath, path); + strcat(newpath, ConfigurationTypeCodes[component->Type]); + sprintf(keybuf, "(%d)", component->Key); + strcat(newpath, keybuf); + } + if (!strcmp(ConfigurationTypeCodes[component->Type], "rdisk") || + !strcmp(ConfigurationTypeCodes[component->Type], "fdisk")) { + printf("%s\n", newpath); + } + for (child = GetChild(component); child; child = GetPeer(child)) { + listdisks(newpath, child); + } +} + +static int exit_code = 0; +jmp_buf exit_env; + +void +exit(int code) +{ + exit_code = 0; + longjmp(exit_env, 1); +} + +int +main(int argc, int argv[], int envp[]) +{ + int i; + char *bootfile; + + if (setjmp(exit_env)) + return exit_code; + + /* + * Initialise the heap as early as possible. Once this is done, + * alloc() is usable. The stack is buried inside us, so this is + * safe. + */ + setheap((void *)end, (void *)(end + 512*1024)); + + /* + * XXX Chicken-and-egg problem; we want to have console output + * early, but some console attributes may depend on reading from + * eg. the boot device, which we can't do yet. We can use + * printf() etc. once this is done. + */ + cons_probe(); + +#if 0 + printconfig(0, GetChild(NULL)); + dumpdisk("scsi(0)disk(0)rdisk(0)partition(0)"); +#endif + listdisks(NULL, GetChild(NULL)); + printf("\n"); + + make_rpb(); + + /* + * Initialise the block cache + */ + bcache_init(32, 512); /* 16k XXX tune this */ + + /* + * March through the device switch probing for things. + */ + for (i = 0; devsw[i] != NULL; i++) + if (devsw[i]->dv_init != NULL) + (devsw[i]->dv_init)(); + + printf("\n"); + printf("%s, Revision %s\n", bootprog_name, bootprog_rev); + printf("(%s, %s)\n", bootprog_maker, bootprog_date); + printf("Memory: %ld k\n", memsize() / 1024); + + /* We're booting from an SRM disk, try to spiff this */ + /* XXX presumes that biosdisk is first in devsw */ + currdev.d_dev = devsw[0]; + currdev.d_type = currdev.d_dev->dv_type; + currdev.d_kind.arcdisk.unit = 0; + /* XXX should be able to detect this, default to autoprobe */ + currdev.d_kind.arcdisk.slice = -1; + /* default to 'a' */ + currdev.d_kind.arcdisk.partition = 0; + + /* Create arc-specific variables */ + bootfile = GetEnvironmentVariable(ARCENV_BOOTFILE); + if (bootfile) + setenv("bootfile", bootfile, 1); + + env_setenv("currdev", EV_VOLATILE, + arc_fmtdev(&currdev), arc_setcurrdev, env_nounset); + env_setenv("loaddev", EV_VOLATILE, + arc_fmtdev(&currdev), env_noset, env_nounset); + setenv("LINES", "24", 1); /* optional */ + + archsw.arch_autoload = arc_autoload; + archsw.arch_getdev = arc_getdev; + archsw.arch_copyin = arc_copyin; + archsw.arch_copyout = arc_copyout; + archsw.arch_readin = arc_readin; + + interact(); /* doesn't return */ + + return 0; /* keep compiler happy */ +} + +COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); + +static int +command_reboot(int argc, char *argv[]) +{ + + printf("Rebooting...\n"); + delay(1000000); + FwReboot(); + /* Note: we shouldn't get to this point! */ + panic("Reboot failed!"); + exit(0); +} + +COMMAND_SET(quit, "quit", "exit the loader", command_quit); + +static int +command_quit(int argc, char *argv[]) +{ + exit(0); + return(CMD_OK); +} + +#if 0 + +COMMAND_SET(stack, "stack", "show stack usage", command_stack); + +static int +command_stack(int argc, char *argv[]) +{ + char *cp; + + for (cp = &stackbase; cp < &stacktop; cp++) + if (*cp != 0) + break; + + printf("%d bytes of stack used\n", &stacktop - cp); + return(CMD_OK); +} + +#endif + +COMMAND_SET(heap, "heap", "show heap usage", command_heap); + +static int +command_heap(int argc, char *argv[]) +{ + printf("heap base at %p, top at %p, used %ld\n", end, sbrk(0), sbrk(0) - end); + return(CMD_OK); +} Property changes on: cvs2svn/tags/initial/sys/boot/arc/loader/main.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/loader/setdef0.c =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/loader/setdef0.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/loader/setdef0.c (revision 49189) @@ -0,0 +1,49 @@ +/*- + * Copyright (c) 1997 John D. Polstra + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: setdef0.c,v 1.1.1.1 1998/08/21 03:17:42 msmith Exp $ + */ + +#ifdef __ELF__ + +#include +#include + +/* + * DEFINE_SET creates the section and label for a set, and emits the + * count word at the front of it. + */ +#define DEFINE_SET(set, count) \ + __asm__(".section .set." #set ",\"aw\""); \ + __asm__(".globl " #set); \ + __asm__(".type " #set ",@object"); \ + __asm__(".p2align 3"); \ + __asm__(#set ":"); \ + __asm__(".quad " #count); \ + __asm__(".previous") + +#include "setdefs.h" /* Contains a `DEFINE_SET' for each set */ + +#endif /* __ELF__ */ Property changes on: cvs2svn/tags/initial/sys/boot/arc/loader/setdef0.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/loader/setdef1.c =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/loader/setdef1.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/loader/setdef1.c (revision 49189) @@ -0,0 +1,41 @@ +/*- + * Copyright (c) 1997 John D. Polstra + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: setdef1.c,v 1.1.1.1 1998/08/21 03:17:42 msmith Exp $ + */ + +#ifdef __ELF__ + +/* + * DEFINE_SET emits the NULL terminator for a set. + */ +#define DEFINE_SET(set, count) \ + __asm__(".section .set." #set ",\"aw\""); \ + __asm__(".quad 0"); \ + __asm__(".previous") + +#include "setdefs.h" /* Contains a `DEFINE_SET' for each set */ + +#endif /* __ELF__ */ Property changes on: cvs2svn/tags/initial/sys/boot/arc/loader/setdef1.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/arc/loader/version =================================================================== --- cvs2svn/tags/initial/sys/boot/arc/loader/version (nonexistent) +++ cvs2svn/tags/initial/sys/boot/arc/loader/version (revision 49189) @@ -0,0 +1,7 @@ +$Id: version,v 1.1.1.1 1998/08/21 03:17:42 msmith Exp $ + +NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this +file is important. Make sure the current version number is on line 6. + +0.1: Initial i386 version, germinated from the NetBSD i386 + standalone, but enormously modified. Property changes on: cvs2svn/tags/initial/sys/boot/arc/loader/version ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/Makefile =================================================================== --- cvs2svn/tags/initial/sys/boot/Makefile (nonexistent) +++ cvs2svn/tags/initial/sys/boot/Makefile (revision 49189) @@ -0,0 +1,4 @@ +# Pick the subdir based on the target architecture. +SUBDIR= ${MACHINE_ARCH} + +.include Property changes on: cvs2svn/tags/initial/sys/boot/Makefile ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/Makefile =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/Makefile (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/Makefile (revision 49189) @@ -0,0 +1,6 @@ +# $Id$ + +SUBDIR= libalpha +SUBDIR+= boot1 boot2 netboot + +.include Property changes on: cvs2svn/tags/initial/sys/boot/alpha/Makefile ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/Makefile.inc =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/Makefile.inc (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/Makefile.inc (revision 49189) @@ -0,0 +1,6 @@ +# Options used when building app-specific libalpha components +PRIMARY_LOAD_ADDRESS= 20000000 # "Region 1 start" +SECONDARY_LOAD_ADDRESS= 2000c000 # "Region 1 start" + 48k +HEAP_LIMIT= 20040000 # "Region 1 start" + 256k + +BINDIR= /usr/mdec Property changes on: cvs2svn/tags/initial/sys/boot/alpha/Makefile.inc ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/boot1/Makefile =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/boot1/Makefile (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/boot1/Makefile (revision 49189) @@ -0,0 +1,47 @@ +# $NetBSD: Makefile,v 1.15 1998/03/28 00:21:35 thorpej Exp $ + +.include <../Makefile.inc> + +PROG = boot1 + +.PATH: ${.CURDIR}/../../common +.PATH: ${.CURDIR}/../libalpha + +SRCS= start.S boot1.c sys.c +CFLAGS+= -mno-fp-regs +CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR} +LIBSTANDDIR= /home/dfr/FreeBSD/alpha/src/lib/libstand +LIBSTAND= ${LIBSTANDDIR}/obj/libstand.a +CFLAGS+= -I${LIBSTANDDIR} +LIBALPHA= ${.CURDIR}/../libalpha/obj/libalpha.a +CFLAGS+= -I${.CURDIR}/.. +CFLAGS+= -DSECONDARY_LOAD_ADDRESS=0x${SECONDARY_LOAD_ADDRESS} -DMINIMAL +NOMAN=1 +STRIP= + +BOOT_RELOC = ${PRIMARY_LOAD_ADDRESS} + +CLEANFILES+= ${PROG}.sym ${PROG}.nosym ${PROG}.list + +all: ${PROG} + +afterinstall: + ln -sf boot1 /usr/mdec/sdboot + +${PROG}.nosym: ${PROG}.sym + cp ${PROG}.sym ${PROG}.nosym + strip ${PROG}.nosym + +${PROG}: ${PROG}.nosym + objcopy -O binary ${PROG}.nosym ${PROG} + +.include + +start.o: ${.CURDIR}/../libalpha/start.S + ${CC} -c -DPRIMARY_BOOTBLOCK $< + +${PROG}.sym: ${OBJS} ${LIBKERN} + ${LD} -M -Ttext ${BOOT_RELOC} -N -e start -o ${PROG}.sym ${OBJS} \ + ${LIBSTAND} ${LIBALPHA} ${LIBSTAND} > ${.OBJDIR}/${PROG}.list + size ${PROG}.sym + Property changes on: cvs2svn/tags/initial/sys/boot/alpha/boot1/Makefile ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/boot1/boot1.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/boot1/boot1.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/boot1/boot1.c (revision 49189) @@ -0,0 +1,188 @@ +/* + * $Id$ + * From $NetBSD: bootxx.c,v 1.4 1997/09/06 14:08:29 drochner Exp $ + */ + +/* + * Copyright (c) 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include + +#include + +#define DEBUGxx + +extern end[]; +int errno; + +char *heap = (char*) end; + +void +putchar(int c) +{ + if (c == '\n') + prom_putchar('\r'); + prom_putchar(c); +} + +void +puts(const char *s) +{ + while (*s) + putchar(*s++); +} + +void * +malloc(size_t size) +{ + char *p = heap; + size = (size + 7) & ~7; + heap += size; + return p; +} + +void +free(void * p) +{ +} + +void +panic(const char *message, ...) +{ + puts(message); + puts("\r\n"); + halt(); +} + +int prom_fd = 0; + +int +devopen() +{ + prom_return_t ret; + char devname[64]; + + if (prom_fd) + return; + + ret.bits = prom_getenv(PROM_E_BOOTED_DEV, devname, sizeof devname); + + ret.bits = prom_open(devname, ret.u.retval + 1); + if (ret.u.status) + panic("devopen: open failed\n"); + + prom_fd = ret.u.retval; + + /* XXX read disklabel and setup partition offset */ + + return 0; +} + +#ifdef DEBUG + +void +puthex(u_long v) +{ + int digit; + char hex[] = "0123456789abcdef"; + + if (!v) { + puts("0"); + return; + } + + for (digit = 0; v >= (0x10L << digit); digit += 4) + ; + + for (; digit >= 0; digit -= 4) + putchar(hex[(v >> digit) & 0xf]); +} + +#endif + +void +devread(char *buf, int block, size_t size) +{ +#ifdef DEBUG + puts("devread("); + puthex((u_long)buf); + puts(","); + puthex(block); + puts(","); + puthex(size); + puts(")\n"); +#endif + + prom_read(prom_fd, size, buf, block); +} + +void +devclose() +{ + if (prom_fd) { + prom_close(prom_fd); + prom_fd = 0; + } +} + +void +loadfile(char *name, char *addr) +{ + int n; + + if (openrd(name)) { + puts("Can't open file "); + puts(name); + puts("\n"); + halt(); + } + + do { + n = read(addr, 1024); + addr += n; + twiddle(); + } while (n > 0); + + devclose(); +} + +void +main() +{ + char *loadaddr = (char*) SECONDARY_LOAD_ADDRESS; + char *p; + void (*entry) __P((void)); + + int i; + + init_prom_calls(); + + loadfile("/boot/boot2", loadaddr); + + entry = (void (*)())loadaddr; + (*entry)(); +} Property changes on: cvs2svn/tags/initial/sys/boot/alpha/boot1/boot1.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/boot1/sys.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/boot1/sys.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/boot1/sys.c (revision 49189) @@ -0,0 +1,187 @@ +/* + * Mach Operating System + * Copyright (c) 1992, 1991 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + * + * from: Mach, Revision 2.2 92/04/04 11:36:34 rpd + * fromL Id: sys.c,v 1.21 1997/06/09 05:10:56 bde Exp + * $Id$ + */ + +#include +#include + +#include +#include +#include + +#include + +struct fs *fs; +struct inode inode; +int boff = 0; + +#if 0 +/* #define BUFSIZE 4096 */ +#define BUFSIZE MAXBSIZE + +static char buf[BUFSIZE], fsbuf[SBSIZE], iobuf[MAXBSIZE]; +#endif + +#define BUFSIZE 8192 +#define MAPBUFSIZE BUFSIZE +static char buf[BUFSIZE], fsbuf[BUFSIZE], iobuf[BUFSIZE]; + +static char mapbuf[MAPBUFSIZE]; +static int mapblock; + +int poff; + +#ifdef RAWBOOT +#define STARTBYTE 8192 /* Where on the media the kernel starts */ +#endif + +static int block_map(int file_block); +static int find(char *path); + +int +read(char *buffer, int count) +{ + int logno, off, size; + int cnt2, bnum2; + struct fs *fs_copy; + int n = 0; + + if (poff + count > inode.i_size) + count = inode.i_size - poff; + while (count > 0 && poff < inode.i_size) { + fs_copy = fs; + off = blkoff(fs_copy, poff); + logno = lblkno(fs_copy, poff); + cnt2 = size = blksize(fs_copy, &inode, logno); + bnum2 = fsbtodb(fs_copy, block_map(logno)) + boff; + if ( (!off) && (size <= count)) { + devread(buffer, bnum2, cnt2); + } else { + size -= off; + if (size > count) + size = count; + devread(iobuf, bnum2, cnt2); + bcopy(iobuf+off, buffer, size); + } + buffer += size; + count -= size; + poff += size; + n += size; + } + return n; +} + +static int +find(char *path) +{ + char *rest, ch; + int block, off, loc, ino = ROOTINO; + struct dirent *dp; + char list_only; + + list_only = (path[0] == '?' && path[1] == '\0'); + loop: + devread(iobuf, fsbtodb(fs, ino_to_fsba(fs, ino)) + boff, fs->fs_bsize); + bcopy((void *)&((struct dinode *)iobuf)[ino % fs->fs_inopb], + (void *)&inode.i_din, + sizeof (struct dinode)); + if (!*path) + return 1; + while (*path == '/') + path++; + if (!inode.i_size || ((inode.i_mode&IFMT) != IFDIR)) + return 0; + for (rest = path; (ch = *rest) && ch != '/'; rest++) ; + *rest = 0; + loc = 0; + do { + if (loc >= inode.i_size) { + if (list_only) { + putchar('\n'); + return -1; + } else { + return 0; + } + } + if (!(off = blkoff(fs, loc))) { + block = lblkno(fs, loc); + devread(iobuf, fsbtodb(fs, block_map(block)) + boff, + blksize(fs, &inode, block)); + } + dp = (struct dirent *)(iobuf + off); + loc += dp->d_reclen; + if (dp->d_fileno && list_only) { + puts(dp->d_name); + putchar(' '); + } + } while (!dp->d_fileno || strcmp(path, dp->d_name)); + ino = dp->d_fileno; + *(path = rest) = ch; + goto loop; +} + + +static int +block_map(int file_block) +{ + int bnum; + if (file_block < NDADDR) + return(inode.i_db[file_block]); + if ((bnum=fsbtodb(fs, inode.i_ib[0])+boff) != mapblock) { + devread(mapbuf, bnum, fs->fs_bsize); + mapblock = bnum; + } + return (((int *)mapbuf)[(file_block - NDADDR) % NINDIR(fs)]); +} + + +int +openrd(char *name) +{ + int ret; + + if (devopen()) + return 1; + + /* + * Load Filesystem info (mount the device). + */ + devread((char *)(fs = (struct fs *)fsbuf), SBLOCK + boff, SBSIZE); + + /* + * Find the actual FILE on the mounted device. + */ + ret = find(name); + if (ret == 0) + return 1; + if (ret < 0) + return -1; + poff = 0; + return 0; +} Property changes on: cvs2svn/tags/initial/sys/boot/alpha/boot1/sys.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/boot2/Makefile =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/boot2/Makefile (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/boot2/Makefile (revision 49189) @@ -0,0 +1,69 @@ +# $NetBSD: Makefile,v 1.12 1998/02/19 14:18:36 drochner Exp $ + +BASE= boot2 +PROG= ${BASE} +NOMAN= +NEWVERSWHAT= "SRM disk boot" + +.PATH: ${.CURDIR}/../common + +# i386-specific bootstrap sources +SRCS+= main.c conf.c + +# Always add MI sources +.PATH: ${.CURDIR}/../../common +.include <${.CURDIR}/../../common/Makefile.inc> +CFLAGS+= -mno-fp-regs +CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR} +# Verbose ls causes extra heap usage +CFLAGS+= -DVERBOSE_LS + +CLEANFILES+= vers.c vers.o gensetdefs.o gensetdefs setdef0.o setdef1.o \ + setdefs.h start.o +CLEANFILES+= ${BASE} ${BASE}.sym ${BASE}.list + +CFLAGS+= -Wall + +# XXX fix to use "standard" versions +LIBSTANDDIR= /home/dfr/FreeBSD/alpha/src/lib/libstand +LIBSTAND= ${LIBSTANDDIR}/obj/libstand.a +CFLAGS+= -I${LIBSTANDDIR} +LIBALPHA= ${.CURDIR}/../libalpha/obj/libalpha.a +CFLAGS+= -I${.CURDIR}/.. +CRT= start.o +STRIP= + +all: ${BASE} + +vers.o: ${.CURDIR}/newvers.sh ${.CURDIR}/Makefile + sh ${.CURDIR}/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} + ${CC} -c vers.c + +${BASE}: ${BASE}.sym + objcopy -O binary ${BASE}.sym ${BASE} + +${BASE}.sym: ${OBJS} ${LIBSTAND} ${LIBALPHA} ${CRT} vers.o setdef0.o setdef1.o + ${LD} -o ${BASE}.sym -M -e start -N -Ttext ${SECONDARY_LOAD_ADDRESS} \ + ${CRT} setdef0.o ${OBJS} setdef1.o \ + vers.o ${LIBSTAND} ${LIBALPHA} ${LIBSTAND} >${.OBJDIR}/${BASE}.list + +# Other fragments still to be brought in from ../Makfile.booters? +start.o: ${.CURDIR}/../libalpha/start.S + ${CC} -c $< + +setdef0.o: setdefs.h + +setdef1.o: setdefs.h + +.include + +setdefs.h: gensetdefs ${OBJS} + @echo Generating linker sets + @./gensetdefs ${OBJS} >setdefs.h + +gensetdefs: gensetdefs.o + ${CC} -static gensetdefs.o -o $@ + +gensetdefs.o: gensetdefs.c + ${CC} -c $< + Property changes on: cvs2svn/tags/initial/sys/boot/alpha/boot2/Makefile ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/boot2/boot2.list =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/boot2/boot2.list (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/boot2/boot2.list (revision 49189) @@ -0,0 +1,1000 @@ +Archive member included because of file (symbol) + +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ufs.o) + conf.o (ufs_fsops) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(stat.o) + ls.o (stat) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__reml.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ufs.o) (__reml) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__remlu.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ufs.o) (__remlu) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__divl.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ufs.o) (__divl) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__divlu.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ufs.o) (__divlu) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strncpy.o) + boot.o (strncpy) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcat.o) + misc.o (strcat) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(pager.o) + commands.o (pager_open) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) + ls.o (optind) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(environment.o) + commands.o (environ) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strtol.o) + boot.o (strtol) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strchr.o) + boot.o (strchr) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strerror.o) + commands.o (strerror) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strdup.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(environment.o) (strdup) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(gets.o) + interp.o (ngets) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) + conf.o (zipfs_fsops) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(read.o) + ls.o (read) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(open.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(read.o) (files) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(close.o) + interp.o (close) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(fstat.o) + ls.o (fstat) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nullfs.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ufs.o) (null_write) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inflate.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) (inflateEnd) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infblock.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inflate.o) (inflate_blocks_reset) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(adler32.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inflate.o) (adler32) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strrchr.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) (strrchr) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcmp.o) + console.o (strcmp) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(twiddle.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ufs.o) (twiddle) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zutil.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inflate.o) (zcalloc) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inftrees.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infblock.o) (inflate_trees_bits) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infcodes.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infblock.o) (inflate_codes_new) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(alloc.o) + main.o (setheap) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inffast.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infcodes.o) (inflate_fast) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infutil.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infblock.o) (inflate_mask) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcopy.o) + interp.o (bcopy) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) + interp.o (errno) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bzero.o) + start.o (bzero) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(printf.o) + main.o (printf) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__remqu.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strtol.o) (__remqu) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__divqu.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strtol.o) (__divqu) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strlen.o) + boot.o (strlen) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcd.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(printf.o) (hex2ascii_data) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(srmdisk.o) + conf.o (srmdisk) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(devicename.o) + main.o (alpha_getdev) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(alpha_module.o) + main.o (alpha_boot) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(time.o) + boot.o (time) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(delay.o) + main.o (delay) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(reboot.o) + main.o (reboot) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(elf_freebsd.o) + conf.o (alpha_elf) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(OSFpal.o) + main.o (OSFpal) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(getsecs.o) + /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(time.o) (getsecs) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(pal.o) + /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(delay.o) (alpha_rpcc) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(prom_swpal.o) + /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(OSFpal.o) (switch_palcode) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(prom.o) + conf.o (promconsole) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(prom_disp.o) + /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(prom.o) (prom_dispatch_v) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(lseek.o) + /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(elf_freebsd.o) (lseek) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(dev.o) + /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(srmdisk.o) (noioctl) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(closeall.o) + /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(elf_freebsd.o) (closeall) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strncmp.o) + /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(devicename.o) (strncmp) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcpy.o) + /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(devicename.o) (strcpy) + +Allocating common symbols +Common symbol size file + +domainname 0x80 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +nameip 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +hostnamelen 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +command_errmsg 0x8 commands.o +errno 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +ffp_save 0x8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(elf_freebsd.o) +swapip 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +rootip 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +optarg 0x8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) +myip 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +hostname 0x80 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +archsw 0x18 main.o +ssym 0x8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(elf_freebsd.o) +console 0x4 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(prom.o) +command_errbuf 0x100 commands.o +currdev 0x18 main.o +bootfile 0x80 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +ptbr_save 0x8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(elf_freebsd.o) +gateip 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +files 0x180 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(open.o) +ifname 0x10 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +domainnamelen 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +optreset 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) +optopt 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) +prom_dispatch_v 0x10 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(prom_disp.o) +esym 0x8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(elf_freebsd.o) + +Memory Configuration + +Name Origin Length +*default* 0x0000000000000000 0xffffffffffffffff + +Linker script and memory map + +Address of section .text set to 0x2000c000 +LOAD start.o +LOAD setdef0.o +LOAD main.o +LOAD conf.o +LOAD boot.o +LOAD commands.o +LOAD console.o +LOAD devopen.o +LOAD interp.o +LOAD ls.o +LOAD misc.o +LOAD module.o +LOAD panic.o +LOAD setdef1.o +LOAD vers.o +LOAD /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a +LOAD /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a +LOAD /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a + 0x00000001200000b0 .=(0x120000000+SIZEOF_HEADERS) + +.interp + *(.interp) + +.hash + *(.hash) + +.dynsym + *(.dynsym) + +.dynstr + *(.dynstr) + +.gnu.version + *(.gnu.version) + +.gnu.version_d + *(.gnu.version_d) + +.gnu.version_r + *(.gnu.version_r) + +.rel.text + *(.rel.text) + *(.rel.gnu.linkonce.t*) + +.rela.text + *(.rela.text) + *(.rela.gnu.linkonce.t*) + +.rel.data + *(.rel.data) + *(.rel.gnu.linkonce.d*) + +.rela.data 0x00000001200000b0 0x0 + *(.rela.data) + *(.rela.gnu.linkonce.d*) + +.rela.set.Xcommand_set + 0x00000001200000b0 0x0 + +.rel.rodata + *(.rel.rodata) + *(.rel.gnu.linkonce.r*) + +.rela.rodata + *(.rela.rodata) + *(.rela.gnu.linkonce.r*) + +.rel.got + *(.rel.got) + +.rela.got + *(.rela.got) + +.rel.ctors + *(.rel.ctors) + +.rela.ctors + *(.rela.ctors) + +.rel.dtors + *(.rel.dtors) + +.rela.dtors + *(.rela.dtors) + +.rel.init + *(.rel.init) + +.rela.init + *(.rela.init) + +.rel.fini + *(.rel.fini) + +.rela.fini + *(.rela.fini) + +.rel.bss + *(.rel.bss) + +.rela.bss + *(.rela.bss) + +.rel.plt + *(.rel.plt) + +.rela.plt + *(.rela.plt) + +.init + *(.init) + +.text 0x000000002000c000 0xe4c0 + *(.text) + .text 0x000000002000c000 0x50 start.o + 0x000000002000c044 __main + 0x000000002000c040 _rtt + 0x000000002000c048 cpu_number + 0x000000002000c040 halt + 0x000000002000c000 start + *fill* 0x000000002000c050 0x10 1207895071 + .text 0x000000002000c060 0x3e0 main.o + 0x000000002000c060 memsize + 0x000000002000c0c8 main + .text 0x000000002000c440 0x580 boot.o + 0x000000002000c6e8 autoboot + .text 0x000000002000c9c0 0x3e0 commands.o + .text 0x000000002000cda0 0x480 console.o + 0x000000002000cff8 putchar + 0x000000002000cda0 cons_probe + 0x000000002000cf68 ischar + 0x000000002000cea8 getchar + .text 0x000000002000d220 0xf0 devopen.o + 0x000000002000d2d0 devclose + 0x000000002000d220 devopen + *fill* 0x000000002000d310 0x10 1207895071 + .text 0x000000002000d320 0x5c0 interp.o + 0x000000002000d5e8 interact + 0x000000002000d700 source + .text 0x000000002000d8e0 0x480 ls.o + .text 0x000000002000dd60 0x140 misc.o + 0x000000002000dd60 unargv + .text 0x000000002000dea0 0x3a0 module.o + 0x000000002000e178 mod_findmodule + 0x000000002000dfd0 mod_load + .text 0x000000002000e240 0xf0 panic.o + 0x000000002000e240 panic + *fill* 0x000000002000e330 0x10 1207895071 + .text 0x000000002000e340 0xf80 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ufs.o) + .text 0x000000002000f2c0 0x90 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(stat.o) + 0x000000002000f2c0 stat + .text 0x000000002000f350 0x130 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__reml.o) + 0x000000002000f350 __reml + .text 0x000000002000f480 0xec /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__remlu.o) + 0x000000002000f480 __remlu + .text 0x000000002000f56c 0x128 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__divl.o) + 0x000000002000f56c __divl + .text 0x000000002000f694 0xe4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__divlu.o) + 0x000000002000f694 __divlu + *fill* 0x000000002000f778 0x8 1207895071 + .text 0x000000002000f780 0xa0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strncpy.o) + 0x000000002000f780 strncpy + .text 0x000000002000f820 0x80 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcat.o) + 0x000000002000f820 strcat + .text 0x000000002000f8a0 0x380 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(pager.o) + 0x000000002000f948 pager_output + 0x000000002000f930 pager_close + 0x000000002000faf8 pager_file + 0x000000002000f8a0 pager_open + .text 0x000000002000fc20 0x310 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) + 0x000000002000fc20 getopt + *fill* 0x000000002000ff30 0x10 1207895071 + .text 0x000000002000ff40 0x4a0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(environment.o) + 0x00000000200102a8 unsetenv + 0x00000000200103d0 env_nounset + 0x00000000200101a0 getenv + 0x0000000020010248 putenv + 0x00000000200103c8 env_noset + 0x00000000200101e0 setenv + 0x000000002000ff40 env_getenv + 0x000000002000ffc0 env_setenv + .text 0x00000000200103e0 0x260 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strtol.o) + 0x00000000200103e0 strtol + .text 0x0000000020010640 0x60 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strchr.o) + 0x0000000020010640 strchr + .text 0x00000000200106a0 0xa0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strerror.o) + 0x00000000200106a0 strerror + .text 0x0000000020010740 0xa0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strdup.o) + 0x0000000020010740 strdup + .text 0x00000000200107e0 0x340 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(gets.o) + 0x0000000020010a10 fgetstr + 0x00000000200107e0 ngets + .text 0x0000000020010b20 0x8e0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) + 0x0000000020010b20 calloc + .text 0x0000000020011400 0x150 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(read.o) + 0x0000000020011400 read + *fill* 0x0000000020011550 0x10 1207895071 + .text 0x0000000020011560 0x220 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(open.o) + 0x00000000200115a8 open + .text 0x0000000020011780 0x130 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(close.o) + 0x0000000020011780 close + .text 0x00000000200118b0 0xa0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(fstat.o) + 0x00000000200118b0 fstat + .text 0x0000000020011950 0xa8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nullfs.o) + 0x0000000020011998 null_write + 0x00000000200119d8 null_stat + 0x0000000020011970 null_close + 0x0000000020011978 null_read + 0x0000000020011950 null_open + 0x00000000200119b8 null_seek + *fill* 0x00000000200119f8 0x8 1207895071 + .text 0x0000000020011a00 0xc00 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inflate.o) + 0x0000000020011cb0 inflate + 0x0000000020012590 inflateSyncPoint + 0x0000000020011c80 inflateInit_ + 0x0000000020011a00 inflateReset + 0x00000000200123f8 inflateSync + 0x00000000200122f0 inflateSetDictionary + 0x0000000020011a80 inflateEnd + 0x0000000020011b10 inflateInit2_ + .text 0x0000000020012600 0x1400 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infblock.o) + 0x0000000020013908 inflate_blocks_free + 0x00000000200127f0 inflate_blocks + 0x0000000020012600 inflate_blocks_reset + 0x00000000200139f0 inflate_blocks_sync_point + 0x0000000020013990 inflate_set_dictionary + 0x00000000200126d0 inflate_blocks_new + .text 0x0000000020013a00 0x240 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(adler32.o) + 0x0000000020013a00 adler32 + .text 0x0000000020013c40 0x60 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strrchr.o) + 0x0000000020013c40 strrchr + .text 0x0000000020013ca0 0xa0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcmp.o) + 0x0000000020013ca0 strcmp + .text 0x0000000020013d40 0x70 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(twiddle.o) + 0x0000000020013d40 twiddle + .text 0x0000000020013db0 0x98 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zutil.o) + 0x0000000020013db0 zlibVersion + 0x0000000020013e18 zcfree + 0x0000000020013dc0 zError + 0x0000000020013de0 zcalloc + *fill* 0x0000000020013e48 0x18 1207895071 + .text 0x0000000020013e60 0xd40 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inftrees.o) + 0x00000000200148b8 inflate_trees_fixed + 0x0000000020014598 inflate_trees_bits + 0x00000000200146c0 inflate_trees_dynamic + .text 0x0000000020014ba0 0xc40 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infcodes.o) + 0x0000000020014ba0 inflate_codes_new + 0x0000000020014c48 inflate_codes + 0x00000000200157a0 inflate_codes_free + .text 0x00000000200157e0 0x1e0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(alloc.o) + 0x00000000200157e0 setheap + 0x0000000020015808 malloc + 0x0000000020015998 sbrk + 0x0000000020015900 free + .text 0x00000000200159c0 0x540 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inffast.o) + 0x00000000200159c0 inflate_fast + .text 0x0000000020015f00 0x1e0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infutil.o) + 0x0000000020015f00 inflate_flush + .text 0x00000000200160e0 0x25c /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcopy.o) + 0x00000000200160e0 bcopy + .text 0x000000002001633c 0xb0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bzero.o) + 0x000000002001633c bzero + *fill* 0x00000000200163ec 0x14 1207895071 + .text 0x0000000020016400 0x11c0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(printf.o) + 0x0000000020016400 printf + 0x0000000020016480 vprintf + 0x00000000200164c0 sprintf + .text 0x00000000200175c0 0xe4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__remqu.o) + 0x00000000200175c0 __remqu + .text 0x00000000200176a4 0xdc /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__divqu.o) + 0x00000000200176a4 __divqu + .text 0x0000000020017780 0x40 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strlen.o) + 0x0000000020017780 strlen + .text 0x00000000200177c0 0x650 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(srmdisk.o) + .text 0x0000000020017e10 0x8e0 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(devicename.o) + 0x0000000020018478 alpha_fmtdev + 0x0000000020017e10 alpha_getdev + 0x0000000020018628 alpha_setcurrdev + .text 0x00000000200186f0 0x138 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(alpha_module.o) + 0x00000000200186f0 alpha_boot + 0x00000000200187f8 alpha_autoload + .text 0x0000000020018828 0x68 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(time.o) + 0x0000000020018828 time + .text 0x0000000020018890 0xb0 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(delay.o) + 0x0000000020018890 delay + .text 0x0000000020018940 0x120 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(reboot.o) + 0x0000000020018940 reboot + 0x00000000200189c8 exit + .text 0x0000000020018a60 0xdd0 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(elf_freebsd.o) + .text 0x0000000020019830 0x120 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(OSFpal.o) + 0x0000000020019830 OSFpal + .text 0x0000000020019950 0x1c8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(getsecs.o) + 0x0000000020019950 getsecs + .text 0x0000000020019b18 0xcc /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(pal.o) + 0x0000000020019b20 alpha_mb + 0x0000000020019b94 alpha_pal_tbi + 0x0000000020019bcc alpha_pal_wrmces + 0x0000000020019bd4 alpha_pal_wrval + 0x0000000020019bc4 alpha_pal_wrvptptr + 0x0000000020019b40 alpha_pal_imb + 0x0000000020019bb4 alpha_pal_wripir + 0x0000000020019bbc alpha_pal_wrusp + 0x0000000020019b7c alpha_pal_rdval + 0x0000000020019bdc alpha_pal_swpctx + 0x0000000020019b48 alpha_pal_cflush + 0x0000000020019b8c _alpha_pal_swpipl + 0x0000000020019b18 alpha_rpcc + 0x0000000020019b30 alpha_amask + 0x0000000020019b58 alpha_pal_halt + 0x0000000020019ba4 alpha_pal_wrent + 0x0000000020019b74 alpha_pal_rdusp + 0x0000000020019b6c alpha_pal_rdps + 0x0000000020019b38 alpha_implver + 0x0000000020019b64 alpha_pal_rdmces + 0x0000000020019b84 alpha_pal_swpipl + 0x0000000020019b9c alpha_pal_whami + 0x0000000020019b28 alpha_wmb + 0x0000000020019b50 alpha_pal_draina + 0x0000000020019bac alpha_pal_wrfen + *fill* 0x0000000020019be4 0xc 1207895071 + .text 0x0000000020019bf0 0xc0 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(prom_swpal.o) + 0x0000000020019bf0 switch_palcode + .text 0x0000000020019cb0 0x4e8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(prom.o) + 0x0000000020019cb0 init_prom_calls + 0x000000002001a020 prom_getenv + 0x0000000020019dd8 prom_putchar + 0x0000000020019e80 prom_getchar + 0x000000002001a100 prom_open + *fill* 0x000000002001a198 0x8 1207895071 + .text 0x000000002001a1a0 0x70 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(prom_disp.o) + 0x000000002001a1a0 prom_dispatch + .text 0x000000002001a210 0xe0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(lseek.o) + 0x000000002001a210 lseek + .text 0x000000002001a2f0 0x18 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(dev.o) + 0x000000002001a2f0 nodev + 0x000000002001a300 noioctl + 0x000000002001a2f8 nullsys + *fill* 0x000000002001a308 0x18 1207895071 + .text 0x000000002001a320 0x80 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(closeall.o) + 0x000000002001a320 closeall + .text 0x000000002001a3a0 0xa0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strncmp.o) + 0x000000002001a3a0 strncmp + .text 0x000000002001a440 0x80 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcpy.o) + 0x000000002001a440 strcpy + *(.gnu.warning) + *(.gnu.linkonce.t*) + 0x000000002001a4c0 _etext=. + 0x000000002001a4c0 PROVIDE (etext, .) + +.fini + *(.fini) + +.rodata 0x000000002001a4c0 0x17c0 + *(.rodata) + .rodata 0x000000002001a4c0 0x128 main.o + .rodata 0x000000002001a5e8 0x188 boot.o + .rodata 0x000000002001a770 0x168 commands.o + .rodata 0x000000002001a8d8 0x30 console.o + .rodata 0x000000002001a908 0xa0 interp.o + .rodata 0x000000002001a9a8 0xa8 ls.o + .rodata 0x000000002001aa50 0x18 misc.o + .rodata 0x000000002001aa68 0xb8 module.o + .rodata 0x000000002001ab20 0x28 panic.o + .rodata 0x000000002001ab48 0x8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ufs.o) + .rodata 0x000000002001ab50 0xa8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(pager.o) + .rodata 0x000000002001abf8 0x48 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) + .rodata 0x000000002001ac40 0x8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(environment.o) + .rodata 0x000000002001ac48 0x8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strtol.o) + .rodata 0x000000002001ac50 0x2a0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strerror.o) + .rodata 0x000000002001aef0 0xc0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) + .rodata 0x000000002001afb0 0xb8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inflate.o) + .rodata 0x000000002001b068 0xf8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infblock.o) + .rodata 0x000000002001b160 0x8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(adler32.o) + .rodata 0x000000002001b168 0x8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(twiddle.o) + .rodata 0x000000002001b170 0xa0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zutil.o) + .rodata 0x000000002001b210 0x318 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inftrees.o) + 0x000000002001b210 inflate_copyright + .rodata 0x000000002001b528 0x60 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infcodes.o) + .rodata 0x000000002001b588 0x60 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(alloc.o) + .rodata 0x000000002001b5e8 0x38 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inffast.o) + .rodata 0x000000002001b620 0x170 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(printf.o) + .rodata 0x000000002001b790 0x130 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcd.o) + 0x000000002001b898 hex2ascii_data + 0x000000002001b790 bcd2bin_data + 0x000000002001b830 bin2bcd_data + .rodata 0x000000002001b8c0 0x120 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(srmdisk.o) + .rodata 0x000000002001b9e0 0x40 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(devicename.o) + .rodata 0x000000002001ba20 0x8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(delay.o) + .rodata 0x000000002001ba28 0x198 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(elf_freebsd.o) + .rodata 0x000000002001bbc0 0x98 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(OSFpal.o) + .rodata 0x000000002001bc58 0x8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(getsecs.o) + .rodata 0x000000002001bc60 0x20 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(prom.o) + *(.gnu.linkonce.r*) + +.rodata1 + *(.rodata1) + +.reginfo + *(.reginfo) + 0x000000002001bc80 .=. + +.data 0x000000002001bc80 0x698 + *(.data) + .data 0x000000002001bc80 0x48 main.o + .data 0x000000002001bcc8 0x48 conf.o + 0x000000002001bcf0 module_formats + 0x000000002001bcd8 file_system + 0x000000002001bd00 consoles + 0x000000002001bcc8 devsw + .data 0x000000002001bd10 0x40 boot.o + .data 0x000000002001bd50 0x90 commands.o + .data 0x000000002001bde0 0x18 interp.o + .data 0x000000002001bdf8 0x28 ls.o + .data 0x000000002001be20 0x40 module.o + 0x000000002001be28 loaded_modules + .data 0x000000002001be60 0x68 vers.o + 0x000000002001be80 bootprog_rev + 0x000000002001be88 bootprog_date + 0x000000002001bea8 bootprog_maker + 0x000000002001be60 bootprog_name + .data 0x000000002001bec8 0x38 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ufs.o) + 0x000000002001bec8 ufs_fsops + .data 0x000000002001bf00 0x18 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(pager.o) + .data 0x000000002001bf18 0x10 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) + 0x000000002001bf18 opterr + 0x000000002001bf1c optind + .data 0x000000002001bf28 0x8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(environment.o) + 0x000000002001bf28 environ + .data 0x000000002001bf30 0x1d0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strerror.o) + .data 0x000000002001c100 0x40 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) + 0x000000002001c100 zipfs_fsops + .data 0x000000002001c140 0x50 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zutil.o) + 0x000000002001c140 z_errmsg + .data 0x000000002001c190 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inftrees.o) + *fill* 0x000000002001c194 0x4 + .data 0x000000002001c198 0x8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(alloc.o) + 0x000000002001c198 freelist + .data 0x000000002001c1a0 0x44 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infutil.o) + 0x000000002001c1a0 inflate_mask + *fill* 0x000000002001c1e4 0x4 + .data 0x000000002001c1e8 0x90 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) + 0x000000002001c1f0 rootpath + 0x000000002001c270 netmask + 0x000000002001c1e8 bcea + .data 0x000000002001c278 0x40 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(srmdisk.o) + 0x000000002001c278 srmdisk + .data 0x000000002001c2b8 0x18 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(elf_freebsd.o) + 0x000000002001c2b8 alpha_elf + .data 0x000000002001c2d0 0x48 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(prom.o) + 0x000000002001c2d0 promconsole + *(.gnu.linkonce.d*) + +.set.Xcommand_set + 0x000000002001c318 0x88 + .set.Xcommand_set + 0x000000002001c318 0x8 setdef0.o + 0x000000002001c318 Xcommand_set + .set.Xcommand_set + 0x000000002001c320 0x18 main.o + .set.Xcommand_set + 0x000000002001c338 0x10 boot.o + .set.Xcommand_set + 0x000000002001c348 0x30 commands.o + .set.Xcommand_set + 0x000000002001c378 0x8 interp.o + .set.Xcommand_set + 0x000000002001c380 0x8 ls.o + .set.Xcommand_set + 0x000000002001c388 0x10 module.o + .set.Xcommand_set + 0x000000002001c398 0x8 setdef1.o + +.data1 + *(.data1) + +.ctors + *(.ctors) + +.dtors + *(.dtors) + +.plt + *(.plt) + +.got 0x000000002001c3a0 0xaa8 + *(.got.plt) + *(.got) + .got 0x000000002001c3a0 0xaa8 start.o + +.dynamic + *(.dynamic) + +.sdata + *(.sdata) + 0x000000002001ce48 _edata=. + 0x000000002001ce48 PROVIDE (edata, .) + 0x000000002001ce48 __bss_start=. + +.sbss + *(.sbss) + *(.scommon) + +.bss 0x000000002001ce50 0x2b50 + *(.dynbss) + *(.bss) + .bss 0x000000002001ce50 0xb0 interp.o + .bss 0x000000002001cf00 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(pager.o) + .bss 0x000000002001cf04 0x20 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strerror.o) + *fill* 0x000000002001cf24 0x4 + .bss 0x000000002001cf28 0x8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) + .bss 0x000000002001cf30 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(twiddle.o) + *fill* 0x000000002001cf34 0x4 + .bss 0x000000002001cf38 0x1a98 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inftrees.o) + .bss 0x000000002001e9d0 0x18 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(alloc.o) + .bss 0x000000002001e9e8 0x17 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(printf.o) + *fill* 0x000000002001e9ff 0x1 + .bss 0x000000002001ea00 0x934 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(srmdisk.o) + .bss 0x000000002001f334 0x80 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(devicename.o) + *fill* 0x000000002001f3b4 0x4 + .bss 0x000000002001f3b8 0x100 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(elf_freebsd.o) + .bss 0x000000002001f4b8 0x18 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(getsecs.o) + *(COMMON) + COMMON 0x000000002001f4d0 0x30 main.o + 0x000000002001f4d0 archsw + 0x000000002001f4e8 currdev + COMMON 0x000000002001f500 0x110 commands.o + 0x000000002001f500 command_errmsg + 0x000000002001f510 command_errbuf + COMMON 0x000000002001f610 0x10 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) + 0x000000002001f610 optarg + 0x000000002001f618 optreset + 0x000000002001f61c optopt + COMMON 0x000000002001f620 0x180 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(open.o) + 0x000000002001f620 files + COMMON 0x000000002001f7a0 0x1c4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) + 0x000000002001f7a0 domainname + 0x000000002001f820 nameip + 0x000000002001f824 hostnamelen + 0x000000002001f828 errno + 0x000000002001f82c swapip + 0x000000002001f830 rootip + 0x000000002001f834 myip + 0x000000002001f840 hostname + 0x000000002001f8c0 bootfile + 0x000000002001f940 gateip + 0x000000002001f950 ifname + 0x000000002001f960 domainnamelen + *fill* 0x000000002001f964 0x4 + COMMON 0x000000002001f968 0x20 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(elf_freebsd.o) + 0x000000002001f968 ffp_save + 0x000000002001f970 ssym + 0x000000002001f978 ptbr_save + 0x000000002001f980 esym + COMMON 0x000000002001f988 0x4 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(prom.o) + 0x000000002001f988 console + *fill* 0x000000002001f98c 0x4 + COMMON 0x000000002001f990 0x10 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(prom_disp.o) + 0x000000002001f990 prom_dispatch_v + 0x000000002001f9a0 _end=. + 0x000000002001f9a0 PROVIDE (end, .) + +.stab + *(.stab) + +.stabstr + *(.stabstr) + +.stab.excl + *(.stab.excl) + +.stab.exclstr + *(.stab.exclstr) + +.stab.index + *(.stab.index) + +.stab.indexstr + *(.stab.indexstr) + +.comment 0x0000000000000000 0x4ec + *(.comment) + .comment 0x0000000000000000 0x14 setdef0.o + .comment 0x0000000000000014 0x14 main.o + .comment 0x0000000000000028 0x14 conf.o + .comment 0x000000000000003c 0x14 boot.o + .comment 0x0000000000000050 0x14 commands.o + .comment 0x0000000000000064 0x14 console.o + .comment 0x0000000000000078 0x14 devopen.o + .comment 0x000000000000008c 0x14 interp.o + .comment 0x00000000000000a0 0x14 ls.o + .comment 0x00000000000000b4 0x14 misc.o + .comment 0x00000000000000c8 0x14 module.o + .comment 0x00000000000000dc 0x14 panic.o + .comment 0x00000000000000f0 0x14 setdef1.o + .comment 0x0000000000000104 0x14 vers.o + .comment 0x0000000000000118 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ufs.o) + .comment 0x000000000000012c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(stat.o) + .comment 0x0000000000000140 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strncpy.o) + .comment 0x0000000000000154 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcat.o) + .comment 0x0000000000000168 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(pager.o) + .comment 0x000000000000017c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) + .comment 0x0000000000000190 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(environment.o) + .comment 0x00000000000001a4 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strtol.o) + .comment 0x00000000000001b8 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strchr.o) + .comment 0x00000000000001cc 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strerror.o) + .comment 0x00000000000001e0 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strdup.o) + .comment 0x00000000000001f4 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(gets.o) + .comment 0x0000000000000208 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) + .comment 0x000000000000021c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(read.o) + .comment 0x0000000000000230 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(open.o) + .comment 0x0000000000000244 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(close.o) + .comment 0x0000000000000258 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(fstat.o) + .comment 0x000000000000026c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nullfs.o) + .comment 0x0000000000000280 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inflate.o) + .comment 0x0000000000000294 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infblock.o) + .comment 0x00000000000002a8 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(adler32.o) + .comment 0x00000000000002bc 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strrchr.o) + .comment 0x00000000000002d0 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcmp.o) + .comment 0x00000000000002e4 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(twiddle.o) + .comment 0x00000000000002f8 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zutil.o) + .comment 0x000000000000030c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inftrees.o) + .comment 0x0000000000000320 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infcodes.o) + .comment 0x0000000000000334 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(alloc.o) + .comment 0x0000000000000348 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inffast.o) + .comment 0x000000000000035c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infutil.o) + .comment 0x0000000000000370 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) + .comment 0x0000000000000384 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(printf.o) + .comment 0x0000000000000398 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strlen.o) + .comment 0x00000000000003ac 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcd.o) + .comment 0x00000000000003c0 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(srmdisk.o) + .comment 0x00000000000003d4 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(devicename.o) + .comment 0x00000000000003e8 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(alpha_module.o) + .comment 0x00000000000003fc 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(time.o) + .comment 0x0000000000000410 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(delay.o) + .comment 0x0000000000000424 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(reboot.o) + .comment 0x0000000000000438 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(elf_freebsd.o) + .comment 0x000000000000044c 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(OSFpal.o) + .comment 0x0000000000000460 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(getsecs.o) + .comment 0x0000000000000474 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(prom.o) + .comment 0x0000000000000488 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(lseek.o) + .comment 0x000000000000049c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(dev.o) + .comment 0x00000000000004b0 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(closeall.o) + .comment 0x00000000000004c4 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strncmp.o) + .comment 0x00000000000004d8 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcpy.o) + +.debug + *(.debug) + +.line + *(.line) + +.debug_srcinfo + *(.debug_srcinfo) + +.debug_sfnames + *(.debug_sfnames) + +.debug_aranges + *(.debug_aranges) + +.debug_pubnames + *(.debug_pubnames) + +.debug_info + *(.debug_info) + +.debug_abbrev + *(.debug_abbrev) + +.debug_line + *(.debug_line) + +.debug_frame + *(.debug_frame) + +.debug_str + *(.debug_str) + +.debug_loc + *(.debug_loc) + +.debug_macinfo + *(.debug_macinfo) + +.debug_weaknames + *(.debug_weaknames) + +.debug_funcnames + *(.debug_funcnames) + +.debug_typenames + *(.debug_typenames) + +.debug_varnames + *(.debug_varnames) +OUTPUT(boot2.sym elf64-alpha) + +.mdebug 0x00000000000004f0 0xdb50 + .mdebug 0x00000000000004f0 0x850 start.o + .mdebug 0x0000000000000d40 0x1e0 setdef0.o + .mdebug 0x0000000000000f20 0xab8 main.o + .mdebug 0x00000000000019d8 0x2e8 conf.o + .mdebug 0x0000000000001cc0 0x8c0 boot.o + .mdebug 0x0000000000002580 0xb00 commands.o + .mdebug 0x0000000000003080 0x788 console.o + .mdebug 0x0000000000003808 0x3d0 devopen.o + .mdebug 0x0000000000003bd8 0x968 interp.o + .mdebug 0x0000000000004540 0x540 ls.o + .mdebug 0x0000000000004a80 0x330 misc.o + .mdebug 0x0000000000004db0 0x790 module.o + .mdebug 0x0000000000005540 0x310 panic.o + .mdebug 0x0000000000005850 0x1b8 setdef1.o + .mdebug 0x0000000000005a08 0x248 vers.o + .mdebug 0x0000000000005c50 0xc30 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ufs.o) + .mdebug 0x0000000000006880 0x308 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(stat.o) + .mdebug 0x0000000000006b88 0x778 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__reml.o) + .mdebug 0x0000000000007300 0x708 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__remlu.o) + .mdebug 0x0000000000007a08 0x778 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__divl.o) + .mdebug 0x0000000000008180 0x708 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__divlu.o) + .mdebug 0x0000000000008888 0x288 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strncpy.o) + .mdebug 0x0000000000008b10 0x288 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcat.o) + .mdebug 0x0000000000008d98 0x7a0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(pager.o) + .mdebug 0x0000000000009538 0x3d0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) + .mdebug 0x0000000000009908 0xa30 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(environment.o) + .mdebug 0x000000000000a338 0x318 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strtol.o) + .mdebug 0x000000000000a650 0x288 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strchr.o) + .mdebug 0x000000000000a8d8 0x350 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strerror.o) + .mdebug 0x000000000000ac28 0x318 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strdup.o) + .mdebug 0x000000000000af40 0x3e0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(gets.o) + .mdebug 0x000000000000b320 0xc28 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) + .mdebug 0x000000000000bf48 0x308 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(read.o) + .mdebug 0x000000000000c250 0x430 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(open.o) + .mdebug 0x000000000000c680 0x310 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(close.o) + .mdebug 0x000000000000c990 0x2f0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(fstat.o) + .mdebug 0x000000000000cc80 0x720 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nullfs.o) + .mdebug 0x000000000000d3a0 0xac8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inflate.o) + .mdebug 0x000000000000de68 0x9a0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infblock.o) + .mdebug 0x000000000000e808 0x2c0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(adler32.o) + .mdebug 0x000000000000eac8 0x288 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strrchr.o) + .mdebug 0x000000000000ed50 0x288 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcmp.o) + .mdebug 0x000000000000efd8 0x318 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(twiddle.o) + .mdebug 0x000000000000f2f0 0x590 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zutil.o) + .mdebug 0x000000000000f880 0x830 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inftrees.o) + .mdebug 0x00000000000100b0 0x538 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infcodes.o) + .mdebug 0x00000000000105e8 0x618 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(alloc.o) + .mdebug 0x0000000000010c00 0x2f8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inffast.o) + .mdebug 0x0000000000010ef8 0x320 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infutil.o) + .mdebug 0x0000000000011218 0xbc0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcopy.o) + .mdebug 0x0000000000011dd8 0x3a0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) + .mdebug 0x0000000000012178 0x828 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bzero.o) + .mdebug 0x00000000000129a0 0x6e0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(printf.o) + .mdebug 0x0000000000013080 0x708 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__remqu.o) + .mdebug 0x0000000000013788 0x700 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__divqu.o) + .mdebug 0x0000000000013e88 0x288 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strlen.o) + .mdebug 0x0000000000014110 0x228 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcd.o) + .mdebug 0x0000000000014338 0x6d8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(srmdisk.o) + .mdebug 0x0000000000014a10 0x740 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(devicename.o) + .mdebug 0x0000000000015150 0x408 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(alpha_module.o) + .mdebug 0x0000000000015558 0x2d0 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(time.o) + .mdebug 0x0000000000015828 0x2d8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(delay.o) + .mdebug 0x0000000000015b00 0x3a0 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(reboot.o) + .mdebug 0x0000000000015ea0 0x770 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(elf_freebsd.o) + .mdebug 0x0000000000016610 0x320 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(OSFpal.o) + .mdebug 0x0000000000016930 0x3b8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(getsecs.o) + .mdebug 0x0000000000016ce8 0x18b8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(pal.o) + .mdebug 0x00000000000185a0 0xae0 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(prom_swpal.o) + .mdebug 0x0000000000019080 0x9b8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(prom.o) + .mdebug 0x0000000000019a38 0xaa0 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(prom_disp.o) + .mdebug 0x000000000001a4d8 0x2f0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(lseek.o) + .mdebug 0x000000000001a7c8 0x418 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(dev.o) + .mdebug 0x000000000001abe0 0x2f8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(closeall.o) + .mdebug 0x000000000001aed8 0x288 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strncmp.o) + .mdebug 0x000000000001b160 0x288 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcpy.o) + +.note 0x000000000001b3e8 0x4ec + .note 0x000000000001b3e8 0x14 setdef0.o + .note 0x000000000001b3fc 0x14 main.o + .note 0x000000000001b410 0x14 conf.o + .note 0x000000000001b424 0x14 boot.o + .note 0x000000000001b438 0x14 commands.o + .note 0x000000000001b44c 0x14 console.o + .note 0x000000000001b460 0x14 devopen.o + .note 0x000000000001b474 0x14 interp.o + .note 0x000000000001b488 0x14 ls.o + .note 0x000000000001b49c 0x14 misc.o + .note 0x000000000001b4b0 0x14 module.o + .note 0x000000000001b4c4 0x14 panic.o + .note 0x000000000001b4d8 0x14 setdef1.o + .note 0x000000000001b4ec 0x14 vers.o + .note 0x000000000001b500 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ufs.o) + .note 0x000000000001b514 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(stat.o) + .note 0x000000000001b528 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strncpy.o) + .note 0x000000000001b53c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcat.o) + .note 0x000000000001b550 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(pager.o) + .note 0x000000000001b564 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) + .note 0x000000000001b578 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(environment.o) + .note 0x000000000001b58c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strtol.o) + .note 0x000000000001b5a0 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strchr.o) + .note 0x000000000001b5b4 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strerror.o) + .note 0x000000000001b5c8 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strdup.o) + .note 0x000000000001b5dc 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(gets.o) + .note 0x000000000001b5f0 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) + .note 0x000000000001b604 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(read.o) + .note 0x000000000001b618 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(open.o) + .note 0x000000000001b62c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(close.o) + .note 0x000000000001b640 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(fstat.o) + .note 0x000000000001b654 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nullfs.o) + .note 0x000000000001b668 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inflate.o) + .note 0x000000000001b67c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infblock.o) + .note 0x000000000001b690 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(adler32.o) + .note 0x000000000001b6a4 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strrchr.o) + .note 0x000000000001b6b8 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcmp.o) + .note 0x000000000001b6cc 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(twiddle.o) + .note 0x000000000001b6e0 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zutil.o) + .note 0x000000000001b6f4 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inftrees.o) + .note 0x000000000001b708 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infcodes.o) + .note 0x000000000001b71c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(alloc.o) + .note 0x000000000001b730 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inffast.o) + .note 0x000000000001b744 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infutil.o) + .note 0x000000000001b758 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) + .note 0x000000000001b76c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(printf.o) + .note 0x000000000001b780 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strlen.o) + .note 0x000000000001b794 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcd.o) + .note 0x000000000001b7a8 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(srmdisk.o) + .note 0x000000000001b7bc 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(devicename.o) + .note 0x000000000001b7d0 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(alpha_module.o) + .note 0x000000000001b7e4 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(time.o) + .note 0x000000000001b7f8 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(delay.o) + .note 0x000000000001b80c 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(reboot.o) + .note 0x000000000001b820 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(elf_freebsd.o) + .note 0x000000000001b834 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(OSFpal.o) + .note 0x000000000001b848 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(getsecs.o) + .note 0x000000000001b85c 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/boot2/../libalpha/obj/libalpha.a(prom.o) + .note 0x000000000001b870 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(lseek.o) + .note 0x000000000001b884 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(dev.o) + .note 0x000000000001b898 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(closeall.o) + .note 0x000000000001b8ac 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strncmp.o) + .note 0x000000000001b8c0 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcpy.o) Property changes on: cvs2svn/tags/initial/sys/boot/alpha/boot2/boot2.list ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/boot2/conf.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/boot2/conf.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/boot2/conf.c (revision 49189) @@ -0,0 +1,83 @@ +/* + * $Id$ + * From $NetBSD: conf.c,v 1.2 1997/03/22 09:03:29 thorpej Exp $ + */ + +/* + * Copyright (c) 1997 + * 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. + */ + + +#include +#include "libalpha/libalpha.h" + +/* + * We could use linker sets for some or all of these, but + * then we would have to control what ended up linked into + * the bootstrap. So it's easier to conditionalise things + * here. + * + * XXX rename these arrays to be consistent and less namespace-hostile + */ + +/* Exported for libstand */ +struct devsw *devsw[] = { + &srmdisk, + NULL +}; + +struct fs_ops *file_system[] = { + &ufs_fsops, + &zipfs_fsops, + NULL +}; + +/* Exported for alpha only */ +/* + * Sort formats so that those that can detect based on arguments + * rather than reading the file go first. + */ +struct module_format *module_formats[] = { + &alpha_elf, + NULL +}; + +/* + * Consoles + * + * We don't prototype these in libalpha.h because they require + * data structures from bootstrap.h as well. + */ +extern struct console promconsole; + +struct console *consoles[] = { + &promconsole, + NULL +}; Property changes on: cvs2svn/tags/initial/sys/boot/alpha/boot2/conf.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/boot2/newvers.sh =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/boot2/newvers.sh (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/boot2/newvers.sh (revision 49189) @@ -0,0 +1,44 @@ +#!/bin/sh - +# +# $NetBSD: newvers.sh,v 1.1 1997/07/26 01:50:38 thorpej Exp $ +# +# Copyright (c) 1984, 1986, 1990, 1993 +# The Regents of the University of California. 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 by the University of +# California, Berkeley and its contributors. +# 4. Neither the name of the University nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. +# +# @(#)newvers.sh 8.1 (Berkeley) 4/20/94 + +u=${USER-root} h=`hostname` t=`date` +r=`head -n 6 $1 | tail -n 1 | awk -F: ' { print $1 } '` + +echo "char bootprog_name[] = \"FreeBSD/alpha ${2}\";" > vers.c +echo "char bootprog_rev[] = \"${r}\";" >> vers.c +echo "char bootprog_date[] = \"${t}\";" >> vers.c +echo "char bootprog_maker[] = \"${u}@${h}\";" >> vers.c Property changes on: cvs2svn/tags/initial/sys/boot/alpha/boot2/newvers.sh ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/boot2/setdefs.h =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/boot2/setdefs.h (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/boot2/setdefs.h (revision 49189) @@ -0,0 +1,2 @@ +/* $Id$ */ +DEFINE_SET(Xcommand_set, 15); Property changes on: cvs2svn/tags/initial/sys/boot/alpha/boot2/setdefs.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/boot2/vers.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/boot2/vers.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/boot2/vers.c (revision 49189) @@ -0,0 +1,4 @@ +char bootprog_name[] = "FreeBSD/alpha SRM disk boot"; +char bootprog_rev[] = "0.1"; +char bootprog_date[] = "Mon Aug 17 10:38:19 BST 1998"; +char bootprog_maker[] = "dfr@salmon.nlsystems.com"; Property changes on: cvs2svn/tags/initial/sys/boot/alpha/boot2/vers.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/boot2/version =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/boot2/version (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/boot2/version (revision 49189) @@ -0,0 +1,7 @@ +$Id$ + +NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this +file is important. Make sure the current version number is on line 6. + +0.1: Initial i386 version, germinated from the NetBSD i386 + standalone, but enormously modified. Property changes on: cvs2svn/tags/initial/sys/boot/alpha/boot2/version ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/common/gensetdefs.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/common/gensetdefs.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/common/gensetdefs.c (revision 49189) @@ -0,0 +1,313 @@ +/*- + * Copyright (c) 1997 John D. Polstra. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: gensetdefs.c,v 1.2 1998/06/14 13:44:44 dfr Exp $ + */ + +#include +#include + +#include +#include +#include +#include +#include + +#define HASHSIZE 1009u /* Number of hash chains. */ +#define PREFIX ".set." /* Section name prefix for linker sets. */ + +/* One entry in the hash table. */ +typedef struct hashent { + struct hashent *next; /* Next entry with the same hash. */ + char *name; /* Name of the linker set. */ + size_t size; /* Size in bytes. */ +} hashent; + +/* Allocate storage for "count" objects of type "type". */ +#define NEW(type, count) ((type *) xmalloc((count) * sizeof(type))) + +static hashent *hashtab[HASHSIZE]; /* Hash chain heads. */ + +static void enter(const char *, size_t); +static int enter_sets(const char *); +static unsigned int hash(const char *); +static hashent *merge(void); +static int my_byte_order(void); +static void *xmalloc(size_t); +static char *xstrdup(const char *); + +/* + * This is a special-purpose program to generate the linker set definitions + * needed when building an ELF kernel. Its arguments are the names of + * ELF object files. It scans the section names of the object files, + * building a table of those that begin with ".set.", which represent + * linker sets. Finally, for each set "foo" with "count" elements, it + * writes a line "DEFINE_SET(foo, count);" to the standard output. + */ +int +main(int argc, char **argv) +{ + int i; + int status = EXIT_SUCCESS; + hashent *list; + + for (i = 1; i < argc; i++) + if (enter_sets(argv[i]) == -1) + status = EXIT_FAILURE; + + list = merge(); + while (list != NULL) { + hashent *next; + + printf("DEFINE_SET(%s, %lu);\n", list->name, + (unsigned long) (list->size / sizeof (void *))); + next = list->next; + free(list->name); + free(list); + list = next; + } + + return (status); +} + +/* + * Enter the given string into the hash table, if it is not already there. + * Each hash chain is kept sorted, so that it will be easy to merge the + * chains to get a single sorted list. + */ +static void +enter(const char *name, size_t size) +{ + int c = 0; + hashent *entp; + hashent **linkp; + hashent *newp; + + linkp = &hashtab[hash(name) % HASHSIZE]; + while ((entp = *linkp) != NULL && (c = strcmp(name, entp->name)) > 0) + linkp = &entp->next; + + if (entp == NULL || c != 0) { /* Not found; create a new entry. */ + newp = NEW(hashent, 1); + newp->name = xstrdup(name); + newp->size = 0; + newp->next = entp; + *linkp = newp; + entp = newp; + } + + entp->size += size; +} + +/* + * Return a hash value for the given string. + */ +static unsigned int +hash(const char *s) +{ + unsigned char ch; + unsigned int h = 0; + + while((ch = *s) != '\0') { + h = 9*h + ch; + s++; + } + return (h); +} + +/* + * Enter the linker sets from the given ELF object file. Returns 0 on + * success, or -1 if an error occurred. + */ +static int +enter_sets(const char *filename) +{ + int i; + FILE *iop; + Elf64_Shdr *shdr; + char *shstr; + Elf64_Ehdr ehdr; + + if ((iop = fopen(filename, "rb")) == NULL) { + warn("%s", filename); + return (-1); + } + if (fread(&ehdr, sizeof ehdr, 1, iop) != 1 || + ehdr.e_ident[EI_MAG0] != ELFMAG0 || + ehdr.e_ident[EI_MAG1] != ELFMAG1 || + ehdr.e_ident[EI_MAG2] != ELFMAG2 || + ehdr.e_ident[EI_MAG3] != ELFMAG3) { + warnx("%s: not an ELF file", filename); + fclose(iop); + return (-1); + } + if (ehdr.e_ident[EI_VERSION] != EV_CURRENT) { + warnx("%s: unsupported ELF version", filename); + fclose(iop); + return (-1); + } + if (ehdr.e_ident[EI_DATA] != my_byte_order()) { + warnx("%s: unsupported byte order", filename); + fclose(iop); + return (-1); + } + if (ehdr.e_shoff == 0) { + warnx("%s: no section table", filename); + fclose(iop); + return (-1); + } + if (ehdr.e_shstrndx == SHN_UNDEF) { + warnx("%s: no section name string table", filename); + fclose(iop); + return (-1); + } + + shdr = NEW(Elf64_Shdr, ehdr.e_shnum); + if (fseek(iop, ehdr.e_shoff, SEEK_SET) == -1) { + warn("%s", filename); + free(shdr); + fclose(iop); + return (-1); + } + if (fread(shdr, sizeof *shdr, ehdr.e_shnum, iop) != ehdr.e_shnum) { + warnx("%s: truncated section table", filename); + free(shdr); + fclose(iop); + return (-1); + } + + shstr = NEW(char, shdr[ehdr.e_shstrndx].sh_size); + if (fseek(iop, shdr[ehdr.e_shstrndx].sh_offset, SEEK_SET) == -1) { + warn("%s", filename); + free(shstr); + free(shdr); + fclose(iop); + return (-1); + } + if (fread(shstr, sizeof *shstr, shdr[ehdr.e_shstrndx].sh_size, iop) != + shdr[ehdr.e_shstrndx].sh_size) { + warnx("%s: truncated section name string table", filename); + free(shstr); + free(shdr); + fclose(iop); + return (-1); + } + + for (i = 1; i < ehdr.e_shnum; i++) { + const char *name = shstr + shdr[i].sh_name; + + if (strncmp(name, PREFIX, sizeof (PREFIX) - 1) == 0) + enter(name + sizeof (PREFIX) - 1, shdr[i].sh_size); + } + + free(shstr); + free(shdr); + fclose(iop); + return (0); +} + +/* + * Destructively merge all the sorted hash chains into a single sorted + * list, and return a pointer to its first element. + */ +static hashent * +merge(void) +{ + unsigned int numchains = HASHSIZE; + + while (numchains > 1) { /* More merging to do. */ + unsigned int lo = 0; + /* + * Merge chains pairwise from the outside in, halving the + * number of chains. + */ + while (numchains - lo >= 2) { + hashent **linkp = &hashtab[lo]; + hashent *l1 = hashtab[lo++]; + hashent *l2 = hashtab[--numchains]; + + while (l1 != NULL && l2 != NULL) { + if (strcmp(l1->name, l2->name) < 0) { + *linkp = l1; + linkp = &l1->next; + l1 = l1->next; + } else { + *linkp = l2; + linkp = &l2->next; + l2 = l2->next; + } + } + *linkp = l1==NULL ? l2 : l1; + } + } + + return (hashtab[0]); +} + +/* + * Determine the host byte order. + */ +static int +my_byte_order(void) +{ + static unsigned short s = 0xbbaa; + int byte0; + + byte0 = *(unsigned char *)&s; + if (byte0 == 0xaa) + return (ELFDATA2LSB); + else if (byte0 == 0xbb) + return (ELFDATA2MSB); + else + return (ELFDATANONE); +} + +/* + * Allocate a chunk of memory and return a pointer to it. Die if the + * malloc fails. + */ +static void * +xmalloc(size_t size) +{ + void *p; + + p = malloc(size); + if (p == NULL) + err(EXIT_FAILURE, "malloc"); + return (p); +} + +/* + * Duplicate a string and return a pointer to the copy. Die if there is + * not enough memory. + */ +static char * +xstrdup(const char *s) +{ + int size; + + size = strlen(s) + 1; + return (memcpy(xmalloc(size), s, size)); +} Property changes on: cvs2svn/tags/initial/sys/boot/alpha/common/gensetdefs.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/common/main.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/common/main.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/common/main.c (revision 49189) @@ -0,0 +1,178 @@ +/*- + * Copyright (c) 1998 Michael Smith + * Copyright (c) 1998 Doug Rabson + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + + +#include +#include + +#include +#include +#include +#include "bootstrap.h" +#include "libalpha/libalpha.h" + +extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; + +struct alpha_devdesc currdev; /* our current device */ +struct arch_switch archsw; /* MI/MD interface boundary */ + +extern char end[]; +extern void OSFpal(void); +extern void halt(void); + +unsigned long +memsize() +{ + struct rpb *hwrpb = (struct rpb *)HWRPB_ADDR; + struct mddt *mddtp; + struct mddt_cluster *memc; + int i; + unsigned long total = 0; + + mddtp = (struct mddt *)(((caddr_t)hwrpb) + hwrpb->rpb_memdat_off); + for (i = 0; i < mddtp->mddt_cluster_cnt; i++) { + memc = &mddtp->mddt_clusters[i]; + total += memc->mddt_pg_cnt << PAGE_SHIFT; + } + return total; +} + +void +main(void) +{ + int i; + char bootfile[128]; + + /* + * Initialise the heap as early as possible. Once this is done, alloc() is usable. + * The stack is buried inside us, so this is safe + */ + setheap((void *)end, (void *)0x20040000); + + + /* + * XXX Chicken-and-egg problem; we want to have console output early, but some + * console attributes may depend on reading from eg. the boot device, which we + * can't do yet. + * + * We can use printf() etc. once this is done. + */ + cons_probe(); + + /* switch to OSF pal code. */ + OSFpal(); + + /* + * March through the device switch probing for things. + */ + for (i = 0; devsw[i] != NULL; i++) + if (devsw[i]->dv_init != NULL) + (devsw[i]->dv_init)(); + + printf("\n"); + printf(">> %s, Revision %s\n", bootprog_name, bootprog_rev); + printf(">> (%s, %s)\n", bootprog_maker, bootprog_date); + printf(">> Memory: %ld k\n", memsize() / 1024); + + /* We're booting from an SRM disk, try to spiff this */ + currdev.d_dev = devsw[0]; /* XXX presumes that biosdisk is first in devsw */ + currdev.d_type = currdev.d_dev->dv_type; + currdev.d_kind.srmdisk.unit = 0; + currdev.d_kind.srmdisk.slice = -1; /* XXX should be able to detect this, default to autoprobe */ + currdev.d_kind.srmdisk.partition = 0; /* default to 'a' */ + + /* Create alpha-specific variables */ + prom_getenv(PROM_E_BOOTED_FILE, bootfile, sizeof(bootfile)); + if (bootfile[0]) + setenv("bootfile", bootfile, 1); + env_setenv("currdev", EV_VOLATILE, alpha_fmtdev(&currdev), alpha_setcurrdev, env_nounset); + env_setenv("loaddev", EV_VOLATILE, alpha_fmtdev(&currdev), env_noset, env_nounset); + setenv("LINES", "24", 1); /* optional */ + + archsw.arch_autoload = alpha_autoload; + archsw.arch_boot = alpha_boot; + archsw.arch_getdev = alpha_getdev; + + /* + * XXX should these be in the MI source? + */ + source("/boot/boot.config"); + interact(); /* doesn't return */ +} + +COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); + +static int +command_reboot(int argc, char *argv[]) +{ + + printf("Rebooting...\n"); + delay(1000000); + reboot(); + /* Note: we shouldn't get to this point! */ + panic("Reboot failed!"); + exit(0); +} + +COMMAND_SET(halt, "halt", "halt the system", command_halt); + +static int +command_halt(int argc, char *argv[]) +{ + halt(); /* never returns */ + return(CMD_OK); +} + +#if 0 + +COMMAND_SET(stack, "stack", "show stack usage", command_stack); + +static int +command_stack(int argc, char *argv[]) +{ + char *cp; + + for (cp = &stackbase; cp < &stacktop; cp++) + if (*cp != 0) + break; + + printf("%d bytes of stack used\n", &stacktop - cp); + return(CMD_OK); +} + +#endif + +COMMAND_SET(heap, "heap", "show heap usage", command_heap); + +static int +command_heap(int argc, char *argv[]) +{ + printf("heap base at %p, top at %p, used %ld\n", end, sbrk(0), sbrk(0) - end); + return(CMD_OK); +} Property changes on: cvs2svn/tags/initial/sys/boot/alpha/common/main.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/common/setdef0.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/common/setdef0.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/common/setdef0.c (revision 49189) @@ -0,0 +1,49 @@ +/*- + * Copyright (c) 1997 John D. Polstra + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: setdef0.c,v 1.1 1998/06/10 10:53:12 dfr Exp $ + */ + +#ifdef __ELF__ + +#include +#include + +/* + * DEFINE_SET creates the section and label for a set, and emits the + * count word at the front of it. + */ +#define DEFINE_SET(set, count) \ + __asm__(".section .set." #set ",\"aw\""); \ + __asm__(".globl " #set); \ + __asm__(".type " #set ",@object"); \ + __asm__(".p2align 3"); \ + __asm__(#set ":"); \ + __asm__(".quad " #count); \ + __asm__(".previous") + +#include "setdefs.h" /* Contains a `DEFINE_SET' for each set */ + +#endif /* __ELF__ */ Property changes on: cvs2svn/tags/initial/sys/boot/alpha/common/setdef0.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/common/setdef1.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/common/setdef1.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/common/setdef1.c (revision 49189) @@ -0,0 +1,41 @@ +/*- + * Copyright (c) 1997 John D. Polstra + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: setdef1.c,v 1.1 1998/06/10 10:53:13 dfr Exp $ + */ + +#ifdef __ELF__ + +/* + * DEFINE_SET emits the NULL terminator for a set. + */ +#define DEFINE_SET(set, count) \ + __asm__(".section .set." #set ",\"aw\""); \ + __asm__(".quad 0"); \ + __asm__(".previous") + +#include "setdefs.h" /* Contains a `DEFINE_SET' for each set */ + +#endif /* __ELF__ */ Property changes on: cvs2svn/tags/initial/sys/boot/alpha/common/setdef1.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/libalpha/Makefile =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/libalpha/Makefile (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/libalpha/Makefile (revision 49189) @@ -0,0 +1,23 @@ +# $Id$ + +LIB= alpha +NOPIC= true +NOPROFILE= true +INTERNALLIB= true + +# XXX hack to pick up stand.h +CFLAGS= -I/home/dfr/FreeBSD/alpha/src/lib/libstand +CFLAGS+= -DDEBUG + +# Pick up the bootstrap header for some interface items +CFLAGS+= -I${.CURDIR}/../../common -mno-fp-regs + +CFLAGS+= -DDISK_DEBUG +#CPPFLAGS+= -DNO_DISKLABEL +#CPPFLAGS+= -DSAVE_MEMORY + +SRCS= OSFpal.c elf_freebsd.c prom.c prom_disp.S prom_swpal.S start.S \ + pal.S reboot.c delay.c time.c alpha_module.c devicename.c \ + srmdisk.c srmnet.c getsecs.c + +.include Property changes on: cvs2svn/tags/initial/sys/boot/alpha/libalpha/Makefile ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/libalpha/OSFpal.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/libalpha/OSFpal.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/libalpha/OSFpal.c (revision 49189) @@ -0,0 +1,71 @@ +/* + * $Id$ + * From $NetBSD: OSFpal.c,v 1.5 1998/06/24 01:33:19 ross Exp $ + */ + +/* + * Copyright (c) 1994, 1996 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Keith Bostic + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include +#include + +#include +#include +#include + +vm_offset_t ptbr_save; + +#include "common.h" + +void +OSFpal() +{ + struct rpb *r; + struct pcs *p; + + r = (struct rpb *)HWRPB_ADDR; + /* + * Note, cpu_number() is a VMS op, can't necessarily call it. + * Real fun: PAL_VMS_mfpr_whami == PAL_OSF1_rti... + * We might not be rpb_primary_cpu_id, but it is supposed to go + * first so the answer should apply to everyone. + */ + p = LOCATE_PCS(r, r->rpb_primary_cpu_id); + + printf("VMS PAL rev: 0x%lx\n", p->pcs_palrevisions[PALvar_OpenVMS]); + printf("OSF PAL rev: 0x%lx\n", p->pcs_palrevisions[PALvar_OSF1]); + + if(p->pcs_pal_type==PAL_TYPE_OSF1) { + printf("OSF PAL code already running.\n"); + ptbr_save = ((struct alpha_pcb *)p)->apcb_ptbr; + printf("PTBR is: 0x%lx\n", ptbr_save); + return; + } + switch_palcode(); + printf("Switch to OSF PAL code succeeded.\n"); +} + Property changes on: cvs2svn/tags/initial/sys/boot/alpha/libalpha/OSFpal.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/libalpha/alpha_module.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/libalpha/alpha_module.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/libalpha/alpha_module.c (revision 49189) @@ -0,0 +1,64 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +/* + * alpha-specific module functionality. + * + */ + +#include +#include + +#include "bootstrap.h" +#include "libalpha.h" + +/* + * Look for a method and having found it, boot the kernel module. + */ +int +alpha_boot(void) +{ + int i; + + for (i = 0; module_formats[i] != NULL; i++) { + if (((loaded_modules->m_flags & MF_FORMATMASK) == module_formats[i]->l_format) && + (module_formats[i]->l_exec != NULL)) { + return((module_formats[i]->l_exec)(loaded_modules)); + } + } +} + +/* + * Use voodoo to load modules required by current hardware. + */ +int +alpha_autoload(void) +{ + /* XXX use PnP to locate stuff here */ + return(0); +} Property changes on: cvs2svn/tags/initial/sys/boot/alpha/libalpha/alpha_module.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/libalpha/bbinfo.h =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/libalpha/bbinfo.h (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/libalpha/bbinfo.h (revision 49189) @@ -0,0 +1,57 @@ +/* + * $Id$ + * From $NetBSD: bbinfo.h,v 1.2 1997/04/06 08:40:57 cgd Exp $ + */ + +/* + * Copyright (c) 1995, 1996 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +struct bbinfoloc { + u_int64_t magic1; + u_int64_t start; + u_int64_t end; + u_int64_t pad1[4]; + u_int64_t magic2; +}; + +struct bbinfo { + int32_t cksum; + int32_t nblocks; + int32_t bsize; + u_int32_t pad1[8]; + int32_t blocks[1]; +}; + +struct netbbinfo { + u_int64_t magic1; + u_int8_t set; + u_int8_t ether_addr[6]; + u_int8_t force; + u_int64_t pad1[4]; + u_int64_t cksum; + u_int64_t magic2; +}; Property changes on: cvs2svn/tags/initial/sys/boot/alpha/libalpha/bbinfo.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/libalpha/common.h =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/libalpha/common.h (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/libalpha/common.h (revision 49189) @@ -0,0 +1,11 @@ +/* + * $Id$ + * From: $NetBSD: common.h,v 1.2 1998/01/05 07:02:48 perry Exp $ + */ + +int prom_open __P((char*, int)); +void OSFpal __P((void)); +void halt __P((void)); +u_int64_t prom_dispatch __P((int, ...)); +int cpu_number __P((void)); +void switch_palcode __P((void)); Property changes on: cvs2svn/tags/initial/sys/boot/alpha/libalpha/common.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/libalpha/delay.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/libalpha/delay.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/libalpha/delay.c (revision 49189) @@ -0,0 +1,40 @@ +/*- + * Copyright (c) 1998 Doug Rabson + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +#include +#include + +void +delay(int usecs) +{ + struct rpb *hwrpb = (struct rpb *)HWRPB_ADDR; + unsigned long start = alpha_rpcc(); + unsigned long end = start + (hwrpb->rpb_cc_freq * usecs) / 1000000; + while (alpha_rpcc() < end) + ; +} Property changes on: cvs2svn/tags/initial/sys/boot/alpha/libalpha/delay.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/libalpha/devicename.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/libalpha/devicename.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/libalpha/devicename.c (revision 49189) @@ -0,0 +1,232 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +#include +#include +#include +#include "bootstrap.h" +#include "libalpha.h" + +static int alpha_parsedev(struct alpha_devdesc **dev, char *devspec, char **path); + +/* + * Point (dev) at an allocated device specifier for the device matching the + * path in (devspec). If it contains an explicit device specification, + * use that. If not, use the default device. + */ +int +alpha_getdev(void **vdev, char *devspec, char **path) +{ + struct alpha_devdesc **dev = (struct alpha_devdesc **)vdev; + int rv; + + /* + * If it looks like this is just a path and no + * device, go with the current device. + */ + if ((devspec == NULL) || + (devspec[0] == '/') || + (strchr(devspec, ':') == NULL)) { + + if (((rv = alpha_parsedev(dev, getenv("currdev"), NULL)) == 0) && + (path != NULL)) + *path = devspec; + return(rv); + } + + /* + * Try to parse the device name off the beginning of the devspec + */ + return(alpha_parsedev(dev, devspec, path)); +} + +/* + * Point (dev) at an allocated device specifier matching the string version + * at the beginning of (devspec). Return a pointer to the remaining + * text in (path). + * + * In all cases, the beginning of (devspec) is compared to the names + * of known devices in the device switch, and then any following text + * is parsed according to the rules applied to the device type. + * + * For disk-type devices, the syntax is: + * + * disk[s][]: + * + */ +static int +alpha_parsedev(struct alpha_devdesc **dev, char *devspec, char **path) +{ + struct alpha_devdesc *idev; + struct devsw *dv; + int i, unit, slice, partition, err; + char *cp, *np; + + /* minimum length check */ + if (strlen(devspec) < 2) + return(EINVAL); + + /* look for a device that matches */ + for (i = 0, dv = NULL; devsw[i] != NULL; i++) { + if (!strncmp(devspec, devsw[i]->dv_name, strlen(devsw[i]->dv_name))) { + dv = devsw[i]; + break; + } + } + + if (dv == NULL) + return(ENOENT); + idev = malloc(sizeof(struct alpha_devdesc)); + err = 0; + np = (devspec + strlen(dv->dv_name)); + + switch(dv->dv_type) { + case DEVT_NONE: /* XXX what to do here? Do we care? */ + break; + + case DEVT_DISK: + unit = -1; + slice = -1; + partition = -1; + if (*np && (*np != ':')) { + unit = strtol(np, &cp, 10); /* next comes the unit number */ + if (cp == np) { + err = EUNIT; + goto fail; + } + if (*cp == 's') { /* got a slice number */ + np = cp + 1; + slice = strtol(np, &cp, 10); + if (cp == np) { + err = ESLICE; + goto fail; + } + } + if (*cp && (*cp != ':')) { + partition = *cp - 'a'; /* get a partition number */ + if ((partition < 0) || (partition >= MAXPARTITIONS)) { + err = EPART; + goto fail; + } + cp++; + } + } + if (*cp && (*cp != ':')) { + err = EINVAL; + goto fail; + } + + idev->d_kind.srmdisk.unit = unit; + idev->d_kind.srmdisk.slice = slice; + idev->d_kind.srmdisk.partition = partition; + if (path != NULL) + *path = (*cp == 0) ? cp : cp + 1; + break; + + case DEVT_NET: + unit = 0; + + if (*np && (*np != ':')) { + unit = strtol(np, &cp, 0); /* get unit number if present */ + if (cp == np) { + err = EUNIT; + goto fail; + } + } + if (*cp && (*cp != ':')) { + err = EINVAL; + goto fail; + } + + idev->d_kind.netif.unit = unit; + if (path != NULL) + *path = (*cp == 0) ? cp : cp + 1; + break; + + default: + err = EINVAL; + goto fail; + } + idev->d_dev = dv; + idev->d_type = dv->dv_type; + if (dev != NULL) + *dev = idev; + return(0); + + fail: + free(idev); + return(err); +} + + +char * +alpha_fmtdev(void *vdev) +{ + struct alpha_devdesc *dev = (struct alpha_devdesc *)vdev; + static char buf[128]; /* XXX device length constant? */ + char *cp; + + switch(dev->d_type) { + case DEVT_NONE: + strcpy(buf, "(no device)"); + break; + + case DEVT_DISK: + cp = buf; + cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_kind.srmdisk.unit); + if (dev->d_kind.srmdisk.slice > 0) + cp += sprintf(cp, "s%d", dev->d_kind.srmdisk.slice); + if (dev->d_kind.srmdisk.partition >= 0) + cp += sprintf(cp, "%c", dev->d_kind.srmdisk.partition + 'a'); + strcat(cp, ":"); + break; + + case DEVT_NET: + sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_kind.netif.unit); + break; + } + return(buf); +} + + +/* + * Set currdev to suit the value being supplied in (value) + */ +int +alpha_setcurrdev(struct env_var *ev, int flags, void *value) +{ + struct alpha_devdesc *ncurr; + int rv; + + if ((rv = alpha_parsedev(&ncurr, value, NULL)) != 0) + return(rv); + free(ncurr); + env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); + return(0); +} + Property changes on: cvs2svn/tags/initial/sys/boot/alpha/libalpha/devicename.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/libalpha/elf_freebsd.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/libalpha/elf_freebsd.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/libalpha/elf_freebsd.c (revision 49189) @@ -0,0 +1,316 @@ +/* $Id$ */ +/* $NetBSD: loadfile.c,v 1.10 1998/06/25 06:45:46 ross Exp $ */ + +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center. + * + * 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 by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``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 FOUNDATION OR CONTRIBUTORS + * 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. + */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ralph Campbell. + * + * 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)boot.c 8.1 (Berkeley) 6/10/93 + */ + +#include +#include + +#include +#include +#include +#include +#include + +#include "bootstrap.h" + +#define _KERNEL + +struct elf_kernel_module +{ + struct loaded_module m; + vm_offset_t m_entry; /* module entrypoint */ + struct bootinfo_v1 m_bi; /* legacy bootinfo */ +}; + +static int elf_loadmodule(char *filename, vm_offset_t dest, struct loaded_module **result); +static int elf_exec(struct loaded_module *amp); +static int elf_load(int fd, Elf_Ehdr *elf, vm_offset_t dest); + +struct module_format alpha_elf = { MF_ELF, elf_loadmodule, elf_exec }; + +vm_offset_t ffp_save, ptbr_save; +vm_offset_t ssym, esym; + +static int +elf_loadmodule(char *filename, vm_offset_t dest, struct loaded_module **result) +{ + struct elf_kernel_module *mp; + Elf_Ehdr hdr; + ssize_t nr; + int fd, rval; + + /* Open the file. */ + rval = 1; + if ((fd = open(filename, 0)) < 0) { + (void)printf("open %s: %s\n", filename, strerror(errno)); + goto err; + } + + /* Read the exec header. */ + if ((nr = read(fd, &hdr, sizeof(hdr))) != sizeof(hdr)) { + (void)printf("read header: %s\n", strerror(errno)); + goto err; + } + + if (!(hdr.e_ident[0] == ELFMAG0 + && hdr.e_ident[1] == ELFMAG1 + && hdr.e_ident[2] == ELFMAG2 + && hdr.e_ident[3] == ELFMAG3)) { + (void)printf("%s: unknown executable format\n", filename); + goto err; + } + + /* + * Ok, we think this is for us. + */ + mp = malloc(sizeof(struct elf_kernel_module)); + mp->m.m_name = strdup(filename); /* XXX should we prune the name? */ + mp->m.m_type = "elf kernel"; /* XXX only if that's what we really are */ + mp->m.m_args = NULL; /* XXX should we put the bootstrap args here and parse later? */ + mp->m.m_flags = MF_ELF; /* we're an elf kernel */ + mp->m_entry = hdr.e_entry; + if (dest == 0) + dest = (vm_offset_t) hdr.e_entry; + if (mod_findmodule(NULL, mp->m.m_type) != NULL) { + printf("elf_loadmodule: kernel already loaded\n"); + rval = EPERM; + goto err; + } + rval = elf_load(fd, &hdr, (vm_offset_t) dest); + + *result = (struct loaded_module *)mp; + + err: + if (fd >= 0) + (void)close(fd); + return (rval); +} + +static int +elf_load(int fd, Elf_Ehdr *elf, vm_offset_t dest) +{ + Elf_Shdr *shp; + Elf_Off off; + int i; + int first = 1; + int havesyms; + + for (i = 0; i < elf->e_phnum; i++) { + Elf_Phdr phdr; + if (lseek(fd, elf->e_phoff + sizeof(phdr) * i, SEEK_SET) + == -1) { + (void)printf("lseek phdr: %s\n", strerror(errno)); + return (1); + } + if (read(fd, (void *)&phdr, sizeof(phdr)) != sizeof(phdr)) { + (void)printf("read phdr: %s\n", strerror(errno)); + return (1); + } + if (phdr.p_type != PT_LOAD || + (phdr.p_flags & (PF_W|PF_X)) == 0) + continue; + + /* Read in segment. */ + (void)printf("%s%lu", first ? "" : "+", phdr.p_filesz); + if (lseek(fd, phdr.p_offset, SEEK_SET) == -1) { + (void)printf("lseek text: %s\n", strerror(errno)); + return (1); + } + if (read(fd, (void *)phdr.p_vaddr, phdr.p_filesz) != + phdr.p_filesz) { + (void)printf("read text: %s\n", strerror(errno)); + return (1); + } + if (first || ffp_save < phdr.p_vaddr + phdr.p_memsz) + ffp_save = phdr.p_vaddr + phdr.p_memsz; + + /* Zero out bss. */ + if (phdr.p_filesz < phdr.p_memsz) { + (void)printf("+%lu", phdr.p_memsz - phdr.p_filesz); + bzero((void *)(phdr.p_vaddr + phdr.p_filesz), + phdr.p_memsz - phdr.p_filesz); + } + first = 0; + } + /* + * Copy the ELF and section headers. + */ + ffp_save = roundup(ffp_save, sizeof(long)); + ssym = ffp_save; + bcopy(elf, (void *)ffp_save, sizeof(Elf_Ehdr)); + ffp_save += sizeof(Elf_Ehdr); + if (lseek(fd, elf->e_shoff, SEEK_SET) == -1) { + printf("lseek section headers: %s\n", strerror(errno)); + return (1); + } + if (read(fd, (void *)ffp_save, elf->e_shnum * sizeof(Elf_Shdr)) != + elf->e_shnum * sizeof(Elf_Shdr)) { + printf("read section headers: %s\n", strerror(errno)); + return (1); + } + shp = (Elf_Shdr *)ffp_save; + ffp_save += roundup((elf->e_shnum * sizeof(Elf_Shdr)), sizeof(long)); + + /* + * Now load the symbol sections themselves. Make sure the + * sections are aligned. Don't bother with string tables if + * there are no symbol sections. + */ + off = roundup((sizeof(Elf_Ehdr) + (elf->e_shnum * sizeof(Elf_Shdr))), + sizeof(long)); + for (havesyms = i = 0; i < elf->e_shnum; i++) + if (shp[i].sh_type == SHT_SYMTAB) + havesyms = 1; + for (first = 1, i = 0; i < elf->e_shnum; i++) { + if (shp[i].sh_type == SHT_SYMTAB || + shp[i].sh_type == SHT_STRTAB) { + printf("%s%ld", first ? " [" : "+", shp[i].sh_size); + if (havesyms) { + if (lseek(fd, shp[i].sh_offset, SEEK_SET) + == -1) { + printf("\nlseek symbols: %s\n", + strerror(errno)); + return (1); + } + if (read(fd, (void *)ffp_save, shp[i].sh_size) + != shp[i].sh_size) { + printf("\nread symbols: %s\n", + strerror(errno)); + return (1); + } + } + ffp_save += roundup(shp[i].sh_size, sizeof(long)); + shp[i].sh_offset = off; + off += roundup(shp[i].sh_size, sizeof(long)); + first = 0; + } + } + esym = ffp_save; + + if (first == 0) + printf("]"); + + ffp_save = ALPHA_K0SEG_TO_PHYS((ffp_save + PAGE_MASK) & ~PAGE_MASK) + >> PAGE_SHIFT; + ffp_save += 2; /* XXX OSF/1 does this, no idea why. */ + + (void)printf("\n"); + + /* + * Frob the copied ELF header to give information relative + * to ssym. + */ + elf = (Elf_Ehdr *)ssym; + elf->e_phoff = 0; + elf->e_shoff = sizeof(Elf_Ehdr); + elf->e_phentsize = 0; + elf->e_phnum = 0; + + return (0); +} + +static int +elf_exec(struct loaded_module *amp) +{ + struct elf_kernel_module *mp = (struct elf_kernel_module *)amp; + static struct bootinfo_v1 bootinfo_v1; + + /* + * Fill in the bootinfo for the kernel. + */ + bzero(&bootinfo_v1, sizeof(bootinfo_v1)); + bootinfo_v1.ssym = ssym; + bootinfo_v1.esym = esym; + strncpy(bootinfo_v1.booted_kernel, mp->m.m_name, + sizeof(bootinfo_v1.booted_kernel)); + prom_getenv(PROM_E_BOOTED_OSFLAGS, bootinfo_v1.boot_flags, + sizeof(bootinfo_v1.boot_flags)); + bootinfo_v1.hwrpb = (void *)HWRPB_ADDR; + bootinfo_v1.hwrpbsize = ((struct rpb *)HWRPB_ADDR)->rpb_size; + bootinfo_v1.cngetc = NULL; + bootinfo_v1.cnputc = NULL; + bootinfo_v1.cnpollc = NULL; + + printf("Entering %s at 0x%lx...\n", mp->m.m_name, mp->m_entry); + closeall(); + alpha_pal_imb(); + (*(void (*)())mp->m_entry)(ffp_save, ptbr_save, + BOOTINFO_MAGIC, &bootinfo_v1, 1, 0); +} + + + Property changes on: cvs2svn/tags/initial/sys/boot/alpha/libalpha/elf_freebsd.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/libalpha/getsecs.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/libalpha/getsecs.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/libalpha/getsecs.c (revision 49189) @@ -0,0 +1,37 @@ +/* + * $Id$ + * From: $NetBSD: getsecs.c,v 1.5 1998/01/05 07:02:49 perry Exp $ + */ + +#include +#include +#include + +int +getsecs() +{ + static long tnsec; + static long lastpcc, wrapsecs; + long curpcc; + + if (tnsec == 0) { + tnsec = 1; + lastpcc = alpha_rpcc() & 0xffffffff; + wrapsecs = (0xffffffff / + ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq) + 1; + +#if 0 + printf("getsecs: cc freq = %d, time to wrap = %d\n", + ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq, wrapsecs); +#endif + } + + curpcc = alpha_rpcc() & 0xffffffff; + if (curpcc < lastpcc) + curpcc += 0x100000000; + + tnsec += ((curpcc - lastpcc) * 1000000000) / ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq; + lastpcc = curpcc; + + return (tnsec / 1000000000); +} Property changes on: cvs2svn/tags/initial/sys/boot/alpha/libalpha/getsecs.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/libalpha/libalpha.h =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/libalpha/libalpha.h (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/libalpha/libalpha.h (revision 49189) @@ -0,0 +1,107 @@ +/* $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. + * + */ + + +/* + * alpha fully-qualified device descriptor + */ +struct alpha_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; + } srmdisk; + struct + { + int unit; /* XXX net layer lives over these? */ + } netif; + } d_kind; +}; + +extern int alpha_getdev(void **vdev, char *devspec, char **path); +extern char *alpha_fmtdev(void *vdev); +extern int alpha_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 srmdisk; +extern struct netif_driver srmnet; + +/* this is in startup code */ +extern void delay(int); +extern void reboot(void); + +/* + * alpha module loader + */ +#define MF_FORMATMASK 0xf +#define MF_AOUT 0 /* not supported */ +#define MF_ELF 1 + +struct alpha_module +{ + char *m_name; /* module name */ + char *m_type; /* module type, eg 'kernel', 'pnptable', etc. */ + char *m_args; /* arguments for the module */ + int m_flags; /* 0xffff reserved for arch-specific use */ + struct alpha_module *m_next; /* next module */ + physaddr_t m_addr; /* load address */ + size_t m_size; /* module size */ +}; + +struct alpha_format +{ + int l_format; + /* Load function must return EFTYPE if it can't handle the module supplied */ + int (* l_load)(char *filename, physaddr_t dest, struct alpha_module **result); + int (* l_exec)(struct alpha_module *amp); +}; +extern struct alpha_format *formats[]; /* supplied by consumer */ +extern struct alpha_format alpha_elf; + +extern int alpha_boot(void); +extern int alpha_autoload(void); +extern struct alpha_module *alpha_findmodule(char *name, char *type); Property changes on: cvs2svn/tags/initial/sys/boot/alpha/libalpha/libalpha.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/libalpha/pal.S =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/libalpha/pal.S (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/libalpha/pal.S (revision 49189) @@ -0,0 +1,351 @@ +/* + * $Id$ + * From: $NetBSD: pal.s,v 1.12 1998/02/27 03:44:53 thorpej Exp $ + */ + +/* + * Copyright (c) 1994, 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +/* + * The various OSF PALcode routines. + * + * The following code is originally derived from pages: (I) 6-5 - (I) 6-7 + * and (III) 2-1 - (III) 2-25 of "Alpha Architecture Reference Manual" by + * Richard L. Sites. + * + * Updates taken from pages: (II-B) 2-1 - (II-B) 2-33 of "Alpha AXP + * Architecture Reference Manual, Second Edition" by Richard L. Sites + * and Richard T. Witek. + */ + +#include + +inc2: .stabs __FILE__,132,0,0,inc2; .loc 1 __LINE__ +/* + * alpha_rpcc: read process cycle counter (XXX INSTRUCTION, NOT PALcode OP) + */ + .text +LEAF(alpha_rpcc,1) + rpcc v0 + RET + END(alpha_rpcc) + +/* + * alpha_mb: memory barrier (XXX INSTRUCTION, NOT PALcode OP) + */ + .text +LEAF(alpha_mb,0) + mb + RET + END(alpha_mb) + +/* + * alpha_wmb: write memory barrier (XXX INSTRUCTION, NOT PALcode OP) + */ + .text +LEAF(alpha_wmb,0) + /* wmb XXX */ + mb /* XXX */ + RET + END(alpha_wmb) + +/* + * alpha_amask: read architecture features (XXX INSTRUCTION, NOT PALcode OP) + * + * Arguments: + * a0 bitmask of features to test + * + * Returns: + * v0 bitmask - bit is _cleared_ if feature is supported + */ + .text +LEAF(alpha_amask,1) + amask a0, v0 + RET + END(alpha_amask) + +/* + * alpha_implver: read implementation version (XXX INSTRUCTION, NOT PALcode OP) + * + * Returns: + * v0 implementation version - see + */ + .text +LEAF(alpha_implver,0) +#if 0 + implver 0x1, v0 +#else + .long 0x47e03d80 /* XXX gas(1) does the Wrong Thing */ +#endif + RET + END(alpha_implver) + +/* + * alpha_pal_imb: I-Stream memory barrier. [UNPRIVILEGED] + * (Makes instruction stream coherent with data stream.) + */ + .text +LEAF(alpha_pal_imb,0) + call_pal PAL_imb + RET + END(alpha_pal_imb) + +/* + * alpha_pal_cflush: Cache flush [PRIVILEGED] + * + * Flush the entire physical page specified by the PFN specified in + * a0 from any data caches associated with the current processor. + * + * Arguments: + * a0 page frame number of page to flush + */ + .text +LEAF(alpha_pal_cflush,1) + call_pal PAL_cflush + RET + END(alpha_pal_cflush) + +/* + * alpha_pal_draina: Drain aborts. [PRIVILEGED] + */ + .text +LEAF(alpha_pal_draina,0) + call_pal PAL_draina + RET + END(alpha_pal_draina) + +/* + * alpha_pal_halt: Halt the processor. [PRIVILEGED] + */ + .text +LEAF(alpha_pal_halt,0) + call_pal PAL_halt + br zero,alpha_pal_halt /* Just in case */ + RET + END(alpha_pal_halt) + +/* + * alpha_pal_rdmces: Read MCES processor register. [PRIVILEGED] + * + * Return: + * v0 current MCES value + */ + .text +LEAF(alpha_pal_rdmces,1) + call_pal PAL_OSF1_rdmces + RET + END(alpha_pal_rdmces) + +/* + * alpha_pal_rdps: Read processor status. [PRIVILEGED] + * + * Return: + * v0 current PS value + */ + .text +LEAF(alpha_pal_rdps,0) + call_pal PAL_OSF1_rdps + RET + END(alpha_pal_rdps) + +/* + * alpha_pal_rdusp: Read user stack pointer. [PRIVILEGED] + * + * Return: + * v0 current user stack pointer + */ + .text +LEAF(alpha_pal_rdusp,0) + call_pal PAL_OSF1_rdusp + RET + END(alpha_pal_rdusp) + +/* + * alpha_pal_rdval: Read system value. [PRIVILEGED] + * + * Returns the sysvalue in v0, allowing access to a 64-bit + * per-processor value for use by the operating system. + * + * Return: + * v0 sysvalue + */ + .text +LEAF(alpha_pal_rdval,0) + call_pal PAL_OSF1_rdval + RET + END(alpha_pal_rdval) + +/* + * alpha_pal_swpipl: Swap Interrupt priority level. [PRIVILEGED] + * _alpha_pal_swpipl: Same, from profiling code. [PRIVILEGED] + * + * Arguments: + * a0 new IPL + * + * Return: + * v0 old IPL + */ + .text +LEAF(alpha_pal_swpipl,1) + call_pal PAL_OSF1_swpipl + RET + END(alpha_pal_swpipl) + +LEAF_NOPROFILE(_alpha_pal_swpipl,1) + call_pal PAL_OSF1_swpipl + RET + END(_alpha_pal_swpipl) + +/* + * alpha_pal_tbi: Translation buffer invalidate. [PRIVILEGED] + * + * Arguments: + * a0 operation selector + * a1 address to operate on (if necessary) + */ + .text +LEAF(alpha_pal_tbi,2) + call_pal PAL_OSF1_tbi + RET + END(alpha_pal_tbi) + +/* + * alpha_pal_whami: Who am I? [PRIVILEGED] + * + * Return: + * v0 processor number + */ + .text +LEAF(alpha_pal_whami,0) + call_pal PAL_OSF1_whami + RET + END(alpha_pal_whami) + +/* + * alpha_pal_wrent: Write system entry address. [PRIVILEGED] + * + * Arguments: + * a0 new vector + * a1 vector selector + */ + .text +LEAF(alpha_pal_wrent,2) + call_pal PAL_OSF1_wrent + RET + END(alpha_pal_wrent) + +/* + * alpha_pal_wrfen: Write floating-point enable. [PRIVILEGED] + * + * Arguments: + * a0 new enable value (val & 0x1 -> enable). + */ + .text +LEAF(alpha_pal_wrfen,1) + call_pal PAL_OSF1_wrfen + RET + END(alpha_pal_wrfen) + +/* + * alpha_pal_wripir: Write interprocessor interrupt request. [PRIVILEGED] + * + * Generate an interprocessor interrupt on the processor specified by + * processor number in a0. + * + * Arguments: + * a0 processor to interrupt + */ + .text +LEAF(alpha_pal_wripir,1) + call_pal PAL_ipir + RET + END(alpha_pal_wripir) + +/* + * alpha_pal_wrusp: Write user stack pointer. [PRIVILEGED] + * + * Arguments: + * a0 new user stack pointer + */ + .text +LEAF(alpha_pal_wrusp,1) + call_pal PAL_OSF1_wrusp + RET + END(alpha_pal_wrusp) + +/* + * alpha_pal_wrvptptr: Write virtual page table pointer. [PRIVILEGED] + * + * Arguments: + * a0 new virtual page table pointer + */ + .text +LEAF(alpha_pal_wrvptptr,1) + call_pal PAL_OSF1_wrvptptr + RET + END(alpha_pal_wrvptptr) + +/* + * alpha_pal_wrmces: Write MCES processor register. [PRIVILEGED] + * + * Arguments: + * a0 value to write to MCES + */ + .text +LEAF(alpha_pal_wrmces,1) + call_pal PAL_OSF1_wrmces + RET + END(alpha_pal_wrmces) + +/* + * alpha_pal_wrval: Write system value. [PRIVILEGED] + * + * Write the value passed in a0 to this processor's sysvalue. + * + * Arguments: + * a0 value to write to sysvalue + */ +LEAF(alpha_pal_wrval,1) + call_pal PAL_OSF1_wrval + RET + END(alpha_pal_wrval) + +/* + * alpha_pal_swpctx: Swap context. [PRIVILEGED] + * + * Switch to a new process context. + * + * Arguments: + * a0 physical address of hardware PCB describing context + * + * Returns: + * v0 physical address of hardware PCB describing previous context + */ +LEAF(alpha_pal_swpctx,1) + call_pal PAL_OSF1_swpctx + RET + END(alpha_pal_swpctx) Property changes on: cvs2svn/tags/initial/sys/boot/alpha/libalpha/pal.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/libalpha/prom.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/libalpha/prom.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/libalpha/prom.c (revision 49189) @@ -0,0 +1,165 @@ +/* $Id$ */ +/* $NetBSD: prom.c,v 1.3 1997/09/06 14:03:58 drochner Exp $ */ + +/* + * Mach Operating System + * Copyright (c) 1992 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ + +#include + +#include +#include + +#include "common.h" +#include "bootstrap.h" + +int console; + +static void prom_probe(struct console *cp); +static int prom_init(int); +void prom_putchar(int); +int prom_getchar(void); +static int prom_poll(void); + +struct console promconsole = { + "prom", + "SRM firmware console", + 0, + prom_probe, + prom_init, + prom_putchar, + prom_getchar, + prom_poll, +}; + +void +init_prom_calls() +{ + extern struct prom_vec prom_dispatch_v; + struct rpb *r; + struct crb *c; + char buf[4]; + + r = (struct rpb *)HWRPB_ADDR; + c = (struct crb *)((u_int8_t *)r + r->rpb_crb_off); + + prom_dispatch_v.routine_arg = c->crb_v_dispatch; + prom_dispatch_v.routine = c->crb_v_dispatch->entry_va; + + /* Look for console tty. */ + prom_getenv(PROM_E_TTY_DEV, buf, 4); + console = buf[0] - '0'; +} + +static void +prom_probe(struct console *cp) +{ + init_prom_calls(); + cp->c_flags |= C_PRESENTIN|C_PRESENTOUT; +} + +static int +prom_init(int arg) +{ + return 0; +} + +void +prom_putchar(int c) +{ + prom_return_t ret; + char cbuf; + + cbuf = c; + do { + ret.bits = prom_dispatch(PROM_R_PUTS, console, &cbuf, 1); + } while ((ret.u.retval & 1) == 0); +} + +static int saved_char = -1; + +int +prom_getchar() +{ + prom_return_t ret; + + if (saved_char != -1) { + int c = saved_char; + saved_char = -1; + return c; + } + + for (;;) { + ret.bits = prom_dispatch(PROM_R_GETC, console); + if (ret.u.status == 0 || ret.u.status == 1) + return (ret.u.retval); + } +} + +int +prom_poll() +{ + prom_return_t ret; + + if (saved_char != -1) + return 1; + + ret.bits = prom_dispatch(PROM_R_GETC, console); + if (ret.u.status == 0 || ret.u.status == 1) { + saved_char = ret.u.retval; + return 1; + } + + return 0; +} + +int +prom_getenv(id, buf, len) + int id, len; + char *buf; +{ + prom_return_t ret; + + ret.bits = prom_dispatch(PROM_R_GETENV, id, buf, len-1); + if (ret.u.status & 0x4) + ret.u.retval = 0; + buf[ret.u.retval] = '\0'; + + return (ret.u.retval); +} + +int +prom_open(dev, len) + char *dev; + int len; +{ + prom_return_t ret; + + ret.bits = prom_dispatch(PROM_R_OPEN, dev, len); + if (ret.u.status & 0x4) + return (-1); + else + return (ret.u.retval); +} Property changes on: cvs2svn/tags/initial/sys/boot/alpha/libalpha/prom.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/libalpha/prom_disp.S =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/libalpha/prom_disp.S (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/libalpha/prom_disp.S (revision 49189) @@ -0,0 +1,118 @@ +/* + * $Id$ + * From: $NetBSD: prom_disp.S,v 1.2 1997/04/06 08:41:00 cgd Exp $ + */ + +/* + * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#ifndef _LOCORE +#define ASSEMBLER +#include +#include +#include +#endif + + .globl prom_dispatch_v + .comm prom_dispatch_v,16 + + .text + .align 4 + +/* + * Dispatcher routine. Implements prom's calling machinery, saves our + * callee-saved registers as required by C. + */ +#define D_RA (7*8) +#define D_S0 (8*8) +#define D_S1 (9*8) +#define D_S2 (10*8) +#define D_S3 (11*8) +#define D_S4 (12*8) +#define D_S5 (13*8) +#define D_S6 (14*8) +#define DISPATCH_FRAME_SIZE (15*8) +#define DISPATCH_REGS IM_RA|IM_S0|IM_S1|IM_S2|IM_S3|IM_S4|IM_S5|IM_S6 + +NESTED(prom_dispatch, 5, DISPATCH_FRAME_SIZE, ra, DISPATCH_REGS, 0) + LDGP(pv) + + lda sp, -DISPATCH_FRAME_SIZE(sp) + stq ra, D_RA(sp) + stq s0, D_S0(sp) + stq s1, D_S1(sp) + stq s2, D_S2(sp) + stq s3, D_S3(sp) + stq s4, D_S4(sp) + stq s5, D_S5(sp) + stq s6, D_S6(sp) + + /* Lord have mercy because.. I would not. */ +/* #define STUPID_PROM_IS_32_BITS */ +#ifdef STUPID_PROM_IS_32_BITS + ldah s0, 0x2000(zero) /* hack for hack */ + lda s0, (0x2000-8)(s0) + + stq sp, 0(s0) + or s0, zero, sp +#endif /* STUPID_PROM_IS_32_BITS */ + + lda pv, prom_dispatch_v + ldq v0, 0(pv) /* routine */ + ldq pv, 8(pv) /* routine_arg */ + + jsr ra, (v0) + +#ifdef STUPID_PROM_IS_32_BITS + ldah s0, 0x2000(zero) /* hack for hack */ + lda s0, (0x2000-8)(s0) + + ldq sp, 0(s0) +#endif /* STUPID_PROM_IS_32_BITS */ + + ldq ra, D_RA(sp) + ldq s0, D_S0(sp) + ldq s1, D_S1(sp) + ldq s2, D_S2(sp) + ldq s3, D_S3(sp) + ldq s4, D_S4(sp) + ldq s5, D_S5(sp) + ldq s6, D_S6(sp) + lda sp, DISPATCH_FRAME_SIZE(sp) + RET +END(prom_dispatch) + +#undef D_RA +#undef D_S0 +#undef D_S1 +#undef D_S2 +#undef D_S3 +#undef D_S4 +#undef D_S5 +#undef D_S6 +#undef DISPATCH_FRAME_SIZE +#undef DISPATCH_REGS Property changes on: cvs2svn/tags/initial/sys/boot/alpha/libalpha/prom_disp.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/libalpha/prom_swpal.S =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/libalpha/prom_swpal.S (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/libalpha/prom_swpal.S (revision 49189) @@ -0,0 +1,139 @@ +/* + * $Id$ + * From: $NetBSD: prom_swpal.S,v 1.2 1997/04/06 08:41:01 cgd Exp $ + */ + +/* + * Copyright (c) 1994, 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Keith Bostic + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#define ASSEMBLER +#include +#include +#include + +/* Offsets from base of HWRPB. */ +#define RPB_SELFREF 0x00 +#define RPB_SLOTSIZE 0x98 +#define RPB_PERCPU_OFF 0xA0 + +/* Offsets in a boot PCB. */ +#define PCB_KSP 0x00 +#define PCB_PTBR 0x10 +#define PCB_ASN 0x1c +#define PCB_FEN 0x28 + +/* Pal values. */ +#define PAL_RESERVED 0 /* Reserved to Digital. */ +#define PAL_VMS 1 /* VMS */ +#define PAL_OSF 2 /* OSF */ + +/* + * PAL code switch routine. + */ +#define D_RA (7*8) +#define D_S0 (8*8) +#define D_S1 (9*8) +#define D_S2 (10*8) +#define D_S3 (11*8) +#define D_S4 (12*8) +#define D_S5 (13*8) +#define PALSW_FRAME_SIZE (14*8) +#define PALSW_REGS IM_RA|IM_S0|IM_S1|IM_S2|IM_S3|IM_S4|IM_S5 + + .comm ptbr_save,8 + + .text + .align 4 + +NESTED(switch_palcode, 0, PALSW_FRAME_SIZE, ra, PALSW_REGS, 0) + LDGP(pv) +/* ldgp gp, 0(pv)*/ + + lda sp, -PALSW_FRAME_SIZE(sp) + stq ra, D_RA(sp) + stq s0, D_S0(sp) + stq s1, D_S1(sp) + stq s2, D_S2(sp) + stq s3, D_S3(sp) + stq s4, D_S4(sp) + stq s5, D_S5(sp) + + stq pv, 0(sp) + stq gp, 8(sp) + + ldiq s0, HWRPB_ADDR /* s0 HWRPB_ADDR */ + ldq s1, RPB_SLOTSIZE(s0) + call_pal PAL_VMS_mfpr_whami + mulq s1, v0, s1 /* s1 per_cpu offset from base */ + ldq s2, RPB_PERCPU_OFF(s0) + addq s0, s2, s2 + addq s2, s1, s2 /* s2 PCB (virtual) */ + + call_pal PAL_VMS_mfpr_ptbr + stq v0, PCB_PTBR(s2) + stq v0, ptbr_save /* save PTBR for the kernel */ + stl zero, PCB_ASN(s2) + stq zero, PCB_FEN(s2) + stq sp, PCB_KSP(s2) + + ldq t0, RPB_SELFREF(s0) /* HWRBP base (physical) */ + ldq t1, RPB_PERCPU_OFF(s0) + addq t0, t1, t0 + addq t0, s1, t0 /* PCB base (phys) */ + stq t0, 16(sp) + + call_pal PAL_VMS_mfpr_vptb + mov v0, a3 + ldiq a0, PAL_OSF + lda a1, contin + ldq a2, 16(sp) + + call_pal PAL_swppal /* a0, a1, a2, a3 */ + +contin: ldq pv, 0(sp) + ldq gp, 8(sp) + + ldq ra, D_RA(sp) + ldq s0, D_S0(sp) + ldq s1, D_S1(sp) + ldq s2, D_S2(sp) + ldq s3, D_S3(sp) + ldq s4, D_S4(sp) + ldq s5, D_S5(sp) + lda sp, PALSW_FRAME_SIZE(sp) + RET +END(switch_palcode) + +#undef D_RA +#undef D_S0 +#undef D_S1 +#undef D_S2 +#undef D_S3 +#undef D_S4 +#undef D_S5 +#undef PALSW_FRAME_SIZE +#undef PALSW_REGS Property changes on: cvs2svn/tags/initial/sys/boot/alpha/libalpha/prom_swpal.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/libalpha/reboot.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/libalpha/reboot.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/libalpha/reboot.c (revision 49189) @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 1998 Doug Rabson + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +#include +#include + +void +reboot(void) +{ + struct rpb *hwrpb = (struct rpb *)HWRPB_ADDR; + struct pcs *pcs = LOCATE_PCS(hwrpb, hwrpb->rpb_primary_cpu_id); + pcs->pcs_flags |= PCS_HALT_WARM_BOOT; + alpha_pal_halt(); +} + +void +exit(int code) +{ + struct rpb *hwrpb = (struct rpb *)HWRPB_ADDR; + struct pcs *pcs = LOCATE_PCS(hwrpb, hwrpb->rpb_primary_cpu_id); + pcs->pcs_flags |= PCS_HALT_STAY_HALTED; + alpha_pal_halt(); +} Property changes on: cvs2svn/tags/initial/sys/boot/alpha/libalpha/reboot.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/libalpha/srmdisk.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/libalpha/srmdisk.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/libalpha/srmdisk.c (revision 49189) @@ -0,0 +1,334 @@ +/*- + * Copyright (c) 1998 Michael Smith + * Copyright (c) 1998 Doug Rabson + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +/* + * SRM disk device handling. + * + * Ideas and algorithms from: + * + * - NetBSD libi386/biosdisk.c + * - FreeBSD biosboot/disk.c + * + * XXX Todo: add bad144 support. + */ + +#include + +#include +#include + +#include +#include + +#include "libalpha.h" + +#define SRMDISK_SECSIZE 512 + +#define BUFSIZE (1 * SRMDISK_SECSIZE) +#define MAXBDDEV MAXDEV + +#ifdef DISK_DEBUG +# define D(x) x +#else +# define D(x) +#endif + +static int bd_init(void); +static int bd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, void *buf, size_t *rsize); +static int bd_open(struct open_file *f, void *vdev); +static int bd_close(struct open_file *f); + +struct open_disk { + int od_fd; + int od_unit; /* our unit number */ + int od_boff; /* block offset from beginning of SRM disk */ + int od_flags; +#define BD_MODEMASK 0x3 +#define BD_MODEINT13 0x0 +#define BD_MODEEDD1 0x1 +#define BD_MODEEDD3 0x2 +#define BD_FLOPPY (1<<2) + u_char od_buf[BUFSIZE]; /* transfer buffer (do we want/need this?) */ +}; + +struct devsw srmdisk = { + "disk", + DEVT_DISK, + bd_init, + bd_strategy, + bd_open, + bd_close, + noioctl +}; + +/* + * List of SRM devices, translation from disk unit number to + * SRM unit number. + */ +static struct +{ + char bd_name[64]; + int bd_unit; /* SRM unit number */ + int bd_namelen; + int bd_flags; +} bdinfo [MAXBDDEV]; +static int nbdinfo = 0; + +/* + * Quiz SRM for disk devices, save a little info about them. + */ +static int +bd_init(void) +{ + prom_return_t ret; + char devname[64]; + + bdinfo[0].bd_unit = 0; /* XXX */ + bdinfo[0].bd_flags = 0; /* XXX */ + ret.bits = prom_getenv(PROM_E_BOOTED_DEV, + bdinfo[0].bd_name, sizeof(bdinfo[0].bd_name)); + bdinfo[0].bd_namelen = ret.u.retval; + nbdinfo++; + + return (0); +} + +/* + * Attempt to open the disk described by (dev) for use by (f). + * + * Note that the philosophy here is "give them exactly what + * they ask for". This is necessary because being too "smart" + * about what the user might want leads to complications. + * (eg. given no slice or partition value, with a disk that is + * sliced - are they after the first BSD slice, or the DOS + * slice before it?) + */ +static int +bd_open(struct open_file *f, void *vdev) +{ + struct alpha_devdesc *dev = vdev; + struct dos_partition *dptr; + struct open_disk *od; + struct disklabel *lp; + int sector, slice, i; + int error; + int unit; + prom_return_t ret; + + unit = dev->d_kind.srmdisk.unit; + if (unit >= nbdinfo) { + D(printf("attempt to open nonexistent disk\n")); + return(ENXIO); + } + + /* Call the prom to open the disk. */ + ret.bits = prom_open(bdinfo[unit].bd_name, bdinfo[unit].bd_namelen); + if (ret.u.status == 2) + return (ENXIO); + if (ret.u.status == 3) + return (EIO); + + od = (struct open_disk *) malloc(sizeof(struct open_disk)); + if (!od) { + D(printf("srmdiskopen: no memory\n")); + return (ENOMEM); + } + + /* Look up SRM unit number, intialise open_disk structure */ + od->od_fd = ret.u.retval; + od->od_unit = dev->d_kind.srmdisk.unit; + od->od_flags = bdinfo[od->od_unit].bd_flags; + od->od_boff = 0; + error = 0; + +#if 0 + /* Get geometry for this open (removable device may have changed) */ + if (set_geometry(&od->od_ll)) { + D(printf("bd_open: can't get geometry\n")); + error = ENXIO; + goto out; + } +#endif + + /* + * Following calculations attempt to determine the correct value + * for d->od_boff by looking for the slice and partition specified, + * or searching for reasonable defaults. + */ + +#if 0 + /* + * Find the slice in the DOS slice table. + */ + if (readsects(&od->od_ll, 0, 1, od->od_buf, 0)) { + D(printf("bd_open: error reading MBR\n")); + error = EIO; + goto out; + } + + /* + * Check the slice table magic. + */ + if ((od->od_buf[0x1fe] != 0xff) || (od->od_buf[0x1ff] != 0xaa)) { + /* If a slice number was explicitly supplied, this is an error */ + if (dev->d_kind.srmdisk.slice > 0) { + D(printf("bd_open: no slice table/MBR (no magic)\n")); + error = ENOENT; + goto out; + } + sector = 0; + goto unsliced; /* may be a floppy */ + } + dptr = (struct dos_partition *) & od->od_buf[DOSPARTOFF]; + + /* + * XXX No support here for 'extended' slices + */ + if (dev->d_kind.srmdisk.slice <= 0) { + /* + * Search for the first FreeBSD slice; this also works on "unsliced" + * disks, as they contain a "historically bogus" MBR. + */ + for (i = 0; i < NDOSPART; i++, dptr++) + if (dptr->dp_typ == DOSPTYP_386BSD) { + sector = dptr->dp_start; + break; + } + /* Did we find something? */ + if (sector == -1) { + error = ENOENT; + goto out; + } + } else { + /* + * Accept the supplied slice number unequivocally (we may be looking + * for a DOS partition) if we can handle it. + */ + if ((dev->d_kind.srmdisk.slice > NDOSPART) || (dev->d_kind.srmdisk.slice < 1)) { + error = ENOENT; + goto out; + } + dptr += (dev->d_kind.srmdisk.slice - 1); + sector = dptr->dp_start; + } + unsliced: + +#else + sector = 0; +#endif + /* + * Now we have the slice, look for the partition in the disklabel if we have + * a partition to start with. + */ + if (dev->d_kind.srmdisk.partition < 0) { + od->od_boff = sector; /* no partition, must be after the slice */ + } else { + if (bd_strategy(od, F_READ, sector + LABELSECTOR, 512, od->od_buf, 0)) { + D(printf("bd_open: error reading disklabel\n")); + error = EIO; + goto out; + } + lp = (struct disklabel *) (od->od_buf + LABELOFFSET); + if (lp->d_magic != DISKMAGIC) { + D(printf("bd_open: no disklabel\n")); + error = ENOENT; + goto out; + + } else if (dev->d_kind.srmdisk.partition >= lp->d_npartitions) { + + /* + * The partition supplied is out of bounds; this is fatal. + */ + D(printf("partition '%c' exceeds partitions in table (a-'%c')\n", + 'a' + dev->d_kind.srmdisk.partition, 'a' + lp->d_npartitions)); + error = EPART; + goto out; + + } else { + + /* + * Complain if the partition type is wrong and it shouldn't be, but + * regardless accept this partition. + */ + D(if ((lp->d_partitions[dev->d_kind.srmdisk.partition].p_fstype == FS_UNUSED) && + !(od->od_flags & BD_FLOPPY)) /* Floppies often have bogus fstype */ + printf("bd_open: warning, partition marked as unused\n");); + + od->od_boff = lp->d_partitions[dev->d_kind.srmdisk.partition].p_offset; + } + } + /* + * Save our context + */ + f->f_devdata = od; + + out: + if (error) + free(od); + return(error); +} + +static int +bd_close(struct open_file *f) +{ + struct open_disk *od = f->f_devdata; + + (void)prom_close(od->od_fd); + + free(od); + f->f_devdata = NULL; + return(0); +} + +static int +bd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, void *buf, size_t *rsize) +{ + prom_return_t ret; + struct open_disk *od = (struct open_disk *)devdata; + + if (size % SRMDISK_SECSIZE) + panic("bd_strategy: I/O not block multiple"); + + if (flag != F_READ) + return(EROFS); + + if (rsize) + *rsize = 0; + + ret.bits = prom_read(od->od_fd, size, buf, dblk + od->od_boff); + if (ret.u.status) { + D(printf("read error\n")); + return (EIO); + } + + if (rsize) + *rsize = size; + return (0); +} + Property changes on: cvs2svn/tags/initial/sys/boot/alpha/libalpha/srmdisk.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/libalpha/srmnet.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/libalpha/srmnet.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/libalpha/srmnet.c (revision 49189) @@ -0,0 +1,257 @@ +/* + * $Id$ + * From: $NetBSD: if_prom.c,v 1.10 1997/09/06 14:08:33 drochner Exp $ + */ + +/* + * Copyright (c) 1997 Christopher G. Demetriou. All rights reserved. + * Copyright (c) 1993 Adam Glass + * 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 by Adam Glass. + * 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 Adam Glass ``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 REGENTS OR CONTRIBUTORS 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. + */ + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include "bbinfo.h" + +int prom_probe(); +int prom_match(); +void prom_init(); +int prom_get(); +int prom_put(); +void prom_end(); + +extern struct netif_stats prom_stats[]; + +struct netif_dif prom_ifs[] = { +/* dif_unit dif_nsel dif_stats dif_private */ + { 0, 1, &prom_stats[0], 0, }, +}; + +struct netif_stats prom_stats[NENTS(prom_ifs)]; + +struct netbbinfo netbbinfo = { + 0xfeedbabedeadbeef, /* magic number */ + 0, /* set */ + {0, 0, 0, 0, 0, 0}, /* ether address */ + 0, /* force */ + { 0, }, /* pad2 */ + 0, /* cksum */ + 0xfeedbeefdeadbabe, /* magic number */ +}; + +struct netif_driver srmnet = { + "prom", /* netif_bname */ + prom_match, /* netif_match */ + prom_probe, /* netif_probe */ + prom_init, /* netif_init */ + prom_get, /* netif_get */ + prom_put, /* netif_put */ + prom_end, /* netif_end */ + prom_ifs, /* netif_ifs */ + NENTS(prom_ifs) /* netif_nifs */ +}; + +int netfd = 0, broken_firmware; + +int +prom_match(nif, machdep_hint) + struct netif *nif; + void *machdep_hint; +{ + + return (1); +} + +int +prom_probe(nif, machdep_hint) + struct netif *nif; + void *machdep_hint; +{ + + return 0; +} + +int +prom_put(desc, pkt, len) + struct iodesc *desc; + void *pkt; + int len; +{ + + prom_write(netfd, len, pkt, 0); + + return len; +} + + +int +prom_get(desc, pkt, len, timeout) + struct iodesc *desc; + void *pkt; + int len; + time_t timeout; +{ + prom_return_t ret; + time_t t; + int cc; + char hate[2000]; + + t = getsecs(); + cc = 0; + while (((getsecs() - t) < timeout) && !cc) { + if (broken_firmware) + ret.bits = prom_read(netfd, 0, hate, 0); + else + ret.bits = prom_read(netfd, sizeof hate, hate, 0); + if (ret.u.status == 0) + cc = ret.u.retval; + } + if (broken_firmware) + cc = min(cc, len); + else + cc = len; + bcopy(hate, pkt, cc); + + return cc; +} + +extern char *strchr(); + +void +prom_init(desc, machdep_hint) + struct iodesc *desc; + void *machdep_hint; +{ + prom_return_t ret; + char devname[64]; + int devlen, i; + int netbbinfovalid; + char *enet_addr; + u_int64_t *qp, csum; + + broken_firmware = 0; + + csum = 0; + for (i = 0, qp = (u_int64_t *)&netbbinfo; + i < (sizeof netbbinfo / sizeof (u_int64_t)); i++, qp++) + csum += *qp; + netbbinfovalid = (csum == 0); + if (netbbinfovalid) + netbbinfovalid = netbbinfo.set; + + printf("netbbinfo "); + if (!netbbinfovalid) + printf("invalid\n"); + else + printf("valid: force = %d, ea = %s\n", netbbinfo.force, + ether_sprintf(netbbinfo.ether_addr)); + + ret.bits = prom_getenv(PROM_E_BOOTED_DEV, devname, sizeof(devname)); + devlen = ret.u.retval; + + /* Ethernet address is the 9th component of the booted_dev string. */ + enet_addr = devname; + for (i = 0; i < 8; i++) { + enet_addr = strchr(enet_addr, ' '); + if (enet_addr == NULL) { + printf("boot: boot device name does not contain ethernet address.\n"); + goto punt; + } + enet_addr++; + } + if (enet_addr != NULL) { + int hv, lv; + +#define dval(c) (((c) >= '0' && (c) <= '9') ? ((c) - '0') : \ + (((c) >= 'A' && (c) <= 'F') ? (10 + (c) - 'A') : \ + (((c) >= 'a' && (c) <= 'f') ? (10 + (c) - 'a') : -1))) + + for (i = 0; i < 6; i++) { + hv = dval(*enet_addr); enet_addr++; + lv = dval(*enet_addr); enet_addr++; + enet_addr++; + + if (hv == -1 || lv == -1) { + printf("boot: boot device name contains bogus ethernet address.\n"); + goto punt; + } + + desc->myea[i] = (hv << 4) | lv; + } +#undef dval + } + + if (netbbinfovalid && netbbinfo.force) { + printf("boot: using hard-coded ethernet address (forced).\n"); + bcopy(netbbinfo.ether_addr, desc->myea, sizeof desc->myea); + } + + gotit: + printf("boot: ethernet address: %s\n", ether_sprintf(desc->myea)); + + ret.bits = prom_open(devname, devlen + 1); + if (ret.u.status) { + printf("prom_init: open failed: %d\n", ret.u.status); + goto reallypunt; + } + netfd = ret.u.retval; + return; + + punt: + broken_firmware = 1; + if (netbbinfovalid) { + printf("boot: using hard-coded ethernet address.\n"); + bcopy(netbbinfo.ether_addr, desc->myea, sizeof desc->myea); + goto gotit; + } + + reallypunt: + printf("\n"); + printf("Boot device name was: \"%s\"\n", devname); + printf("\n"); + printf("Your firmware may be too old to network-boot NetBSD/Alpha,\n"); + printf("or you might have to hard-code an ethernet address into\n"); + printf("your network boot block with setnetbootinfo(8).\n"); + halt(); +} + +void +prom_end(nif) + struct netif *nif; +{ + prom_close(netfd); +} Property changes on: cvs2svn/tags/initial/sys/boot/alpha/libalpha/srmnet.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/libalpha/start.S =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/libalpha/start.S (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/libalpha/start.S (revision 49189) @@ -0,0 +1,85 @@ +/* + * $Id$ + * From: $NetBSD: start.S,v 1.4 1998/03/28 00:54:15 cgd Exp $ + */ + +/* + * Mach Operating System + * Copyright (c) 1992 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ + +#include + +/* + * start -- + * Entry point for boot/standalone programs. + * + * Arguments: + * a0 long (first free physical page) + * + * This is where the prom comes to. Leaves all exception and interrupts + * to prom, runs off prom's stack too. No return values. + */ + .text + .set noreorder /* don't reorder instructions */ + +#define ENTRY_FRAME 32 + +NESTED(start, 1, ENTRY_FRAME, ra, 0, 0) + br pv,Lstartgp +Lstartgp: + LDGP(pv) + +#ifndef PRIMARY_BOOTBLOCK + lda sp,start /* start stack below text */ + lda sp,-ENTRY_FRAME(sp) +#endif + + lda a0,_edata + lda a1,_end + subq a1,a0,a1 + CALL(bzero) + + CALL(main) /* transfer to C */ + +XLEAF(_rtt, 0) +XLEAF(halt, 0) + call_pal PAL_halt /* halt if we ever return */ +END(start) + +/* + * Dummy routine for GCC2. + */ +LEAF(__main,0) + RET +END(__main) + +/* + * cpu_number + * Return the cpu number, using the whami instruction. + */ +LEAF(cpu_number, 0) + call_pal PAL_VMS_mfpr_whami + RET +END(cpu_number) Property changes on: cvs2svn/tags/initial/sys/boot/alpha/libalpha/start.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/libalpha/time.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/libalpha/time.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/libalpha/time.c (revision 49189) @@ -0,0 +1,43 @@ +/*- + * Copyright (c) 1998 Doug Rabson + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +#include + +/* + * Can't do this properly without putting PCI chipset drivers into the + * bootstrap :-( + */ + +time_t +time(time_t *tloc) +{ + int secs = getsecs(); + if (tloc) + *tloc = secs; + return secs; +} Property changes on: cvs2svn/tags/initial/sys/boot/alpha/libalpha/time.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/netboot/Makefile =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/netboot/Makefile (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/netboot/Makefile (revision 49189) @@ -0,0 +1,72 @@ +# $NetBSD: Makefile,v 1.12 1998/02/19 14:18:36 drochner Exp $ + +BASE= netboot +PROG= ${BASE} +NOMAN= +NEWVERSWHAT= "SRM net boot" + +.PATH: ${.CURDIR}/../common + +# i386-specific bootstrap sources +SRCS+= main.c conf.c dev_net.c + +# Always add MI sources +.PATH: ${.CURDIR}/../../common +.include <${.CURDIR}/../../common/Makefile.inc> +CFLAGS+= -mno-fp-regs +CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR} +# Verbose ls causes extra heap usage +CFLAGS+= -DVERBOSE_LS + +CLEANFILES+= vers.c vers.o gensetdefs.o gensetdefs setdef0.o setdef1.o \ + setdefs.h start.o +CLEANFILES+= ${BASE} ${BASE}.sym ${BASE}.list + +CFLAGS+= -Wall + +# XXX fix to use "standard" versions +LIBSTANDDIR= /home/dfr/FreeBSD/alpha/src/lib/libstand +LIBSTAND= ${LIBSTANDDIR}/obj/libstand.a +CFLAGS+= -I${LIBSTANDDIR} +LIBALPHA= ${.CURDIR}/../libalpha/obj/libalpha.a +CFLAGS+= -I${.CURDIR}/.. +CRT= start.o +STRIP= + +all: ${BASE} + +vers.o: ${.CURDIR}/newvers.sh ${.CURDIR}/Makefile + sh ${.CURDIR}/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} + ${CC} -c vers.c + +${BASE}: ${BASE}.sym + objcopy -O binary ${BASE}.sym ${BASE} + +${BASE}.nosym: ${BASE}.sym + cp ${BASE}.sym ${BASE}.nosym + strip ${BASE}.nosym + +${BASE}.sym: ${OBJS} ${LIBSTAND} ${LIBALPHA} ${CRT} vers.o setdef0.o setdef1.o + ${LD} -o ${BASE}.sym -M -e start -N -Ttext ${PRIMARY_LOAD_ADDRESS} \ + ${CRT} setdef0.o ${OBJS} setdef1.o \ + vers.o ${LIBSTAND} ${LIBALPHA} ${LIBSTAND} >${.OBJDIR}/${BASE}.list + +start.o: ${.CURDIR}/../libalpha/start.S + ${CC} -c -DPRIMARY_BOOTBLOCK $< + +setdef0.o: setdefs.h + +setdef1.o: setdefs.h + +.include + +setdefs.h: gensetdefs ${OBJS} + @echo Generating linker sets + @./gensetdefs ${OBJS} >setdefs.h + +gensetdefs: gensetdefs.o + ${CC} -static gensetdefs.o -o $@ + +gensetdefs.o: gensetdefs.c + ${CC} -c $< + Property changes on: cvs2svn/tags/initial/sys/boot/alpha/netboot/Makefile ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/netboot/conf.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/netboot/conf.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/netboot/conf.c (revision 49189) @@ -0,0 +1,89 @@ +/* + * $Id$ + * From: $NetBSD: conf.c,v 1.2 1997/03/22 09:03:29 thorpej Exp $ + */ + +/* + * Copyright (c) 1997 + * 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. + */ + + +#include +#include "libalpha/libalpha.h" +#include "dev_net.h" + +/* + * We could use linker sets for some or all of these, but + * then we would have to control what ended up linked into + * the bootstrap. So it's easier to conditionalise things + * here. + * + * XXX rename these arrays to be consistent and less namespace-hostile + */ + +/* Exported for libstand */ +struct devsw *devsw[] = { + &netdev, + NULL +}; + +struct fs_ops *file_system[] = { + &nfs_fsops, + &zipfs_fsops, + NULL +}; + +struct netif_driver *netif_drivers[] = { + &srmnet, + NULL, +}; + +/* Exported for alpha only */ +/* + * Sort formats so that those that can detect based on arguments + * rather than reading the file go first. + */ +struct module_format *module_formats[] = { + &alpha_elf, + NULL +}; + +/* + * Consoles + * + * We don't prototype these in libalpha.h because they require + * data structures from bootstrap.h as well. + */ +extern struct console promconsole; + +struct console *consoles[] = { + &promconsole, + NULL +}; Property changes on: cvs2svn/tags/initial/sys/boot/alpha/netboot/conf.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/netboot/netboot.list =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/netboot/netboot.list (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/netboot/netboot.list (revision 49189) @@ -0,0 +1,1177 @@ +Archive member included because of file (symbol) + +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nfs.o) + conf.o (nfs_fsops) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootparam.o) + dev_net.o (bp_whoami) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(rarp.o) + dev_net.o (rarp_getipaddress) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootp.o) + dev_net.o (bootp) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(rpc.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nfs.o) (rpc_port) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(stat.o) + ls.o (stat) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(dev.o) + dev_net.o (noioctl) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strncpy.o) + boot.o (strncpy) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcat.o) + misc.o (strcat) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(pager.o) + commands.o (pager_open) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) + ls.o (optind) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(environment.o) + commands.o (environ) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strtol.o) + boot.o (strtol) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strchr.o) + boot.o (strchr) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strerror.o) + commands.o (strerror) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strdup.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(environment.o) (strdup) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(gets.o) + interp.o (ngets) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) + conf.o (zipfs_fsops) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(read.o) + ls.o (read) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(open.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(read.o) (files) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(close.o) + interp.o (close) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(fstat.o) + ls.o (fstat) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nullfs.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) (null_write) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inflate.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) (inflateEnd) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infblock.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inflate.o) (inflate_blocks_reset) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(adler32.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inflate.o) (adler32) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strrchr.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) (strrchr) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcmp.o) + console.o (strcmp) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(twiddle.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nfs.o) (twiddle) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zutil.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inflate.o) (zcalloc) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inftrees.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infblock.o) (inflate_trees_bits) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infcodes.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infblock.o) (inflate_codes_new) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(alloc.o) + main.o (setheap) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inffast.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infcodes.o) (inflate_fast) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infutil.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infblock.o) (inflate_mask) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(net.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootp.o) (sendudp) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(in_cksum.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(net.o) (in_cksum) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(arp.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(net.o) (arpwhohas) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ntohl.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nfs.o) (ntohl) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(htonl.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nfs.o) (htonl) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ether.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(rarp.o) (sendether) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ntohs.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootparam.o) (ntohs) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(htons.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nfs.o) (htons) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcopy.o) + interp.o (bcopy) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcmp.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(rarp.o) (bcmp) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(rarp.o) (bcea) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(netif.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ether.o) (netif_get) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bzero.o) + start.o (bzero) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(printf.o) + main.o (printf) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__remqu.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strtol.o) (__remqu) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__divqu.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strtol.o) (__divqu) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strlen.o) + boot.o (strlen) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcd.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(printf.o) (hex2ascii_data) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(srmnet.o) + conf.o (srmnet) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(devicename.o) + main.o (alpha_getdev) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(alpha_module.o) + main.o (alpha_boot) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(time.o) + boot.o (time) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(delay.o) + main.o (delay) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(reboot.o) + main.o (reboot) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(elf_freebsd.o) + conf.o (alpha_elf) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(OSFpal.o) + main.o (OSFpal) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(getsecs.o) + /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootp.o) (getsecs) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(pal.o) + /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(delay.o) (alpha_rpcc) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(prom_swpal.o) + /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(OSFpal.o) (switch_palcode) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(prom.o) + conf.o (promconsole) +/mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(prom_disp.o) + /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(prom.o) (prom_dispatch_v) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(lseek.o) + /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(elf_freebsd.o) (lseek) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(closeall.o) + /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(elf_freebsd.o) (closeall) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strncmp.o) + /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(devicename.o) (strncmp) +/home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcpy.o) + /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(devicename.o) (strcpy) + +Allocating common symbols +Common symbol size file + +servip 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootp.o) +domainname 0x80 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +nameip 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +hostnamelen 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +command_errmsg 0x8 commands.o +rpc_pmap_list 0x80 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(rpc.o) +errno 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +bp_server_addr 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootparam.o) +ffp_save 0x8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(elf_freebsd.o) +swapip 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +rootip 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +optarg 0x8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) +rpc_xid 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(rpc.o) +myip 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +hostname 0x80 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +archsw 0x18 main.o +ssym 0x8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(elf_freebsd.o) +console 0x4 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(prom.o) +command_errbuf 0x100 commands.o +currdev 0x18 main.o +dhcp_serverip 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootp.o) +bootfile 0x80 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +ptbr_save 0x8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(elf_freebsd.o) +gateip 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +sockets 0x140 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(netif.o) +files 0x180 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(open.o) +bp_server_port 0x2 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootparam.o) +prom_stats 0x1c /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(srmnet.o) +ifname 0x10 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +domainnamelen 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) +optreset 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) +rpc_pmap_num 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(rpc.o) +broken_firmware 0x4 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(srmnet.o) +optopt 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) +prom_dispatch_v 0x10 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(prom_disp.o) +esym 0x8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(elf_freebsd.o) + +Memory Configuration + +Name Origin Length +*default* 0x0000000000000000 0xffffffffffffffff + +Linker script and memory map + +Address of section .text set to 0x20000000 +LOAD start.o +LOAD setdef0.o +LOAD main.o +LOAD conf.o +LOAD dev_net.o +LOAD boot.o +LOAD commands.o +LOAD console.o +LOAD devopen.o +LOAD interp.o +LOAD ls.o +LOAD misc.o +LOAD module.o +LOAD panic.o +LOAD setdef1.o +LOAD vers.o +LOAD /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a +LOAD /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a +LOAD /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a + 0x00000001200000b0 .=(0x120000000+SIZEOF_HEADERS) + +.interp + *(.interp) + +.hash + *(.hash) + +.dynsym + *(.dynsym) + +.dynstr + *(.dynstr) + +.gnu.version + *(.gnu.version) + +.gnu.version_d + *(.gnu.version_d) + +.gnu.version_r + *(.gnu.version_r) + +.rel.text + *(.rel.text) + *(.rel.gnu.linkonce.t*) + +.rela.text + *(.rela.text) + *(.rela.gnu.linkonce.t*) + +.rel.data + *(.rel.data) + *(.rel.gnu.linkonce.d*) + +.rela.data 0x00000001200000b0 0x0 + *(.rela.data) + *(.rela.gnu.linkonce.d*) + +.rela.set.Xcommand_set + 0x00000001200000b0 0x0 + +.rel.rodata + *(.rel.rodata) + *(.rel.gnu.linkonce.r*) + +.rela.rodata + *(.rela.rodata) + *(.rela.gnu.linkonce.r*) + +.rel.got + *(.rel.got) + +.rela.got + *(.rela.got) + +.rel.ctors + *(.rel.ctors) + +.rela.ctors + *(.rela.ctors) + +.rel.dtors + *(.rel.dtors) + +.rela.dtors + *(.rela.dtors) + +.rel.init + *(.rel.init) + +.rela.init + *(.rela.init) + +.rel.fini + *(.rel.fini) + +.rela.fini + *(.rela.fini) + +.rel.bss + *(.rel.bss) + +.rela.bss + *(.rela.bss) + +.rel.plt + *(.rel.plt) + +.rela.plt + *(.rela.plt) + +.init + *(.init) + +.text 0x0000000020000000 0x12660 + *(.text) + .text 0x0000000020000000 0x48 start.o + 0x000000002000003c __main + 0x0000000020000038 _rtt + 0x0000000020000040 cpu_number + 0x0000000020000038 halt + 0x0000000020000000 start + *fill* 0x0000000020000048 0x18 1207895071 + .text 0x0000000020000060 0x3e0 main.o + 0x0000000020000060 memsize + 0x00000000200000c8 main + .text 0x0000000020000440 0x400 dev_net.o + .text 0x0000000020000840 0x580 boot.o + 0x0000000020000ae8 autoboot + .text 0x0000000020000dc0 0x3e0 commands.o + .text 0x00000000200011a0 0x480 console.o + 0x00000000200013f8 putchar + 0x00000000200011a0 cons_probe + 0x0000000020001368 ischar + 0x00000000200012a8 getchar + .text 0x0000000020001620 0xf0 devopen.o + 0x00000000200016d0 devclose + 0x0000000020001620 devopen + *fill* 0x0000000020001710 0x10 1207895071 + .text 0x0000000020001720 0x5c0 interp.o + 0x00000000200019e8 interact + 0x0000000020001b00 source + .text 0x0000000020001ce0 0x480 ls.o + .text 0x0000000020002160 0x140 misc.o + 0x0000000020002160 unargv + .text 0x00000000200022a0 0x3a0 module.o + 0x0000000020002578 mod_findmodule + 0x00000000200023d0 mod_load + .text 0x0000000020002640 0xf0 panic.o + 0x0000000020002640 panic + *fill* 0x0000000020002730 0x10 1207895071 + .text 0x0000000020002740 0xe20 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nfs.o) + 0x0000000020002740 nfs_getrootfh + 0x0000000020002c00 nfs_readdata + 0x0000000020002dd0 nfs_open + 0x00000000200028d0 nfs_lookupfh + 0x0000000020002aa0 nfs_readlink + .text 0x0000000020003560 0x890 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootparam.o) + 0x0000000020003560 bp_whoami + 0x0000000020003848 bp_getfile + 0x0000000020003b08 xdr_string_decode + 0x0000000020003bd0 xdr_inaddr_encode + 0x0000000020003a60 xdr_string_encode + 0x0000000020003cb8 xdr_inaddr_decode + .text 0x0000000020003df0 0x420 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(rarp.o) + 0x0000000020003df0 rarp_getipaddress + *fill* 0x0000000020004210 0x10 1207895071 + .text 0x0000000020004220 0x960 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootp.o) + 0x0000000020004220 bootp + .text 0x0000000020004b80 0x660 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(rpc.o) + 0x0000000020004f18 rpc_fromaddr + 0x0000000020004f58 rpc_pmap_getcache + 0x0000000020004b80 rpc_call + 0x0000000020004ff8 rpc_pmap_putcache + .text 0x00000000200051e0 0x90 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(stat.o) + 0x00000000200051e0 stat + .text 0x0000000020005270 0x18 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(dev.o) + 0x0000000020005270 nodev + 0x0000000020005280 noioctl + 0x0000000020005278 nullsys + *fill* 0x0000000020005288 0x18 1207895071 + .text 0x00000000200052a0 0xa0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strncpy.o) + 0x00000000200052a0 strncpy + .text 0x0000000020005340 0x80 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcat.o) + 0x0000000020005340 strcat + .text 0x00000000200053c0 0x380 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(pager.o) + 0x0000000020005468 pager_output + 0x0000000020005450 pager_close + 0x0000000020005618 pager_file + 0x00000000200053c0 pager_open + .text 0x0000000020005740 0x310 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) + 0x0000000020005740 getopt + *fill* 0x0000000020005a50 0x10 1207895071 + .text 0x0000000020005a60 0x4a0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(environment.o) + 0x0000000020005dc8 unsetenv + 0x0000000020005ef0 env_nounset + 0x0000000020005cc0 getenv + 0x0000000020005d68 putenv + 0x0000000020005ee8 env_noset + 0x0000000020005d00 setenv + 0x0000000020005a60 env_getenv + 0x0000000020005ae0 env_setenv + .text 0x0000000020005f00 0x260 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strtol.o) + 0x0000000020005f00 strtol + .text 0x0000000020006160 0x60 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strchr.o) + 0x0000000020006160 strchr + .text 0x00000000200061c0 0xa0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strerror.o) + 0x00000000200061c0 strerror + .text 0x0000000020006260 0xa0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strdup.o) + 0x0000000020006260 strdup + .text 0x0000000020006300 0x340 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(gets.o) + 0x0000000020006530 fgetstr + 0x0000000020006300 ngets + .text 0x0000000020006640 0x8e0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) + 0x0000000020006640 calloc + .text 0x0000000020006f20 0x150 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(read.o) + 0x0000000020006f20 read + *fill* 0x0000000020007070 0x10 1207895071 + .text 0x0000000020007080 0x220 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(open.o) + 0x00000000200070c8 open + .text 0x00000000200072a0 0x130 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(close.o) + 0x00000000200072a0 close + .text 0x00000000200073d0 0xa0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(fstat.o) + 0x00000000200073d0 fstat + .text 0x0000000020007470 0xa8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nullfs.o) + 0x00000000200074b8 null_write + 0x00000000200074f8 null_stat + 0x0000000020007490 null_close + 0x0000000020007498 null_read + 0x0000000020007470 null_open + 0x00000000200074d8 null_seek + *fill* 0x0000000020007518 0x8 1207895071 + .text 0x0000000020007520 0xc00 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inflate.o) + 0x00000000200077d0 inflate + 0x00000000200080b0 inflateSyncPoint + 0x00000000200077a0 inflateInit_ + 0x0000000020007520 inflateReset + 0x0000000020007f18 inflateSync + 0x0000000020007e10 inflateSetDictionary + 0x00000000200075a0 inflateEnd + 0x0000000020007630 inflateInit2_ + .text 0x0000000020008120 0x1400 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infblock.o) + 0x0000000020009428 inflate_blocks_free + 0x0000000020008310 inflate_blocks + 0x0000000020008120 inflate_blocks_reset + 0x0000000020009510 inflate_blocks_sync_point + 0x00000000200094b0 inflate_set_dictionary + 0x00000000200081f0 inflate_blocks_new + .text 0x0000000020009520 0x240 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(adler32.o) + 0x0000000020009520 adler32 + .text 0x0000000020009760 0x60 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strrchr.o) + 0x0000000020009760 strrchr + .text 0x00000000200097c0 0xa0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcmp.o) + 0x00000000200097c0 strcmp + .text 0x0000000020009860 0x70 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(twiddle.o) + 0x0000000020009860 twiddle + .text 0x00000000200098d0 0x98 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zutil.o) + 0x00000000200098d0 zlibVersion + 0x0000000020009938 zcfree + 0x00000000200098e0 zError + 0x0000000020009900 zcalloc + *fill* 0x0000000020009968 0x18 1207895071 + .text 0x0000000020009980 0xd40 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inftrees.o) + 0x000000002000a3d8 inflate_trees_fixed + 0x000000002000a0b8 inflate_trees_bits + 0x000000002000a1e0 inflate_trees_dynamic + .text 0x000000002000a6c0 0xc40 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infcodes.o) + 0x000000002000a6c0 inflate_codes_new + 0x000000002000a768 inflate_codes + 0x000000002000b2c0 inflate_codes_free + .text 0x000000002000b300 0x1e0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(alloc.o) + 0x000000002000b300 setheap + 0x000000002000b328 malloc + 0x000000002000b4b8 sbrk + 0x000000002000b420 free + .text 0x000000002000b4e0 0x540 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inffast.o) + 0x000000002000b4e0 inflate_fast + .text 0x000000002000ba20 0x1e0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infutil.o) + 0x000000002000ba20 inflate_flush + .text 0x000000002000bc00 0xe00 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(net.o) + 0x000000002000c6e0 intoa + 0x000000002000c8a0 ip_convertaddr + 0x000000002000c518 inet_addr + 0x000000002000c358 sendrecv + 0x000000002000bc00 sendudp + 0x000000002000c6b0 inet_ntoa + 0x000000002000bf90 readudp + .text 0x000000002000ca00 0x120 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(in_cksum.o) + 0x000000002000ca00 in_cksum + .text 0x000000002000cb20 0x6c0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(arp.o) + 0x000000002000cfd0 arp_reply + 0x000000002000cb20 arpwhohas + .text 0x000000002000d1e0 0x2c /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ntohl.o) + 0x000000002000d1e0 ntohl + .text 0x000000002000d20c 0x2c /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(htonl.o) + 0x000000002000d20c htonl + *fill* 0x000000002000d238 0x8 1207895071 + .text 0x000000002000d240 0x2e0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ether.o) + 0x000000002000d460 ether_sprintf + 0x000000002000d240 sendether + 0x000000002000d358 readether + .text 0x000000002000d520 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ntohs.o) + 0x000000002000d520 ntohs + .text 0x000000002000d534 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(htons.o) + 0x000000002000d534 htons + .text 0x000000002000d548 0x25c /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcopy.o) + 0x000000002000d548 bcopy + *fill* 0x000000002000d7a4 0x1c 1207895071 + .text 0x000000002000d7c0 0x60 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcmp.o) + 0x000000002000d7c0 bcmp + .text 0x000000002000d820 0x8c0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(netif.o) + 0x000000002000dbb0 netif_probe + 0x000000002000df48 netif_open + 0x000000002000d8e0 netif_match + 0x000000002000dce8 netif_detach + 0x000000002000de38 netif_put + 0x000000002000dc30 netif_attach + 0x000000002000df08 socktodesc + 0x000000002000d910 netif_select + 0x000000002000dd58 netif_get + 0x000000002000d820 netif_init + 0x000000002000e070 netif_close + .text 0x000000002000e0e0 0xb0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bzero.o) + 0x000000002000e0e0 bzero + *fill* 0x000000002000e190 0x10 1207895071 + .text 0x000000002000e1a0 0x11c0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(printf.o) + 0x000000002000e1a0 printf + 0x000000002000e220 vprintf + 0x000000002000e260 sprintf + .text 0x000000002000f360 0xe4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__remqu.o) + 0x000000002000f360 __remqu + .text 0x000000002000f444 0xdc /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__divqu.o) + 0x000000002000f444 __divqu + .text 0x000000002000f520 0x40 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strlen.o) + 0x000000002000f520 strlen + .text 0x000000002000f560 0xa70 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(srmnet.o) + 0x000000002000f650 prom_get + 0x000000002000f560 prom_match + 0x000000002000f598 prom_probe + 0x000000002000f810 prom_init + 0x000000002000f5d0 prom_put + 0x000000002000ff28 prom_end + .text 0x000000002000ffd0 0x8e0 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(devicename.o) + 0x0000000020010638 alpha_fmtdev + 0x000000002000ffd0 alpha_getdev + 0x00000000200107e8 alpha_setcurrdev + .text 0x00000000200108b0 0x138 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(alpha_module.o) + 0x00000000200108b0 alpha_boot + 0x00000000200109b8 alpha_autoload + .text 0x00000000200109e8 0x68 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(time.o) + 0x00000000200109e8 time + .text 0x0000000020010a50 0xb0 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(delay.o) + 0x0000000020010a50 delay + .text 0x0000000020010b00 0x120 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(reboot.o) + 0x0000000020010b00 reboot + 0x0000000020010b88 exit + .text 0x0000000020010c20 0xdd0 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(elf_freebsd.o) + .text 0x00000000200119f0 0x120 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(OSFpal.o) + 0x00000000200119f0 OSFpal + .text 0x0000000020011b10 0x1c8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(getsecs.o) + 0x0000000020011b10 getsecs + .text 0x0000000020011cd8 0xcc /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(pal.o) + 0x0000000020011ce0 alpha_mb + 0x0000000020011d54 alpha_pal_tbi + 0x0000000020011d8c alpha_pal_wrmces + 0x0000000020011d94 alpha_pal_wrval + 0x0000000020011d84 alpha_pal_wrvptptr + 0x0000000020011d00 alpha_pal_imb + 0x0000000020011d74 alpha_pal_wripir + 0x0000000020011d7c alpha_pal_wrusp + 0x0000000020011d3c alpha_pal_rdval + 0x0000000020011d9c alpha_pal_swpctx + 0x0000000020011d08 alpha_pal_cflush + 0x0000000020011d4c _alpha_pal_swpipl + 0x0000000020011cd8 alpha_rpcc + 0x0000000020011cf0 alpha_amask + 0x0000000020011d18 alpha_pal_halt + 0x0000000020011d64 alpha_pal_wrent + 0x0000000020011d34 alpha_pal_rdusp + 0x0000000020011d2c alpha_pal_rdps + 0x0000000020011cf8 alpha_implver + 0x0000000020011d24 alpha_pal_rdmces + 0x0000000020011d44 alpha_pal_swpipl + 0x0000000020011d5c alpha_pal_whami + 0x0000000020011ce8 alpha_wmb + 0x0000000020011d10 alpha_pal_draina + 0x0000000020011d6c alpha_pal_wrfen + *fill* 0x0000000020011da4 0xc 1207895071 + .text 0x0000000020011db0 0xc0 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(prom_swpal.o) + 0x0000000020011db0 switch_palcode + .text 0x0000000020011e70 0x4e8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(prom.o) + 0x0000000020011e70 init_prom_calls + 0x00000000200121e0 prom_getenv + 0x0000000020011f98 prom_putchar + 0x0000000020012040 prom_getchar + 0x00000000200122c0 prom_open + *fill* 0x0000000020012358 0x8 1207895071 + .text 0x0000000020012360 0x70 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(prom_disp.o) + 0x0000000020012360 prom_dispatch + .text 0x00000000200123d0 0xe0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(lseek.o) + 0x00000000200123d0 lseek + *fill* 0x00000000200124b0 0x10 1207895071 + .text 0x00000000200124c0 0x80 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(closeall.o) + 0x00000000200124c0 closeall + .text 0x0000000020012540 0xa0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strncmp.o) + 0x0000000020012540 strncmp + .text 0x00000000200125e0 0x80 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcpy.o) + 0x00000000200125e0 strcpy + *(.gnu.warning) + *(.gnu.linkonce.t*) + 0x0000000020012660 _etext=. + 0x0000000020012660 PROVIDE (etext, .) + +.fini + *(.fini) + +.rodata 0x0000000020012660 0x1e88 + *(.rodata) + .rodata 0x0000000020012660 0x128 main.o + .rodata 0x0000000020012788 0x1f0 dev_net.o + .rodata 0x0000000020012978 0x188 boot.o + .rodata 0x0000000020012b00 0x168 commands.o + .rodata 0x0000000020012c68 0x30 console.o + .rodata 0x0000000020012c98 0xa0 interp.o + .rodata 0x0000000020012d38 0xa8 ls.o + .rodata 0x0000000020012de0 0x18 misc.o + .rodata 0x0000000020012df8 0xb8 module.o + .rodata 0x0000000020012eb0 0x28 panic.o + .rodata 0x0000000020012ed8 0x48 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nfs.o) + .rodata 0x0000000020012f20 0x50 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootparam.o) + .rodata 0x0000000020012f70 0x38 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(rarp.o) + .rodata 0x0000000020012fa8 0x70 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootp.o) + .rodata 0x0000000020013018 0x50 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(rpc.o) + .rodata 0x0000000020013068 0xa8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(pager.o) + .rodata 0x0000000020013110 0x48 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) + .rodata 0x0000000020013158 0x8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(environment.o) + .rodata 0x0000000020013160 0x8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strtol.o) + .rodata 0x0000000020013168 0x2a0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strerror.o) + .rodata 0x0000000020013408 0xc0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) + .rodata 0x00000000200134c8 0xb8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inflate.o) + .rodata 0x0000000020013580 0xf8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infblock.o) + .rodata 0x0000000020013678 0x8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(adler32.o) + .rodata 0x0000000020013680 0x8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(twiddle.o) + .rodata 0x0000000020013688 0xa0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zutil.o) + .rodata 0x0000000020013728 0x318 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inftrees.o) + 0x0000000020013728 inflate_copyright + .rodata 0x0000000020013a40 0x60 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infcodes.o) + .rodata 0x0000000020013aa0 0x60 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(alloc.o) + .rodata 0x0000000020013b00 0x38 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inffast.o) + .rodata 0x0000000020013b38 0x70 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(net.o) + .rodata 0x0000000020013ba8 0x48 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(arp.o) + .rodata 0x0000000020013bf0 0x168 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(netif.o) + .rodata 0x0000000020013d58 0x170 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(printf.o) + .rodata 0x0000000020013ec8 0x130 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcd.o) + 0x0000000020013fd0 hex2ascii_data + 0x0000000020013ec8 bcd2bin_data + 0x0000000020013f68 bin2bcd_data + .rodata 0x0000000020013ff8 0x250 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(srmnet.o) + .rodata 0x0000000020014248 0x40 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(devicename.o) + .rodata 0x0000000020014288 0x8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(delay.o) + .rodata 0x0000000020014290 0x198 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(elf_freebsd.o) + .rodata 0x0000000020014428 0x98 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(OSFpal.o) + .rodata 0x00000000200144c0 0x8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(getsecs.o) + .rodata 0x00000000200144c8 0x20 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(prom.o) + *(.gnu.linkonce.r*) + +.rodata1 + *(.rodata1) + +.reginfo + *(.reginfo) + 0x00000000200144e8 .=. + +.data 0x00000000200144e8 0x810 + *(.data) + .data 0x00000000200144e8 0x48 main.o + .data 0x0000000020014530 0x58 conf.o + 0x0000000020014568 module_formats + 0x0000000020014558 netif_drivers + 0x0000000020014540 file_system + 0x0000000020014578 consoles + 0x0000000020014530 devsw + .data 0x0000000020014588 0x48 dev_net.o + 0x0000000020014590 netdev + 0x0000000020014588 debug + 0x00000000200145c8 try_bootp + .data 0x00000000200145d0 0x40 boot.o + .data 0x0000000020014610 0x90 commands.o + .data 0x00000000200146a0 0x18 interp.o + .data 0x00000000200146b8 0x28 ls.o + .data 0x00000000200146e0 0x40 module.o + 0x00000000200146e8 loaded_modules + .data 0x0000000020014720 0x68 vers.o + 0x0000000020014740 bootprog_rev + 0x0000000020014748 bootprog_date + 0x0000000020014768 bootprog_maker + 0x0000000020014720 bootprog_name + .data 0x0000000020014788 0x58 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nfs.o) + 0x00000000200147c0 nfs_stat_types + 0x0000000020014788 nfs_fsops + .data 0x00000000200147e0 0x8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootp.o) + .data 0x00000000200147e8 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(rpc.o) + 0x00000000200147e8 rpc_port + *fill* 0x00000000200147ec 0x4 + .data 0x00000000200147f0 0x18 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(pager.o) + .data 0x0000000020014808 0x10 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) + 0x0000000020014808 opterr + 0x000000002001480c optind + .data 0x0000000020014818 0x8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(environment.o) + 0x0000000020014818 environ + .data 0x0000000020014820 0x1d0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strerror.o) + .data 0x00000000200149f0 0x40 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) + 0x00000000200149f0 zipfs_fsops + .data 0x0000000020014a30 0x50 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zutil.o) + 0x0000000020014a30 z_errmsg + .data 0x0000000020014a80 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inftrees.o) + *fill* 0x0000000020014a84 0x4 + .data 0x0000000020014a88 0x8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(alloc.o) + 0x0000000020014a88 freelist + .data 0x0000000020014a90 0x44 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infutil.o) + 0x0000000020014a90 inflate_mask + .data 0x0000000020014ad4 0x64 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(arp.o) + 0x0000000020014b34 arp_num + 0x0000000020014ad4 arp_list + .data 0x0000000020014b38 0x18 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ether.o) + .data 0x0000000020014b50 0x90 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) + 0x0000000020014b58 rootpath + 0x0000000020014bd8 netmask + 0x0000000020014b50 bcea + .data 0x0000000020014be0 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(netif.o) + 0x0000000020014be0 netif_debug + *fill* 0x0000000020014be4 0x4 + .data 0x0000000020014be8 0xb0 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(srmnet.o) + 0x0000000020014c08 netbbinfo + 0x0000000020014c90 netfd + 0x0000000020014be8 prom_ifs + 0x0000000020014c48 srmnet + .data 0x0000000020014c98 0x18 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(elf_freebsd.o) + 0x0000000020014c98 alpha_elf + .data 0x0000000020014cb0 0x48 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(prom.o) + 0x0000000020014cb0 promconsole + *(.gnu.linkonce.d*) + +.set.Xcommand_set + 0x0000000020014cf8 0x88 + .set.Xcommand_set + 0x0000000020014cf8 0x8 setdef0.o + 0x0000000020014cf8 Xcommand_set + .set.Xcommand_set + 0x0000000020014d00 0x18 main.o + .set.Xcommand_set + 0x0000000020014d18 0x10 boot.o + .set.Xcommand_set + 0x0000000020014d28 0x30 commands.o + .set.Xcommand_set + 0x0000000020014d58 0x8 interp.o + .set.Xcommand_set + 0x0000000020014d60 0x8 ls.o + .set.Xcommand_set + 0x0000000020014d68 0x10 module.o + .set.Xcommand_set + 0x0000000020014d78 0x8 setdef1.o + +.data1 + *(.data1) + +.ctors + *(.ctors) + +.dtors + *(.dtors) + +.plt + *(.plt) + +.got 0x0000000020014d80 0xeb8 + *(.got.plt) + *(.got) + .got 0x0000000020014d80 0xeb8 start.o + +.dynamic + *(.dynamic) + +.sdata + *(.sdata) + 0x0000000020015c38 _edata=. + 0x0000000020015c38 PROVIDE (edata, .) + 0x0000000020015c38 __bss_start=. + +.sbss + *(.sbss) + *(.scommon) + +.bss 0x0000000020015c40 0x24f0 + *(.dynbss) + *(.bss) + .bss 0x0000000020015c40 0x4 dev_net.o + *fill* 0x0000000020015c44 0x4 + .bss 0x0000000020015c48 0xb0 interp.o + .bss 0x0000000020015cf8 0x78 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nfs.o) + .bss 0x0000000020015d70 0x10 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootp.o) + .bss 0x0000000020015d80 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(pager.o) + .bss 0x0000000020015d84 0x20 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strerror.o) + *fill* 0x0000000020015da4 0x4 + .bss 0x0000000020015da8 0x8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) + .bss 0x0000000020015db0 0x4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(twiddle.o) + *fill* 0x0000000020015db4 0x4 + .bss 0x0000000020015db8 0x1a98 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inftrees.o) + .bss 0x0000000020017850 0x18 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(alloc.o) + .bss 0x0000000020017868 0x11 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(net.o) + .bss 0x0000000020017879 0x12 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ether.o) + *fill* 0x000000002001788b 0x5 + .bss 0x0000000020017890 0x18 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(netif.o) + .bss 0x00000000200178a8 0x17 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(printf.o) + .bss 0x00000000200178bf 0x80 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(devicename.o) + *fill* 0x000000002001793f 0x1 + .bss 0x0000000020017940 0x100 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(elf_freebsd.o) + .bss 0x0000000020017a40 0x18 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(getsecs.o) + *(COMMON) + COMMON 0x0000000020017a58 0x30 main.o + 0x0000000020017a58 archsw + 0x0000000020017a70 currdev + *fill* 0x0000000020017a88 0x8 + COMMON 0x0000000020017a90 0x110 commands.o + 0x0000000020017a90 command_errmsg + 0x0000000020017aa0 command_errbuf + COMMON 0x0000000020017ba0 0x6 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootparam.o) + 0x0000000020017ba0 bp_server_addr + 0x0000000020017ba4 bp_server_port + *fill* 0x0000000020017ba6 0x2 + COMMON 0x0000000020017ba8 0x8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootp.o) + 0x0000000020017ba8 servip + 0x0000000020017bac dhcp_serverip + COMMON 0x0000000020017bb0 0x88 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(rpc.o) + 0x0000000020017bb0 rpc_pmap_list + 0x0000000020017c30 rpc_xid + 0x0000000020017c34 rpc_pmap_num + COMMON 0x0000000020017c38 0x10 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) + 0x0000000020017c38 optarg + 0x0000000020017c40 optreset + 0x0000000020017c44 optopt + COMMON 0x0000000020017c48 0x180 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(open.o) + 0x0000000020017c48 files + *fill* 0x0000000020017dc8 0x8 + COMMON 0x0000000020017dd0 0x1c4 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) + 0x0000000020017dd0 domainname + 0x0000000020017e50 nameip + 0x0000000020017e54 hostnamelen + 0x0000000020017e58 errno + 0x0000000020017e5c swapip + 0x0000000020017e60 rootip + 0x0000000020017e64 myip + 0x0000000020017e70 hostname + 0x0000000020017ef0 bootfile + 0x0000000020017f70 gateip + 0x0000000020017f80 ifname + 0x0000000020017f90 domainnamelen + *fill* 0x0000000020017f94 0x4 + COMMON 0x0000000020017f98 0x140 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(netif.o) + 0x0000000020017f98 sockets + COMMON 0x00000000200180d8 0x20 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(srmnet.o) + 0x00000000200180d8 prom_stats + 0x00000000200180f4 broken_firmware + COMMON 0x00000000200180f8 0x20 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(elf_freebsd.o) + 0x00000000200180f8 ffp_save + 0x0000000020018100 ssym + 0x0000000020018108 ptbr_save + 0x0000000020018110 esym + COMMON 0x0000000020018118 0x4 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(prom.o) + 0x0000000020018118 console + *fill* 0x000000002001811c 0x4 + COMMON 0x0000000020018120 0x10 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(prom_disp.o) + 0x0000000020018120 prom_dispatch_v + 0x0000000020018130 _end=. + 0x0000000020018130 PROVIDE (end, .) + +.stab + *(.stab) + +.stabstr + *(.stabstr) + +.stab.excl + *(.stab.excl) + +.stab.exclstr + *(.stab.exclstr) + +.stab.index + *(.stab.index) + +.stab.indexstr + *(.stab.indexstr) + +.comment 0x0000000000000000 0x5c8 + *(.comment) + .comment 0x0000000000000000 0x14 setdef0.o + .comment 0x0000000000000014 0x14 main.o + .comment 0x0000000000000028 0x14 conf.o + .comment 0x000000000000003c 0x14 dev_net.o + .comment 0x0000000000000050 0x14 boot.o + .comment 0x0000000000000064 0x14 commands.o + .comment 0x0000000000000078 0x14 console.o + .comment 0x000000000000008c 0x14 devopen.o + .comment 0x00000000000000a0 0x14 interp.o + .comment 0x00000000000000b4 0x14 ls.o + .comment 0x00000000000000c8 0x14 misc.o + .comment 0x00000000000000dc 0x14 module.o + .comment 0x00000000000000f0 0x14 panic.o + .comment 0x0000000000000104 0x14 setdef1.o + .comment 0x0000000000000118 0x14 vers.o + .comment 0x000000000000012c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nfs.o) + .comment 0x0000000000000140 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootparam.o) + .comment 0x0000000000000154 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(rarp.o) + .comment 0x0000000000000168 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootp.o) + .comment 0x000000000000017c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(rpc.o) + .comment 0x0000000000000190 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(stat.o) + .comment 0x00000000000001a4 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(dev.o) + .comment 0x00000000000001b8 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strncpy.o) + .comment 0x00000000000001cc 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcat.o) + .comment 0x00000000000001e0 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(pager.o) + .comment 0x00000000000001f4 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) + .comment 0x0000000000000208 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(environment.o) + .comment 0x000000000000021c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strtol.o) + .comment 0x0000000000000230 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strchr.o) + .comment 0x0000000000000244 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strerror.o) + .comment 0x0000000000000258 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strdup.o) + .comment 0x000000000000026c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(gets.o) + .comment 0x0000000000000280 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) + .comment 0x0000000000000294 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(read.o) + .comment 0x00000000000002a8 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(open.o) + .comment 0x00000000000002bc 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(close.o) + .comment 0x00000000000002d0 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(fstat.o) + .comment 0x00000000000002e4 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nullfs.o) + .comment 0x00000000000002f8 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inflate.o) + .comment 0x000000000000030c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infblock.o) + .comment 0x0000000000000320 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(adler32.o) + .comment 0x0000000000000334 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strrchr.o) + .comment 0x0000000000000348 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcmp.o) + .comment 0x000000000000035c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(twiddle.o) + .comment 0x0000000000000370 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zutil.o) + .comment 0x0000000000000384 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inftrees.o) + .comment 0x0000000000000398 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infcodes.o) + .comment 0x00000000000003ac 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(alloc.o) + .comment 0x00000000000003c0 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inffast.o) + .comment 0x00000000000003d4 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infutil.o) + .comment 0x00000000000003e8 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(net.o) + .comment 0x00000000000003fc 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(in_cksum.o) + .comment 0x0000000000000410 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(arp.o) + .comment 0x0000000000000424 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ether.o) + .comment 0x0000000000000438 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcmp.o) + .comment 0x000000000000044c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) + .comment 0x0000000000000460 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(netif.o) + .comment 0x0000000000000474 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(printf.o) + .comment 0x0000000000000488 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strlen.o) + .comment 0x000000000000049c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcd.o) + .comment 0x00000000000004b0 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(srmnet.o) + .comment 0x00000000000004c4 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(devicename.o) + .comment 0x00000000000004d8 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(alpha_module.o) + .comment 0x00000000000004ec 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(time.o) + .comment 0x0000000000000500 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(delay.o) + .comment 0x0000000000000514 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(reboot.o) + .comment 0x0000000000000528 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(elf_freebsd.o) + .comment 0x000000000000053c 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(OSFpal.o) + .comment 0x0000000000000550 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(getsecs.o) + .comment 0x0000000000000564 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(prom.o) + .comment 0x0000000000000578 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(lseek.o) + .comment 0x000000000000058c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(closeall.o) + .comment 0x00000000000005a0 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strncmp.o) + .comment 0x00000000000005b4 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcpy.o) + +.debug + *(.debug) + +.line + *(.line) + +.debug_srcinfo + *(.debug_srcinfo) + +.debug_sfnames + *(.debug_sfnames) + +.debug_aranges + *(.debug_aranges) + +.debug_pubnames + *(.debug_pubnames) + +.debug_info + *(.debug_info) + +.debug_abbrev + *(.debug_abbrev) + +.debug_line + *(.debug_line) + +.debug_frame + *(.debug_frame) + +.debug_str + *(.debug_str) + +.debug_loc + *(.debug_loc) + +.debug_macinfo + *(.debug_macinfo) + +.debug_weaknames + *(.debug_weaknames) + +.debug_funcnames + *(.debug_funcnames) + +.debug_typenames + *(.debug_typenames) + +.debug_varnames + *(.debug_varnames) +OUTPUT(netboot.sym elf64-alpha) + +.mdebug 0x00000000000005c8 0x10ef0 + .mdebug 0x00000000000005c8 0x858 start.o + .mdebug 0x0000000000000e20 0x1e0 setdef0.o + .mdebug 0x0000000000001000 0xab8 main.o + .mdebug 0x0000000000001ab8 0x330 conf.o + .mdebug 0x0000000000001de8 0xa28 dev_net.o + .mdebug 0x0000000000002810 0x8c0 boot.o + .mdebug 0x00000000000030d0 0xb00 commands.o + .mdebug 0x0000000000003bd0 0x788 console.o + .mdebug 0x0000000000004358 0x3d0 devopen.o + .mdebug 0x0000000000004728 0x968 interp.o + .mdebug 0x0000000000005090 0x540 ls.o + .mdebug 0x00000000000055d0 0x330 misc.o + .mdebug 0x0000000000005900 0x790 module.o + .mdebug 0x0000000000006090 0x310 panic.o + .mdebug 0x00000000000063a0 0x1b8 setdef1.o + .mdebug 0x0000000000006558 0x248 vers.o + .mdebug 0x00000000000067a0 0xd00 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nfs.o) + .mdebug 0x00000000000074a0 0xa40 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootparam.o) + .mdebug 0x0000000000007ee0 0x620 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(rarp.o) + .mdebug 0x0000000000008500 0x960 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootp.o) + .mdebug 0x0000000000008e60 0x908 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(rpc.o) + .mdebug 0x0000000000009768 0x308 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(stat.o) + .mdebug 0x0000000000009a70 0x418 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(dev.o) + .mdebug 0x0000000000009e88 0x288 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strncpy.o) + .mdebug 0x000000000000a110 0x288 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcat.o) + .mdebug 0x000000000000a398 0x7a0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(pager.o) + .mdebug 0x000000000000ab38 0x3d0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) + .mdebug 0x000000000000af08 0xa30 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(environment.o) + .mdebug 0x000000000000b938 0x318 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strtol.o) + .mdebug 0x000000000000bc50 0x288 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strchr.o) + .mdebug 0x000000000000bed8 0x350 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strerror.o) + .mdebug 0x000000000000c228 0x318 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strdup.o) + .mdebug 0x000000000000c540 0x3e0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(gets.o) + .mdebug 0x000000000000c920 0xc28 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) + .mdebug 0x000000000000d548 0x308 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(read.o) + .mdebug 0x000000000000d850 0x430 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(open.o) + .mdebug 0x000000000000dc80 0x310 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(close.o) + .mdebug 0x000000000000df90 0x2f0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(fstat.o) + .mdebug 0x000000000000e280 0x720 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nullfs.o) + .mdebug 0x000000000000e9a0 0xac8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inflate.o) + .mdebug 0x000000000000f468 0x9a0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infblock.o) + .mdebug 0x000000000000fe08 0x2c0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(adler32.o) + .mdebug 0x00000000000100c8 0x288 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strrchr.o) + .mdebug 0x0000000000010350 0x288 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcmp.o) + .mdebug 0x00000000000105d8 0x318 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(twiddle.o) + .mdebug 0x00000000000108f0 0x590 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zutil.o) + .mdebug 0x0000000000010e80 0x830 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inftrees.o) + .mdebug 0x00000000000116b0 0x538 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infcodes.o) + .mdebug 0x0000000000011be8 0x618 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(alloc.o) + .mdebug 0x0000000000012200 0x2f8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inffast.o) + .mdebug 0x00000000000124f8 0x320 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infutil.o) + .mdebug 0x0000000000012818 0xad8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(net.o) + .mdebug 0x00000000000132f0 0x290 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(in_cksum.o) + .mdebug 0x0000000000013580 0x6f0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(arp.o) + .mdebug 0x0000000000013c70 0x888 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ntohl.o) + .mdebug 0x00000000000144f8 0x888 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(htonl.o) + .mdebug 0x0000000000014d80 0x5d8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ether.o) + .mdebug 0x0000000000015358 0x880 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ntohs.o) + .mdebug 0x0000000000015bd8 0x880 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(htons.o) + .mdebug 0x0000000000016458 0xbc0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcopy.o) + .mdebug 0x0000000000017018 0x278 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcmp.o) + .mdebug 0x0000000000017290 0x3a0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) + .mdebug 0x0000000000017630 0xc98 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(netif.o) + .mdebug 0x00000000000182c8 0x828 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bzero.o) + .mdebug 0x0000000000018af0 0x6e0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(printf.o) + .mdebug 0x00000000000191d0 0x708 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__remqu.o) + .mdebug 0x00000000000198d8 0x700 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(__divqu.o) + .mdebug 0x0000000000019fd8 0x288 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strlen.o) + .mdebug 0x000000000001a260 0x228 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcd.o) + .mdebug 0x000000000001a488 0x9b0 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(srmnet.o) + .mdebug 0x000000000001ae38 0x740 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(devicename.o) + .mdebug 0x000000000001b578 0x408 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(alpha_module.o) + .mdebug 0x000000000001b980 0x2d0 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(time.o) + .mdebug 0x000000000001bc50 0x2d8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(delay.o) + .mdebug 0x000000000001bf28 0x3a0 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(reboot.o) + .mdebug 0x000000000001c2c8 0x770 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(elf_freebsd.o) + .mdebug 0x000000000001ca38 0x320 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(OSFpal.o) + .mdebug 0x000000000001cd58 0x3b8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(getsecs.o) + .mdebug 0x000000000001d110 0x18b8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(pal.o) + .mdebug 0x000000000001e9c8 0xae0 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(prom_swpal.o) + .mdebug 0x000000000001f4a8 0x9b8 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(prom.o) + .mdebug 0x000000000001fe60 0xaa0 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(prom_disp.o) + .mdebug 0x0000000000020900 0x2f0 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(lseek.o) + .mdebug 0x0000000000020bf0 0x2f8 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(closeall.o) + .mdebug 0x0000000000020ee8 0x288 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strncmp.o) + .mdebug 0x0000000000021170 0x288 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcpy.o) + +.note 0x00000000000213f8 0x5c8 + .note 0x00000000000213f8 0x14 setdef0.o + .note 0x000000000002140c 0x14 main.o + .note 0x0000000000021420 0x14 conf.o + .note 0x0000000000021434 0x14 dev_net.o + .note 0x0000000000021448 0x14 boot.o + .note 0x000000000002145c 0x14 commands.o + .note 0x0000000000021470 0x14 console.o + .note 0x0000000000021484 0x14 devopen.o + .note 0x0000000000021498 0x14 interp.o + .note 0x00000000000214ac 0x14 ls.o + .note 0x00000000000214c0 0x14 misc.o + .note 0x00000000000214d4 0x14 module.o + .note 0x00000000000214e8 0x14 panic.o + .note 0x00000000000214fc 0x14 setdef1.o + .note 0x0000000000021510 0x14 vers.o + .note 0x0000000000021524 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nfs.o) + .note 0x0000000000021538 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootparam.o) + .note 0x000000000002154c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(rarp.o) + .note 0x0000000000021560 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bootp.o) + .note 0x0000000000021574 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(rpc.o) + .note 0x0000000000021588 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(stat.o) + .note 0x000000000002159c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(dev.o) + .note 0x00000000000215b0 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strncpy.o) + .note 0x00000000000215c4 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcat.o) + .note 0x00000000000215d8 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(pager.o) + .note 0x00000000000215ec 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(getopt.o) + .note 0x0000000000021600 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(environment.o) + .note 0x0000000000021614 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strtol.o) + .note 0x0000000000021628 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strchr.o) + .note 0x000000000002163c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strerror.o) + .note 0x0000000000021650 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strdup.o) + .note 0x0000000000021664 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(gets.o) + .note 0x0000000000021678 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zipfs.o) + .note 0x000000000002168c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(read.o) + .note 0x00000000000216a0 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(open.o) + .note 0x00000000000216b4 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(close.o) + .note 0x00000000000216c8 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(fstat.o) + .note 0x00000000000216dc 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(nullfs.o) + .note 0x00000000000216f0 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inflate.o) + .note 0x0000000000021704 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infblock.o) + .note 0x0000000000021718 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(adler32.o) + .note 0x000000000002172c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strrchr.o) + .note 0x0000000000021740 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcmp.o) + .note 0x0000000000021754 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(twiddle.o) + .note 0x0000000000021768 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(zutil.o) + .note 0x000000000002177c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inftrees.o) + .note 0x0000000000021790 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infcodes.o) + .note 0x00000000000217a4 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(alloc.o) + .note 0x00000000000217b8 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(inffast.o) + .note 0x00000000000217cc 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(infutil.o) + .note 0x00000000000217e0 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(net.o) + .note 0x00000000000217f4 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(in_cksum.o) + .note 0x0000000000021808 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(arp.o) + .note 0x000000000002181c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(ether.o) + .note 0x0000000000021830 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcmp.o) + .note 0x0000000000021844 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(globals.o) + .note 0x0000000000021858 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(netif.o) + .note 0x000000000002186c 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(printf.o) + .note 0x0000000000021880 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strlen.o) + .note 0x0000000000021894 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(bcd.o) + .note 0x00000000000218a8 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(srmnet.o) + .note 0x00000000000218bc 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(devicename.o) + .note 0x00000000000218d0 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(alpha_module.o) + .note 0x00000000000218e4 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(time.o) + .note 0x00000000000218f8 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(delay.o) + .note 0x000000000002190c 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(reboot.o) + .note 0x0000000000021920 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(elf_freebsd.o) + .note 0x0000000000021934 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(OSFpal.o) + .note 0x0000000000021948 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(getsecs.o) + .note 0x000000000002195c 0x14 /mnt/herring/b/dfr/FreeBSD/boot/newboot/alpha/netboot/../libalpha/obj/libalpha.a(prom.o) + .note 0x0000000000021970 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(lseek.o) + .note 0x0000000000021984 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(closeall.o) + .note 0x0000000000021998 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strncmp.o) + .note 0x00000000000219ac 0x14 /home/dfr/FreeBSD/alpha/src/lib/libstand/obj/libstand.a(strcpy.o) Property changes on: cvs2svn/tags/initial/sys/boot/alpha/netboot/netboot.list ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/netboot/newvers.sh =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/netboot/newvers.sh (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/netboot/newvers.sh (revision 49189) @@ -0,0 +1,44 @@ +#!/bin/sh - +# +# $NetBSD: newvers.sh,v 1.1 1997/07/26 01:50:38 thorpej Exp $ +# +# Copyright (c) 1984, 1986, 1990, 1993 +# The Regents of the University of California. 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 by the University of +# California, Berkeley and its contributors. +# 4. Neither the name of the University nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. +# +# @(#)newvers.sh 8.1 (Berkeley) 4/20/94 + +u=${USER-root} h=`hostname` t=`date` +r=`head -n 6 $1 | tail -n 1 | awk -F: ' { print $1 } '` + +echo "char bootprog_name[] = \"FreeBSD/alpha ${2}\";" > vers.c +echo "char bootprog_rev[] = \"${r}\";" >> vers.c +echo "char bootprog_date[] = \"${t}\";" >> vers.c +echo "char bootprog_maker[] = \"${u}@${h}\";" >> vers.c Property changes on: cvs2svn/tags/initial/sys/boot/alpha/netboot/newvers.sh ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/netboot/setdefs.h =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/netboot/setdefs.h (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/netboot/setdefs.h (revision 49189) @@ -0,0 +1,2 @@ +/* $Id$ */ +DEFINE_SET(Xcommand_set, 15); Property changes on: cvs2svn/tags/initial/sys/boot/alpha/netboot/setdefs.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/netboot/vers.c =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/netboot/vers.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/netboot/vers.c (revision 49189) @@ -0,0 +1,4 @@ +char bootprog_name[] = "FreeBSD/alpha SRM net boot"; +char bootprog_rev[] = "0.1"; +char bootprog_date[] = "Mon Aug 17 10:38:31 BST 1998"; +char bootprog_maker[] = "dfr@salmon.nlsystems.com"; Property changes on: cvs2svn/tags/initial/sys/boot/alpha/netboot/vers.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/alpha/netboot/version =================================================================== --- cvs2svn/tags/initial/sys/boot/alpha/netboot/version (nonexistent) +++ cvs2svn/tags/initial/sys/boot/alpha/netboot/version (revision 49189) @@ -0,0 +1,7 @@ +$Id$ + +NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this +file is important. Make sure the current version number is on line 6. + +0.1: Initial i386 version, germinated from the NetBSD i386 + standalone, but enormously modified. Property changes on: cvs2svn/tags/initial/sys/boot/alpha/netboot/version ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/common/Makefile.inc =================================================================== --- cvs2svn/tags/initial/sys/boot/common/Makefile.inc (nonexistent) +++ cvs2svn/tags/initial/sys/boot/common/Makefile.inc (revision 49189) @@ -0,0 +1,4 @@ +# $Id$ + +SRCS+= boot.c commands.c console.c devopen.c interp.c ls.c misc.c module.c +SRCS+= panic.c Property changes on: cvs2svn/tags/initial/sys/boot/common/Makefile.inc ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/common/boot.c =================================================================== --- cvs2svn/tags/initial/sys/boot/common/boot.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/common/boot.c (revision 49189) @@ -0,0 +1,229 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +/* + * Loading modules, booting the system + */ + +#include +#include + +#include "bootstrap.h" + +static char *getbootfile(int try); + +/* List of kernel names to try (may be overwritten by boot.config) XXX should move from here? */ +static char *default_bootfiles = "kernel,kernel.old"; + +/* + * The user wants us to boot. + */ +COMMAND_SET(boot, "boot", "boot a file or loaded kernel", command_boot); + +static int +command_boot(int argc, char *argv[]) +{ + struct loaded_module *km; + char *cp; + int try; + + /* + * See if the user has specified an explicit kernel to boot. + */ + if ((argc > 1) && (argv[1][0] != '-')) { + + /* XXX maybe we should discard everything and start again? */ + if (mod_findmodule(NULL, NULL) != NULL) { + sprintf(command_errbuf, "can't boot '%s', kernel module already loaded", argv[0]); + return(CMD_ERROR); + } + + /* find/load the kernel module */ + if (mod_load(argv[1], argc - 2, argv + 2) != 0) + return(CMD_ERROR); + /* we have consumed all arguments */ + argc = 1; + } + + /* + * See if there is a kernel module already loaded + */ + if (mod_findmodule(NULL, NULL) == NULL) { + for (try = 0; (cp = getbootfile(try)) != NULL; try++) { + if (mod_load(cp, argc - 1, argv + 1) != 0) { + printf("can't load '%s'\n", argv[0]); + } else { + /* we have consumed all arguments */ + argc = 1; + break; + } + } + } + + /* + * Loaded anything yet? + */ + if ((km = mod_findmodule(NULL, NULL)) == NULL) { + command_errmsg = "no bootable kernel"; + return(CMD_ERROR); + } + + /* + * If we were given arguments, discard any previous. + * XXX should we merge arguments? Hard to DWIM. + */ + if (argc > 1) { + if (km->m_args != NULL) + free(km->m_args); + km->m_args = unargv(argc - 1, argv + 1); + } + + /* Hook for platform-specific autoloading of modules */ + if (archsw.arch_autoload() != 0) + return(CMD_ERROR); + archsw.arch_boot(); + return(CMD_ERROR); +} + + +/* + * Autoboot after a delay + */ + +COMMAND_SET(autoboot, "autoboot", "boot automatically after a delay", command_autoboot); + +/* + * XXX note the 'prompt' argument is not really useful until quoting is implemented + */ +static int +command_autoboot(int argc, char *argv[]) +{ + int howlong; + char *cp, *prompt; + + prompt = NULL; + howlong = -1; + switch(argc) { + case 3: + prompt = argv[2]; + /* FALLTHROUGH */ + case 2: + howlong = strtol(argv[1], &cp, 0); + if (*cp != 0) { + sprintf(command_errbuf, "bad delay '%s'", argv[1]); + return(CMD_ERROR); + } + /* FALLTHROUGH */ + case 1: + return(autoboot(howlong, prompt)); + } + + command_errmsg = "too many arguments"; + return(CMD_ERROR); +} + +int +autoboot(int delay, char *prompt) +{ + time_t when, otime, ntime; + int c, yes; + char *argv[2]; + + if (delay == -1) + delay = 5; /* env var? compile-time define? */ + + otime = time(NULL); + when = otime + delay; /* when to boot */ + yes = 0; + + /* XXX could try to work out what we might boot */ + printf("%s\n", (prompt == NULL) ? "Hit [Enter] to boot immediately, or any other key for command prompt." : prompt); + + for (;;) { + if (ischar()) { + c = getchar(); + if ((c == '\r') || (c == '\n')) + yes = 1; + break; + } + ntime = time(NULL); + if (ntime == when) { + yes = 1; + break; + } + if (ntime != otime) { + printf("\rBooting [%s] in %d seconds...", getbootfile(0), (int)(when - ntime)); + otime = ntime; + } + } + printf("\n"); + if (yes) { + argv[0] = "boot"; + argv[1] = NULL; + return(command_boot(1, argv)); + } + return(CMD_OK); +} + +/* + * Scrounge for the name of the (try)'th file we will try to boot. + */ +static char * +getbootfile(int try) +{ + static char *name = NULL; + char *spec, *ep; + int len; + + /* we use dynamic storage */ + if (name != NULL) { + free(name); + name = NULL; + } + + /* + * Try $bootfile, then try our builtin default + */ + if ((spec = getenv("bootfile")) == NULL) + spec = default_bootfiles; + + while ((try > 0) && (spec != NULL)) + spec = strchr(spec, ','); + if (spec != NULL) { + if ((ep = strchr(spec, ',')) != NULL) { + len = ep - spec; + } else { + len = strlen(spec); + } + name = malloc(len + 1); + strncpy(name, spec, len); + name[len] = 0; + } + return(name); +} + Property changes on: cvs2svn/tags/initial/sys/boot/common/boot.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/common/bootstrap.h =================================================================== --- cvs2svn/tags/initial/sys/boot/common/bootstrap.h (nonexistent) +++ cvs2svn/tags/initial/sys/boot/common/bootstrap.h (revision 49189) @@ -0,0 +1,226 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +#include + +/* XXX debugging */ +extern struct console vidconsole; +#define MARK(s, c) {vidconsole.c_out(s); vidconsole.c_out(c); while (!vidconsole.c_ready()) ; vidconsole.c_in();} + +/* + * Generic device specifier; architecture-dependant + * versions may be larger, but should be allowed to + * overlap. + */ +struct devdesc +{ + struct devsw *d_dev; + int d_type; +#define DEVT_NONE 0 +#define DEVT_DISK 1 +#define DEVT_NET 2 +}; + +/* Commands and return values; nonzero return sets command_errmsg != NULL */ +typedef int (bootblk_cmd_t)(int argc, char *argv[]); +extern char *command_errmsg; +extern char command_errbuf[]; /* XXX blah, length */ +#define CMD_OK 0 +#define CMD_ERROR 1 + +/* interp.c */ +extern void interact(void); +extern void source(char *filename); + +/* boot.c */ +extern int autoboot(int delay, char *prompt); + +/* misc.c */ +extern char *unargv(int argc, char *argv[]); + +/* + * Modular console support. + */ +struct console +{ + char *c_name; + char *c_desc; + int c_flags; +#define C_PRESENTIN (1<<0) +#define C_PRESENTOUT (1<<1) +#define C_ACTIVEIN (1<<2) +#define C_ACTIVEOUT (1<<3) + void (* c_probe)(struct console *cp); /* set c_flags to match hardware */ + int (* c_init)(int arg); /* reinit XXX may need more args */ + void (* c_out)(int c); /* emit c */ + int (* c_in)(void); /* wait for and return input */ + int (* c_ready)(void); /* return nonzer if input waiting */ +}; +extern struct console *consoles[]; +extern void cons_probe(void); + +/* + * Module loader. + */ +#define MF_FORMATMASK 0xf +#define MF_AOUT 0 +#define MF_ELF 1 + +/* + * Module metadata header. + * + * Metadata are allocated on our heap, and copied into kernel space + * before executing the kernel. + */ +struct module_metadata +{ + size_t md_size; + u_int16_t md_type; + struct module_metadata *md_next; + char md_data[0]; /* data are immediately appended */ +}; + +/* + * Loaded module information. + * + * At least one module (the kernel) must be loaded in order to boot. + * The kernel is always loaded first. + */ +struct loaded_module +{ + char *m_name; /* module name */ + char *m_type; /* module type, eg 'kernel', 'pnptable', etc. */ + char *m_args; /* arguments for the module */ + void *m_metadata; /* metadata that will be placed in the module directory */ + int m_flags; /* 0xffff reserved for arch-specific use */ + vm_offset_t m_addr; /* load address */ + size_t m_size; /* module size */ + struct loaded_module *m_next; /* next module */ +}; + +struct module_format +{ + int l_format; + /* Load function must return EFTYPE if it can't handle the module supplied */ + int (* l_load)(char *filename, vm_offset_t dest, struct loaded_module **result); + int (* l_exec)(struct loaded_module *amp); +}; +extern struct module_format *module_formats[]; /* supplied by consumer */ +extern struct loaded_module *loaded_modules; +extern int mod_load(char *name, int argc, char *argv[]); +extern struct loaded_module *mod_findmodule(char *name, char *type); + +/* XXX these belong in */ +#define MODINFO_NAME 0x0000 +#define MODINFO_TYPE 0x0001 +#define MODINFO_ADDR 0x0002 +#define MODINFO_SIZE 0x0003 +#define MODINFO_METADATA 0x8000 + + +#if defined(__ELF__) + +/* + * Alpha GAS needs an align before the section change. It seems to assume + * that after the .previous, it is aligned, so the following .align 3 is + * ignored. Since the previous instructions often contain strings, this is + * a problem. + */ + +#ifdef __alpha__ +#define MAKE_SET(set, sym) \ + __asm(".align 3"); \ + __asm(".section .set." #set ",\"aw\""); \ + __asm(".quad " #sym); \ + __asm(".previous") +#else +#define MAKE_SET(set, sym) \ + __asm(".section .set." #set ",\"aw\""); \ + __asm(".long " #sym); \ + __asm(".previous") +#endif +#define TEXT_SET(set, sym) MAKE_SET(set, sym) +#define DATA_SET(set, sym) MAKE_SET(set, sym) +#define BSS_SET(set, sym) MAKE_SET(set, sym) +#define ABS_SET(set, sym) MAKE_SET(set, sym) + +#else + +/* + * Linker set support, directly from + * + * NB: the constants defined below must match those defined in + * ld/ld.h. Since their calculation requires arithmetic, we + * can't name them symbolically (e.g., 23 is N_SETT | N_EXT). + */ +#define MAKE_SET(set, sym, type) \ + static void const * const __set_##set##_sym_##sym = &sym; \ + __asm(".stabs \"_" #set "\", " #type ", 0, 0, _" #sym) +#define TEXT_SET(set, sym) MAKE_SET(set, sym, 23) +#define DATA_SET(set, sym) MAKE_SET(set, sym, 25) +#define BSS_SET(set, sym) MAKE_SET(set, sym, 27) +#define ABS_SET(set, sym) MAKE_SET(set, sym, 21) + +#endif + +struct linker_set { + int ls_length; + const void *ls_items[1]; /* really ls_length of them, trailing NULL */ +}; + +/* + * Support for commands + */ +struct bootblk_command +{ + const char *c_name; + const char *c_desc; + bootblk_cmd_t *c_fn; +}; + +#define COMMAND_SET(tag, key, desc, func) \ + static bootblk_cmd_t func; \ + static struct bootblk_command _cmd_ ## tag = { key, desc, func }; \ + DATA_SET(Xcommand_set, _cmd_ ## tag); + +extern struct linker_set Xcommand_set; + +/* + * functions called down from the generic code + */ +struct arch_switch +{ + /* Automatically load modules as required by detected hardware */ + int (* arch_autoload)(); + /* Boot the loaded kernel (first loaded module) */ + int (* arch_boot)(void); + /* Locate the device for (name), return pointer to tail in (*path) */ + int (*arch_getdev)(void **dev, char *name, char **path); +}; +extern struct arch_switch archsw; + Property changes on: cvs2svn/tags/initial/sys/boot/common/bootstrap.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/common/commands.c =================================================================== --- cvs2svn/tags/initial/sys/boot/common/commands.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/common/commands.c (revision 49189) @@ -0,0 +1,155 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +#include +#include +#include + +#include "bootstrap.h" + +char *command_errmsg; +char command_errbuf[256]; /* XXX should have procedural interface for setting, size limit? */ + +COMMAND_SET(help, "help", "detailed help", command_help); + +static int +command_help(int argc, char *argv[]) +{ + char helppath[80]; /* XXX buffer size? */ + + /* page the help text from our load path */ + sprintf(helppath, "%s/boot.help", getenv("loaddev")); + printf("%s\n", helppath); + if (pager_file(helppath) == -1) + printf("Verbose help not available, use '?' to list commands\n"); + return(CMD_OK); +} + +COMMAND_SET(commandlist, "?", "list commands", command_commandlist); + +static int +command_commandlist(int argc, char *argv[]) +{ + struct bootblk_command **cmdp; + int i; + + printf("Available commands:\n"); + cmdp = (struct bootblk_command **)Xcommand_set.ls_items; + for (i = 0; i < Xcommand_set.ls_length; i++) + if (cmdp[i]->c_name != NULL) + printf(" %-15s %s\n", cmdp[i]->c_name, cmdp[i]->c_desc); + return(CMD_OK); +} + +/* + * XXX set/show should become set/echo if we have variable + * substitution happening. + */ + +COMMAND_SET(show, "show", "show variable(s)", command_show); + +static int +command_show(int argc, char *argv[]) +{ + struct env_var *ev; + char *cp; + + if (argc < 2) { + /* + * With no arguments, print everything. + */ + pager_open(); + for (ev = environ; ev != NULL; ev = ev->ev_next) { + pager_output(ev->ev_name); + cp = getenv(ev->ev_name); + if (cp != NULL) { + pager_output("="); + pager_output(cp); + } + pager_output("\n"); + } + pager_close(); + } else { + if ((cp = getenv(argv[1])) != NULL) { + printf("%s\n", cp); + } else { + sprintf(command_errbuf, "variable '%s' not found", argv[1]); + return(CMD_ERROR); + } + } + return(CMD_OK); +} + +COMMAND_SET(set, "set", "set a variable", command_set); + +static int +command_set(int argc, char *argv[]) +{ + int err; + + if (argc != 2) { + command_errmsg = "wrong number of arguments"; + return(CMD_ERROR); + } else { + if ((err = putenv(argv[1])) != 0) { + command_errmsg = strerror(err); + return(CMD_ERROR); + } + } + return(CMD_OK); +} + +COMMAND_SET(unset, "unset", "unset a variable", command_unset); + +static int +command_unset(int argc, char *argv[]) +{ + int err; + + if (argc != 2) { + command_errmsg = "wrong number of arguments"; + return(CMD_ERROR); + } else { + if ((err = unsetenv(argv[1])) != 0) { + command_errmsg = strerror(err); + return(CMD_ERROR); + } + } + return(CMD_OK); +} + +COMMAND_SET(panic, "panic", "test panic", command_panic); + +static int +command_panic(int argc, char *argv[]) +{ + char *cp; + + cp = unargv(argc - 1, argv + 1); + panic(cp); +} Property changes on: cvs2svn/tags/initial/sys/boot/common/commands.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/common/console.c =================================================================== --- cvs2svn/tags/initial/sys/boot/common/console.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/common/console.c (revision 49189) @@ -0,0 +1,142 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +#include +#include + +#include "bootstrap.h" +/* + * Core console support + */ + +static int cons_set(struct env_var *ev, int flags, void *value); +static int cons_find(char *name); + +/* + * Detect possible console(s) to use. The first probed console + * is marked active. Also create the console variable. + * + * XXX Add logic for multiple console support. + */ +void +cons_probe(void) +{ + int cons; + int active; + + /* Do all console probes, make the fist fully functional console active */ + for (cons = 0, active = -1; consoles[cons] != NULL; cons++) { + consoles[cons]->c_flags = 0; + consoles[cons]->c_probe(consoles[cons]); + if ((consoles[cons]->c_flags == (C_PRESENTIN | C_PRESENTOUT)) && (active == -1)) { + consoles[cons]->c_flags |= (C_ACTIVEIN | C_ACTIVEOUT); + active = cons; + } + } + printf("Console: %s\n", consoles[active]->c_desc); + env_setenv("console", 0, consoles[active]->c_name, cons_set, env_nounset); +} + +int +getchar(void) +{ + int cons; + int rv; + + /* Loop forever polling all active consoles */ + for(;;) + for (cons = 0; consoles[cons] != NULL; cons++) + if ((consoles[cons]->c_flags & C_ACTIVEIN) && + ((rv = consoles[cons]->c_in()) != -1)) + return(rv); +} + +int +ischar(void) +{ + int cons; + + for (cons = 0; consoles[cons] != NULL; cons++) + if ((consoles[cons]->c_flags & C_ACTIVEIN) && + (consoles[cons]->c_ready() != 0)) + return(1); + return(0); +} + +void +putchar(int c) +{ + int cons; + + /* Expand newlines */ + if (c == '\n') + putchar('\r'); + + for (cons = 0; consoles[cons] != NULL; cons++) + if (consoles[cons]->c_flags & C_ACTIVEOUT) + consoles[cons]->c_out(c); +} + +static int +cons_find(char *name) +{ + int cons; + + for (cons = 0; consoles[cons] != NULL; cons++) + if (!strcmp(consoles[cons]->c_name, name)) + return(cons); + return(-1); +} + + +/* + * Select a console. + * + * XXX Note that the console system design allows for some extension + * here (eg. multiple consoles, input/output only, etc.) + */ +static int +cons_set(struct env_var *ev, int flags, void *value) +{ + int cons, active; + + if ((active = cons_find(value)) == -1) { + printf("no such console '%s'\n", (char *)value); + return(CMD_ERROR); + } + + /* disable all current consoles */ + for (cons = 0; consoles[cons] != NULL; cons++) + consoles[cons]->c_flags &= ~(C_ACTIVEIN | C_ACTIVEOUT); + + /* enable selected console */ + consoles[active]->c_flags |= C_ACTIVEIN | C_ACTIVEOUT; + + env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); + return(CMD_OK); +} Property changes on: cvs2svn/tags/initial/sys/boot/common/console.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/common/dev_net.c =================================================================== --- cvs2svn/tags/initial/sys/boot/common/dev_net.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/common/dev_net.c (revision 49189) @@ -0,0 +1,275 @@ +/* + * $Id$ + * From: $NetBSD: dev_net.c,v 1.12 1997/12/10 20:38:37 gwr Exp $ + */ + +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Gordon W. Ross. + * + * 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 by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``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 FOUNDATION OR CONTRIBUTORS + * 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. + */ + +/* + * This module implements a "raw device" interface suitable for + * use by the stand-alone I/O library NFS code. This interface + * does not support any "block" access, and exists only for the + * purpose of initializing the network interface, getting boot + * parameters, and performing the NFS mount. + * + * At open time, this does: + * + * find interface - netif_open() + * RARP for IP address - rarp_getipaddress() + * RPC/bootparams - callrpc(d, RPC_BOOTPARAMS, ...) + * RPC/mountd - nfs_mount(sock, ip, path) + * + * the root file handle from mountd is saved in a global + * for use by the NFS open code (NFS/lookup). + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "dev_net.h" +#include "bootstrap.h" + +int debug = 0; + +static int netdev_sock = -1; +static int netdev_opens; + +static int net_init(void); +static int net_open(struct open_file *, void *vdev); +static int net_close(struct open_file *); +static int net_ioctl(); +static int net_strategy(); + +static int net_getparams(int sock); + +struct devsw netdev = { + "net", + DEVT_NET, + net_init, + net_strategy, + net_open, + net_close, + noioctl +}; + +int +net_init(void) +{ + return 0; +} + +/* + * Called by devopen after it sets f->f_dev to our devsw entry. + * This opens the low-level device and sets f->f_devdata. + * This is declared with variable arguments... + */ +int +net_open(struct open_file *f, void *vdev) +{ + char *devname; /* Device part of file name (or NULL). */ + int error = 0; + + devname = vdev; + + /* On first open, do netif open, mount, etc. */ + if (netdev_opens == 0) { + /* Find network interface. */ + if (netdev_sock < 0) { + netdev_sock = netif_open(devname); + if (netdev_sock < 0) { + printf("net_open: netif_open() failed\n"); + return (ENXIO); + } + if (debug) + printf("net_open: netif_open() succeeded\n"); + } + if (rootip.s_addr == 0) { + /* Get root IP address, and path, etc. */ + error = net_getparams(netdev_sock); + if (error) { + /* getparams makes its own noise */ + netif_close(netdev_sock); + netdev_sock = -1; + return (error); + } + } + } + netdev_opens++; + f->f_devdata = &netdev_sock; + return (error); +} + +int +net_close(f) + struct open_file *f; +{ + +#ifdef NETIF_DEBUG + if (debug) + printf("net_close: opens=%d\n", netdev_opens); +#endif + + /* On last close, do netif close, etc. */ + f->f_devdata = NULL; + /* Extra close call? */ + if (netdev_opens <= 0) + return (0); + /* + * On SRM boots opening the device the first time takes ages + * I don't see the point of doing this every time you load a file + */ + /* netdev_opens--; */ + /* Not last close? */ + if (netdev_opens > 0) + return(0); + rootip.s_addr = 0; + if (netdev_sock >= 0) { + if (debug) + printf("net_close: calling netif_close()\n"); + netif_close(netdev_sock); + netdev_sock = -1; + } + return (0); +} + +int +net_ioctl() +{ + return EIO; +} + +int +net_strategy() +{ + return EIO; +} + +#define SUPPORT_BOOTP + +/* + * Get info for NFS boot: our IP address, our hostname, + * server IP address, and our root path on the server. + * There are two ways to do this: The old, Sun way, + * and the more modern, BOOTP way. (RFC951, RFC1048) + * + * The default is to use the Sun bootparams RPC + * (because that is what the kernel will do). + * MD code can make try_bootp initialied data, + * which will override this common definition. + */ +#ifdef SUPPORT_BOOTP +int try_bootp = 1; +int bootp(int sock); +#endif + +static int +net_getparams(sock) + int sock; +{ + char buf[MAXHOSTNAMELEN]; + n_long smask; + +#ifdef SUPPORT_BOOTP + /* + * Try to get boot info using BOOTP. If we succeed, then + * the server IP address, gateway, and root path will all + * be initialized. If any remain uninitialized, we will + * use RARP and RPC/bootparam (the Sun way) to get them. + */ + if (try_bootp) + bootp(sock); + if (myip.s_addr != 0) + return (0); + if (debug) + printf("net_open: BOOTP failed, trying RARP/RPC...\n"); +#endif + + /* + * Use RARP to get our IP address. This also sets our + * netmask to the "natural" default for our address. + */ + if (rarp_getipaddress(sock)) { + printf("net_open: RARP failed\n"); + return (EIO); + } + printf("net_open: client addr: %s\n", inet_ntoa(myip)); + + /* Get our hostname, server IP address, gateway. */ + if (bp_whoami(sock)) { + printf("net_open: bootparam/whoami RPC failed\n"); + return (EIO); + } + printf("net_open: client name: %s\n", hostname); + + /* + * Ignore the gateway from whoami (unreliable). + * Use the "gateway" parameter instead. + */ + smask = 0; + gateip.s_addr = 0; + if (bp_getfile(sock, "gateway", &gateip, buf) == 0) { + /* Got it! Parse the netmask. */ + smask = ip_convertaddr(buf); + } + if (smask) { + netmask = smask; + printf("net_open: subnet mask: %s\n", intoa(netmask)); + } + if (gateip.s_addr) + printf("net_open: net gateway: %s\n", inet_ntoa(gateip)); + + /* Get the root server and pathname. */ + if (bp_getfile(sock, "root", &rootip, rootpath)) { + printf("net_open: bootparam/getfile RPC failed\n"); + return (EIO); + } + + printf("net_open: server addr: %s\n", inet_ntoa(rootip)); + printf("net_open: server path: %s\n", rootpath); + + return (0); +} Property changes on: cvs2svn/tags/initial/sys/boot/common/dev_net.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/common/dev_net.h =================================================================== --- cvs2svn/tags/initial/sys/boot/common/dev_net.h (nonexistent) +++ cvs2svn/tags/initial/sys/boot/common/dev_net.h (revision 49189) @@ -0,0 +1,30 @@ +/*- + * Copyright (c) 1998 Doug Rabson + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +extern struct devsw netdev; + Property changes on: cvs2svn/tags/initial/sys/boot/common/dev_net.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/common/devopen.c =================================================================== --- cvs2svn/tags/initial/sys/boot/common/devopen.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/common/devopen.c (revision 49189) @@ -0,0 +1,61 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + + +#include +#include + +#include "bootstrap.h" + +int +devopen(struct open_file *f, const char *fname, char **file) +{ + struct devdesc *dev; + int result; + + if ((result = archsw.arch_getdev((void *)&dev, fname, file)) == 0) { /* get the device */ + /* point to device-specific data so that device open can use it */ + f->f_devdata = dev; + if ((result = dev->d_dev->dv_open(f, dev)) == 0) { /* try to open it */ + /* reference the devsw entry from the open_file structure */ + f->f_dev = dev->d_dev; + } else { + free(dev); /* release the device descriptor */ + } + } + return(result); +} + +int +devclose(struct open_file *f) +{ + if (f->f_devdata != NULL) { + free(f->f_devdata); + } + return(0); +} Property changes on: cvs2svn/tags/initial/sys/boot/common/devopen.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/common/interp.c =================================================================== --- cvs2svn/tags/initial/sys/boot/common/interp.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/common/interp.c (revision 49189) @@ -0,0 +1,207 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ +/* + * Simple commandline interpreter. + * + * XXX may be obsoleted by BootFORTH + */ + +#include +#include +#include "bootstrap.h" + +#define MAXARGS 20 /* maximum number of arguments allowed */ + +static int parse(char *buf, int *argcp, char **argvp[]); +static void prompt(void); +/* + * Parse the supplied text into argv/argc form. + * XXX should perhaps learn about quotes, etc? + * XXX can also do alias expansion, variable substitution, etc. here + */ +static int +parse(char *buf, int *argcp, char **argvp[]) +{ + static int argc; + static char *argv[MAXARGS], *cp; + + argc = 0; + cp = buf; + while ((*cp != 0) && (argc < MAXARGS)) { + if (isspace(*cp)) { + *(cp++) = 0; + } else { + argv[argc++] = cp++; + while ((*cp != 0) && !isspace(*cp)) + cp++; + } + } + argv[argc] = NULL; + /* command too complex */ + if (argc >= MAXARGS) { + printf("too many arguments\n"); + return(1); + } + *argcp = argc; + *argvp = argv; + return(0); +} + +/* + * Perform the command + */ +static int +perform(int argc, char *argv[]) +{ + int i, result; + struct bootblk_command **cmdp; + bootblk_cmd_t *cmd; + + if (argc < 1) + return(CMD_OK); + + /* set return defaults; a successful command will override these */ + command_errmsg = command_errbuf; + strcpy(command_errbuf, "no error message"); + cmd = NULL; + result = CMD_ERROR; + + cmdp = (struct bootblk_command **)Xcommand_set.ls_items; + for (i = 0; i < Xcommand_set.ls_length; i++) { + if ((cmdp[i]->c_name != NULL) && !strcmp(argv[0], cmdp[i]->c_name)) + cmd = cmdp[i]->c_fn; + } + if (cmd != NULL) { + result = (cmd)(argc, argv); + } else { + command_errmsg = "unknown command"; + } + return(result); +} + +/* + * Interactive mode + */ +void +interact(void) +{ + char input[256]; /* big enough? */ + int argc; + char **argv; + + for (;;) { + input[0] = '\0'; + prompt(); + ngets(input, sizeof(input)); + if (!parse(input, &argc, &argv) && + (perform(argc, argv) != 0)) + printf("%s: %s\n", argv[0], command_errmsg); + } +} + +/* + * Read command from a file + */ +COMMAND_SET(source, "source", "read commands from a file", command_source); + +static int +command_source(int argc, char *argv[]) +{ + int i; + + for (i = 1; i < argc; i++) + source(argv[i]); + return(CMD_OK); +} + +void +source(char *filename) +{ + char input[256]; /* big enough? */ + int argc; + char **argv, *cp; + int fd; + + if (((fd = open(filename, O_RDONLY)) == -1)) { + printf("can't open '%s': %s\n", filename, strerror(errno)); + } else { + while (fgetstr(input, sizeof(input), fd) > 0) { + + /* Discard comments */ + if (input[0] == '#') + continue; + cp = input; + /* Echo? */ + if (input[0] == '@') { + cp++; + } else { + prompt(); + printf("%s\n", input); + } + + if (!parse(cp, &argc, &argv) && + (argc > 0) && + (perform(argc, argv) != 0)) + printf("%s: %s\n", argv[0], command_errmsg); + } + close(fd); + } +} + +/* + * Emit the current prompt; support primitive embedding of + * environment variables. + * We're a little rude here, modifying the return from getenv(). + */ +static void +prompt(void) +{ + char *p, *cp, *ev, c; + + if ((p = getenv("prompt")) == NULL) + p = ">"; + + while (*p != 0) { + if (*p == '$') { + for (cp = p + 1; (*cp != 0) && isalpha(*cp); cp++) + ; + c = *cp; + *cp = 0; + ev = getenv(p + 1); + *cp = c; + + if (ev != NULL) { + printf(ev); + p = cp; + continue; + } + } + putchar(*p++); + } + putchar(' '); +} Property changes on: cvs2svn/tags/initial/sys/boot/common/interp.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/common/load.c =================================================================== --- cvs2svn/tags/initial/sys/boot/common/load.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/common/load.c (revision 49189) @@ -0,0 +1,101 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +#include + +#define LOAD_TINYBUF 2048 + +/* + * Attempt to load the file at (path) into an allocated + * area on the heap, return a pointer to it or NULL + * on failure. + * + * Because in many cases it is impossible to determine the + * true size of a file without reading it, we do just that. + */ +char * +filedup(const char *path, int flags) +{ + char *buf; + int fd; + size_t size, result; + + if ((fd = open(path, F_READ | flags)) == -1) + return(NULL); + + printf("%s open, flags 0x%x\n", path, files[fd].f_flags); + buf = alloc(LOAD_TINYBUF); + + /* Read the first buffer-full */ + size = read(fd, buf, LOAD_TINYBUF); + if (size < 1) { + free(buf, LOAD_TINYBUF); + close(fd); + return(NULL); + } + /* If it all fitted, then just return the buffer straight out */ + if (size < LOAD_TINYBUF) { + close(fd); + buf[size] = 0; + return(buf); + } + + printf("tinybuf loaded, size %d\n", size); + getchar(); + + + /* Read everything until we know how big it is */ + for (;;) { + result = read(fd, buf, LOAD_TINYBUF); + if (size == -1) { + free(buf, LOAD_TINYBUF); + close(fd); + return(NULL); + } + if (result == 0) + break; + size += result; + } + + /* discard the old buffer, close the file */ + free(buf, LOAD_TINYBUF); + close(fd); + + /* reopen the file, realloc the buffer */ + if ((fd = open(path, F_READ | flags)) == -1) + return(NULL); + buf = alloc(size); + result = read(fd, buf, size); + close(fd); + if (result != size) { + free(buf, size); + return(NULL); + } + return(buf); +} + Property changes on: cvs2svn/tags/initial/sys/boot/common/load.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/common/ls.c =================================================================== --- cvs2svn/tags/initial/sys/boot/common/ls.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/common/ls.c (revision 49189) @@ -0,0 +1,160 @@ +/* + * $Id$ + * From: $NetBSD: ls.c,v 1.3 1997/06/13 13:48:47 drochner Exp $ + */ + +/* + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + */ + + +#include +#include +#include + +#include + +#include "bootstrap.h" + +static char typestr[] = "?fc?d?b? ?l?s?w"; + +COMMAND_SET(ls, "ls", "list files", command_ls); + +static int +command_ls(int argc, char *argv[]) +{ + int fd; + struct stat sb; + size_t size; + char dirbuf[DIRBLKSIZ]; + char pathbuf[128]; /* XXX path length constant? */ + char buf[128]; /* must be long enough for dir entry! */ + char *path; + int result, ch; +#ifdef VERBOSE_LS + int verbose; + + verbose = 0; + optind = 1; + while ((ch = getopt(argc, argv, "l")) != -1) { + switch(ch) { + case 'l': + verbose = 1; + break; + case '?': + default: + /* getopt has already reported an error */ + return(CMD_OK); + } + } + argv += (optind - 1); + argc -= (optind - 1); +#endif + + if (argc < 2) { + path = "/"; + } else { + path = argv[1]; + } + + pager_open(); + pager_output(path); + pager_output("\n"); + + fd = open(path, O_RDONLY); + if (fd < 0) { + sprintf(command_errbuf, "open '%s' failed: %s", path, strerror(errno)); + return(CMD_ERROR); + } + result = CMD_OK; + if (fstat(fd, &sb) < 0) { + sprintf(command_errbuf, "stat failed: %s", strerror(errno)); + result = CMD_ERROR; + goto out; + } + if (!S_ISDIR(sb.st_mode)) { + sprintf(command_errbuf, "%s: %s", path, strerror(ENOTDIR)); + result = CMD_ERROR; + goto out; + } + while ((size = read(fd, dirbuf, DIRBLKSIZ)) == DIRBLKSIZ) { + struct direct *dp, *edp; + + dp = (struct direct *) dirbuf; + edp = (struct direct *) (dirbuf + size); + + while (dp < edp) { + if (dp->d_ino != (ino_t) 0) { + + if ((dp->d_namlen > MAXNAMLEN + 1) || (dp->d_type > sizeof(typestr))) { + /* + * This does not handle "old" + * filesystems properly. On little + * endian machines, we get a bogus + * type name if the namlen matches a + * valid type identifier. We could + * check if we read namlen "0" and + * handle this case specially, if + * there were a pressing need... + */ + command_errmsg = "bad dir entry"; + result = CMD_ERROR; + goto out; + } + + if (strcmp(dp->d_name, ".") && strcmp(dp->d_name, "..")) { +#ifdef VERBOSE_LS /* too much UFS activity blows the heap out */ + if (verbose) { + /* stat the file, if possible */ + sb.st_size = 0; + sprintf(buf, "%s/%s", pathbuf, dp->d_name); + /* ignore return */ + if (stat(buf, &sb)) + sb.st_size = -1; + sprintf(buf, " %c %8d %s\n", typestr[dp->d_type], (int)sb.st_size, dp->d_name); +#endif + } else + sprintf(buf, " %c %s\n", typestr[dp->d_type], dp->d_name); + if (pager_output(buf)) + goto out; + } + } + dp = (struct direct *) ((char *) dp + dp->d_reclen); + } + } + out: + pager_close(); + close(fd); + return(result); +} Property changes on: cvs2svn/tags/initial/sys/boot/common/ls.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/common/misc.c =================================================================== --- cvs2svn/tags/initial/sys/boot/common/misc.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/common/misc.c (revision 49189) @@ -0,0 +1,55 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +#include +#include + +/* + * Concatenate the (argc) elements of (argv) into a single string, and return + * a copy of same. + */ +char * +unargv(int argc, char *argv[]) +{ + size_t hlong; + int i; + char *cp; + + for (hlong = 0, i = 0, hlong = 0; i < argc; i++) + hlong += strlen(argv[i]) + 1; + + if(hlong == 0) + return(NULL); + + cp = malloc(hlong); + cp[0] = 0; + for (i = 0; i < argc; i++) + strcat(cp, argv[i]); + return(cp); +} + Property changes on: cvs2svn/tags/initial/sys/boot/common/misc.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/common/module.c =================================================================== --- cvs2svn/tags/initial/sys/boot/common/module.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/common/module.c (revision 49189) @@ -0,0 +1,129 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +/* + * module function dispatcher, support, etc. + * + * XXX need a 'searchmodule' function that takes a name and + * traverses a search path. + */ + +#include +#include + +#include "bootstrap.h" + +/* Initially determined from kernel load address */ +static vm_offset_t loadaddr = 0; + +struct loaded_module *loaded_modules = NULL; + +COMMAND_SET(load, "load", "load a kernel or module", command_load); + +static int +command_load(int argc, char *argv[]) +{ + return(mod_load(argv[1], argc - 2, argv + 2)); +} + +COMMAND_SET(lsmod, "lsmod", "list loaded modules", command_lsmod); + +static int +command_lsmod(int argc, char *argv[]) +{ + struct loaded_module *am; + char lbuf[80]; + + pager_open(); + for (am = loaded_modules; (am != NULL); am = am->m_next) { + sprintf(lbuf, " %p: %s (%s, 0x%x)\n", + am->m_addr, am->m_name, am->m_type, am->m_size); + pager_output(lbuf); + if (am->m_args != NULL) { + pager_output(" args: "); + pager_output(am->m_args); + pager_output("\n"); + } + } + pager_close(); + return(CMD_OK); +} + +int +mod_load(char *name, int argc, char *argv[]) +{ + struct loaded_module *am, *cm; + int i, err; + + for (i = 0, am = NULL; (module_formats[i] != NULL) && (am == NULL); i++) { + /* XXX call searchmodule() to search for module (name) */ + if ((err = (module_formats[i]->l_load)(name, loadaddr, &am)) != 0) { + + /* Unknown to this handler? */ + if (err == EFTYPE) + continue; + + /* Fatal error */ + sprintf(command_errbuf, "can't load module '%s': %s", name, strerror(err)); + return(CMD_ERROR); + } + } + if (am == NULL) { + sprintf(command_errbuf, "can't work out what to do with '%s'", name); + return(CMD_ERROR); + } + /* where can we put the next one? */ + loadaddr = am->m_addr + am->m_size; + + /* Load was OK, set args */ + am->m_args = unargv(argc, argv); + + /* Append to list of loaded modules */ + am->m_next = NULL; + if (loaded_modules == NULL) { + loaded_modules = am; + } else { + for (cm = loaded_modules; cm->m_next != NULL; cm = cm->m_next) + ; + cm->m_next = am; + } + return(CMD_OK); +} + +struct loaded_module * +mod_findmodule(char *name, char *type) +{ + struct loaded_module *mp; + + for (mp = loaded_modules; mp != NULL; mp = mp->m_next) { + if (((name == NULL) || !strcmp(name, mp->m_name)) && + ((type == NULL) || !strcmp(type, mp->m_type))) + break; + } + return(mp); +} Property changes on: cvs2svn/tags/initial/sys/boot/common/module.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/common/panic.c =================================================================== --- cvs2svn/tags/initial/sys/boot/common/panic.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/common/panic.c (revision 49189) @@ -0,0 +1,56 @@ +/* + * $Id$ + * From: $NetBSD: panic.c,v 1.2 1997/03/22 01:48:36 thorpej Exp $ + */ + +/* + * 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. + * + */ + + +#include +#include + +__dead void +panic(const char *fmt,...) +{ + va_list ap; + + printf("panic: "); + va_start(ap, fmt); + printf(fmt, ap); + printf("\n"); + va_end(ap); + printf("Press a key to reboot\n"); + getchar(); + + exit(1); +} Property changes on: cvs2svn/tags/initial/sys/boot/common/panic.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/Makefile =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/Makefile (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/Makefile (revision 49189) @@ -0,0 +1,3 @@ +SUBDIR= installboot libi386 loader + +.include Property changes on: cvs2svn/tags/initial/sys/boot/i386/Makefile ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/installboot/Makefile =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/installboot/Makefile (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/installboot/Makefile (revision 49189) @@ -0,0 +1,16 @@ +# $NetBSD: Makefile,v 1.5 1998/03/02 19:57:01 cgd Exp $ + +.include + +BINDIR= /usr/mdec +PROG= installboot + +SRCS= installboot.c bootblks.c getmount.c + +NOMAN= yes + +CPPFLAGS= -I${.CURDIR}/../libi386/crt/bootsect +CFLAGS+= -Wall ${CPPFLAGS} +LDSTATIC?=-static + +.include Property changes on: cvs2svn/tags/initial/sys/boot/i386/installboot/Makefile ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/installboot/bootblks.c =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/installboot/bootblks.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/installboot/bootblks.c (revision 49189) @@ -0,0 +1,146 @@ +/* $NetBSD: bootblks.c,v 1.2 1997/07/21 18:04:35 drochner Exp $ */ + +/* + * 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. + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "installboot.h" + +static char bootblkpath[MAXPATHLEN]; +static char backuppath[MAXPATHLEN]; +static char backupext[] = ".bak"; +static int havebackup; + +ino_t +createfileondev(diskdev, bootblkname, bp, size) + char *diskdev, *bootblkname; + char *bp; + int size; +{ + char *mntpoint; + int fd = -1; + struct stat statbuf; + int allok = 0; + + if ((mntpoint = getmountpoint(diskdev)) == NULL) + return ((ino_t) - 1); + + /* + * create file in fs root for bootloader data + * try to rename existing file before + */ + havebackup = 0; + sprintf(bootblkpath, "%s/%s", mntpoint, bootblkname); + sprintf(backuppath, "%s%s", bootblkpath, backupext); + if(rename(bootblkpath, backuppath) == -1) { + if(errno != ENOENT) { + warn("rename old %s", bootblkpath); + goto out; + } + } else { + if(verbose) + fprintf(stderr, "renamed %s -> %s\n", + bootblkpath, backuppath); + havebackup = 1; + } + fd = open(bootblkpath, O_RDWR | O_CREAT | O_EXCL, 0444); + if (fd < 0) { + warn("open %s", bootblkpath); + goto out; + } + /* + * do the write, flush, get inode number + */ + if (write(fd, bp, size) < 0) { + warn("write %s", bootblkpath); + goto out; + } + if (fsync(fd) != 0) { + warn("fsync: %s", bootblkpath); + goto out; + } + if (fstat(fd, &statbuf) != 0) { + warn("fstat: %s", bootblkpath); + goto out; + } + allok = 1; + +out: + if (fd != -1) { + close(fd); + if (!allok) + unlink(bootblkpath); + } + if(!allok && havebackup) + rename(backuppath, bootblkpath); + cleanupmount(mntpoint); + return (allok ? statbuf.st_ino : (ino_t) - 1); +} + +void +cleanupfileondev(diskdev, bootblkname, recover) + char *diskdev, *bootblkname; +{ + char *mntpoint; + + /* save some work if nothing to do */ + if(!(recover || havebackup)) + return; + + if ((mntpoint = getmountpoint(diskdev)) == NULL) + return; + + sprintf(bootblkpath, "%s/%s", mntpoint, bootblkname); + sprintf(backuppath, "%s%s", bootblkpath, backupext); + + if(recover) { + unlink(bootblkpath); + if(havebackup) { + fprintf(stderr, "renaming %s -> %s\n", + backuppath, bootblkpath); + rename(backuppath, bootblkpath); + } + } else if(havebackup) { + if(verbose) + fprintf(stderr, "deleting %s\n", backuppath); + unlink(backuppath); + } + + cleanupmount(mntpoint); +} Property changes on: cvs2svn/tags/initial/sys/boot/i386/installboot/bootblks.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/installboot/getmount.c =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/installboot/getmount.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/installboot/getmount.c (revision 49189) @@ -0,0 +1,156 @@ +/* $NetBSD: getmount.c,v 1.3 1998/03/01 13:22:55 fvdl Exp $ */ + +/* + * 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. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "installboot.h" + +static int tempmounted = 0; + +/* make block device name from character device name */ +static char * +getbdev(dev) + char *dev; +{ + static char bdiskdev[MAXPATHLEN]; + + if (strncmp(dev, "/dev/r", 6)) { + warnx("bad device name %s", dev); + return (0); + } + sprintf(bdiskdev, "/dev/%s", dev + 6); + return (bdiskdev); +} + +/* + * create mountpoint and mount given block device there, return + * mountpoint + */ +static char * +dotempmount(bdiskdev) + char *bdiskdev; +{ + static char dir[] = "/tmp/installbootXXXXXX"; + struct ufs_args data; + + if (mktemp(dir) == NULL) { + warnx("mktemp failed"); + return (0); + } + if (mkdir(dir, 0700)) { + warn("could not create temporary dir %s", dir); + return (0); + } + bzero(&data, sizeof(data)); + data.fspec = bdiskdev; + + /* this code if FFS only */ + if (mount("ufs", dir, 0, &data) == -1) { + warn("mount %s->%s failed", bdiskdev, dir); + rmdir(dir); + return (0); + } + if (verbose) + fprintf(stderr, "mounted %s at %s\n", bdiskdev, dir); + tempmounted = 1; + return (dir); +} + +/* + * Find out if given character device is already mounted. If not, mount it + * temporarily. + */ +char * +getmountpoint(diskdev) + char *diskdev; +{ + char *bdiskdev; + struct statfs *buf; + int num, i; + + bdiskdev = getbdev(diskdev); + if (bdiskdev == NULL) + return (0); + + num = getmntinfo(&buf, MNT_WAIT); + if (num == 0) { + warn("getmntinfo"); + return (0); + } + for (i = 0; i < num; i++) + if (strncmp(bdiskdev, buf[i].f_mntfromname, MNAMELEN) == 0) { + int j; + + /* Device is mounted. If there are more devices mounted + at the same point, the fs could be hidden. Don't think + too much about layering order - simply refuse. */ + for (j = 0; j < num; j++) + if ((i != j) && (strncmp(buf[i].f_mntonname, + buf[j].f_mntonname, + MNAMELEN) == 0)) { + warnx("there is more than 1 mount at %s", + buf[i].f_mntonname); + return (0); + } + /* this code is FFS only */ + if (strncmp(buf[i].f_fstypename, "ufs", MFSNAMELEN)) { + warnx("%s: must be a FFS filesystem", bdiskdev); + return (0); + } + return (buf[i].f_mntonname); + } + if (verbose) + fprintf(stderr, "%s is not mounted\n", bdiskdev); + return (dotempmount(bdiskdev)); +} + +void +cleanupmount(dir) + char *dir; +{ + if (tempmounted) { + if (verbose) + fprintf(stderr, "unmounting\n"); + unmount(dir, 0); + rmdir(dir); + tempmounted = 0; + } +} Property changes on: cvs2svn/tags/initial/sys/boot/i386/installboot/getmount.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/installboot/installboot.8 =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/installboot/installboot.8 (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/installboot/installboot.8 (revision 49189) @@ -0,0 +1,150 @@ +.\" $NetBSD: installboot.8,v 1.1.1.1 1997/03/14 02:40:32 perry Exp $ +.\" +.\" Copyright (c) 1997 Perry E. Metzger. All rights reserved. +.\" Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. +.\" Copyright (c) 1995 Paul Kranenburg. 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 by Paul Kranenburg. +.\" 3. 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. +.\" +.Dd March 14, 1997 +.Dt INSTALLBOOT 8 i386 +.Os +.Sh NAME +.Nm installboot +.Nd install disk bootstrap software +.Sh SYNOPSIS +.Nm installboot +.Op Fl nvf +.Ar bootfile +.Ar rawdiskdevice +.Sh DESCRIPTION +The +.Nm installboot +utility prepares a disk for bootstrapping. +.Pp +The +.Nx /i386 +disk bootstrap software is split into two parts: +a small first-stage boot program that is written into the disklabel +area of a disk and a second-stage boot program that resides in a FFS file +system on the disk (named +.Pa /boot ) . +Both parts of the boot are derived from a single object file +which is split by +.Nm +during the installation process. +The first-stage boot program is loaded into memory by the BIOS. +After receiving control of the system, it loads the +second-stage boot program from a set of filesystem block numbers that +have been hard-coded into it by +.Nm +during execution. +The second-stage boot program then locates and loads the kernel. +.Pp +Note: so that the +.Pa /boot +file can be installed on the bootable partition, the partition must be +mounted before +.Nm +is run. +.Pp +The options recognized by +.Nm installboot +are as follows: +.Bl -tag -width flag +.It Fl n +Do not actually write anything on the disk. +.It Fl v +Verbose mode. +.It Fl f +Force a write of the boot blocks (with the first stage put at offset +zero) even if no disk label is detected. +This is useful if there is no disk label (as is often the case with +floppy or vnode devices). +.El +.Pp +The arguments are: +.Bl -tag -width rawdiskdevice +.It Ar bootfile +The name of the special object file +(typically +.Pa /usr/mdec/biosboot.sym ) +where the first and second stage boot programs to be installed reside. +.It Ar rawdiskdevice +The name of the device corresponding to the raw whole-disk partition (the +.Dq raw partition ) +of the disk on which the first-stage boot program is to be installed. +.El +.Sh EXAMPLES +Assuming the file containing the boot program is in its typical place, +and you wished to make +.Pa /dev/fd0a +bootable. One might first mount +.Pa /dev/fd0a +on +.Pa /mnt , +and in the case that there is already a file named +.Pa boot +in that directory, remove it. +To install the boot blocks, one then would issue the command: +.Bd -literal -offset indent +installboot -f /usr/mdec/biosboot.sym /dev/rfd0a +.Ed +Note that the -f option is needed if the floppy is unlabeled -- see +.Xr disklabel 8 . +.Sh BUGS +The NetBSD/i386 boot blocks can only read from the first 1024 +cylinders of the disk because they use the BIOS to do their I/O. Thus, +it is advisable that +.Dq a +partitions reside entirely within the first 1024 cylinders. +.Pp +.Nm +requires simultaneous access to the mounted file system and +the disks' raw partition. +That is not allowed with the kernel +.Dv securelevel +variable +.Po +see +.Xr sysctl 8 +.Pc +set to a value greater than one, or with +.Dv securelevel +set to one if the +.Dq boot +program resides in a file system on the disk's raw partition. +.Sh "SEE ALSO" +.Xr boot 8 , +.Xr disklabel 8 , +.Xr init 8 , +.Xr sysctl 8 , +.Xr vnd 4 +.Sh HISTORY +The NetBSD/i386 +.Nm +command first appeared in +.Nx 1.3 . Property changes on: cvs2svn/tags/initial/sys/boot/i386/installboot/installboot.8 ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/installboot/installboot.c =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/installboot/installboot.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/installboot/installboot.c (revision 49189) @@ -0,0 +1,433 @@ +/* $NetBSD: installboot.c,v 1.5 1997/11/01 06:49:50 lukem Exp $ */ + +/* + * Copyright (c) 1994 Paul Kranenburg + * All rights reserved. + * Copyright (c) 1996, 1997 + * Matthias Drochner. All rights reserved. + * Copyright (c) 1996, 1997 + * Perry E. Metzger. 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 by Paul Kranenburg. + * This product includes software developed for the NetBSD Project + * by Matthias Drochner. + * This product includes software developed for the NetBSD Project + * by Perry E. Metzger. + * 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. + */ + +#include +#include +/* #include */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "installboot.h" + +#include "bbinfo.h" + +#define DEFBBLKNAME "boot" + +struct fraglist *fraglist; + +struct nlist nl[] = { +#define X_fraglist 0 + {{"_fraglist"}}, + {{NULL}} +}; + +int verbose = 0; + +char * +loadprotoblocks(fname, size) + char *fname; + long *size; +{ + int fd; + size_t tdsize; /* text+data size */ + size_t bbsize; /* boot block size (block aligned) */ + char *bp; + struct nlist *nlp; + struct exec eh; + + fd = -1; + bp = NULL; + + /* Locate block number array in proto file */ + if (nlist(fname, nl) != 0) { + warnx("nlist: %s: symbols not found", fname); + return NULL; + } + /* Validate symbol types (global text!). */ + for (nlp = nl; nlp->n_un.n_name; nlp++) { + if (nlp->n_type != (N_TEXT | N_EXT)) { + warnx("nlist: %s: wrong type", nlp->n_un.n_name); + return NULL; + } + } + + if ((fd = open(fname, O_RDONLY)) < 0) { + warn("open: %s", fname); + return NULL; + } + if (read(fd, &eh, sizeof(eh)) != sizeof(eh)) { + warn("read: %s", fname); + goto bad; + } + if (N_GETMAGIC(eh) != OMAGIC) { + warn("bad magic: 0x%lx", eh.a_midmag); + goto bad; + } + /* + * We need only text and data. + */ + tdsize = eh.a_text + eh.a_data; + bbsize = roundup(tdsize, DEV_BSIZE); + + if ((bp = calloc(bbsize, 1)) == NULL) { + warnx("malloc: %s: no memory", fname); + goto bad; + } + /* read the rest of the file. */ + if (read(fd, bp, tdsize) != tdsize) { + warn("read: %s", fname); + goto bad; + } + *size = bbsize; /* aligned to DEV_BSIZE */ + + fraglist = (struct fraglist *) (bp + nl[X_fraglist].n_value); + + if (fraglist->magic != FRAGLISTMAGIC) { + warnx("invalid bootblock version"); + goto bad; + } + if (verbose) { + fprintf(stderr, "%s: entry point %#lx\n", fname, eh.a_entry); + fprintf(stderr, "proto bootblock size %ld\n", *size); + fprintf(stderr, "room for %d filesystem blocks at %#lx\n", + fraglist->maxentries, nl[X_fraglist].n_value); + } + close(fd); + return bp; + +bad: + if (bp) + free(bp); + if (fd >= 0) + close(fd); + return NULL; +} + +static int +devread(fd, buf, blk, size, msg) + int fd; + void *buf; + daddr_t blk; + size_t size; + char *msg; +{ + if (lseek(fd, dbtob(blk), SEEK_SET) != dbtob(blk)) { + warn("%s: devread: lseek", msg); + return (1); + } + if (read(fd, buf, size) != size) { + warn("%s: devread: read", msg); + return (1); + } + return (0); +} + +/* add file system blocks to fraglist */ +static int +add_fsblk(fs, blk, blcnt) + struct fs *fs; + daddr_t blk; + int blcnt; +{ + int nblk; + + /* convert to disk blocks */ + blk = fsbtodb(fs, blk); + nblk = fs->fs_bsize / DEV_BSIZE; + if (nblk > blcnt) + nblk = blcnt; + + if (verbose) + fprintf(stderr, "dblk: %d, num: %d\n", blk, nblk); + + /* start new entry or append to previous? */ + if (!fraglist->numentries || + (fraglist->entries[fraglist->numentries - 1].offset + + fraglist->entries[fraglist->numentries - 1].num != blk)) { + + /* need new entry */ + if (fraglist->numentries > fraglist->maxentries - 1) { + errx(1, "not enough fragment space in bootcode\n"); + return(-1); + } + + fraglist->entries[fraglist->numentries].offset = blk; + fraglist->entries[fraglist->numentries++].num = 0; + } + fraglist->entries[fraglist->numentries - 1].num += nblk; + + return (blcnt - nblk); +} + +static char sblock[SBSIZE]; + +int +loadblocknums(diskdev, inode) + char *diskdev; + ino_t inode; +{ + int devfd = -1; + struct fs *fs; + char *buf = 0; + daddr_t blk, *ap; + struct dinode *ip; + int i, ndb; + int allok = 0; + + devfd = open(diskdev, O_RDONLY, 0); + if (devfd < 0) { + warn("open raw partition"); + return (1); + } + /* Read superblock */ + if (devread(devfd, sblock, SBLOCK, SBSIZE, "superblock")) + goto out; + fs = (struct fs *) sblock; + + if (fs->fs_magic != FS_MAGIC) { + warnx("invalid super block"); + goto out; + } + /* Read inode */ + if ((buf = malloc(fs->fs_bsize)) == NULL) { + warnx("No memory for filesystem block"); + goto out; + } + blk = fsbtodb(fs, ino_to_fsba(fs, inode)); + if (devread(devfd, buf, blk, fs->fs_bsize, "inode")) + goto out; + ip = (struct dinode *) (buf) + ino_to_fsbo(fs, inode); + + /* + * Have the inode. Figure out how many blocks we need. + */ + ndb = ip->di_size / DEV_BSIZE; /* size is rounded! */ + + if (verbose) + fprintf(stderr, "Will load %d blocks.\n", ndb); + + /* + * Get the block numbers, first direct blocks + */ + ap = ip->di_db; + for (i = 0; i < NDADDR && *ap && ndb > 0; i++, ap++) + ndb = add_fsblk(fs, *ap, ndb); + + if (ndb > 0) { + /* + * Just one level of indirections; there isn't much room + * for more in the 1st-level bootblocks anyway. + */ + blk = fsbtodb(fs, ip->di_ib[0]); + if (devread(devfd, buf, blk, fs->fs_bsize, "indirect block")) + goto out; + ap = (daddr_t *) buf; + for (; i < NINDIR(fs) && *ap && ndb > 0; i++, ap++) { + ndb = add_fsblk(fs, *ap, ndb); + } + } + + if (!ndb) + allok = 1; + else { + if (ndb > 0) + warnx("too many fs blocks"); + /* else, ie ndb < 0, add_fsblk returned error */ + goto out; + } + +out: + if (buf) + free(buf); + if (devfd >= 0) + close(devfd); + return (!allok); +} + +static void +usage() +{ + fprintf(stderr, + "usage: installboot [-n] [-v] [-f] \n"); + exit(1); +} + +int +main(argc, argv) + int argc; + char *argv[]; +{ + char c, *bp = 0; + long size; + ino_t inode = (ino_t) -1; + int devfd = -1; + struct disklabel dl; + int bsdoffs; + int i, res; + int forceifnolabel = 0; + char *bootblkname = DEFBBLKNAME; + int nowrite = 0; + int allok = 0; + + while ((c = getopt(argc, argv, "vnf")) != -1) { + switch (c) { + case 'n': + /* Do not actually write the bootblock to disk */ + nowrite = 1; + break; + case 'v': + /* Chat */ + verbose = 1; + break; + case 'f': + /* assume zero offset if no disklabel */ + forceifnolabel = 1; + break; + default: + usage(); + } + } + + if (argc - optind != 2) { + usage(); + } + + bp = loadprotoblocks(argv[optind], &size); + if (!bp) + errx(1, "error reading bootblocks"); + + fraglist->numentries = 0; + + /* do we need the fraglist? */ + if (size > fraglist->loadsz * DEV_BSIZE) { + + inode = createfileondev(argv[optind + 1], bootblkname, + bp + fraglist->loadsz * DEV_BSIZE, + size - fraglist->loadsz * DEV_BSIZE); + if (inode == (ino_t) - 1) + goto out; + + /* paranoia */ + sync(); + sleep(3); + + if (loadblocknums(argv[optind + 1], inode)) + goto out; + + size = fraglist->loadsz * DEV_BSIZE; + /* size to be written to bootsect */ + } + + devfd = open(argv[optind + 1], O_RDWR, 0); + if (devfd < 0) { + warn("open raw partition RW"); + goto out; + } + if (ioctl(devfd, DIOCGDINFO, &dl) < 0) { + if ((errno == EINVAL) || (errno == ENOTTY)) { + if (forceifnolabel) + bsdoffs = 0; + else { + warnx("no disklabel, use -f to install anyway"); + goto out; + } + } else { + warn("get disklabel"); + goto out; + } + } else { + char c = argv[optind + 1][strlen(argv[optind + 1]) - 1]; +#define isvalidpart(c) ((c) >= 'a' && (c) <= 'z') + if(!isvalidpart(c) || (c - 'a') >= dl.d_npartitions) { + warnx("invalid partition"); + goto out; + } + bsdoffs = dl.d_partitions[c - 'a'].p_offset; + } + if (verbose) + fprintf(stderr, "BSD partition starts at sector %d\n", bsdoffs); + + /* + * add offset of BSD partition to fraglist entries + */ + for (i = 0; i < fraglist->numentries; i++) + fraglist->entries[i].offset += bsdoffs; + + if (!nowrite) { + /* + * write first blocks (max loadsz) to start of BSD partition, + * skip disklabel (in second disk block) + */ + lseek(devfd, 0, SEEK_SET); + res = write(devfd, bp, DEV_BSIZE); + if (res < 0) { + warn("final write1"); + goto out; + } + lseek(devfd, 2 * DEV_BSIZE, SEEK_SET); + res = write(devfd, bp + 2 * DEV_BSIZE, size - 2 * DEV_BSIZE); + if (res < 0) { + warn("final write2"); + goto out; + } + } + allok = 1; + +out: + if (devfd >= 0) + close(devfd); + if (bp) + free(bp); + if (inode != (ino_t) - 1) { + cleanupfileondev(argv[optind + 1], bootblkname, !allok || nowrite); + } + return (!allok); +} Property changes on: cvs2svn/tags/initial/sys/boot/i386/installboot/installboot.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/installboot/installboot.h =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/installboot/installboot.h (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/installboot/installboot.h (revision 49189) @@ -0,0 +1,9 @@ +/* $NetBSD: installboot.h,v 1.3 1998/01/05 07:02:57 perry Exp $ */ + +ino_t createfileondev __P((char *, char *, char *, int)); +void cleanupfileondev __P((char *, char *, int)); + +char *getmountpoint __P((char *)); +void cleanupmount __P((char *)); + +extern int verbose; Property changes on: cvs2svn/tags/initial/sys/boot/i386/installboot/installboot.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/Makefile =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/Makefile (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/Makefile (revision 49189) @@ -0,0 +1,21 @@ +# $Id$ +# +SUBDIR= crt +LIB= i386 +NOPIC= +NOPROFILE= + +SRCS= aout_freebsd.c biosdelay.S biosdisk.c biosdisk_support.S biosgetrtc.S \ + biosmem.S biosreboot.S bootinfo.c comconsole.c comconsole_support.S \ + devicename.c gatea20.c getsecs.c i386_module.c pread.c startprog.S \ + vidconsole.c vidconsole_support.S + +CFLAGS+= -I${.CURDIR}/../../common + +# Make the disk code more talkative +#CFLAGS+= -DDISK_DEBUG + +# Minimise the pread() buffer at the price of slower loads +#CPPFLAGS+= -DSAVE_MEMORY + +.include Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/Makefile ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/aout_freebsd.c =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/aout_freebsd.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/aout_freebsd.c (revision 49189) @@ -0,0 +1,274 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "bootstrap.h" +#include "libi386.h" + +struct aout_kernel_module +{ + struct loaded_module m; + vm_offset_t m_entry; /* module entrypoint */ + struct bootinfo m_bi; /* legacy bootinfo */ +}; + +static int aout_loadmodule(char *filename, vm_offset_t dest, struct loaded_module **result); +static int aout_exec(struct loaded_module *amp); + +struct module_format i386_aout = { MF_AOUT, aout_loadmodule, aout_exec }; + +static int aout_loadimage(int fd, vm_offset_t loadaddr, struct exec *ehdr); + +/* + * Attempt to load the file (file) as an a.out module. It will be stored at + * (dest), and a pointer to a module structure describing the loaded object + * will be saved in (result). + */ +static int +aout_loadmodule(char *filename, vm_offset_t dest, struct loaded_module **result) +{ + struct aout_kernel_module *mp; + struct exec ehdr; + int fd; + vm_offset_t addr; + int err; + u_int pad; + + /* + * Open the image, read and validate the a.out header + * + * XXX what do kld modules look like? We only handle kernels here. + */ + if (filename == NULL) /* can't handle nameless */ + return(EFTYPE); + if ((fd = open(filename, O_RDONLY)) == -1) + return(errno); + if (read(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr)) + return(EFTYPE); /* could be EIO, but may be small file */ + if (N_BADMAG(ehdr)) + return(EFTYPE); + + /* + * Ok, we think this is for us. + */ + mp = malloc(sizeof(struct aout_kernel_module)); + mp->m.m_name = strdup(filename); /* XXX should we prune the name? */ + mp->m.m_type = "a.out kernel"; /* XXX only if that's what we really are */ + mp->m.m_args = NULL; /* XXX should we put the bootstrap args here and parse later? */ + mp->m.m_flags = MF_AOUT; /* we're an a.out kernel */ + mp->m_entry = (vm_offset_t)(ehdr.a_entry & 0xffffff); + if (dest == 0) + dest = (vm_offset_t)(ehdr.a_entry & 0x100000); + if (mod_findmodule(NULL, mp->m.m_type) != NULL) { + printf("aout_loadmodule: kernel already loaded\n"); + err = EPERM; + goto out; + } + printf("%s at 0x%x\n", filename, dest); + mp->m.m_addr = addr = dest; + + mp->m.m_size = aout_loadimage(fd, addr, &ehdr); + printf("\n"); + if (mp->m.m_size == 0) + goto ioerr; + + /* XXX and if these parts don't exist? */ + mp->m_bi.bi_symtab = mp->m.m_addr + ehdr.a_text + ehdr.a_data + ehdr.a_bss; + mp->m_bi.bi_esymtab = mp->m_bi.bi_symtab + sizeof(ehdr.a_syms) + ehdr.a_syms; + + /* Load OK, return module pointer */ + *result = (struct loaded_module *)mp; + return(0); + + ioerr: + err = EIO; + out: + close(fd); + free(mp); + return(err); +} + +/* + * With the file (fd) open on the image, and (ehdr) containing + * the exec header, load the image at (addr) + * + * Fixup the a_bss field in (ehdr) to reflect the padding added to + * align the symbol table. + */ +static int +aout_loadimage(int fd, vm_offset_t loadaddr, struct exec *ehdr) +{ + u_int pad; + vm_offset_t addr; + int ss; + + addr = loadaddr; + lseek(fd, N_TXTOFF(*ehdr), SEEK_SET); + + /* text segment */ + printf("text=0x%x ", ehdr->a_text); + if (pread(fd, addr, ehdr->a_text) != ehdr->a_text) + return(0); + addr += ehdr->a_text; + + /* data segment */ + printf("data=0x%x ", ehdr->a_data); + if (pread(fd, addr, ehdr->a_data) != ehdr->a_data) + return(0); + addr += ehdr->a_data; + + /* skip the BSS */ + printf("bss=0x%x ", ehdr->a_bss); + addr += ehdr->a_bss; + + /* pad to a page boundary */ + pad = (u_int)addr & PAGE_MASK; + if (pad != 0) { + pad = PAGE_SIZE - pad; + addr += pad; + ehdr->a_bss += pad; + } + /* XXX bi_symtab = addr */ + + /* symbol table size */ + vpbcopy(&ehdr->a_syms, addr, sizeof(ehdr->a_syms)); + addr += sizeof(ehdr->a_syms); + + /* symbol table */ + printf("symbols=[0x%x+0x%x+0x%x", pad, sizeof(ehdr->a_syms), ehdr->a_syms); + if (pread(fd, addr, ehdr->a_syms) != ehdr->a_syms) + return(0); + addr += ehdr->a_syms; + + /* string table */ + read(fd, &ss, sizeof(ss)); + vpbcopy(&ss, addr, sizeof(ss)); + addr += sizeof(ss); + ss -= sizeof(ss); + printf("+0x%x+0x%x]", sizeof(ss), ss); + if (pread(fd, addr, ss) != ss) + return(0); + /* XXX bi_esymtab = addr */ + addr += ss; + return(addr - loadaddr); +} + + +/* + * There is an a.out kernel and one or more a.out modules loaded. + * We wish to start executing the kernel image, so make such + * preparations as are required, and do so. + */ +static int +aout_exec(struct loaded_module *amp) +{ + struct aout_kernel_module *mp = (struct aout_kernel_module *)amp; + struct loaded_module *xp; + struct i386_devdesc *currdev; + u_int32_t argv[6]; /* kernel arguments */ + int major, bootdevnr; + vm_offset_t addr; + u_int pad; + + if ((amp->m_flags & MF_FORMATMASK) != MF_AOUT) + return(EFTYPE); + + /* Boot from whatever the current device is */ + i386_getdev((void **)(&currdev), NULL, NULL); + switch(currdev->d_type) { + case DEVT_DISK: + major = 0; /* XXX in the short term, have to work out a major number here for old kernels */ + bootdevnr = MAKEBOOTDEV(major, + currdev->d_kind.biosdisk.slice >> 4, + currdev->d_kind.biosdisk.slice & 0xf, + currdev->d_kind.biosdisk.unit, + currdev->d_kind.biosdisk.partition); + break; + default: + printf("aout_loadmodule: WARNING - don't know how to boot from device type %d\n", currdev->d_type); + } + free(currdev); + + /* Device data is kept in the kernel argv array */ + argv[1] = bootdevnr; + + argv[0] = bi_getboothowto(amp->m_args); +/* argv[2] = vtophys(bootinfo); /* old cyl offset (do we care about this?) */ + argv[3] = 0; + argv[4] = 0; + argv[5] = (u_int32_t)vtophys(&(mp->m_bi)); + + /* legacy bootinfo structure */ + mp->m_bi.bi_version = BOOTINFO_VERSION; + mp->m_bi.bi_memsizes_valid = 1; + /* XXX bi_vesa */ + mp->m_bi.bi_basemem = getbasemem(); + mp->m_bi.bi_extmem = getextmem(); + + /* find the last module in the chain */ + for (xp = amp; xp->m_next != NULL; xp = xp->m_next) + ; + addr = xp->m_addr + xp->m_size; + /* pad to a page boundary */ + pad = (u_int)addr & PAGE_MASK; + if (pad != 0) { + pad = PAGE_SIZE - pad; + addr += pad; + } + /* copy our environment XXX save addr here as env pointer */ + addr = bi_copyenv(addr); + + /* pad to a page boundary */ + pad = (u_int)addr & PAGE_MASK; + if (pad != 0) { + pad = PAGE_SIZE - pad; + addr += pad; + } + /* copy module list and metadata */ + bi_copymodules(addr); + +#ifdef DEBUG + { + int i; + for (i = 0; i < 6; i++) + printf("argv[%d]=%lx\n", i, argv[i]); + } + + printf("Start @ 0x%lx ...\n", mp->m_entry); +#endif + + startprog(mp->m_entry, 6, argv, (vm_offset_t)0x90000); + panic("exec returned"); +} Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/aout_freebsd.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/biosdelay.S =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/biosdelay.S (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/biosdelay.S (revision 49189) @@ -0,0 +1,79 @@ +/* $NetBSD: biosdelay.S,v 1.1.1.1 1997/03/14 02:40:32 perry Exp $ */ + +/* + * Copyright (c) 1996, 1997 + * Perry E. Metzger. 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 acknowledgements: + * This product includes software developed for the NetBSD Project + * by Perry E. Metzger. + * 4. The names of the authors 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. + * + */ + +#include + +#define data32 .byte 0x66 + + .text + +/* +# BIOS call "INT 15H Function 86H" to sleep for a set number of microseconds +# Call with %ah = 0x86 +# %cx = time interval (high) +# %dx = time interval (low) +# Return: +# If error +# CF = set +# else +# CF = clear +*/ +ENTRY(delay) + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + + movw 20(%esp), %dx + movw 22(%esp), %cx + + call CNAME(prot_to_real) + + movb $0x86, %ah + int $0x15 + setnc %ah + + movb %ah, %bl # real_to_prot uses %eax + + data32 + call CNAME(real_to_prot) + + xorl %eax, %eax + movb %bl, %al + + popl %edi + popl %esi + popl %ebx + popl %ebp + ret Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/biosdelay.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/biosdisk.c =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/biosdisk.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/biosdisk.c (revision 49189) @@ -0,0 +1,408 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +/* + * BIOS disk device handling. + * + * Ideas and algorithms from: + * + * - NetBSD libi386/biosdisk.c + * - FreeBSD biosboot/disk.c + * + * XXX Todo: add bad144 support. + */ + +#include + +#include +#include + +#include "bootstrap.h" +#include "libi386.h" +#include "crt/biosdisk_ll.h" + +#define BUFSIZE (1 * BIOSDISK_SECSIZE) +#define MAXBDDEV MAXDEV + +#ifdef DISK_DEBUG +# define D(x) x +#else +# define D(x) +#endif + +/* biosdisk_support.S */ +extern u_long bd_int13fn8(int unit); + +static int bd_edd3probe(int unit); +static int bd_edd1probe(int unit); +static int bd_int13probe(int unit); + +static int bd_init(void); +static int bd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, void *buf, size_t *rsize); +static int bd_open(struct open_file *f, void *vdev); +static int bd_close(struct open_file *f); + +struct open_disk { + struct biosdisk_ll od_ll; /* contains bios unit, geometry (XXX absorb) */ + int od_unit; /* our unit number */ + int od_boff; /* block offset from beginning of BIOS disk */ + int od_flags; +#define BD_MODEMASK 0x3 +#define BD_MODEINT13 0x0 +#define BD_MODEEDD1 0x1 +#define BD_MODEEDD3 0x2 +#define BD_FLOPPY (1<<2) + u_char od_buf[BUFSIZE]; /* transfer buffer (do we want/need this?) */ +}; + +struct devsw biosdisk = { + "disk", + DEVT_DISK, + bd_init, + bd_strategy, + bd_open, + bd_close, + noioctl +}; + +/* + * List of BIOS devices, translation from disk unit number to + * BIOS unit number. + */ +static struct +{ + int bd_unit; /* BIOS unit number */ + int bd_flags; +} bdinfo [MAXBDDEV]; +static int nbdinfo = 0; + +/* + * Quiz the BIOS for disk devices, save a little info about them. + * + * XXX should we be consulting the BIOS equipment list, specifically + * the value at 0x475? + */ +static int +bd_init(void) +{ + int base, unit; + + /* sequence 0, 0x80 */ + for (base = 0; base <= 0x80; base += 0x80) { + for (unit = base; (nbdinfo < MAXBDDEV); unit++) { + bdinfo[nbdinfo].bd_unit = -1; + bdinfo[nbdinfo].bd_flags = (unit < 0x80) ? BD_FLOPPY : 0; + + if (bd_edd3probe(unit)) { + bdinfo[nbdinfo].bd_flags |= BD_MODEEDD3; + } else if (bd_edd1probe(unit)) { + bdinfo[nbdinfo].bd_flags |= BD_MODEEDD1; + } else if (bd_int13probe(unit)) { + bdinfo[nbdinfo].bd_flags |= BD_MODEINT13; + } else { + break; + } + /* XXX we need "disk aliases" to make this simpler */ + printf("BIOS drive %c: is disk%d\n", + (unit < 0x80) ? ('A' + unit) : ('C' + unit - 0x80), nbdinfo); + bdinfo[nbdinfo].bd_unit = unit; + nbdinfo++; + } + } + return(0); +} + +/* + * Try to detect a device supported by an Enhanced Disk Drive 3.0-compliant BIOS + */ +static int +bd_edd3probe(int unit) +{ + return(0); /* XXX not implemented yet */ +} + +/* + * Try to detect a device supported by an Enhanced Disk Drive 1.1-compliant BIOS + */ +static int +bd_edd1probe(int unit) +{ + return(0); /* XXX not implemented yet */ +} + +/* + * Try to detect a device supported by the legacy int13 BIOS + */ + +static int +bd_int13probe(int unit) +{ + u_long geom; + + /* try int 0x13, function 8 */ + geom = bd_int13fn8(unit); + + return(geom != 0); +} + +/* + * Attempt to open the disk described by (dev) for use by (f). + * + * Note that the philosophy here is "give them exactly what + * they ask for". This is necessary because being too "smart" + * about what the user might want leads to complications. + * (eg. given no slice or partition value, with a disk that is + * sliced - are they after the first BSD slice, or the DOS + * slice before it?) + */ +static int +bd_open(struct open_file *f, void *vdev) +{ + struct i386_devdesc *dev = (struct i386_devdesc *)vdev; + struct dos_partition *dptr; + struct open_disk *od; + struct disklabel *lp; + int sector, slice, i; + int error; + + if (dev->d_kind.biosdisk.unit >= nbdinfo) { + D(printf("bd_open: attempt to open nonexistent disk\n")); + return(ENXIO); + } + + od = (struct open_disk *)malloc(sizeof(struct open_disk)); + if (!od) { + D(printf("bd_open: no memory\n")); + return (ENOMEM); + } + + /* Look up BIOS unit number, intialise open_disk structure */ + od->od_unit = dev->d_kind.biosdisk.unit; + od->od_ll.dev = bdinfo[od->od_unit].bd_unit; + od->od_flags = bdinfo[od->od_unit].bd_flags; + od->od_boff = 0; + error = 0; +#if 0 + D(printf("bd_open: open '%s' - unit 0x%x slice %d partition %c\n", + i386_fmtdev(dev), dev->d_kind.biosdisk.unit, + dev->d_kind.biosdisk.slice, dev->d_kind.biosdisk.partition + 'a')); +#endif + + /* Get geometry for this open (removable device may have changed) */ + if (set_geometry(&od->od_ll)) { + D(printf("bd_open: can't get geometry\n")); + error = ENXIO; + goto out; + } + + /* + * Following calculations attempt to determine the correct value + * for d->od_boff by looking for the slice and partition specified, + * or searching for reasonable defaults. + */ + + /* + * Find the slice in the DOS slice table. + */ + if (readsects(&od->od_ll, 0, 1, od->od_buf, 0)) { + D(printf("bd_open: error reading MBR\n")); + error = EIO; + goto out; + } + + /* + * Check the slice table magic. + */ + if ((od->od_buf[0x1fe] != 0xff) || (od->od_buf[0x1ff] != 0xaa)) { + /* If a slice number was explicitly supplied, this is an error */ + if (dev->d_kind.biosdisk.slice > 0) { + D(printf("bd_open: no slice table/MBR (no magic)\n")); + error = ENOENT; + goto out; + } + sector = 0; + goto unsliced; /* may be a floppy */ + } + dptr = (struct dos_partition *) & od->od_buf[DOSPARTOFF]; + + /* + * XXX No support here for 'extended' slices + */ + if (dev->d_kind.biosdisk.slice <= 0) { + /* + * Search for the first FreeBSD slice; this also works on "unsliced" + * disks, as they contain a "historically bogus" MBR. + */ + for (i = 0; i < NDOSPART; i++, dptr++) + if (dptr->dp_typ == DOSPTYP_386BSD) { + sector = dptr->dp_start; + break; + } + /* Did we find something? */ + if (sector == -1) { + error = ENOENT; + goto out; + } + } else { + /* + * Accept the supplied slice number unequivocally (we may be looking + * for a DOS partition) if we can handle it. + */ + if ((dev->d_kind.biosdisk.slice > NDOSPART) || (dev->d_kind.biosdisk.slice < 1)) { + error = ENOENT; + goto out; + } + dptr += (dev->d_kind.biosdisk.slice - 1); + sector = dptr->dp_start; + } + unsliced: + /* + * Now we have the slice, look for the partition in the disklabel if we have + * a partition to start with. + * + * XXX we might want to check the label checksum. + */ + if (dev->d_kind.biosdisk.partition < 0) { + od->od_boff = sector; /* no partition, must be after the slice */ + D(printf("bd_open: opening raw slice\n")); + } else { + + if (readsects(&od->od_ll, sector + LABELSECTOR, 1, od->od_buf, 0)) { + D(printf("bd_open: error reading disklabel\n")); + error = EIO; + goto out; + } + lp = (struct disklabel *) (od->od_buf + LABELOFFSET); + if (lp->d_magic != DISKMAGIC) { + D(printf("bd_open: no disklabel\n")); + error = ENOENT; + goto out; + + } else if (dev->d_kind.biosdisk.partition >= lp->d_npartitions) { + + /* + * The partition supplied is out of bounds; this is fatal. + */ + D(printf("partition '%c' exceeds partitions in table (a-'%c')\n", + 'a' + dev->d_kind.biosdisk.partition, 'a' + lp->d_npartitions)); + error = EPART; + goto out; + + } else { + + /* + * Complain if the partition type is wrong and it shouldn't be, but + * regardless accept this partition. + */ + D(if ((lp->d_partitions[dev->d_kind.biosdisk.partition].p_fstype == FS_UNUSED) && + !(od->od_flags & BD_FLOPPY)) /* Floppies often have bogus fstype */ + printf("bd_open: warning, partition marked as unused\n");); + + od->od_boff = lp->d_partitions[dev->d_kind.biosdisk.partition].p_offset; + } + } + /* + * Save our context + */ + ((struct i386_devdesc *)(f->f_devdata))->d_kind.biosdisk.data = od; +#if 0 + D(printf("bd_open: open_disk %p\n", od)); +#endif + + out: + if (error) + free(od); + return(error); +} + +static int +bd_close(struct open_file *f) +{ + struct open_disk *od = (struct open_disk *)(((struct i386_devdesc *)(f->f_devdata))->d_kind.biosdisk.data); + +#if 0 + D(printf("bd_close: open_disk %p\n", od)); +#endif + + /* XXX is this required? (especially if disk already open...) */ + if (od->od_flags & BD_FLOPPY) + delay(3000000); + + free(od); + return(0); +} + +static int +bd_strategy(void *devdata, int rw, daddr_t dblk, size_t size, void *buf, size_t *rsize) +{ + struct open_disk *od = (struct open_disk *)(((struct i386_devdesc *)devdata)->d_kind.biosdisk.data); + int blks; +#ifdef BD_SUPPORT_FRAGS + char fragbuf[BIOSDISK_SECSIZE]; + size_t fragsize; + + fragsize = size % BIOSDISK_SECSIZE; +#else + if (size % BIOSDISK_SECSIZE) + panic("bd_strategy: %d bytes I/O not multiple of block size", size); +#endif + +#if 0 + D(printf("bd_strategy: open_disk %p\n", od)); +#endif + + if (rw != F_READ) + return(EROFS); + + + blks = size / BIOSDISK_SECSIZE; +#if 0 + D(printf("bd_strategy: read %d from %d+%d to %p\n", blks, od->od_boff, dblk, buf)); +#endif + + if (rsize) + *rsize = 0; + if (blks && readsects(&od->od_ll, dblk + od->od_boff, blks, buf, 0)) { + D(printf("read error\n")); + return (EIO); + } +#ifdef BD_SUPPORT_FRAGS +#if 0 + D(printf("bd_strategy: frag read %d from %d+%d+d to %p\n", +#endif + fragsize, od->od_boff, dblk, blks, buf + (blks * BIOSDISK_SECSIZE))); + if (fragsize && readsects(&od->od_ll, dblk + od->od_boff + blks, 1, fragsize, 0)) { + D(printf("frag read error\n")); + return(EIO); + } + bcopy(fragbuf, buf + (blks * BIOSDISK_SECSIZE), fragsize); +#endif + if (rsize) + *rsize = size; + return (0); +} Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/biosdisk.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/biosdisk_support.S =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/biosdisk_support.S (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/biosdisk_support.S (revision 49189) @@ -0,0 +1,114 @@ +/* + * Mach Operating System + * Copyright (c) 1992, 1991 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + * + * from: Mach, Revision 2.2 92/04/04 11:34:26 rpd + * $Id: bios.S,v 1.12 1997/07/31 08:07:53 phk Exp $ + */ + +/* + Copyright 1988, 1989, 1990, 1991, 1992 + by Intel Corporation, Santa Clara, California. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appears in all +copies and that both the copyright notice and this permission notice +appear in supporting documentation, and that the name of Intel +not be used in advertising or publicity pertaining to distribution +of the software without specific, written prior permission. + +INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, +IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, +NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION +WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#include + +#define addr32 .byte 0x67 +#define data32 .byte 0x66 + +/* + * + * get_diskinfo(): return a word that represents the + * max number of sectors and heads and drives for this device + * + */ + +ENTRY(bd_int13fn8) + push %ebp + mov %esp, %ebp + push %ebx + push %esi + push %edi + + movb 0x8(%ebp), %dl /* diskinfo(drive #) */ + call CNAME(prot_to_real) /* enter real mode */ + + movb $0x8, %ah /* ask for disk info */ + + sti + int $0x13 + cli + + jnc ok + /* call failed, return 0 */ + subb %cl, %cl + subb %ch, %ch + subb %dl, %dl + subb %dh, %dh +ok: + + data32 + call CNAME(real_to_prot) /* back to protected mode */ + + /* + * form a longword representing all this gunk: + * 6 bit zero + * 10 bit max cylinder (0 based) + * 8 bit max head (0 based) + * 2 bit zero + * 6 bit max sector (1 based) = # sectors + */ + movb %cl, %al /* Upper two bits of cylinder count */ + andl $0xc0,%eax + leal 0(,%eax,4),%eax /* << 2 */ + movb %ch, %al /* Lower 8 bits */ + sall $16,%eax /* << 16 */ + movb %dh, %ah /* max head */ + andb $0x3f, %cl /* mask of cylinder gunk */ + movb %cl, %al /* max sector (and # sectors) */ + + pop %edi + pop %esi + pop %ebx + pop %ebp + ret + Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/biosdisk_support.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/biosgetrtc.S =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/biosgetrtc.S (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/biosgetrtc.S (revision 49189) @@ -0,0 +1,77 @@ +/* $NetBSD: biosgetrtc.S,v 1.2 1997/06/13 13:42:27 drochner Exp $ */ + +/* + * 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. + * + */ + +#include + +#define addr32 .byte 0x67 +#define data32 .byte 0x66 + +ENTRY(biosgetrtc) + pushl %ebp + movl %esp, %ebp + pushl %ebx + pushl %ecx + pushl %edx + push %esi + push %edi + + xorl %ebx, %ebx + + call CNAME(prot_to_real) # enter real mode + + movb $2, %ah + int $0x1a + jnc ok + data32 + movl $-1, %ebx + +ok: + data32 + call CNAME(real_to_prot) # back to protected mode + + movl 8(%ebp), %eax + movl $0, (%eax) + movb %ch, (%eax) + movb %cl, 1(%eax) + movb %dh, 2(%eax) + + movl %ebx, %eax + + pop %edi + pop %esi + popl %edx + popl %ecx + popl %ebx + popl %ebp + ret Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/biosgetrtc.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/biosmem.S =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/biosmem.S (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/biosmem.S (revision 49189) @@ -0,0 +1,99 @@ +/* $NetBSD: biosmem.S,v 1.5 1997/08/18 22:44:01 hannken Exp $ */ + +/* + * Copyright (c) 1996 + * Perry E. Metzger. 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 acknowledgements: + * This product includes software developed for the NetBSD Project + * by Perry E. Metzger. + * 4. The names of the authors 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. + * + */ + + +#include + +#define data32 .byte 0x66 + + .text + +/* get mem below 1M, in kByte */ + +ENTRY(getbasemem) + pushl %ebp + movl %esp,%ebp + pushl %ebx + push %esi + push %edi + + call CNAME(prot_to_real) + + int $0x12 + # zero-extend 16-bit result to 32 bits. + data32 + movl $0, %ebx + mov %eax,%ebx # !!! at run time, it is mov %ax,%bx + + data32 + call CNAME(real_to_prot) + + movl %ebx, %eax + + pop %edi + pop %esi + popl %ebx + popl %ebp + ret + +/* get mem above 1M, in kByte */ + +ENTRY(getextmem) + pushl %ebp + movl %esp,%ebp + pushl %ebx + push %esi + push %edi + + call CNAME(prot_to_real) + + movb $0x88,%ah + int $0x15 + + # zero-extend 16-bit result to 32 bits. + data32 + movl $0, %ebx + mov %eax,%ebx # !!! at run time, it is mov %ax,%bx + + data32 + call CNAME(real_to_prot) + + movl %ebx, %eax + + pop %edi + pop %esi + popl %ebx + popl %ebp + ret + Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/biosmem.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/biosreboot.S =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/biosreboot.S (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/biosreboot.S (revision 49189) @@ -0,0 +1,66 @@ +/* $NetBSD: biosreboot.S,v 1.1 1997/04/13 18:45:37 perry Exp $ */ + +/* + * Copyright (c) 1997 + * Perry E. Metzger. 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 acknowledgements: + * This product includes software developed for the NetBSD Project + * by Perry E. Metzger. + * 4. The names of the authors 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. + * + */ + + +#include + +#define data32 .byte 0x66 + + .text + +/* Call INT 19 to do the equivalent of CTL-ALT-DEL */ + +ENTRY(reboot) + pushl %ebp + movl %esp,%ebp + pushl %ebx + push %esi + push %edi + + call CNAME(prot_to_real) + + int $0x19 + + /* NOTE: We should never even get past this point. */ + + data32 + call CNAME(real_to_prot) + + movl %ebx, %eax + + pop %edi + pop %esi + popl %ebx + popl %ebp + ret Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/biosreboot.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/bootinfo.c =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/bootinfo.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/bootinfo.c (revision 49189) @@ -0,0 +1,197 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +#include +#include +#include "bootstrap.h" + + +/* + * Return a 'boothowto' value corresponding to the kernel arguments in + * (kargs) and any relevant environment variables. + */ +static struct +{ + char *ev; + int mask; +} howto_names[] = { + {"boot_askname", RB_ASKNAME}, + {"boot_userconfig", RB_CONFIG}, + {"boot_ddb", RB_KDB}, + {"boot_gdb", RB_GDB}, + {"boot_single", RB_SINGLE}, + {"boot_verbose", RB_VERBOSE}, + {NULL, 0} +}; + +int +bi_getboothowto(char *kargs) +{ + char *cp; + int howto; + int active; + int i; + + howto = 0; + if (kargs != NULL) { + cp = kargs; + active = 0; + while (*cp != 0) { + if (!active && (*cp == '-')) { + active = 1; + } else if (active) + switch (*cp) { + case 'a': + howto |= RB_ASKNAME; + break; + case 'c': + howto |= RB_CONFIG; + break; + case 'd': + howto |= RB_KDB; + break; + case 'g': + howto |= RB_GDB; + break; + case 'h': + howto |= RB_SERIAL; + break; + case 'r': + howto |= RB_DFLTROOT; + break; + case 's': + howto |= RB_SINGLE; + break; + case 'v': + howto |= RB_VERBOSE; + break; + default: + active = 0; + break; + } + } + cp++; + } + for (i = 0; howto_names[i].ev != NULL; i++) + if (getenv(howto_names[i].ev) != NULL) + howto |= howto_names[i].mask; + if (!strcmp(getenv("console"), "comconsole")) + howto |= RB_SERIAL; + return(howto); +} + +/* + * Copy the environment into the load area starting at (addr). + * Each variable is formatted as =, with a single nul + * separating each variable, and a double nul terminating the environment. + */ +vm_offset_t +bi_copyenv(vm_offset_t addr) +{ + struct env_var *ep; + + /* traverse the environment */ + for (ep = environ; ep != NULL; ep = ep->ev_next) { + vpbcopy(ep->ev_name, addr, strlen(ep->ev_name)); + addr += strlen(ep->ev_name); + vpbcopy("=", addr, 1); + addr++; + if (ep->ev_value != NULL) { + vpbcopy(ep->ev_value, addr, strlen(ep->ev_value)); + addr += strlen(ep->ev_value); + } + vpbcopy("", addr, 1); + addr++; + } + vpbcopy("", addr, 1); + addr++; +} + +/* + * Copy module-related data into the load area, where it can be + * used as a directory for loaded modules. + * + * Module data is presented in a self-describing format. Each datum + * is preceeded by a 16-bit identifier and a 16-bit size field. + * + * Currently, the following data are saved: + * + * MOD_NAME (variable) module name (string) + * MOD_TYPE (variable) module type (string) + * MOD_ADDR sizeof(vm_offset_t) module load address + * MOD_SIZE sizeof(size_t) module size + * MOD_METADATA (variable) type-specific metadata + */ +#define MOD_STR(t, a, s) { \ + u_int32_t ident = (t << 16) + strlen(s) + 1; \ + vpbcopy(&ident, a, sizeof(ident)); \ + a += sizeof(ident); \ + vpbcopy(s, a, strlen(s) + 1); \ + a += strlen(s) + 1; \ +} + +#define MOD_NAME(a, s) MOD_STR(MODINFO_NAME, a, s) +#define MOD_TYPE(a, s) MOD_STR(MODINFO_TYPE, a, s) + +#define MOD_VAR(t, a, s) { \ + u_int32_t ident = (t << 16) + sizeof(s); \ + vpbcopy(&ident, a, sizeof(ident)); \ + a += sizeof(ident); \ + vpbcopy(&s, a, sizeof(s)); \ + a += sizeof(s); \ +} + +#define MOD_ADDR(a, s) MOD_VAR(MODINFO_ADDR, a, s) +#define MOD_SIZE(a, s) MOD_VAR(MODINFO_SIZE, a, s) + +#define MOD_METADATA(a, mm) { \ + u_int32_t ident = ((MODINFO_METADATA | mm->md_type) << 16) + mm->md_size; \ + vpbcopy(&ident, a, sizeof(ident)); \ + a += sizeof(ident); \ + vpbcopy(mm->md_data, a, mm->md_size); \ + a += mm->md_size; \ +} + +vm_offset_t +bi_copymodules(vm_offset_t addr) +{ + struct loaded_module *mp; + struct module_metadata *md; + + /* start with the first module on the list, should be the kernel */ + for (mp = mod_findmodule(NULL, NULL); mp != NULL; mp = mp->m_next) { + + MOD_NAME(addr, mp->m_name); + MOD_TYPE(addr, mp->m_type); + MOD_ADDR(addr, mp->m_addr); + MOD_SIZE(addr, mp->m_size); + for (md = mp->m_metadata; md != NULL; md = md->md_next) + MOD_METADATA(addr, md); + } + return(addr); +} Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/bootinfo.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/comconsole.c =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/comconsole.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/comconsole.c (revision 49189) @@ -0,0 +1,78 @@ +/* + * Copyright (c) 1998 Michael Smith (msmith@freebsd.org) + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. + * + * From Id: probe_keyboard.c,v 1.13 1997/06/09 05:10:55 bde Exp + * + * $Id$ + */ + +#include + +#include "bootstrap.h" + +/* in comconsole.S */ +extern void cominit(int s); +extern void computc(int c); +extern int comgetc(void); +extern int comiskey(void); + +static void comc_probe(struct console *cp); +static int comc_init(int arg); +static int comc_in(void); + +struct console comconsole = { + "comconsole", + "BIOS serial port", + 0, + comc_probe, + comc_init, + computc, + comc_in, + comiskey +}; + +static void +comc_probe(struct console *cp) +{ + /* XXX check the BIOS equipment list? */ + cp->c_flags |= (C_PRESENTIN | C_PRESENTOUT); +} + +static int +comc_init(int arg) +{ + /* XXX arg is unit number, should we use variables instead? */ + cominit(arg); + return(0); +} + +static int +comc_in(void) +{ + if (comiskey()) { + return(comgetc()); + } else { + return(-1); + } +} Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/comconsole.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/comconsole_support.S =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/comconsole_support.S (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/comconsole_support.S (revision 49189) @@ -0,0 +1,147 @@ +/* $NetBSD: comio.S,v 1.2 1997/10/27 19:51:18 drochner Exp $ */ + +/* serial console handling + modelled after code in FreeBSD:sys/i386/boot/netboot/start2.S + */ + +#include + +#define addr32 .byte 0x67 +#define data32 .byte 0x66 + + .text + +/************************************************************************** +INIT - Initialization (com number) +**************************************************************************/ +ENTRY(cominit) + push %ebp + mov %esp,%ebp + push %ebx + push %edx + push %esi + push %edi + + movl 8(%ebp), %edx + + call CNAME(prot_to_real) # enter real mode + + # Initialize the serial port (dl) to 9600 baud, 8N1. + movb $0xe3, %al + movb $0, %ah + int $0x14 + mov %ax,%bx + + data32 + call CNAME(real_to_prot) # back to protected mode + + xor %eax,%eax + mov %bx,%ax + + pop %edi + pop %esi + pop %edx + pop %ebx + pop %ebp + ret + +/************************************************************************** +PUTC - Print a character (char, com number) +**************************************************************************/ +ENTRY(computc) + push %ebp + mov %esp,%ebp + push %ecx + push %ebx + push %edx + push %esi + push %edi + + movb 8(%ebp),%cl + movl 12(%ebp),%edx + + call CNAME(prot_to_real) # enter real mode + + movb %cl,%al + movb $0x01, %ah + int $0x14 + + movb %ah,%bl + + data32 + call CNAME(real_to_prot) # back to protected mode + + xor %eax,%eax + movb %bl,%al + + pop %edi + pop %esi + pop %edx + pop %ebx + pop %ecx + pop %ebp + ret + +/************************************************************************** +GETC - Get a character (com number) +**************************************************************************/ +ENTRY(comgetc) + push %ebp + mov %esp,%ebp + push %ebx + push %edx + push %esi + push %edi + + movl 8(%ebp),%edx + + call CNAME(prot_to_real) # enter real mode + + movb $0x02, %ah + int $0x14 + movl %eax,%ebx # at run time, it is mov %ax,%bx + + data32 + call CNAME(real_to_prot) # back to protected mode + + xor %eax,%eax + mov %bx,%ax + + pop %edi + pop %esi + pop %edx + pop %ebx + pop %ebp + ret + +/************************************************************************** +ISKEY - Check for keyboard interrupt (com number) +**************************************************************************/ +ENTRY(comiskey) + push %ebp + mov %esp,%ebp + push %ebx + push %edx + push %esi + push %edi + + movl 8(%ebp),%edx + + call CNAME(prot_to_real) # enter real mode + + movb $0x03, %ah + int $0x14 + mov %ax,%bx + + data32 + call CNAME(real_to_prot) # back to protected mode + + xor %eax,%eax + mov %bx,%ax + + pop %edi + pop %esi + pop %edx + pop %ebx + pop %ebp + ret Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/comconsole_support.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/Makefile =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/crt/Makefile (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/crt/Makefile (revision 49189) @@ -0,0 +1,3 @@ +SUBDIR= bootsect + +.include Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/Makefile ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bios_disk.S =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bios_disk.S (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bios_disk.S (revision 49189) @@ -0,0 +1,176 @@ +/* + * $Id$ + * From: $NetBSD: bios_disk.S,v 1.1.1.1 1997/03/14 02:40:32 perry Exp $ + */ + +/* + * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 + * + * Mach Operating System + * Copyright (c) 1992, 1991 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ + +/* + Copyright 1988, 1989, 1990, 1991, 1992 + by Intel Corporation, Santa Clara, California. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appears in all +copies and that both the copyright notice and this permission notice +appear in supporting documentation, and that the name of Intel +not be used in advertising or publicity pertaining to distribution +of the software without specific, written prior permission. + +INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, +IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, +NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION +WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +/* extracted from netbsd:sys/arch/i386/boot/bios.S */ + +#include + +#define addr32 .byte 0x67 +#define data32 .byte 0x66 + +/* +# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory +# Call with %ah = 0x2 +# %al = number of sectors +# %ch = cylinder +# %cl = sector +# %dh = head +# %dl = drive (0x80 for hard disk, 0x0 for floppy disk) +# %es:%bx = segment:offset of buffer +# Return: +# %al = 0x0 on success; err code on failure +*/ +ENTRY(biosread) + pushl %ebp + movl %esp, %ebp + pushl %ebx + push %ecx + push %edx + push %esi + push %edi + + movb 16(%ebp), %dh + movw 12(%ebp), %cx + xchgb %ch, %cl # cylinder; the highest 2 bits of cyl is in %cl + rorb $2, %cl + movb 20(%ebp), %al + orb %al, %cl + incb %cl # sector; sec starts from 1, not 0 + movb 8(%ebp), %dl # device + movl 28(%ebp), %ebx # offset + # prot_to_real will set %es to BOOTSEG + + call CNAME(prot_to_real) # enter real mode + + movb $0x2, %ah # subfunction + addr32 + movb 24(%ebp), %al # number of sectors + int $0x13 + setc %bl + + data32 + call CNAME(real_to_prot) # back to protected mode + + xorl %eax, %eax + movb %bl, %al # return value in %ax + + pop %edi + pop %esi + pop %edx + pop %ecx + popl %ebx + popl %ebp + ret + +/* +# +# get_diskinfo(): return a word that represents the +# max number of sectors and heads and drives for this device +# +*/ + +ENTRY(get_diskinfo) + pushl %ebp + movl %esp, %ebp + push %es + pushl %ebx + push %ecx + push %edx + push %esi + push %edi + + movb 8(%ebp), %dl # diskinfo(drive #) + + call CNAME(prot_to_real) # enter real mode + + movb $0x08, %ah # ask for disk info + int $0x13 + jnc ok + + /* + * Urk. Call failed. It is not supported for floppies by old BIOS's. + * Guess it's a 15-sector floppy. Initialize all the registers for + * documentation, although we only need head and sector counts. + */ +# subb %ah, %ah # %ax = 0 +# movb %ah, %bh # %bh = 0 +# movb $2, %bl # %bl bits 0-3 = drive type, 2 = 1.2M +# movb $79, %ch # max track + movb $15, %cl # max sector + movb $1, %dh # max head +# movb $1, %dl # # floppy drives installed + # es:di = parameter table + # carry = 0 + +ok: + data32 + call CNAME(real_to_prot) # back to protected mode + + xorl %eax, %eax + + /*form a longword representing all this gunk*/ + movb %dh, %ah # max head + andb $0x3f, %cl # mask of cylinder gunk + movb %cl, %al # max sector (and # sectors) + + pop %edi + pop %esi + pop %edx + pop %ecx + popl %ebx + pop %es + popl %ebp + ret Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bios_disk.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/biosdisk_ll.c =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/crt/biosdisk_ll.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/crt/biosdisk_ll.c (revision 49189) @@ -0,0 +1,148 @@ +/* + * $Id$ + * From: $NetBSD: biosdisk_ll.c,v 1.3 1997/06/13 13:36:06 drochner Exp $ + */ + +/* + * Copyright (c) 1996 + * Matthias Drochner. All rights reserved. + * Copyright (c) 1996 + * Perry E. Metzger. 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 acknowledgements: + * This product includes software developed for the NetBSD Project + * by Matthias Drochner. + * This product includes software developed for the NetBSD Project + * by Perry E. Metzger. + * 4. The names of the authors 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. + */ + +/* + * shared by bootsector startup (bootsectmain) and biosdisk.c + * needs lowlevel parts from bios_disk.S + */ + +#include + +#include "biosdisk_ll.h" +#include "diskbuf.h" + +/* XXX prototypes from export header? */ +extern int get_diskinfo(int); +extern int biosread(int, int, int, int, int, char *); + +#define SPT(di) ((di)&0xff) +#define HEADS(di) ((((di)>>8)&0xff)+1) + +int +set_geometry(d) + struct biosdisk_ll *d; +{ + int diskinfo; + + diskinfo = get_diskinfo(d->dev); + + d->spc = (d->spt = SPT(diskinfo)) * HEADS(diskinfo); + + /* + * get_diskinfo assumes floppy if BIOS call fails. Check at least + * "valid" geometry. + */ + return (!d->spc || !d->spt); +} + +/* + * Global shared "diskbuf" is used as read ahead buffer. For reading from + * floppies, the bootstrap has to be loaded on a 64K boundary to ensure that + * this buffer doesn't cross a 64K DMA boundary. + */ +static int ra_dev; +static int ra_end; +static int ra_first; + +int +readsects(d, dblk, num, buf, cold) /* reads ahead if (!cold) */ + struct biosdisk_ll *d; + int dblk, num; + char *buf; + int cold; /* don't use data segment or bss, don't call + * library functions */ +{ + while (num) { + int nsec; + + /* check for usable data in read-ahead buffer */ + if (cold || diskbuf_user != &ra_dev || d->dev != ra_dev + || dblk < ra_first || dblk >= ra_end) { + + /* no, read from disk */ + int cyl, head, sec; + char *trbuf; + + cyl = dblk / d->spc; + head = (dblk % d->spc) / d->spt; + sec = dblk % d->spt; + nsec = d->spt - sec; + + if (cold) { + /* transfer directly to buffer */ + trbuf = buf; + if (nsec > num) + nsec = num; + } else { + /* fill read-ahead buffer */ + trbuf = diskbuf; + if (nsec > diskbuf_size) + nsec = diskbuf_size; + + ra_dev = d->dev; + ra_first = dblk; + ra_end = dblk + nsec; + diskbuf_user = &ra_dev; + } + + if (biosread(d->dev, cyl, head, sec, nsec, trbuf)) { + if (!cold) + diskbuf_user = 0; /* mark invalid */ + return (-1); /* XXX cannot output here if + * (cold) */ + } + } else /* can take blocks from end of read-ahead + * buffer */ + nsec = ra_end - dblk; + + if (!cold) { + /* copy data from read-ahead to user buffer */ + if (nsec > num) + nsec = num; + bcopy(diskbuf + (dblk - ra_first) * BIOSDISK_SECSIZE, + buf, nsec * BIOSDISK_SECSIZE); + } + buf += nsec * BIOSDISK_SECSIZE; + num -= nsec; + dblk += nsec; + } + + return (0); +} Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/biosdisk_ll.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/biosdisk_ll.h =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/crt/biosdisk_ll.h (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/crt/biosdisk_ll.h (revision 49189) @@ -0,0 +1,54 @@ +/* + * $Id$ + * From: $NetBSD: biosdisk_ll.h,v 1.2 1997/03/22 01:41:36 thorpej Exp $ + */ + +/* + * Copyright (c) 1996 + * Matthias Drochner. All rights reserved. + * Copyright (c) 1996 + * Perry E. Metzger. 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 acknowledgements: + * This product includes software developed for the NetBSD Project + * by Matthias Drochner. + * This product includes software developed for the NetBSD Project + * by Perry E. Metzger. + * 4. The names of the authors 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. + */ + +/* + * shared by bootsector startup (bootsectmain) and biosdisk.c needs lowlevel + * parts from bios_disk.S + */ + +struct biosdisk_ll { + int dev; /* BIOS device number */ + int spt, spc; /* geometry */ +}; + +#define BIOSDISK_SECSIZE 512 + +extern int set_geometry(struct biosdisk_ll *); +extern int readsects(struct biosdisk_ll *, int, int, char *, int); Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/biosdisk_ll.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bootsect/Makefile =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bootsect/Makefile (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bootsect/Makefile (revision 49189) @@ -0,0 +1,25 @@ +# +# Build a startup module +# + +# Disk buffer size in sectors +CFLAGS+= -DDISKBUFSIZE=18 +# Stack size in bytes +CFLAGS+= -DSTACKSIZE=0x1000 + +PROG= bscrt.o +LDFLAGS= -static -nostartfiles -nostdlib -Xlinker -r +NOMAN= yes + +# Bootblock-specific sources +SRCS= start_bootsect.S fraglist.S bootsectmain.c + +# Includes for libsa support routines XXX fix path! +CFLAGS+= -I${.CURDIR}/../../../../../whole/lib/libstand + +# Common items across all startups +.PATH: ${.CURDIR}/.. +CFLAGS+= -I${.CURDIR}/.. +SRCS+= biosdisk_ll.c bios_disk.S buffers.S + +.include Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bootsect/Makefile ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bootsect/bbinfo.h =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bootsect/bbinfo.h (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bootsect/bbinfo.h (revision 49189) @@ -0,0 +1,64 @@ +/* + * $Id$ + * From: $NetBSD: bbinfo.h,v 1.3 1997/11/07 16:59:41 drochner Exp $ + */ + +/* + * 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. + * + */ + +/* data structure shared by bootsector + and installboot + */ + +#ifndef __ASSEMBLER__ + +struct fraglist { + int magic; + int loadsz; /* blocks loaded by primary boot */ + int numentries, maxentries; + struct { + int offset, num; + } entries[1]; +}; + +#endif + +#define FRAGLISTVERSION 0 +#define FRAGLISTMAGIC (0xb00deda5 + FRAGLISTVERSION) + +/* only used by bootsect code (not by installboot) */ +#ifndef MAXFLENTRIES +#define MAXFLENTRIES 10 +#endif +#ifndef PRIM_LOADSZ +#define PRIM_LOADSZ 15 +#endif Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bootsect/bbinfo.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bootsect/bootsectmain.c =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bootsect/bootsectmain.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bootsect/bootsectmain.c (revision 49189) @@ -0,0 +1,88 @@ +/* + * $Id$ + * From: $NetBSD: bootsectmain.c,v 1.1.1.1 1997/03/14 02:40:34 perry Exp $ + */ + +/* + * 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. + * + */ + +/* load remainder of boot program + (blocks from fraglist), + start main() + needs lowlevel parts from biosdisk_ll.c + */ + +#include "biosdisk_ll.h" +#include "bbinfo.h" + +int boot_biosdev; /* exported */ + +extern struct fraglist fraglist; +extern char edata[], end[]; + +extern void main(void); + +void bootsectmain(biosdev) +int biosdev; +{ + struct biosdisk_ll d; + int i; + char *buf; + + /* + * load sectors from bootdev + */ + d.dev = biosdev; + set_geometry(&d); + + buf = (char*)(PRIM_LOADSZ * BIOSDISK_SECSIZE); + + for(i = 0; i < fraglist.numentries; i++) { + int dblk, num; + + dblk = fraglist.entries[i].offset; + num = fraglist.entries[i].num; + + if(readsects(&d, dblk, num, buf, 1)) + return; /* halts in start_bootsect.S */ + + buf += num * BIOSDISK_SECSIZE; + } + + /* clear BSS */ + buf = edata; + while(buf < end) *buf++ = 0; + + /* call main() */ + boot_biosdev = biosdev; +/* main(); */ +} Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bootsect/bootsectmain.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bootsect/fraglist.S =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bootsect/fraglist.S (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bootsect/fraglist.S (revision 49189) @@ -0,0 +1,49 @@ +/* $NetBSD: fraglist.S,v 1.1.1.1 1997/03/14 02:40:34 perry Exp $ */ + +/* + * 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. + * + */ + +/* space for fragment list + goes to text section - must be loaded by primary boot + */ + +#include "bbinfo.h" + + .text + + .globl _fraglist +_fraglist: + .long FRAGLISTMAGIC + .long PRIM_LOADSZ /* blocks already in memory */ + .long 0 + .long MAXFLENTRIES + . = . + 2 * MAXFLENTRIES * 4 Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bootsect/fraglist.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bootsect/start_bootsect.S =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bootsect/start_bootsect.S (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bootsect/start_bootsect.S (revision 49189) @@ -0,0 +1,540 @@ +/* $NetBSD: start_bootsect.S,v 1.3 1998/02/19 14:15:38 drochner Exp $ */ + +/* BIOS bootsector startup + parts from netbsd:sys/arch/i386/boot/start.S + and freebsd:sys/i386/boot/biosboot/boot2.S + */ + +/* + * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 + * + * Mach Operating System + * Copyright (c) 1992, 1991 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ + +/* + Copyright 1988, 1989, 1990, 1991, 1992 + by Intel Corporation, Santa Clara, California. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appears in all +copies and that both the copyright notice and this permission notice +appear in supporting documentation, and that the name of Intel +not be used in advertising or publicity pertaining to distribution +of the software without specific, written prior permission. + +INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, +IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, +NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION +WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#include +#define addr32 .byte 0x67 +#define data32 .byte 0x66 +/* #include */ + +#include "bbinfo.h" + +BOOTSEG = 0x0100 # boot will be loaded here (below 640K) +BOOTSTACK = 0xfffc # boot stack +LOADSZ = PRIM_LOADSZ # size of first loaded chunk + +SIGNATURE = 0xaa55 +PARTSTART = 0x1be # starting address of partition table +NUMPART = 4 # number of partitions in partition table +PARTSZ = 16 # sizeof(struct dos_partition) +BSDPART = 0xA5 +BOOTABLE = 0x80 # value of dp_flag, means bootable partition + + .text +_boot1: +ENTRY(start) + # start (aka boot1) is loaded at 0x0:0x7c00 but we want 0x7c0:0 + # ljmp to the next instruction to adjust %cs + data32 + ljmp $0x7c0, $start1 + +start1: + # set up %ds + movl %cs, %ax + movl %ax, %ds + + # temporary stack while we locate boot2 + # set up %ss and %esp + data32 + movl $BOOTSEG, %eax + movl %ax, %ss + data32 + movl $BOOTSTACK, %esp + + /*** set up %es, (where we will load boot2 to) ***/ + movl %ax, %es + + # bootstrap passes us drive number in %dl + cmpb $0x80, %dl + data32 + jae hd + +fd: +# reset the disk system + movb $0x00, %ah + int $0x13 + data32 + movl $0x0001, %ecx # cyl 0, sector 1 + movb $0x00, %dh # head + # XXX Override the drive number. + movb $0x00, %dl + data32 + jmp load + +hd: /**** load sector 0 (DOSBBSECTOR) into the BOOTSEG ****/ + data32 + movl $0x0201, %eax + xorl %ebx, %ebx # %bx = 0 + data32 + movl $0x0001, %ecx + data32 + andl $0xff, %edx + /*mov $0x0080, %edx*/ + int $0x13 + data32 + jb read_error + + /***# find the first BSD partition *****/ + data32 + movl $PARTSTART, %ebx + data32 + movl $NUMPART, %ecx +again: + addr32 + movb %es:4(%ebx), %al /* dp_typ */ + cmpb $BSDPART, %al + data32 + je found + data32 + addl $PARTSZ, %ebx + data32 + loop again + + /* didn't find either NetBSD or 386BSD partitions */ + data32 + movl $enoboot, %esi + data32 + jmp err_stop + + +/* +# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory +# Call with %ah = 0x2 +# %al = number of sectors +# %ch = cylinder +# %cl = sector +# %dh = head +# %dl = drive (0x80 for hard disk, 0x0 for floppy disk) +# %es:%bx = segment:offset of buffer +# Return: +# %al = 0x0 on success; err code on failure +*/ + +found: + addr32 + movb %es:1(%ebx), %dh /* head: dp_sdh */ + addr32 + movl %es:2(%ebx), %ecx /*sect, cyl: dp_ssect + (dp_scyl << 8)*/ + +load: + movb $0x2, %ah /* function 2 */ + movb $LOADSZ, %al /* number of blocks */ + xorl %ebx, %ebx /* %bx = 0, put it at 0 in the BOOTSEG */ + int $0x13 + data32 + jb read_error + + # ljmp to the second stage boot loader (boot2). + # After ljmp, %cs is BOOTSEG and boot1 (512 bytes) will be used + # for stack space while we load boot3. + + data32 + ljmp $BOOTSEG, $CNAME(boot2) + +# +# read_error +# + +read_error: + data32 + movl $eread, %esi +err_stop: + data32 + call message + data32 + jmp stop + +# +# message: write the error message in %ds:%esi to console +# + +message: +/* +# BIOS call "INT 10H Function 0Eh" to write character to console +# Call with %ah = 0x0e +# %al = character +# %bh = page +# %bl = foreground color +*/ + data32 + pushl %eax + data32 + pushl %ebx + data32 + pushl %edx + +nextb: + cld + lodsb # load a byte into %al + testb %al, %al + data32 + jz done + + movb $0x0e, %ah + data32 + movl $0x0001, %ebx + int $0x10 + + data32 + jmp nextb + +done: + data32 + popl %edx + data32 + popl %ebx + data32 + popl %eax + data32 + ret + +_ourseg: + .long 0 + +/************************************************************************** +GLOBAL DESCRIPTOR TABLE +**************************************************************************/ + .align 4 +gdt: /* 0x0 */ + .word 0, 0 + .byte 0, 0x00, 0x00, 0 + +/* additional dummy for Linux support (?) */ /* 0x8 */ + .word 0, 0 + .byte 0, 0x00, 0x00, 0 + + /* kernel code segment */ + .globl flatcodeseg +flatcodeseg = . - gdt /* 0x10 */ + .word 0xffff, 0 + .byte 0, 0x9f, 0xcf, 0 + + /* kernel data segment */ + .globl flatdataseg +flatdataseg = . - gdt /* 0x18 */ + .word 0xffff, 0 + .byte 0, 0x93, 0xcf, 0 + + /* boot code segment, will be patched */ +bootcodeseg = . - gdt /* 0x20 */ + .word 0xffff, 0 + .byte 0, 0x9e, 0x40, 0 + + /* boot data segment, will be patched */ +bootdataseg = . - gdt /* 0x28 */ + .word 0xffff, 0 + .byte 0, 0x92, 0x0f, 0 + + /* 16 bit real mode, will be patched */ +bootrealseg = . - gdt /* 0x30 */ + .word 0xffff, 0 + .byte 0, 0x9e, 0x00, 0 +gdtlen = . - gdt + + .align 4 +gdtarg: + .word gdtlen-1 /* limit */ + .long 0 /* addr, will be inserted */ + +_boot2: + data32 + xorl %eax, %eax + movl %cs, %ax + movl %ax, %ds + movl %ax, %es + addr32 + data32 + movl %eax, CNAME(ourseg) + data32 + shll $4, %eax + + /* fix up GDT entries for bootstrap */ +#define FIXUP(gdt_index) \ + addr32; \ + movl %eax, gdt+gdt_index+2; /* actually movw %ax */ \ + addr32; \ + movb %bl, gdt+gdt_index+4 + + data32 + shldl $16, %eax, %ebx + + FIXUP(bootcodeseg) + FIXUP(bootrealseg) + FIXUP(bootdataseg) + + /* fix up GDT pointer */ + data32 + addl $gdt, %eax + addr32 + data32 + movl %eax, gdtarg+2 + + /* change to protected mode */ + data32 + call CNAME(real_to_prot) + + /* move the stack over the top of boot1 while we load */ + movl $_ourseg - 4, %eax + movl %eax, %esp + + movzbl %dl, %edx /* discard head (%dh) and random high bits */ + pushl %edx + call CNAME(bootsectmain) + + /* Go to internal stack */ + movl $CNAME(stacktop), %eax + movl %eax, %esp + call CNAME(main) + + +ENTRY(exit) +stop: + cli + hlt + +eread: .asciz "Read error\r\n" +enoboot: .asciz "No bootable partition\r\n" +endofcode: +/* throw in a partition in case we are block0 as well */ +/* flag, head, sec, cyl, typ, ehead, esect, ecyl, start, len */ + . = CNAME(boot1) + PARTSTART + .byte 0x0,0,0,0,0,0,0,0 + .long 0,0 + .byte 0x0,0,0,0,0,0,0,0 + .long 0,0 + .byte 0x0,0,0,0,0,0,0,0 + .long 0,0 + .byte BOOTABLE,0,1,0,BSDPART,255,255,255 + .long 0,50000 +/* the last 2 bytes in the sector 0 contain the signature */ + . = CNAME(boot1) + 0x1fe + .short SIGNATURE + . = CNAME(boot1) + 0x200 + .globl _disklabel +_disklabel: + . = CNAME(boot1) + 0x400 + + +CR0_PE = 0x1 +/* + * real_to_prot() + * transfer from real mode to protected mode. + */ +ENTRY(real_to_prot) + # guarantee that interrupt is disabled when in prot mode + cli + + # load the gdtr + addr32 + data32 + lgdt gdtarg + + # set the PE bit of CR0 + movl %cr0, %eax + + data32 + orl $CR0_PE, %eax + movl %eax, %cr0 + + # make intrasegment jump to flush the processor pipeline and + # reload CS register + data32 + ljmp $bootcodeseg, $xprot + +xprot: + # we are in USE32 mode now + # set up the protected mode segment registers : DS, SS, ES + movl $bootdataseg, %eax + movl %ax, %ds + movl %ax, %ss + movl %ax, %es + + ret + +/* + * prot_to_real() + * transfer from protected mode to real mode + */ +ENTRY(prot_to_real) + # set up a dummy stack frame for the second seg change. + # Adjust the intersegment jump instruction following + # the clearing of protected mode bit. + # This is self-modifying code, but we need a writable + # code segment, and an intersegment return does not give us that. + + movl _ourseg, %eax + movw %ax, xreal-2 + + # Change to use16 mode. + ljmp $bootrealseg, $x16 + +x16: + # clear the PE bit of CR0 + movl %cr0, %eax + data32 + andl $~CR0_PE, %eax + movl %eax, %cr0 + # Here we have an 16 bits intersegment jump. + .byte 0xea + .word xreal + .word 0 + +xreal: + # we are in real mode now + # set up the real mode segment registers : DS, SS, ES + movl %cs, %ax + movl %ax, %ds + movl %ax, %ss + movl %ax, %es + + sti + data32 + ret + +/* + * pbzero(dst, cnt) + * where dst is a physical address and cnt is the length + */ +ENTRY(pbzero) + pushl %ebp + movl %esp, %ebp + pushl %es + pushl %edi + + cld + + # set %es to point at the flat segment + movl $flatdataseg, %eax + movl %ax, %es + + movl 8(%ebp), %edi # destination + movl 12(%ebp), %ecx # count + xorl %eax, %eax # value + + rep + stosb + + popl %edi + popl %es + popl %ebp + ret + +/* + * vpbcopy(src, dst, cnt) + * where src is a virtual address and dst is a physical address + */ +ENTRY(vpbcopy) + pushl %ebp + movl %esp, %ebp + pushl %es + pushl %esi + pushl %edi + + cld + + # set %es to point at the flat segment + movl $flatdataseg, %eax + movl %ax, %es + + movl 8(%ebp), %esi # source + movl 12(%ebp), %edi # destination + movl 16(%ebp), %ecx # count + + rep + movsb + + popl %edi + popl %esi + popl %es + popl %ebp + ret + +/* + * pvbcopy(src, dst, cnt) + * where src is a physical address and dst is a virtual address + */ +ENTRY(pvbcopy) + pushl %ebp + movl %esp, %ebp + pushl %ds + pushl %esi + pushl %edi + + cld + + # set %ds to point at the flat segment + movl $flatdataseg, %eax + movl %ax, %ds + + movl 8(%ebp), %esi # source + movl 12(%ebp), %edi # destination + movl 16(%ebp), %ecx # count + + rep + movsb + + popl %edi + popl %esi + popl %ds + popl %ebp + ret + +ENTRY(vtophys) + movl _ourseg, %eax + shll $4, %eax + addl 4(%esp), %eax + ret Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/bootsect/start_bootsect.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/buffers.S =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/crt/buffers.S (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/crt/buffers.S (revision 49189) @@ -0,0 +1,27 @@ +/* + * Provide buffer space for various items. + * + * We do this in the text segment so that we can control the location + * of the buffers at the link stage, and thus ensure that they are + * within reach of the real-mode support routines. + * + * It is especially important to have the stack down low so that + * it is reachable from both 32-bit and 16-bit code. + */ + +#include + + .text + .align 4 +ENTRY(diskbuf) + . = CNAME(diskbuf) + (DISKBUFSIZE * 512) +ENTRY(diskbuf_user) + .long 0 +ENTRY(diskbuf_size) + .long DISKBUFSIZE + + .align 4 +ENTRY(stackbase) + . = CNAME(stackbase) + STACKSIZE +ENTRY(stacktop) + .long 0 Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/buffers.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/diskbuf.h =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/crt/diskbuf.h (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/crt/diskbuf.h (revision 49189) @@ -0,0 +1,42 @@ +/* + * $Id$ + * From: $NetBSD: diskbuf.h,v 1.1.1.1 1997/03/14 02:40:32 perry Exp $ + */ + +/* + * 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. + * + */ + +/* data buffer for BIOS disk / DOS I/O */ + +extern char diskbuf[]; /* client-supplied disk buffer */ +extern void *diskbuf_user; /* using function sets it to unique value to allow check if overwritten*/ +extern int diskbuf_size; /* size of client-supplied buffer in sectors */ Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/crt/diskbuf.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/devicename.c =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/devicename.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/devicename.c (revision 49189) @@ -0,0 +1,234 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +#include +#include +#include +#include "bootstrap.h" +#include "libi386.h" + +static int i386_parsedev(struct i386_devdesc **dev, char *devspec, char **path); + +/* + * Point (dev) at an allocated device specifier for the device matching the + * path in (devspec). If it contains an explicit device specification, + * use that. If not, use the default device. + */ +int +i386_getdev(void **vdev, char *devspec, char **path) +{ + struct i386_devdesc **dev = (struct i386_devdesc **)vdev; + int rv; + + /* + * If it looks like this is just a path and no + * device, go with the current device. + */ + if ((devspec == NULL) || + (devspec[0] == '/') || + (strchr(devspec, ':') == NULL)) { + + if (((rv = i386_parsedev(dev, getenv("currdev"), NULL)) == 0) && + (path != NULL)) + *path = devspec; + return(rv); + } + + /* + * Try to parse the device name off the beginning of the devspec + */ + return(i386_parsedev(dev, devspec, path)); +} + +/* + * Point (dev) at an allocated device specifier matching the string version + * at the beginning of (devspec). Return a pointer to the remaining + * text in (path). + * + * In all cases, the beginning of (devspec) is compared to the names + * of known devices in the device switch, and then any following text + * is parsed according to the rules applied to the device type. + * + * For disk-type devices, the syntax is: + * + * disk[s][]: + * + */ +static int +i386_parsedev(struct i386_devdesc **dev, char *devspec, char **path) +{ + struct i386_devdesc *idev; + struct devsw *dv; + int i, unit, slice, partition, err; + char *cp, *np; + + /* minimum length check */ + if (strlen(devspec) < 2) + return(EINVAL); + + /* look for a device that matches */ + for (i = 0, dv = NULL; devsw[i] != NULL; i++) { + if (!strncmp(devspec, devsw[i]->dv_name, strlen(devsw[i]->dv_name))) { + dv = devsw[i]; + break; + } + } + if (dv == NULL) + return(ENOENT); + idev = malloc(sizeof(struct i386_devdesc)); + err = 0; + np = (devspec + strlen(dv->dv_name)); + + switch(dv->dv_type) { + case DEVT_NONE: /* XXX what to do here? Do we care? */ + break; + + case DEVT_DISK: + unit = -1; + slice = -1; + partition = -1; + if (*np && (*np != ':')) { + unit = strtol(np, &cp, 10); /* next comes the unit number */ + if (cp == np) { + err = EUNIT; + goto fail; + } + if (*cp == 's') { /* got a slice number */ + np = cp + 1; + slice = strtol(np, &cp, 10); + if (cp == np) { + err = ESLICE; + goto fail; + } + } + if (*cp && (*cp != ':')) { + partition = *cp - 'a'; /* get a partition number */ + if ((partition < 0) || (partition >= MAXPARTITIONS)) { + err = EPART; + goto fail; + } + cp++; + } + } + if (*cp && (*cp != ':')) { + err = EINVAL; + goto fail; + } + + idev->d_kind.biosdisk.unit = unit; + idev->d_kind.biosdisk.slice = slice; + idev->d_kind.biosdisk.partition = partition; + if (path != NULL) + *path = (*cp == 0) ? cp : cp + 1; + break; + + case DEVT_NET: + unit = 0; + + if (*np && (*np != ':')) { + unit = strtol(np, &cp, 0); /* get unit number if present */ + if (cp == np) { + err = EUNIT; + goto fail; + } + } + if (*cp && (*cp != ':')) { + err = EINVAL; + goto fail; + } + + idev->d_kind.netif.unit = unit; + if (path != NULL) + *path = (*cp == 0) ? cp : cp + 1; + break; + + default: + err = EINVAL; + goto fail; + } + idev->d_dev = dv; + idev->d_type = dv->dv_type; + if (dev == NULL) { + free(idev); + } else { + *dev = idev; + } + return(0); + + fail: + free(idev); + return(err); +} + + +char * +i386_fmtdev(void *vdev) +{ + struct i386_devdesc *dev = (struct i386_devdesc *)vdev; + static char buf[128]; /* XXX device length constant? */ + char *cp; + + switch(dev->d_type) { + case DEVT_NONE: + strcpy(buf, "(no device)"); + break; + + case DEVT_DISK: + cp = buf; + cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_kind.biosdisk.unit); + if (dev->d_kind.biosdisk.slice > 0) + cp += sprintf(cp, "s%d", dev->d_kind.biosdisk.slice); + if (dev->d_kind.biosdisk.partition >= 0) + cp += sprintf(cp, "%c", dev->d_kind.biosdisk.partition + 'a'); + strcat(cp, ":"); + break; + + case DEVT_NET: + sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_kind.netif.unit); + break; + } + return(buf); +} + + +/* + * Set currdev to suit the value being supplied in (value) + */ +int +i386_setcurrdev(struct env_var *ev, int flags, void *value) +{ + struct i386_devdesc *ncurr; + int rv; + + if ((rv = i386_parsedev(&ncurr, value, NULL)) != 0) + return(rv); + free(ncurr); + env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); + return(0); +} + Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/devicename.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/gatea20.c =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/gatea20.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/gatea20.c (revision 49189) @@ -0,0 +1,52 @@ +/* + * $Id$ + * From: $NetBSD: gatea20.c,v 1.2 1997/10/29 00:32:49 fvdl Exp $ + */ + +/* extracted from freebsd:sys/i386/boot/biosboot/io.c */ + +#include +#include + +#include + +#include "libi386.h" + +#define K_RDWR 0x60 /* keyboard data & cmds (read/write) */ +#define K_STATUS 0x64 /* keyboard status */ +#define K_CMD 0x64 /* keybd ctlr command (write-only) */ + +#define K_OBUF_FUL 0x01 /* output buffer full */ +#define K_IBUF_FUL 0x02 /* input buffer full */ + +#define KC_CMD_WIN 0xd0 /* read output port */ +#define KC_CMD_WOUT 0xd1 /* write output port */ +#define KB_A20 0x9f /* enable A20, + reset (!), + enable output buffer full interrupt + enable data line + disable clock line */ + +/* + * Gate A20 for high memory + */ +static unsigned char x_20 = KB_A20; +void gateA20() +{ + __asm("pushfl ; cli"); +#ifdef IBM_L40 + outb(0x92, 0x2); +#else IBM_L40 + while (inb(K_STATUS) & K_IBUF_FUL); + while (inb(K_STATUS) & K_OBUF_FUL) + (void)inb(K_RDWR); + + outb(K_CMD, KC_CMD_WOUT); + delay(100); + while (inb(K_STATUS) & K_IBUF_FUL); + outb(K_RDWR, x_20); + delay(100); + while (inb(K_STATUS) & K_IBUF_FUL); +#endif IBM_L40 + __asm("popfl"); +} Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/gatea20.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/getsecs.c =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/getsecs.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/getsecs.c (revision 49189) @@ -0,0 +1,40 @@ +/* + * $Id$ + * From: $NetBSD: getsecs.c,v 1.1.1.1 1997/03/14 02:40:32 perry Exp $ + */ + +/* extracted from netbsd:sys/arch/i386/netboot/misc.c */ + +#include +#include + +#include "libi386.h" + +extern int biosgetrtc __P((u_long*)); + +time_t +time(time_t *tloc) { + /* + * Return the current time (of day) in seconds. + * XXX should be extended to do it "more right" perhaps? + * XXX uses undocumented BCD support from libstand. + */ + + u_long t; + time_t sec; + + if(biosgetrtc(&t)) + panic("RTC invalid"); + + sec = bcd2bin(t & 0xff); + sec *= 60; + t >>= 8; + sec += bcd2bin(t & 0xff); + sec *= 60; + t >>= 8; + sec += bcd2bin(t & 0xff); + + if (tloc != NULL) + *tloc = sec; + return(sec); +} Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/getsecs.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/i386_module.c =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/i386_module.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/i386_module.c (revision 49189) @@ -0,0 +1,64 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +/* + * i386-specific module functionality. + * + */ + +#include +#include + +#include "bootstrap.h" +#include "libi386.h" + +/* + * Look for a method and having found it, boot the kernel module. + */ +int +i386_boot(void) +{ + int i; + + for (i = 0; module_formats[i] != NULL; i++) { + if (((loaded_modules->m_flags & MF_FORMATMASK) == module_formats[i]->l_format) && + (module_formats[i]->l_exec != NULL)) { + return((module_formats[i]->l_exec)(loaded_modules)); + } + } +} + +/* + * Use voodoo to load modules required by current hardware. + */ +int +i386_autoload(void) +{ + /* XXX use PnP to locate stuff here */ + return(0); +} Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/i386_module.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/libi386.h =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/libi386.h (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/libi386.h (revision 49189) @@ -0,0 +1,86 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + + +/* + * i386 fully-qualified device descriptor. + * Note, this must match the 'struct devdesc' declaration + * in bootstrap.h. + */ +struct i386_devdesc +{ + struct devsw *d_dev; + int d_type; + union + { + struct + { + int unit; + int slice; + int partition; + void *data; + } biosdisk; + struct + { + int unit; /* XXX net layer lives over these? */ + } netif; + } d_kind; +}; + +extern int i386_getdev(void **vdev, char *devspec, char **path); +extern char *i386_fmtdev(void *vdev); +extern int i386_setcurrdev(struct env_var *ev, int flags, void *value); + +extern struct devdesc currdev; /* our current device */ + +#define MAXDEV 31 /* maximum number of distinct devices */ + +/* exported devices XXX rename? */ +extern struct devsw biosdisk; + +/* from crt module */ +extern void vpbcopy(void*, vm_offset_t, int); +extern void pvbcopy(vm_offset_t, void*, int); +extern void pbzero(vm_offset_t, int); +extern vm_offset_t vtophys(void*); + +extern int pread(int, vm_offset_t, int); +extern void startprog(vm_offset_t, int, u_int32_t *, vm_offset_t); + +extern void delay(int); +extern int getbasemem(void); +extern int getextmem(void); + +extern void reboot(void); +extern void gateA20(void); + +extern int i386_boot(void); +extern int i386_autoload(void); + +extern int bi_getboothowto(char *kargs); +extern vm_offset_t bi_copyenv(vm_offset_t addr); Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/libi386.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/pread.c =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/pread.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/pread.c (revision 49189) @@ -0,0 +1,79 @@ +/* + * $Id$ + * From: $NetBSD: pread.c,v 1.2 1997/03/22 01:48:38 thorpej Exp $ + */ + +/* + * 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. + * + */ + +/* read into destination in flat addr space */ + +#include + +#include "libi386.h" + +#ifdef SAVE_MEMORY +#define BUFSIZE (1*1024) +#else +#define BUFSIZE (4*1024) +#endif + +static char buf[BUFSIZE]; + +int +pread(fd, dest, size) + int fd; + vm_offset_t dest; + int size; +{ + int rsize; + + rsize = size; + while (rsize > 0) { + int count, got; + + count = (rsize < BUFSIZE ? rsize : BUFSIZE); + + got = read(fd, buf, count); + if (got < 0) + return (-1); + + /* put to physical space */ + vpbcopy(buf, dest, got); + + dest += got; + rsize -= got; + if (got < count) + break; /* EOF */ + } + return (size - rsize); +} Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/pread.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/startprog.S =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/startprog.S (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/startprog.S (revision 49189) @@ -0,0 +1,120 @@ +/* $NetBSD: startprog.S,v 1.1.1.1 1997/03/14 02:40:33 perry Exp $ */ + +/* starts program in protected mode / flat space + with given stackframe + needs global variables flatcodeseg and flatdataseg + (gdt offsets) + derivied from: NetBSD:sys/arch/i386/boot/asm.S + */ + +/* + * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 + * + * Mach Operating System + * Copyright (c) 1992, 1991 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ + +/* + Copyright 1988, 1989, 1990, 1991, 1992 + by Intel Corporation, Santa Clara, California. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appears in all +copies and that both the copyright notice and this permission notice +appear in supporting documentation, and that the name of Intel +not be used in advertising or publicity pertaining to distribution +of the software without specific, written prior permission. + +INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, +IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, +NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION +WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#include + +/* + * startprog(phyaddr,argc,argv,stack) + * start the program on protected mode where phyaddr is the entry point + */ +ENTRY(startprog) + pushl %ebp + movl %esp, %ebp + + # prepare a new stack + movl $flatdataseg, %ebx + movw %bx, %es # for arg copy + movl 20(%ebp), %eax # stack + subl $4,%eax + movl %eax, %edi + + # push some number of args onto the stack + movl 12(%ebp), %ecx # argc + + movl %ecx, %eax + decl %eax + shl $2, %eax + addl 16(%ebp), %eax # ptr to last arg + movl %eax, %esi + + std # backwards + rep + movsl + + cld # LynxOS depends on it + + movl 8(%ebp), %ecx # entry + + # set new stackptr (movsl decd sp 1 more -> dummy return address) + movw %bx, %ss + movl %edi, %esp + + # plug in a return address so that FreeBSD detects we are using + # bootinfo + movl $ourreturn, %eax + movl %eax, (%esp) + + # push on our entry address + movl $flatcodeseg, %ebx # segment + pushl %ebx + pushl %ecx #entry + + # convert over the other data segs + movl $flatdataseg, %ebx + movl %bx, %ds + movl %bx, %es + + # convert the PC (and code seg) + lret + +ourreturn: + /* For now there is not much we can do, just lock in a loop */ + jmp ourreturn + Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/startprog.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/vidconsole.c =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/vidconsole.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/vidconsole.c (revision 49189) @@ -0,0 +1,199 @@ +/* + * Copyright (c) 1998 Michael Smith (msmith@freebsd.org) + * Copyright (c) 1997 Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp) + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. + * + * From Id: probe_keyboard.c,v 1.13 1997/06/09 05:10:55 bde Exp + * + * $Id$ + */ + +#include + +#include + +#include "bootstrap.h" + +/* in vidconsole.S */ +extern void vidputc(int c); +extern int kbdgetc(void); +extern int kbdiskey(void); + +static int probe_keyboard(void); +static void vidc_probe(struct console *cp); +static int vidc_init(int arg); +static int vidc_in(void); + +struct console vidconsole = { + "vidconsole", + "internal video/keyboard", + 0, + vidc_probe, + vidc_init, + vidputc, + vidc_in, + kbdiskey +}; + +static void +vidc_probe(struct console *cp) +{ + + /* look for a keyboard */ +#if 0 + if (probe_keyboard()) { +#else + if (1) { +#endif + cp->c_flags |= C_PRESENTIN; + } + + /* XXX for now, always assume we can do BIOS screen output */ + cp->c_flags |= C_PRESENTOUT; +} + +static int +vidc_init(int arg) +{ + return(0); /* XXX reinit? */ +} + +static int +vidc_in(void) +{ + if (kbdiskey()) { + return(kbdgetc()); + } else { + return(-1); + } +} + +#define PROBE_MAXRETRY 5 +#define PROBE_MAXWAIT 400 +#define IO_DUMMY 0x84 +#define IO_KBD 0x060 /* 8042 Keyboard */ + +/* selected defines from kbdio.h */ +#define KBD_STATUS_PORT 4 /* status port, read */ +#define KBD_DATA_PORT 0 /* data port, read/write + * also used as keyboard command + * and mouse command port + */ +#define KBDC_ECHO 0x00ee +#define KBDS_ANY_BUFFER_FULL 0x0001 +#define KBDS_INPUT_BUFFER_FULL 0x0002 +#define KBD_ECHO 0x00ee + +/* 7 microsec delay necessary for some keyboard controllers */ +static void +delay7(void) +{ + /* + * I know this is broken, but no timer is avaiable yet at this stage... + * See also comments in `delay1ms()'. + */ + inb(IO_DUMMY); inb(IO_DUMMY); + inb(IO_DUMMY); inb(IO_DUMMY); + inb(IO_DUMMY); inb(IO_DUMMY); +} + +/* + * This routine uses an inb to an unused port, the time to execute that + * inb is approximately 1.25uS. This value is pretty constant across + * all CPU's and all buses, with the exception of some PCI implentations + * that do not forward this I/O adress to the ISA bus as they know it + * is not a valid ISA bus address, those machines execute this inb in + * 60 nS :-(. + * + */ +static void +delay1ms(void) +{ + int i = 800; + while (--i >= 0) + (void)inb(0x84); +} + +/* + * We use the presence/absence of a keyboard to determine whether the internal + * console can be used for input. + * + * Perform a simple test on the keyboard; issue the ECHO command and see + * if the right answer is returned. We don't do anything as drastic as + * full keyboard reset; it will be too troublesome and take too much time. + */ +static int +probe_keyboard(void) +{ + int retry = PROBE_MAXRETRY; + int wait; + int i; + + while (--retry >= 0) { + /* flush any noise */ + while (inb(IO_KBD + KBD_STATUS_PORT) & KBDS_ANY_BUFFER_FULL) { + delay7(); + inb(IO_KBD + KBD_DATA_PORT); + delay1ms(); + } + + /* wait until the controller can accept a command */ + for (wait = PROBE_MAXWAIT; wait > 0; --wait) { + if (((i = inb(IO_KBD + KBD_STATUS_PORT)) + & (KBDS_INPUT_BUFFER_FULL | KBDS_ANY_BUFFER_FULL)) == 0) + break; + if (i & KBDS_ANY_BUFFER_FULL) { + delay7(); + inb(IO_KBD + KBD_DATA_PORT); + } + delay1ms(); + } + if (wait <= 0) + continue; + + /* send the ECHO command */ + outb(IO_KBD + KBD_DATA_PORT, KBDC_ECHO); + + /* wait for a response */ + for (wait = PROBE_MAXWAIT; wait > 0; --wait) { + if (inb(IO_KBD + KBD_STATUS_PORT) & KBDS_ANY_BUFFER_FULL) + break; + delay1ms(); + } + if (wait <= 0) + continue; + + delay7(); + i = inb(IO_KBD + KBD_DATA_PORT); +#ifdef PROBE_KBD_BEBUG + printf("probe_keyboard: got 0x%x.\n", i); +#endif + if (i == KBD_ECHO) { + /* got the right answer */ + return (0); + } + } + + return (1); +} Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/vidconsole.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/libi386/vidconsole_support.S =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/libi386/vidconsole_support.S (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/libi386/vidconsole_support.S (revision 49189) @@ -0,0 +1,103 @@ +/* $Id$ */ + +/* + * PC console handling + * originally from: FreeBSD:sys/i386/boot/netboot/start2.S via NetBSD + */ + +#include + +#define data32 .byte 0x66 + + .text + +/************************************************************************** +PUTC - Print a character +**************************************************************************/ +ENTRY(vidputc) + push %ebp + mov %esp,%ebp + push %ecx + push %ebx + push %esi + push %edi + + movb 8(%ebp),%cl + + call CNAME(prot_to_real) # enter real mode + + movb %cl,%al + data32 + mov $1,%ebx + movb $0x0e,%ah + int $0x10 + + data32 + call CNAME(real_to_prot) # back to protected mode + + pop %edi + pop %esi + pop %ebx + pop %ecx + pop %ebp + ret + +/************************************************************************** +GETC - Get a character +**************************************************************************/ +ENTRY(kbdgetc) + push %ebp + mov %esp,%ebp + push %ebx + push %esi + push %edi + + call CNAME(prot_to_real) # enter real mode + + movb $0x0,%ah + int $0x16 + movb %al,%bl + + data32 + call CNAME(real_to_prot) # back to protected mode + + xor %eax,%eax + movb %bl,%al + + pop %edi + pop %esi + pop %ebx + pop %ebp + ret + +/************************************************************************** +ISKEY - Check for keyboard interrupt +**************************************************************************/ +ENTRY(kbdiskey) + push %ebp + mov %esp,%ebp + push %ebx + push %esi + push %edi + + call CNAME(prot_to_real) # enter real mode + + xor %ebx,%ebx + movb $0x1,%ah + int $0x16 + data32 + jz 1f + movb %al,%bl +1: + + data32 + call CNAME(real_to_prot) # back to protected mode + + xor %eax,%eax + movb %bl,%al + + pop %edi + pop %esi + pop %ebx + pop %ebp + ret Property changes on: cvs2svn/tags/initial/sys/boot/i386/libi386/vidconsole_support.S ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/loader/Makefile =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/loader/Makefile (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/loader/Makefile (revision 49189) @@ -0,0 +1,36 @@ +# $Id$ +# from $NetBSD: Makefile,v 1.12 1998/02/19 14:18:36 drochner Exp $ + +BASE= loader +PROG= ${BASE}.sym +NOMAN= +NEWVERSWHAT= "bootstrap loader" + +# architecture-specific loader code +SRCS+= main.c conf.c + +# Always add MI sources +.PATH: ${.CURDIR}/../../common +.include <${.CURDIR}/../../common/Makefile.inc> +CFLAGS+= -I${.CURDIR}/../../common +# Verbose ls causes extra heap usage +CFLAGS+= -DVERBOSE_LS + +CLEANFILES+= vers.c vers.o ${BASE}.list + +CFLAGS+= -Wall + +# i386 standalone support library +LIBI386= ${.OBJDIR}/../libi386/libi386.a +CFLAGS+= -I${.CURDIR}/.. +CRT= ${.OBJDIR}/../libi386/crt/bootsect/bscrt.o + +vers.o: + sh ${.CURDIR}/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} + ${CC} -c vers.c + +${BASE}.sym: ${OBJS} ${LIBI386} ${CRT} vers.o + ${LD} -o ${BASE}.sym -M -e _start -N -Ttext 0 ${CRT} ${OBJS} \ + vers.o -lstand ${LIBI386} -lstand >${.OBJDIR}/${BASE}.list + +.include Property changes on: cvs2svn/tags/initial/sys/boot/i386/loader/Makefile ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/loader/conf.c =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/loader/conf.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/loader/conf.c (revision 49189) @@ -0,0 +1,85 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +#include +#include +#include "libi386/libi386.h" + +/* + * We could use linker sets for some or all of these, but + * then we would have to control what ended up linked into + * the bootstrap. So it's easier to conditionalise things + * here. + * + * XXX rename these arrays to be consistent and less namespace-hostile + * + * XXX as libi386 and biosboot merge, some of these can become linker sets. + */ + +/* Exported for libstand */ +struct devsw *devsw[] = { + &biosdisk, + /* XXX network devices? */ + NULL +}; + +struct fs_ops *file_system[] = { + &ufs_fsops, +#if notyet + &dosfs_fsops, +#endif + &zipfs_fsops, + NULL +}; + +/* Exported for i386 only */ +/* + * Sort formats so that those that can detect based on arguments + * rather than reading the file go first. + */ +extern struct module_format i386_aout; + +struct module_format *module_formats[] = { + &i386_aout, + NULL +}; + +/* + * Consoles + * + * We don't prototype these in libi386.h because they require + * data structures from bootstrap.h as well. + */ +extern struct console vidconsole; +extern struct console comconsole; + +struct console *consoles[] = { + &vidconsole, + &comconsole, + NULL +}; Property changes on: cvs2svn/tags/initial/sys/boot/i386/loader/conf.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/loader/main.c =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/loader/main.c (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/loader/main.c (revision 49189) @@ -0,0 +1,156 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +/* + * MD bootstrap main() and assorted miscellaneous + * commands. + */ + +#include +#include + +#include "bootstrap.h" +#include "libi386/libi386.h" + +extern int boot_biosdev; /* from runtime startup */ + +struct arch_switch archsw; /* MI/MD interface boundary */ + +/* from vers.c */ +extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; + +/* XXX debugging */ +#include "libi386/crt/diskbuf.h" +extern char stackbase, stacktop; +extern char end[]; + +void +main(void) +{ + struct i386_devdesc currdev; + int i; + + /* + * Initialise the heap as early as possible. Once this is done, alloc() is usable. + * The stack is buried inside us, so this is safe + */ + setheap((void *)end, (void *)(end + 0x80000)); + + /* + * XXX Chicken-and-egg problem; we want to have console output early, but some + * console attributes may depend on reading from eg. the boot device, which we + * can't do yet. + * + * We can use printf() etc. once this is done. + */ + cons_probe(); + + /* + * March through the device switch probing for things. + */ + for (i = 0; devsw[i] != NULL; i++) + if (devsw[i]->dv_init != NULL) + (devsw[i]->dv_init)(); + + printf("\n"); + printf("%s, Revision %s\n", bootprog_name, bootprog_rev); + printf("(%s, %s)\n", bootprog_maker, bootprog_date); + printf("memory: %d/%dkB\n", getbasemem(), getextmem()); +#if 0 + printf("diskbuf at %p, %d sectors\n", &diskbuf, diskbuf_size); + printf("using %d bytes of stack at %p\n", (&stacktop - &stackbase), &stacktop); +#endif + + /* We're booting from a BIOS disk, try to spiff this */ + currdev.d_dev = devsw[0]; /* XXX presumes that biosdisk is first in devsw */ + currdev.d_type = currdev.d_dev->dv_type; + currdev.d_kind.biosdisk.unit = boot_biosdev; + currdev.d_kind.biosdisk.slice = -1; /* XXX should be able to detect this, default to autoprobe */ + currdev.d_kind.biosdisk.partition = 0; /* default to 'a' */ + + /* Create i386-specific variables */ + + env_setenv("currdev", EV_VOLATILE, i386_fmtdev(&currdev), i386_setcurrdev, env_nounset); + env_setenv("loaddev", EV_VOLATILE, i386_fmtdev(&currdev), env_noset, env_nounset); + setenv("LINES", "24", 1); /* optional */ + + archsw.arch_autoload = i386_autoload; + archsw.arch_boot = i386_boot; + archsw.arch_getdev = i386_getdev; + /* + * XXX should these be in the MI source? + */ + source("/boot/boot.conf"); +#if 0 + legacy_config(); /* read old /boot.config file */ +#endif + printf("\n"); + autoboot(10, NULL); /* try to boot automatically */ + printf("\nType '?' for a list of commands, 'help' for more detailed help.\n"); + setenv("prompt", "$currdev>", 1); + + interact(); /* doesn't return */ +} + +COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); + +static int +command_reboot(int argc, char *argv[]) +{ + + printf("Rebooting...\n"); + delay(1000000); + reboot(); + /* Note: we shouldn't get to this point! */ + panic("Reboot failed!"); + exit(0); +} + +COMMAND_SET(stack, "stack", "show stack usage", command_stack); + +static int +command_stack(int argc, char *argv[]) +{ + char *cp; + + for (cp = &stackbase; cp < &stacktop; cp++) + if (*cp != 0) + break; + + printf("%d bytes of stack used\n", &stacktop - cp); + return(CMD_OK); +} + +COMMAND_SET(heap, "heap", "show heap usage", command_heap); + +static int +command_heap(int argc, char *argv[]) +{ + printf("heap base at %p, top at %p, used %d\n", end, sbrk(0), sbrk(0) - end); + return(CMD_OK); +} Property changes on: cvs2svn/tags/initial/sys/boot/i386/loader/main.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/loader/newvers.sh =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/loader/newvers.sh (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/loader/newvers.sh (revision 49189) @@ -0,0 +1,44 @@ +#!/bin/sh - +# +# $NetBSD: newvers.sh,v 1.1 1997/07/26 01:50:38 thorpej Exp $ +# +# Copyright (c) 1984, 1986, 1990, 1993 +# The Regents of the University of California. 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 by the University of +# California, Berkeley and its contributors. +# 4. Neither the name of the University nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. +# +# @(#)newvers.sh 8.1 (Berkeley) 4/20/94 + +u=${USER-root} h=`hostname` t=`date` +r=`head -n 6 $1 | tail -n 1 | awk -F: ' { print $1 } '` + +echo "char bootprog_name[] = \"FreeBSD/i386 ${2}\";" > vers.c +echo "char bootprog_rev[] = \"${r}\";" >> vers.c +echo "char bootprog_date[] = \"${t}\";" >> vers.c +echo "char bootprog_maker[] = \"${u}@${h}\";" >> vers.c Property changes on: cvs2svn/tags/initial/sys/boot/i386/loader/newvers.sh ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/boot/i386/loader/version =================================================================== --- cvs2svn/tags/initial/sys/boot/i386/loader/version (nonexistent) +++ cvs2svn/tags/initial/sys/boot/i386/loader/version (revision 49189) @@ -0,0 +1,7 @@ +$Id$ + +NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this +file is important. Make sure the current version number is on line 6. + +0.1: Initial i386 version, inspiration and some structure from the + NetBSD version. Property changes on: cvs2svn/tags/initial/sys/boot/i386/loader/version ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/dev/smbus/smb.c =================================================================== --- cvs2svn/tags/initial/sys/dev/smbus/smb.c (nonexistent) +++ cvs2svn/tags/initial/sys/dev/smbus/smb.c (revision 49189) @@ -0,0 +1,287 @@ +/*- + * Copyright (c) 1998 Nicolas Souchu + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: smb.c,v 1.1.2.1 1998/08/13 15:15:19 son Exp $ + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include "smbus_if.h" + +#define BUFSIZE 1024 + +struct smb_softc { + + int sc_addr; /* address on smbus */ + int sc_count; /* >0 if device opened */ + + char *sc_cp; /* output buffer pointer */ + + char sc_buffer[BUFSIZE]; /* output buffer */ + char sc_inbuf[BUFSIZE]; /* input buffer */ +}; + +#define IIC_SOFTC(unit) \ + ((struct smb_softc *)devclass_get_softc(smb_devclass, (unit))) + +#define IIC_DEVICE(unit) \ + (devclass_get_device(smb_devclass, (unit))) + +static int smb_probe(device_t); +static int smb_attach(device_t); + +static devclass_t smb_devclass; + +static device_method_t smb_methods[] = { + /* device interface */ + DEVMETHOD(device_probe, smb_probe), + DEVMETHOD(device_attach, smb_attach), + + /* smbus interface */ + DEVMETHOD(smbus_intr, smbus_generic_intr), + + { 0, 0 } +}; + +static driver_t smb_driver = { + "smb", + smb_methods, + DRIVER_TYPE_MISC, + sizeof(struct smb_softc), +}; + +static d_open_t smbopen; +static d_close_t smbclose; +static d_write_t smbwrite; +static d_read_t smbread; +static d_ioctl_t smbioctl; + +#define CDEV_MAJOR 73 +static struct cdevsw smb_cdevsw = + { smbopen, smbclose, smbread, smbwrite, /*73*/ + smbioctl, nullstop, nullreset, nodevtotty, /*smb*/ + seltrue, nommap, nostrat, "smb", NULL, -1 }; + +/* + * smbprobe() + */ +static int +smb_probe(device_t dev) +{ + struct smb_softc *sc = (struct smb_softc *)device_get_softc(dev); + + sc->sc_addr = smbus_get_addr(dev); + + /* XXX detect chip with start/stop conditions */ + + return (0); +} + +/* + * smbattach() + */ +static int +smb_attach(device_t dev) +{ + struct smb_softc *sc = (struct smb_softc *)device_get_softc(dev); + + return (0); +} + +static int +smbopen (dev_t dev, int flags, int fmt, struct proc *p) +{ + struct smb_softc *sc = IIC_SOFTC(minor(dev)); + + if (!sc) + return (EINVAL); + + if (sc->sc_count) + return (EBUSY); + + sc->sc_count++; + + return (0); +} + +static int +smbclose(dev_t dev, int flags, int fmt, struct proc *p) +{ + struct smb_softc *sc = IIC_SOFTC(minor(dev)); + + if (!sc) + return (EINVAL); + + if (!sc->sc_count) + return (EINVAL); + + sc->sc_count--; + + return (0); +} + +static int +smbwrite(dev_t dev, struct uio * uio, int ioflag) +{ + device_t smbdev = IIC_DEVICE(minor(dev)); + struct smb_softc *sc = IIC_SOFTC(minor(dev)); + int error, count; + + if (!sc || !smbdev) + return (EINVAL); + + if (sc->sc_count == 0) + return (EINVAL); + + count = min(uio->uio_resid, BUFSIZE); + uiomove(sc->sc_buffer, count, uio); + + /* we consider the command char as the first character to send */ + smbus_bwrite(device_get_parent(smbdev), sc->sc_addr, + sc->sc_buffer[0], count-1, sc->sc_buffer+1); + + return (0); +} + +static int +smbread(dev_t dev, struct uio * uio, int ioflag) +{ + /* not supported */ + + return (EINVAL); +} + +static int +smbioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) +{ + device_t smbdev = IIC_DEVICE(minor(dev)); + struct smb_softc *sc = IIC_SOFTC(minor(dev)); + device_t parent = device_get_parent(smbdev); + + int error = 0; + struct smbcmd *s = (struct smbcmd *)data; + + if (!sc) + return (EINVAL); + + switch (cmd) { + case SMB_QUICK_WRITE: + smbus_quick(parent, sc->sc_addr, SMB_QWRITE); + goto end; + + case SMB_QUICK_READ: + smbus_quick(parent, sc->sc_addr, SMB_QREAD); + goto end; + }; + + if (!s) + return (EINVAL); + + switch (cmd) { + case SMB_SENDB: + smbus_sendb(parent, sc->sc_addr, s->cmd); + break; + + case SMB_RECVB: + smbus_recvb(parent, sc->sc_addr, &s->cmd); + break; + + case SMB_WRITEB: + smbus_writeb(parent, sc->sc_addr, s->cmd, s->data.byte); + break; + + case SMB_WRITEW: + smbus_writew(parent, sc->sc_addr, s->cmd, s->data.word); + break; + + case SMB_READB: + if (s->data.byte_ptr) + smbus_readb(parent, sc->sc_addr, s->cmd, + s->data.byte_ptr); + break; + + case SMB_READW: + if (s->data.word_ptr) + smbus_readw(parent, sc->sc_addr, s->cmd, s->data.word_ptr); + break; + + case SMB_PCALL: + if (s->data.process.rdata) + smbus_pcall(parent, sc->sc_addr, s->cmd, + s->data.process.sdata, s->data.process.rdata); + break; + + case SMB_BWRITE: + if (s->count && s->data.byte_ptr) + smbus_bwrite(parent, sc->sc_addr, s->cmd, s->count, + s->data.byte_ptr); + break; + + case SMB_BREAD: + if (s->count && s->data.byte_ptr) + smbus_bread(parent, sc->sc_addr, s->cmd, s->count, + s->data.byte_ptr); + break; + + default: + error = ENODEV; + } + +end: + return (error); +} + +static int smb_devsw_installed = 0; + +static void +smb_drvinit(void *unused) +{ + dev_t dev; + + if( ! smb_devsw_installed ) { + dev = makedev(CDEV_MAJOR,0); + cdevsw_add(&dev,&smb_cdevsw,NULL); + smb_devsw_installed = 1; + } +} + +CDEV_DRIVER_MODULE(smb, smbus, smb_driver, smb_devclass, CDEV_MAJOR, + smb_cdevsw, 0, 0); + +SYSINIT(smbdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,smb_drvinit,NULL) Property changes on: cvs2svn/tags/initial/sys/dev/smbus/smb.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/dev/smbus/smbconf.c =================================================================== --- cvs2svn/tags/initial/sys/dev/smbus/smbconf.c (nonexistent) +++ cvs2svn/tags/initial/sys/dev/smbus/smbconf.c (revision 49189) @@ -0,0 +1,157 @@ +/*- + * Copyright (c) 1998 Nicolas Souchu + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: smbconf.c,v 1.1.1.2 1998/08/13 15:16:57 son Exp $ + * + */ +#include +#include +#include +#include +#include +#include + +#include +#include +#include "smbus_if.h" + +/* + * smbus_intr() + */ +void +smbus_intr(device_t bus, u_char devaddr, char low, char high, int error) +{ + struct smbus_softc *sc = (struct smbus_softc *)device_get_softc(bus); + + /* call owner's intr routine */ + if (sc->owner) + SMBUS_INTR(sc->owner, devaddr, low, high, error); + + return; +} + +/* + * smbus_alloc_bus() + * + * Allocate a new bus connected to the given parent device + */ +device_t +smbus_alloc_bus(device_t parent) +{ + device_t child; + + /* add the bus to the parent */ + child = device_add_child(parent, "smbus", -1, NULL); + + if (child) + device_set_desc(child, "System Management Bus"); + + return (child); +} + +/* + * smbus_request_bus() + * + * Allocate the device to perform transfers. + * + * how : SMB_WAIT or SMB_DONTWAIT + */ +int +smbus_request_bus(device_t bus, device_t dev, int how) +{ + struct smbus_softc *sc = (struct smbus_softc *)device_get_softc(bus); + int s, error = 0; + + while (!error) { + s = splhigh(); + if (sc->owner) { + splx(s); + + switch (how) { + case (SMB_WAIT | SMB_INTR): + error = tsleep(sc, SMBPRI|PCATCH, "smbreq", 0); + break; + + case (SMB_WAIT | SMB_NOINTR): + error = tsleep(sc, SMBPRI, "smbreq", 0); + break; + + default: + return (EWOULDBLOCK); + break; + } + + } else { + sc->owner = dev; + + splx(s); + return (0); + } + } + + return (error); +} + +/* + * smbus_release_bus() + * + * Release the device allocated with smbus_request_dev() + */ +int +smbus_release_bus(device_t bus, device_t dev) +{ + struct smbus_softc *sc = (struct smbus_softc *)device_get_softc(bus); + int s; + + s = splhigh(); + if (sc->owner != dev) { + splx(s); + return (EACCES); + } + + sc->owner = 0; + splx(s); + + /* wakeup waiting processes */ + wakeup(sc); + + return (0); +} + +/* + * smbus_get_addr() + * + * Get the I2C 7 bits address of the device + */ +u_char +smbus_get_addr(device_t dev) +{ + u_long addr; + device_t parent = device_get_parent(dev); + + BUS_READ_IVAR(parent, dev, SMBUS_IVAR_ADDR, &addr); + + return ((u_char)addr); +} Property changes on: cvs2svn/tags/initial/sys/dev/smbus/smbconf.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/dev/smbus/smbconf.h =================================================================== --- cvs2svn/tags/initial/sys/dev/smbus/smbconf.h (nonexistent) +++ cvs2svn/tags/initial/sys/dev/smbus/smbconf.h (revision 49189) @@ -0,0 +1,91 @@ +/*- + * Copyright (c) 1998 Nicolas Souchu + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: smbconf.h,v 1.1.1.2 1998/08/13 15:16:58 son Exp $ + */ +#ifndef __SMBONF_H +#define __SMBONF_H + +#include + +#define SMBPRI PZERO+8 /* XXX sleep/wakeup queue priority */ + +#define n(flags) (~(flags) & (flags)) + +/* + * How tsleep() is called in smb_request_bus(). + */ +#define SMB_DONTWAIT 0 +#define SMB_NOINTR 0 +#define SMB_WAIT 0x1 +#define SMB_INTR 0x2 + +/* + * SMB bus errors + */ +#define SMB_ENOERR 0x0 +#define SMB_EBUSERR 0x1 + +/* + * How Quick command is executed + */ +#define SMB_QWRITE 0x0 +#define SMB_QREAD 0x1 + +/* + * ivars codes + */ +#define SMBUS_IVAR_ADDR 0x1 /* I2C address of the device */ + +extern int smbus_request_bus(device_t, device_t, int); +extern int smbus_release_bus(device_t, device_t); +extern device_t smbus_alloc_bus(device_t); + +extern void smbus_intr(device_t, u_char, char low, char high, int error); + +extern u_char smbus_get_addr(device_t); + +#define smbus_quick(bus,slave,how) \ + (SMBUS_QUICK(device_get_parent(bus), slave, how)) +#define smbus_sendb(bus,slave,byte) \ + (SMBUS_SENDB(device_get_parent(bus), slave, byte)) +#define smbus_recvb(bus,slave,byte) \ + (SMBUS_RECVB(device_get_parent(bus), slave, byte)) +#define smbus_writeb(bus,slave,cmd,byte) \ + (SMBUS_WRITEB(device_get_parent(bus), slave, cmd, byte)) +#define smbus_writew(bus,slave,cmd,word) \ + (SMBUS_WRITEW(device_get_parent(bus), slave, cmd, word)) +#define smbus_readb(bus,slave,cmd,byte) \ + (SMBUS_READB(device_get_parent(bus), slave, cmd, byte)) +#define smbus_readw(bus,slave,cmd,word) \ + (SMBUS_READW(device_get_parent(bus), slave, cmd, word)) +#define smbus_pcall(bus,slave,cmd,sdata,rdata) \ + (SMBUS_PCALL(device_get_parent(bus), slave, cmd, sdata, rdata)) +#define smbus_bwrite(bus,slave,cmd,count,buf) \ + (SMBUS_BWRITE(device_get_parent(bus), slave, cmd, count, buf)) +#define smbus_bread(bus,slave,cmd,count,buf) \ + (SMBUS_BREAD(device_get_parent(bus), slave, cmd, count, buf)) + +#endif Property changes on: cvs2svn/tags/initial/sys/dev/smbus/smbconf.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/dev/smbus/smbus.c =================================================================== --- cvs2svn/tags/initial/sys/dev/smbus/smbus.c (nonexistent) +++ cvs2svn/tags/initial/sys/dev/smbus/smbus.c (revision 49189) @@ -0,0 +1,157 @@ +/*- + * Copyright (c) 1998 Nicolas Souchu + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: smbus.c,v 1.1.1.2 1998/08/13 15:16:58 son Exp $ + * + */ +#include +#include +#include +#include +#include + +#include +#include + +/* + * Autoconfiguration and support routines for the Philips serial I2C bus + */ + +#define DEVTOSMBUS(dev) ((struct smbus_device*)device_get_ivars(dev)) + +/* + * structure used to attach devices to the I2C bus + */ +struct smbus_device { + const char *smbd_name; /* device name */ + const u_char smbd_addr; /* address of the device */ + const char *smbd_desc; /* device descriptor */ +}; + +/* + * list of known devices + */ +struct smbus_device smbus_children[] = { + { "smb", 0, "General Call" }, + { NULL, 0 } +}; + +static devclass_t smbus_devclass; + +/* + * Device methods + */ +static int smbus_probe(device_t); +static int smbus_attach(device_t); +static void smbus_print_child(device_t, device_t); +static int smbus_read_ivar(device_t , device_t, int, u_long *); + +static device_method_t smbus_methods[] = { + /* device interface */ + DEVMETHOD(device_probe, smbus_probe), + DEVMETHOD(device_attach, smbus_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + + /* bus interface */ + DEVMETHOD(bus_print_child, smbus_print_child), + DEVMETHOD(bus_read_ivar, smbus_read_ivar), + DEVMETHOD(bus_write_ivar, bus_generic_write_ivar), + DEVMETHOD(bus_create_intr, bus_generic_create_intr), + DEVMETHOD(bus_connect_intr, bus_generic_connect_intr), + + { 0, 0 } +}; + +static driver_t smbus_driver = { + "smbus", + smbus_methods, + DRIVER_TYPE_MISC, + sizeof(struct smbus_softc), +}; + +/* + * At 'probe' time, we add all the devices which we know about to the + * bus. The generic attach routine will probe and attach them if they + * are alive. + */ +static int +smbus_probe(device_t dev) +{ + struct smbus_device *smbdev; + device_t child; + + for (smbdev = smbus_children; smbdev->smbd_name; smbdev++) { + + child = device_add_child(dev, smbdev->smbd_name, -1, smbdev); + device_set_desc(child, smbdev->smbd_desc); + } + + return (0); +} + +static int +smbus_attach(device_t dev) +{ + struct smbus_softc *sc = device_get_softc(dev); + device_t parent = device_get_parent(dev); + + printf("Probing for devices on the SMB bus:\n"); + bus_generic_attach(dev); + + return (0); +} + +void +smbus_generic_intr(device_t dev, u_char devaddr, char low, char high) +{ + return; +} + +static void +smbus_print_child(device_t bus, device_t dev) +{ + struct smbus_device* smbdev = DEVTOSMBUS(dev); + + printf(" on %s%d addr 0x%x", device_get_name(bus), + device_get_unit(bus), smbdev->smbd_addr); + + return; +} + +static int +smbus_read_ivar(device_t bus, device_t dev, int index, u_long* result) +{ + struct smbus_device* smbdev = DEVTOSMBUS(dev); + + switch (index) { + case SMBUS_IVAR_ADDR: + *result = smbdev->smbd_addr; + break; + } + return (ENOENT); +} + +DRIVER_MODULE(smbus, iicsmb, smbus_driver, smbus_devclass, 0, 0); Property changes on: cvs2svn/tags/initial/sys/dev/smbus/smbus.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/dev/smbus/smbus.h =================================================================== --- cvs2svn/tags/initial/sys/dev/smbus/smbus.h (nonexistent) +++ cvs2svn/tags/initial/sys/dev/smbus/smbus.h (revision 49189) @@ -0,0 +1,41 @@ +/*- + * Copyright (c) 1998 Nicolas Souchu + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: smbus.h,v 1.1.1.1 1998/08/10 18:26:05 son Exp $ + * + */ +#ifndef __SMBUS_H +#define __SMBUS_H + +struct smbus_softc { + + device_t owner; /* smbus owner device structure */ +}; + +extern devclass_t smbus_devclass; + +extern void smbus_generic_intr(device_t dev, u_char devaddr, char low, char high); + +#endif Property changes on: cvs2svn/tags/initial/sys/dev/smbus/smbus.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/dev/smbus/smbus_if.m =================================================================== --- cvs2svn/tags/initial/sys/dev/smbus/smbus_if.m (nonexistent) +++ cvs2svn/tags/initial/sys/dev/smbus/smbus_if.m (revision 49189) @@ -0,0 +1,140 @@ +# +# Copyright (c) 1998 Nicolas Souchu +# 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. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: smbus_if.m,v 1.1.1.2 1998/08/13 15:16:58 son Exp $ +# + +INTERFACE smbus + +# +# Interprete interrupt +# +METHOD void intr { + device_t dev; + u_char devaddr; + char low; + char high; + int error; +}; + +# +# Quick command +# +METHOD int quick { + device_t dev; + u_char slave; + int how; +}; + +# +# Send Byte command +# +METHOD int sendb { + device_t dev; + u_char slave; + char byte; +}; + +# +# Receive Byte command +# +METHOD int recvb { + device_t dev; + u_char slave; + char *byte; +}; + +# +# Write Byte command +# +METHOD int writeb { + device_t dev; + u_char slave; + char cmd; + char byte; +}; + +# +# Write Word command +# +METHOD int writew { + device_t dev; + u_char slave; + char cmd; + short word; +}; + +# +# Read Byte command +# +METHOD int readb { + device_t dev; + u_char slave; + char cmd; + char *byte; +}; + +# +# Read Word command +# +METHOD int readw { + device_t dev; + u_char slave; + char cmd; + short *word; +}; + +# +# Process Call command +# +METHOD int pcall { + device_t dev; + u_char slave; + char cmd; + short sdata; + short *rdata; +}; + +# +# Block Write command +# +METHODE int bwrite { + device_t dev; + u_char slave; + char cmd; + u_char count; + char *buf; +}; + +# +# Block Read command +# +METHODE int bread { + device_t dev; + u_char slave; + char cmd; + u_char count; + char *buf; +}; Property changes on: cvs2svn/tags/initial/sys/dev/smbus/smbus_if.m ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/dev/iicbus/if_ic.c =================================================================== --- cvs2svn/tags/initial/sys/dev/iicbus/if_ic.c (nonexistent) +++ cvs2svn/tags/initial/sys/dev/iicbus/if_ic.c (revision 49189) @@ -0,0 +1,468 @@ +/*- + * Copyright (c) 1998 Nicolas Souchu + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: if_ic.c,v 1.1.1.11 1998/08/13 17:10:42 son Exp $ + */ + +/* + * I2C bus IP driver + */ + +#ifdef KERNEL +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#endif /* KERNEL */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "bpfilter.h" + +#if NBPFILTER > 0 +#include +#endif + +#include +#include + +#include "iicbus_if.h" + +#define ICHDRLEN sizeof(u_int) +#define ICMTU 1500 /* default mtu */ + +struct ic_softc { + struct ifnet ic_if; + + u_char ic_addr; /* peer I2C address */ + + int ic_sending; + + char *ic_obuf; + char *ic_ifbuf; + char *ic_cp; + + int ic_xfercnt; + + int ic_iferrs; +}; + +static devclass_t ic_devclass; + +static int icprobe(device_t); +static int icattach(device_t); + +static int icioctl(struct ifnet *, u_long, caddr_t); +static int icoutput(struct ifnet *, struct mbuf *, struct sockaddr *, + struct rtentry *); + +static void icintr(device_t, int, char *); + +static device_method_t ic_methods[] = { + /* device interface */ + DEVMETHOD(device_probe, icprobe), + DEVMETHOD(device_attach, icattach), + + /* iicbus interface */ + DEVMETHOD(iicbus_intr, icintr), + + { 0, 0 } +}; + +static driver_t ic_driver = { + "ic", + ic_methods, + DRIVER_TYPE_MISC, + sizeof(struct ic_softc), +}; + +/* + * icprobe() + */ +static int +icprobe(device_t dev) +{ + return (0); +} + +/* + * icattach() + */ +static int +icattach(device_t dev) +{ + struct ic_softc *sc = (struct ic_softc *)device_get_softc(dev); + struct ifnet *ifp = &sc->ic_if; + + sc->ic_addr = iicbus_get_addr(dev); + + ifp->if_softc = sc; + ifp->if_name = "ic"; + ifp->if_unit = device_get_unit(dev); + ifp->if_mtu = ICMTU; + ifp->if_flags = IFF_SIMPLEX | IFF_POINTOPOINT | IFF_MULTICAST; + ifp->if_ioctl = icioctl; + ifp->if_output = icoutput; + ifp->if_type = IFT_PARA; + ifp->if_hdrlen = 0; + ifp->if_addrlen = 0; + ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; + + if_attach(ifp); + +#if NBPFILTER > 0 + bpfattach(ifp, DLT_NULL, ICHDRLEN); +#endif + + return (0); +} + +/* + * iciotcl() + */ +static int +icioctl(struct ifnet *ifp, u_long cmd, caddr_t data) +{ + device_t icdev = devclass_get_device(ic_devclass, ifp->if_unit); + device_t parent = device_get_parent(icdev); + struct ic_softc *sc = (struct ic_softc *)device_get_softc(icdev); + + struct ifaddr *ifa = (struct ifaddr *)data; + struct ifreq *ifr = (struct ifreq *)data; + + u_char *iptr, *optr; + int error; + + switch (cmd) { + + case SIOCSIFDSTADDR: + case SIOCAIFADDR: + case SIOCSIFADDR: + if (ifa->ifa_addr->sa_family != AF_INET) + return EAFNOSUPPORT; + ifp->if_flags |= IFF_UP; + /* FALLTHROUGH */ + case SIOCSIFFLAGS: + if ((!(ifp->if_flags & IFF_UP)) && (ifp->if_flags & IFF_RUNNING)) { + + /* XXX disable PCF */ + ifp->if_flags &= ~IFF_RUNNING; + + /* IFF_UP is not set, try to release the bus anyway */ + iicbus_release_bus(parent, icdev); + break; + } + if (((ifp->if_flags & IFF_UP)) && (!(ifp->if_flags & IFF_RUNNING))) { + + if ((error = iicbus_request_bus(parent, icdev, IIC_WAIT|IIC_INTR))) + return (error); + + sc->ic_obuf = malloc(sc->ic_if.if_mtu + ICHDRLEN, + M_DEVBUF, M_WAITOK); + if (!sc->ic_obuf) { + iicbus_release_bus(parent, icdev); + return ENOBUFS; + } + + sc->ic_ifbuf = malloc(sc->ic_if.if_mtu + ICHDRLEN, + M_DEVBUF, M_WAITOK); + if (!sc->ic_ifbuf) { + iicbus_release_bus(parent, icdev); + return ENOBUFS; + } + + iicbus_reset(parent, IIC_FASTEST); + + ifp->if_flags |= IFF_RUNNING; + } + break; + + case SIOCSIFMTU: + /* save previous buffers */ + iptr = sc->ic_ifbuf; + optr = sc->ic_obuf; + + /* allocate input buffer */ + sc->ic_ifbuf = malloc(ifr->ifr_mtu+ICHDRLEN, M_DEVBUF, M_NOWAIT); + if (!sc->ic_ifbuf) { + + sc->ic_ifbuf = iptr; + sc->ic_obuf = optr; + + return ENOBUFS; + } + + /* allocate output buffer */ + sc->ic_ifbuf = malloc(ifr->ifr_mtu+ICHDRLEN, M_DEVBUF, M_NOWAIT); + if (!sc->ic_obuf) { + + free(sc->ic_ifbuf,M_DEVBUF); + + sc->ic_ifbuf = iptr; + sc->ic_obuf = optr; + + return ENOBUFS; + } + + if (iptr) + free(iptr,M_DEVBUF); + + if (optr) + free(optr,M_DEVBUF); + + sc->ic_if.if_mtu = ifr->ifr_mtu; + break; + + case SIOCGIFMTU: + ifr->ifr_mtu = sc->ic_if.if_mtu; + break; + + case SIOCADDMULTI: + case SIOCDELMULTI: + if (ifr == 0) { + return EAFNOSUPPORT; /* XXX */ + } + switch (ifr->ifr_addr.sa_family) { + + case AF_INET: + break; + + default: + return EAFNOSUPPORT; + } + break; + + default: + return EINVAL; + } + return 0; +} + +/* + * icintr() + */ +static void +icintr (device_t dev, int event, char *ptr) +{ + struct ic_softc *sc = (struct ic_softc *)device_get_softc(dev); + int unit = device_get_unit(dev); + int s, len; + struct mbuf *top; + int i; + + s = splhigh(); + + switch (event) { + + case INTR_GENERAL: + case INTR_START: + sc->ic_cp = sc->ic_ifbuf; + sc->ic_xfercnt = 0; + break; + + case INTR_STOP: + + /* if any error occured during transfert, + * drop the packet */ + if (sc->ic_iferrs) + goto err; + + if ((len = sc->ic_xfercnt) == 0) + break; /* ignore */ + + if (len <= ICHDRLEN) + goto err; + + if (IF_QFULL(&ipintrq)) { + IF_DROP(&ipintrq); + break; + } + + len -= ICHDRLEN; + sc->ic_if.if_ipackets ++; + sc->ic_if.if_ibytes += len; + +#if NBPFILTER > 0 + if (sc->ic_if.if_bpf) + bpf_tap(&sc->ic_if, sc->ic_ifbuf, len + ICHDRLEN); +#endif + + top = m_devget(sc->ic_ifbuf + ICHDRLEN, len, 0, &sc->ic_if, 0); + + if (top) { + IF_ENQUEUE(&ipintrq, top); + schednetisr(NETISR_IP); + } + break; + + err: + printf("ic%d: errors (%d)!\n", unit, sc->ic_iferrs); + + sc->ic_iferrs = 0; /* reset error count */ + sc->ic_if.if_ierrors ++; + + break; + + case INTR_RECEIVE: + if (sc->ic_xfercnt >= sc->ic_if.if_mtu+ICHDRLEN) { + sc->ic_iferrs ++; + + } else { + *sc->ic_cp++ = *ptr; + sc->ic_xfercnt ++; + } + break; + + case INTR_NOACK: /* xfer terminated by master */ + break; + + case INTR_TRANSMIT: + *ptr = 0xff; /* XXX */ + break; + + case INTR_ERROR: + sc->ic_iferrs ++; + break; + + default: + panic("%s: unknown event (%d)!", __FUNCTION__, event); + } + + splx(s); + return; +} + +/* + * icoutput() + */ +static int +icoutput(struct ifnet *ifp, struct mbuf *m, + struct sockaddr *dst, struct rtentry *rt) +{ + device_t icdev = devclass_get_device(ic_devclass, ifp->if_unit); + device_t parent = device_get_parent(icdev); + struct ic_softc *sc = (struct ic_softc *)device_get_softc(icdev); + + int s, len, sent; + struct mbuf *mm; + u_char *cp; + u_int hdr = dst->sa_family; + + ifp->if_flags |= IFF_RUNNING; + + s = splhigh(); + + /* already sending? */ + if (sc->ic_sending) { + ifp->if_oerrors ++; + goto error; + } + + /* insert header */ + bcopy ((char *)&hdr, sc->ic_obuf, ICHDRLEN); + + cp = sc->ic_obuf + ICHDRLEN; + len = 0; + mm = m; + do { + if (len + mm->m_len > sc->ic_if.if_mtu) { + /* packet to large */ + ifp->if_oerrors ++; + goto error; + } + + bcopy(mtod(mm,char *), cp, mm->m_len); + cp += mm->m_len; + len += mm->m_len; + + } while ((mm = mm->m_next)); + +#if NBPFILTER > 0 + if (ifp->if_bpf) { + struct mbuf m0, *n = m; + + /* + * We need to prepend the address family as + * a four byte field. Cons up a dummy header + * to pacify bpf. This is safe because bpf + * will only read from the mbuf (i.e., it won't + * try to free it or keep a pointer a to it). + */ + m0.m_next = m; + m0.m_len = sizeof(u_int); + m0.m_data = (char *)&hdr; + n = &m0; + + bpf_mtap(ifp, n); + } +#endif + + sc->ic_sending = 1; + + m_freem(m); + splx(s); + + /* send the packet */ + if (iicbus_block_write(parent, sc->ic_addr, sc->ic_obuf, + len + ICHDRLEN, &sent)) + + ifp->if_oerrors ++; + else { + ifp->if_opackets ++; + ifp->if_obytes += len; + } + + sc->ic_sending = 0; + + return (0); + +error: + m_freem(m); + splx(s); + + return(0); +} + +DRIVER_MODULE(ic, iicbus, ic_driver, ic_devclass, 0, 0); Property changes on: cvs2svn/tags/initial/sys/dev/iicbus/if_ic.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/dev/iicbus/iic.c =================================================================== --- cvs2svn/tags/initial/sys/dev/iicbus/iic.c (nonexistent) +++ cvs2svn/tags/initial/sys/dev/iicbus/iic.c (revision 49189) @@ -0,0 +1,257 @@ +/*- + * Copyright (c) 1998 Nicolas Souchu + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: iic.c,v 1.1.2.9 1998/08/13 17:10:42 son Exp $ + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include "iicbus_if.h" + +#define BUFSIZE 1024 + +struct iic_softc { + + u_char sc_addr; /* address on iicbus */ + int sc_count; /* >0 if device opened */ + + char sc_buffer[BUFSIZE]; /* output buffer */ + char sc_inbuf[BUFSIZE]; /* input buffer */ +}; + +#define IIC_SOFTC(unit) \ + ((struct iic_softc *)devclass_get_softc(iic_devclass, (unit))) + +#define IIC_DEVICE(unit) \ + (devclass_get_device(iic_devclass, (unit))) + +static int iic_probe(device_t); +static int iic_attach(device_t); + +static devclass_t iic_devclass; + +static device_method_t iic_methods[] = { + /* device interface */ + DEVMETHOD(device_probe, iic_probe), + DEVMETHOD(device_attach, iic_attach), + + /* iicbus interface */ + DEVMETHOD(iicbus_intr, iicbus_generic_intr), + + { 0, 0 } +}; + +static driver_t iic_driver = { + "iic", + iic_methods, + DRIVER_TYPE_MISC, + sizeof(struct iic_softc), +}; + +static d_open_t iicopen; +static d_close_t iicclose; +static d_write_t iicwrite; +static d_read_t iicread; +static d_ioctl_t iicioctl; + +#define CDEV_MAJOR 15 +static struct cdevsw iic_cdevsw = + { iicopen, iicclose, iicread, iicwrite, /*15*/ + iicioctl, nullstop, nullreset, nodevtotty, /*iic*/ + seltrue, nommap, nostrat, "iic", NULL, -1 }; + +/* + * iicprobe() + */ +static int +iic_probe(device_t dev) +{ + struct iic_softc *sc = (struct iic_softc *)device_get_softc(dev); + + sc->sc_addr = iicbus_get_addr(dev); + + /* XXX detect chip with start/stop conditions */ + + return (0); +} + +/* + * iicattach() + */ +static int +iic_attach(device_t dev) +{ + struct iic_softc *sc = (struct iic_softc *)device_get_softc(dev); + + return (0); +} + +static int +iicopen (dev_t dev, int flags, int fmt, struct proc *p) +{ + struct iic_softc *sc = IIC_SOFTC(minor(dev)); + + if (!sc) + return (EINVAL); + + if (sc->sc_count > 0) + return (EBUSY); + + sc->sc_count++; + + return (0); +} + +static int +iicclose(dev_t dev, int flags, int fmt, struct proc *p) +{ + struct iic_softc *sc = IIC_SOFTC(minor(dev)); + + if (!sc) + return (EINVAL); + + if (!sc->sc_count) + return (EINVAL); + + sc->sc_count--; + + if (sc->sc_count < 0) + panic("%s: iic_count < 0!", __FUNCTION__); + + return (0); +} + +static int +iicwrite(dev_t dev, struct uio * uio, int ioflag) +{ + device_t iicdev = IIC_DEVICE(minor(dev)); + struct iic_softc *sc = IIC_SOFTC(minor(dev)); + int sent, error, count; + + if (!sc || !iicdev) + return (EINVAL); + + if (sc->sc_count == 0) + return (EINVAL); + + count = min(uio->uio_resid, BUFSIZE); + uiomove(sc->sc_buffer, count, uio); + + error = iicbus_block_write(device_get_parent(iicdev), sc->sc_addr, + sc->sc_buffer, count, &sent); + + return(error); +} + +static int +iicread(dev_t dev, struct uio * uio, int ioflag) +{ + device_t iicdev = IIC_DEVICE(minor(dev)); + struct iic_softc *sc = IIC_SOFTC(minor(dev)); + int len, error = 0; + int bufsize; + + if (!sc || !iicdev) + return (EINVAL); + + if (sc->sc_count == 0) + return (EINVAL); + + /* max amount of data to read */ + len = min(uio->uio_resid, BUFSIZE); + + if ((error = iicbus_block_read(device_get_parent(iicdev), sc->sc_addr, + sc->sc_inbuf, len, &bufsize))) + return (error); + + if (bufsize > uio->uio_resid) + panic("%s: too much data read!", __FUNCTION__); + + return (uiomove(sc->sc_inbuf, bufsize, uio)); +} + +static int +iicioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) +{ + device_t iicdev = IIC_DEVICE(minor(dev)); + struct iic_softc *sc = IIC_SOFTC(minor(dev)); + int error; + device_t parent = device_get_parent(iicdev); + + if (!sc) + return (EINVAL); + + switch (cmd) { + case I2CSTART: + error = iicbus_start(parent, sc->sc_addr); + break; + + case I2CSTOP: + error = iicbus_stop(parent); + break; + + case I2CRSTCARD: + error = iicbus_reset(parent, 0); + break; + + default: + error = ENODEV; + } + + return (error); +} + +static int iic_devsw_installed = 0; + +static void +iic_drvinit(void *unused) +{ + dev_t dev; + + if( ! iic_devsw_installed ) { + dev = makedev(CDEV_MAJOR,0); + cdevsw_add(&dev,&iic_cdevsw,NULL); + iic_devsw_installed = 1; + } +} + +CDEV_DRIVER_MODULE(iic, iicbus, iic_driver, iic_devclass, CDEV_MAJOR, + iic_cdevsw, 0, 0); + +SYSINIT(iicdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,iic_drvinit,NULL) Property changes on: cvs2svn/tags/initial/sys/dev/iicbus/iic.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/dev/iicbus/iicbus.c =================================================================== --- cvs2svn/tags/initial/sys/dev/iicbus/iicbus.c (nonexistent) +++ cvs2svn/tags/initial/sys/dev/iicbus/iicbus.c (revision 49189) @@ -0,0 +1,215 @@ +/*- + * Copyright (c) 1998 Nicolas Souchu + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: iicbus.c,v 1.1.2.7 1998/08/29 16:54:16 son Exp $ + * + */ + +/* + * Autoconfiguration and support routines for the Philips serial I2C bus + */ + +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "iicbus_if.h" + +#define DEVTOIICBUS(dev) ((struct iicbus_device*)device_get_ivars(dev)) + +/* + * structure used to attach devices to the I2C bus + */ +struct iicbus_device { + const char *iicd_name; /* device name */ + int iicd_class; /* driver or slave device class */ + const char *iicd_desc; /* device descriptor */ + u_char iicd_addr; /* address of the device */ + int iicd_alive; /* 1 if device found */ +}; + +/* + * Common I2C addresses + */ +#define I2C_GENERAL_CALL 0x0 +#define I2C_MASTER_ADDRESS 0xaa +#define I2C_INET_ADDRESS 0xaa + +#define MAXSLAVE 256 + +#define IICBUS_UNKNOWN_CLASS 0 +#define IICBUS_DEVICE_CLASS 1 +#define IICBUS_DRIVER_CLASS 2 + +/* + * list of known devices + */ +struct iicbus_device iicbus_children[] = { + { "iic", IICBUS_DRIVER_CLASS, "General Call", I2C_GENERAL_CALL }, + { "iicsmb", IICBUS_DRIVER_CLASS, "I2C to SMB bridge" }, + { "iic", IICBUS_DEVICE_CLASS, "PCF8574 I2C to 8 bits parallel i/o", 64}, + { "iic", IICBUS_DEVICE_CLASS, "PCF8584 as slave", I2C_MASTER_ADDRESS }, + { "ic", IICBUS_DEVICE_CLASS, "network interface", I2C_INET_ADDRESS }, + { NULL, 0 } +}; + +static devclass_t iicbus_devclass; + +/* + * Device methods + */ +static int iicbus_probe(device_t); +static int iicbus_attach(device_t); +static void iicbus_print_child(device_t, device_t); +static int iicbus_read_ivar(device_t , device_t, int, u_long *); + +static device_method_t iicbus_methods[] = { + /* device interface */ + DEVMETHOD(device_probe, iicbus_probe), + DEVMETHOD(device_attach, iicbus_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + + /* bus interface */ + DEVMETHOD(bus_print_child, iicbus_print_child), + DEVMETHOD(bus_read_ivar, iicbus_read_ivar), + DEVMETHOD(bus_write_ivar, bus_generic_write_ivar), + DEVMETHOD(bus_create_intr, bus_generic_create_intr), + DEVMETHOD(bus_connect_intr, bus_generic_connect_intr), + + { 0, 0 } +}; + +static driver_t iicbus_driver = { + "iicbus", + iicbus_methods, + DRIVER_TYPE_MISC, + sizeof(struct iicbus_softc), +}; + +/* + * At 'probe' time, we add all the devices which we know about to the + * bus. The generic attach routine will probe and attach them if they + * are alive. + */ +static int +iicbus_probe(device_t dev) +{ + struct iicbus_softc *sc = device_get_softc(dev); + struct iicbus_device *iicdev; + device_t child; + + /* XXX should query parent */ + sc->ownaddr = I2C_MASTER_ADDRESS; + + iicbus_reset(dev, IIC_FASTEST); + + for (iicdev = iicbus_children; iicdev->iicd_name; iicdev++) { + + /* probe devices, not drivers */ + switch (iicdev->iicd_class) { + case IICBUS_DEVICE_CLASS: + if (!iicbus_start(dev, iicdev->iicd_addr)) { + iicbus_stop(dev); + iicdev->iicd_alive = 1; + } + break; + case IICBUS_DRIVER_CLASS: + iicdev->iicd_addr = sc->ownaddr; + break; + default: + panic("%s: unknown class!", __FUNCTION__); + } + + child = device_add_child(dev, iicdev->iicd_name, -1, iicdev); + device_set_desc(child, iicdev->iicd_desc); + } + + return (0); +} + +static int +iicbus_attach(device_t dev) +{ + bus_generic_attach(dev); + + return (0); +} + +int +iicbus_generic_intr(device_t dev, int event, char *buf) +{ + return (0); +} + +static void +iicbus_print_child(device_t bus, device_t dev) +{ + struct iicbus_device* iicdev = DEVTOIICBUS(dev); + + switch (iicdev->iicd_class) { + case IICBUS_DEVICE_CLASS: + printf(" on %s%d addr %d %s", device_get_name(bus), + device_get_unit(bus), iicdev->iicd_addr, + (iicdev->iicd_alive) ? "found" : "not found"); + break; + + case IICBUS_DRIVER_CLASS: + printf(" on %s%d", device_get_name(bus), + device_get_unit(bus)); + break; + + default: + panic("%s: unknown class!", __FUNCTION__); + } + + return; +} + +static int +iicbus_read_ivar(device_t bus, device_t dev, int index, u_long* result) +{ + struct iicbus_device* iicdev = DEVTOIICBUS(dev); + + switch (index) { + case IICBUS_IVAR_ADDR: + *result = (u_long)iicdev->iicd_addr; + break; + + default: + return (ENOENT); + } + + return (0); +} + +DRIVER_MODULE(iicbus, pcf, iicbus_driver, iicbus_devclass, 0, 0); Property changes on: cvs2svn/tags/initial/sys/dev/iicbus/iicbus.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/dev/iicbus/iicbus.h =================================================================== --- cvs2svn/tags/initial/sys/dev/iicbus/iicbus.h (nonexistent) +++ cvs2svn/tags/initial/sys/dev/iicbus/iicbus.h (revision 49189) @@ -0,0 +1,42 @@ +/*- + * Copyright (c) 1998 Nicolas Souchu + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: iicbus.h,v 1.1.2.3 1998/08/13 17:10:43 son Exp $ + * + */ +#ifndef __IICBUS_H +#define __IICBUS_H + +struct iicbus_softc { + + u_char ownaddr; /* address of the adapter */ + device_t owner; /* iicbus owner device structure */ +}; + +extern devclass_t iicbus_devclass; + +extern int iicbus_generic_intr(device_t dev, int event, char *buf); + +#endif Property changes on: cvs2svn/tags/initial/sys/dev/iicbus/iicbus.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/dev/iicbus/iicbus_if.m =================================================================== --- cvs2svn/tags/initial/sys/dev/iicbus/iicbus_if.m (nonexistent) +++ cvs2svn/tags/initial/sys/dev/iicbus/iicbus_if.m (revision 49189) @@ -0,0 +1,89 @@ +# +# Copyright (c) 1998 Nicolas Souchu +# 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. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: iicbus_if.m,v 1.1.2.4 1998/08/13 17:10:43 son Exp $ +# + +INTERFACE iicbus + +# +# Interprete interrupt +# +METHOD int intr { + device_t dev; + int event; + char *buf; +}; + +# +# Send REPEATED_START condition +# +METHOD int repeated_start { + device_t dev; + u_char slave; +}; + +# +# Send START condition +# +METHOD int start { + device_t dev; + u_char slave; +}; + +# +# Send STOP condition +# +METHOD int stop { + device_t dev; +}; + +# +# Read from I2C bus +# +METHOD int read { + device_t dev; + char *buf; + int len; + int *bytes; +}; + +# +# Write to the I2C bus +# +METHOD int write { + device_t dev; + char *buf; + int len; + int *bytes; +}; + +# +# Reset I2C bus +# +METHOD int reset { + device_t dev; + u_char speed; +}; Property changes on: cvs2svn/tags/initial/sys/dev/iicbus/iicbus_if.m ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/dev/iicbus/iiconf.c =================================================================== --- cvs2svn/tags/initial/sys/dev/iicbus/iiconf.c (nonexistent) +++ cvs2svn/tags/initial/sys/dev/iicbus/iiconf.c (revision 49189) @@ -0,0 +1,207 @@ +/*- + * Copyright (c) 1998 Nicolas Souchu + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: iiconf.c,v 1.1.1.11 1998/08/29 17:02:05 son Exp $ + * + */ +#include +#include +#include +#include +#include +#include + +#include +#include +#include "iicbus_if.h" + +/* + * iicbus_intr() + */ +void +iicbus_intr(device_t bus, int event, char *buf) +{ + struct iicbus_softc *sc = (struct iicbus_softc *)device_get_softc(bus); + + /* call owner's intr routine */ + if (sc->owner) + IICBUS_INTR(sc->owner, event, buf); + + return; +} + +/* + * iicbus_alloc_bus() + * + * Allocate a new bus connected to the given parent device + */ +device_t +iicbus_alloc_bus(device_t parent) +{ + device_t child; + + /* add the bus to the parent */ + child = device_add_child(parent, "iicbus", -1, NULL); + + if (child) + device_set_desc(child, "Philips I2C bus"); + + return (child); +} + +/* + * iicbus_request_bus() + * + * Allocate the device to perform transfers. + * + * how : IIC_WAIT or IIC_DONTWAIT + */ +int +iicbus_request_bus(device_t bus, device_t dev, int how) +{ + struct iicbus_softc *sc = (struct iicbus_softc *)device_get_softc(bus); + int s, error = 0; + + while (!error) { + s = splhigh(); + if (sc->owner) { + splx(s); + + switch (how) { + case (IIC_WAIT | IIC_INTR): + error = tsleep(sc, IICPRI|PCATCH, "iicreq", 0); + break; + + case (IIC_WAIT | IIC_NOINTR): + error = tsleep(sc, IICPRI, "iicreq", 0); + break; + + default: + return (EWOULDBLOCK); + break; + } + + } else { + sc->owner = dev; + + splx(s); + return (0); + } + } + + return (error); +} + +/* + * iicbus_release_bus() + * + * Release the device allocated with iicbus_request_dev() + */ +int +iicbus_release_bus(device_t bus, device_t dev) +{ + struct iicbus_softc *sc = (struct iicbus_softc *)device_get_softc(bus); + int s; + + s = splhigh(); + if (sc->owner != dev) { + splx(s); + return (EACCES); + } + + sc->owner = 0; + splx(s); + + /* wakeup waiting processes */ + wakeup(sc); + + return (0); +} + +/* + * iicbus_block_write() + * + * Write a block of data to slave ; start/stop protocol managed + */ +int +iicbus_block_write(device_t bus, u_char slave, char *buf, int len, int *sent) +{ + u_char addr = slave & ~LSB; + int error; + + if ((error = iicbus_start(bus, addr))) + return (error); + + error = iicbus_write(bus, buf, len, sent); + + iicbus_stop(bus); + + return (error); +} + +/* + * iicbus_block_read() + * + * Read a block of data from slave ; start/stop protocol managed + */ +int +iicbus_block_read(device_t bus, u_char slave, char *buf, int len, int *read) +{ + u_char addr = slave | LSB; + int error; + + if ((error = iicbus_start(bus, addr))) + return (error); + + error = iicbus_read(bus, buf, len, read); + + /* STOP condition sent at adapter level */ + + return (error); +} + +/* + * iicbus_get_addr() + * + * Get the I2C 7 bits address of the device + */ +u_char +iicbus_get_addr(device_t dev) +{ + u_long addr; + device_t parent = device_get_parent(dev); + + BUS_READ_IVAR(parent, dev, IICBUS_IVAR_ADDR, &addr); + + return ((u_char)addr); +} + +u_char +iicbus_get_own_address(device_t bus) +{ + struct iicbus_softc *sc = (struct iicbus_softc *)device_get_softc(bus); + + return (sc->ownaddr); +} Property changes on: cvs2svn/tags/initial/sys/dev/iicbus/iiconf.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/dev/iicbus/iiconf.h =================================================================== --- cvs2svn/tags/initial/sys/dev/iicbus/iiconf.h (nonexistent) +++ cvs2svn/tags/initial/sys/dev/iicbus/iiconf.h (revision 49189) @@ -0,0 +1,115 @@ +/*- + * Copyright (c) 1998 Nicolas Souchu + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: iiconf.h,v 1.1.1.10 1998/08/13 17:10:43 son Exp $ + */ +#ifndef __IICONF_H +#define __IICONF_H + +#include + +#define IICPRI PZERO+8 /* XXX sleep/wakeup queue priority */ + +#define n(flags) (~(flags) & (flags)) + +#define LSB 0x1 + +/* + * How tsleep() is called in iic_request_bus(). + */ +#define IIC_DONTWAIT 0 +#define IIC_NOINTR 0 +#define IIC_WAIT 0x1 +#define IIC_INTR 0x2 + +/* + * i2c modes + */ +#define IIC_MASTER 0x1 +#define IIC_SLAVE 0x2 +#define IIC_POLLED 0x4 + +/* + * i2c speed + */ +#define IIC_UNKNOWN 0x0 +#define IIC_SLOW 0x1 +#define IIC_FAST 0x2 +#define IIC_FASTEST 0x3 + +/* + * interrupt events + */ +#define INTR_GENERAL 0x1 /* general call received */ +#define INTR_START 0x2 /* the I2C interface is addressed */ +#define INTR_STOP 0x3 /* stop condition received */ +#define INTR_RECEIVE 0x4 /* character received */ +#define INTR_TRANSMIT 0x5 /* character to transmit */ +#define INTR_ERROR 0x6 /* error */ +#define INTR_NOACK 0x7 /* no ack from master receiver */ + +/* + * adapter layer errors + */ +#define IIC_NOERR 0x0 /* no error occured */ +#define IIC_EBUSERR 0x1 /* bus error */ +#define IIC_ENOACK 0x2 /* ack not received until timeout */ +#define IIC_ETIMEOUT 0x3 /* timeout */ +#define IIC_EBUSBSY 0x4 /* bus busy */ +#define IIC_ESTATUS 0x5 /* status error */ +#define IIC_EUNDERFLOW 0x6 /* slave ready for more data */ +#define IIC_EOVERFLOW 0x7 /* too much data */ + +/* + * ivars codes + */ +#define IICBUS_IVAR_ADDR 0x1 /* I2C address of the device */ + +extern int iicbus_request_bus(device_t, device_t, int); +extern int iicbus_release_bus(device_t, device_t); +extern device_t iicbus_alloc_bus(device_t); + +extern void iicbus_intr(device_t, int, char *); + +#define iicbus_repeated_start(bus,slave) \ + (IICBUS_REPEATED_START(device_get_parent(bus), slave)) +#define iicbus_start(bus,slave) \ + (IICBUS_START(device_get_parent(bus), slave)) +#define iicbus_stop(bus) \ + (IICBUS_STOP(device_get_parent(bus))) +#define iicbus_reset(bus,speed) \ + (IICBUS_RESET(device_get_parent(bus), speed)) +#define iicbus_write(bus,buf,len,sent) \ + (IICBUS_WRITE(device_get_parent(bus), buf, len, sent)) +#define iicbus_read(bus,buf,len,sent) \ + (IICBUS_READ(device_get_parent(bus), buf, len, sent)) + +extern int iicbus_block_write(device_t, u_char, char *, int, int *); +extern int iicbus_block_read(device_t, u_char, char *, int, int *); + +extern u_char iicbus_get_addr(device_t); +extern u_char iicbus_get_own_address(device_t); + +#endif Property changes on: cvs2svn/tags/initial/sys/dev/iicbus/iiconf.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/sys/dev/iicbus/iicsmb.c =================================================================== --- cvs2svn/tags/initial/sys/dev/iicbus/iicsmb.c (nonexistent) +++ cvs2svn/tags/initial/sys/dev/iicbus/iicsmb.c (revision 49189) @@ -0,0 +1,450 @@ +/*- + * Copyright (c) 1998 Nicolas Souchu + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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: iicsmb.c,v 1.1.2.2 1998/08/13 17:10:44 son Exp $ + * + */ + +/* + * I2C to SMB bridge + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include + +#include "iicbus_if.h" +#include "smbus_if.h" + +struct iicsmb_softc { + +#define SMB_WAITING_ADDR 0x0 +#define SMB_WAITING_LOW 0x1 +#define SMB_WAITING_HIGH 0x2 +#define SMB_DONE 0x3 + int state; + + u_char devaddr; /* slave device address */ + + char low; /* low byte received first */ + char high; /* high byte */ + + device_t smbus; +}; + +static int iicsmb_probe(device_t); +static int iicsmb_attach(device_t); +static void iicsmb_print_child(device_t, device_t); + +static void iicsmb_intr(device_t dev, int event, char *buf); +static int iicsmb_quick(device_t dev, u_char slave, int how); +static int iicsmb_sendb(device_t dev, u_char slave, char byte); +static int iicsmb_recvb(device_t dev, u_char slave, char *byte); +static int iicsmb_writeb(device_t dev, u_char slave, char cmd, char byte); +static int iicsmb_writew(device_t dev, u_char slave, char cmd, short word); +static int iicsmb_readb(device_t dev, u_char slave, char cmd, char *byte); +static int iicsmb_readw(device_t dev, u_char slave, char cmd, short *word); +static int iicsmb_pcall(device_t dev, u_char slave, char cmd, short sdata, short *rdata); +static int iicsmb_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf); +static int iicsmb_bread(device_t dev, u_char slave, char cmd, u_char count, char *buf); + +static devclass_t iicsmb_devclass; + +static device_method_t iicsmb_methods[] = { + /* device interface */ + DEVMETHOD(device_probe, iicsmb_probe), + DEVMETHOD(device_attach, iicsmb_attach), + + /* bus interface */ + DEVMETHOD(bus_print_child, iicsmb_print_child), + + /* iicbus interface */ + DEVMETHOD(iicbus_intr, iicsmb_intr), + + /* smbus interface */ + DEVMETHOD(smbus_quick, iicsmb_quick), + DEVMETHOD(smbus_sendb, iicsmb_sendb), + DEVMETHOD(smbus_recvb, iicsmb_recvb), + DEVMETHOD(smbus_writeb, iicsmb_writeb), + DEVMETHOD(smbus_writew, iicsmb_writew), + DEVMETHOD(smbus_readb, iicsmb_readb), + DEVMETHOD(smbus_readw, iicsmb_readw), + DEVMETHOD(smbus_pcall, iicsmb_pcall), + DEVMETHOD(smbus_bwrite, iicsmb_bwrite), + DEVMETHOD(smbus_bread, iicsmb_bread), + + { 0, 0 } +}; + +static driver_t iicsmb_driver = { + "iicsmb", + iicsmb_methods, + DRIVER_TYPE_MISC, + sizeof(struct iicsmb_softc), +}; + +static int +iicsmb_probe(device_t dev) +{ + struct iicsmb_softc *sc = (struct iicsmb_softc *)device_get_softc(dev); + + sc->smbus = smbus_alloc_bus(dev); + + if (!sc->smbus) + return (EINVAL); /* XXX don't know what to return else */ + + return (0); +} + +static int +iicsmb_attach(device_t dev) +{ + struct iicsmb_softc *sc = (struct iicsmb_softc *)device_get_softc(dev); + + /* probe and attach the smbus */ + device_probe_and_attach(sc->smbus); + + return (0); +} + +static void +iicsmb_print_child(device_t bus, device_t dev) +{ + printf(" on %s%d", device_get_name(bus), device_get_unit(bus)); + + return; +} + +/* + * iicsmb_intr() + * + * iicbus interrupt handler + */ +static void +iicsmb_intr(device_t dev, int event, char *buf) +{ + struct iicsmb_softc *sc = (struct iicsmb_softc *)device_get_softc(dev); + + switch (event) { + case INTR_GENERAL: + case INTR_START: + sc->state = SMB_WAITING_ADDR; + break; + + case INTR_STOP: + /* call smbus intr handler */ + smbus_intr(sc->smbus, sc->devaddr, + sc->low, sc->high, SMB_ENOERR); + break; + + case INTR_RECEIVE: + switch (sc->state) { + case SMB_DONE: + /* XXX too much data, discard */ + printf("%s: too much data from 0x%x\n", __FUNCTION__, + sc->devaddr & 0xff); + goto end; + + case SMB_WAITING_ADDR: + sc->devaddr = (u_char)*buf; + sc->state = SMB_WAITING_LOW; + break; + + case SMB_WAITING_LOW: + sc->low = *buf; + sc->state = SMB_WAITING_HIGH; + break; + + case SMB_WAITING_HIGH: + sc->high = *buf; + sc->state = SMB_DONE; + break; + } +end: + break; + + case INTR_TRANSMIT: + case INTR_NOACK: + break; + + case INTR_ERROR: + switch (*buf) { + case IIC_EBUSERR: + smbus_intr(sc->smbus, sc->devaddr, 0, 0, SMB_EBUSERR); + break; + + default: + printf("%s unknown error 0x%x!\n", __FUNCTION__, + (int)*buf); + break; + } + break; + + default: + panic("%s: unknown event (%d)!", __FUNCTION__, event); + } + + return; +} + +static int +iicsmb_quick(device_t dev, u_char slave, int how) +{ + device_t parent = device_get_parent(dev); + int error; + + switch (how) { + case SMB_QWRITE: + error = iicbus_start(parent, slave & ~LSB); + break; + + case SMB_QREAD: + error = iicbus_start(parent, slave | LSB); + break; + + default: + error = EINVAL; + break; + } + + if (!error) + error = iicbus_stop(parent); + + return (error); +} + +static int +iicsmb_sendb(device_t dev, u_char slave, char byte) +{ + device_t parent = device_get_parent(dev); + int error, sent; + + error = iicbus_start(parent, slave & ~LSB); + + if (!error) { + error = iicbus_write(parent, &byte, 1, &sent); + + iicbus_stop(parent); + } + + return (error); +} + +static int +iicsmb_recvb(device_t dev, u_char slave, char *byte) +{ + device_t parent = device_get_parent(dev); + int error, read; + + error = iicbus_start(parent, slave | LSB); + + if (!error) + error = iicbus_read(parent, byte, 1, &read); + + return (error); +} + +static int +iicsmb_writeb(device_t dev, u_char slave, char cmd, char byte) +{ + device_t parent = device_get_parent(dev); + int error, sent; + + error = iicbus_start(parent, slave & ~LSB); + + if (!error) { + if (!(error = iicbus_write(parent, &cmd, 1, &sent))) + error = iicbus_write(parent, &byte, 1, &sent); + + iicbus_stop(parent); + } + + return (error); +} + +static int +iicsmb_writew(device_t dev, u_char slave, char cmd, short word) +{ + device_t parent = device_get_parent(dev); + int error, sent; + + char low = (char)(word & 0xff); + char high = (char)((word & 0xff00) >> 8); + + error = iicbus_start(parent, slave & ~LSB); + + if (!error) { + if (!(error = iicbus_write(parent, &cmd, 1, &sent))) + if (!(error = iicbus_write(parent, &low, 1, &sent))) + error = iicbus_write(parent, &high, 1, &sent); + + iicbus_stop(parent); + } + + return (error); +} + +static int +iicsmb_readb(device_t dev, u_char slave, char cmd, char *byte) +{ + device_t parent = device_get_parent(dev); + int error, sent, read; + + if ((error = iicbus_start(parent, slave & ~LSB))) + goto error; + + if ((error = iicbus_write(parent, &cmd, 1, &sent))) + goto error; + + if ((error = iicbus_repeated_start(parent, slave | LSB))) + goto error; + + if ((error = iicbus_read(parent, byte, 1, &read))) + goto error; + +error: + return (error); +} + +#define BUF2SHORT(low,high) \ + ((short)(((high) & 0xff) << 8) | (short)((low) & 0xff)) + +static int +iicsmb_readw(device_t dev, u_char slave, char cmd, short *word) +{ + device_t parent = device_get_parent(dev); + int error, sent, read; + char buf[2]; + + if ((error = iicbus_start(parent, slave & ~LSB))) + goto error; + + if ((error = iicbus_write(parent, &cmd, 1, &sent))) + goto error; + + if ((error = iicbus_repeated_start(parent, slave | LSB))) + goto error; + + if ((error = iicbus_read(parent, buf, 2, &read))) + goto error; + + /* first, receive low, then high byte */ + *word = BUF2SHORT(buf[0], buf[1]); + +error: + return (error); +} + +static int +iicsmb_pcall(device_t dev, u_char slave, char cmd, short sdata, short *rdata) +{ + device_t parent = device_get_parent(dev); + int error, sent, read; + char buf[2]; + + if ((error = iicbus_start(parent, slave & ~LSB))) + goto error; + + if ((error = iicbus_write(parent, &cmd, 1, &sent))) + goto error; + + /* first, send low, then high byte */ + buf[0] = (char)(sdata & 0xff); + buf[1] = (char)((sdata & 0xff00) >> 8); + + if ((error = iicbus_write(parent, buf, 2, &sent))) + goto error; + + if ((error = iicbus_repeated_start(parent, slave | LSB))) + goto error; + + if ((error = iicbus_read(parent, buf, 2, &read))) + goto error; + + /* first, receive low, then high byte */ + *rdata = BUF2SHORT(buf[0], buf[1]); + +error: + return (error); +} + +static int +iicsmb_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf) +{ + device_t parent = device_get_parent(dev); + int error, sent; + + if ((error = iicbus_start(parent, slave & ~LSB))) + goto error; + + if ((error = iicbus_write(parent, &cmd, 1, &sent))) + goto error; + + if ((error = iicbus_write(parent, buf, (int)count, &sent))) + goto error; + + if ((error = iicbus_stop(parent))) + goto error; + +error: + return (error); +} + +static int +iicsmb_bread(device_t dev, u_char slave, char cmd, u_char count, char *buf) +{ + device_t parent = device_get_parent(dev); + int error, sent, read; + + if ((error = iicbus_start(parent, slave & ~LSB))) + goto error; + + if ((error = iicbus_write(parent, &cmd, 1, &sent))) + goto error; + + if ((error = iicbus_repeated_start(parent, slave | LSB))) + goto error; + + if ((error = iicbus_read(parent, buf, (int)count, &read))) + goto error; + +error: + return (error); +} + +DRIVER_MODULE(iicsmb, iicbus, iicsmb_driver, iicsmb_devclass, 0, 0); Property changes on: cvs2svn/tags/initial/sys/dev/iicbus/iicsmb.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/tools/tools/kdrv/KernelDriver =================================================================== --- cvs2svn/tags/initial/tools/tools/kdrv/KernelDriver (nonexistent) +++ cvs2svn/tags/initial/tools/tools/kdrv/KernelDriver (revision 49189) @@ -0,0 +1,803 @@ +#!/bin/sh +# Tcl magic -*- tcl -*- \ +exec tclsh $0 $* +################################################################################ +# +# KernelDriver - FreeBSD driver source installer +# +################################################################################ +# +# Copyright (C) 1997 +# Michael Smith. 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. Neither the name of the author nor the names of any co-contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY Michael Smith AND CONTRIBUTORS ``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 Michael Smith OR CONTRIBUTORS 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. +# +################################################################################ +# +# KernelDriver provides a means for installing source-form drivers into FreeBSD +# kernel source trees in an automated fashion. It can also remove drivers it +# has installed. +# +# Driver information is read from a control file, with the following syntax : +# +# description {} Driver description; used in comments inserted into +# files. +# driver The name of the driver. +# file The file in the driver package is installed into +# in the kernel source tree. Files whose names +# end in '.c' have an entry added to i386/conf/files.i386. +# option Adds an entry to i386/conf/options.i386, such that +# the option will be placed in the header . +# linttext Lines between this and a subsequent 'end' line are added +# to the LINT file to provide configuration examples, +# comments, etc. +# end Ends a text region. +# +# Possible additions : +# +# patch Applies the patch contained in ; patch is invoked +# at the top level of the kernel source tree, and the +# patch must apply cleanly (this is checked). +# +# option Adds an entry to i386/conf/options.i386 +# +# Lines beginning with '#' or blanks are considered comments, except in +# 'linttext' regions. +# +################################################################################ +# +# $Id: KernelDriver,v 1.3 1997/01/21 08:23:31 msmith Exp $ +# +################################################################################ + +################################################################################ +# findDrvFile +# +# Given (hint), use it to locate a driver information file. +# (Possible extension; support drivers in gzipped tarballs...) +# +proc findDrvFile_try {hint} { + + # points to something already + if {[file exists $hint]} { + # unwind symbolic links + while {[file type $hint] == "link"} { + set hint [file readlink $hint]; + } + switch [file type $hint] { + file { + # run with it as it is + return $hint; + } + directory { + # look for a drvinfo file in the directory + set candidate [glob -nocomplain "$hint/*.drvinfo"]; + switch [llength $candidate] { + 0 { + error "no driver info files in directory : $hint"; + } + 1 { + return $candidate; + } + default { + error "multiple driver info files in directory : $hint"; + } + } + } + default { + error "driver info file may be a typewriter : $hint"; + } + } + } + return ""; +} + +proc findDrvFile {hint} { + + set result [findDrvFile_try $hint]; + if {$result != ""} { + return $result; + } + set result [findDrvFile_try ${hint}.drvinfo]; + if {$result != ""} { + return $result; + } + error "can't find driver information file using : $hint"; +} + +################################################################################ +# readDrvFile +# +# Reads the contents of (fname), which are expected to be in the format +# described above, and fill in the global Drv array. +# +proc readDrvFile {fname} { + + global Drv Options; + + if {$Options(verbose)} {puts "+ read options from '$fname'";} + set fh [open $fname r]; + + # set defaults + set Drv(description) ""; + set Drv(driver) ""; + set Drv(files) ""; + set Drv(options) ""; + set Drv(patches) ""; + set Drv(linttext) ""; + + while {[gets $fh line] >= 0} { + + # blank lines/comments + if {([llength $line] == 0) || + ([string index $line 0] == "\#")} { + continue ; + } + + # get keyword, process + switch -- [lindex $line 0] { + description { + set Drv(description) [lindex $line 1]; + } + driver { + set Drv(driver) [lindex $line 1]; + } + file { + set path [lindex $line 1]; + set plast [expr [string length $path] -1]; + if {[string index $path $plast] != "/"} { + append path "/"; + } + set name [lindex $line 2]; + set Drv(file:$name) $path; + lappend Drv(files) $name; + } + option { + set opt [lindex $line 1]; + set hdr [lindex $line 2]; + lappend Drv(options) $opt; + set Drv(option:$opt) $hdr; + } + patch { + lappend Drv(patches) [lindex $line 1]; + } + linttext { + while {[gets $fh line] >= 0} { + if {$line == "end"} { + break ; + } + lappend Drv(linttext) $line; + } + } + } + } + close $fh; + if {$Options(verbose)} { + printDrv; + } +} + +################################################################################ +# validateDrvPackage +# +# With the global Drv filled in, check that the files required are all in +# (dir), and that the kernel config at (kpath) can be written. +# +proc validateDrvPackage {dir kpath} { + + global Drv Options; + + if {$Options(verbose)} {puts "+ checking driver package...";} + set missing ""; + set unwritable ""; + + # check files, patches + foreach f $Drv(files) { + if {![file readable $dir$f]} { + lappend missing $f; + } + } + foreach f $Drv(patches) { + if {![file readable $dir$f]} { + lappend missing $f; + } + } + if {$missing != ""} { + error "missing files : $missing"; + } + + # check writability + if {$Options(verbose)} {puts "+ checking kernel source writability...";} + foreach f $Drv(files) { + set p $Drv(file:$f); + if {![file isdirectory $kpath$p]} { + lappend missing $p; + } else { + if {![file writable $kpath$p]} { + if {[lsearch -exact $unwritable $p] == -1} { + lappend unwritable $p; + } + } + } + } + foreach f [list \ + "i386/conf/files.i386" \ + "i386/conf/options.i386" \ + "i386/conf/LINT"] { + if {![file writable $kpath$f]} { + lappend unwritable $f; + } + } + if {$missing != ""} { + error "missing directories : $missing"; + } + if {$unwritable != ""} { + error "can't write to : $unwritable"; + } +} + +################################################################################ +# installDrvFiles +# +# Install the files listed in the global Drv into (kpath) from (dir) +# +proc installDrvFiles {dir kpath} { + + global Drv Options; + + # clear 'installed' record + set Drv(installed) ""; + set failed ""; + + if {$Options(verbose)} {puts "+ installing driver files...";} + foreach f $Drv(files) { + if {$Options(verbose)} {puts "$f -> $kpath$Drv(file:$f)";} + if {$Options(real)} { + if {[catch {exec cp $dir$f $kpath$Drv(file:$f)} msg]} { + lappend failed $f; + } else { + lappend Drv(installed) $f; + } + } + } + if {$failed != ""} { + error "failed to install files : $failed"; + } +} + +################################################################################ +# backoutDrvChanges +# +# Remove files from a failed installation in (kpath) +# +proc backoutDrvChanges {kpath} { + + global Drv Options; + + if {$Options(verbose)} {puts "+ backing out installed files...";} + # delete installed files + foreach f $Drv(installed) { + exec rm -f $kpath$Drv(file:$f)$f; + } +} + +################################################################################ +# registerDrvFiles +# +# Adds an entry to i386/conf/files.i386 for the .c files in the driver. +# (kpath) points to the kernel. +# +# A comment is added to the file preceeding the new entries : +# +# ## driver: +# # +# # file: +# +# ## enddriver +# +# We only append to the end of the file. +# +# Add linttext to the LINT file. +# Add options to i386/conf/options.i386 if any are specified +# +proc registerDrvFiles {kpath} { + + global Drv Options; + + if {$Options(verbose)} {puts "+ registering installed files...";} + + if {$Options(real)} { + set fname [format "%si386/conf/files.i386" $kpath]; + set fh [open $fname a]; + + # header + puts $fh "\#\# driver: $Drv(driver)"; + puts $fh "\# $Drv(description)"; + # file information + foreach f $Drv(files) { + puts $fh "\# file: $Drv(file:$f)$f"; + # is it a compilable object? + if {[string match "*.c" $f]} { + puts $fh "$Drv(file:$f)$f\t\toptional\t$Drv(driver)\tdevice-driver"; + } + } + puts $fh "\#\# enddriver"; + close $fh; + } + if {$Drv(linttext) != ""} { + + if {$Options(verbose)} {puts "+ updating LINT...";} + if {$Options(real)} { + set fname [format "%si386/conf/LINT" $kpath]; + set fh [open $fname a]; + + # header + puts $fh "\#\# driver: $Drv(driver)"; + puts $fh "\# $Drv(description)"; + foreach l $Drv(linttext) { + puts $fh $l; + } + puts $fh "\#\# enddriver"; + close $fh; + } + } + if {$Drv(options) != ""} { + if {$Options(verbose)} {puts "+ adding options...";} + if {$Options(real)} { + set fname [format "%si386/conf/options.i386" $kpath]; + set fh [open $fname a]; + + # header + puts $fh "\#\# driver: $Drv(driver)"; + puts $fh "\# $Drv(description)"; + # options + foreach opt $Drv(options) { + puts $fh "$opt\t$Drv(option:$opt)"; + } + puts $fh "\#\# enddriver"; + close $fh; + } + } +} + +################################################################################ +# listInstalledDrv +# +# List all drivers recorded as installed, in the kernel at (kpath) +# +proc listInstalledDrv {kpath} { + + global Drv; + + set drvopt ""; # drivers with options + + # pick up all the options information first + set fname [format "%si386/conf/options.i386" $kpath]; + set fh [open $fname r]; + + while {[gets $fh line] >= 0} { + + # got a driver? + if {[scan $line "\#\# driver: %s" Drv(driver)] == 1} { + # read driver details, ignore + gets $fh line; + # loop reading option details + while {[gets $fh line] >= 0} { + # end of driver info + if {$line == "\#\# enddriver"} { + break ; + } + # parse + if {[scan $line "%s %s" $opt $hdr] == 2} { + lappend opts($driver:list) $opt; + # learn all of the options at once + set Drv(option:$opt) $hdr; + } + } + # this driver has options + lappend drvopt $driver; + } + } + close $fh; + + set fname [format "%si386/conf/files.i386" $kpath]; + set fh [open $fname r]; + + while {[gets $fh line] >= 0} { + + # got a driver? + if {[scan $line "\#\# driver: %s" Drv(driver)] == 1} { + # read driver details + gets $fh line; + set Drv(description) [string range $line 2 end]; + set Drv(files) ""; + # options? + if {[lsearch -exact $drvopt $Drv(driver)] != -1} { + set Drv(options) $opts($Drv(driver)); + } + # loop reading file details + while {[gets $fh line] >= 0} { + if {$line == "\#\# enddriver"} { + printDrv; + break ; + } + if {[scan $line "\# file: %s" fpath] == 1} { + set f [file tail $fpath]; + set Drv(file:$f) "[file dirname $fpath]/"; + lappend Drv(files) $f; + } + } + } + } + close $fh; +} + +################################################################################ +# printDrv +# +# Print the contents of the global Drv. +# +proc printDrv {} { + + global Drv Options; + + puts "$Drv(driver) : $Drv(description)"; + if {$Options(verbose)} { + foreach f $Drv(files) { + puts " $Drv(file:$f)$f" + } + foreach opt $Drv(options) { + puts " $opt in $Drv(option:$opt)"; + } + } +} + +################################################################################ +# findInstalledDrv +# +# Given a kernel tree at (kpath), get driver details about an installed +# driver (drvname) +# +proc findInstalledDrv {drvname kpath} { + + global Drv Options; + + if {$Options(verbose)} {puts "+ look for driver '$drvname' in '$kpath'";} + + set fname [format "%si386/conf/files.i386" $kpath]; + set fh [open $fname r]; + + while {[gets $fh line] >= 0} { + if {[scan $line "\#\# driver: %s" name] == 1} { + if {$name != $drvname} { + continue ; # not us + } + # read information + set Drv(driver) $drvname; + set line [gets $fh]; + set Drv(description) [string range $line 2 end]; + set Drv(files) ""; + # loop reading file details + while {[gets $fh line] >= 0} { + if {$line == "\#\# enddriver"} { + close $fh; + return ; # all done + } + if {[scan $line "\# file: %s" fpath] == 1} { + set f [file tail $fpath]; + set Drv(file:$f) "[file dirname $fpath]/"; + lappend Drv(files) $f; + } + } + close $fh; + error "unexpected EOF reading '$fname'"; + } + } + close $fh + error "driver '$drvname' not recorded as installed"; +} + +################################################################################ +# validateDrvRemoval +# +# Verify that we can remove the driver described in the global Drv installed +# at (kpath). +# +proc validateDrvRemoval {kpath} { + + global Drv Options; + + set missing ""; + set unwritable ""; + + if {$Options(verbose)} {puts "+ checking for removabilty...";} + + # admin files? + foreach f [list \ + "i386/conf/files.i386" \ + "i386/conf/options.i386" \ + "i386/conf/LINT"] { + if {![file exists $kpath$f]} { + lappend missing $kpath$f; + } else { + if {![file writable $kpath$f]} { + lappend unwritable $f; + } + } + } + # driver components? + foreach f $Drv(files) { + set p $Drv(file:$f); + if {![file isdirectory $kpath$p]} { + lappend missing $p; + } else { + if {![file writable $kpath$p]} { + if {[lsearch -exact $unwritable $p] == -1} { + lappend unwritable $p; + } + } + } + } + if {$missing != ""} { + error "files/directories missing : $missing"; + } + if {$unwritable != ""} { + error "can't write to : $unwritable"; + } +} + +################################################################################ +# deleteDrvFiles +# +# Delete the files belonging to the driver devfined in the global Drv in +# the kernel tree at (kpath) +# +proc deleteDrvFiles {kpath} { + + global Drv Options; + + if {$Options(verbose)} {puts "+ delete driver files...";} + + # loop deleting files + foreach f $Drv(files) { + if {$Options(verbose)} {puts "- $Drv(file:$f)$f";} + if {$Options(real)} { + exec rm $kpath$Drv(file:$f)$f; + } + } +} + +################################################################################ +# unregisterDrvFiles +# +# Remove any mention of the current driver from the files.i386 and LINT +# files in (ksrc) +# +proc unregisterDrvFiles {ksrc} { + + global Drv Options; + + if {$Options(verbose)} {puts "+ deregister driver files...";} + + # don't really do it? + if {!$Options(real)} { return ; } + + foreach f [list \ + "i386/conf/files.i386" \ + "i386/conf/options.i386" \ + "i386/conf/LINT"] { + set ifh [open $ksrc$f r]; + set ofh [open $ksrc$f.new w]; + set copying 1; + + while {[gets $ifh line] >= 0} { + + if {[scan $line "\#\# driver: %s" name] == 1} { + if {$name == $Drv(driver)} { + set copying 0; # don't copy this one + } + } + if {$copying} { + puts $ofh $line; # copy through + } + if {$line == "\#\# enddriver"} { # end of driver detail + set copying 1; + } + } + close $ifh; + close $ofh; + exec mv $ksrc$f.new $ksrc$f; # move new over old + } +} + +################################################################################ +# usage +# +# Remind the user what goes where +# +proc usage {} { + + global argv0; + + set progname [file tail $argv0]; + + puts stderr "Usage is :"; + puts stderr " $progname \[-v -n\] add \[\]"; + puts stderr " $progname \[-v -n\] delete \[\]"; + puts stderr " $progname \[-v\] list \[\]"; + puts stderr " is a driver info file"; + puts stderr " is a driver name"; + puts stderr " is the path to the kernel source (default /sys/)"; + puts stderr " -v be verbose"; + puts stderr " -n don't actually do anything"; + exit ; +} + +################################################################################ +# getOptions +# +# Parse commandline options, return anything that doesn't look like an option +# +proc getOptions {} { + + global argv Options; + + set Options(real) 1; + set Options(verbose) 0; + set ret ""; + + for {set index 0} {$index < [llength $argv]} {incr index} { + + switch -- [lindex $argv $index] { + + -n { + set Options(real) 0; # 'do-nothing' mode + } + -v { + set Options(verbose) 1; # brag + } + default { + lappend ret [lindex $argv $index]; + } + } + } + return $ret; +} + +################################################################################ +# getKpath +# +# Given (hint), return the kernel path. If (hint) is empty, return /sys. +# If the kernel path is not a directory, dump the usage. +# +proc getKpath {hint} { + + set kpath ""; + + # check the kernel path + if {$hint == ""} { + set kpath "/sys/"; + } else { + set kpath $hint; + } + if {![file isdirectory $kpath]} { + usage ; + } + set plast [expr [string length $kpath] -1]; + if {[string index $kpath $plast] != "/"} { + append kpath "/"; + } + return $kpath; +} + +################################################################################ +# main +# +# Start somewhere here. +# +proc main {} { + + global Options; + + # Work out what we're trying to do + set cmdline [getOptions]; + set mode [lindex $cmdline 0]; + + # do stuff + switch -- $mode { + add { + set hint [lindex $cmdline 1]; + set kpath [getKpath [lindex $cmdline 2]]; + + # check driver file argument + if {[catch {set drv [findDrvFile $hint]} msg]} { + puts stderr msg; + usage ; + } + if {([file type $drv] != "file") || + ![file readable $drv]} { + puts "can't read driver file : $drv"; + usage ; + } + set drvdir "[file dirname $drv]/"; + + # read driver file + if {[catch {readDrvFile $drv} msg]} { + puts stderr $msg; + exit ; + } + # validate driver + if {[catch {validateDrvPackage $drvdir $kpath} msg]} { + puts stderr $msg; + exit ; + } + # install new files + if {[catch {installDrvFiles $drvdir $kpath} msg]} { + backoutDrvChanges $kpath; # oops, unwind + puts stderr $msg; + exit ; + } + # register files in config + if {[catch {registerDrvFiles $kpath} msg]} { + backoutDrvChanges $kpath; # oops, unwind + puts stderr $msg; + exit ; + } + } + delete { + set drv [lindex $cmdline 1]; + set kpath [getKpath [lindex $cmdline 2]]; + + if {[catch {findInstalledDrv $drv $kpath} msg]} { + puts stderr $msg; + exit ; + } + if {[catch {validateDrvRemoval $kpath} msg]} { + puts stderr $msg; + exit ; + } + if {[catch {unregisterDrvFiles $kpath} msg]} { + puts stderr $msg; + exit ; + } + if {[catch {deleteDrvFiles $kpath} msg]} { + puts stderr $msg; + exit ; + } + } + list { + set kpath [getKpath [lindex $cmdline 1]]; + listInstalledDrv $kpath + } + default { + usage ; + } + } +} + + + +################################################################################ +main; Property changes on: cvs2svn/tags/initial/tools/tools/kdrv/KernelDriver ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/tools/tools/kdrv/sample.drvinfo =================================================================== --- cvs2svn/tags/initial/tools/tools/kdrv/sample.drvinfo (nonexistent) +++ cvs2svn/tags/initial/tools/tools/kdrv/sample.drvinfo (revision 49189) @@ -0,0 +1,39 @@ +# +# Sample driver information file for KernelDriver. See the top of +# the KernelDriver script for a more exact definition of the syntax. +# +# $Id: sample.drvinfo,v 1.1 1997/01/21 08:23:32 msmith Exp $ + +# Device driver name +# +driver blorg + +# Description (must be in curly braces) +# +description {Snoofle roob wronkle bnar} + +# List of files to install for the driver. +# Files ending in .c will be added to files.i386 as required for +# this driver. Paths listed seperately. +# +file i386/isa/ mdsio.c +file i386/include mdsio.h + +# List of options used by the driver, and the header into which +# they should be written. +# +option MDSIO_RXBUF opt_mdsio.h +option MDSIO_TXBUF opt_mdsio.h +option MDSIO_DEBUG opt_mdsio.h + +# Text to be added to LINT to provide configuration examples for the +# user. +# + +linttext +# +# This driver causes your system to emit occasional digestive noises. +# +device blorg0 at isa? port 0x123 irq 10 flags 0x10 drq 2 vector blorgintr +device blorg1 at isa? port 0x234 irq 11 flags 0x10 drq 2 vector blorgintr +end Property changes on: cvs2svn/tags/initial/tools/tools/kdrv/sample.drvinfo ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/usr.sbin/elf2exe/Makefile =================================================================== --- cvs2svn/tags/initial/usr.sbin/elf2exe/Makefile (nonexistent) +++ cvs2svn/tags/initial/usr.sbin/elf2exe/Makefile (revision 49189) @@ -0,0 +1,9 @@ +# $Id$ + +PROG= elf2exe +SRCS= elf2exe.c +MAN8= elf2exe.8 + +MANSUBDIR=/${MACHINE_ARCH} + +.include Property changes on: cvs2svn/tags/initial/usr.sbin/elf2exe/Makefile ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/usr.sbin/elf2exe/elf2exe.8 =================================================================== --- cvs2svn/tags/initial/usr.sbin/elf2exe/elf2exe.8 (nonexistent) +++ cvs2svn/tags/initial/usr.sbin/elf2exe/elf2exe.8 (revision 49189) @@ -0,0 +1,49 @@ +.\" Copyright (c) 1999 Stefan Esser +.\" +.\" 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. +.\" +.\" $Id$ +.\" +.Dd July 26, 1999 +.Dt ELF2EXE 8 +.Os FreeBSD 4.0 +.Sh NAME +.Nm elf2exe +.Nd convert Alpha ELF executable to AlphaBIOS / ARCS format +.Sh SYNOPSIS +.Nm elf2exe +.Ar infile +.Ar outfile +.Sh DESCRIPTION +.Nm Elf2exe +creates an executable that can be loaded by the AlphaBIOS or ARCS consoles +as found on systems designed for +.Tn Windows/NT . +The input file must have been +created as a non-relocatable standalone binary with a load address within +the memory range available for user programs (0x80000000 to 0x806fdfff +and 0x80900000 to at least 0x80ffffff). +.Pp +The command prints a list of sections found in the ELF executable and the +section sizes and offsets of the output file for diagnostic purposes. +.Pp +Given an object file +.B src.o +the follwoing two commands will create a binary for ARCS: +.Dl ld \-o a.out \-M \-N \-Ttext 0x80900000 src.o\c +.Dl elf2exe a.out a.exe\c +.Sh BUGS +.Nm Elf2exe +does not even attempt to verify that the input file matches the requirements +for an ARC executable. +.Sh HISTORY +The +.Nm +command appeared in FreeBSD 4.0. Property changes on: cvs2svn/tags/initial/usr.sbin/elf2exe/elf2exe.8 ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/usr.sbin/elf2exe/elf2exe.c =================================================================== --- cvs2svn/tags/initial/usr.sbin/elf2exe/elf2exe.c (nonexistent) +++ cvs2svn/tags/initial/usr.sbin/elf2exe/elf2exe.c (revision 49189) @@ -0,0 +1,380 @@ +/*- + * Copyright (c) 1999 Stefan Esser + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +/* + * Make an ARC firmware executable from an ELF file. + */ + +#include + +#include +#include +#include +#include +#include +#include + +#define ALPHA_FMAGIC 0x184 + +#define TOTHSZ 0x200 + +typedef struct filehdr { + u_int16_t f_magic; + u_int16_t f_nscns; + u_int32_t f_timdat; + u_int32_t f_symptr; + u_int32_t f_nsyms; + u_int16_t f_opthdr; + u_int16_t f_flags; +} FILHDR; +#define FILHSZ 20 + +#define ALPHA_AMAGIC 0407 + +typedef struct aouthdr { + u_int16_t a_magic; + u_int16_t a_vstamp; + u_int32_t a_tsize; + u_int32_t a_dsize; + u_int32_t a_bsize; + u_int32_t a_entry; + u_int32_t a_text_start; + u_int32_t a_data_start; + u_int32_t a_bss_start; + u_int32_t a_gprmask; + u_int32_t a_cprmask[4]; + u_int32_t a_gp_value; +} AOUTHDR; +#define AOUTSZ 56 + +typedef struct scnhdr { + char s_name[8]; + u_int32_t s_fill; + u_int32_t s_vaddr; + u_int32_t s_size; + u_int32_t s_scnptr; + u_int32_t s_relptr; + u_int32_t s_lnnoptr; + u_int16_t s_nreloc; + u_int16_t s_nlnno; + u_int32_t s_flags; +} SCNHDR; +#define SCNHSZ 40 + +#define ROUNDUP(a,b) ((((a) -1) | ((b) -1)) +1) + +/* + * initialization subroutines + */ + +int +open_elffile(char *filename) +{ + int fileno = open(filename, O_RDONLY); + if (fileno < 0) + err(1, filename); + return (fileno); +} + + +Elf64_Ehdr * +load_ehdr(int fileno) +{ + Elf64_Ehdr *ehdr; + int bytes = sizeof(*ehdr); + ehdr = malloc(bytes); + if (ehdr) { + lseek(fileno, 0, SEEK_SET); + if (read(fileno, ehdr, bytes) != bytes) + errx(1, "file truncated (ehdr)"); + } + return (ehdr); +} + +Elf64_Phdr * +load_phdr(int fileno, Elf64_Ehdr *ehdr) +{ + int bytes = ehdr->e_phentsize * ehdr->e_phnum; + Elf64_Phdr *phdr = malloc(bytes); + if (phdr) { + lseek(fileno, ehdr->e_phoff, SEEK_SET); + if (read(fileno, phdr, bytes) != bytes) + errx(1, "file truncated (phdr)"); + } + return (phdr); +} + +Elf64_Shdr * +load_shdr(int fileno, Elf64_Ehdr *ehdr) +{ + int bytes = ehdr->e_shentsize * ehdr->e_shnum; + + Elf64_Shdr *shdr = malloc(bytes); + if (shdr) { + lseek(fileno, ehdr->e_shoff, SEEK_SET); + if (read(fileno, shdr, bytes) != bytes) + errx(1, "file truncated (shdr)"); + } + return (shdr); +} + +char * +find_shstrtable(int fileno, int sections, Elf64_Shdr *shdr) +{ + char *shstrtab = NULL; + int i; + int shstrtabindex; + for (i = 0; shstrtab == NULL && i < sections; i++) { + if (shdr[i].sh_type == 3 && shdr[i].sh_flags == 0) { + shstrtabindex = i; + + shstrtab = malloc(shdr[shstrtabindex].sh_size); + lseek(fileno, shdr[shstrtabindex].sh_offset, SEEK_SET); + read(fileno, shstrtab, shdr[shstrtabindex].sh_size); + + if (strcmp (shstrtab + shdr[i].sh_name, ".shstrtab")) { + free(shstrtab); + shstrtab = NULL; + } + } + } + return shstrtab; +} + +int +open_exefile(char *filename) +{ + int fileno = open(filename, O_RDWR | O_TRUNC | O_CREAT, 0666); + if (fileno < 0) + err(1, filename); + return (fileno); +} + +/* + * utility subroutines + */ + +static char *shstrtab; + +char * +section_name(Elf64_Shdr *shdr, int i) +{ + return (shstrtab + shdr[i].sh_name); +} + +long +section_index(Elf64_Shdr *shdr, int sections, char *name) +{ + int i; + + for (i = 0; i < sections; i++) + if (strcmp (name, section_name(shdr, i)) == 0) + return (i); + + return -1; +} + +/* first byte of section */ +long +section_start(Elf64_Shdr *shdr, int sections, char *name) +{ + int i = section_index(shdr, sections, name); + if (i < 0) + return -1; + + return shdr[i].sh_addr; +} + +/* last byte of section */ +long +section_end(Elf64_Shdr *shdr, int sections, char *name) +{ + int i = section_index(shdr, sections, name); + if (i < 0) + return -1; + + return shdr[i].sh_addr + shdr[i].sh_size -1; +} + +/* last byte of section */ +long +section_size(Elf64_Shdr *shdr, int sections, char *name) +{ + int i = section_index(shdr, sections, name); + if (i < 0) + return -1; + + return shdr[i].sh_size; +} + +/* file position of section start */ +long +section_fpos(Elf64_Shdr *shdr, int sections, char *name) +{ + int i = section_index(shdr, sections, name); + if (i < 0) + return -1; + + return shdr[i].sh_offset; +} + +int +main(int argc, char** argv) +{ + int infd, outfd, i; + Elf64_Ehdr *ehdr; + Elf64_Phdr *phdr; + Elf64_Shdr *shdr; + int shstrtabindex; + FILHDR filehdr; + AOUTHDR aouthdr; + SCNHDR textscn, datascn; + long textstart, textsize, textsize2, textfsize, textfpos; + long datastart, datasize, datafsize, datafpos; + long bssstart, bsssize; + long progentry; + char* p; + int sections; + + if (argc != 3) + errx(1, "usage: elf2exe "); + + infd = open_elffile(argv[1]); + ehdr = load_ehdr(infd); + + if (ehdr == NULL) + errx(1, "can´t read Elf Header\n"); + + sections = ehdr->e_shnum; + progentry = ehdr->e_entry; + + phdr = load_phdr(infd, ehdr); + shdr = load_shdr(infd, ehdr); + outfd = open_exefile(argv[2]); + + shstrtab = find_shstrtable(infd, sections, shdr); + + for (i = 1; i < sections; i++) { + printf("section %d (%s): " + "type=%x flags=0%x " + "offs=%x size=%x addr=%x\n", + i, shstrtab + shdr[i].sh_name, + shdr[i].sh_type, shdr[i].sh_flags, + shdr[i].sh_offset, shdr[i].sh_size, shdr[i].sh_addr); + } + + textstart = section_start(shdr, sections, ".text"); + textsize = section_size(shdr, sections, ".text"); + textsize2 = section_end(shdr, sections, ".rodata") - textstart +1; + if (textsize < textsize2) + textsize = textsize2; + textfsize = ROUNDUP(textsize, 512); + textfpos = section_fpos(shdr, sections, ".text"); + + datastart = section_start(shdr, sections, ".data"); + datasize = section_start(shdr, sections, ".bss") - datastart; + datafsize = ROUNDUP(datasize, 512); + datafpos = section_fpos(shdr, sections, ".data"); + + bssstart = section_start(shdr, sections, ".bss"); + bsssize = section_size(shdr, sections, ".bss"); + + printf ("text: %x(%x) @%x data: %x(%x) @%x bss: %x(%x)\n", + textstart, textsize, textfpos, + datastart, datasize, datafpos, + bssstart, bsssize); + + memset(&filehdr, 0, sizeof filehdr); + memset(&aouthdr, 0, sizeof aouthdr); + memset(&textscn, 0, sizeof textscn); + memset(&datascn, 0, sizeof datascn); + + filehdr.f_magic = ALPHA_FMAGIC; + filehdr.f_nscns = 2; + filehdr.f_timdat = time(0); + filehdr.f_symptr = 0; + filehdr.f_nsyms = 0; + filehdr.f_opthdr = AOUTSZ; + filehdr.f_flags = 0x010f; + + aouthdr.a_magic = ALPHA_AMAGIC; + aouthdr.a_vstamp = 0x5004; + aouthdr.a_tsize = textfsize; + aouthdr.a_dsize = datafsize; + aouthdr.a_bsize = bsssize; + aouthdr.a_entry = progentry; + aouthdr.a_text_start = textstart; + aouthdr.a_data_start = datastart; + aouthdr.a_bss_start = bssstart; + + strcpy(textscn.s_name, ".text"); + textscn.s_fill = textsize; + textscn.s_vaddr = textstart; + textscn.s_size = textfsize; + textscn.s_scnptr = 0x200; + textscn.s_relptr = 0; + textscn.s_lnnoptr = 0; + textscn.s_nreloc = 0; + textscn.s_nlnno = 0; + textscn.s_flags = 0x20; + + strcpy(datascn.s_name, ".data"); + datascn.s_fill = datasize; + datascn.s_vaddr = datastart; + datascn.s_size = datafsize; + datascn.s_scnptr = 0x200 + textfsize; + datascn.s_relptr = 0; + datascn.s_lnnoptr = 0; + datascn.s_nreloc = 0; + datascn.s_nlnno = 0; + datascn.s_flags = 0x40; + + write(outfd, &filehdr, FILHSZ); + write(outfd, &aouthdr, AOUTSZ); + write(outfd, &textscn, SCNHSZ); + write(outfd, &datascn, SCNHSZ); + + lseek(outfd, textscn.s_scnptr, SEEK_SET); + p = malloc(ROUNDUP(textsize, 512)); + memset(p, 0, ROUNDUP(textsize, 512)); + lseek(infd, textfpos, SEEK_SET); + read(infd, p, textsize); + write(outfd, p, ROUNDUP(textsize, 512)); + free(p); + + lseek(outfd, datascn.s_scnptr, SEEK_SET); + p = malloc(ROUNDUP(datasize, 512)); + memset(p, 0, ROUNDUP(datasize, 512)); + lseek(infd, datafpos, SEEK_SET); + read(infd, p, datasize); + write(outfd, p, ROUNDUP(datasize, 512)); + free(p); + + return 0; +} + Property changes on: cvs2svn/tags/initial/usr.sbin/elf2exe/elf2exe.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/usr.sbin/lsdev/Makefile =================================================================== --- cvs2svn/tags/initial/usr.sbin/lsdev/Makefile (nonexistent) +++ cvs2svn/tags/initial/usr.sbin/lsdev/Makefile (revision 49189) @@ -0,0 +1,8 @@ +# $Id$ + +PROG= lsdev +MAN8= lsdev.8 +SRCS= lsdev.c ${MACHINE}.c +CFLAGS+= -I${.CURDIR}/../../sys + +.include Property changes on: cvs2svn/tags/initial/usr.sbin/lsdev/Makefile ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/usr.sbin/lsdev/i386.c =================================================================== --- cvs2svn/tags/initial/usr.sbin/lsdev/i386.c (nonexistent) +++ cvs2svn/tags/initial/usr.sbin/lsdev/i386.c (revision 49189) @@ -0,0 +1,183 @@ +#include "lsdev.h" +#include +#include + +static void print_isa(struct devconf *); +static void print_eisa(struct devconf *); +static void print_pci(struct devconf *); +static void print_scsi(struct devconf *); +static void print_disk(struct devconf *); + +void +print(struct devconf *dc) +{ + if(vflag) + printf("%d: ", dc->dc_number); + + switch(dc->dc_devtype) { + case MDDT_CPU: + printf("CPU on %s", dc->dc_parent); + break; + case MDDT_ISA: + if(dc->dc_datalen >= ISA_EXTERNALLEN) { + print_isa(dc); + } else { +printit: + printf("%s%d on %s", + dc->dc_name, dc->dc_unit, dc->dc_parent); + } + break; + case MDDT_EISA: + if(dc->dc_datalen >= EISA_EXTERNALLEN) { + print_eisa(dc); + } else { + goto printit; + } + break; + case MDDT_PCI: + if(dc->dc_datalen >= PCI_EXTERNALLEN) { + print_pci(dc); + } else { + goto printit; + } + break; + case MDDT_SCSI: + if(dc->dc_datalen >= SCSI_EXTERNALLEN) { + print_scsi(dc); + } else { + goto printit; + } + break; + case MDDT_DISK: + if(dc->dc_datalen >= DISK_EXTERNALLEN) { + print_disk(dc); + } else { + goto printit; + } + break; + + default: + if(dc->dc_devtype >= NDEVTYPES) { + printf("%s%d (#%d) on %s", + dc->dc_name, dc->dc_unit, dc->dc_devtype, + dc->dc_parent); + } else { + printf("%s%d (%s) on %s", + dc->dc_name, dc->dc_unit, + devtypes[dc->dc_devtype], dc->dc_parent); + } + break; + } + fputc('\n', stdout); +} + +static void +print_isa(struct devconf *dc) +{ + struct isa_device *id = (struct isa_device *)dc->dc_data; + + printf("%s%d on %s", dc->dc_name, dc->dc_unit, dc->dc_parent); + + if(vflag) { + printf(" (id %d)", id->id_id); + } + + if(id->id_iobase) { + if(id->id_iobase < 0) { + printf(" port ?"); + } else { + printf(" port 0x%x", id->id_iobase); + } + } + + if(id->id_irq) { + int bit = ffs(id->id_irq) - 1; + + if(id->id_irq & ~(1 << bit)) { + printf(" irq ?"); + } else { + printf(" irq %d", bit); + } + } + + if(id->id_drq) { + if(id->id_drq < 0) { + printf(" drq ?"); + } else { + printf(" drq %d", id->id_drq); + } + } + + if(id->id_maddr) { + if((unsigned long)id->id_maddr == ~0UL) { + printf(" iomem ?"); + } else { + printf(" iomem 0x%lx", (unsigned long)id->id_maddr); + } + } + + if(id->id_msize) { + if(id->id_msize < 0) { + printf(" iosiz ?", id->id_msize); + } else { + printf(" iosiz %d", id->id_msize); + } + } + + if(id->id_flags) { + printf(" flags 0x%x", id->id_flags); + } +} + +static void +print_eisa(struct devconf *dc) +{ + int *slotp = (int *)&dc->dc_data[ISA_EXTERNALLEN]; + print_isa(dc); + if(vflag) { + printf(" (slot %d)", *slotp); + } +} + +static void +print_pci(struct devconf *dc) +{ + struct pci_device *pd = (struct pci_device *)dc->dc_data; + + /* + * Unfortunately, the `pci_device' struct is completely + * useless. We will have to develop a unique structure + * for this task eventually, unless the existing one can + * be made to serve. + */ + + printf("%s%d on %s", dc->dc_name, dc->dc_unit, dc->dc_parent); +} + +static void +print_scsi(struct devconf *dc) +{ + struct scsi_link *sl = (struct scsi_link *)dc->dc_data; + + printf("%s%d on SCSI bus %d:%d:%d", + dc->dc_name, dc->dc_unit, sl->scsibus, sl->target, + sl->lun); + if(vflag) { + if(sl->flags & SDEV_MEDIA_LOADED) + printf(" (ready)"); + if(sl->flags & SDEV_OPEN) + printf(" (open)"); + if(sl->flags & SDEV_BOUNCE) + printf(" (bounce)"); + } +} + +static void +print_disk(struct devconf *dc) +{ + int *slavep = (int *)dc->dc_data; + + printf("%s%d on %s drive %d", + dc->dc_name, dc->dc_unit, dc->dc_parent, *slavep); +} + Property changes on: cvs2svn/tags/initial/usr.sbin/lsdev/i386.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/usr.sbin/lsdev/lsdev.8 =================================================================== --- cvs2svn/tags/initial/usr.sbin/lsdev/lsdev.8 (nonexistent) +++ cvs2svn/tags/initial/usr.sbin/lsdev/lsdev.8 (revision 49189) @@ -0,0 +1,61 @@ +.\" $Id: lsvfs.1,v 1.1 1994/09/22 01:25:56 wollman Exp $ +.\" Garrett A. Wollman, October 1994 +.\" This file is in the public domain. +.\" +.Dd October 17, 1994 +.Dt LSDEV 1 +.Os +.Sh NAME +.Nm lsdev +.Nd list configured devices +.Sh SYNOPSIS +.Nm lsdev +.Op Fl t Ar type +.Op Fl v +.Op Ar class Ns Op unit +.Sh DESCRIPTION +The +.Nm lsdev +utility lists devices configured in the current system, in a +machine-dependent manner. The +.Fl t +flag can be used to restrict the listing to a specific +.Ar type +of device; +the types available vary from machine to machine. (Specifying an +invalid type will cause a list of valid types to be printed.) The +.Fl v +flag requests more verbose output. The optional +.Ar class +argument requests information on a particular class of devices (e.g., +.Dq Li wdc +or +.No Do Li ie Dc Ns ). +If no +.Ar unit +is specified, all units of the specified class will be listed. +.Pp +The +.Xr sysctl 3 +mechanism is used to retrieve information from the kernel about which +devices are configured. +.Sh FILES +.Bl -tag -width +.It Aq sys/devconf.h +defines the structure examined by +.Nm +.It Aq machine/devconf.h +defines the machine-dependent parts of the structure, including the +supported device type names +.El +.Sh SEE ALSO +.\" .Xr chdev 8 +.Xr sysctl 3 +.Sh BUGS +Not all devices have the proper support implmented yet. +.Sh HISTORY +An +.Nm +comand appeared in +.Tn FreeBSD +2.0. Property changes on: cvs2svn/tags/initial/usr.sbin/lsdev/lsdev.8 ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/usr.sbin/lsdev/lsdev.c =================================================================== --- cvs2svn/tags/initial/usr.sbin/lsdev/lsdev.c (nonexistent) +++ cvs2svn/tags/initial/usr.sbin/lsdev/lsdev.c (revision 49189) @@ -0,0 +1,155 @@ +#include "lsdev.h" +#include +#include +#include +#include +#include + +const char *const devtypes[] = DEVTYPENAMES; +int vflag = 0; +const char *whoami; + +static void usage(void); +static void badtype(const char *); +static void badname(const char *); + +int +main(int argc, char **argv) +{ + struct devconf *dc = 0; + size_t size, osize; + int ndevs, i; + int mib[8]; + int c; + int showonlytype = -1; + int showonlydev = 0; + char showonlydevclass[MAXDEVNAME]; + int showonlydevunit = -1; + + whoami = argv[0]; + + while((c = getopt(argc, argv, "t:v")) != EOF) { + switch(c) { + case 't': + showonlytype = findtype(optarg); + if(showonlytype < 0) + badtype(optarg); + break; + case 'v': + vflag++; + break; + default: + usage(); + break; + } + } + + if(argc - optind > 1) { + usage(); + } + + if(argv[optind]) { + char *s = &argv[optind][strlen(argv[optind])]; + + if(s - argv[optind] > MAXDEVNAME) + badname(argv[optind]); + s--; /* step over null */ + while(s > argv[optind] && isdigit(*s)) + s--; + s++; + if(*s) { + showonlydevunit = atoi(s); + *s = '\0'; + } else { + showonlydevunit = -1; + } + + strcpy(showonlydevclass, argv[optind]); + showonlydev = 1; + } + + mib[0] = CTL_HW; + mib[1] = HW_DEVCONF; + mib[2] = DEVCONF_NUMBER; + + size = sizeof ndevs; + if(sysctl(mib, 3, &ndevs, &size, 0, 0) < 0) { + err(1, "sysctl(hw.devconf.number)"); + } + osize = 0; + + for(i = 1; i <= ndevs; i++) { + mib[2] = i; + if(sysctl(mib, 3, 0, &size, 0, 0) < 0) { + /* + * Probably a deleted device; just go on to the next + * one. + */ + continue; + } + if(size > osize) { + dc = realloc(dc, size); + if(!dc) { + err(2, "realloc(%lu)", (unsigned long)size); + } + } + if(sysctl(mib, 3, dc, &size, 0, 0) < 0) { + err(1, "sysctl(hw.devconf.%d)", i); + } + if(!showonlydev && showonlytype < 0) { + print(dc); + } else if(showonlydev) { + if(!strcmp(showonlydevclass, dc->dc_name) + && (showonlydevunit < 0 || + showonlydevunit == dc->dc_unit)) + print(dc); + } else if(showonlytype == dc->dc_devtype) { + print(dc); + } + osize = size; + } + return 0; +} + +static void +usage(void) +{ + fprintf(stderr, + "usage:\n" + "\t%s [-t type] [-v] [name]\n", + whoami); + exit(-1); +} + +int +findtype(const char *name) +{ + int i; + for(i = 0; devtypes[i]; i++) { + if(!strcmp(name, devtypes[i])) + return i; + } + return -1; +} + +static void +badtype(const char *name) +{ + int i; + + fprintf(stderr, + "%s: invalid device type `%s'\n", whoami, name); + fprintf(stderr, + "%s: valid types are: ", whoami); + for(i = 0; devtypes[i]; i++) { + fprintf(stderr, "%s`%s'", i ? ", " : "", devtypes[i]); + } + fputs(".\n", stderr); + exit(-1); +} + +static void +badname(const char *name) +{ + errx(3, "invalid device name `%s'", name); +} Property changes on: cvs2svn/tags/initial/usr.sbin/lsdev/lsdev.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/usr.sbin/lsdev/lsdev.h =================================================================== --- cvs2svn/tags/initial/usr.sbin/lsdev/lsdev.h (nonexistent) +++ cvs2svn/tags/initial/usr.sbin/lsdev/lsdev.h (revision 49189) @@ -0,0 +1,16 @@ +/* + * Declarations for lsdev(8). + */ +#include +#include +#include +#include +#include +#include +#include + +extern const char *const devtypes[]; /* device type array */ +extern void print(struct devconf *); /* machine-specific print routine */ +extern int vflag; + +extern int findtype(const char *); /* get device type by name */ Property changes on: cvs2svn/tags/initial/usr.sbin/lsdev/lsdev.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/Makefile =================================================================== --- cvs2svn/tags/initial/lib/libstand/Makefile (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/Makefile (revision 49189) @@ -0,0 +1,116 @@ +# $Id$ +# +# Originally from $NetBSD: Makefile,v 1.21 1997/10/26 22:08:38 lukem Exp $ +# +# Notes: +# - We don't use the libc strerror/sys_errlist because the string table is +# quite large. +# + +LIB= stand +NOPROFILE= YES +NOPIC= YES + +# Mostly OK, some of the libc imports are a bit noisy +CFLAGS+= -Wall + +# i386 apps are loaded by an a.out only loader +.if ${MACHINE_ARCH} == "i386" +OBJFORMAT= aout +.endif + +.if ${MACHINE_ARCH} == "alpha" +CFLAGS+= -mno-fp-regs +.endif + +# standalone components and stuff we have modified locally +SRCS+= __main.c alloc.c bcd.c bswap.c environment.c getopt.c gets.c \ + globals.c pager.c printf.c strdup.c strerror.c strtol.c random.c \ + twiddle.c + +# string functions from libc +.PATH: ${.CURDIR}/../libc/string +.if ${MACHINE_ARCH} == "i386" +SRCS+= bcmp.c bcopy.c bzero.c ffs.c index.c memccpy.c memchr.c memcmp.c \ + memcpy.c memmove.c memset.c rindex.c strcasecmp.c strcat.c strchr.c \ + strcmp.c strcpy.c strcspn.c strlen.c strncat.c strncmp.c strncpy.c \ + strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c +.endif +.if ${MACHINE_ARCH} == "alpha" +.PATH: ${.CURDIR}/../libc/alpha/string +SRCS+= bcmp.c bcopy.S bzero.S ffs.S index.c memccpy.c memchr.c memcmp.c \ + memcpy.S memmove.S memset.c rindex.c strcasecmp.c strcat.c strchr.c \ + strcmp.c strcpy.c strcspn.c strlen.c \ + strncat.c strncmp.c strncpy.c strpbrk.c strrchr.c strsep.c \ + strspn.c strstr.c strtok.c swab.c + +.PATH: ${.CURDIR}/../libc/alpha/net +SRCS+= htons.S ntohs.S htonl.S ntohl.S + +SRCS+= __divqu.S __divq.S __divlu.S __divl.S +SRCS+= __remqu.S __remq.S __remlu.S __reml.S + +CLEANFILES+= __divqu.S __divq.S __divlu.S __divl.S +CLEANFILES+= __remqu.S __remq.S __remlu.S __reml.S + + +__divqu.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4 + m4 -DNAME=__divqu -DOP=div -DS=false -DWORDSIZE=64 \ + ${.ALLSRC} > ${.TARGET} + +__divq.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4 + m4 -DNAME=__divq -DOP=div -DS=true -DWORDSIZE=64 \ + ${.ALLSRC} > ${.TARGET} + +__divlu.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4 + m4 -DNAME=__divlu -DOP=div -DS=false -DWORDSIZE=32 \ + ${.ALLSRC} > ${.TARGET} + +__divl.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4 + m4 -DNAME=__divl -DOP=div -DS=true -DWORDSIZE=32 \ + ${.ALLSRC} > ${.TARGET} + +__remqu.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4 + m4 -DNAME=__remqu -DOP=rem -DS=false -DWORDSIZE=64 \ + ${.ALLSRC} > ${.TARGET} + +__remq.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4 + m4 -DNAME=__remq -DOP=rem -DS=true -DWORDSIZE=64 \ + ${.ALLSRC} > ${.TARGET} + +__remlu.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4 + m4 -DNAME=__remlu -DOP=rem -DS=false -DWORDSIZE=32 \ + ${.ALLSRC} > ${.TARGET} + +__reml.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4 + m4 -DNAME=__reml -DOP=rem -DS=true -DWORDSIZE=32 \ + ${.ALLSRC} > ${.TARGET} +.endif + +# network support from libc +.PATH: ${.CURDIR}/../libc/net +SRCS+= inet_ntoa.c inet_addr.c + +# decompression functionality from libz +.PATH: ${.CURDIR}/../libz +CFLAGS+=-DHAVE_MEMCPY +SRCS+= adler32.c crc32.c infblock.c infcodes.c inffast.c inflate.c \ + inftrees.c infutil.c zutil.c + +# io routines +SRCS+= closeall.c dev.c ioctl.c nullfs.c stat.c \ + fstat.c close.c lseek.c open.c read.c write.c + +# network routines +SRCS+= arp.c ether.c in_cksum.c net.c netif.c rpc.c + +# network info services: +SRCS+= bootp.c rarp.c bootparam.c + +# boot filesystems +SRCS+= ufs.c nfs.c cd9660.c tftp.c zipfs.c +SRCS+= netif.c nfs.c +# needs "open directory" support +#SRCS+= dosfs.c + +.include Property changes on: cvs2svn/tags/initial/lib/libstand/Makefile ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/__main.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/__main.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/__main.c (revision 49189) @@ -0,0 +1,40 @@ +/* $NetBSD: __main.c,v 1.4 1996/03/14 18:52:03 christos Exp $ */ + +/* + * Copyright (c) 1993 Christopher G. Demetriou + * 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 by Christopher G. Demetriou. + * 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. + */ + +#include + +void __main(void); + +void +__main() +{ +} Property changes on: cvs2svn/tags/initial/lib/libstand/__main.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/alloc.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/alloc.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/alloc.c (revision 49189) @@ -0,0 +1,244 @@ +/* $NetBSD: alloc.c,v 1.11 1997/09/17 16:24:00 drochner Exp $ */ + +/* + * Copyright (c) 1997 Christopher G. Demetriou. All rights reserved. + * Copyright (c) 1996 + * Matthias Drochner. All rights reserved. + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * The Mach Operating System project at Carnegie-Mellon University. + * + * 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)alloc.c 8.1 (Berkeley) 6/11/93 + * + * + * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University + * All Rights Reserved. + * + * Author: Alessandro Forin + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +/* + * Dynamic memory allocator. + * + * Compile options: + * + * ALLOC_TRACE enable tracing of allocations/deallocations + + * ALLOC_FIRST_FIT use a first-fit allocation algorithm, rather than + * the default best-fit algorithm. + * + * HEAP_LIMIT heap limit address (defaults to "no limit"). + * + * HEAP_START start address of heap (defaults to '&end'). + * + * DEBUG enable debugging sanity checks. + */ + +#include +#include "stand.h" + +/* Default to variable heap operation */ +#define HEAP_VARIABLE +#define DEBUG + +/* + * Each block actually has ALIGN(size_t) + ALIGN(size) bytes allocated + * to it, as follows: + * + * 0 ... (sizeof(size_t) - 1) + * allocated or unallocated: holds size of user-data part of block. + * + * sizeof(size_t) ... (ALIGN(sizeof(size_t)) - 1) + * allocated: unused + * unallocated: depends on packing of struct fl + * + * ALIGN(sizeof(size_t)) ... (ALIGN(sizeof(size_t)) + ALIGN(data size) - 1) + * allocated: user data + * unallocated: depends on packing of struct fl + * + * 'next' is only used when the block is unallocated (i.e. on the free list). + * However, note that ALIGN(sizeof(size_t)) + ALIGN(data size) must + * be at least 'sizeof(struct fl)', so that blocks can be used as structures + * when on the free list. + */ +struct fl { + size_t size; + struct fl *next; +} *freelist = (struct fl *)0; + +#ifdef HEAP_VARIABLE +static char *top, *heapstart, *heaplimit; +void setheap(start, limit) +void *start, *limit; +{ + heapstart = top = start; + heaplimit = limit; +} +#define HEAP_START heapstart +#define HEAP_LIMIT heaplimit +#else /* !HEAP_VARIABLE */ +#ifndef HEAP_START +extern char end[]; +#define HEAP_START end +#endif +static char *top = (char*)HEAP_START; +#endif /* HEAP_VARIABLE */ + +void * +malloc(size) + size_t size; +{ + register struct fl **f = &freelist, **bestf = NULL; + size_t bestsize = 0xffffffff; /* greater than any real size */ + char *help; + int failed; + +#ifdef ALLOC_TRACE + printf("alloc(%u)", size); +#endif + +#ifdef ALLOC_FIRST_FIT + while (*f != (struct fl *)0 && (*f)->size < size) + f = &((*f)->next); + bestf = f; + failed = (*bestf == (struct fl *)0); +#else + /* scan freelist */ + while (*f) { + if ((*f)->size >= size) { + if ((*f)->size == size) /* exact match */ + goto found; + + if ((*f)->size < bestsize) { + /* keep best fit */ + bestf = f; + bestsize = (*f)->size; + } + } + f = &((*f)->next); + } + + /* no match in freelist if bestsize unchanged */ + failed = (bestsize == 0xffffffff); +#endif + + if (failed) { /* nothing found */ + /* + * allocate from heap, keep chunk len in + * first word + */ + help = top; + + /* make _sure_ the region can hold a struct fl. */ + if (size < ALIGN(sizeof (struct fl *))) + size = ALIGN(sizeof (struct fl *)); + top += ALIGN(sizeof(size_t)) + ALIGN(size); +#ifdef HEAP_LIMIT + if (top > (char*)HEAP_LIMIT) + panic("heap full (0x%lx+%u)", help, size); +#endif + *(size_t *)help = ALIGN(size); +#ifdef ALLOC_TRACE + printf("=%lx\n", (u_long)help + ALIGN(sizeof(size_t))); + getchar(); +#endif + return(help + ALIGN(sizeof(size_t))); + } + + /* we take the best fit */ + f = bestf; + +found: + /* remove from freelist */ + help = (char*)*f; + *f = (*f)->next; +#ifdef ALLOC_TRACE + printf("=%lx (origsize %u)\n", (u_long)help + ALIGN(sizeof(size_t)), + *(size_t *)help); + getchar(); +#endif + return(help + ALIGN(sizeof(size_t))); +} + +void +free(ptr) + void *ptr; +{ + register struct fl *f = + (struct fl *)((char*)ptr - ALIGN(sizeof(size_t))); +#ifdef ALLOC_TRACE + printf("free(%lx, %u) (origsize %u)\n", (u_long)ptr, size, f->size); + getchar(); +#endif +#ifdef DEBUG + if (ptr < (void *)HEAP_START) + printf("free: %lx before start of heap.\n", (u_long)ptr); + +#ifdef HEAP_LIMIT + if (ptr > (void *)HEAP_LIMIT) + printf("free: %lx beyond end of heap.\n", (u_long)ptr); +#endif +#endif /* DEBUG */ + /* put into freelist */ + f->next = freelist; + freelist = f; +} + +/* + * Emulate sbrk(0) behaviour + */ +char * +sbrk(int junk) +{ + return((char *)top); +} Property changes on: cvs2svn/tags/initial/lib/libstand/alloc.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/arp.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/arp.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/arp.c (revision 49189) @@ -0,0 +1,310 @@ +/* $NetBSD: arp.c,v 1.18 1997/07/07 15:52:49 drochner Exp $ */ + +/* + * Copyright (c) 1992 Regents of the University of California. + * All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * 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 by the University of + * California, Lawrence Berkeley Laboratory and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#) Header: arp.c,v 1.5 93/07/15 05:52:26 leres Exp (LBL) + */ + +#include +#include +#include +#include +#include + +#include + +#include + +#include "stand.h" +#include "net.h" + +/* Cache stuff */ +#define ARP_NUM 8 /* need at most 3 arp entries */ + +struct arp_list { + struct in_addr addr; + u_char ea[6]; +} arp_list[ARP_NUM] = { + /* XXX - net order `INADDR_BROADCAST' must be a constant */ + { {0xffffffff}, BA } +}; +int arp_num = 1; + +/* Local forwards */ +static ssize_t arpsend(struct iodesc *, void *, size_t); +static ssize_t arprecv(struct iodesc *, void *, size_t, time_t); + +/* Broadcast an ARP packet, asking who has addr on interface d */ +u_char * +arpwhohas(d, addr) + register struct iodesc *d; + struct in_addr addr; +{ + register int i; + register struct ether_arp *ah; + register struct arp_list *al; + struct { + struct ether_header eh; + struct { + struct ether_arp arp; + u_char pad[18]; /* 60 - sizeof(...) */ + } data; + } wbuf; + struct { + struct ether_header eh; + struct { + struct ether_arp arp; + u_char pad[24]; /* extra space */ + } data; + } rbuf; + + /* Try for cached answer first */ + for (i = 0, al = arp_list; i < arp_num; ++i, ++al) + if (addr.s_addr == al->addr.s_addr) + return (al->ea); + + /* Don't overflow cache */ + if (arp_num > ARP_NUM - 1) { + arp_num = 1; /* recycle */ + printf("arpwhohas: overflowed arp_list!\n"); + } + +#ifdef ARP_DEBUG + if (debug) + printf("arpwhohas: send request for %s\n", inet_ntoa(addr)); +#endif + + bzero((char*)&wbuf.data, sizeof(wbuf.data)); + ah = &wbuf.data.arp; + ah->arp_hrd = htons(ARPHRD_ETHER); + ah->arp_pro = htons(ETHERTYPE_IP); + ah->arp_hln = sizeof(ah->arp_sha); /* hardware address length */ + ah->arp_pln = sizeof(ah->arp_spa); /* protocol address length */ + ah->arp_op = htons(ARPOP_REQUEST); + MACPY(d->myea, ah->arp_sha); + bcopy(&d->myip, ah->arp_spa, sizeof(ah->arp_spa)); + /* Leave zeros in arp_tha */ + bcopy(&addr, ah->arp_tpa, sizeof(ah->arp_tpa)); + + /* Store ip address in cache (incomplete entry). */ + al->addr = addr; + + i = sendrecv(d, + arpsend, &wbuf.data, sizeof(wbuf.data), + arprecv, &rbuf.data, sizeof(rbuf.data)); + if (i == -1) { + panic("arp: no response for %s\n", + inet_ntoa(addr)); + } + + /* Store ethernet address in cache */ + ah = &rbuf.data.arp; +#ifdef ARP_DEBUG + if (debug) { + printf("arp: response from %s\n", + ether_sprintf(rbuf.eh.ether_shost)); + printf("arp: cacheing %s --> %s\n", + inet_ntoa(addr), ether_sprintf(ah->arp_sha)); + } +#endif + MACPY(ah->arp_sha, al->ea); + ++arp_num; + + return (al->ea); +} + +static ssize_t +arpsend(d, pkt, len) + register struct iodesc *d; + register void *pkt; + register size_t len; +{ + +#ifdef ARP_DEBUG + if (debug) + printf("arpsend: called\n"); +#endif + + return (sendether(d, pkt, len, bcea, ETHERTYPE_ARP)); +} + +/* + * Returns 0 if this is the packet we're waiting for + * else -1 (and errno == 0) + */ +static ssize_t +arprecv(d, pkt, len, tleft) + register struct iodesc *d; + register void *pkt; + register size_t len; + time_t tleft; +{ + register ssize_t n; + register struct ether_arp *ah; + u_int16_t etype; /* host order */ + +#ifdef ARP_DEBUG + if (debug) + printf("arprecv: "); +#endif + + n = readether(d, pkt, len, tleft, &etype); + errno = 0; /* XXX */ + if (n == -1 || n < sizeof(struct ether_arp)) { +#ifdef ARP_DEBUG + if (debug) + printf("bad len=%d\n", n); +#endif + return (-1); + } + + if (etype != ETHERTYPE_ARP) { +#ifdef ARP_DEBUG + if (debug) + printf("not arp type=%d\n", etype); +#endif + return (-1); + } + + /* Ethernet address now checked in readether() */ + + ah = (struct ether_arp *)pkt; + if (ah->arp_hrd != htons(ARPHRD_ETHER) || + ah->arp_pro != htons(ETHERTYPE_IP) || + ah->arp_hln != sizeof(ah->arp_sha) || + ah->arp_pln != sizeof(ah->arp_spa) ) + { +#ifdef ARP_DEBUG + if (debug) + printf("bad hrd/pro/hln/pln\n"); +#endif + return (-1); + } + + if (ah->arp_op == htons(ARPOP_REQUEST)) { +#ifdef ARP_DEBUG + if (debug) + printf("is request\n"); +#endif + arp_reply(d, ah); + return (-1); + } + + if (ah->arp_op != htons(ARPOP_REPLY)) { +#ifdef ARP_DEBUG + if (debug) + printf("not ARP reply\n"); +#endif + return (-1); + } + + /* Is the reply from the source we want? */ + if (bcmp(&arp_list[arp_num].addr, + ah->arp_spa, sizeof(ah->arp_spa))) + { +#ifdef ARP_DEBUG + if (debug) + printf("unwanted address\n"); +#endif + return (-1); + } + /* We don't care who the reply was sent to. */ + + /* We have our answer. */ +#ifdef ARP_DEBUG + if (debug) + printf("got it\n"); +#endif + return (n); +} + +/* + * Convert an ARP request into a reply and send it. + * Notes: Re-uses buffer. Pad to length = 46. + */ +void +arp_reply(d, pkt) + register struct iodesc *d; + register void *pkt; /* the request */ +{ + struct ether_arp *arp = pkt; + + if (arp->arp_hrd != htons(ARPHRD_ETHER) || + arp->arp_pro != htons(ETHERTYPE_IP) || + arp->arp_hln != sizeof(arp->arp_sha) || + arp->arp_pln != sizeof(arp->arp_spa) ) + { +#ifdef ARP_DEBUG + if (debug) + printf("arp_reply: bad hrd/pro/hln/pln\n"); +#endif + return; + } + + if (arp->arp_op != htons(ARPOP_REQUEST)) { +#ifdef ARP_DEBUG + if (debug) + printf("arp_reply: not request!\n"); +#endif + return; + } + + /* If we are not the target, ignore the request. */ + if (bcmp(arp->arp_tpa, &d->myip, sizeof(arp->arp_tpa))) + return; + +#ifdef ARP_DEBUG + if (debug) { + printf("arp_reply: to %s\n", ether_sprintf(arp->arp_sha)); + } +#endif + + arp->arp_op = htons(ARPOP_REPLY); + /* source becomes target */ + bcopy(arp->arp_sha, arp->arp_tha, sizeof(arp->arp_tha)); + bcopy(arp->arp_spa, arp->arp_tpa, sizeof(arp->arp_tpa)); + /* here becomes source */ + bcopy(d->myea, arp->arp_sha, sizeof(arp->arp_sha)); + bcopy(&d->myip, arp->arp_spa, sizeof(arp->arp_spa)); + + /* + * No need to get fancy here. If the send fails, the + * requestor will just ask again. + */ + (void) sendether(d, pkt, sizeof(*arp) + 18, + arp->arp_tha, ETHERTYPE_ARP); +} Property changes on: cvs2svn/tags/initial/lib/libstand/arp.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/bcd.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/bcd.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/bcd.c (revision 49189) @@ -0,0 +1,35 @@ +/* + * Some data-tables that are often used. + * Cannot be copyrighted. + */ + +#include + +u_char const bcd2bin_data[] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 0, 0, 0, 0, 0, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 0, 0, 0, 0, 0, 0, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 0, 0, 0, 0, 0, 0, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0, 0, 0, 0, 0, 0, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 0, 0, 0, 0, 0, 0, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 0, 0, 0, 0, 0, 0, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 0, 0, 0, 0, 0, 0, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 0, 0, 0, 0, 0, 0, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 +}; + +u_char const bin2bcd_data[] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99 +}; + +/* This is actually used with radix [2..36] */ +char const hex2ascii_data[] = "0123456789abcdefghijklmnopqrstuvwxyz"; Property changes on: cvs2svn/tags/initial/lib/libstand/bcd.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/bootp.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/bootp.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/bootp.c (revision 49189) @@ -0,0 +1,396 @@ +/* $NetBSD: bootp.c,v 1.14 1998/02/16 11:10:54 drochner Exp $ */ + +/* + * Copyright (c) 1992 Regents of the University of California. + * All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * 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 by the University of + * California, Lawrence Berkeley Laboratory and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#) Header: bootp.c,v 1.4 93/09/11 03:13:51 leres Exp (LBL) + */ + +#include +#include +#include + +#include + +#define BOOTP_DEBUGxx +#define SUPPORT_DHCP + +#include "stand.h" +#include "net.h" +#include "netif.h" +#include "bootp.h" + + +struct in_addr servip; + +static n_long nmask, smask; + +static time_t bot; + +static char vm_rfc1048[4] = VM_RFC1048; +#ifdef BOOTP_VEND_CMU +static char vm_cmu[4] = VM_CMU; +#endif + +/* Local forwards */ +static ssize_t bootpsend(struct iodesc *, void *, size_t); +static ssize_t bootprecv(struct iodesc *, void *, size_t, time_t); +static int vend_rfc1048(u_char *, u_int); +#ifdef BOOTP_VEND_CMU +static void vend_cmu(u_char *); +#endif + +#ifdef SUPPORT_DHCP +static char expected_dhcpmsgtype = -1, dhcp_ok; +struct in_addr dhcp_serverip; +#endif + +/* Fetch required bootp infomation */ +void +bootp(sock) + int sock; +{ + struct iodesc *d; + register struct bootp *bp; + struct { + u_char header[HEADER_SIZE]; + struct bootp wbootp; + } wbuf; + struct { + u_char header[HEADER_SIZE]; + struct bootp rbootp; + } rbuf; + +#ifdef BOOTP_DEBUG + if (debug) + printf("bootp: socket=%d\n", sock); +#endif + if (!bot) + bot = getsecs(); + + if (!(d = socktodesc(sock))) { + printf("bootp: bad socket. %d\n", sock); + return; + } +#ifdef BOOTP_DEBUG + if (debug) + printf("bootp: d=%lx\n", (long)d); +#endif + + bp = &wbuf.wbootp; + bzero(bp, sizeof(*bp)); + + bp->bp_op = BOOTREQUEST; + bp->bp_htype = 1; /* 10Mb Ethernet (48 bits) */ + bp->bp_hlen = 6; + bp->bp_xid = htonl(d->xid); + MACPY(d->myea, bp->bp_chaddr); + strncpy(bp->bp_file, bootfile, sizeof(bp->bp_file)); + bcopy(vm_rfc1048, bp->bp_vend, sizeof(vm_rfc1048)); +#ifdef SUPPORT_DHCP + bp->bp_vend[4] = TAG_DHCP_MSGTYPE; + bp->bp_vend[5] = 1; + bp->bp_vend[6] = DHCPDISCOVER; + bp->bp_vend[7] = TAG_END; +#else + bp->bp_vend[4] = TAG_END; +#endif + + d->myip.s_addr = INADDR_ANY; + d->myport = htons(IPPORT_BOOTPC); + d->destip.s_addr = INADDR_BROADCAST; + d->destport = htons(IPPORT_BOOTPS); + +#ifdef SUPPORT_DHCP + expected_dhcpmsgtype = DHCPOFFER; + dhcp_ok = 0; +#endif + + if(sendrecv(d, + bootpsend, bp, sizeof(*bp), + bootprecv, &rbuf.rbootp, sizeof(rbuf.rbootp)) + == -1) { + printf("bootp: no reply\n"); + return; + } + +#ifdef SUPPORT_DHCP + if(dhcp_ok) { + u_int32_t leasetime; + bp->bp_vend[6] = DHCPREQUEST; + bp->bp_vend[7] = TAG_REQ_ADDR; + bp->bp_vend[8] = 4; + bcopy(&rbuf.rbootp.bp_yiaddr, &bp->bp_vend[9], 4); + bp->bp_vend[13] = TAG_SERVERID; + bp->bp_vend[14] = 4; + bcopy(&dhcp_serverip.s_addr, &bp->bp_vend[15], 4); + bp->bp_vend[19] = TAG_LEASETIME; + bp->bp_vend[20] = 4; + leasetime = htonl(300); + bcopy(&leasetime, &bp->bp_vend[21], 4); + bp->bp_vend[25] = TAG_END; + + expected_dhcpmsgtype = DHCPACK; + + if(sendrecv(d, + bootpsend, bp, sizeof(*bp), + bootprecv, &rbuf.rbootp, sizeof(rbuf.rbootp)) + == -1) { + printf("DHCPREQUEST failed\n"); + return; + } + } +#endif + + myip = d->myip = rbuf.rbootp.bp_yiaddr; + servip = rbuf.rbootp.bp_siaddr; + if(rootip.s_addr == INADDR_ANY) rootip = servip; + bcopy(rbuf.rbootp.bp_file, bootfile, sizeof(bootfile)); + bootfile[sizeof(bootfile) - 1] = '\0'; + + if (IN_CLASSA(myip.s_addr)) + nmask = htonl(IN_CLASSA_NET); + else if (IN_CLASSB(myip.s_addr)) + nmask = htonl(IN_CLASSB_NET); + else + nmask = htonl(IN_CLASSC_NET); +#ifdef BOOTP_DEBUG + if (debug) + printf("'native netmask' is %s\n", intoa(nmask)); +#endif + + /* Check subnet mask against net mask; toss if bogus */ + if ((nmask & smask) != nmask) { +#ifdef BOOTP_DEBUG + if (debug) + printf("subnet mask (%s) bad\n", intoa(smask)); +#endif + smask = 0; + } + + /* Get subnet (or natural net) mask */ + netmask = nmask; + if (smask) + netmask = smask; +#ifdef BOOTP_DEBUG + if (debug) + printf("mask: %s\n", intoa(netmask)); +#endif + + /* We need a gateway if root is on a different net */ + if (!SAMENET(myip, rootip, netmask)) { +#ifdef BOOTP_DEBUG + if (debug) + printf("need gateway for root ip\n"); +#endif + } + + /* Toss gateway if on a different net */ + if (!SAMENET(myip, gateip, netmask)) { +#ifdef BOOTP_DEBUG + if (debug) + printf("gateway ip (%s) bad\n", inet_ntoa(gateip)); +#endif + gateip.s_addr = 0; + } + + /* Bump xid so next request will be unique. */ + ++d->xid; +} + +/* Transmit a bootp request */ +static ssize_t +bootpsend(d, pkt, len) + register struct iodesc *d; + register void *pkt; + register size_t len; +{ + register struct bootp *bp; + +#ifdef BOOTP_DEBUG + if (debug) + printf("bootpsend: d=%lx called.\n", (long)d); +#endif + + bp = pkt; + bp->bp_secs = htons((u_short)(getsecs() - bot)); + +#ifdef BOOTP_DEBUG + if (debug) + printf("bootpsend: calling sendudp\n"); +#endif + + return (sendudp(d, pkt, len)); +} + +static ssize_t +bootprecv(d, pkt, len, tleft) +register struct iodesc *d; +register void *pkt; +register size_t len; +time_t tleft; +{ + register ssize_t n; + register struct bootp *bp; + +#ifdef BOOTP_DEBUGx + if (debug) + printf("bootp_recvoffer: called\n"); +#endif + + n = readudp(d, pkt, len, tleft); + if (n == -1 || n < sizeof(struct bootp) - BOOTP_VENDSIZE) + goto bad; + + bp = (struct bootp *)pkt; + +#ifdef BOOTP_DEBUG + if (debug) + printf("bootprecv: checked. bp = 0x%lx, n = %d\n", + (long)bp, (int)n); +#endif + if (bp->bp_xid != htonl(d->xid)) { +#ifdef BOOTP_DEBUG + if (debug) { + printf("bootprecv: expected xid 0x%lx, got 0x%x\n", + d->xid, ntohl(bp->bp_xid)); + } +#endif + goto bad; + } + +#ifdef BOOTP_DEBUG + if (debug) + printf("bootprecv: got one!\n"); +#endif + + /* Suck out vendor info */ + if (bcmp(vm_rfc1048, bp->bp_vend, sizeof(vm_rfc1048)) == 0) { + if(vend_rfc1048(bp->bp_vend, sizeof(bp->bp_vend)) != 0) + goto bad; + } +#ifdef BOOTP_VEND_CMU + else if (bcmp(vm_cmu, bp->bp_vend, sizeof(vm_cmu)) == 0) + vend_cmu(bp->bp_vend); +#endif + else + printf("bootprecv: unknown vendor 0x%lx\n", (long)bp->bp_vend); + + return(n); +bad: + errno = 0; + return (-1); +} + +static int +vend_rfc1048(cp, len) + register u_char *cp; + u_int len; +{ + register u_char *ep; + register int size; + register u_char tag; + +#ifdef BOOTP_DEBUG + if (debug) + printf("vend_rfc1048 bootp info. len=%d\n", len); +#endif + ep = cp + len; + + /* Step over magic cookie */ + cp += sizeof(int); + + while (cp < ep) { + tag = *cp++; + size = *cp++; + if (tag == TAG_END) + break; + + if (tag == TAG_SUBNET_MASK) { + bcopy(cp, &smask, sizeof(smask)); + } + if (tag == TAG_GATEWAY) { + bcopy(cp, &gateip.s_addr, sizeof(gateip.s_addr)); + } + if (tag == TAG_SWAPSERVER) { + /* let it override bp_siaddr */ + bcopy(cp, &rootip.s_addr, sizeof(swapip.s_addr)); + } + if (tag == TAG_ROOTPATH) { + strncpy(rootpath, (char *)cp, sizeof(rootpath)); + rootpath[size] = '\0'; + } + if (tag == TAG_HOSTNAME) { + strncpy(hostname, (char *)cp, sizeof(hostname)); + hostname[size] = '\0'; + } +#ifdef SUPPORT_DHCP + if (tag == TAG_DHCP_MSGTYPE) { + if(*cp != expected_dhcpmsgtype) + return(-1); + dhcp_ok = 1; + } + if (tag == TAG_SERVERID) { + bcopy(cp, &dhcp_serverip.s_addr, + sizeof(dhcp_serverip.s_addr)); + } +#endif + cp += size; + } + return(0); +} + +#ifdef BOOTP_VEND_CMU +static void +vend_cmu(cp) + u_char *cp; +{ + register struct cmu_vend *vp; + +#ifdef BOOTP_DEBUG + if (debug) + printf("vend_cmu bootp info.\n"); +#endif + vp = (struct cmu_vend *)cp; + + if (vp->v_smask.s_addr != 0) { + smask = vp->v_smask.s_addr; + } + if (vp->v_dgate.s_addr != 0) { + gateip = vp->v_dgate; + } +} +#endif Property changes on: cvs2svn/tags/initial/lib/libstand/bootp.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/bootp.h =================================================================== --- cvs2svn/tags/initial/lib/libstand/bootp.h (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/bootp.h (revision 49189) @@ -0,0 +1,137 @@ +/* $NetBSD: bootp.h,v 1.4 1997/09/06 13:55:57 drochner Exp $ */ + +/* + * Bootstrap Protocol (BOOTP). RFC951 and RFC1048. + * + * This file specifies the "implementation-independent" BOOTP protocol + * information which is common to both client and server. + * + * Copyright 1988 by Carnegie Mellon. + * + * Permission to use, copy, modify, and distribute this program for any + * purpose and without fee is hereby granted, provided that this copyright + * and permission notice appear on all copies and supporting documentation, + * the name of Carnegie Mellon not be used in advertising or publicity + * pertaining to distribution of the program without specific prior + * permission, and notice be given in supporting documentation that copying + * and distribution is by permission of Carnegie Mellon and Stanford + * University. Carnegie Mellon makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + */ + + +struct bootp { + unsigned char bp_op; /* packet opcode type */ + unsigned char bp_htype; /* hardware addr type */ + unsigned char bp_hlen; /* hardware addr length */ + unsigned char bp_hops; /* gateway hops */ + unsigned int bp_xid; /* transaction ID */ + unsigned short bp_secs; /* seconds since boot began */ + unsigned short bp_flags; + struct in_addr bp_ciaddr; /* client IP address */ + struct in_addr bp_yiaddr; /* 'your' IP address */ + struct in_addr bp_siaddr; /* server IP address */ + struct in_addr bp_giaddr; /* gateway IP address */ + unsigned char bp_chaddr[16]; /* client hardware address */ + unsigned char bp_sname[64]; /* server host name */ + unsigned char bp_file[128]; /* boot file name */ +#ifdef SUPPORT_DHCP +#define BOOTP_VENDSIZE 312 +#else +#define BOOTP_VENDSIZE 64 +#endif + unsigned char bp_vend[BOOTP_VENDSIZE]; /* vendor-specific area */ +}; + +/* + * UDP port numbers, server and client. + */ +#define IPPORT_BOOTPS 67 +#define IPPORT_BOOTPC 68 + +#define BOOTREPLY 2 +#define BOOTREQUEST 1 + + +/* + * Vendor magic cookie (v_magic) for CMU + */ +#define VM_CMU "CMU" + +/* + * Vendor magic cookie (v_magic) for RFC1048 + */ +#define VM_RFC1048 { 99, 130, 83, 99 } + + + +/* + * RFC1048 tag values used to specify what information is being supplied in + * the vendor field of the packet. + */ + +#define TAG_PAD ((unsigned char) 0) +#define TAG_SUBNET_MASK ((unsigned char) 1) +#define TAG_TIME_OFFSET ((unsigned char) 2) +#define TAG_GATEWAY ((unsigned char) 3) +#define TAG_TIME_SERVER ((unsigned char) 4) +#define TAG_NAME_SERVER ((unsigned char) 5) +#define TAG_DOMAIN_SERVER ((unsigned char) 6) +#define TAG_LOG_SERVER ((unsigned char) 7) +#define TAG_COOKIE_SERVER ((unsigned char) 8) +#define TAG_LPR_SERVER ((unsigned char) 9) +#define TAG_IMPRESS_SERVER ((unsigned char) 10) +#define TAG_RLP_SERVER ((unsigned char) 11) +#define TAG_HOSTNAME ((unsigned char) 12) +#define TAG_BOOTSIZE ((unsigned char) 13) +#define TAG_DUMPFILE ((unsigned char) 14) +#define TAG_DOMAINNAME ((unsigned char) 15) +#define TAG_SWAPSERVER ((unsigned char) 16) +#define TAG_ROOTPATH ((unsigned char) 17) + +#ifdef SUPPORT_DHCP +#define TAG_REQ_ADDR ((unsigned char) 50) +#define TAG_LEASETIME ((unsigned char) 51) +#define TAG_OVERLOAD ((unsigned char) 52) +#define TAG_DHCP_MSGTYPE ((unsigned char) 53) +#define TAG_SERVERID ((unsigned char) 54) +#define TAG_PARAM_REQ ((unsigned char) 55) +#define TAG_MSG ((unsigned char) 56) +#define TAG_MAXSIZE ((unsigned char) 57) +#define TAG_T1 ((unsigned char) 58) +#define TAG_T2 ((unsigned char) 59) +#define TAG_CLASSID ((unsigned char) 60) +#define TAG_CLIENTID ((unsigned char) 61) +#endif + +#define TAG_END ((unsigned char) 255) + +#ifdef SUPPORT_DHCP +#define DHCPDISCOVER 1 +#define DHCPOFFER 2 +#define DHCPREQUEST 3 +#define DHCPDECLINE 4 +#define DHCPACK 5 +#define DHCPNAK 6 +#define DHCPRELEASE 7 +#endif + +/* + * "vendor" data permitted for CMU bootp clients. + */ + +struct cmu_vend { + unsigned char v_magic[4]; /* magic number */ + unsigned int v_flags; /* flags/opcodes, etc. */ + struct in_addr v_smask; /* Subnet mask */ + struct in_addr v_dgate; /* Default gateway */ + struct in_addr v_dns1, v_dns2; /* Domain name servers */ + struct in_addr v_ins1, v_ins2; /* IEN-116 name servers */ + struct in_addr v_ts1, v_ts2; /* Time servers */ + unsigned char v_unused[25]; /* currently unused */ +}; + + +/* v_flags values */ +#define VF_SMASK 1 /* Subnet mask field contains valid data */ Property changes on: cvs2svn/tags/initial/lib/libstand/bootp.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/bootparam.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/bootparam.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/bootparam.c (revision 49189) @@ -0,0 +1,449 @@ +/* $NetBSD: bootparam.c,v 1.11 1997/06/26 19:11:32 drochner Exp $ */ + +/* + * Copyright (c) 1995 Gordon W. Ross + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * 4. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Gordon W. Ross + * + * 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. + */ + +/* + * RPC/bootparams + */ + +#include +#include + +#include + +#include +#include + +#include + +#include "rpcv2.h" + +#include "stand.h" +#include "net.h" +#include "netif.h" +#include "rpc.h" +#include "bootparam.h" + +#ifdef DEBUG_RPC +#define RPC_PRINTF(a) printf a +#else +#define RPC_PRINTF(a) +#endif + +struct in_addr bp_server_addr; /* net order */ +n_short bp_server_port; /* net order */ + +/* + * RPC definitions for bootparamd + */ +#define BOOTPARAM_PROG 100026 +#define BOOTPARAM_VERS 1 +#define BOOTPARAM_WHOAMI 1 +#define BOOTPARAM_GETFILE 2 + +/* + * Inet address in RPC messages + * (Note, really four ints, NOT chars. Blech.) + */ +struct xdr_inaddr { + u_int32_t atype; + int32_t addr[4]; +}; + +int xdr_inaddr_encode(char **p, struct in_addr ia); +int xdr_inaddr_decode(char **p, struct in_addr *ia); + +int xdr_string_encode(char **p, char *str, int len); +int xdr_string_decode(char **p, char *str, int *len_p); + + +/* + * RPC: bootparam/whoami + * Given client IP address, get: + * client name (hostname) + * domain name (domainname) + * gateway address + * + * The hostname and domainname are set here for convenience. + * + * Note - bpsin is initialized to the broadcast address, + * and will be replaced with the bootparam server address + * after this call is complete. Have to use PMAP_PROC_CALL + * to make sure we get responses only from a servers that + * know about us (don't want to broadcast a getport call). + */ +int +bp_whoami(sockfd) + int sockfd; +{ + /* RPC structures for PMAPPROC_CALLIT */ + struct args { + u_int32_t prog; + u_int32_t vers; + u_int32_t proc; + u_int32_t arglen; + struct xdr_inaddr xina; + } *args; + struct repl { + u_int16_t _pad; + u_int16_t port; + u_int32_t encap_len; + /* encapsulated data here */ + n_long capsule[64]; + } *repl; + struct { + n_long h[RPC_HEADER_WORDS]; + struct args d; + } sdata; + struct { + n_long h[RPC_HEADER_WORDS]; + struct repl d; + } rdata; + char *send_tail, *recv_head; + struct iodesc *d; + int len, x; + + RPC_PRINTF(("bp_whoami: myip=%s\n", inet_ntoa(myip))); + + if (!(d = socktodesc(sockfd))) { + RPC_PRINTF(("bp_whoami: bad socket. %d\n", sockfd)); + return (-1); + } + args = &sdata.d; + repl = &rdata.d; + + /* + * Build request args for PMAPPROC_CALLIT. + */ + args->prog = htonl(BOOTPARAM_PROG); + args->vers = htonl(BOOTPARAM_VERS); + args->proc = htonl(BOOTPARAM_WHOAMI); + args->arglen = htonl(sizeof(struct xdr_inaddr)); + send_tail = (char*) &args->xina; + + /* + * append encapsulated data (client IP address) + */ + if (xdr_inaddr_encode(&send_tail, myip)) + return (-1); + + /* RPC: portmap/callit */ + d->myport = htons(--rpc_port); + d->destip.s_addr = INADDR_BROADCAST; /* XXX: subnet bcast? */ + /* rpc_call will set d->destport */ + + len = rpc_call(d, PMAPPROG, PMAPVERS, PMAPPROC_CALLIT, + args, send_tail - (char*)args, + repl, sizeof(*repl)); + if (len < 8) { + printf("bootparamd: 'whoami' call failed\n"); + return (-1); + } + + /* Save bootparam server address (from IP header). */ + rpc_fromaddr(repl, &bp_server_addr, &bp_server_port); + + /* + * Note that bp_server_port is now 111 due to the + * indirect call (using PMAPPROC_CALLIT), so get the + * actual port number from the reply data. + */ + bp_server_port = repl->port; + + RPC_PRINTF(("bp_whoami: server at %s:%d\n", + inet_ntoa(bp_server_addr), ntohs(bp_server_port))); + + /* We have just done a portmap call, so cache the portnum. */ + rpc_pmap_putcache(bp_server_addr, + BOOTPARAM_PROG, + BOOTPARAM_VERS, + (int)ntohs(bp_server_port)); + + /* + * Parse the encapsulated results from bootparam/whoami + */ + x = ntohl(repl->encap_len); + if (len < x) { + printf("bp_whoami: short reply, %d < %d\n", len, x); + return (-1); + } + recv_head = (char*) repl->capsule; + + /* client name */ + hostnamelen = MAXHOSTNAMELEN-1; + if (xdr_string_decode(&recv_head, hostname, &hostnamelen)) { + RPC_PRINTF(("bp_whoami: bad hostname\n")); + return (-1); + } + + /* domain name */ + domainnamelen = MAXHOSTNAMELEN-1; + if (xdr_string_decode(&recv_head, domainname, &domainnamelen)) { + RPC_PRINTF(("bp_whoami: bad domainname\n")); + return (-1); + } + + /* gateway address */ + if (xdr_inaddr_decode(&recv_head, &gateip)) { + RPC_PRINTF(("bp_whoami: bad gateway\n")); + return (-1); + } + + /* success */ + return(0); +} + + +/* + * RPC: bootparam/getfile + * Given client name and file "key", get: + * server name + * server IP address + * server pathname + */ +int +bp_getfile(sockfd, key, serv_addr, pathname) + int sockfd; + char *key; + char *pathname; + struct in_addr *serv_addr; +{ + struct { + n_long h[RPC_HEADER_WORDS]; + n_long d[64]; + } sdata; + struct { + n_long h[RPC_HEADER_WORDS]; + n_long d[128]; + } rdata; + char serv_name[FNAME_SIZE]; + char *send_tail, *recv_head; + /* misc... */ + struct iodesc *d; + int sn_len, path_len, rlen; + + if (!(d = socktodesc(sockfd))) { + RPC_PRINTF(("bp_getfile: bad socket. %d\n", sockfd)); + return (-1); + } + + send_tail = (char*) sdata.d; + recv_head = (char*) rdata.d; + + /* + * Build request message. + */ + + /* client name (hostname) */ + if (xdr_string_encode(&send_tail, hostname, hostnamelen)) { + RPC_PRINTF(("bp_getfile: bad client\n")); + return (-1); + } + + /* key name (root or swap) */ + if (xdr_string_encode(&send_tail, key, strlen(key))) { + RPC_PRINTF(("bp_getfile: bad key\n")); + return (-1); + } + + /* RPC: bootparam/getfile */ + d->myport = htons(--rpc_port); + d->destip = bp_server_addr; + /* rpc_call will set d->destport */ + + rlen = rpc_call(d, + BOOTPARAM_PROG, BOOTPARAM_VERS, BOOTPARAM_GETFILE, + sdata.d, send_tail - (char*)sdata.d, + rdata.d, sizeof(rdata.d)); + if (rlen < 4) { + RPC_PRINTF(("bp_getfile: short reply\n")); + errno = EBADRPC; + return (-1); + } + recv_head = (char*) rdata.d; + + /* + * Parse result message. + */ + + /* server name */ + sn_len = FNAME_SIZE-1; + if (xdr_string_decode(&recv_head, serv_name, &sn_len)) { + RPC_PRINTF(("bp_getfile: bad server name\n")); + return (-1); + } + + /* server IP address (mountd/NFS) */ + if (xdr_inaddr_decode(&recv_head, serv_addr)) { + RPC_PRINTF(("bp_getfile: bad server addr\n")); + return (-1); + } + + /* server pathname */ + path_len = MAXPATHLEN-1; + if (xdr_string_decode(&recv_head, pathname, &path_len)) { + RPC_PRINTF(("bp_getfile: bad server path\n")); + return (-1); + } + + /* success */ + return(0); +} + + +/* + * eXternal Data Representation routines. + * (but with non-standard args...) + */ + + +int +xdr_string_encode(pkt, str, len) + char **pkt; + char *str; + int len; +{ + u_int32_t *lenp; + char *datap; + int padlen = (len + 3) & ~3; /* padded length */ + + /* The data will be int aligned. */ + lenp = (u_int32_t*) *pkt; + *pkt += sizeof(*lenp); + *lenp = htonl(len); + + datap = *pkt; + *pkt += padlen; + bcopy(str, datap, len); + + return (0); +} + +int +xdr_string_decode(pkt, str, len_p) + char **pkt; + char *str; + int *len_p; /* bufsize - 1 */ +{ + u_int32_t *lenp; + char *datap; + int slen; /* string length */ + int plen; /* padded length */ + + /* The data will be int aligned. */ + lenp = (u_int32_t*) *pkt; + *pkt += sizeof(*lenp); + slen = ntohl(*lenp); + plen = (slen + 3) & ~3; + + if (slen > *len_p) + slen = *len_p; + datap = *pkt; + *pkt += plen; + bcopy(datap, str, slen); + + str[slen] = '\0'; + *len_p = slen; + + return (0); +} + + +int +xdr_inaddr_encode(pkt, ia) + char **pkt; + struct in_addr ia; /* network order */ +{ + struct xdr_inaddr *xi; + u_char *cp; + int32_t *ip; + union { + n_long l; /* network order */ + u_char c[4]; + } uia; + + /* The data will be int aligned. */ + xi = (struct xdr_inaddr *) *pkt; + *pkt += sizeof(*xi); + xi->atype = htonl(1); + uia.l = ia.s_addr; + cp = uia.c; + ip = xi->addr; + /* + * Note: the htonl() calls below DO NOT + * imply that uia.l is in host order. + * In fact this needs it in net order. + */ + *ip++ = htonl((unsigned int)*cp++); + *ip++ = htonl((unsigned int)*cp++); + *ip++ = htonl((unsigned int)*cp++); + *ip++ = htonl((unsigned int)*cp++); + + return (0); +} + +int +xdr_inaddr_decode(pkt, ia) + char **pkt; + struct in_addr *ia; /* network order */ +{ + struct xdr_inaddr *xi; + u_char *cp; + int32_t *ip; + union { + n_long l; /* network order */ + u_char c[4]; + } uia; + + /* The data will be int aligned. */ + xi = (struct xdr_inaddr *) *pkt; + *pkt += sizeof(*xi); + if (xi->atype != htonl(1)) { + RPC_PRINTF(("xdr_inaddr_decode: bad addrtype=%d\n", + ntohl(xi->atype))); + return(-1); + } + + cp = uia.c; + ip = xi->addr; + /* + * Note: the ntohl() calls below DO NOT + * imply that uia.l is in host order. + * In fact this needs it in net order. + */ + *cp++ = ntohl(*ip++); + *cp++ = ntohl(*ip++); + *cp++ = ntohl(*ip++); + *cp++ = ntohl(*ip++); + ia->s_addr = uia.l; + + return (0); +} Property changes on: cvs2svn/tags/initial/lib/libstand/bootparam.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/bootparam.h =================================================================== --- cvs2svn/tags/initial/lib/libstand/bootparam.h (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/bootparam.h (revision 49189) @@ -0,0 +1,5 @@ +/* $NetBSD: bootparam.h,v 1.3 1998/01/05 19:19:41 perry Exp $ */ + +int bp_whoami(int sock); +int bp_getfile(int sock, char *key, struct in_addr *addrp, char *path); + Property changes on: cvs2svn/tags/initial/lib/libstand/bootparam.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/bswap.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/bswap.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/bswap.c (revision 49189) @@ -0,0 +1,37 @@ +/* + * Written by Manuel Bouyer . + * Public domain. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char *rcsid = "$NetBSD: bswap32.c,v 1.1 1997/10/09 15:42:33 bouyer Exp $"; +static char *rcsid = "$NetBSD: bswap64.c,v 1.1 1997/10/09 15:42:33 bouyer Exp $"; +#endif + +#include + +#undef bswap32 +#undef bswap64 + +u_int32_t +bswap32(x) + u_int32_t x; +{ + return ((x << 24) & 0xff000000 ) | + ((x << 8) & 0x00ff0000 ) | + ((x >> 8) & 0x0000ff00 ) | + ((x >> 24) & 0x000000ff ); +} + +u_int64_t +bswap64(x) + u_int64_t x; +{ + u_int32_t *p = (u_int32_t*)&x; + u_int32_t t; + t = bswap32(p[0]); + p[0] = bswap32(p[1]); + p[1] = t; + return x; +} + Property changes on: cvs2svn/tags/initial/lib/libstand/bswap.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/cd9660.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/cd9660.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/cd9660.c (revision 49189) @@ -0,0 +1,401 @@ +/* $NetBSD: cd9660.c,v 1.5 1997/06/26 19:11:33 drochner Exp $ */ + +/* + * Copyright (C) 1996 Wolfgang Solfrank. + * Copyright (C) 1996 TooLs GmbH. + * 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 by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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. + */ + +/* + * Stand-alone ISO9660 file reading package. + * + * Note: This doesn't support Rock Ridge extensions, extended attributes, + * blocksizes other than 2048 bytes, multi-extent files, etc. + */ +#include +#include +#include + +#include "stand.h" + +static int cd9660_open(char *path, struct open_file *f); +static int cd9660_close(struct open_file *f); +static int cd9660_read(struct open_file *f, void *buf, size_t size, size_t *resid); +static int cd9660_write(struct open_file *f, void *buf, size_t size, size_t *resid); +static off_t cd9660_seek(struct open_file *f, off_t offset, int where); +static int cd9660_stat(struct open_file *f, struct stat *sb); + +struct fs_ops cd9660_fsops = { + "cd9660", cd9660_open, cd9660_close, cd9660_read, cd9660_write, cd9660_seek, cd9660_stat +}; + +struct file { + off_t off; /* Current offset within file */ + daddr_t bno; /* Starting block number */ + off_t size; /* Size of file */ +}; + +struct ptable_ent { + char namlen [ISODCL( 1, 1)]; /* 711 */ + char extlen [ISODCL( 2, 2)]; /* 711 */ + char block [ISODCL( 3, 6)]; /* 732 */ + char parent [ISODCL( 7, 8)]; /* 722 */ + char name [1]; +}; +#define PTFIXSZ 8 +#define PTSIZE(pp) roundup(PTFIXSZ + isonum_711((pp)->namlen), 2) + +#define cdb2devb(bno) ((bno) * ISO_DEFAULT_BLOCK_SIZE / DEV_BSIZE) + +/* XXX these should be in the system headers */ +static __inline int +isonum_722(p) + u_char *p; +{ + return (*p << 8)|p[1]; +} + +static __inline int +isonum_732(p) + u_char *p; +{ + return (*p << 24)|(p[1] << 16)|(p[2] << 8)|p[3]; +} + + + +static int +pnmatch(path, pp) + char *path; + struct ptable_ent *pp; +{ + char *cp; + int i; + + cp = pp->name; + for (i = isonum_711(pp->namlen); --i >= 0; path++, cp++) { + if (toupper(*path) == *cp) + continue; + return 0; + } + if (*path != '/') + return 0; + return 1; +} + +static int +dirmatch(path, dp) + char *path; + struct iso_directory_record *dp; +{ + char *cp; + int i; + + /* This needs to be a regular file */ + if (dp->flags[0] & 6) + return 0; + + cp = dp->name; + for (i = isonum_711(dp->name_len); --i >= 0; path++, cp++) { + if (!*path) + break; + if (toupper(*path) == *cp) + continue; + return 0; + } + if (*path) + return 0; + /* + * Allow stripping of trailing dots and the version number. + * Note that this will find the first instead of the last version + * of a file. + */ + if (i >= 0 && (*cp == ';' || *cp == '.')) { + /* This is to prevent matching of numeric extensions */ + if (*cp == '.' && cp[1] != ';') + return 0; + while (--i >= 0) + if (*++cp != ';' && (*cp < '0' || *cp > '9')) + return 0; + } + return 1; +} + +static int +cd9660_open(path, f) + char *path; + struct open_file *f; +{ + struct file *fp = 0; + void *buf; + struct iso_primary_descriptor *vd; + size_t buf_size, read, psize, dsize; + daddr_t bno; + int parent, ent; + struct ptable_ent *pp; + struct iso_directory_record *dp = 0; + int rc; + + /* First find the volume descriptor */ + buf = malloc(buf_size = ISO_DEFAULT_BLOCK_SIZE); + vd = buf; + for (bno = 16;; bno++) { + twiddle(); + rc = f->f_dev->dv_strategy(f->f_devdata, F_READ, cdb2devb(bno), + ISO_DEFAULT_BLOCK_SIZE, buf, &read); + if (rc) + goto out; + if (read != ISO_DEFAULT_BLOCK_SIZE) { + rc = EIO; + goto out; + } + rc = EINVAL; + if (bcmp(vd->id, ISO_STANDARD_ID, sizeof vd->id) != 0) + goto out; + if (isonum_711(vd->type) == ISO_VD_END) + goto out; + if (isonum_711(vd->type) == ISO_VD_PRIMARY) + break; + } + if (isonum_723(vd->logical_block_size) != ISO_DEFAULT_BLOCK_SIZE) + goto out; + + /* Now get the path table and lookup the directory of the file */ + bno = isonum_732(vd->type_m_path_table); + psize = isonum_733(vd->path_table_size); + + if (psize > ISO_DEFAULT_BLOCK_SIZE) { + free(buf); + buf = malloc(buf_size = roundup(psize, ISO_DEFAULT_BLOCK_SIZE)); + } + + twiddle(); + rc = f->f_dev->dv_strategy(f->f_devdata, F_READ, cdb2devb(bno), + buf_size, buf, &read); + if (rc) + goto out; + if (read != buf_size) { + rc = EIO; + goto out; + } + + parent = 1; + pp = (struct ptable_ent *)buf; + ent = 1; + bno = isonum_732(pp->block) + isonum_711(pp->extlen); + + rc = ENOENT; + while (*path) { + if ((void *)pp >= buf + psize) + break; + if (isonum_722(pp->parent) != parent) + break; + if (!pnmatch(path, pp)) { + pp = (struct ptable_ent *)((void *)pp + PTSIZE(pp)); + ent++; + continue; + } + path += isonum_711(pp->namlen) + 1; + parent = ent; + bno = isonum_732(pp->block) + isonum_711(pp->extlen); + while ((void *)pp < buf + psize) { + if (isonum_722(pp->parent) == parent) + break; + pp = (struct ptable_ent *)((void *)pp + PTSIZE(pp)); + ent++; + } + } + + /* Now bno has the start of the directory that supposedly contains the file */ + bno--; + dsize = 1; /* Something stupid, but > 0 XXX */ + for (psize = 0; psize < dsize;) { + if (!(psize % ISO_DEFAULT_BLOCK_SIZE)) { + bno++; + twiddle(); + rc = f->f_dev->dv_strategy(f->f_devdata, F_READ, + cdb2devb(bno), + ISO_DEFAULT_BLOCK_SIZE, + buf, &read); + if (rc) + goto out; + if (read != ISO_DEFAULT_BLOCK_SIZE) { + rc = EIO; + goto out; + } + dp = (struct iso_directory_record *)buf; + } + if (!isonum_711(dp->length)) { + if ((void *)dp == buf) + psize += ISO_DEFAULT_BLOCK_SIZE; + else + psize = roundup(psize, ISO_DEFAULT_BLOCK_SIZE); + continue; + } + if (dsize == 1) + dsize = isonum_733(dp->size); + if (dirmatch(path, dp)) + break; + psize += isonum_711(dp->length); + dp = (struct iso_directory_record *)((void *)dp + isonum_711(dp->length)); + } + + if (psize >= dsize) { + rc = ENOENT; + goto out; + } + + /* allocate file system specific data structure */ + fp = malloc(sizeof(struct file)); + bzero(fp, sizeof(struct file)); + f->f_fsdata = (void *)fp; + + fp->off = 0; + fp->bno = isonum_733(dp->extent); + fp->size = isonum_733(dp->size); + free(buf); + + return 0; + +out: + if (fp) + free(fp); + free(buf); + + return rc; +} + +static int +cd9660_close(f) + struct open_file *f; +{ + struct file *fp = (struct file *)f->f_fsdata; + + f->f_fsdata = 0; + free(fp); + + return 0; +} + +static int +cd9660_read(f, start, size, resid) + struct open_file *f; + void *start; + size_t size; + size_t *resid; +{ + struct file *fp = (struct file *)f->f_fsdata; + int rc = 0; + daddr_t bno; + char buf[ISO_DEFAULT_BLOCK_SIZE]; + char *dp; + size_t read, off; + + while (size) { + if (fp->off < 0 || fp->off >= fp->size) + break; + bno = fp->off / ISO_DEFAULT_BLOCK_SIZE + fp->bno; + if (fp->off & (ISO_DEFAULT_BLOCK_SIZE - 1) + || size < ISO_DEFAULT_BLOCK_SIZE) + dp = buf; + else + dp = start; + twiddle(); + rc = f->f_dev->dv_strategy(f->f_devdata, F_READ, cdb2devb(bno), + ISO_DEFAULT_BLOCK_SIZE, dp, &read); + if (rc) + return rc; + if (read != ISO_DEFAULT_BLOCK_SIZE) + return EIO; + if (dp == buf) { + off = fp->off & (ISO_DEFAULT_BLOCK_SIZE - 1); + if (read > off + size) + read = off + size; + read -= off; + bcopy(buf + off, start, read); + start += read; + fp->off += read; + size -= read; + } else { + start += ISO_DEFAULT_BLOCK_SIZE; + fp->off += ISO_DEFAULT_BLOCK_SIZE; + size -= ISO_DEFAULT_BLOCK_SIZE; + } + } + if (resid) + *resid = size; + return rc; +} + +static int +cd9660_write(f, start, size, resid) + struct open_file *f; + void *start; + size_t size; + size_t *resid; +{ + return EROFS; +} + +static off_t +cd9660_seek(f, offset, where) + struct open_file *f; + off_t offset; + int where; +{ + struct file *fp = (struct file *)f->f_fsdata; + + switch (where) { + case SEEK_SET: + fp->off = offset; + break; + case SEEK_CUR: + fp->off += offset; + break; + case SEEK_END: + fp->off = fp->size - offset; + break; + default: + return -1; + } + return fp->off; +} + +static int +cd9660_stat(f, sb) + struct open_file *f; + struct stat *sb; +{ + struct file *fp = (struct file *)f->f_fsdata; + + /* only importatn stuff */ + sb->st_mode = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH; + sb->st_uid = sb->st_gid = 0; + sb->st_size = fp->size; + return 0; +} Property changes on: cvs2svn/tags/initial/lib/libstand/cd9660.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/close.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/close.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/close.c (revision 49189) @@ -0,0 +1,96 @@ +/* $NetBSD: close.c,v 1.7 1997/01/22 00:38:09 cgd Exp $ */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * The Mach Operating System project at Carnegie-Mellon University. + * + * 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)close.c 8.1 (Berkeley) 6/11/93 + * + * + * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University + * All Rights Reserved. + * + * Author: Alessandro Forin + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include "stand.h" + +int +close(fd) + int fd; +{ + register struct open_file *f = &files[fd]; + int err1 = 0, err2 = 0; + + if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { + errno = EBADF; + return (-1); + } + if (!(f->f_flags & F_RAW) && f->f_ops) + err1 = (f->f_ops->fo_close)(f); + if (!(f->f_flags & F_NODEV) && f->f_dev) + err2 = (f->f_dev->dv_close)(f); + if (f->f_devdata != NULL) + devclose(f); + f->f_flags = 0; + if (err1) { + errno = err1; + return (-1); + } + if (err2) { + errno = err2; + return (-1); + } + return (0); +} Property changes on: cvs2svn/tags/initial/lib/libstand/close.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/closeall.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/closeall.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/closeall.c (revision 49189) @@ -0,0 +1,77 @@ +/* $NetBSD: closeall.c,v 1.1 1996/01/13 22:25:36 leo Exp $ */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * The Mach Operating System project at Carnegie-Mellon University. + * + * 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)close.c 8.1 (Berkeley) 6/11/93 + * + * + * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University + * All Rights Reserved. + * + * Author: Alessandro Forin + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include "stand.h" + +void +closeall() +{ + int i; + + for (i = 0; i < SOPEN_MAX; i++) + if (files[i].f_flags != 0) + (void)close(i); +} Property changes on: cvs2svn/tags/initial/lib/libstand/closeall.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/dev.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/dev.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/dev.c (revision 49189) @@ -0,0 +1,62 @@ +/* $NetBSD: dev.c,v 1.4 1994/10/30 21:48:23 cgd Exp $ */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)dev.c 8.1 (Berkeley) 6/11/93 + */ + +#include +#include + +#include "stand.h" + +int +nodev() +{ + return (ENXIO); +} + +void +nullsys() +{ +} + +/* ARGSUSED */ +int +noioctl(f, cmd, data) + struct open_file *f; + u_long cmd; + void *data; +{ + return (EINVAL); +} Property changes on: cvs2svn/tags/initial/lib/libstand/dev.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/dev_net.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/dev_net.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/dev_net.c (revision 49189) @@ -0,0 +1,255 @@ +/* $NetBSD: dev_net.c,v 1.12 1997/12/10 20:38:37 gwr Exp $ */ + +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Gordon W. Ross. + * + * 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 by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``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 FOUNDATION OR CONTRIBUTORS + * 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. + */ + +/* + * This module implements a "raw device" interface suitable for + * use by the stand-alone I/O library NFS code. This interface + * does not support any "block" access, and exists only for the + * purpose of initializing the network interface, getting boot + * parameters, and performing the NFS mount. + * + * At open time, this does: + * + * find interface - netif_open() + * RARP for IP address - rarp_getipaddress() + * RPC/bootparams - callrpc(d, RPC_BOOTPARAMS, ...) + * RPC/mountd - nfs_mount(sock, ip, path) + * + * the root file handle from mountd is saved in a global + * for use by the NFS open code (NFS/lookup). + */ + +#include +#include +#include +#include +#include +#include + +#include "stand.h" +#include "net.h" +#include "netif.h" +#include "nfs.h" +#include "bootparam.h" +#include "dev_net.h" + +static int netdev_sock = -1; +static int netdev_opens; + +static int net_getparams(int sock); + +struct devsw netdev = { + "net", + DEVT_NET, + net_init, + net_strategy, + net_open, + net_close, + noioctl +}; + +/* + * Called by devopen after it sets f->f_dev to our devsw entry. + * This opens the low-level device and sets f->f_devdata. + * This is declared with variable arguments... + */ +int +net_open(struct open_file *f, void *vdev) +{ + char *devname; /* Device part of file name (or NULL). */ + int error = 0; + + devname = vdev; + +#ifdef NETIF_DEBUG + if (debug) + printf("net_open: %s\n", devname); +#endif + + /* On first open, do netif open, mount, etc. */ + if (netdev_opens == 0) { + /* Find network interface. */ + if (netdev_sock < 0) { + netdev_sock = netif_open(devname); + if (netdev_sock < 0) { + printf("net_open: netif_open() failed\n"); + return (ENXIO); + } + if (debug) + printf("net_open: netif_open() succeeded\n"); + } + if (rootip.s_addr == 0) { + /* Get root IP address, and path, etc. */ + error = net_getparams(netdev_sock); + if (error) { + /* getparams makes its own noise */ + netif_close(netdev_sock); + netdev_sock = -1; + return (error); + } + } + } + netdev_opens++; + return (error); +} + +int +net_close(f) + struct open_file *f; +{ + +#ifdef NETIF_DEBUG + if (debug) + printf("net_close: opens=%d\n", netdev_opens); +#endif + + /* On last close, do netif close, etc. */ + f->f_devdata = NULL; + /* Extra close call? */ + if (netdev_opens <= 0) + return (0); + netdev_opens--; + /* Not last close? */ + if (netdev_opens > 0) + return(0); + rootip.s_addr = 0; + if (netdev_sock >= 0) { + if (debug) + printf("net_close: calling netif_close()\n"); + netif_close(netdev_sock); + netdev_sock = -1; + } + return (0); +} + +int +net_ioctl() +{ + return EIO; +} + +int +net_strategy() +{ + return EIO; +} + + +/* + * Get info for NFS boot: our IP address, our hostname, + * server IP address, and our root path on the server. + * There are two ways to do this: The old, Sun way, + * and the more modern, BOOTP way. (RFC951, RFC1048) + * + * The default is to use the Sun bootparams RPC + * (because that is what the kernel will do). + * MD code can make try_bootp initialied data, + * which will override this common definition. + */ +#ifdef SUPPORT_BOOTP +int try_bootp; +int bootp(int sock); +#endif + +static int +net_getparams(sock) + int sock; +{ + char buf[MAXHOSTNAMELEN]; + n_long smask; + +#ifdef SUPPORT_BOOTP + /* + * Try to get boot info using BOOTP. If we succeed, then + * the server IP address, gateway, and root path will all + * be initialized. If any remain uninitialized, we will + * use RARP and RPC/bootparam (the Sun way) to get them. + */ + if (try_bootp) + bootp(sock); + if (myip.s_addr != 0) + return (0); + if (debug) + printf("net_open: BOOTP failed, trying RARP/RPC...\n"); +#endif + + /* + * Use RARP to get our IP address. This also sets our + * netmask to the "natural" default for our address. + */ + if (rarp_getipaddress(sock)) { + printf("net_open: RARP failed\n"); + return (EIO); + } + printf("net_open: client addr: %s\n", inet_ntoa(myip)); + + /* Get our hostname, server IP address, gateway. */ + if (bp_whoami(sock)) { + printf("net_open: bootparam/whoami RPC failed\n"); + return (EIO); + } + printf("net_open: client name: %s\n", hostname); + + /* + * Ignore the gateway from whoami (unreliable). + * Use the "gateway" parameter instead. + */ + smask = 0; + gateip.s_addr = 0; + if (bp_getfile(sock, "gateway", &gateip, buf) == 0) { + /* Got it! Parse the netmask. */ + smask = ip_convertaddr(buf); + } + if (smask) { + netmask = smask; + printf("net_open: subnet mask: %s\n", intoa(netmask)); + } + if (gateip.s_addr) + printf("net_open: net gateway: %s\n", inet_ntoa(gateip)); + + /* Get the root server and pathname. */ + if (bp_getfile(sock, "root", &rootip, rootpath)) { + printf("net_open: bootparam/getfile RPC failed\n"); + return (EIO); + } + + printf("net_open: server addr: %s\n", inet_ntoa(rootip)); + printf("net_open: server path: %s\n", rootpath); + + return (0); +} Property changes on: cvs2svn/tags/initial/lib/libstand/dev_net.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/dev_net.h =================================================================== --- cvs2svn/tags/initial/lib/libstand/dev_net.h (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/dev_net.h (revision 49189) @@ -0,0 +1,7 @@ +/* $NetBSD: dev_net.h,v 1.3 1997/03/15 18:12:14 is Exp $ */ + +int net_open(struct open_file *, ...); +int net_close(struct open_file *); +int net_ioctl(); +int net_strategy(); + Property changes on: cvs2svn/tags/initial/lib/libstand/dev_net.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/dosfs.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/dosfs.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/dosfs.c (revision 49189) @@ -0,0 +1,660 @@ +/* + * Copyright (c) 1996, 1998 Robert Nordier + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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(S) 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. + */ + +/* + * Readonly filesystem for Microsoft FAT12/FAT16/FAT32 filesystems, + * also supports VFAT. + */ + +#include +#include +#include + +#include "stand.h" + +#if 0 +#include +#include +#include +#include +#include +#endif + +#include "dosfs.h" + + +static int dos_open(char *path, struct open_file *fd); +static int dos_close(struct open_file *fd); +static int dos_read(struct open_file *fd, void *buf, size_t size, size_t *resid); +static off_t dos_seek(struct open_file *fd, off_t offset, int whence); +static int dos_stat(struct open_file *fd, struct stat *sb); + +struct fs_ops dos_fsops = { + "dosfs", dos_open, dos_close, dos_read, null_write, dos_seek, dos_stat +}; + +#define SECSIZ 512 /* sector size */ +#define SSHIFT 9 /* SECSIZ shift */ +#define DEPSEC 16 /* directory entries per sector */ +#define DSHIFT 4 /* DEPSEC shift */ +#define LOCLUS 2 /* lowest cluster number */ + +/* DOS "BIOS Parameter Block" */ +typedef struct { + u_char secsiz[2]; /* sector size */ + u_char spc; /* sectors per cluster */ + u_char ressec[2]; /* reserved sectors */ + u_char fats; /* FATs */ + u_char dirents[2]; /* root directory entries */ + u_char secs[2]; /* total sectors */ + u_char media; /* media descriptor */ + u_char spf[2]; /* sectors per FAT */ + u_char spt[2]; /* sectors per track */ + u_char heads[2]; /* drive heads */ + u_char hidsec[4]; /* hidden sectors */ + u_char lsecs[4]; /* huge sectors */ + u_char lspf[4]; /* huge sectors per FAT */ + u_char xflg[2]; /* flags */ + u_char vers[2]; /* filesystem version */ + u_char rdcl[4]; /* root directory start cluster */ + u_char infs[2]; /* filesystem info sector */ + u_char bkbs[2]; /* backup boot sector */ +} DOS_BPB; + +/* Initial portion of DOS boot sector */ +typedef struct { + u_char jmp[3]; /* usually 80x86 'jmp' opcode */ + u_char oem[8]; /* OEM name and version */ + DOS_BPB bpb; /* BPB */ +} DOS_BS; + +/* Supply missing "." and ".." root directory entries */ +static const char *const dotstr[2] = {".", ".."}; +static DOS_DE dot[2] = { + {". ", " ", FA_DIR, {0, 0, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, + {0, 0}, {0x21, 0}, {0, 0}, {0, 0, 0, 0}}, + {".. ", " ", FA_DIR, {0, 0, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, + {0, 0}, {0x21, 0}, {0, 0}, {0, 0, 0, 0}} +}; + +/* The usual conversion macros to avoid multiplication and division */ +#define bytsec(n) ((n) >> SSHIFT) +#define secbyt(s) ((s) << SSHIFT) +#define entsec(e) ((e) >> DSHIFT) +#define bytblk(fs, n) ((n) >> (fs)->bshift) +#define blkbyt(fs, b) ((b) << (fs)->bshift) +#define secblk(fs, s) ((s) >> ((fs)->bshift - SSHIFT)) +#define blksec(fs, b) ((b) << ((fs)->bshift - SSHIFT)) + +/* Convert cluster number to offset within filesystem */ +#define blkoff(fs, b) (secbyt((fs)->lsndta) + blkbyt(fs, (b) - LOCLUS)) + +/* Convert cluster number to logical sector number */ +#define blklsn(fs, b) ((fs)->lsndta + blksec(fs, (b) - LOCLUS)) + +/* Convert cluster number to offset within FAT */ +#define fatoff(sz, c) ((sz) == 12 ? (c) + ((c) >> 1) : \ + (sz) == 16 ? (c) << 1 : \ + (c) << 2) + +/* Does cluster number reference a valid data cluster? */ +#define okclus(fs, c) ((c) >= LOCLUS && (c) <= (fs)->xclus) + +/* Get start cluster from directory entry */ +#define stclus(sz, de) ((sz) != 32 ? cv2((de)->clus) : \ + ((u_int)cv2((de)->dex.h_clus) << 16) | \ + cv2((de)->clus)) + +static int dosunmount(DOS_FS *); +static int parsebs(DOS_FS *, DOS_BS *); +static int namede(DOS_FS *, const char *, DOS_DE **); +static int lookup(DOS_FS *, u_int, const char *, DOS_DE **); +static void cp_xdnm(u_char *, DOS_XDE *); +static void cp_sfn(u_char *, DOS_DE *); +static int fatget(DOS_FS *, u_int *); +static int fatend(u_int, u_int); +static int ioread(DOS_FS *, u_int, void *, u_int); +static int iobuf(DOS_FS *, u_int); +static int ioget(struct open_file *, u_int, void *, u_int); + +/* + * Mount DOS filesystem + */ +static int +dos_mount(DOS_FS *fs, struct open_file *fd) +{ + int err; + + bzero(fs, sizeof(DOS_FS)); + fs->fd = fd; + if ((err = !(fs->buf = alloc(SECSIZ)) ? errno : 0) || + (err = ioget(fs->fd, 0, fs->buf, 1)) || + (err = parsebs(fs, (DOS_BS *)fs->buf))) { + (void)dosunmount(fs); + return(err); + } + return 0; +} + +/* + * Unmount mounted filesystem + */ +static int +dos_unmount(DOS_FS *fs) +{ + int err; + + if (fs->links) + return(EBUSY); + if ((err = dosunmount(fs))) + return(err); + return 0; +} + +/* + * Common code shared by dos_mount() and dos_unmount() + */ +static int +dosunmount(DOS_FS *fs) +{ + if (fs->buf) + free(fs->buf, 0); + free(fs, 0); + return(0); +} + +/* + * Open DOS file + */ +static int +dos_open(char *path, struct open_file *fd) +{ + DOS_DE *de; + DOS_FILE *f; + DOS_FS *fs; + u_int size, clus; + int err = 0; + + /* Allocate mount structure, associate with open */ + fs = alloc(sizeof(DOS_FS)); + + if ((err = dos_mount(fs, fd))) + goto out; + + if ((err = namede(fs, path, &de))) + goto out; + + /* XXX we need to be able to open directories */ + if (de->attr & FA_DIR) { + err = EISDIR; + goto out; + } + clus = stclus(fs->fatsz, de); + size = cv4(de->size); + if (!clus ^ !size || (clus && !okclus(fs, clus))) { + err = EINVAL; + goto out; + } + f = alloc(sizeof(DOS_FILE)); + bzero(f, sizeof(DOS_FILE)); + f->fs = fs; + fs->links++; + f->de = *de; + fd->f_fsdata = (void *)f; + + out: + return(err); +} + +/* + * Read from file + */ +static int +dos_read(struct open_file *fd, void *buf, size_t nbyte, size_t *resid) +{ + u_int nb, off, clus, c, cnt, n; + DOS_FILE *f = (DOS_FILE *)fd->f_fsdata; + int err = 0; + + nb = (u_int)nbyte; + if (nb > (n = cv4(f->de.size) - f->offset)) + nb = n; + off = f->offset; + if ((clus = stclus(f->fs->fatsz, &f->de))) + off &= f->fs->bsize - 1; + c = f->c; + cnt = nb; + while (cnt) { + n = 0; + if (!c) { + if ((c = clus)) + n = bytblk(f->fs, f->offset); + } else if (!off) + n++; + while (n--) { + if ((err = fatget(f->fs, &c))) + goto out; + if (!okclus(f->fs, c)) { + err = EINVAL; + goto out; + } + } + if (!clus || (n = f->fs->bsize - off) > cnt) + n = cnt; + if ((err = ioread(f->fs, blkoff(f->fs, c) + off, buf, n))) + goto out; + f->offset += n; + f->c = c; + off = 0; + buf += n; + cnt -= n; + } + out: + if (resid) + *resid = cnt; + return(err); +} + +/* + * Reposition within file + */ +static off_t +dos_seek(struct open_file *fd, off_t offset, int whence) +{ + off_t off; + u_int size; + DOS_FILE *f = (DOS_FILE *)fd->f_fsdata; + + size = cv4(f->de.size); + switch (whence) { + case SEEK_SET: + off = 0; + break; + case SEEK_CUR: + off = f->offset; + break; + case SEEK_END: + off = size; + break; + default: + return(-1); + } + off += offset; + if (off < 0 || off > size) + return(-1); + f->offset = (u_int)off; + f->c = 0; + return(off); +} + +/* + * Close open file + */ +static int +dos_close(struct open_file *fd) +{ + DOS_FILE *f = (DOS_FILE *)fd->f_fsdata; + DOS_FS *fs = f->fs; + + f->fs->links--; + free(f, 0); + dos_unmount(fs); + return 0; +} + +/* + * Return some stat information on a file. + */ +static int +dos_stat(struct open_file *fd, struct stat *sb) +{ + DOS_FILE *f = (DOS_FILE *)fd->f_fsdata; + + /* only important stuff */ + sb->st_mode = 0444; + sb->st_nlink = 1; + sb->st_uid = 0; + sb->st_gid = 0; + sb->st_size = cv4(f->de.size); + return (0); +} + +/* + * Parse DOS boot sector + */ +static int +parsebs(DOS_FS *fs, DOS_BS *bs) +{ + u_int sc; + + if ((bs->jmp[0] != 0x69 && + bs->jmp[0] != 0xe9 && + (bs->jmp[0] != 0xeb || bs->jmp[2] != 0x90)) || + bs->bpb.media < 0xf0) + return EINVAL; + if (cv2(bs->bpb.secsiz) != SECSIZ) + return EINVAL; + if (!(fs->spc = bs->bpb.spc) || fs->spc & (fs->spc - 1)) + return EINVAL; + fs->bsize = secbyt(fs->spc); + fs->bshift = ffs(fs->bsize) - 1; + if ((fs->spf = cv2(bs->bpb.spf))) { + if (bs->bpb.fats != 2) + return EINVAL; + if (!(fs->dirents = cv2(bs->bpb.dirents))) + return EINVAL; + } else { + if (!(fs->spf = cv4(bs->bpb.lspf))) + return EINVAL; + if (!bs->bpb.fats || bs->bpb.fats > 16) + return EINVAL; + if ((fs->rdcl = cv4(bs->bpb.rdcl)) < LOCLUS) + return EINVAL; + } + if (!(fs->lsnfat = cv2(bs->bpb.ressec))) + return EINVAL; + fs->lsndir = fs->lsnfat + fs->spf * bs->bpb.fats; + fs->lsndta = fs->lsndir + entsec(fs->dirents); + if (!(sc = cv2(bs->bpb.secs)) && !(sc = cv4(bs->bpb.lsecs))) + return EINVAL; + if (fs->lsndta > sc) + return EINVAL; + if ((fs->xclus = secblk(fs, sc - fs->lsndta) + 1) < LOCLUS) + return EINVAL; + fs->fatsz = fs->dirents ? fs->xclus < 0xff6 ? 12 : 16 : 32; + sc = (secbyt(fs->spf) << 1) / (fs->fatsz >> 2) - 1; + if (fs->xclus > sc) + fs->xclus = sc; + return 0; +} + +/* + * Return directory entry from path + */ +static int +namede(DOS_FS *fs, const char *path, DOS_DE **dep) +{ + char name[256]; + DOS_DE *de; + char *s; + size_t n; + int err; + + err = 0; + de = dot; + if (*path == '/') + path++; + while (*path) { + if (!(s = strchr(path, '/'))) + s = strchr(path, 0); + if ((n = s - path) > 255) + return ENAMETOOLONG; + memcpy(name, path, n); + name[n] = 0; + path = s; + if (!(de->attr & FA_DIR)) + return ENOTDIR; + if ((err = lookup(fs, stclus(fs->fatsz, de), name, &de))) + return err; + if (*path == '/') + path++; + } + *dep = de; + return 0; +} + +/* + * Lookup path segment + */ +static int +lookup(DOS_FS *fs, u_int clus, const char *name, DOS_DE **dep) +{ + static DOS_DIR dir[DEPSEC]; + u_char lfn[261]; + u_char sfn[13]; + u_int nsec, lsec, xdn, chk, sec, ent, x; + int err, ok, i; + + if (!clus) + for (ent = 0; ent < 2; ent++) + if (!strcasecmp(name, dotstr[ent])) { + *dep = dot + ent; + return 0; + } + if (!clus && fs->fatsz == 32) + clus = fs->rdcl; + nsec = !clus ? entsec(fs->dirents) : fs->spc; + lsec = 0; + xdn = chk = 0; + for (;;) { + if (!clus && !lsec) + lsec = fs->lsndir; + else if (okclus(fs, clus)) + lsec = blklsn(fs, clus); + else + return EINVAL; + for (sec = 0; sec < nsec; sec++) { + if ((err = ioget(fs->fd, lsec + sec, dir, 1))) + return err; + for (ent = 0; ent < DEPSEC; ent++) { + if (!*dir[ent].de.name) + return ENOENT; + if (*dir[ent].de.name != 0xe5) + if ((dir[ent].de.attr & FA_MASK) == FA_XDE) { + x = dir[ent].xde.seq; + if (x & 0x40 || (x + 1 == xdn && + dir[ent].xde.chk == chk)) { + if (x & 0x40) { + chk = dir[ent].xde.chk; + x &= ~0x40; + } + if (x >= 1 && x <= 20) { + cp_xdnm(lfn, &dir[ent].xde); + xdn = x; + continue; + } + } + } else if (!(dir[ent].de.attr & FA_LABEL)) { + if ((ok = xdn == 1)) { + for (x = 0, i = 0; i < 11; i++) + x = ((((x & 1) << 7) | (x >> 1)) + + dir[ent].de.name[i]) & 0xff; + ok = chk == x && + !strcasecmp(name, (const char *)lfn); + } + if (!ok) { + cp_sfn(sfn, &dir[ent].de); + ok = !strcasecmp(name, (const char *)sfn); + } + if (ok) { + *dep = &dir[ent].de; + return 0; + } + } + xdn = 0; + } + } + if (!clus) + break; + if ((err = fatget(fs, &clus))) + return err; + if (fatend(fs->fatsz, clus)) + break; + } + return ENOENT; +} + +/* + * Copy name from extended directory entry + */ +static void +cp_xdnm(u_char *lfn, DOS_XDE *xde) +{ + static struct { + u_int off; + u_int dim; + } ix[3] = { + {offsetof(DOS_XDE, name1), sizeof(xde->name1) / 2}, + {offsetof(DOS_XDE, name2), sizeof(xde->name2) / 2}, + {offsetof(DOS_XDE, name3), sizeof(xde->name3) / 2} + }; + u_char *p; + u_int n, x, c; + + lfn += 13 * ((xde->seq & ~0x40) - 1); + for (n = 0; n < 3; n++) + for (p = (u_char *)xde + ix[n].off, x = ix[n].dim; x; + p += 2, x--) { + if ((c = cv2(p)) && (c < 32 || c > 127)) + c = '?'; + if (!(*lfn++ = c)) + return; + } + if (xde->seq & 0x40) + *lfn = 0; +} + +/* + * Copy short filename + */ +static void +cp_sfn(u_char *sfn, DOS_DE *de) +{ + u_char *p; + int j, i; + + p = sfn; + if (*de->name != ' ') { + for (j = 7; de->name[j] == ' '; j--); + for (i = 0; i <= j; i++) + *p++ = de->name[i]; + if (*de->ext != ' ') { + *p++ = '.'; + for (j = 2; de->ext[j] == ' '; j--); + for (i = 0; i <= j; i++) + *p++ = de->ext[i]; + } + } + *p = 0; + if (*sfn == 5) + *sfn = 0xe5; +} + +/* + * Get next cluster in cluster chain + */ +static int +fatget(DOS_FS *fs, u_int *c) +{ + u_char buf[4]; + u_int x; + int err; + + err = ioread(fs, secbyt(fs->lsnfat) + fatoff(fs->fatsz, *c), buf, + fs->fatsz != 32 ? 2 : 4); + if (err) + return err; + x = fs->fatsz != 32 ? cv2(buf) : cv4(buf); + *c = fs->fatsz == 12 ? *c & 1 ? x >> 4 : x & 0xfff : x; + return 0; +} + +/* + * Is cluster an end-of-chain marker? + */ +static int +fatend(u_int sz, u_int c) +{ + return c > (sz == 12 ? 0xff7U : sz == 16 ? 0xfff7U : 0xffffff7); +} + +/* + * Offset-based I/O primitive + */ +static int +ioread(DOS_FS *fs, u_int offset, void *buf, u_int nbyte) +{ + char *s; + u_int off, n; + int err; + + s = buf; + if ((off = offset & (SECSIZ - 1))) { + offset -= off; + if ((err = iobuf(fs, bytsec(offset)))) + return err; + offset += SECSIZ; + if ((n = SECSIZ - off) > nbyte) + n = nbyte; + memcpy(s, fs->buf + off, n); + s += n; + nbyte -= n; + } + n = nbyte & (SECSIZ - 1); + if (nbyte -= n) { + if ((err = ioget(fs->fd, bytsec(offset), s, bytsec(nbyte)))) + return err; + offset += nbyte; + s += nbyte; + } + if (n) { + if ((err = iobuf(fs, bytsec(offset)))) + return err; + memcpy(s, fs->buf, n); + } + return 0; +} + +/* + * Buffered sector-based I/O primitive + */ +static int +iobuf(DOS_FS *fs, u_int lsec) +{ + int err; + + if (fs->bufsec != lsec) { + if ((err = ioget(fs->fd, lsec, fs->buf, 1))) + return err; + fs->bufsec = lsec; + } + return 0; +} + +/* + * Sector-based I/O primitive + */ +static int +ioget(struct open_file *fd, u_int lsec, void *buf, u_int nsec) +{ + int err; + + if ((err = (fd->f_dev->dv_strategy)(fd->f_devdata, F_READ, lsec, + secbyt(nsec), buf, NULL))) + return(err); + return(0); +} Property changes on: cvs2svn/tags/initial/lib/libstand/dosfs.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/dosfs.h =================================================================== --- cvs2svn/tags/initial/lib/libstand/dosfs.h (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/dosfs.h (revision 49189) @@ -0,0 +1,120 @@ +/* + * Copyright (c) 1996, 1998 Robert Nordier + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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(S) 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. + */ + +#ifndef DOSIO_H +#define DOSIO_H + +/* + * DOS file attributes + */ + +#define FA_RDONLY 001 /* read-only */ +#define FA_HIDDEN 002 /* hidden file */ +#define FA_SYSTEM 004 /* system file */ +#define FA_LABEL 010 /* volume label */ +#define FA_DIR 020 /* directory */ +#define FA_ARCH 040 /* archive (file modified) */ +#define FA_XDE 017 /* extended directory entry */ +#define FA_MASK 077 /* all attributes */ + +/* + * Macros to convert DOS-format 16-bit and 32-bit quantities + */ + +#define cv2(p) ((u_int16_t)(p)[0] | \ + ((u_int16_t)(p)[1] << 010)) +#define cv4(p) ((u_int32_t)(p)[0] | \ + ((u_int32_t)(p)[1] << 010) | \ + ((u_int32_t)(p)[2] << 020) | \ + ((u_int32_t)(p)[3] << 030)) + +/* + * Directory, filesystem, and file structures. + */ + +typedef struct { + u_char x_case; /* case */ + u_char c_hsec; /* created: secs/100 */ + u_char c_time[2]; /* created: time */ + u_char c_date[2]; /* created: date */ + u_char a_date[2]; /* accessed: date */ + u_char h_clus[2]; /* clus[hi] */ +} DOS_DEX; + +typedef struct { + u_char name[8]; /* name */ + u_char ext[3]; /* extension */ + u_char attr; /* attributes */ + DOS_DEX dex; /* VFAT/FAT32 only */ + u_char time[2]; /* modified: time */ + u_char date[2]; /* modified: date */ + u_char clus[2]; /* starting cluster */ + u_char size[4]; /* size */ +} DOS_DE; + +typedef struct { + u_char seq; /* flags */ + u_char name1[5][2]; /* 1st name area */ + u_char attr; /* (see fat_de) */ + u_char res; /* reserved */ + u_char chk; /* checksum */ + u_char name2[6][2]; /* 2nd name area */ + u_char clus[2]; /* (see fat_de) */ + u_char name3[2][2]; /* 3rd name area */ +} DOS_XDE; + +typedef union { + DOS_DE de; /* standard directory entry */ + DOS_XDE xde; /* extended directory entry */ +} DOS_DIR; + +typedef struct { + struct open_file *fd; /* file descriptor */ + u_char *buf; /* buffer */ + u_int bufsec; /* buffered sector */ + u_int links; /* active links to structure */ + u_int spc; /* sectors per cluster */ + u_int bsize; /* cluster size in bytes */ + u_int bshift; /* cluster conversion shift */ + u_int dirents; /* root directory entries */ + u_int spf; /* sectors per fat */ + u_int rdcl; /* root directory start cluster */ + u_int lsnfat; /* start of fat */ + u_int lsndir; /* start of root dir */ + u_int lsndta; /* start of data area */ + u_int fatsz; /* FAT entry size */ + u_int xclus; /* maximum cluster number */ +} DOS_FS; + +typedef struct { + DOS_FS *fs; /* associated filesystem */ + DOS_DE de; /* directory entry */ + u_int offset; /* current offset */ + u_int c; /* last cluster read */ +} DOS_FILE; + +#endif /* !DOSIO_H */ Property changes on: cvs2svn/tags/initial/lib/libstand/dosfs.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/environment.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/environment.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/environment.c (revision 49189) @@ -0,0 +1,212 @@ +/* + * Copyright (c) 1998 Michael Smith. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + * + */ + +/* + * Manage an environment-like space in which string variables may be stored. + * Provide support for some method-like operations for setting/retrieving + * variables in order to allow some type strength. + */ + +#include "stand.h" + +#include + +static void env_discard(struct env_var *ev); + +struct env_var *environ = NULL; + +/* + * Look up (name) and return it's env_var structure. + */ +struct env_var * +env_getenv(const char *name) +{ + struct env_var *ev; + + for (ev = environ; ev != NULL; ev = ev->ev_next) + if (!strcmp(ev->ev_name, name)) + break; + return(ev); +} + +/* + * Some notes: + * + * If the EV_VOLATILE flag is set, a copy of the variable is made. + * If EV_DYNAMIC is set, the the variable has been allocated with + * malloc and ownership transferred to the environment. + * If (value) is NULL, the variable is set but has no value. + */ +int +env_setenv(const char *name, int flags, void *value, ev_sethook_t sethook, + ev_unsethook_t unsethook) +{ + struct env_var *ev, *curr, *last; + + if ((ev = env_getenv(name)) != NULL) { + + /* + * If there's a set hook, let it do the work (unless we are working + * for one already. + */ + if ((ev->ev_sethook != NULL) && !(flags & EV_NOHOOK)) + return(ev->ev_sethook(ev, flags, value)); + } else { + ev = malloc(sizeof(struct env_var)); + ev->ev_name = strdup(name); + ev->ev_value = NULL; + /* hooks can only be set when the variable is instantiated */ + ev->ev_sethook = sethook; + ev->ev_unsethook = unsethook; + } + + /* If there is data in the variable, discard it */ + if (ev->ev_value != NULL) + free(ev->ev_value); + + /* If we have a new value, use it */ + if (flags & EV_VOLATILE) { + ev->ev_value = strdup(value); + } else { + ev->ev_value = value; + } + + /* Keep the flag components that are relevant */ + ev->ev_flags = flags & (EV_DYNAMIC); + + /* Sort into list */ + ev->ev_prev = NULL; + ev->ev_next = NULL; + + /* Search for the record to insert before */ + for (last = NULL, curr = environ; + curr != NULL; + last = curr, curr = curr->ev_next) { + + if (strcmp(ev->ev_name, curr->ev_name) < 0) { + if (curr->ev_prev) { + curr->ev_prev->ev_next = ev; + } else { + environ = ev; + } + ev->ev_next = curr; + ev->ev_prev = curr->ev_prev; + curr->ev_prev = ev; + break; + } + } + if (curr == NULL) { + if (last == NULL) { + environ = ev; + } else { + last->ev_next = ev; + ev->ev_prev = last; + } + } + return(0); +} + +char * +getenv(const char *name) +{ + struct env_var *ev; + + /* Set but no value gives empty string */ + if ((ev = env_getenv(name)) != NULL) { + if (ev->ev_value != NULL) + return(ev->ev_value); + return(""); + } + return(NULL); +} + +int +setenv(const char *name, char *value, int overwrite) +{ + /* No guarantees about state, always assume volatile */ + if (overwrite || (env_getenv(name) == NULL)) + return(env_setenv(name, EV_VOLATILE, value, NULL, NULL)); + return(0); +} + +int +putenv(const char *string) +{ + char *value; + + if ((value = strchr(string, '=')) != NULL) + *(value++) = 0; + return(setenv(string, value, 1)); +} + +int +unsetenv(const char *name) +{ + struct env_var *ev; + int err; + + err = 0; + if ((ev = env_getenv(name)) == NULL) { + err = ENOENT; + } else { + if (ev->ev_unsethook != NULL) + err = ev->ev_unsethook(ev); + if (err == 0) { + env_discard(ev); + } + } + return(err); +} + +static void +env_discard(struct env_var *ev) +{ + if (ev->ev_prev) + ev->ev_prev->ev_next = ev->ev_next; + if (ev->ev_next) + ev->ev_next->ev_prev = ev->ev_prev; + if (environ == ev) + environ = ev->ev_next; + free(ev->ev_name); + if (ev->ev_flags & EV_DYNAMIC) + free(ev->ev_value); + free(ev); +} + +int +env_noset(struct env_var *ev, int flags, void *value) +{ + return(EPERM); +} + +int +env_nounset(struct env_var *ev) +{ + return(EPERM); +} Property changes on: cvs2svn/tags/initial/lib/libstand/environment.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/ether.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/ether.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/ether.c (revision 49189) @@ -0,0 +1,151 @@ +/* $NetBSD: ether.c,v 1.11 1997/07/07 15:52:50 drochner Exp $ */ + +/* + * Copyright (c) 1992 Regents of the University of California. + * All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * 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 by the University of + * California, Lawrence Berkeley Laboratory and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#) Header: net.c,v 1.9 93/08/06 19:32:15 leres Exp (LBL) + */ + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "stand.h" +#include "net.h" +#include "netif.h" + +/* Caller must leave room for ethernet header in front!! */ +ssize_t +sendether(d, pkt, len, dea, etype) + struct iodesc *d; + void *pkt; + size_t len; + u_char *dea; + int etype; +{ + register ssize_t n; + register struct ether_header *eh; + +#ifdef ETHER_DEBUG + if (debug) + printf("sendether: called\n"); +#endif + + eh = (struct ether_header *)pkt - 1; + len += sizeof(*eh); + + MACPY(d->myea, eh->ether_shost); /* by byte */ + MACPY(dea, eh->ether_dhost); /* by byte */ + eh->ether_type = htons(etype); + + n = netif_put(d, eh, len); + if (n == -1 || n < sizeof(*eh)) + return (-1); + + n -= sizeof(*eh); + return (n); +} + +/* + * Get a packet of any Ethernet type, with our address or + * the broadcast address. Save the Ether type in arg 5. + * NOTE: Caller must leave room for the Ether header. + */ +ssize_t +readether(d, pkt, len, tleft, etype) + register struct iodesc *d; + register void *pkt; + register size_t len; + time_t tleft; + register u_int16_t *etype; +{ + register ssize_t n; + register struct ether_header *eh; + +#ifdef ETHER_DEBUG + if (debug) + printf("readether: called\n"); +#endif + + eh = (struct ether_header *)pkt - 1; + len += sizeof(*eh); + + n = netif_get(d, eh, len, tleft); + if (n == -1 || n < sizeof(*eh)) + return (-1); + + /* Validate Ethernet address. */ + if (bcmp(d->myea, eh->ether_dhost, 6) != 0 && + bcmp(bcea, eh->ether_dhost, 6) != 0) { +#ifdef ETHER_DEBUG + if (debug) + printf("readether: not ours (ea=%s)\n", + ether_sprintf(eh->ether_dhost)); +#endif + return (-1); + } + *etype = ntohs(eh->ether_type); + + n -= sizeof(*eh); + return (n); +} + +/* + * Convert Ethernet address to printable (loggable) representation. + */ +static char digits[] = "0123456789abcdef"; +char * +ether_sprintf(ap) + register u_char *ap; +{ + register i; + static char etherbuf[18]; + register char *cp = etherbuf; + + for (i = 0; i < 6; i++) { + *cp++ = digits[*ap >> 4]; + *cp++ = digits[*ap++ & 0xf]; + *cp++ = ':'; + } + *--cp = 0; + return (etherbuf); +} Property changes on: cvs2svn/tags/initial/lib/libstand/ether.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/fstat.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/fstat.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/fstat.c (revision 49189) @@ -0,0 +1,60 @@ +/* $NetBSD: fstat.c,v 1.1 1996/01/13 22:25:38 leo Exp $ */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)stat.c 8.1 (Berkeley) 6/11/93 + */ + +#include "stand.h" + +int +fstat(fd, sb) + int fd; + struct stat *sb; +{ + register struct open_file *f = &files[fd]; + + if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { + errno = EBADF; + return (-1); + } + + /* operation not defined on raw devices */ + if (f->f_flags & F_RAW) { + errno = EOPNOTSUPP; + return (-1); + } + + errno = (f->f_ops->fo_stat)(f, sb); + return (0); +} Property changes on: cvs2svn/tags/initial/lib/libstand/fstat.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/getopt.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/getopt.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/getopt.c (revision 49189) @@ -0,0 +1,112 @@ +/* + * Copyright (c) 1987, 1993, 1994 + * The Regents of the University of California. 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95"; +#endif /* LIBC_SCCS and not lint */ + +#include "stand.h" +#include + +int opterr = 1, /* if error message should be printed */ + optind = 1, /* index into parent argv vector */ + optopt, /* character checked for validity */ + optreset; /* reset getopt */ +char *optarg; /* argument associated with option */ + +#define BADCH (int)'?' +#define BADARG (int)':' +#define EMSG "" + +/* + * getopt -- + * Parse argc/argv argument vector. + */ +int +getopt(nargc, nargv, ostr) + int nargc; + char * const *nargv; + const char *ostr; +{ + static char *place = EMSG; /* option letter processing */ + char *oli; /* option letter list index */ + + if (optreset || !*place) { /* update scanning pointer */ + optreset = 0; + if (optind >= nargc || *(place = nargv[optind]) != '-') { + place = EMSG; + return (-1); + } + if (place[1] && *++place == '-') { /* found "--" */ + ++optind; + place = EMSG; + return (-1); + } + } /* option letter okay? */ + if ((optopt = (int)*place++) == (int)':' || + !(oli = strchr(ostr, optopt))) { + /* + * if the user didn't specify '-' as an option, + * assume it means -1. + */ + if (optopt == (int)'-') + return (-1); + if (!*place) + ++optind; + if (opterr && *ostr != ':') + (void)printf("illegal option -- %c\n", optopt); + return (BADCH); + } + if (*++oli != ':') { /* don't need argument */ + optarg = NULL; + if (!*place) + ++optind; + } + else { /* need an argument */ + if (*place) /* no white space */ + optarg = place; + else if (nargc <= ++optind) { /* no arg */ + place = EMSG; + if (*ostr == ':') + return (BADARG); + if (opterr) + (void)printf("option requires an argument -- %c\n", optopt); + return (BADCH); + } + else /* white space */ + optarg = nargv[optind]; + place = EMSG; + ++optind; + } + return (optopt); /* dump back option letter */ +} Property changes on: cvs2svn/tags/initial/lib/libstand/getopt.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/gets.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/gets.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/gets.c (revision 49189) @@ -0,0 +1,110 @@ +/* $NetBSD: gets.c,v 1.6 1995/10/11 21:16:57 pk Exp $ */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)gets.c 8.1 (Berkeley) 6/11/93 + */ + +#include "stand.h" + +/* gets() with constrained input length */ + +void +ngets(char *buf, int n) +{ + register int c; + register char *lp; + + for (lp = buf;;) + switch (c = getchar() & 0177) { + case '\n': + case '\r': + *lp = '\0'; + putchar('\n'); + return; + case '\b': + case '\177': + if (lp > buf) { + lp--; + putchar('\b'); + putchar(' '); + putchar('\b'); + } + break; + case 'r'&037: { + register char *p; + + putchar('\n'); + for (p = buf; p < lp; ++p) + putchar(*p); + break; + } + case 'u'&037: + case 'w'&037: + lp = buf; + putchar('\n'); + break; + default: + if ((n < 1) || ((lp - buf) < n)) { + *lp++ = c; + putchar(c); + } + } + /*NOTREACHED*/ +} + +int +fgetstr(char *buf, int size, int fd) +{ + char c; + int err, len; + + size--; /* leave space for terminator */ + len = 0; + while (size != 0) { + err = read(fd, &c, sizeof(c)); + if (err < 0) /* read error */ + return(-1); + if (err == 0) /* EOF */ + break; + if ((c == '\r') || /* line terminators */ + (c == '\n')) + break; + *buf++ = c; /* keep char */ + size--; + len++; + } + *buf = 0; + return(len); +} + Property changes on: cvs2svn/tags/initial/lib/libstand/gets.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/globals.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/globals.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/globals.c (revision 49189) @@ -0,0 +1,33 @@ +/* $NetBSD: globals.c,v 1.3 1995/09/18 21:19:27 pk Exp $ */ + +/* + * globals.c: + * + * global variables should be separate, so nothing else + * must be included extraneously. + */ + +#include +#include +#include + +#include "stand.h" +#include "net.h" + +u_char bcea[6] = BA; /* broadcast ethernet address */ + +char rootpath[FNAME_SIZE] = "/"; /* root mount path */ +char bootfile[FNAME_SIZE]; /* bootp says to boot this */ +char hostname[FNAME_SIZE]; /* our hostname */ +int hostnamelen; +char domainname[FNAME_SIZE]; /* our DNS domain */ +int domainnamelen; +char ifname[IFNAME_SIZE]; /* name of interface (e.g. "le0") */ +struct in_addr myip; /* my ip address */ +struct in_addr nameip; /* DNS server ip address */ +struct in_addr rootip; /* root ip address */ +struct in_addr swapip; /* swap ip address */ +struct in_addr gateip; /* swap ip address */ +n_long netmask = 0xffffff00; /* subnet or net mask */ +int errno; /* our old friend */ + Property changes on: cvs2svn/tags/initial/lib/libstand/globals.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/if_ether.h =================================================================== --- cvs2svn/tags/initial/lib/libstand/if_ether.h (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/if_ether.h (revision 49189) @@ -0,0 +1,263 @@ +/* $NetBSD: if_ether.h,v 1.25 1997/01/17 17:06:06 mikel Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)if_ether.h 8.1 (Berkeley) 6/10/93 + */ + +/* + * Ethernet address - 6 octets + * this is only used by the ethers(3) functions. + */ +struct ether_addr { + u_int8_t ether_addr_octet[6]; +}; + +/* + * Structure of a 10Mb/s Ethernet header. + */ +#define ETHER_ADDR_LEN 6 + +struct ether_header { + u_int8_t ether_dhost[ETHER_ADDR_LEN]; + u_int8_t ether_shost[ETHER_ADDR_LEN]; + u_int16_t ether_type; +}; + +#define ETHERTYPE_PUP 0x0200 /* PUP protocol */ +#define ETHERTYPE_IP 0x0800 /* IP protocol */ +#define ETHERTYPE_ARP 0x0806 /* address resolution protocol */ +#define ETHERTYPE_REVARP 0x8035 /* reverse addr resolution protocol */ + +/* + * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have + * (type-ETHERTYPE_TRAIL)*512 bytes of data followed + * by an ETHER type (as given above) and then the (variable-length) header. + */ +#define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */ +#define ETHERTYPE_NTRAILER 16 + +#define ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */ + +#define ETHERMTU 1500 +#define ETHERMIN (60-14) + +#ifdef _KERNEL +/* + * Macro to map an IP multicast address to an Ethernet multicast address. + * The high-order 25 bits of the Ethernet address are statically assigned, + * and the low-order 23 bits are taken from the low end of the IP address. + */ +#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \ + /* struct in_addr *ipaddr; */ \ + /* u_int8_t enaddr[ETHER_ADDR_LEN]; */ \ +{ \ + (enaddr)[0] = 0x01; \ + (enaddr)[1] = 0x00; \ + (enaddr)[2] = 0x5e; \ + (enaddr)[3] = ((u_int8_t *)ipaddr)[1] & 0x7f; \ + (enaddr)[4] = ((u_int8_t *)ipaddr)[2]; \ + (enaddr)[5] = ((u_int8_t *)ipaddr)[3]; \ +} +#endif + +/* + * Ethernet Address Resolution Protocol. + * + * See RFC 826 for protocol description. Structure below is adapted + * to resolving internet addresses. Field names used correspond to + * RFC 826. + */ +struct ether_arp { + struct arphdr ea_hdr; /* fixed-size header */ + u_int8_t arp_sha[ETHER_ADDR_LEN]; /* sender hardware address */ + u_int8_t arp_spa[4]; /* sender protocol address */ + u_int8_t arp_tha[ETHER_ADDR_LEN]; /* target hardware address */ + u_int8_t arp_tpa[4]; /* target protocol address */ +}; +#define arp_hrd ea_hdr.ar_hrd +#define arp_pro ea_hdr.ar_pro +#define arp_hln ea_hdr.ar_hln +#define arp_pln ea_hdr.ar_pln +#define arp_op ea_hdr.ar_op + +/* + * Structure shared between the ethernet driver modules and + * the address resolution code. For example, each ec_softc or il_softc + * begins with this structure. + */ +struct arpcom { + struct ifnet ac_if; /* network-visible interface */ + u_int8_t ac_enaddr[ETHER_ADDR_LEN]; /* ethernet hardware address */ + char ac__pad[2]; /* be nice to m68k ports */ + LIST_HEAD(, ether_multi) ac_multiaddrs; /* list of ether multicast addrs */ + int ac_multicnt; /* length of ac_multiaddrs list */ +}; + +struct llinfo_arp { + LIST_ENTRY(llinfo_arp) la_list; + struct rtentry *la_rt; + struct mbuf *la_hold; /* last packet until resolved/timeout */ + long la_asked; /* last time we QUERIED for this addr */ +#define la_timer la_rt->rt_rmx.rmx_expire /* deletion time in seconds */ +}; + +struct sockaddr_inarp { + u_int8_t sin_len; + u_int8_t sin_family; + u_int16_t sin_port; + struct in_addr sin_addr; + struct in_addr sin_srcaddr; + u_int16_t sin_tos; + u_int16_t sin_other; +#define SIN_PROXY 1 +}; + +/* + * IP and ethernet specific routing flags + */ +#define RTF_USETRAILERS RTF_PROTO1 /* use trailers */ +#define RTF_ANNOUNCE RTF_PROTO2 /* announce new arp entry */ + +#ifdef _KERNEL +u_int8_t etherbroadcastaddr[ETHER_ADDR_LEN]; +u_int8_t ether_ipmulticast_min[ETHER_ADDR_LEN]; +u_int8_t ether_ipmulticast_max[ETHER_ADDR_LEN]; +struct ifqueue arpintrq; + +void arpwhohas(struct arpcom *, struct in_addr *); +void arpintr(void); +int arpresolve(struct arpcom *, + struct rtentry *, struct mbuf *, struct sockaddr *, u_char *); +void arp_ifinit(struct arpcom *, struct ifaddr *); +void arp_rtrequest(int, struct rtentry *, struct sockaddr *); + +int ether_addmulti(struct ifreq *, struct arpcom *); +int ether_delmulti(struct ifreq *, struct arpcom *); +#endif /* _KERNEL */ + +/* + * Ethernet multicast address structure. There is one of these for each + * multicast address or range of multicast addresses that we are supposed + * to listen to on a particular interface. They are kept in a linked list, + * rooted in the interface's arpcom structure. (This really has nothing to + * do with ARP, or with the Internet address family, but this appears to be + * the minimally-disrupting place to put it.) + */ +struct ether_multi { + u_int8_t enm_addrlo[ETHER_ADDR_LEN]; /* low or only address of range */ + u_int8_t enm_addrhi[ETHER_ADDR_LEN]; /* high or only address of range */ + struct arpcom *enm_ac; /* back pointer to arpcom */ + u_int enm_refcount; /* no. claims to this addr/range */ + LIST_ENTRY(ether_multi) enm_list; +}; + +/* + * Structure used by macros below to remember position when stepping through + * all of the ether_multi records. + */ +struct ether_multistep { + struct ether_multi *e_enm; +}; + +/* + * Macro for looking up the ether_multi record for a given range of Ethernet + * multicast addresses connected to a given arpcom structure. If no matching + * record is found, "enm" returns NULL. + */ +#define ETHER_LOOKUP_MULTI(addrlo, addrhi, ac, enm) \ + /* u_int8_t addrlo[ETHER_ADDR_LEN]; */ \ + /* u_int8_t addrhi[ETHER_ADDR_LEN]; */ \ + /* struct arpcom *ac; */ \ + /* struct ether_multi *enm; */ \ +{ \ + for ((enm) = (ac)->ac_multiaddrs.lh_first; \ + (enm) != NULL && \ + (bcmp((enm)->enm_addrlo, (addrlo), ETHER_ADDR_LEN) != 0 || \ + bcmp((enm)->enm_addrhi, (addrhi), ETHER_ADDR_LEN) != 0); \ + (enm) = (enm)->enm_list.le_next); \ +} + +/* + * Macro to step through all of the ether_multi records, one at a time. + * The current position is remembered in "step", which the caller must + * provide. ETHER_FIRST_MULTI(), below, must be called to initialize "step" + * and get the first record. Both macros return a NULL "enm" when there + * are no remaining records. + */ +#define ETHER_NEXT_MULTI(step, enm) \ + /* struct ether_multistep step; */ \ + /* struct ether_multi *enm; */ \ +{ \ + if (((enm) = (step).e_enm) != NULL) \ + (step).e_enm = (enm)->enm_list.le_next; \ +} + +#define ETHER_FIRST_MULTI(step, ac, enm) \ + /* struct ether_multistep step; */ \ + /* struct arpcom *ac; */ \ + /* struct ether_multi *enm; */ \ +{ \ + (step).e_enm = (ac)->ac_multiaddrs.lh_first; \ + ETHER_NEXT_MULTI((step), (enm)); \ +} + +#ifdef _KERNEL +void arp_rtrequest(int, struct rtentry *, struct sockaddr *); +int arpresolve(struct arpcom *, struct rtentry *, struct mbuf *, + struct sockaddr *, u_char *); +void arpintr(void); +int arpioctl(u_long, caddr_t); +void arp_ifinit(struct arpcom *, struct ifaddr *); +void revarpinput(struct mbuf *); +void in_revarpinput(struct mbuf *); +void revarprequest(struct ifnet *); +int revarpwhoarewe(struct ifnet *, struct in_addr *, struct in_addr *); +int revarpwhoami(struct in_addr *, struct ifnet *); +int db_show_arptab(void); +#endif + +/* + * Prototype ethers(3) functions. + */ +#ifndef _KERNEL +#include +__BEGIN_DECLS +char * ether_ntoa(struct ether_addr *); +struct ether_addr * + ether_aton(char *); +int ether_ntohost(char *, struct ether_addr *); +int ether_hostton(char *, struct ether_addr *); +int ether_line(char *, struct ether_addr *, char *); +__END_DECLS +#endif Property changes on: cvs2svn/tags/initial/lib/libstand/if_ether.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/in_cksum.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/in_cksum.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/in_cksum.c (revision 49189) @@ -0,0 +1,83 @@ +/* $NetBSD: in_cksum.c,v 1.3 1995/04/22 13:53:48 cgd Exp $ */ + +/* + * Copyright (c) 1992 Regents of the University of California. + * All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * 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 by the University of + * California, Lawrence Berkeley Laboratory and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#) Header: in_cksum.c,v 1.1 92/09/11 01:15:55 leres Exp (LBL) + */ + +#include + +/* + * Checksum routine for Internet Protocol family headers. + * This routine is very heavily used in the network + * code and should be modified for each CPU to be as fast as possible. + * In particular, it should not be this one. + */ +int +in_cksum(p, len) + register void *p; + register int len; +{ + register int sum = 0, oddbyte = 0, v = 0; + register u_char *cp = p; + + /* we assume < 2^16 bytes being summed */ + while (len > 0) { + if (oddbyte) { + sum += v + *cp++; + len--; + } + if (((long)cp & 1) == 0) { + while ((len -= 2) >= 0) { + sum += *(u_short *)cp; + cp += 2; + } + } else { + while ((len -= 2) >= 0) { + sum += *cp++ << 8; + sum += *cp++; + } + } + if ((oddbyte = len & 1) != 0) + v = *cp << 8; + } + if (oddbyte) + sum += v; + sum = (sum >> 16) + (sum & 0xffff); /* add in accumulated carries */ + sum += sum >> 16; /* add potential last carry */ + return (0xffff & ~sum); +} Property changes on: cvs2svn/tags/initial/lib/libstand/in_cksum.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/ioctl.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/ioctl.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/ioctl.c (revision 49189) @@ -0,0 +1,89 @@ +/* $NetBSD: ioctl.c,v 1.4 1994/10/30 21:48:24 cgd Exp $ */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * The Mach Operating System project at Carnegie-Mellon University. + * + * 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)ioctl.c 8.1 (Berkeley) 6/11/93 + * + * + * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University + * All Rights Reserved. + * + * Author: Alessandro Forin + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include "stand.h" + +int +ioctl(fd, cmd, arg) + int fd; + u_long cmd; + char *arg; +{ + register struct open_file *f = &files[fd]; + + if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { + errno = EBADF; + return (-1); + } + if (f->f_flags & F_RAW) { + errno = (f->f_dev->dv_ioctl)(f, cmd, arg); + if (errno) + return (-1); + return (0); + } + errno = EIO; + return (-1); +} Property changes on: cvs2svn/tags/initial/lib/libstand/ioctl.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/iodesc.h =================================================================== --- cvs2svn/tags/initial/lib/libstand/iodesc.h (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/iodesc.h (revision 49189) @@ -0,0 +1,54 @@ +/* $NetBSD: iodesc.h,v 1.4 1995/09/23 03:31:50 gwr Exp $ */ + +/* + * Copyright (c) 1993 Adam Glass + * Copyright (c) 1992 Regents of the University of California. + * All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * 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 by the University of + * California, Lawrence Berkeley Laboratory and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + */ + +#ifndef __SYS_LIBNETBOOT_IODESC_H +#define __SYS_LIBNETBOOT_IODESC_H + +struct iodesc { + struct in_addr destip; /* dest. ip addr, net order */ + struct in_addr myip; /* local ip addr, net order */ + u_short destport; /* dest. port, net order */ + u_short myport; /* local port, net order */ + u_long xid; /* transaction identification */ + u_char myea[6]; /* my ethernet address */ + struct netif *io_netif; +}; + +#endif /* __SYS_LIBNETBOOT_IODESC_H */ Property changes on: cvs2svn/tags/initial/lib/libstand/iodesc.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/libstand.3 =================================================================== --- cvs2svn/tags/initial/lib/libstand/libstand.3 (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/libstand.3 (revision 49189) @@ -0,0 +1,456 @@ +.\" Copyright (c) Michael Smith +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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 Ohttp://wafu.netgate.net/tama/unix/indexe.htmlTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $Id$ +.\" +.Dd June 22, 1998 +.Dt LIBSTAND 3 +.Os FreeBSD 3.0 +.Sh NAME +.Nm libstand +.Nd support library for standalone executables +.Sh SYNOPSIS +.Fd #include +.Sh DESCRIPTION +.Nm +provides a set of supporting functions for standalone +applications, mimicking where possible the standard BSD programming +environment. The following sections group these functions by kind. +Unless specifically described here, see the corresponding section 3 +manpages for the given functions. +.Sh STRING FUNCTIONS +String functions are available as documented in +.Xr string 3 +and +.Xr bstring 3 . +.Sh MEMORY ALLOCATION +.Bl -hang -width 10n +.It Fn "void *malloc" "size_t size" +.Pp +Allocate +.Fa size +bytes of memory from the heap using a best-fit algorithm. +.It Fn "void free" "void *ptr" +.Pp +Free the allocated object at +.Fa ptr . +.It Fn "void setheap" "void *start" "void *limit" +.Pp +Initialise the heap. This function must be called before calling +.Fn alloc +for the first time. The region between +.Fa start +and +.Fa limit +will be used for the heap; attempting to allocate beyond this will result +in a panic. +.It Fn "char *sbrk" "int junk" +.Pp +Provides the behaviour of +.Fn sbrk 0 , +ie. returns the highest point that the heap has reached. This value can +be used during testing to determine the actual heap usage. The +.Fa junk +argument is ignored. +.El +.Sh ENVIRONMENT +A set of functions are provided for manipulating a flat variable space similar +to the traditional shell-supported evironment. Major enhancements are support +for set/unset hook functions. +.Bl -hang -width 10n +.It Fn "char *getenv" "const char *name" +.It Fn "int setenv" "const char *name" "char *value" "int overwrite" +.It Fn "int putenv" "const char *string" +.It Fn "int unsetenv" "const char *name" +.Pp +These functions behave similarly to their standard library counterparts. +.It Fn "struct env_var *env_getenv" "const char *name" +.Pp +Looks up a variable in the environment and returns its entire +data structure. +.It Fn "int env_setenv" "const char *name" "int flags" "char *value" "ev_sethook_t sethook" "ev_unsethook_t unsethook" +.Pp +Creates a new or sets an existing environment variable called +.Fa name . +If creating a new variable, the +.Fa sethook +and +.Fa unsethook +arguments may be specified. +.Pp +The set hook is invoked whenever an attempt +is made to set the variable, unless the EV_NOHOOK flag is set. Typically +a set hook will validate the +.Fa value +argument, and then call +.Fn env_setenv +again with EV_NOHOOK set to actually save the value. The predefined function +.Fn env_noset +may be specified to refuse all attempts to set a variable. +.Pp +The unset hook is invoked when an attempt is made to unset a variable. If it +returns zero, the variable will be unset. The predefined function +.Fa env_nounset +may be used to prevent a variable being unset. +.El +.Sh STANDARD LIBRARY SUPPORT +.Bl -hang -width 10n +.It Fn "int getopt" "int argc" "char * const *argv" "cont char *optstring" +.It Fn "long strtol" "const char *nptr" "char **endptr" "int base" +.It Fn "void srandom" "unsigned long seed" +.It Fn "unsigned long random" "void" +.It Fn "char *strerror" "int error" +.Pp +Returns error messages for the subset of errno values supported by +.Nm No . +.El +.Sh CHARACTER I/O +.Bl -hang -width 10n +.It Fn "void gets" "char *buf" +.Pp +Read characters from the console into +.Fa buf . +All of the standard cautions apply to this function. +.It Fn "void ngets" "char *buf" "size_t size" +.Pp +Read at most +.Fa size +- 1 characters from the console into +.Fa buf . +If +.Fa size +is less than 1, the function's behaviour is as for +.Fn gets . +.It Fn "int fgetstr" "char *buf" "int size" "int fd" +.Pp +Read a line of at most +.Fa size +characters into +.Fa buf . +Line terminating characters are stripped, and the buffer is always nul +terminated. Returns the number of characters in +.Fa buf +if successful, or -1 if a read error occurs. +.It Fn "int printf" "const char *fmt" "..." +.It Fn "void vprintf" "const char *fmt" "va_list ap" +.It Fn "int sprintf" "char *buf" "const char *fmt" "..." +.Pp +The *printf functions implement a subset of the standard +.Fn printf +family functionality and some extensions. The following standard conversions +are supported: c,d,n,o,p,s,u,x. The following modifiers are supported: ++,-,#,*,0,field width,precision,l. +.Pp +The +.Li b +conversion is provided to decode error registers. Its usage is: +.Pp +.Bd -offset indent +printf( +.Qq reg=%b\en , +regval, +.Qq * +); +.Ed + +where is the output expressed as a control character, eg. \e10 gives +octal, \e20 gives hex. Each is a sequence of characters, the first of +which gives the bit number to be inspected (origin 1) and the next characters +(up to a character less than 32) give the text to be displayed if the bit is set. +Thus +.Pp +.Bd -offset indent +printf( +.Qq reg=%b\en +3 +.Qq \e10\e2BITTWO\e1BITONE\en +); +.Ed + +would give the output +.Pp +.Bd -offset indent +reg=3 +.Ed +.Pp +The +.Li D +conversion provides a hexdump facility, eg. +.Pp +.Bd -offset indent -literal +printf( +.Qq %6D , +ptr, +.Qq \: +); gives +.Qq XX:XX:XX:XX:XX:XX +.Ed +.Bd -offset indent -literal +printf( +.Qq %*D , +len, +ptr, +.Qq "\ " +); gives +.Qq XX XX XX ... +.Ed +.El +.Sh CHARACTER TESTS AND CONVERSIONS +.Bl -hang -width 10n +.It Fn "int isupper" "int c" +.It Fn "int islower" "int c" +.It Fn "int isspace" "int c" +.It Fn "int isdigit" "int c" +.It Fn "int isxdigit" "int c" +.It Fn "int isascii" "int c" +.It Fn "int isalpha" "int c" +.It Fn "int toupper" "int c" +.It Fn "int tolower" "int c" +.El +.Sh FILE I/O +.Bl -hang -width 10n +.It Fn "int open" "const char *path" "int flags" +.Pp +Similar to the behaviour as specified in +.Xr open 2 , +except that file creation is not supported, so the mode parameter is not +required. The +.Fa flags +argument may be one of O_RDONLY, O_WRONLY and O_RDWR (although no filesystems +currently support writing). +.It Fn "int close" "int fd" +.It Fn "void closeall" "void" +.Pp +Close all open files. +.It Fn "ssize_t read" "int fd" "void *buf" "size_t len" +.It Fn "ssize_t write" "int fd" "void *buf" "size_t len" +.Pp +(No filesystems currently support writing.) +.It Fn "off_t lseek" "int fd" "off_t offset" "int whence" +.Pp +Files being automatically uncompressed during reading cannot seek backwards +from the current point. +.It Fn "int stat" "const char *path" "struct stat *sb" +.It Fn "int fstat" "int fd" "struct stat *sb" +.Pp +The +.Fn stat +and +.Fn fstat +functions only fill out the following fields in the +.Fa sb +structure: st_mode,st_nlink,st_uid,st_gid,st_size. The +.Nm tftp +filesystem cannot provide meaningful values for this call, and the +.Nm cd9660 +filesystem always reports files having uid/gid of zero. +.El +.Sh PAGER +.Nm +supplies a simple internal pager to ease reading the output of large commands. +.Bl -hang -width 10n +.It Fn "void pager_open" +.Pp +Initialises the pager and tells it that the next line output will be the top of the +display. The environment variable LINES is consulted to determine the number of +lines to be displayed before pausing. +.It Fn "void pager_close" "void" +.Pp +Closes the pager. +.It Fn "void pager_output" "char *lines" +.Pp +Sends the lines in the nul-terminated buffer at +.Fa lines +to the pager. Newline characters are counted in order to determine the number +of lines being output (wrapped lines are not accounted for). +.Fn pager_output +will return zero when all of the lines have been output, or nonzero if the +display was paused and the user elected to quit. +.It Fn "int pager_file" "char *fname" +.Pp +Attempts to open and display the file +.Fa fname. + Returns -1 on error, 0 at EOF, or 1 if the user elects to quit while reading. +.El +.Sh MISC +.Bl -hang -width 10n +.It Fn "void twiddle" "void" +.Pp +Successive calls emit the characters in the sequence |,/,-,\\ followed by a +backspace in order to provide reassurance to the user. +.El +.Sh REQUIRED LOW-LEVEL SUPPORT +The following resources are consumed by +.Nm +- stack, heap, console and devices. +.Pp +The stack must be established before +.Nm +functions can be invoked. Stack requirements vary depending on the functions +and filesystems used by the consumer and the support layer functions detailed +below. +.Pp +The heap must be established before calling +.Fn alloc +or +.Fn open +by calling +.Fn setheap . +Heap usage will vary depending on the number of simultaneously open files, +as well as client behaviour. Automatic decompression will allocate more +than 64K of data per open file. +.Pp +Console access is performed via the +.Fn getchar , +.Fn putchar +and +.Fn ischar +functions detailed below. +.Pp +Device access is initiated via +.Fn devopen +and is performed through the +.Fn dv_strategy , +.Fn dv_ioctl +and +.Fn dv_close +functions in the device switch structure that +.Fn devopen +returns. +.Pp +The consumer must provide the following support functions: +.Bl -hang -width 10n +.It Fn "int getchar" "void" +.Pp +Return a character from the console, used by +.Fn gets , +.Fn ngets +and pager functions. +.It Fn "int ischar" "void" +.Pp +Returns nonzero if a character is waiting from the console. +.It Fn "void putchar" "int" +.Pp +Write a character to the console, used by +.Fn gets , +.Fn ngets , +.Fn *printf , +.Fn panic +and +.Fn twiddle +and thus by many other functions for debugging and informational output. +.It Fn "int devopen" "struct open_file *of" "const char *name" "char **file" +.Pp +Open the appropriate device for the file named in +.Fa name , +returning in +.Fa file +a pointer to the remaining body of +.Fa name +which does not refer to the device. The +.Va f_dev +field in +.Fa of +will be set to point to the +.Dv devsw +structure for the opened device if successful. Device identifiers must +always precede the path component, but may otherwise be arbitrarily formatted. +Used by +.Fn open +and thus for all device-related I/O. +.It Fn "int devclose" "struct open_file *of" +Close the device allocated for +.Fa of . +The device driver itself will already have been called for the close; this call +should clean up any allocation made by devopen only. +.It Fn "void panic" "const char *msg" "..." +.Pp +Signal a fatal and unrecoverable error condition. The +.Fa msg ... +arguments are as for +.Fn printf . +.El +.Sh INTERNAL FILESYSTEMS +Internal filesystems are enabled by the consumer exporting the array +.Dv struct fs_ops *file_system[], which should be initialised with pointers +to +.Dv struct fs_ops +structures. The following filesystem handlers are supplied by +.Nm No , +the consumer may supply other filesystems of their own: +.Bl -hang -width "cd9660_fsops " +.It ufs_fsops +The BSD UFS. +.It tftp_fsops +File access via TFTP. +.It nfs_fsops +File access via NFS. +.It cd9660_fsops +ISO 9660 (CD-ROM) filesystem. +.It zipfs_fsops +Stacked filesystem supporting gzipped files. When trying the zipfs filesystem, +.Nm +appends +.Li .gz +to the end of the filename, and then tries to locate the file using the other +filesystems. Placement of this filesystem in the +.Dv file_system[] +array determines whether gzipped files will be opened in preference to non-gzipped +files. It is only possible to seek a gzipped file forwards, and +.Fn stat +and +.Fn fstat +on gzipped files will report an invalid length. +.El +.Pp +The array of +.Dv struct fs_ops +pointers should be terminated with a NULL. +.Sh DEVICES +Devices are exported by the supporting code via the array +.Dv struct devsw *devsw[] +which is a NULL terminated array of pointers to device switch structures. +.Sh BUGS +.Pp +The lack of detailed memory usage data is unhelpful. +.Sh HISTORY +.Nm +contains contributions from many sources, including: +.Bl -bullet -compact +.It +.Nm libsa +from +.Nx +.It +.Nm libc +and +.Nm libkern +from +.Fx 3.0 . +.El +.Pp +The reorganisation and port to +.Fx 3.0 , +the environment functions and this manpage were written by +.An Mike Smith Aq msmith@freebsd.org . Property changes on: cvs2svn/tags/initial/lib/libstand/libstand.3 ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/lseek.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/lseek.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/lseek.c (revision 49189) @@ -0,0 +1,102 @@ +/* $NetBSD: lseek.c,v 1.4 1997/01/22 00:38:10 cgd Exp $ */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * The Mach Operating System project at Carnegie-Mellon University. + * + * 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)lseek.c 8.1 (Berkeley) 6/11/93 + * + * + * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University + * All Rights Reserved. + * + * Author: Alessandro Forin + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include "stand.h" + +off_t +lseek(fd, offset, where) + int fd; + off_t offset; + int where; +{ + register struct open_file *f = &files[fd]; + + if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { + errno = EBADF; + return (-1); + } + + if (f->f_flags & F_RAW) { + /* + * On RAW devices, update internal offset. + */ + switch (where) { + case SEEK_SET: + f->f_offset = offset; + break; + case SEEK_CUR: + f->f_offset += offset; + break; + case SEEK_END: + default: + errno = EOFFSET; + return (-1); + } + return (f->f_offset); + } + + return (f->f_ops->fo_seek)(f, offset, where); +} Property changes on: cvs2svn/tags/initial/lib/libstand/lseek.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/net.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/net.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/net.c (revision 49189) @@ -0,0 +1,503 @@ +/* $NetBSD: net.c,v 1.20 1997/12/26 22:41:30 scottr Exp $ */ + +/* + * Copyright (c) 1992 Regents of the University of California. + * All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * 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 by the University of + * California, Lawrence Berkeley Laboratory and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#) Header: net.c,v 1.9 93/08/06 19:32:15 leres Exp (LBL) + */ + +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "stand.h" +#include "net.h" + +/* Caller must leave room for ethernet, ip and udp headers in front!! */ +ssize_t +sendudp(d, pkt, len) + register struct iodesc *d; + register void *pkt; + register size_t len; +{ + register ssize_t cc; + register struct ip *ip; + register struct udphdr *uh; + register u_char *ea; + +#ifdef NET_DEBUG + if (debug) { + printf("sendudp: d=%lx called.\n", (long)d); + if (d) { + printf("saddr: %s:%d", + inet_ntoa(d->myip), ntohs(d->myport)); + printf(" daddr: %s:%d\n", + inet_ntoa(d->destip), ntohs(d->destport)); + } + } +#endif + + uh = (struct udphdr *)pkt - 1; + ip = (struct ip *)uh - 1; + len += sizeof(*ip) + sizeof(*uh); + + bzero(ip, sizeof(*ip) + sizeof(*uh)); + + ip->ip_v = IPVERSION; /* half-char */ + ip->ip_hl = sizeof(*ip) >> 2; /* half-char */ + ip->ip_len = htons(len); + ip->ip_p = IPPROTO_UDP; /* char */ + ip->ip_ttl = IP_TTL; /* char */ + ip->ip_src = d->myip; + ip->ip_dst = d->destip; + ip->ip_sum = in_cksum(ip, sizeof(*ip)); /* short, but special */ + + uh->uh_sport = d->myport; + uh->uh_dport = d->destport; + uh->uh_ulen = htons(len - sizeof(*ip)); + +#ifndef UDP_NO_CKSUM + { + register struct udpiphdr *ui; + struct ip tip; + + /* Calculate checksum (must save and restore ip header) */ + tip = *ip; + ui = (struct udpiphdr *)ip; + bzero(&ui->ui_x1, sizeof(ui->ui_x1)); + ui->ui_len = uh->uh_ulen; + uh->uh_sum = in_cksum(ui, len); + *ip = tip; + } +#endif + + if (ip->ip_dst.s_addr == INADDR_BROADCAST || ip->ip_src.s_addr == 0 || + netmask == 0 || SAMENET(ip->ip_src, ip->ip_dst, netmask)) + ea = arpwhohas(d, ip->ip_dst); + else + ea = arpwhohas(d, gateip); + + cc = sendether(d, ip, len, ea, ETHERTYPE_IP); + if (cc == -1) + return (-1); + if (cc != len) + panic("sendudp: bad write (%d != %d)", cc, len); + return (cc - (sizeof(*ip) + sizeof(*uh))); +} + +/* + * Receive a UDP packet and validate it is for us. + * Caller leaves room for the headers (Ether, IP, UDP) + */ +ssize_t +readudp(d, pkt, len, tleft) + register struct iodesc *d; + register void *pkt; + register size_t len; + time_t tleft; +{ + register ssize_t n; + register size_t hlen; + register struct ip *ip; + register struct udphdr *uh; + u_int16_t etype; /* host order */ + +#ifdef NET_DEBUG + if (debug) + printf("readudp: called\n"); +#endif + + uh = (struct udphdr *)pkt - 1; + ip = (struct ip *)uh - 1; + + n = readether(d, ip, len + sizeof(*ip) + sizeof(*uh), tleft, &etype); + if (n == -1 || n < sizeof(*ip) + sizeof(*uh)) + return -1; + + /* Ethernet address checks now in readether() */ + + /* Need to respond to ARP requests. */ + if (etype == ETHERTYPE_ARP) { + struct arphdr *ah = (void *)ip; + if (ah->ar_op == htons(ARPOP_REQUEST)) { + /* Send ARP reply */ + arp_reply(d, ah); + } + return -1; + } + + if (etype != ETHERTYPE_IP) { +#ifdef NET_DEBUG + if (debug) + printf("readudp: not IP. ether_type=%x\n", etype); +#endif + return -1; + } + + /* Check ip header */ + if (ip->ip_v != IPVERSION || + ip->ip_p != IPPROTO_UDP) { /* half char */ +#ifdef NET_DEBUG + if (debug) + printf("readudp: IP version or not UDP. ip_v=%d ip_p=%d\n", ip->ip_v, ip->ip_p); +#endif + return -1; + } + + hlen = ip->ip_hl << 2; + if (hlen < sizeof(*ip) || + in_cksum(ip, hlen) != 0) { +#ifdef NET_DEBUG + if (debug) + printf("readudp: short hdr or bad cksum.\n"); +#endif + return -1; + } + if (n < ntohs(ip->ip_len)) { +#ifdef NET_DEBUG + if (debug) + printf("readudp: bad length %d < %d.\n", + (int)n, ntohs(ip->ip_len)); +#endif + return -1; + } + if (d->myip.s_addr && ip->ip_dst.s_addr != d->myip.s_addr) { +#ifdef NET_DEBUG + if (debug) { + printf("readudp: bad saddr %s != ", inet_ntoa(d->myip)); + printf("%s\n", inet_ntoa(ip->ip_dst)); + } +#endif + return -1; + } + + /* If there were ip options, make them go away */ + if (hlen != sizeof(*ip)) { + bcopy(((u_char *)ip) + hlen, uh, len - hlen); + ip->ip_len = htons(sizeof(*ip)); + n -= hlen - sizeof(*ip); + } + if (uh->uh_dport != d->myport) { +#ifdef NET_DEBUG + if (debug) + printf("readudp: bad dport %d != %d\n", + d->myport, ntohs(uh->uh_dport)); +#endif + return -1; + } + +#ifndef UDP_NO_CKSUM + if (uh->uh_sum) { + register struct udpiphdr *ui; + struct ip tip; + + n = ntohs(uh->uh_ulen) + sizeof(*ip); + if (n > RECV_SIZE - ETHER_SIZE) { + printf("readudp: huge packet, udp len %d\n", (int)n); + return -1; + } + + /* Check checksum (must save and restore ip header) */ + tip = *ip; + ui = (struct udpiphdr *)ip; + bzero(&ui->ui_x1, sizeof(ui->ui_x1)); + ui->ui_len = uh->uh_ulen; + if (in_cksum(ui, n) != 0) { +#ifdef NET_DEBUG + if (debug) + printf("readudp: bad cksum\n"); +#endif + *ip = tip; + return -1; + } + *ip = tip; + } +#endif + if (ntohs(uh->uh_ulen) < sizeof(*uh)) { +#ifdef NET_DEBUG + if (debug) + printf("readudp: bad udp len %d < %d\n", + ntohs(uh->uh_ulen), (int)sizeof(*uh)); +#endif + return -1; + } + + n -= sizeof(*ip) + sizeof(*uh); + return (n); +} + +/* + * Send a packet and wait for a reply, with exponential backoff. + * + * The send routine must return the actual number of bytes written, + * or -1 on error. + * + * The receive routine can indicate success by returning the number of + * bytes read; it can return 0 to indicate EOF; it can return -1 with a + * non-zero errno to indicate failure; finally, it can return -1 with a + * zero errno to indicate it isn't done yet. + */ +ssize_t +sendrecv(d, sproc, sbuf, ssize, rproc, rbuf, rsize) + register struct iodesc *d; + register ssize_t (*sproc)(struct iodesc *, void *, size_t); + register void *sbuf; + register size_t ssize; + register ssize_t (*rproc)(struct iodesc *, void *, size_t, time_t); + register void *rbuf; + register size_t rsize; +{ + register ssize_t cc; + register time_t t, tmo, tlast; + long tleft; + +#ifdef NET_DEBUG + if (debug) + printf("sendrecv: called\n"); +#endif + + tmo = MINTMO; + tlast = tleft = 0; + t = getsecs(); + for (;;) { + if (tleft <= 0) { + if (tmo >= MAXTMO) { + errno = ETIMEDOUT; + return -1; + } + cc = (*sproc)(d, sbuf, ssize); + if (cc != -1 && cc < ssize) + panic("sendrecv: short write! (%d < %d)", + cc, ssize); + + tleft = tmo; + tmo <<= 1; + if (tmo > MAXTMO) + tmo = MAXTMO; + + if (cc == -1) { + /* Error on transmit; wait before retrying */ + while ((getsecs() - t) < tmo); + tleft = 0; + continue; + } + + tlast = t; + } + + /* Try to get a packet and process it. */ + cc = (*rproc)(d, rbuf, rsize, tleft); + /* Return on data, EOF or real error. */ + if (cc != -1 || errno != 0) + return (cc); + + /* Timed out or didn't get the packet we're waiting for */ + t = getsecs(); + tleft -= t - tlast; + tlast = t; + } +} + +/* + * Like inet_addr() in the C library, but we only accept base-10. + * Return values are in network order. + */ +n_long +inet_addr(cp) + char *cp; +{ + register u_long val; + register int n; + register char c; + u_int parts[4]; + register u_int *pp = parts; + + for (;;) { + /* + * Collect number up to ``.''. + * Values are specified as for C: + * 0x=hex, 0=octal, other=decimal. + */ + val = 0; + while ((c = *cp) != '\0') { + if (c >= '0' && c <= '9') { + val = (val * 10) + (c - '0'); + cp++; + continue; + } + break; + } + if (*cp == '.') { + /* + * Internet format: + * a.b.c.d + * a.b.c (with c treated as 16-bits) + * a.b (with b treated as 24 bits) + */ + if (pp >= parts + 3 || val > 0xff) + goto bad; + *pp++ = val, cp++; + } else + break; + } + /* + * Check for trailing characters. + */ + if (*cp != '\0') + goto bad; + + /* + * Concoct the address according to + * the number of parts specified. + */ + n = pp - parts + 1; + switch (n) { + + case 1: /* a -- 32 bits */ + break; + + case 2: /* a.b -- 8.24 bits */ + if (val > 0xffffff) + goto bad; + val |= parts[0] << 24; + break; + + case 3: /* a.b.c -- 8.8.16 bits */ + if (val > 0xffff) + goto bad; + val |= (parts[0] << 24) | (parts[1] << 16); + break; + + case 4: /* a.b.c.d -- 8.8.8.8 bits */ + if (val > 0xff) + goto bad; + val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); + break; + } + + return (htonl(val)); + bad: + return (htonl(INADDR_NONE)); +} + +char * +inet_ntoa(ia) + struct in_addr ia; +{ + return (intoa(ia.s_addr)); +} + +/* Similar to inet_ntoa() */ +char * +intoa(addr) + register n_long addr; +{ + register char *cp; + register u_int byte; + register int n; + static char buf[17]; /* strlen(".255.255.255.255") + 1 */ + + NTOHL(addr); + cp = &buf[sizeof buf]; + *--cp = '\0'; + + n = 4; + do { + byte = addr & 0xff; + *--cp = byte % 10 + '0'; + byte /= 10; + if (byte > 0) { + *--cp = byte % 10 + '0'; + byte /= 10; + if (byte > 0) + *--cp = byte + '0'; + } + *--cp = '.'; + addr >>= 8; + } while (--n > 0); + + return (cp+1); +} + +static char * +number(s, n) + char *s; + int *n; +{ + for (*n = 0; isdigit(*s); s++) + *n = (*n * 10) + *s - '0'; + return s; +} + +n_long +ip_convertaddr(p) + char *p; +{ +#define IP_ANYADDR 0 + n_long addr = 0, n; + + if (p == (char *)0 || *p == '\0') + return IP_ANYADDR; + p = number(p, &n); + addr |= (n << 24) & 0xff000000; + if (*p == '\0' || *p++ != '.') + return IP_ANYADDR; + p = number(p, &n); + addr |= (n << 16) & 0xff0000; + if (*p == '\0' || *p++ != '.') + return IP_ANYADDR; + p = number(p, &n); + addr |= (n << 8) & 0xff00; + if (*p == '\0' || *p++ != '.') + return IP_ANYADDR; + p = number(p, &n); + addr |= n & 0xff; + if (*p != '\0') + return IP_ANYADDR; + + return htonl(addr); +} Property changes on: cvs2svn/tags/initial/lib/libstand/net.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/net.h =================================================================== --- cvs2svn/tags/initial/lib/libstand/net.h (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/net.h (revision 49189) @@ -0,0 +1,122 @@ +/* $NetBSD: net.h,v 1.10 1995/10/20 00:46:30 cgd Exp $ */ + +/* + * Copyright (c) 1993 Adam Glass + * Copyright (c) 1992 Regents of the University of California. + * All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * 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 by the University of + * California, Lawrence Berkeley Laboratory and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + */ + +#define NETIF_DEBUG 1 + +#ifndef _KERNEL /* XXX - see */ +#undef __IPADDR +#define __IPADDR(x) htonl((u_int32_t)(x)) +#endif + +#include "iodesc.h" + +#define BA { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } + +/* Returns true if n_long's on the same net */ +#define SAMENET(a1, a2, m) ((a1.s_addr & m) == (a2.s_addr & m)) + +#define MACPY(s, d) bcopy((char *)s, (char *)d, 6) + +#define MAXTMO 20 /* seconds */ +#define MINTMO 2 /* seconds */ + +#define FNAME_SIZE 128 +#define IFNAME_SIZE 16 +#define RECV_SIZE 1536 /* XXX delete this */ + +/* + * How much room to leave for headers: + * 14: struct ether_header + * 20: struct ip + * 8: struct udphdr + * That's 42 but let's pad it out to 48 bytes. + */ +#define ETHER_SIZE 14 +#define HEADER_SIZE 48 + +extern u_char bcea[6]; +extern char rootpath[FNAME_SIZE]; +extern char bootfile[FNAME_SIZE]; +extern char hostname[FNAME_SIZE]; +extern int hostnamelen; +extern char domainname[FNAME_SIZE]; +extern int domainnamelen; +extern char ifname[IFNAME_SIZE]; + +/* All of these are in network order. */ +extern struct in_addr myip; +extern struct in_addr rootip; +extern struct in_addr swapip; +extern struct in_addr gateip; +extern struct in_addr nameip; +extern n_long netmask; + +extern int debug; /* defined in the machdep sources */ + +extern struct iodesc sockets[SOPEN_MAX]; + +/* ARP/RevARP functions: */ +u_char *arpwhohas(struct iodesc *, struct in_addr); +void arp_reply(struct iodesc *, void *); +int rarp_getipaddress(int); + +/* Link functions: */ +ssize_t sendether(struct iodesc *d, void *pkt, size_t len, + u_char *dea, int etype); +ssize_t readether(struct iodesc *d, void *pkt, size_t len, + time_t tleft, u_int16_t *etype); + +ssize_t sendudp(struct iodesc *, void *, size_t); +ssize_t readudp(struct iodesc *, void *, size_t, time_t); +ssize_t sendrecv(struct iodesc *, + ssize_t (*)(struct iodesc *, void *, size_t), + void *, size_t, + ssize_t (*)(struct iodesc *, void *, size_t, time_t), + void *, size_t); + +/* Utilities: */ +char *ether_sprintf(u_char *); +int in_cksum(void *, int); +char *inet_ntoa(struct in_addr); +char *intoa(n_long); /* similar to inet_ntoa */ +n_long inet_addr(char *); + +/* Machine-dependent functions: */ +time_t getsecs(void); Property changes on: cvs2svn/tags/initial/lib/libstand/net.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/netif.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/netif.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/netif.c (revision 49189) @@ -0,0 +1,332 @@ +/* $NetBSD: netif.c,v 1.10 1997/09/06 13:57:14 drochner Exp $ */ + +/* + * Copyright (c) 1993 Adam Glass + * 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 by Adam Glass. + * 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 Adam Glass ``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 REGENTS OR CONTRIBUTORS 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. + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include "stand.h" +#include "net.h" +#include "netif.h" + +struct iodesc sockets[SOPEN_MAX]; +#ifdef NETIF_DEBUG +int netif_debug = 0; +#endif + +/* + * netif_init: + * + * initialize the generic network interface layer + */ + +void +netif_init() +{ + struct netif_driver *drv; + int d, i; + +#ifdef NETIF_DEBUG + if (netif_debug) + printf("netif_init: called\n"); +#endif + for (d = 0; netif_drivers[d]; d++) { + drv = netif_drivers[d]; + for (i = 0; i < drv->netif_nifs; i++) + drv->netif_ifs[i].dif_used = 0; + } +} + +int +netif_match(nif, machdep_hint) + struct netif *nif; + void *machdep_hint; +{ + struct netif_driver *drv = nif->nif_driver; + +#if 0 + if (netif_debug) + printf("%s%d: netif_match (%d)\n", drv->netif_bname, + nif->nif_unit, nif->nif_sel); +#endif + return drv->netif_match(nif, machdep_hint); +} + +struct netif * +netif_select(machdep_hint) + void *machdep_hint; +{ + int d, u, unit_done, s; + struct netif_driver *drv; + struct netif cur_if; + static struct netif best_if; + int best_val; + int val; + + best_val = 0; + best_if.nif_driver = NULL; + + for (d = 0; netif_drivers[d] != NULL; d++) { + cur_if.nif_driver = netif_drivers[d]; + drv = cur_if.nif_driver; + + for (u = 0; u < drv->netif_nifs; u++) { + cur_if.nif_unit = u; + unit_done = 0; + +#ifdef NETIF_DEBUG + if (netif_debug) + printf("\t%s%d:", drv->netif_bname, + cur_if.nif_unit); +#endif + + for (s = 0; s < drv->netif_ifs[u].dif_nsel; s++) { + cur_if.nif_sel = s; + + if (drv->netif_ifs[u].dif_used & (1 << s)) { +#ifdef NETIF_DEBUG + if (netif_debug) + printf(" [%d used]", s); +#endif + continue; + } + + val = netif_match(&cur_if, machdep_hint); +#ifdef NETIF_DEBUG + if (netif_debug) + printf(" [%d -> %d]", s, val); +#endif + if (val > best_val) { + best_val = val; + best_if = cur_if; + } + } +#ifdef NETIF_DEBUG + if (netif_debug) + printf("\n"); +#endif + } + } + + if (best_if.nif_driver == NULL) + return NULL; + + best_if.nif_driver-> + netif_ifs[best_if.nif_unit].dif_used |= (1 << best_if.nif_sel); + +#ifdef NETIF_DEBUG + if (netif_debug) + printf("netif_select: %s%d(%d) wins\n", + best_if.nif_driver->netif_bname, + best_if.nif_unit, best_if.nif_sel); +#endif + return &best_if; +} + +int +netif_probe(nif, machdep_hint) + struct netif *nif; + void *machdep_hint; +{ + struct netif_driver *drv = nif->nif_driver; + +#ifdef NETIF_DEBUG + if (netif_debug) + printf("%s%d: netif_probe\n", drv->netif_bname, nif->nif_unit); +#endif + return drv->netif_probe(nif, machdep_hint); +} + +void +netif_attach(nif, desc, machdep_hint) + struct netif *nif; + struct iodesc *desc; + void *machdep_hint; +{ + struct netif_driver *drv = nif->nif_driver; + +#ifdef NETIF_DEBUG + if (netif_debug) + printf("%s%d: netif_attach\n", drv->netif_bname, nif->nif_unit); +#endif + desc->io_netif = nif; +#ifdef PARANOID + if (drv->netif_init == NULL) + panic("%s%d: no netif_init support\n", drv->netif_bname, + nif->nif_unit); +#endif + drv->netif_init(desc, machdep_hint); + bzero(drv->netif_ifs[nif->nif_unit].dif_stats, + sizeof(struct netif_stats)); +} + +void +netif_detach(nif) + struct netif *nif; +{ + struct netif_driver *drv = nif->nif_driver; + +#ifdef NETIF_DEBUG + if (netif_debug) + printf("%s%d: netif_detach\n", drv->netif_bname, nif->nif_unit); +#endif +#ifdef PARANOID + if (drv->netif_end == NULL) + panic("%s%d: no netif_end support\n", drv->netif_bname, + nif->nif_unit); +#endif + drv->netif_end(nif); +} + +ssize_t +netif_get(desc, pkt, len, timo) + struct iodesc *desc; + void *pkt; + size_t len; + time_t timo; +{ +#ifdef NETIF_DEBUG + struct netif *nif = desc->io_netif; +#endif + struct netif_driver *drv = desc->io_netif->nif_driver; + ssize_t rv; + +#ifdef NETIF_DEBUG + if (netif_debug) + printf("%s%d: netif_get\n", drv->netif_bname, nif->nif_unit); +#endif +#ifdef PARANOID + if (drv->netif_get == NULL) + panic("%s%d: no netif_get support\n", drv->netif_bname, + nif->nif_unit); +#endif + rv = drv->netif_get(desc, pkt, len, timo); +#ifdef NETIF_DEBUG + if (netif_debug) + printf("%s%d: netif_get returning %d\n", drv->netif_bname, + nif->nif_unit, (int)rv); +#endif + return rv; +} + +ssize_t +netif_put(desc, pkt, len) + struct iodesc *desc; + void *pkt; + size_t len; +{ +#ifdef NETIF_DEBUG + struct netif *nif = desc->io_netif; +#endif + struct netif_driver *drv = desc->io_netif->nif_driver; + ssize_t rv; + +#ifdef NETIF_DEBUG + if (netif_debug) + printf("%s%d: netif_put\n", drv->netif_bname, nif->nif_unit); +#endif +#ifdef PARANOID + if (drv->netif_put == NULL) + panic("%s%d: no netif_put support\n", drv->netif_bname, + nif->nif_unit); +#endif + rv = drv->netif_put(desc, pkt, len); +#ifdef NETIF_DEBUG + if (netif_debug) + printf("%s%d: netif_put returning %d\n", drv->netif_bname, + nif->nif_unit, (int)rv); +#endif + return rv; +} + +struct iodesc * +socktodesc(sock) + int sock; +{ + if (sock >= SOPEN_MAX) { + errno = EBADF; + return (NULL); + } + return (&sockets[sock]); +} + +int +netif_open(machdep_hint) + void *machdep_hint; +{ + int fd; + register struct iodesc *s; + struct netif *nif; + + /* find a free socket */ + for (fd = 0, s = sockets; fd < SOPEN_MAX; fd++, s++) + if (s->io_netif == (struct netif *)0) + goto fnd; + errno = EMFILE; + return (-1); + +fnd: + bzero(s, sizeof(*s)); + netif_init(); + nif = netif_select(machdep_hint); + if (!nif) + panic("netboot: no interfaces left untried"); + if (netif_probe(nif, machdep_hint)) { + printf("netboot: couldn't probe %s%d\n", + nif->nif_driver->netif_bname, nif->nif_unit); + errno = EINVAL; + return(-1); + } + netif_attach(nif, s, machdep_hint); + + return(fd); +} + +int +netif_close(sock) + int sock; +{ + if (sock >= SOPEN_MAX) { + errno = EBADF; + return(-1); + } + netif_detach(sockets[sock].io_netif); + sockets[sock].io_netif = (struct netif *)0; + + return(0); +} Property changes on: cvs2svn/tags/initial/lib/libstand/netif.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/netif.h =================================================================== --- cvs2svn/tags/initial/lib/libstand/netif.h (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/netif.h (revision 49189) @@ -0,0 +1,65 @@ +/* $NetBSD: netif.h,v 1.4 1995/09/14 23:45:30 pk Exp $ */ + +#ifndef __SYS_LIBNETBOOT_NETIF_H +#define __SYS_LIBNETBOOT_NETIF_H +#include "iodesc.h" + +#define NENTS(x) sizeof(x)/sizeof(x[0]) + +struct netif_driver { + char *netif_bname; + int (*netif_match)(struct netif *, void *); + int (*netif_probe)(struct netif *, void *); + void (*netif_init)(struct iodesc *, void *); + int (*netif_get)(struct iodesc *, void *, size_t, time_t); + int (*netif_put)(struct iodesc *, void *, size_t); + void (*netif_end)(struct netif *); + struct netif_dif *netif_ifs; + int netif_nifs; +}; + +struct netif_dif { + int dif_unit; + int dif_nsel; + struct netif_stats *dif_stats; + void *dif_private; + /* the following fields are used internally by the netif layer */ + u_long dif_used; +}; + +struct netif_stats { + int collisions; + int collision_error; + int missed; + int sent; + int received; + int deferred; + int overflow; +}; + +struct netif { + struct netif_driver *nif_driver; + int nif_unit; + int nif_sel; + void *nif_devdata; +}; + +extern struct netif_driver *netif_drivers[]; /* machdep */ +extern int n_netif_drivers; + +extern int netif_debug; + +void netif_init(void); +struct netif *netif_select(void *); +int netif_probe(struct netif *, void *); +void netif_attach(struct netif *, struct iodesc *, void *); +void netif_detach(struct netif *); +ssize_t netif_get(struct iodesc *, void *, size_t, time_t); +ssize_t netif_put(struct iodesc *, void *, size_t); + +int netif_open(void *); +int netif_close(int); + +struct iodesc *socktodesc(int); + +#endif /* __SYS_LIBNETBOOT_NETIF_H */ Property changes on: cvs2svn/tags/initial/lib/libstand/netif.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/nfs.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/nfs.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/nfs.c (revision 49189) @@ -0,0 +1,653 @@ +/* $NetBSD: nfs.c,v 1.2 1998/01/24 12:43:09 drochner Exp $ */ + +/*- + * Copyright (c) 1993 John Brezak + * 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. 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. + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include "rpcv2.h" +#include "nfsv2.h" + +#include "stand.h" +#include "net.h" +#include "netif.h" +#include "nfs.h" +#include "rpc.h" + +#define NFS_DEBUGxx + +/* Define our own NFS attributes without NQNFS stuff. */ +struct nfsv2_fattrs { + n_long fa_type; + n_long fa_mode; + n_long fa_nlink; + n_long fa_uid; + n_long fa_gid; + n_long fa_size; + n_long fa_blocksize; + n_long fa_rdev; + n_long fa_blocks; + n_long fa_fsid; + n_long fa_fileid; + struct nfsv2_time fa_atime; + struct nfsv2_time fa_mtime; + struct nfsv2_time fa_ctime; +}; + + +struct nfs_read_args { + u_char fh[NFS_FHSIZE]; + n_long off; + n_long len; + n_long xxx; /* XXX what's this for? */ +}; + +/* Data part of nfs rpc reply (also the largest thing we receive) */ +#define NFSREAD_SIZE 1024 +struct nfs_read_repl { + n_long errno; + struct nfsv2_fattrs fa; + n_long count; + u_char data[NFSREAD_SIZE]; +}; + +#ifndef NFS_NOSYMLINK +struct nfs_readlnk_repl { + n_long errno; + n_long len; + char path[NFS_MAXPATHLEN]; +}; +#endif + +struct nfs_iodesc { + struct iodesc *iodesc; + off_t off; + u_char fh[NFS_FHSIZE]; + struct nfsv2_fattrs fa; /* all in network order */ +}; + +/* + * XXX interactions with tftp? See nfswrapper.c for a confusing + * issue. + */ +int nfs_open(char *path, struct open_file *f); +static int nfs_close(struct open_file *f); +static int nfs_read(struct open_file *f, void *buf, size_t size, size_t *resid); +static int nfs_write(struct open_file *f, void *buf, size_t size, size_t *resid); +static off_t nfs_seek(struct open_file *f, off_t offset, int where); +static int nfs_stat(struct open_file *f, struct stat *sb); + +struct fs_ops nfs_fsops = { + "nfs", nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_stat +}; + + +/* + * Fetch the root file handle (call mount daemon) + * Return zero or error number. + */ +int +nfs_getrootfh(d, path, fhp) + register struct iodesc *d; + char *path; + u_char *fhp; +{ + register int len; + struct args { + n_long len; + char path[FNAME_SIZE]; + } *args; + struct repl { + n_long errno; + u_char fh[NFS_FHSIZE]; + } *repl; + struct { + n_long h[RPC_HEADER_WORDS]; + struct args d; + } sdata; + struct { + n_long h[RPC_HEADER_WORDS]; + struct repl d; + } rdata; + size_t cc; + +#ifdef NFS_DEBUG + if (debug) + printf("nfs_getrootfh: %s\n", path); +#endif + + args = &sdata.d; + repl = &rdata.d; + + bzero(args, sizeof(*args)); + len = strlen(path); + if (len > sizeof(args->path)) + len = sizeof(args->path); + args->len = htonl(len); + bcopy(path, args->path, len); + len = 4 + roundup(len, 4); + + cc = rpc_call(d, RPCPROG_MNT, RPCMNT_VER1, RPCMNT_MOUNT, + args, len, repl, sizeof(*repl)); + if (cc == -1) { + /* errno was set by rpc_call */ + return (errno); + } + if (cc < 4) + return (EBADRPC); + if (repl->errno) + return (ntohl(repl->errno)); + bcopy(repl->fh, fhp, sizeof(repl->fh)); + return (0); +} + +/* + * Lookup a file. Store handle and attributes. + * Return zero or error number. + */ +int +nfs_lookupfh(d, name, newfd) + struct nfs_iodesc *d; + char *name; + struct nfs_iodesc *newfd; +{ + register int len, rlen; + struct args { + u_char fh[NFS_FHSIZE]; + n_long len; + char name[FNAME_SIZE]; + } *args; + struct repl { + n_long errno; + u_char fh[NFS_FHSIZE]; + struct nfsv2_fattrs fa; + } *repl; + struct { + n_long h[RPC_HEADER_WORDS]; + struct args d; + } sdata; + struct { + n_long h[RPC_HEADER_WORDS]; + struct repl d; + } rdata; + ssize_t cc; + +#ifdef NFS_DEBUG + if (debug) + printf("lookupfh: called\n"); +#endif + + args = &sdata.d; + repl = &rdata.d; + + bzero(args, sizeof(*args)); + bcopy(d->fh, args->fh, sizeof(args->fh)); + len = strlen(name); + if (len > sizeof(args->name)) + len = sizeof(args->name); + bcopy(name, args->name, len); + args->len = htonl(len); + len = 4 + roundup(len, 4); + len += NFS_FHSIZE; + + rlen = sizeof(*repl); + + cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER2, NFSPROC_LOOKUP, + args, len, repl, rlen); + if (cc == -1) + return (errno); /* XXX - from rpc_call */ + if (cc < 4) + return (EIO); + if (repl->errno) { + /* saerrno.h now matches NFS error numbers. */ + return (ntohl(repl->errno)); + } + bcopy( repl->fh, &newfd->fh, sizeof(newfd->fh)); + bcopy(&repl->fa, &newfd->fa, sizeof(newfd->fa)); + return (0); +} + +#ifndef NFS_NOSYMLINK +/* + * Get the destination of a symbolic link. + */ +int +nfs_readlink(d, buf) + struct nfs_iodesc *d; + char *buf; +{ + struct { + n_long h[RPC_HEADER_WORDS]; + u_char fh[NFS_FHSIZE]; + } sdata; + struct { + n_long h[RPC_HEADER_WORDS]; + struct nfs_readlnk_repl d; + } rdata; + ssize_t cc; + +#ifdef NFS_DEBUG + if (debug) + printf("readlink: called\n"); +#endif + + bcopy(d->fh, sdata.fh, NFS_FHSIZE); + cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER2, NFSPROC_READLINK, + sdata.fh, NFS_FHSIZE, + &rdata.d, sizeof(rdata.d)); + if (cc == -1) + return (errno); + + if (cc < 4) + return (EIO); + + if (rdata.d.errno) + return (ntohl(rdata.d.errno)); + + rdata.d.len = ntohl(rdata.d.len); + if (rdata.d.len > NFS_MAXPATHLEN) + return (ENAMETOOLONG); + + bcopy(rdata.d.path, buf, rdata.d.len); + buf[rdata.d.len] = 0; + return (0); +} +#endif + +/* + * Read data from a file. + * Return transfer count or -1 (and set errno) + */ +ssize_t +nfs_readdata(d, off, addr, len) + struct nfs_iodesc *d; + off_t off; + void *addr; + size_t len; +{ + struct nfs_read_args *args; + struct nfs_read_repl *repl; + struct { + n_long h[RPC_HEADER_WORDS]; + struct nfs_read_args d; + } sdata; + struct { + n_long h[RPC_HEADER_WORDS]; + struct nfs_read_repl d; + } rdata; + size_t cc; + long x; + int hlen, rlen; + + args = &sdata.d; + repl = &rdata.d; + + bcopy(d->fh, args->fh, NFS_FHSIZE); + args->off = htonl((n_long)off); + if (len > NFSREAD_SIZE) + len = NFSREAD_SIZE; + args->len = htonl((n_long)len); + args->xxx = htonl((n_long)0); + hlen = sizeof(*repl) - NFSREAD_SIZE; + + cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER2, NFSPROC_READ, + args, sizeof(*args), + repl, sizeof(*repl)); + if (cc == -1) { + /* errno was already set by rpc_call */ + return (-1); + } + if (cc < hlen) { + errno = EBADRPC; + return (-1); + } + if (repl->errno) { + errno = ntohl(repl->errno); + return (-1); + } + rlen = cc - hlen; + x = ntohl(repl->count); + if (rlen < x) { + printf("nfsread: short packet, %d < %ld\n", rlen, x); + errno = EBADRPC; + return(-1); + } + bcopy(repl->data, addr, x); + return (x); +} + +/* + * Open a file. + * return zero or error number + */ +int +nfs_open(path, f) + char *path; + struct open_file *f; +{ + static struct nfs_iodesc nfs_root_node; + struct iodesc *desc; + struct nfs_iodesc *currfd; +#ifndef NFS_NOSYMLINK + struct nfs_iodesc *newfd; + struct nfsv2_fattrs *fa; + register char *cp, *ncp; + register int c; + char namebuf[NFS_MAXPATHLEN + 1]; + char linkbuf[NFS_MAXPATHLEN + 1]; + int nlinks = 0; +#endif + int error; + +#ifdef NFS_DEBUG + if (debug) + printf("nfs_open: %s (rootpath=%s)\n", path, rootpath); +#endif + if (!rootpath[0]) { + printf("no rootpath, no nfs\n"); + return (ENXIO); + } + + if (!(desc = socktodesc(*(int *)(f->f_devdata)))) + return(EINVAL); + + /* Bind to a reserved port. */ + desc->myport = htons(--rpc_port); + desc->destip = rootip; + if ((error = nfs_getrootfh(desc, rootpath, nfs_root_node.fh))) + return (error); + nfs_root_node.iodesc = desc; + +#ifndef NFS_NOSYMLINK + /* Fake up attributes for the root dir. */ + fa = &nfs_root_node.fa; + fa->fa_type = htonl(NFDIR); + fa->fa_mode = htonl(0755); + fa->fa_nlink = htonl(2); + + currfd = &nfs_root_node; + newfd = 0; + + cp = path; + while (*cp) { + /* + * Remove extra separators + */ + while (*cp == '/') + cp++; + + if (*cp == '\0') + break; + /* + * Check that current node is a directory. + */ + if (currfd->fa.fa_type != htonl(NFDIR)) { + error = ENOTDIR; + goto out; + } + + /* allocate file system specific data structure */ + newfd = malloc(sizeof(*newfd)); + newfd->iodesc = currfd->iodesc; + newfd->off = 0; + + /* + * Get next component of path name. + */ + { + register int len = 0; + + ncp = cp; + while ((c = *cp) != '\0' && c != '/') { + if (++len > NFS_MAXNAMLEN) { + error = ENOENT; + goto out; + } + cp++; + } + *cp = '\0'; + } + + /* lookup a file handle */ + error = nfs_lookupfh(currfd, ncp, newfd); + *cp = c; + if (error) + goto out; + + /* + * Check for symbolic link + */ + if (newfd->fa.fa_type == htonl(NFLNK)) { + int link_len, len; + + error = nfs_readlink(newfd, linkbuf); + if (error) + goto out; + + link_len = strlen(linkbuf); + len = strlen(cp); + + if (link_len + len > MAXPATHLEN + || ++nlinks > MAXSYMLINKS) { + error = ENOENT; + goto out; + } + + bcopy(cp, &namebuf[link_len], len + 1); + bcopy(linkbuf, namebuf, link_len); + + /* + * If absolute pathname, restart at root. + * If relative pathname, restart at parent directory. + */ + cp = namebuf; + if (*cp == '/') { + if (currfd != &nfs_root_node) + free(currfd); + currfd = &nfs_root_node; + } + + free(newfd); + newfd = 0; + + continue; + } + + if (currfd != &nfs_root_node) + free(currfd); + currfd = newfd; + newfd = 0; + } + + error = 0; + +out: + if (newfd) + free(newfd); +#else + /* allocate file system specific data structure */ + currfd = malloc(sizeof(*currfd)); + currfd->iodesc = desc; + currfd->off = 0; + + error = nfs_lookupfh(&nfs_root_node, path, currfd); +#endif + if (!error) { + f->f_fsdata = (void *)currfd; + return (0); + } + +#ifdef NFS_DEBUG + if (debug) + printf("nfs_open: %s lookupfh failed: %s\n", + path, strerror(error)); +#endif +#ifndef NFS_NOSYMLINK + if (currfd != &nfs_root_node) +#endif + free(currfd); + + return (error); +} + +int +nfs_close(f) + struct open_file *f; +{ + register struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata; + +#ifdef NFS_DEBUG + if (debug) + printf("nfs_close: fp=0x%lx\n", (u_long)fp); +#endif + + if (fp) + free(fp); + f->f_fsdata = (void *)0; + + return (0); +} + +/* + * read a portion of a file + */ +int +nfs_read(f, buf, size, resid) + struct open_file *f; + void *buf; + size_t size; + size_t *resid; /* out */ +{ + register struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata; + register ssize_t cc; + register char *addr = buf; + +#ifdef NFS_DEBUG + if (debug) + printf("nfs_read: size=%lu off=%d\n", (u_long)size, + (int)fp->off); +#endif + while ((int)size > 0) { + twiddle(); + cc = nfs_readdata(fp, fp->off, (void *)addr, size); + /* XXX maybe should retry on certain errors */ + if (cc == -1) { +#ifdef NFS_DEBUG + if (debug) + printf("nfs_read: read: %s", strerror(errno)); +#endif + return (errno); /* XXX - from nfs_readdata */ + } + if (cc == 0) { +#ifdef NFS_DEBUG + if (debug) + printf("nfs_read: hit EOF unexpectantly"); +#endif + goto ret; + } + fp->off += cc; + addr += cc; + size -= cc; + } +ret: + if (resid) + *resid = size; + + return (0); +} + +/* + * Not implemented. + */ +int +nfs_write(f, buf, size, resid) + struct open_file *f; + void *buf; + size_t size; + size_t *resid; /* out */ +{ + return (EROFS); +} + +off_t +nfs_seek(f, offset, where) + struct open_file *f; + off_t offset; + int where; +{ + register struct nfs_iodesc *d = (struct nfs_iodesc *)f->f_fsdata; + n_long size = ntohl(d->fa.fa_size); + + switch (where) { + case SEEK_SET: + d->off = offset; + break; + case SEEK_CUR: + d->off += offset; + break; + case SEEK_END: + d->off = size - offset; + break; + default: + return (-1); + } + + return (d->off); +} + +/* NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5 */ +int nfs_stat_types[8] = { + 0, S_IFREG, S_IFDIR, S_IFBLK, S_IFCHR, S_IFLNK, 0 }; + +int +nfs_stat(f, sb) + struct open_file *f; + struct stat *sb; +{ + struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata; + register n_long ftype, mode; + + ftype = ntohl(fp->fa.fa_type); + mode = ntohl(fp->fa.fa_mode); + mode |= nfs_stat_types[ftype & 7]; + + sb->st_mode = mode; + sb->st_nlink = ntohl(fp->fa.fa_nlink); + sb->st_uid = ntohl(fp->fa.fa_uid); + sb->st_gid = ntohl(fp->fa.fa_gid); + sb->st_size = ntohl(fp->fa.fa_size); + + return (0); +} Property changes on: cvs2svn/tags/initial/lib/libstand/nfs.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/nfs.h =================================================================== --- cvs2svn/tags/initial/lib/libstand/nfs.h (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/nfs.h (revision 49189) @@ -0,0 +1,37 @@ +/* $NetBSD: nfs.h,v 1.5 1996/07/10 18:32:33 cgd Exp $ */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + */ + +extern int nfs_open(char *path, struct open_file *f); /* XXX for nfswrapper */ + Property changes on: cvs2svn/tags/initial/lib/libstand/nfs.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/nfsv2.h =================================================================== --- cvs2svn/tags/initial/lib/libstand/nfsv2.h (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/nfsv2.h (revision 49189) @@ -0,0 +1,166 @@ +/* $NetBSD: nfsv2.h,v 1.2 1996/02/26 23:05:23 gwr Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Rick Macklem at The University of Guelph. + * + * 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)nfsv2.h 8.1 (Berkeley) 6/10/93 + */ + +/* + * nfs definitions as per the version 2 specs + */ + +/* + * Constants as defined in the Sun NFS Version 2 spec. + * "NFS: Network File System Protocol Specification" RFC1094 + */ + +#define NFS_PORT 2049 +#define NFS_PROG 100003 +#define NFS_VER2 2 +#define NFS_MAXDGRAMDATA 8192 +#define NFS_MAXDATA 32768 +#define NFS_MAXPATHLEN 1024 +#define NFS_MAXNAMLEN 255 +#define NFS_FHSIZE 32 +#define NFS_MAXPKTHDR 404 +#define NFS_MAXPACKET (NFS_MAXPKTHDR+NFS_MAXDATA) +#define NFS_MINPACKET 20 +#define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */ + +/* Stat numbers for rpc returns */ +#define NFS_OK 0 +#define NFSERR_PERM 1 +#define NFSERR_NOENT 2 +#define NFSERR_IO 5 +#define NFSERR_NXIO 6 +#define NFSERR_ACCES 13 +#define NFSERR_EXIST 17 +#define NFSERR_NODEV 19 +#define NFSERR_NOTDIR 20 +#define NFSERR_ISDIR 21 +#define NFSERR_FBIG 27 +#define NFSERR_NOSPC 28 +#define NFSERR_ROFS 30 +#define NFSERR_NAMETOL 63 +#define NFSERR_NOTEMPTY 66 +#define NFSERR_DQUOT 69 +#define NFSERR_STALE 70 +#define NFSERR_WFLUSH 99 + +/* Sizes in bytes of various nfs rpc components */ +#define NFSX_FH 32 +#define NFSX_UNSIGNED 4 +#define NFSX_FATTR 68 +#define NFSX_SATTR 32 +#define NFSX_STATFS 20 +#define NFSX_COOKIE 4 + +/* nfs rpc procedure numbers */ +#define NFSPROC_NULL 0 +#define NFSPROC_GETATTR 1 +#define NFSPROC_SETATTR 2 +#define NFSPROC_NOOP 3 +#define NFSPROC_ROOT NFSPROC_NOOP /* Obsolete */ +#define NFSPROC_LOOKUP 4 +#define NFSPROC_READLINK 5 +#define NFSPROC_READ 6 +#define NFSPROC_WRITECACHE NFSPROC_NOOP /* Obsolete */ +#define NFSPROC_WRITE 8 +#define NFSPROC_CREATE 9 +#define NFSPROC_REMOVE 10 +#define NFSPROC_RENAME 11 +#define NFSPROC_LINK 12 +#define NFSPROC_SYMLINK 13 +#define NFSPROC_MKDIR 14 +#define NFSPROC_RMDIR 15 +#define NFSPROC_READDIR 16 +#define NFSPROC_STATFS 17 + +#define NFS_NPROCS 18 + + +/* File types */ +typedef enum { + NFNON=0, + NFREG=1, + NFDIR=2, + NFBLK=3, + NFCHR=4, + NFLNK=5 +} nfstype; + +/* Structs for common parts of the rpc's */ +struct nfsv2_time { + n_long nfs_sec; + n_long nfs_usec; +}; + +/* + * File attributes and setable attributes. + */ +struct nfsv2_fattr { + n_long fa_type; + n_long fa_mode; + n_long fa_nlink; + n_long fa_uid; + n_long fa_gid; + n_long fa_size; + n_long fa_blocksize; + n_long fa_rdev; + n_long fa_blocks; + n_long fa_fsid; + n_long fa_fileid; + struct nfsv2_time fa_atime; + struct nfsv2_time fa_mtime; + struct nfsv2_time fa_ctime; +}; + +struct nfsv2_sattr { + n_long sa_mode; + n_long sa_uid; + n_long sa_gid; + n_long sa_size; + struct nfsv2_time sa_atime; + struct nfsv2_time sa_mtime; +}; + +struct nfsv2_statfs { + n_long sf_tsize; + n_long sf_bsize; + n_long sf_blocks; + n_long sf_bfree; + n_long sf_bavail; +}; Property changes on: cvs2svn/tags/initial/lib/libstand/nfsv2.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/nullfs.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/nullfs.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/nullfs.c (revision 49189) @@ -0,0 +1,105 @@ +/* $NetBSD: nullfs.c,v 1.1 1996/01/13 22:25:39 leo Exp $ */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * The Mach Operating System project at Carnegie-Mellon University. + * + * 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)open.c 8.1 (Berkeley) 6/11/93 + * + * + * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University + * All Rights Reserved. + * + * Author: Alessandro Forin + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include "stand.h" + +/* + * Null filesystem + */ +int null_open (char *path, struct open_file *f) +{ + errno = EIO; + return -1; +} + +int null_close(struct open_file *f) +{ + return 0; +} + +ssize_t null_read (struct open_file *f, void *buf, size_t size, size_t *resid) +{ + errno = EIO; + return -1; +} + +ssize_t null_write (struct open_file *f, void *buf, size_t size, size_t *resid) +{ + errno = EIO; + return -1; +} + +off_t null_seek (struct open_file *f, off_t offset, int where) +{ + errno = EIO; + return -1; +} + +int null_stat (struct open_file *f, struct stat *sb) +{ + errno = EIO; + return -1; +} Property changes on: cvs2svn/tags/initial/lib/libstand/nullfs.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/open.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/open.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/open.c (revision 49189) @@ -0,0 +1,137 @@ +/* $NetBSD: open.c,v 1.16 1997/01/28 09:41:03 pk Exp $ */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * The Mach Operating System project at Carnegie-Mellon University. + * + * 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)open.c 8.1 (Berkeley) 6/11/93 + * + * + * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University + * All Rights Reserved. + * + * Author: Alessandro Forin + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include "stand.h" + +struct open_file files[SOPEN_MAX]; + +static int +o_gethandle(void) +{ + int fd; + + for (fd = 0; fd < SOPEN_MAX; fd++) + if (files[fd].f_flags == 0) + return(fd); + return(-1); +} + + +int +open(const char *fname, int mode) +{ + struct open_file *f; + int fd, i, error, besterror; + char *file; + + if ((fd = o_gethandle()) == -1) { + errno = EMFILE; + return(-1); + } + + f = &files[fd]; + f->f_flags = mode + 1; + f->f_dev = (struct devsw *)0; + f->f_ops = (struct fs_ops *)0; + f->f_offset = 0; + f->f_devdata = NULL; + file = (char *)0; + error = devopen(f, fname, &file); + if (error || + (((f->f_flags & F_NODEV) == 0) && f->f_dev == (struct devsw *)0)) + goto err; + + /* see if we opened a raw device; otherwise, 'file' is the file name. */ + if (file == (char *)0 || *file == '\0') { + f->f_flags |= F_RAW; + return (fd); + } + + /* pass file name to the different filesystem open routines */ + besterror = ENOENT; + for (i = 0; file_system[i] != NULL; i++) { + + error = ((*file_system[i]).fo_open)(file, f); + if (error == 0) { + + f->f_ops = file_system[i]; + return (fd); + } + if (error != EINVAL) + besterror = error; + } + error = besterror; + + if ((f->f_flags & F_NODEV) == 0) + f->f_dev->dv_close(f); + if (error) + devclose(f); + + err: + f->f_flags = 0; + errno = error; + return (-1); +} Property changes on: cvs2svn/tags/initial/lib/libstand/open.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/pager.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/pager.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/pager.c (revision 49189) @@ -0,0 +1,162 @@ +/*- + * Copyright (c) 1998 Michael Smith + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ +/* + * Simple paged-output and paged-viewing functions + */ + +#include "stand.h" +#include + +static int p_maxlines = -1; +static int p_freelines; + +static char *pager_prompt1 = " --more-- page down line down quit "; +static char *pager_blank = " "; + +/* + * 'open' the pager + */ +void +pager_open(void) +{ + int nlines; + char *cp, *lp; + + nlines = 24; /* sensible default */ + if ((cp = getenv("LINES")) != NULL) { + nlines = strtol(cp, &lp, 0); + } + + p_maxlines = nlines - 1; + if (p_maxlines < 1) + p_maxlines = 1; + p_freelines = p_maxlines; +} + +/* + * 'close' the pager + */ +void +pager_close(void) +{ + p_maxlines = -1; +} + +/* + * Emit lines to the pager; may not return until the user + * has responded to the prompt. + * + * Will return nonzero if the user enters 'q' or 'Q' at the prompt. + * + * XXX note that this watches outgoing newlines (and eats them), but + * does not handle wrap detection (req. count of columns). + */ + +int +pager_output(const char *cp) +{ + int action; + + if (cp == NULL) + return(0); + + for (;;) { + if (*cp == 0) + return(0); + + putchar(*cp); /* always emit character */ + + if (*(cp++) == '\n') { /* got a newline? */ + p_freelines--; + if (p_freelines <= 0) { + printf(pager_prompt1); + action = 0; + while (action == 0) { + switch(getchar()) { + case '\r': + case '\n': + p_freelines = 1; + action = 1; + break; + case ' ': + p_freelines = p_maxlines; + action = 1; + break; + case 'q': + case 'Q': + action = 2; + break; + default: + break; + } + } + printf("\r%s\r", pager_blank); + if (action == 2) + return(1); + } + } + } +} + +/* + * Display from (fd). + */ +int +pager_file(char *fname) +{ + char buf[80]; + size_t hmuch; + int fd; + int result; + + if ((fd = open(fname, O_RDONLY)) == -1) { + printf("can't open '%s': %s\n", fname, strerror(errno)); + return(-1); + } + + pager_open(); + for (;;) { + hmuch = read(fd, buf, sizeof(buf) - 1); + if (hmuch == -1) { + result = -1; + break; + } + if (hmuch == 0) { + result = 0; + break; + } + buf[hmuch] = 0; + if (pager_output(buf)) { + result = 1; + break; + } + } + pager_close(); + close(fd); + return(result); +} Property changes on: cvs2svn/tags/initial/lib/libstand/pager.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/printf.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/printf.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/printf.c (revision 49189) @@ -0,0 +1,355 @@ +/*- + * Copyright (c) 1986, 1988, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)subr_prf.c 8.3 (Berkeley) 1/21/94 + * $Id: subr_prf.c,v 1.46 1998/05/28 09:30:20 phk Exp $ + */ + +/* + * Standaloneified version of the FreeBSD kernel printf family. + */ + +#include +#include "stand.h" + +/* + * Note that stdarg.h and the ANSI style va_start macro is used for both + * ANSI and traditional C compilers. + */ +#include + +static char *ksprintn (u_long num, int base, int *len); +static int kvprintf(char const *fmt, void (*func)(int), void *arg, int radix, va_list ap); + +int +printf(const char *fmt, ...) +{ + va_list ap; + int retval; + + va_start(ap, fmt); + retval = kvprintf(fmt, putchar, NULL, 10, ap); + va_end(ap); + return retval; +} + +void +vprintf(const char *fmt, va_list ap) +{ + + kvprintf(fmt, putchar, NULL, 10, ap); +} + +/* + * Scaled down version of sprintf(3). + */ +int +sprintf(char *buf, const char *cfmt, ...) +{ + int retval; + va_list ap; + + va_start(ap, cfmt); + retval = kvprintf(cfmt, NULL, (void *)buf, 10, ap); + buf[retval] = '\0'; + va_end(ap); + return retval; +} + +/* + * Put a number (base <= 16) in a buffer in reverse order; return an + * optional length and a pointer to the NULL terminated (preceded?) + * buffer. + */ +static char * +ksprintn(ul, base, lenp) + register u_long ul; + register int base, *lenp; +{ /* A long in base 8, plus NULL. */ + static char buf[sizeof(long) * NBBY / 3 + 2]; + register char *p; + + p = buf; + do { + *++p = hex2ascii(ul % base); + } while (ul /= base); + if (lenp) + *lenp = p - buf; + return (p); +} + +/* + * Scaled down version of printf(3). + * + * Two additional formats: + * + * The format %b is supported to decode error registers. + * Its usage is: + * + * printf("reg=%b\n", regval, "*"); + * + * where is the output base expressed as a control character, e.g. + * \10 gives octal; \20 gives hex. Each arg is a sequence of characters, + * the first of which gives the bit number to be inspected (origin 1), and + * the next characters (up to a control character, i.e. a character <= 32), + * give the name of the register. Thus: + * + * kvprintf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n"); + * + * would produce output: + * + * reg=3 + * + * XXX: %D -- Hexdump, takes pointer and separator string: + * ("%6D", ptr, ":") -> XX:XX:XX:XX:XX:XX + * ("%*D", len, ptr, " " -> XX XX XX XX ... + */ +static int +kvprintf(char const *fmt, void (*func)(int), void *arg, int radix, va_list ap) +{ +#define PCHAR(c) {int cc=(c); if (func) (*func)(cc); else *d++ = cc; retval++; } + char *p, *q, *d; + u_char *up; + int ch, n; + u_long ul; + int base, lflag, tmp, width, ladjust, sharpflag, neg, sign, dot; + int dwidth; + char padc; + int retval = 0; + + if (!func) + d = (char *) arg; + else + d = NULL; + + if (fmt == NULL) + fmt = "(fmt null)\n"; + + if (radix < 2 || radix > 36) + radix = 10; + + for (;;) { + padc = ' '; + width = 0; + while ((ch = (u_char)*fmt++) != '%') { + if (ch == '\0') + return retval; + PCHAR(ch); + } + lflag = 0; ladjust = 0; sharpflag = 0; neg = 0; + sign = 0; dot = 0; dwidth = 0; +reswitch: switch (ch = (u_char)*fmt++) { + case '.': + dot = 1; + goto reswitch; + case '#': + sharpflag = 1; + goto reswitch; + case '+': + sign = 1; + goto reswitch; + case '-': + ladjust = 1; + goto reswitch; + case '%': + PCHAR(ch); + break; + case '*': + if (!dot) { + width = va_arg(ap, int); + if (width < 0) { + ladjust = !ladjust; + width = -width; + } + } else { + dwidth = va_arg(ap, int); + } + goto reswitch; + case '0': + if (!dot) { + padc = '0'; + goto reswitch; + } + case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + for (n = 0;; ++fmt) { + n = n * 10 + ch - '0'; + ch = *fmt; + if (ch < '0' || ch > '9') + break; + } + if (dot) + dwidth = n; + else + width = n; + goto reswitch; + case 'b': + ul = va_arg(ap, int); + p = va_arg(ap, char *); + for (q = ksprintn(ul, *p++, NULL); *q;) + PCHAR(*q--); + + if (!ul) + break; + + for (tmp = 0; *p;) { + n = *p++; + if (ul & (1 << (n - 1))) { + PCHAR(tmp ? ',' : '<'); + for (; (n = *p) > ' '; ++p) + PCHAR(n); + tmp = 1; + } else + for (; *p > ' '; ++p) + continue; + } + if (tmp) + PCHAR('>'); + break; + case 'c': + PCHAR(va_arg(ap, int)); + break; + case 'D': + up = va_arg(ap, u_char *); + p = va_arg(ap, char *); + if (!width) + width = 16; + while(width--) { + PCHAR(hex2ascii(*up >> 4)); + PCHAR(hex2ascii(*up & 0x0f)); + up++; + if (width) + for (q=p;*q;q++) + PCHAR(*q); + } + break; + case 'd': + ul = lflag ? va_arg(ap, long) : va_arg(ap, int); + sign = 1; + base = 10; + goto number; + case 'l': + lflag = 1; + goto reswitch; + case 'n': + ul = lflag ? va_arg(ap, u_long) : va_arg(ap, u_int); + base = radix; + goto number; + case 'o': + ul = lflag ? va_arg(ap, u_long) : va_arg(ap, u_int); + base = 8; + goto number; + case 'p': + ul = (u_long)va_arg(ap, void *); + base = 16; + sharpflag = 1; + goto number; + case 's': + p = va_arg(ap, char *); + if (p == NULL) + p = "(null)"; + if (!dot) + n = strlen (p); + else + for (n = 0; n < dwidth && p[n]; n++) + continue; + + width -= n; + + if (!ladjust && width > 0) + while (width--) + PCHAR(padc); + while (n--) + PCHAR(*p++); + if (ladjust && width > 0) + while (width--) + PCHAR(padc); + break; + case 'u': + ul = lflag ? va_arg(ap, u_long) : va_arg(ap, u_int); + base = 10; + goto number; + case 'x': + ul = lflag ? va_arg(ap, u_long) : va_arg(ap, u_int); + base = 16; +number: if (sign && (long)ul < 0L) { + neg = 1; + ul = -(long)ul; + } + p = ksprintn(ul, base, &tmp); + if (sharpflag && ul != 0) { + if (base == 8) + tmp++; + else if (base == 16) + tmp += 2; + } + if (neg) + tmp++; + + if (!ladjust && width && (width -= tmp) > 0) + while (width--) + PCHAR(padc); + if (neg) + PCHAR('-'); + if (sharpflag && ul != 0) { + if (base == 8) { + PCHAR('0'); + } else if (base == 16) { + PCHAR('0'); + PCHAR('x'); + } + } + + while (*p) + PCHAR(*p--); + + if (ladjust && width && (width -= tmp) > 0) + while (width--) + PCHAR(padc); + + break; + default: + PCHAR('%'); + if (lflag) + PCHAR('l'); + PCHAR(ch); + break; + } + } +#undef PCHAR +} + Property changes on: cvs2svn/tags/initial/lib/libstand/printf.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/random.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/random.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/random.c (revision 49189) @@ -0,0 +1,72 @@ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)random.c 8.1 (Berkeley) 6/10/93 + * $Id: random.c,v 1.6 1997/02/22 09:39:59 peter Exp $ + */ + +#include + +static u_long randseed = 1; + +void +srandom(seed) + u_long seed; +{ + randseed = seed; +} + +/* + * Pseudo-random number generator for randomizing the profiling clock, + * and whatever else we might use it for. The result is uniform on + * [0, 2^31 - 1]. + */ +u_long +random() +{ + register long x, hi, lo, t; + + /* + * Compute x[n + 1] = (7^5 * x[n]) mod (2^31 - 1). + * From "Random number generators: good ones are hard to find", + * Park and Miller, Communications of the ACM, vol. 31, no. 10, + * October 1988, p. 1195. + */ + x = randseed; + hi = x / 127773; + lo = x % 127773; + t = 16807 * lo - 2836 * hi; + if (t <= 0) + t += 0x7fffffff; + randseed = t; + return (t); +} Property changes on: cvs2svn/tags/initial/lib/libstand/random.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/rarp.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/rarp.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/rarp.c (revision 49189) @@ -0,0 +1,225 @@ +/* $NetBSD: rarp.c,v 1.16 1997/07/07 15:52:52 drochner Exp $ */ + +/* + * Copyright (c) 1992 Regents of the University of California. + * All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * 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 by the University of + * California, Lawrence Berkeley Laboratory and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#) Header: arp.c,v 1.5 93/07/15 05:52:26 leres Exp (LBL) + */ +#include +#include +#include +#include +#include + +#include + +#include + +#include "stand.h" +#include "net.h" +#include "netif.h" + + +static ssize_t rarpsend(struct iodesc *, void *, size_t); +static ssize_t rarprecv(struct iodesc *, void *, size_t, time_t); + +/* + * Ethernet (Reverse) Address Resolution Protocol (see RFC 903, and 826). + */ +int +rarp_getipaddress(sock) + int sock; +{ + struct iodesc *d; + register struct ether_arp *ap; + struct { + u_char header[ETHER_SIZE]; + struct { + struct ether_arp arp; + u_char pad[18]; /* 60 - sizeof(arp) */ + } data; + } wbuf; + struct { + u_char header[ETHER_SIZE]; + struct { + struct ether_arp arp; + u_char pad[24]; /* extra space */ + } data; + } rbuf; + +#ifdef RARP_DEBUG + if (debug) + printf("rarp: socket=%d\n", sock); +#endif + if (!(d = socktodesc(sock))) { + printf("rarp: bad socket. %d\n", sock); + return (-1); + } +#ifdef RARP_DEBUG + if (debug) + printf("rarp: d=%x\n", (u_int)d); +#endif + + bzero((char*)&wbuf.data, sizeof(wbuf.data)); + ap = &wbuf.data.arp; + ap->arp_hrd = htons(ARPHRD_ETHER); + ap->arp_pro = htons(ETHERTYPE_IP); + ap->arp_hln = sizeof(ap->arp_sha); /* hardware address length */ + ap->arp_pln = sizeof(ap->arp_spa); /* protocol address length */ + ap->arp_op = htons(ARPOP_REVREQUEST); + bcopy(d->myea, ap->arp_sha, 6); + bcopy(d->myea, ap->arp_tha, 6); + + if (sendrecv(d, + rarpsend, &wbuf.data, sizeof(wbuf.data), + rarprecv, &rbuf.data, sizeof(rbuf.data)) < 0) + { + printf("No response for RARP request\n"); + return (-1); + } + + ap = &rbuf.data.arp; + bcopy(ap->arp_tpa, (char *)&myip, sizeof(myip)); +#if 0 + /* XXX - Can NOT assume this is our root server! */ + bcopy(ap->arp_spa, (char *)&rootip, sizeof(rootip)); +#endif + + /* Compute our "natural" netmask. */ + if (IN_CLASSA(myip.s_addr)) + netmask = IN_CLASSA_NET; + else if (IN_CLASSB(myip.s_addr)) + netmask = IN_CLASSB_NET; + else + netmask = IN_CLASSC_NET; + + d->myip = myip; + return (0); +} + +/* + * Broadcast a RARP request (i.e. who knows who I am) + */ +static ssize_t +rarpsend(d, pkt, len) + register struct iodesc *d; + register void *pkt; + register size_t len; +{ + +#ifdef RARP_DEBUG + if (debug) + printf("rarpsend: called\n"); +#endif + + return (sendether(d, pkt, len, bcea, ETHERTYPE_REVARP)); +} + +/* + * Returns 0 if this is the packet we're waiting for + * else -1 (and errno == 0) + */ +static ssize_t +rarprecv(d, pkt, len, tleft) + register struct iodesc *d; + register void *pkt; + register size_t len; + time_t tleft; +{ + register ssize_t n; + register struct ether_arp *ap; + u_int16_t etype; /* host order */ + +#ifdef RARP_DEBUG + if (debug) + printf("rarprecv: "); +#endif + + n = readether(d, pkt, len, tleft, &etype); + errno = 0; /* XXX */ + if (n == -1 || n < sizeof(struct ether_arp)) { +#ifdef RARP_DEBUG + if (debug) + printf("bad len=%d\n", n); +#endif + return (-1); + } + + if (etype != ETHERTYPE_REVARP) { +#ifdef RARP_DEBUG + if (debug) + printf("bad type=0x%x\n", etype); +#endif + return (-1); + } + + ap = (struct ether_arp *)pkt; + if (ap->arp_hrd != htons(ARPHRD_ETHER) || + ap->arp_pro != htons(ETHERTYPE_IP) || + ap->arp_hln != sizeof(ap->arp_sha) || + ap->arp_pln != sizeof(ap->arp_spa) ) + { +#ifdef RARP_DEBUG + if (debug) + printf("bad hrd/pro/hln/pln\n"); +#endif + return (-1); + } + + if (ap->arp_op != htons(ARPOP_REVREPLY)) { +#ifdef RARP_DEBUG + if (debug) + printf("bad op=0x%x\n", ntohs(ap->arp_op)); +#endif + return (-1); + } + + /* Is the reply for our Ethernet address? */ + if (bcmp(ap->arp_tha, d->myea, 6)) { +#ifdef RARP_DEBUG + if (debug) + printf("unwanted address\n"); +#endif + return (-1); + } + + /* We have our answer. */ +#ifdef RARP_DEBUG + if (debug) + printf("got it\n"); +#endif + return (n); +} Property changes on: cvs2svn/tags/initial/lib/libstand/rarp.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/read.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/read.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/read.c (revision 49189) @@ -0,0 +1,96 @@ +/* $NetBSD: read.c,v 1.8 1997/01/22 00:38:12 cgd Exp $ */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * The Mach Operating System project at Carnegie-Mellon University. + * + * 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)read.c 8.1 (Berkeley) 6/11/93 + * + * + * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University + * All Rights Reserved. + * + * Author: Alessandro Forin + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include +#include "stand.h" + +ssize_t +read(fd, dest, bcount) + int fd; + void *dest; + size_t bcount; +{ + register struct open_file *f = &files[fd]; + size_t resid; + + if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_READ)) { + errno = EBADF; + return (-1); + } + if (f->f_flags & F_RAW) { + twiddle(); + errno = (f->f_dev->dv_strategy)(f->f_devdata, F_READ, + btodb(f->f_offset), bcount, dest, &resid); + if (errno) + return (-1); + f->f_offset += resid; + return (resid); + } + resid = bcount; + if ((errno = (f->f_ops->fo_read)(f, dest, bcount, &resid))) + return (-1); + return (ssize_t)(bcount - resid); +} Property changes on: cvs2svn/tags/initial/lib/libstand/read.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/rpc.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/rpc.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/rpc.c (revision 49189) @@ -0,0 +1,440 @@ +/* $NetBSD: rpc.c,v 1.18 1998/01/23 19:27:45 thorpej Exp $ */ + +/* + * Copyright (c) 1992 Regents of the University of California. + * All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * 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 by the University of + * California, Lawrence Berkeley Laboratory and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#) Header: rpc.c,v 1.12 93/09/28 08:31:56 leres Exp (LBL) + */ + +/* + * RPC functions used by NFS and bootparams. + * Note that bootparams requires the ability to find out the + * address of the server from which its response has come. + * This is supported by keeping the IP/UDP headers in the + * buffer space provided by the caller. (See rpc_fromaddr) + */ + +#include +#include + +#include +#include + +#include + +#include "rpcv2.h" + +#include "stand.h" +#include "net.h" +#include "netif.h" +#include "rpc.h" + +struct auth_info { + int32_t authtype; /* auth type */ + u_int32_t authlen; /* auth length */ +}; + +struct auth_unix { + int32_t ua_time; + int32_t ua_hostname; /* null */ + int32_t ua_uid; + int32_t ua_gid; + int32_t ua_gidlist; /* null */ +}; + +struct rpc_call { + u_int32_t rp_xid; /* request transaction id */ + int32_t rp_direction; /* call direction (0) */ + u_int32_t rp_rpcvers; /* rpc version (2) */ + u_int32_t rp_prog; /* program */ + u_int32_t rp_vers; /* version */ + u_int32_t rp_proc; /* procedure */ +}; + +struct rpc_reply { + u_int32_t rp_xid; /* request transaction id */ + int32_t rp_direction; /* call direction (1) */ + int32_t rp_astatus; /* accept status (0: accepted) */ + union { + u_int32_t rpu_errno; + struct { + struct auth_info rok_auth; + u_int32_t rok_status; + } rpu_rok; + } rp_u; +}; + +/* Local forwards */ +static ssize_t recvrpc(struct iodesc *, void *, size_t, time_t); +static int rpc_getport(struct iodesc *, n_long, n_long); + +int rpc_xid; +int rpc_port = 0x400; /* predecrement */ + +/* + * Make a rpc call; return length of answer + * Note: Caller must leave room for headers. + */ +ssize_t +rpc_call(d, prog, vers, proc, sdata, slen, rdata, rlen) + register struct iodesc *d; + register n_long prog, vers, proc; + register void *sdata; + register size_t slen; + register void *rdata; + register size_t rlen; +{ + register ssize_t cc; + struct auth_info *auth; + struct rpc_call *call; + struct rpc_reply *reply; + char *send_head, *send_tail; + char *recv_head, *recv_tail; + n_long x; + int port; /* host order */ + +#ifdef RPC_DEBUG + if (debug) + printf("rpc_call: prog=0x%x vers=%d proc=%d\n", + prog, vers, proc); +#endif + + port = rpc_getport(d, prog, vers); + if (port == -1) + return (-1); + + d->destport = htons(port); + + /* + * Prepend authorization stuff and headers. + * Note, must prepend things in reverse order. + */ + send_head = sdata; + send_tail = (char *)sdata + slen; + + /* Auth verifier is always auth_null */ + send_head -= sizeof(*auth); + auth = (struct auth_info *)send_head; + auth->authtype = htonl(RPCAUTH_NULL); + auth->authlen = 0; + +#if 1 + /* Auth credentials: always auth unix (as root) */ + send_head -= sizeof(struct auth_unix); + bzero(send_head, sizeof(struct auth_unix)); + send_head -= sizeof(*auth); + auth = (struct auth_info *)send_head; + auth->authtype = htonl(RPCAUTH_UNIX); + auth->authlen = htonl(sizeof(struct auth_unix)); +#else + /* Auth credentials: always auth_null (XXX OK?) */ + send_head -= sizeof(*auth); + auth = send_head; + auth->authtype = htonl(RPCAUTH_NULL); + auth->authlen = 0; +#endif + + /* RPC call structure. */ + send_head -= sizeof(*call); + call = (struct rpc_call *)send_head; + rpc_xid++; + call->rp_xid = htonl(rpc_xid); + call->rp_direction = htonl(RPC_CALL); + call->rp_rpcvers = htonl(RPC_VER2); + call->rp_prog = htonl(prog); + call->rp_vers = htonl(vers); + call->rp_proc = htonl(proc); + + /* Make room for the rpc_reply header. */ + recv_head = rdata; + recv_tail = (char *)rdata + rlen; + recv_head -= sizeof(*reply); + + cc = sendrecv(d, + sendudp, send_head, send_tail - send_head, + recvrpc, recv_head, recv_tail - recv_head); + +#ifdef RPC_DEBUG + if (debug) + printf("callrpc: cc=%ld rlen=%lu\n", (long)cc, (u_long)rlen); +#endif + if (cc == -1) + return (-1); + + if (cc <= sizeof(*reply)) { + errno = EBADRPC; + return (-1); + } + + recv_tail = recv_head + cc; + + /* + * Check the RPC reply status. + * The xid, dir, astatus were already checked. + */ + reply = (struct rpc_reply *)recv_head; + auth = &reply->rp_u.rpu_rok.rok_auth; + x = ntohl(auth->authlen); + if (x != 0) { +#ifdef RPC_DEBUG + if (debug) + printf("callrpc: reply auth != NULL\n"); +#endif + errno = EBADRPC; + return(-1); + } + x = ntohl(reply->rp_u.rpu_rok.rok_status); + if (x != 0) { + printf("callrpc: error = %ld\n", (long)x); + errno = EBADRPC; + return(-1); + } + recv_head += sizeof(*reply); + + return (ssize_t)(recv_tail - recv_head); +} + +/* + * Returns true if packet is the one we're waiting for. + * This just checks the XID, direction, acceptance. + * Remaining checks are done by callrpc + */ +static ssize_t +recvrpc(d, pkt, len, tleft) + register struct iodesc *d; + register void *pkt; + register size_t len; + time_t tleft; +{ + register struct rpc_reply *reply; + ssize_t n; + int x; + + errno = 0; +#ifdef RPC_DEBUG + if (debug) + printf("recvrpc: called len=%lu\n", (u_long)len); +#endif + + n = readudp(d, pkt, len, tleft); + if (n <= (4 * 4)) + return -1; + + reply = (struct rpc_reply *)pkt; + + x = ntohl(reply->rp_xid); + if (x != rpc_xid) { +#ifdef RPC_DEBUG + if (debug) + printf("recvrpc: rp_xid %d != xid %d\n", x, rpc_xid); +#endif + return -1; + } + + x = ntohl(reply->rp_direction); + if (x != RPC_REPLY) { +#ifdef RPC_DEBUG + if (debug) + printf("recvrpc: rp_direction %d != REPLY\n", x); +#endif + return -1; + } + + x = ntohl(reply->rp_astatus); + if (x != RPC_MSGACCEPTED) { + errno = ntohl(reply->rp_u.rpu_errno); + printf("recvrpc: reject, astat=%d, errno=%d\n", x, errno); + return -1; + } + + /* Return data count (thus indicating success) */ + return (n); +} + +/* + * Given a pointer to a reply just received, + * dig out the IP address/port from the headers. + */ +void +rpc_fromaddr(pkt, addr, port) + void *pkt; + struct in_addr *addr; + u_short *port; +{ + struct hackhdr { + /* Tail of IP header: just IP addresses */ + n_long ip_src; + n_long ip_dst; + /* UDP header: */ + u_int16_t uh_sport; /* source port */ + u_int16_t uh_dport; /* destination port */ + int16_t uh_ulen; /* udp length */ + u_int16_t uh_sum; /* udp checksum */ + /* RPC reply header: */ + struct rpc_reply rpc; + } *hhdr; + + hhdr = ((struct hackhdr *)pkt) - 1; + addr->s_addr = hhdr->ip_src; + *port = hhdr->uh_sport; +} + +/* + * RPC Portmapper cache + */ +#define PMAP_NUM 8 /* need at most 5 pmap entries */ + +int rpc_pmap_num; +struct pmap_list { + struct in_addr addr; /* server, net order */ + u_int prog; /* host order */ + u_int vers; /* host order */ + int port; /* host order */ +} rpc_pmap_list[PMAP_NUM]; + +/* return port number in host order, or -1 */ +int +rpc_pmap_getcache(addr, prog, vers) + struct in_addr addr; /* server, net order */ + u_int prog; /* host order */ + u_int vers; /* host order */ +{ + struct pmap_list *pl; + + for (pl = rpc_pmap_list; pl < &rpc_pmap_list[rpc_pmap_num]; pl++) { + if (pl->addr.s_addr == addr.s_addr && + pl->prog == prog && pl->vers == vers ) + { + return (pl->port); + } + } + return (-1); +} + +void +rpc_pmap_putcache(addr, prog, vers, port) + struct in_addr addr; /* server, net order */ + u_int prog; /* host order */ + u_int vers; /* host order */ + int port; /* host order */ +{ + struct pmap_list *pl; + + /* Don't overflow cache... */ + if (rpc_pmap_num >= PMAP_NUM) { + /* ... just re-use the last entry. */ + rpc_pmap_num = PMAP_NUM - 1; +#ifdef RPC_DEBUG + printf("rpc_pmap_putcache: cache overflow\n"); +#endif + } + + pl = &rpc_pmap_list[rpc_pmap_num]; + rpc_pmap_num++; + + /* Cache answer */ + pl->addr = addr; + pl->prog = prog; + pl->vers = vers; + pl->port = port; +} + + +/* + * Request a port number from the port mapper. + * Returns the port in host order. + */ +int +rpc_getport(d, prog, vers) + register struct iodesc *d; + n_long prog; /* host order */ + n_long vers; /* host order */ +{ + struct args { + n_long prog; /* call program */ + n_long vers; /* call version */ + n_long proto; /* call protocol */ + n_long port; /* call port (unused) */ + } *args; + struct res { + n_long port; + } *res; + struct { + n_long h[RPC_HEADER_WORDS]; + struct args d; + } sdata; + struct { + n_long h[RPC_HEADER_WORDS]; + struct res d; + n_long pad; + } rdata; + ssize_t cc; + int port; + +#ifdef RPC_DEBUG + if (debug) + printf("getport: prog=0x%x vers=%d\n", prog, vers); +#endif + + /* This one is fixed forever. */ + if (prog == PMAPPROG) + return (PMAPPORT); + + /* Try for cached answer first */ + port = rpc_pmap_getcache(d->destip, prog, vers); + if (port != -1) + return (port); + + args = &sdata.d; + args->prog = htonl(prog); + args->vers = htonl(vers); + args->proto = htonl(IPPROTO_UDP); + args->port = 0; + res = &rdata.d; + + cc = rpc_call(d, PMAPPROG, PMAPVERS, PMAPPROC_GETPORT, + args, sizeof(*args), res, sizeof(*res)); + if (cc < sizeof(*res)) { + printf("getport: %s", strerror(errno)); + errno = EBADRPC; + return (-1); + } + port = (int)ntohl(res->port); + + rpc_pmap_putcache(d->destip, prog, vers, port); + + return (port); +} Property changes on: cvs2svn/tags/initial/lib/libstand/rpc.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/rpc.h =================================================================== --- cvs2svn/tags/initial/lib/libstand/rpc.h (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/rpc.h (revision 49189) @@ -0,0 +1,68 @@ +/* $NetBSD: rpc.h,v 1.8 1996/09/26 23:22:03 cgd Exp $ */ + +/* + * Copyright (c) 1992 Regents of the University of California. + * All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * 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 by the University of + * California, Lawrence Berkeley Laboratory and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + */ + +/* XXX defines we can't easily get from system includes */ +#define PMAPPORT 111 +#define PMAPPROG 100000 +#define PMAPVERS 2 +#define PMAPPROC_NULL 0 +#define PMAPPROC_SET 1 +#define PMAPPROC_UNSET 2 +#define PMAPPROC_GETPORT 3 +#define PMAPPROC_DUMP 4 +#define PMAPPROC_CALLIT 5 + +/* RPC functions: */ +ssize_t rpc_call(struct iodesc *, n_long, n_long, n_long, + void *, size_t, void *, size_t); +void rpc_fromaddr(void *, struct in_addr *, u_short *); +int rpc_pmap_getcache(struct in_addr, u_int, u_int); +void rpc_pmap_putcache(struct in_addr, u_int, u_int, int); + +extern int rpc_port; /* decrement before bind */ + +/* + * How much space to leave in front of RPC requests. + * In 32-bit words (alignment) we have: + * 12: Ether + IP + UDP + padding + * 6: RPC call header + * 7: Auth UNIX + * 2: Auth NULL + */ +#define RPC_HEADER_WORDS 28 Property changes on: cvs2svn/tags/initial/lib/libstand/rpc.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/rpcv2.h =================================================================== --- cvs2svn/tags/initial/lib/libstand/rpcv2.h (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/rpcv2.h (revision 49189) @@ -0,0 +1,89 @@ +/* $NetBSD: rpcv2.h,v 1.1 1996/02/26 23:05:32 gwr Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Rick Macklem at The University of Guelph. + * + * 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)rpcv2.h 8.1 (Berkeley) 6/10/93 + */ + +/* + * Definitions for Sun RPC Version 2, from + * "RPC: Remote Procedure Call Protocol Specification" RFC1057 + */ + +/* Version # */ +#define RPC_VER2 2 + +/* Authentication */ +#define RPCAUTH_NULL 0 +#define RPCAUTH_UNIX 1 +#define RPCAUTH_SHORT 2 +#define RPCAUTH_MAXSIZ 400 +#define RPCAUTH_UNIXGIDS 16 + +/* Rpc Constants */ +#define RPC_CALL 0 +#define RPC_REPLY 1 +#define RPC_MSGACCEPTED 0 +#define RPC_MSGDENIED 1 +#define RPC_PROGUNAVAIL 1 +#define RPC_PROGMISMATCH 2 +#define RPC_PROCUNAVAIL 3 +#define RPC_GARBAGE 4 /* I like this one */ +#define RPC_MISMATCH 0 +#define RPC_AUTHERR 1 + +/* Authentication failures */ +#define AUTH_BADCRED 1 +#define AUTH_REJECTCRED 2 +#define AUTH_BADVERF 3 +#define AUTH_REJECTVERF 4 +#define AUTH_TOOWEAK 5 /* Give em wheaties */ + +/* Sizes of rpc header parts */ +#define RPC_SIZ 24 +#define RPC_REPLYSIZ 28 + +/* RPC Prog definitions */ +#define RPCPROG_MNT 100005 +#define RPCMNT_VER1 1 +#define RPCMNT_MOUNT 1 +#define RPCMNT_DUMP 2 +#define RPCMNT_UMOUNT 3 +#define RPCMNT_UMNTALL 4 +#define RPCMNT_EXPORT 5 +#define RPCMNT_NAMELEN 255 +#define RPCMNT_PATHLEN 1024 +#define RPCPROG_NFS 100003 Property changes on: cvs2svn/tags/initial/lib/libstand/rpcv2.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/saioctl.h =================================================================== --- cvs2svn/tags/initial/lib/libstand/saioctl.h (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/saioctl.h (revision 49189) @@ -0,0 +1,52 @@ +/* $NetBSD: saioctl.h,v 1.2 1994/10/26 05:45:04 cgd Exp $ */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)saioctl.h 8.1 (Berkeley) 6/11/93 + */ + +/* ioctl's -- for disks just now */ +#define SAIOHDR (('d'<<8)|1) /* next i/o includes header */ +#define SAIOCHECK (('d'<<8)|2) /* next i/o checks data */ +#define SAIOHCHECK (('d'<<8)|3) /* next i/o checks header & data */ +#define SAIONOBAD (('d'<<8)|4) /* inhibit bad sector forwarding */ +#define SAIODOBAD (('d'<<8)|5) /* enable bad sector forwarding */ +#define SAIOECCLIM (('d'<<8)|6) /* set limit to ecc correction, bits */ +#define SAIOECCUNL (('d'<<8)|7) /* use standard ecc procedures */ +#define SAIORETRIES (('d'<<8)|8) /* set retry count for unit */ +#define SAIODEVDATA (('d'<<8)|9) /* get pointer to pack label */ +#define SAIOSSI (('d'<<8)|10) /* set skip sector inhibit */ +#define SAIONOSSI (('d'<<8)|11) /* inhibit skip sector handling */ +#define SAIOSSDEV (('d'<<8)|12) /* is device skip sector type? */ +#define SAIODEBUG (('d'<<8)|13) /* enable/disable debugging */ +#define SAIOGBADINFO (('d'<<8)|14) /* get bad-sector table */ Property changes on: cvs2svn/tags/initial/lib/libstand/saioctl.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/stand.h =================================================================== --- cvs2svn/tags/initial/lib/libstand/stand.h (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/stand.h (revision 49189) @@ -0,0 +1,305 @@ +/* + * Copyright (c) 1998 Michael Smith. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + * From $NetBSD: stand.h,v 1.22 1997/06/26 19:17:40 drochner Exp $ + */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)stand.h 8.1 (Berkeley) 6/11/93 + */ + +#include +#include +#include + +#ifndef NULL +#define NULL 0 +#endif + +/* Avoid unwanted userlandish components */ +#define KERNEL +#include +#undef KERNEL + +/* special stand error codes */ +#define EADAPT (ELAST+1) /* bad adaptor */ +#define ECTLR (ELAST+2) /* bad controller */ +#define EUNIT (ELAST+3) /* bad unit */ +#define ESLICE (ELAST+4) /* bad slice */ +#define EPART (ELAST+5) /* bad partition */ +#define ERDLAB (ELAST+6) /* can't read disk label */ +#define EUNLAB (ELAST+7) /* unlabeled disk */ +#define EOFFSET (ELAST+8) /* relative seek not supported */ +#define ESALAST (ELAST+8) /* */ + +struct open_file; + +/* + * This structure is used to define file system operations in a file system + * independent way. + * + * XXX note that filesystem providers should export a pointer to their fs_ops + * struct, so that consumers can reference this and thus include the + * filesystems that they require. + */ +struct fs_ops { + char *fs_name; + int (*fo_open)(char *path, struct open_file *f); + int (*fo_close)(struct open_file *f); + int (*fo_read)(struct open_file *f, void *buf, + size_t size, size_t *resid); + int (*fo_write)(struct open_file *f, void *buf, + size_t size, size_t *resid); + off_t (*fo_seek)(struct open_file *f, off_t offset, int where); + int (*fo_stat)(struct open_file *f, struct stat *sb); +}; + +/* + * libstand-supplied filesystems + */ +extern struct fs_ops ufs_fsops; +extern struct fs_ops tftp_fsops; +extern struct fs_ops nfs_fsops; +extern struct fs_ops cd9660_fsops; +extern struct fs_ops zipfs_fsops; +#ifdef notyet +extern struct fs_ops dosfs_fsops; +#endif + +/* where values for lseek(2) */ +#define SEEK_SET 0 /* set file offset to offset */ +#define SEEK_CUR 1 /* set file offset to current plus offset */ +#define SEEK_END 2 /* set file offset to EOF plus offset */ + +/* + * Device switch + */ +struct devsw { + char dv_name[8]; + int dv_type; /* opaque type constant, arch-dependant */ + int (*dv_init)(void); /* early probe call */ + int (*dv_strategy)(void *devdata, int rw, daddr_t blk, size_t size, void *buf, size_t *rsize); + int (*dv_open)(struct open_file *f, ...); + int (*dv_close)(struct open_file *f); + int (*dv_ioctl)(struct open_file *f, u_long cmd, void *data); +}; + +extern int errno; + +struct open_file { + int f_flags; /* see F_* below */ + struct devsw *f_dev; /* pointer to device operations */ + void *f_devdata; /* device specific data */ + struct fs_ops *f_ops; /* pointer to file system operations */ + void *f_fsdata; /* file system specific data */ + off_t f_offset; /* current file offset (F_RAW) */ +}; + +#define SOPEN_MAX 8 +extern struct open_file files[]; + +/* f_flags values */ +#define F_READ 0x0001 /* file opened for reading */ +#define F_WRITE 0x0002 /* file opened for writing */ +#define F_RAW 0x0004 /* raw device open - no file system */ +#define F_NODEV 0x0008 /* network open - no device */ + +#define isupper(c) ((c) >= 'A' && (c) <= 'Z') +#define islower(c) ((c) >= 'a' && (c) <= 'z') +#define isspace(c) ((c) == ' ' || (c) == '\t') +#define isdigit(c) ((c) >= '0' && (c) <= '9') +#define isxdigit(c) (isdigit(c) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) +#define isascii(c) ((c) >= 0 || (c <= 0x7f)) +#define isalpha(c) (isupper(c) || (islower(c))) +#define toupper(c) ((c) - 'a' + 'A') +#define tolower(c) ((c) - 'A' + 'a') + +extern void setheap(void *, void *); +extern void *malloc(size_t); +extern void free(void *); +extern char *sbrk(int junk); + +/* disklabel support (undocumented, may be junk) */ +struct disklabel; +extern char *getdisklabel(const char *, struct disklabel *); +extern int dkcksum(struct disklabel *); + +extern int printf(const char *fmt, ...); +extern void vprintf(const char *fmt, _BSD_VA_LIST_); +extern int sprintf(char *buf, const char *cfmt, ...); + +extern void twiddle(void); + +extern void ngets(char *, int); +#define gets(x) ngets((x), 0) +extern int fgetstr(char *buf, int size, int fd); + +extern char *strerror(int); + +extern int open(const char *, int); +#define O_RDONLY 0x0 +#define O_WRONLY 0x1 /* writing not (yet?) supported */ +#define O_RDWR 0x2 +extern int close(int); +extern void closeall(void); +extern ssize_t read(int, void *, size_t); +extern ssize_t write(int, void *, size_t); +extern off_t lseek(int, off_t, int); +extern int stat(const char *, struct stat *); + +extern void srandom(u_long seed); +extern u_long random(void); + +/* imports from stdlib, locally modified */ +extern long strtol(const char *, char **, int); +extern char *optarg; /* getopt(3) external variables */ +extern int optind, opterr, optopt; +extern int getopt(int, char * const [], const char *); + +/* pager.c */ +extern void pager_open(void); +extern void pager_close(void); +extern int pager_output(const char *lines); +extern int pager_file(char *fname); + +/* environment.c */ +#define EV_DYNAMIC (1<<0) /* value was dynamically allocated, free if changed/unset */ +#define EV_VOLATILE (1<<1) /* value is volatile, make a copy of it */ +#define EV_NOHOOK (1<<2) /* don't call hook when setting */ + +struct env_var; +typedef char *(ev_format_t)(struct env_var *ev); +typedef int (ev_sethook_t)(struct env_var *ev, int flags, void *value); +typedef int (ev_unsethook_t)(struct env_var *ev); + +struct env_var +{ + char *ev_name; + int ev_flags; + void *ev_value; + ev_sethook_t *ev_sethook; + ev_unsethook_t *ev_unsethook; + struct env_var *ev_next, *ev_prev; +}; +extern struct env_var *environ; + +extern struct env_var *env_getenv(const char *name); +extern int env_setenv(const char *name, int flags, void *value, + ev_sethook_t sethook, ev_unsethook_t unsethook); +extern char *getenv(const char *name); +extern int setenv(const char *name, char *value, int overwrite); +extern int putenv(const char *string); +extern int unsetenv(const char *name); + +extern ev_sethook_t env_noset; /* refuse set operation */ +extern ev_unsethook_t env_nounset; /* refuse unset operation */ + +/* BCD conversions (undocumented) */ +extern u_char const bcd2bin_data[]; +extern u_char const bin2bcd_data[]; +extern char const hex2ascii_data[]; + +#define bcd2bin(bcd) (bcd2bin_data[bcd]) +#define bin2bcd(bin) (bin2bcd_data[bin]) +#define hex2ascii(hex) (hex2ascii_data[hex]) + +/* min/max (undocumented) */ +static __inline int imax(int a, int b) { return (a > b ? a : b); } +static __inline int imin(int a, int b) { return (a < b ? a : b); } +static __inline long lmax(long a, long b) { return (a > b ? a : b); } +static __inline long lmin(long a, long b) { return (a < b ? a : b); } +static __inline u_int max(u_int a, u_int b) { return (a > b ? a : b); } +static __inline u_int min(u_int a, u_int b) { return (a < b ? a : b); } +static __inline quad_t qmax(quad_t a, quad_t b) { return (a > b ? a : b); } +static __inline quad_t qmin(quad_t a, quad_t b) { return (a < b ? a : b); } +static __inline u_long ulmax(u_long a, u_long b) { return (a > b ? a : b); } +static __inline u_long ulmin(u_long a, u_long b) { return (a < b ? a : b); } + +/* swaps (undocumented, useful?) */ +#ifdef __i386__ +extern u_int32_t bswap32(u_int32_t x); +extern u_int64_t bswap64(u_int32_t x); +#endif + +/* null functions for device/filesystem switches (undocumented) */ +extern int nodev(void); +extern int noioctl(struct open_file *, u_long, void *); +extern void nullsys(void); + +extern int null_open(char *path, struct open_file *f); +extern int null_close(struct open_file *f); +extern ssize_t null_read(struct open_file *f, void *buf, size_t size, size_t *resid); +extern ssize_t null_write(struct open_file *f, void *buf, size_t size, size_t *resid); +extern off_t null_seek(struct open_file *f, off_t offset, int where); +extern int null_stat(struct open_file *f, struct stat *sb); + +/* stuff should be in bootstrap (undocumented) */ +extern int getfile(char *prompt, int mode); + +/* + * Machine dependent functions and data, must be provided or stubbed by + * the consumer + */ +extern int getchar(void); +extern int ischar(void); +extern void putchar(int); +extern int devopen(struct open_file *, const char *, char **); +extern int devclose(struct open_file *f); +extern __dead void panic(const char *, ...) __attribute__((noreturn)); +extern struct fs_ops *file_system[]; +extern struct devsw *devsw[]; + Property changes on: cvs2svn/tags/initial/lib/libstand/stand.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/stat.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/stat.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/stat.c (revision 49189) @@ -0,0 +1,53 @@ +/* $NetBSD: stat.c,v 1.4 1996/01/13 22:25:43 leo Exp $ */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)stat.c 8.1 (Berkeley) 6/11/93 + */ + +#include "stand.h" + +int +stat(str, sb) + const char *str; + struct stat *sb; +{ + int fd, rv; + + fd = open(str, O_RDONLY); + if (fd < 0) + return (-1); + rv = fstat(fd, sb); + (void)close(fd); + return (rv); +} Property changes on: cvs2svn/tags/initial/lib/libstand/stat.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/strdup.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/strdup.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/strdup.c (revision 49189) @@ -0,0 +1,56 @@ +/* + * Copyright (c) 1988, 1993 + * The Regents of the University of California. 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)strdup.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#include "stand.h" +#include +#include + +char * +strdup(str) + const char *str; +{ + size_t len; + char *copy = NULL; + + if (str != NULL) { + len = strlen(str) + 1; + if ((copy = malloc(len)) == NULL) + return (NULL); + memcpy(copy, str, len); + } + return (copy); +} Property changes on: cvs2svn/tags/initial/lib/libstand/strdup.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/strerror.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/strerror.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/strerror.c (revision 49189) @@ -0,0 +1,88 @@ +/* $NetBSD: strerror.c,v 1.12 1997/01/25 00:37:50 cgd Exp $ */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + */ + +#include "stand.h" + +static struct +{ + int err; + char *msg; +} errtab[] = { + {0, "no error"}, + /* standard errors */ + {EPERM, "operation not permitted"}, + {ENOENT, "no such file or directory"}, + {EIO, "input/output error"}, + {ENXIO, "device not configured"}, + {ENOEXEC, "exec format error"}, + {EBADF, "bad file descriptor"}, + {ENOMEM, "cannot allocate memory"}, + {ENODEV, "operation not supported by device"}, + {ENOTDIR, "not a directory"}, + {EISDIR, "is a directory"}, + {EINVAL, "invalid argument"}, + {EMFILE, "too many open files"}, + {EFBIG, "file too large"}, + {EROFS, "read-only filesystem"}, + {EOPNOTSUPP, "operation not supported"}, + {ETIMEDOUT, "operation timed out"}, + {ESTALE, "stale NFS file handle"}, + {EBADRPC, "RPC struct is bad"}, + {EFTYPE, "inappropriate file type or format"}, + + {EADAPT, "bad adaptor number"}, + {ECTLR, "bad controller number"}, + {EUNIT, "bad unit number"}, + {ESLICE, "bad slice number"}, + {EPART, "bad partition"}, + {ERDLAB, "can't read disk label"}, + {EUNLAB, "disk unlabelled"}, + {EOFFSET, "illegal seek"}, + {0, NULL} +}; + + +char * +strerror(int err) +{ + static char msg[32]; + int i; + + for (i = 0; errtab[i].msg != NULL; i++) + if (errtab[i].err == err) + return(errtab[i].msg); + sprintf(msg, "unknown error (%d)", err); + return(msg); +} Property changes on: cvs2svn/tags/initial/lib/libstand/strerror.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/strtol.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/strtol.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/strtol.c (revision 49189) @@ -0,0 +1,133 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)strtol.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#include "stand.h" +#include + +/* + * Convert a string to a long integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +long +strtol(nptr, endptr, base) + const char *nptr; + char **endptr; + register int base; +{ + register const char *s; + register unsigned long acc; + register unsigned char c; + register unsigned long cutoff; + register int neg = 0, any, cutlim; + + /* Be sensible about NULL strings */ + if (nptr == NULL) + nptr = ""; + s = nptr; + + /* + * Skip white space and pick up leading +/- sign if any. + * If base is 0, allow 0x for hex and 0 for octal, else + * assume decimal; if base is already 16, allow 0x. + */ + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else if (c == '+') + c = *s++; + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + /* + * Compute the cutoff value between legal numbers and illegal + * numbers. That is the largest legal value, divided by the + * base. An input number that is greater than this value, if + * followed by a legal input character, is too big. One that + * is equal to this value may be valid or not; the limit + * between valid and invalid numbers is then based on the last + * digit. For instance, if the range for longs is + * [-2147483648..2147483647] and the input base is 10, + * cutoff will be set to 214748364 and cutlim to either + * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated + * a value > 214748364, or equal but the next digit is > 7 (or 8), + * the number is too big, and we will return a range error. + * + * Set any if any `digits' consumed; make it negative to indicate + * overflow. + */ + cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; + cutlim = cutoff % (unsigned long)base; + cutoff /= (unsigned long)base; + for (acc = 0, any = 0;; c = *s++) { + if (!isascii(c)) + break; + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) + any = -1; + else { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) { + acc = neg ? LONG_MIN : LONG_MAX; + errno = ERANGE; + } else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = (char *)(any ? s - 1 : nptr); + return (acc); +} Property changes on: cvs2svn/tags/initial/lib/libstand/strtol.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/tftp.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/tftp.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/tftp.c (revision 49189) @@ -0,0 +1,400 @@ +/* $NetBSD: tftp.c,v 1.4 1997/09/17 16:57:07 drochner Exp $ */ + +/* + * 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. + * + */ + +/* + * Simple TFTP implementation for libsa. + * Assumes: + * - socket descriptor (int) at open_file->f_devdata + * - server host IP in global servip + * Restrictions: + * - read only + * - lseek only with SEEK_SET or SEEK_CUR + * - no big time differences between transfers ( +#include +#include +#include +#include +#include + +#include + +#include "stand.h" +#include "net.h" +#include "netif.h" + +#include "tftp.h" + +static int tftp_open(char *path, struct open_file *f); +static int tftp_close(struct open_file *f); +static int tftp_read(struct open_file *f, void *buf, size_t size, size_t *resid); +static int tftp_write(struct open_file *f, void *buf, size_t size, size_t *resid); +static off_t tftp_seek(struct open_file *f, off_t offset, int where); +static int tftp_stat(struct open_file *f, struct stat *sb); + +struct fs_ops tftp_fsops = { + "tftp", tftp_open, tftp_close, tftp_read, tftp_write, tftp_seek, tftp_stat +}; + +extern struct in_addr servip; + +static int tftpport = 2000; + +#define RSPACE 520 /* max data packet, rounded up */ + +struct tftp_handle { + struct iodesc *iodesc; + int currblock; /* contents of lastdata */ + int islastblock; /* flag */ + int validsize; + int off; + char *path; /* saved for re-requests */ + struct { + u_char header[HEADER_SIZE]; + struct tftphdr t; + u_char space[RSPACE]; + } lastdata; +}; + +static int tftperrors[8] = { + 0, /* ??? */ + ENOENT, + EPERM, + ENOSPC, + EINVAL, /* ??? */ + EINVAL, /* ??? */ + EEXIST, + EINVAL /* ??? */ +}; + +static ssize_t +recvtftp(d, pkt, len, tleft) + register struct iodesc *d; + register void *pkt; + register ssize_t len; + time_t tleft; +{ + struct tftphdr *t; + + len = readudp(d, pkt, len, tleft); + + if (len < 8) + return (-1); + + t = (struct tftphdr *) pkt; + switch (ntohs(t->th_opcode)) { + case DATA: { + int got; + + if (htons(t->th_block) != d->xid) { + /* + * Expected block? + */ + return (-1); + } + if (d->xid == 1) { + /* + * First data packet from new port. + */ + register struct udphdr *uh; + uh = (struct udphdr *) pkt - 1; + d->destport = uh->uh_sport; + } /* else check uh_sport has not changed??? */ + got = len - (t->th_data - (char *) t); + return got; + } + case ERROR: + if ((unsigned) ntohs(t->th_code) >= 8) { + printf("illegal tftp error %d\n", ntohs(t->th_code)); + errno = EIO; + } else { +#ifdef DEBUG + printf("tftp-error %d\n", ntohs(t->th_code)); +#endif + errno = tftperrors[ntohs(t->th_code)]; + } + return (-1); + default: +#ifdef DEBUG + printf("tftp type %d not handled\n", ntohs(t->th_opcode)); +#endif + return (-1); + } +} + +/* send request, expect first block (or error) */ +static int +tftp_makereq(h) + struct tftp_handle *h; +{ + struct { + u_char header[HEADER_SIZE]; + struct tftphdr t; + u_char space[FNAME_SIZE + 6]; + } wbuf; + char *wtail; + int l; + ssize_t res; + struct tftphdr *t; + + wbuf.t.th_opcode = htons((u_short) RRQ); + wtail = wbuf.t.th_stuff; + l = strlen(h->path); + bcopy(h->path, wtail, l + 1); + wtail += l + 1; + bcopy("octet", wtail, 6); + wtail += 6; + + t = &h->lastdata.t; + + /* h->iodesc->myport = htons(--tftpport); */ + h->iodesc->myport = htons(tftpport + (getsecs() & 0x3ff)); + h->iodesc->destport = htons(IPPORT_TFTP); + h->iodesc->xid = 1; /* expected block */ + + res = sendrecv(h->iodesc, sendudp, &wbuf.t, wtail - (char *) &wbuf.t, + recvtftp, t, sizeof(*t) + RSPACE); + + if (res == -1) + return (errno); + + h->currblock = 1; + h->validsize = res; + h->islastblock = 0; + if (res < SEGSIZE) + h->islastblock = 1; /* very short file */ + return (0); +} + +/* ack block, expect next */ +static int +tftp_getnextblock(h) + struct tftp_handle *h; +{ + struct { + u_char header[HEADER_SIZE]; + struct tftphdr t; + } wbuf; + char *wtail; + int res; + struct tftphdr *t; + + wbuf.t.th_opcode = htons((u_short) ACK); + wtail = (char *) &wbuf.t.th_block; + wbuf.t.th_block = htons((u_short) h->currblock); + wtail += 2; + + t = &h->lastdata.t; + + h->iodesc->xid = h->currblock + 1; /* expected block */ + + res = sendrecv(h->iodesc, sendudp, &wbuf.t, wtail - (char *) &wbuf.t, + recvtftp, t, sizeof(*t) + RSPACE); + + if (res == -1) /* 0 is OK! */ + return (errno); + + h->currblock++; + h->validsize = res; + if (res < SEGSIZE) + h->islastblock = 1; /* EOF */ + return (0); +} + +static int +tftp_open(path, f) + char *path; + struct open_file *f; +{ + struct tftp_handle *tftpfile; + struct iodesc *io; + int res; + + tftpfile = (struct tftp_handle *) malloc(sizeof(*tftpfile)); + if (!tftpfile) + return (ENOMEM); + + tftpfile->iodesc = io = socktodesc(*(int *) (f->f_devdata)); + io->destip = servip; + tftpfile->off = 0; + tftpfile->path = path; /* XXXXXXX we hope it's static */ + + res = tftp_makereq(tftpfile, path); + + if (res) { + free(tftpfile); + return (res); + } + f->f_fsdata = (void *) tftpfile; + return (0); +} + +static int +tftp_read(f, addr, size, resid) + struct open_file *f; + void *addr; + size_t size; + size_t *resid; /* out */ +{ + struct tftp_handle *tftpfile; + static int tc = 0; + tftpfile = (struct tftp_handle *) f->f_fsdata; + + while (size > 0) { + int needblock, count; + + if (!(tc++ % 16)) + twiddle(); + + needblock = tftpfile->off / SEGSIZE + 1; + + if (tftpfile->currblock > needblock) /* seek backwards */ + tftp_makereq(tftpfile); /* no error check, it worked + * for open */ + + while (tftpfile->currblock < needblock) { + int res; + + res = tftp_getnextblock(tftpfile); + if (res) { /* no answer */ +#ifdef DEBUG + printf("tftp: read error\n"); +#endif + return (res); + } + if (tftpfile->islastblock) + break; + } + + if (tftpfile->currblock == needblock) { + int offinblock, inbuffer; + + offinblock = tftpfile->off % SEGSIZE; + + inbuffer = tftpfile->validsize - offinblock; + if (inbuffer < 0) { +#ifdef DEBUG + printf("tftp: invalid offset %d\n", + tftpfile->off); +#endif + return (EINVAL); + } + count = (size < inbuffer ? size : inbuffer); + bcopy(tftpfile->lastdata.t.th_data + offinblock, + addr, count); + + addr += count; + tftpfile->off += count; + size -= count; + + if ((tftpfile->islastblock) && (count == inbuffer)) + break; /* EOF */ + } else { +#ifdef DEBUG + printf("tftp: block %d not found\n", needblock); +#endif + return (EINVAL); + } + + } + + if (resid) + *resid = size; + return (0); +} + +static int +tftp_close(f) + struct open_file *f; +{ + struct tftp_handle *tftpfile; + tftpfile = (struct tftp_handle *) f->f_fsdata; + + /* let it time out ... */ + + if (tftpfile) + free(tftpfile); + return (0); +} + +static int +tftp_write(f, start, size, resid) + struct open_file *f; + void *start; + size_t size; + size_t *resid; /* out */ +{ + return (EROFS); +} + +static int +tftp_stat(f, sb) + struct open_file *f; + struct stat *sb; +{ + struct tftp_handle *tftpfile; + tftpfile = (struct tftp_handle *) f->f_fsdata; + + sb->st_mode = 0444; + sb->st_nlink = 1; + sb->st_uid = 0; + sb->st_gid = 0; + sb->st_size = -1; + return (0); +} + +static off_t +tftp_seek(f, offset, where) + struct open_file *f; + off_t offset; + int where; +{ + struct tftp_handle *tftpfile; + tftpfile = (struct tftp_handle *) f->f_fsdata; + + switch (where) { + case SEEK_SET: + tftpfile->off = offset; + break; + case SEEK_CUR: + tftpfile->off += offset; + break; + default: + errno = EOFFSET; + return (-1); + } + return (tftpfile->off); +} Property changes on: cvs2svn/tags/initial/lib/libstand/tftp.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/tftp.h =================================================================== --- cvs2svn/tags/initial/lib/libstand/tftp.h (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/tftp.h (revision 49189) @@ -0,0 +1,36 @@ +/* $NetBSD: tftp.h,v 1.1.1.1 1997/03/14 02:40:31 perry Exp $ */ + +/* + * 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. + * + */ + + +#define IPPORT_TFTP 69 Property changes on: cvs2svn/tags/initial/lib/libstand/tftp.h ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/twiddle.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/twiddle.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/twiddle.c (revision 49189) @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 1986, 1988, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)subr_prf.c 8.3 (Berkeley) 1/21/94 + * $Id: subr_prf.c,v 1.46 1998/05/28 09:30:20 phk Exp $ + */ + +#include +#include "stand.h" + +/* Extra functions from NetBSD standalone printf.c */ + +void +twiddle() +{ + static int pos; + + putchar("|/-\\"[pos++ & 3]); + putchar('\b'); +} Property changes on: cvs2svn/tags/initial/lib/libstand/twiddle.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/ufs.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/ufs.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/ufs.c (revision 49189) @@ -0,0 +1,704 @@ +/* $NetBSD: ufs.c,v 1.20 1998/03/01 07:15:39 ross Exp $ */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * The Mach Operating System project at Carnegie-Mellon University. + * + * 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * + * Copyright (c) 1990, 1991 Carnegie Mellon University + * All Rights Reserved. + * + * Author: David Golub + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +/* + * Stand-alone file reading package. + */ + +#include +#include +#include +#include +#include +#include "stand.h" +#include "string.h" + +static int ufs_open(char *path, struct open_file *f); +static int ufs_close(struct open_file *f); +static int ufs_read(struct open_file *f, void *buf, size_t size, size_t *resid); +static off_t ufs_seek(struct open_file *f, off_t offset, int where); +static int ufs_stat(struct open_file *f, struct stat *sb); + +struct fs_ops ufs_fsops = { + "ufs", ufs_open, ufs_close, ufs_read, null_write, ufs_seek, ufs_stat +}; + + +/* + * In-core open file. + */ +struct file { + off_t f_seekp; /* seek pointer */ + struct fs *f_fs; /* pointer to super-block */ + struct dinode f_di; /* copy of on-disk inode */ + int f_nindir[NIADDR]; + /* number of blocks mapped by + indirect block at level i */ + char *f_blk[NIADDR]; /* buffer for indirect block at + level i */ + size_t f_blksize[NIADDR]; + /* size of buffer */ + daddr_t f_blkno[NIADDR];/* disk address of block in buffer */ + char *f_buf; /* buffer for data block */ + size_t f_buf_size; /* size of data block */ + daddr_t f_buf_blkno; /* block number of data block */ +}; + +static int read_inode(ino_t, struct open_file *); +static int block_map(struct open_file *, daddr_t, daddr_t *); +static int buf_read_file(struct open_file *, char **, size_t *); +static int search_directory(char *, struct open_file *, ino_t *); +#ifdef COMPAT_UFS +static void ffs_oldfscompat(struct fs *); +#endif + +/* + * Read a new inode into a file structure. + */ +static int +read_inode(inumber, f) + ino_t inumber; + struct open_file *f; +{ + register struct file *fp = (struct file *)f->f_fsdata; + register struct fs *fs = fp->f_fs; + char *buf; + size_t rsize; + int rc; + + /* + * Read inode and save it. + */ + buf = malloc(fs->fs_bsize); + twiddle(); + rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ, + fsbtodb(fs, ino_to_fsba(fs, inumber)), fs->fs_bsize, + buf, &rsize); + if (rc) + goto out; + if (rsize != fs->fs_bsize) { + rc = EIO; + goto out; + } + + { + register struct dinode *dp; + + dp = (struct dinode *)buf; + fp->f_di = dp[ino_to_fsbo(fs, inumber)]; + } + + /* + * Clear out the old buffers + */ + { + register int level; + + for (level = 0; level < NIADDR; level++) + fp->f_blkno[level] = -1; + fp->f_buf_blkno = -1; + } +out: + free(buf); + return (rc); +} + +/* + * Given an offset in a file, find the disk block number that + * contains that block. + */ +static int +block_map(f, file_block, disk_block_p) + struct open_file *f; + daddr_t file_block; + daddr_t *disk_block_p; /* out */ +{ + register struct file *fp = (struct file *)f->f_fsdata; + register struct fs *fs = fp->f_fs; + int level; + int idx; + daddr_t ind_block_num; + daddr_t *ind_p; + int rc; + + /* + * Index structure of an inode: + * + * di_db[0..NDADDR-1] hold block numbers for blocks + * 0..NDADDR-1 + * + * di_ib[0] index block 0 is the single indirect block + * holds block numbers for blocks + * NDADDR .. NDADDR + NINDIR(fs)-1 + * + * di_ib[1] index block 1 is the double indirect block + * holds block numbers for INDEX blocks for blocks + * NDADDR + NINDIR(fs) .. + * NDADDR + NINDIR(fs) + NINDIR(fs)**2 - 1 + * + * di_ib[2] index block 2 is the triple indirect block + * holds block numbers for double-indirect + * blocks for blocks + * NDADDR + NINDIR(fs) + NINDIR(fs)**2 .. + * NDADDR + NINDIR(fs) + NINDIR(fs)**2 + * + NINDIR(fs)**3 - 1 + */ + + if (file_block < NDADDR) { + /* Direct block. */ + *disk_block_p = fp->f_di.di_db[file_block]; + return (0); + } + + file_block -= NDADDR; + + /* + * nindir[0] = NINDIR + * nindir[1] = NINDIR**2 + * nindir[2] = NINDIR**3 + * etc + */ + for (level = 0; level < NIADDR; level++) { + if (file_block < fp->f_nindir[level]) + break; + file_block -= fp->f_nindir[level]; + } + if (level == NIADDR) { + /* Block number too high */ + return (EFBIG); + } + + ind_block_num = fp->f_di.di_ib[level]; + + for (; level >= 0; level--) { + if (ind_block_num == 0) { + *disk_block_p = 0; /* missing */ + return (0); + } + + if (fp->f_blkno[level] != ind_block_num) { + if (fp->f_blk[level] == (char *)0) + fp->f_blk[level] = + malloc(fs->fs_bsize); + twiddle(); + rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ, + fsbtodb(fp->f_fs, ind_block_num), + fs->fs_bsize, + fp->f_blk[level], + &fp->f_blksize[level]); + if (rc) + return (rc); + if (fp->f_blksize[level] != fs->fs_bsize) + return (EIO); + fp->f_blkno[level] = ind_block_num; + } + + ind_p = (daddr_t *)fp->f_blk[level]; + + if (level > 0) { + idx = file_block / fp->f_nindir[level - 1]; + file_block %= fp->f_nindir[level - 1]; + } else + idx = file_block; + + ind_block_num = ind_p[idx]; + } + + *disk_block_p = ind_block_num; + + return (0); +} + +/* + * Read a portion of a file into an internal buffer. Return + * the location in the buffer and the amount in the buffer. + */ +static int +buf_read_file(f, buf_p, size_p) + struct open_file *f; + char **buf_p; /* out */ + size_t *size_p; /* out */ +{ + register struct file *fp = (struct file *)f->f_fsdata; + register struct fs *fs = fp->f_fs; + long off; + register daddr_t file_block; + daddr_t disk_block; + size_t block_size; + int rc; + + off = blkoff(fs, fp->f_seekp); + file_block = lblkno(fs, fp->f_seekp); + block_size = dblksize(fs, &fp->f_di, file_block); + + if (file_block != fp->f_buf_blkno) { + rc = block_map(f, file_block, &disk_block); + if (rc) + return (rc); + + if (fp->f_buf == (char *)0) + fp->f_buf = malloc(fs->fs_bsize); + + if (disk_block == 0) { + bzero(fp->f_buf, block_size); + fp->f_buf_size = block_size; + } else { + twiddle(); + rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ, + fsbtodb(fs, disk_block), + block_size, fp->f_buf, &fp->f_buf_size); + if (rc) + return (rc); + } + + fp->f_buf_blkno = file_block; + } + + /* + * Return address of byte in buffer corresponding to + * offset, and size of remainder of buffer after that + * byte. + */ + *buf_p = fp->f_buf + off; + *size_p = block_size - off; + + /* + * But truncate buffer at end of file. + */ + if (*size_p > fp->f_di.di_size - fp->f_seekp) + *size_p = fp->f_di.di_size - fp->f_seekp; + + return (0); +} + +/* + * Search a directory for a name and return its + * i_number. + */ +static int +search_directory(name, f, inumber_p) + char *name; + struct open_file *f; + ino_t *inumber_p; /* out */ +{ + register struct file *fp = (struct file *)f->f_fsdata; + register struct direct *dp; + struct direct *edp; + char *buf; + size_t buf_size; + int namlen, length; + int rc; + + length = strlen(name); + + fp->f_seekp = 0; + while (fp->f_seekp < fp->f_di.di_size) { + rc = buf_read_file(f, &buf, &buf_size); + if (rc) + return (rc); + + dp = (struct direct *)buf; + edp = (struct direct *)(buf + buf_size); + while (dp < edp) { + if (dp->d_ino == (ino_t)0) + goto next; +#if BYTE_ORDER == LITTLE_ENDIAN + if (fp->f_fs->fs_maxsymlinklen <= 0) + namlen = dp->d_type; + else +#endif + namlen = dp->d_namlen; + if (namlen == length && + !strcmp(name, dp->d_name)) { + /* found entry */ + *inumber_p = dp->d_ino; + return (0); + } + next: + dp = (struct direct *)((char *)dp + dp->d_reclen); + } + fp->f_seekp += buf_size; + } + return (ENOENT); +} + +/* + * Open a file. + */ +static int +ufs_open(path, f) + char *path; + struct open_file *f; +{ + register char *cp, *ncp; + register int c; + ino_t inumber, parent_inumber; + struct file *fp; + struct fs *fs; + int rc; + size_t buf_size; + int nlinks = 0; + char namebuf[MAXPATHLEN+1]; + char *buf = NULL; + + /* allocate file system specific data structure */ + fp = malloc(sizeof(struct file)); + bzero(fp, sizeof(struct file)); + f->f_fsdata = (void *)fp; + + /* allocate space and read super block */ + fs = malloc(SBSIZE); + fp->f_fs = fs; + twiddle(); + rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ, + SBLOCK, SBSIZE, (char *)fs, &buf_size); + if (rc) + goto out; + + if (buf_size != SBSIZE || fs->fs_magic != FS_MAGIC || + fs->fs_bsize > MAXBSIZE || fs->fs_bsize < sizeof(struct fs)) { + rc = EINVAL; + goto out; + } +#ifdef COMPAT_UFS + ffs_oldfscompat(fs); +#endif + + /* + * Calculate indirect block levels. + */ + { + register int mult; + register int level; + + mult = 1; + for (level = 0; level < NIADDR; level++) { + mult *= NINDIR(fs); + fp->f_nindir[level] = mult; + } + } + + inumber = ROOTINO; + if ((rc = read_inode(inumber, f)) != 0) + goto out; + + cp = path; + while (*cp) { + + /* + * Remove extra separators + */ + while (*cp == '/') + cp++; + if (*cp == '\0') + break; + + /* + * Check that current node is a directory. + */ + if ((fp->f_di.di_mode & IFMT) != IFDIR) { + rc = ENOTDIR; + goto out; + } + + /* + * Get next component of path name. + */ + { + register int len = 0; + + ncp = cp; + while ((c = *cp) != '\0' && c != '/') { + if (++len > MAXNAMLEN) { + rc = ENOENT; + goto out; + } + cp++; + } + *cp = '\0'; + } + + /* + * Look up component in current directory. + * Save directory inumber in case we find a + * symbolic link. + */ + parent_inumber = inumber; + rc = search_directory(ncp, f, &inumber); + *cp = c; + if (rc) + goto out; + + /* + * Open next component. + */ + if ((rc = read_inode(inumber, f)) != 0) + goto out; + + /* + * Check for symbolic link. + */ + if ((fp->f_di.di_mode & IFMT) == IFLNK) { + int link_len = fp->f_di.di_size; + int len; + + len = strlen(cp); + + if (link_len + len > MAXPATHLEN || + ++nlinks > MAXSYMLINKS) { + rc = ENOENT; + goto out; + } + + bcopy(cp, &namebuf[link_len], len + 1); + + if (link_len < fs->fs_maxsymlinklen) { + bcopy(fp->f_di.di_shortlink, namebuf, + (unsigned) link_len); + } else { + /* + * Read file for symbolic link + */ + size_t buf_size; + daddr_t disk_block; + register struct fs *fs = fp->f_fs; + + if (!buf) + buf = malloc(fs->fs_bsize); + rc = block_map(f, (daddr_t)0, &disk_block); + if (rc) + goto out; + + twiddle(); + rc = (f->f_dev->dv_strategy)(f->f_devdata, + F_READ, fsbtodb(fs, disk_block), + fs->fs_bsize, buf, &buf_size); + if (rc) + goto out; + + bcopy((char *)buf, namebuf, (unsigned)link_len); + } + + /* + * If relative pathname, restart at parent directory. + * If absolute pathname, restart at root. + */ + cp = namebuf; + if (*cp != '/') + inumber = parent_inumber; + else + inumber = (ino_t)ROOTINO; + + if ((rc = read_inode(inumber, f)) != 0) + goto out; + } + } + + /* + * Found terminal component. + */ + rc = 0; +out: + if (buf) + free(buf); + if (rc) { + if (fp->f_buf) + free(fp->f_buf); + free(fp->f_fs); + free(fp); + } + return (rc); +} + +static int +ufs_close(f) + struct open_file *f; +{ + register struct file *fp = (struct file *)f->f_fsdata; + int level; + + f->f_fsdata = (void *)0; + if (fp == (struct file *)0) + return (0); + + for (level = 0; level < NIADDR; level++) { + if (fp->f_blk[level]) + free(fp->f_blk[level]); + } + if (fp->f_buf) + free(fp->f_buf); + free(fp->f_fs); + free(fp); + return (0); +} + +/* + * Copy a portion of a file into kernel memory. + * Cross block boundaries when necessary. + */ +static int +ufs_read(f, start, size, resid) + struct open_file *f; + void *start; + size_t size; + size_t *resid; /* out */ +{ + register struct file *fp = (struct file *)f->f_fsdata; + register size_t csize; + char *buf; + size_t buf_size; + int rc = 0; + register char *addr = start; + + while (size != 0) { + if (fp->f_seekp >= fp->f_di.di_size) + break; + + rc = buf_read_file(f, &buf, &buf_size); + if (rc) + break; + + csize = size; + if (csize > buf_size) + csize = buf_size; + + bcopy(buf, addr, csize); + + fp->f_seekp += csize; + addr += csize; + size -= csize; + } + if (resid) + *resid = size; + return (rc); +} + +static off_t +ufs_seek(f, offset, where) + struct open_file *f; + off_t offset; + int where; +{ + register struct file *fp = (struct file *)f->f_fsdata; + + switch (where) { + case SEEK_SET: + fp->f_seekp = offset; + break; + case SEEK_CUR: + fp->f_seekp += offset; + break; + case SEEK_END: + fp->f_seekp = fp->f_di.di_size - offset; + break; + default: + return (-1); + } + return (fp->f_seekp); +} + +static int +ufs_stat(f, sb) + struct open_file *f; + struct stat *sb; +{ + register struct file *fp = (struct file *)f->f_fsdata; + + /* only important stuff */ + sb->st_mode = fp->f_di.di_mode; + sb->st_uid = fp->f_di.di_uid; + sb->st_gid = fp->f_di.di_gid; + sb->st_size = fp->f_di.di_size; + return (0); +} + +#ifdef COMPAT_UFS +/* + * Sanity checks for old file systems. + * + * XXX - goes away some day. + */ +static void +ffs_oldfscompat(fs) + struct fs *fs; +{ + int i; + + fs->fs_npsect = max(fs->fs_npsect, fs->fs_nsect); /* XXX */ + fs->fs_interleave = max(fs->fs_interleave, 1); /* XXX */ + if (fs->fs_postblformat == FS_42POSTBLFMT) /* XXX */ + fs->fs_nrpos = 8; /* XXX */ + if (fs->fs_inodefmt < FS_44INODEFMT) { /* XXX */ + quad_t sizepb = fs->fs_bsize; /* XXX */ + /* XXX */ + fs->fs_maxfilesize = fs->fs_bsize * NDADDR - 1; /* XXX */ + for (i = 0; i < NIADDR; i++) { /* XXX */ + sizepb *= NINDIR(fs); /* XXX */ + fs->fs_maxfilesize += sizepb; /* XXX */ + } /* XXX */ + fs->fs_qbmask = ~fs->fs_bmask; /* XXX */ + fs->fs_qfmask = ~fs->fs_fmask; /* XXX */ + } /* XXX */ +} +#endif Property changes on: cvs2svn/tags/initial/lib/libstand/ufs.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/write.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/write.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/write.c (revision 49189) @@ -0,0 +1,96 @@ +/* $NetBSD: write.c,v 1.7 1996/06/21 20:29:30 pk Exp $ */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * The Mach Operating System project at Carnegie-Mellon University. + * + * 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 by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)write.c 8.1 (Berkeley) 6/11/93 + * + * + * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University + * All Rights Reserved. + * + * Author: Alessandro Forin + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include +#include "stand.h" + +ssize_t +write(fd, dest, bcount) + int fd; + void *dest; + size_t bcount; +{ + register struct open_file *f = &files[fd]; + size_t resid; + + if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_WRITE)) { + errno = EBADF; + return (-1); + } + if (f->f_flags & F_RAW) { + twiddle(); + errno = (f->f_dev->dv_strategy)(f->f_devdata, F_WRITE, + btodb(f->f_offset), bcount, dest, &resid); + if (errno) + return (-1); + f->f_offset += resid; + return (resid); + } + resid = bcount; + if ((errno = (f->f_ops->fo_write)(f, dest, bcount, &resid))) + return (-1); + return (0); +} Property changes on: cvs2svn/tags/initial/lib/libstand/write.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: cvs2svn/tags/initial/lib/libstand/zipfs.c =================================================================== --- cvs2svn/tags/initial/lib/libstand/zipfs.c (nonexistent) +++ cvs2svn/tags/initial/lib/libstand/zipfs.c (revision 49189) @@ -0,0 +1,316 @@ +/* + * Copyright (c) 1998 Michael Smith. + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + * + */ + +#include "stand.h" + +#include +#include +#include + +#define Z_BUFSIZE 2048 /* XXX larger? */ + +struct z_file +{ + int zf_rawfd; + z_stream zf_zstream; + char zf_buf[Z_BUFSIZE]; +}; + +static int zf_fill(struct z_file *z); +static int zf_open(char *path, struct open_file *f); +static int zf_close(struct open_file *f); +static int zf_read(struct open_file *f, void *buf, size_t size, size_t *resid); +static off_t zf_seek(struct open_file *f, off_t offset, int where); +static int zf_stat(struct open_file *f, struct stat *sb); + +struct fs_ops zipfs_fsops = { + "zip", + zf_open, + zf_close, + zf_read, + null_write, + zf_seek, + zf_stat +}; + +void * +calloc(int items, size_t size) +{ + return(malloc(items * size)); +} + +static int +zf_fill(struct z_file *zf) +{ + int result; + int req; + + req = Z_BUFSIZE - zf->zf_zstream.avail_in; + result = 0; + + /* If we need more */ + if (req > 0) { + /* move old data to bottom of buffer */ + if (req < Z_BUFSIZE) + bcopy(zf->zf_buf + req, zf->zf_buf, Z_BUFSIZE - req); + + /* read to fill buffer and update availibility data */ + result = read(zf->zf_rawfd, zf->zf_buf + zf->zf_zstream.avail_in, req); + zf->zf_zstream.next_in = zf->zf_buf; + if (result >= 0) + zf->zf_zstream.avail_in += result; + } + return(result); +} + +/* + * Adapted from get_byte/check_header in libz + * + * Returns 0 if the header is OK, nonzero if not. + */ +static int +get_byte(struct z_file *zf) +{ + if ((zf->zf_zstream.avail_in == 0) && (zf_fill(zf) == -1)) + return(-1); + zf->zf_zstream.avail_in--; + return(*(zf->zf_zstream.next_in)++); +} + +static int gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ + +/* gzip flag byte */ +#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ +#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */ +#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ +#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ +#define COMMENT 0x10 /* bit 4 set: file comment present */ +#define RESERVED 0xE0 /* bits 5..7: reserved */ + +static int +check_header(struct z_file *zf) +{ + int method; /* method byte */ + int flags; /* flags byte */ + uInt len; + int c; + + /* Check the gzip magic header */ + for (len = 0; len < 2; len++) { + c = get_byte(zf); + if (c != gz_magic[len]) { + return(1); + } + } + method = get_byte(zf); + flags = get_byte(zf); + if (method != Z_DEFLATED || (flags & RESERVED) != 0) { + return(1); + } + + /* Discard time, xflags and OS code: */ + for (len = 0; len < 6; len++) (void)get_byte(zf); + + if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */ + len = (uInt)get_byte(zf); + len += ((uInt)get_byte(zf))<<8; + /* len is garbage if EOF but the loop below will quit anyway */ + while (len-- != 0 && get_byte(zf) != -1) ; + } + if ((flags & ORIG_NAME) != 0) { /* skip the original file name */ + while ((c = get_byte(zf)) != 0 && c != -1) ; + } + if ((flags & COMMENT) != 0) { /* skip the .gz file comment */ + while ((c = get_byte(zf)) != 0 && c != -1) ; + } + if ((flags & HEAD_CRC) != 0) { /* skip the header crc */ + for (len = 0; len < 2; len++) c = get_byte(zf); + } + /* if there's data left, we're in business */ + return((c == -1) ? 1 : 0); +} + +static int +zf_open(char *fname, struct open_file *f) +{ + static char *zfname; + int rawfd; + struct z_file *zf; + char *cp; + int error; + struct stat sb; + + /* Have to be in "just read it" mode */ + if (f->f_flags != F_READ) + return(EPERM); + + /* If the name already ends in .gz, ignore it */ + if ((cp = strrchr(fname, '.')) && !strcmp(cp, ".gz")) + return(ENOENT); + + /* Construct new name */ + zfname = malloc(strlen(fname) + 3); + sprintf(zfname, "%s.gz", fname); + + /* Try to open the compressed datafile */ + rawfd = open(zfname, O_RDONLY); + free(zfname); + if (rawfd == -1) + return(ENOENT); + + if (fstat(rawfd, &sb) < 0) { + printf("zf_open: stat failed\n"); + close(rawfd); + return(ENOENT); + } + if (!S_ISREG(sb.st_mode)) { + printf("zf_open: not a file\n"); + close(rawfd); + return(EISDIR); /* best guess */ + } + + /* Allocate a z_file structure, populate it */ + zf = malloc(sizeof(struct z_file)); + bzero(zf, sizeof(struct z_file)); + zf->zf_rawfd = rawfd; + + /* Verify that the file is gzipped (XXX why do this afterwards?) */ + if (check_header(zf)) { + close(zf->zf_rawfd); + inflateEnd(&(zf->zf_zstream)); + free(zf); + return(EFTYPE); + } + + /* Initialise the inflation engine */ + if ((error = inflateInit2(&(zf->zf_zstream), -15)) != Z_OK) { + printf("zf_open: inflateInit returned %d : %s\n", error, zf->zf_zstream.msg); + close(zf->zf_rawfd); + free(zf); + return(EIO); + } + + /* Looks OK, we'll take it */ + f->f_fsdata = zf; + return(0); +} + +static int +zf_close(struct open_file *f) +{ + struct z_file *zf = (struct z_file *)f->f_fsdata; + + inflateEnd(&(zf->zf_zstream)); + close(zf->zf_rawfd); + free(zf); + return(0); +} + +static int +zf_read(struct open_file *f, void *buf, size_t size, size_t *resid) +{ + struct z_file *zf = (struct z_file *)f->f_fsdata; + int error; + + zf->zf_zstream.next_out = buf; /* where and how much */ + zf->zf_zstream.avail_out = size; + + while (zf->zf_zstream.avail_out) { + if ((zf->zf_zstream.avail_in == 0) && (zf_fill(zf) == -1)) { + printf("zf_read: fill error\n"); + return(-1); + } + if (zf->zf_zstream.avail_in == 0) { /* oops, unexpected EOF */ + printf("zf_read: unexpected EOF\n"); + break; + } + + error = inflate(&zf->zf_zstream, Z_SYNC_FLUSH); /* decompression pass */ + if (error == Z_STREAM_END) { /* EOF, all done */ + break; + } + if (error != Z_OK) { /* argh, decompression error */ + printf("inflate: %s\n", zf->zf_zstream.msg); + errno = EIO; + return(-1); + } + } + if (resid != NULL) + *resid = zf->zf_zstream.avail_out; + return(0); +} + +static off_t +zf_seek(struct open_file *f, off_t offset, int where) +{ + struct z_file *zf = (struct z_file *)f->f_fsdata; + off_t target; + char discard[16]; + + switch (where) { + case SEEK_SET: + target = offset; + break; + case SEEK_CUR: + target = offset + zf->zf_zstream.total_out; + break; + default: + target = -1; + } + + /* Can we get there from here? */ + if (target < zf->zf_zstream.total_out) { + errno = EOFFSET; + return -1; + } + + /* skip forwards if required */ + while (target > zf->zf_zstream.total_out) { + if (zf_read(f, discard, min(sizeof(discard), target - zf->zf_zstream.total_out), NULL) == -1) + return(-1); + } + /* This is where we are (be honest if we overshot) */ + return (zf->zf_zstream.total_out); +} + + +static int +zf_stat(struct open_file *f, struct stat *sb) +{ + struct z_file *zf = (struct z_file *)f->f_fsdata; + int result; + + /* stat as normal, but indicate that size is unknown */ + if ((result = fstat(zf->zf_rawfd, sb)) == 0) + sb->st_size = -1; + return(result); +} + + + Property changes on: cvs2svn/tags/initial/lib/libstand/zipfs.c ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property