Index: head/stand/common/metadata.c =================================================================== --- head/stand/common/metadata.c (revision 357453) +++ head/stand/common/metadata.c (revision 357454) @@ -1,428 +1,362 @@ /*- * 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. * * from: FreeBSD: src/sys/boot/sparc64/loader/metadata.c,v 1.6 */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #if defined(LOADER_FDT_SUPPORT) #include #endif #ifdef __arm__ #include #endif #include #include "bootstrap.h" #ifdef LOADER_GELI_SUPPORT #include "geliboot.h" #endif -#if defined(__sparc64__) -#include - -extern struct tlb_entry *dtlb_store; -extern struct tlb_entry *itlb_store; - -extern int dtlb_slot; -extern int itlb_slot; - static int -md_bootserial(void) -{ - char buf[64]; - ihandle_t inst; - phandle_t input; - phandle_t node; - phandle_t output; - - if ((node = OF_finddevice("/options")) == -1) - return(-1); - if (OF_getprop(node, "input-device", buf, sizeof(buf)) == -1) - return(-1); - input = OF_finddevice(buf); - if (OF_getprop(node, "output-device", buf, sizeof(buf)) == -1) - return(-1); - output = OF_finddevice(buf); - if (input == -1 || output == -1 || - OF_getproplen(input, "keyboard") >= 0) { - if ((node = OF_finddevice("/chosen")) == -1) - return(-1); - if (OF_getprop(node, "stdin", &inst, sizeof(inst)) == -1) - return(-1); - if ((input = OF_instance_to_package(inst)) == -1) - return(-1); - if (OF_getprop(node, "stdout", &inst, sizeof(inst)) == -1) - return(-1); - if ((output = OF_instance_to_package(inst)) == -1) - return(-1); - } - if (input != output) - return(-1); - if (OF_getprop(input, "device_type", buf, sizeof(buf)) == -1) - return(-1); - if (strcmp(buf, "serial") != 0) - return(-1); - return(0); -} -#endif - -static int md_getboothowto(char *kargs) { int howto; /* Parse kargs */ howto = boot_parse_cmdline(kargs); howto |= boot_env_to_howto(); -#if defined(__sparc64__) - if (md_bootserial() != -1) - howto |= RB_SERIAL; -#else if (!strcmp(getenv("console"), "comconsole")) howto |= RB_SERIAL; if (!strcmp(getenv("console"), "nullconsole")) howto |= RB_MUTE; -#endif 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. */ static vm_offset_t md_copyenv(vm_offset_t addr) { struct env_var *ep; /* traverse the environment */ for (ep = environ; ep != NULL; ep = ep->ev_next) { archsw.arch_copyin(ep->ev_name, addr, strlen(ep->ev_name)); addr += strlen(ep->ev_name); archsw.arch_copyin("=", addr, 1); addr++; if (ep->ev_value != NULL) { archsw.arch_copyin(ep->ev_value, addr, strlen(ep->ev_value)); addr += strlen(ep->ev_value); } archsw.arch_copyin("", addr, 1); addr++; } archsw.arch_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 preceded 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_ARGS (variable) module parameters (string) * MOD_ADDR sizeof(vm_offset_t) module load address * MOD_SIZE sizeof(size_t) module size * MOD_METADATA (variable) type-specific metadata */ static int align; #define COPY32(v, a, c) { \ uint32_t x = (v); \ if (c) \ archsw.arch_copyin(&x, a, sizeof(x)); \ a += sizeof(x); \ } #define MOD_STR(t, a, s, c) { \ COPY32(t, a, c); \ COPY32(strlen(s) + 1, a, c) \ if (c) \ archsw.arch_copyin(s, a, strlen(s) + 1);\ a += roundup(strlen(s) + 1, align); \ } #define MOD_NAME(a, s, c) MOD_STR(MODINFO_NAME, a, s, c) #define MOD_TYPE(a, s, c) MOD_STR(MODINFO_TYPE, a, s, c) #define MOD_ARGS(a, s, c) MOD_STR(MODINFO_ARGS, a, s, c) #define MOD_VAR(t, a, s, c) { \ COPY32(t, a, c); \ COPY32(sizeof(s), a, c); \ if (c) \ archsw.arch_copyin(&s, a, sizeof(s)); \ a += roundup(sizeof(s), align); \ } #define MOD_ADDR(a, s, c) MOD_VAR(MODINFO_ADDR, a, s, c) #define MOD_SIZE(a, s, c) MOD_VAR(MODINFO_SIZE, a, s, c) #define MOD_METADATA(a, mm, c) { \ COPY32(MODINFO_METADATA | mm->md_type, a, c);\ COPY32(mm->md_size, a, c); \ if (c) \ archsw.arch_copyin(mm->md_data, a, mm->md_size);\ a += roundup(mm->md_size, align); \ } #define MOD_END(a, c) { \ COPY32(MODINFO_END, a, c); \ COPY32(0, a, c); \ } static vm_offset_t md_copymodules(vm_offset_t addr, int kern64) { struct preloaded_file *fp; struct file_metadata *md; uint64_t scratch64; uint32_t scratch32; int c; c = addr != 0; /* start with the first module on the list, should be the kernel */ for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) { MOD_NAME(addr, fp->f_name, c); /* this field must come first */ MOD_TYPE(addr, fp->f_type, c); if (fp->f_args) MOD_ARGS(addr, fp->f_args, c); if (kern64) { scratch64 = fp->f_addr; MOD_ADDR(addr, scratch64, c); scratch64 = fp->f_size; MOD_SIZE(addr, scratch64, c); } else { scratch32 = fp->f_addr; #ifdef __arm__ scratch32 -= __elfN(relocation_offset); #endif MOD_ADDR(addr, scratch32, c); MOD_SIZE(addr, fp->f_size, c); } for (md = fp->f_metadata; md != NULL; md = md->md_next) { if (!(md->md_type & MODINFOMD_NOCOPY)) { MOD_METADATA(addr, md, c); } } } MOD_END(addr, c); return(addr); } /* * Load the information expected by a kernel. * * - The 'boothowto' argument is constructed * - The 'bootdev' argument is constructed * - The kernel environment is copied into kernel space. * - Module metadata are formatted and placed in kernel space. */ static int md_load_dual(char *args, vm_offset_t *modulep, vm_offset_t *dtb, int kern64) { struct preloaded_file *kfp; struct preloaded_file *xp; struct file_metadata *md; vm_offset_t kernend; vm_offset_t addr; vm_offset_t envp; #if defined(LOADER_FDT_SUPPORT) vm_offset_t fdtp; #endif vm_offset_t size; uint64_t scratch64; char *rootdevname; int howto; #ifdef __arm__ vm_offset_t vaddr; int i; /* * These metadata addreses must be converted for kernel after * relocation. */ uint32_t mdt[] = { MODINFOMD_SSYM, MODINFOMD_ESYM, MODINFOMD_KERNEND, MODINFOMD_ENVP, #if defined(LOADER_FDT_SUPPORT) MODINFOMD_DTBP #endif }; #endif align = kern64 ? 8 : 4; howto = md_getboothowto(args); /* * Allow the environment variable 'rootdev' to override the supplied * device. This should perhaps go to MI code and/or have $rootdev * tested/set by MI code before launching the kernel. */ rootdevname = getenv("rootdev"); if (rootdevname == NULL) rootdevname = getenv("currdev"); /* Try reading the /etc/fstab file to select the root device */ getrootmount(rootdevname); /* Find the last module in the chain */ addr = 0; for (xp = file_findfile(NULL, NULL); xp != NULL; xp = xp->f_next) { if (addr < (xp->f_addr + xp->f_size)) addr = xp->f_addr + xp->f_size; } /* Pad to a page boundary */ addr = roundup(addr, PAGE_SIZE); /* Copy our environment */ envp = addr; addr = md_copyenv(addr); /* Pad to a page boundary */ addr = roundup(addr, PAGE_SIZE); #if defined(LOADER_FDT_SUPPORT) /* Copy out FDT */ fdtp = 0; #if defined(__powerpc__) if (getenv("usefdt") != NULL) #endif { size = fdt_copy(addr); fdtp = addr; addr = roundup(addr + size, PAGE_SIZE); } #endif kernend = 0; kfp = file_findfile(NULL, kern64 ? "elf64 kernel" : "elf32 kernel"); if (kfp == NULL) kfp = file_findfile(NULL, "elf kernel"); if (kfp == NULL) panic("can't find kernel file"); file_addmetadata(kfp, MODINFOMD_HOWTO, sizeof howto, &howto); if (kern64) { scratch64 = envp; file_addmetadata(kfp, MODINFOMD_ENVP, sizeof scratch64, &scratch64); #if defined(LOADER_FDT_SUPPORT) if (fdtp != 0) { scratch64 = fdtp; file_addmetadata(kfp, MODINFOMD_DTBP, sizeof scratch64, &scratch64); } #endif scratch64 = kernend; file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof scratch64, &scratch64); } else { file_addmetadata(kfp, MODINFOMD_ENVP, sizeof envp, &envp); #if defined(LOADER_FDT_SUPPORT) if (fdtp != 0) file_addmetadata(kfp, MODINFOMD_DTBP, sizeof fdtp, &fdtp); #endif file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof kernend, &kernend); } #ifdef LOADER_GELI_SUPPORT geli_export_key_metadata(kfp); #endif -#if defined(__sparc64__) - file_addmetadata(kfp, MODINFOMD_DTLB_SLOTS, - sizeof dtlb_slot, &dtlb_slot); - file_addmetadata(kfp, MODINFOMD_ITLB_SLOTS, - sizeof itlb_slot, &itlb_slot); - file_addmetadata(kfp, MODINFOMD_DTLB, - dtlb_slot * sizeof(*dtlb_store), dtlb_store); - file_addmetadata(kfp, MODINFOMD_ITLB, - itlb_slot * sizeof(*itlb_store), itlb_store); -#endif *modulep = addr; size = md_copymodules(0, kern64); kernend = roundup(addr + size, PAGE_SIZE); md = file_findmetadata(kfp, MODINFOMD_KERNEND); if (kern64) { scratch64 = kernend; bcopy(&scratch64, md->md_data, sizeof scratch64); } else { bcopy(&kernend, md->md_data, sizeof kernend); } #ifdef __arm__ /* Convert addresses to the final VA */ *modulep -= __elfN(relocation_offset); /* Do relocation fixup on metadata of each module. */ for (xp = file_findfile(NULL, NULL); xp != NULL; xp = xp->f_next) { for (i = 0; i < nitems(mdt); i++) { md = file_findmetadata(xp, mdt[i]); if (md) { bcopy(md->md_data, &vaddr, sizeof vaddr); vaddr -= __elfN(relocation_offset); bcopy(&vaddr, md->md_data, sizeof vaddr); } } } #endif (void)md_copymodules(addr, kern64); #if defined(LOADER_FDT_SUPPORT) if (dtb != NULL) *dtb = fdtp; #endif return(0); } -#if !defined(__sparc64__) int md_load(char *args, vm_offset_t *modulep, vm_offset_t *dtb) { return (md_load_dual(args, modulep, dtb, 0)); } -#endif -#if defined(__mips__) || defined(__powerpc__) || defined(__sparc64__) +#if defined(__mips__) || defined(__powerpc__) int md_load64(char *args, vm_offset_t *modulep, vm_offset_t *dtb) { return (md_load_dual(args, modulep, dtb, 1)); } #endif Index: head/stand/ficl/sparc64/sysdep.c =================================================================== --- head/stand/ficl/sparc64/sysdep.c (revision 357453) +++ head/stand/ficl/sparc64/sysdep.c (nonexistent) @@ -1,99 +0,0 @@ -/******************************************************************* -** s y s d e p . c -** Forth Inspired Command Language -** Author: John Sadler (john_sadler@alum.mit.edu) -** Created: 16 Oct 1997 -** Implementations of FICL external interface functions... -** -*******************************************************************/ - -/* $FreeBSD$ */ - -#ifdef TESTMAIN -#include -#include -#else -#include -#endif -#include "ficl.h" - -/* -******************* FreeBSD P O R T B E G I N S H E R E ******************** Michael Smith -*/ - -#if PORTABLE_LONGMULDIV == 0 -DPUNS ficlLongMul(FICL_UNS x, FICL_UNS y) -{ - DPUNS q; - uint64_t qx; - - qx = (uint64_t)x * (uint64_t) y; - - q.hi = (uint32_t)( qx >> 32 ); - q.lo = (uint32_t)( qx & 0xFFFFFFFFL); - - return q; -} - -UNSQR ficlLongDiv(DPUNS q, FICL_UNS y) -{ - UNSQR result; - uint64_t qx, qh; - - qh = q.hi; - qx = (qh << 32) | q.lo; - - result.quot = qx / y; - result.rem = qx % y; - - return result; -} -#endif - -void ficlTextOut(FICL_VM *pVM, char *msg, int fNewline) -{ - IGNORE(pVM); - - while(*msg != 0) - putchar(*(msg++)); - if (fNewline) - putchar('\n'); - - return; -} - -void *ficlMalloc (size_t size) -{ - return malloc(size); -} - -void *ficlRealloc (void *p, size_t size) -{ - return realloc(p, size); -} - -void ficlFree (void *p) -{ - free(p); -} - - -/* -** Stub function for dictionary access control - does nothing -** by default, user can redefine to guarantee exclusive dict -** access to a single thread for updates. All dict update code -** is guaranteed to be bracketed as follows: -** ficlLockDictionary(TRUE); -** -** ficlLockDictionary(FALSE); -** -** Returns zero if successful, nonzero if unable to acquire lock -** befor timeout (optional - could also block forever) -*/ -#if FICL_MULTITHREAD -int ficlLockDictionary(short fLock) -{ - IGNORE(fLock); - return 0; -} -#endif /* FICL_MULTITHREAD */ Property changes on: head/stand/ficl/sparc64/sysdep.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/stand/ficl/sparc64/sysdep.h =================================================================== --- head/stand/ficl/sparc64/sysdep.h (revision 357453) +++ head/stand/ficl/sparc64/sysdep.h (nonexistent) @@ -1,412 +0,0 @@ -/******************************************************************* - s y s d e p . h -** Forth Inspired Command Language -** Author: John Sadler (john_sadler@alum.mit.edu) -** Created: 16 Oct 1997 -** Ficl system dependent types and prototypes... -** -** Note: Ficl also depends on the use of "assert" when -** FICL_ROBUST is enabled. This may require some consideration -** in firmware systems since assert often -** assumes stderr/stdout. -** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ -*******************************************************************/ -/* -** Copyright (c) 1997-2001 John Sadler (john_sadler@alum.mit.edu) -** All rights reserved. -** -** Get the latest Ficl release at http://ficl.sourceforge.net -** -** L I C E N S E and D I S C L A I M E R -** -** 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. -** -** I am interested in hearing from anyone who uses ficl. If you have -** a problem, a success story, a defect, an enhancement request, or -** if you would like to contribute to the ficl release, please send -** contact me by email at the address above. -** -** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ -*/ - -/* $FreeBSD$ */ - -#if !defined (__SYSDEP_H__) -#define __SYSDEP_H__ - -#include - -#include /* size_t, NULL */ -#include -#include - -#if !defined IGNORE /* Macro to silence unused param warnings */ -#define IGNORE(x) &x -#endif - -/* -** TRUE and FALSE for C boolean operations, and -** portable 32 bit types for CELLs -** -*/ -#if !defined TRUE -#define TRUE 1 -#endif -#if !defined FALSE -#define FALSE 0 -#endif - - -/* -** System dependent data type declarations... -*/ -#if !defined INT32 -#define INT32 int -#endif - -#if !defined UNS32 -#define UNS32 unsigned int -#endif - -#if !defined UNS16 -#define UNS16 unsigned short -#endif - -#if !defined UNS8 -#define UNS8 unsigned char -#endif - -#if !defined NULL -#define NULL ((void *)0) -#endif - -/* -** FICL_UNS and FICL_INT must have the same size as a void* on -** the target system. A CELL is a union of void*, FICL_UNS, and -** FICL_INT. -** (11/2000: same for FICL_FLOAT) -*/ -#if !defined FICL_INT -#define FICL_INT long -#endif - -#if !defined FICL_UNS -#define FICL_UNS unsigned long -#endif - -#if !defined FICL_FLOAT -#define FICL_FLOAT float -#endif - -/* -** Ficl presently supports values of 32 and 64 for BITS_PER_CELL -*/ -#if !defined BITS_PER_CELL -#define BITS_PER_CELL 64 -#endif - -#if ((BITS_PER_CELL != 32) && (BITS_PER_CELL != 64)) - Error! -#endif - -typedef struct -{ - FICL_UNS hi; - FICL_UNS lo; -} DPUNS; - -typedef struct -{ - FICL_UNS quot; - FICL_UNS rem; -} UNSQR; - -typedef struct -{ - FICL_INT hi; - FICL_INT lo; -} DPINT; - -typedef struct -{ - FICL_INT quot; - FICL_INT rem; -} INTQR; - - -/* -** B U I L D C O N T R O L S -*/ - -#if !defined (FICL_MINIMAL) -#define FICL_MINIMAL 0 -#endif -#if (FICL_MINIMAL) -#define FICL_WANT_SOFTWORDS 0 -#define FICL_WANT_FLOAT 0 -#define FICL_WANT_USER 0 -#define FICL_WANT_LOCALS 0 -#define FICL_WANT_DEBUGGER 0 -#define FICL_WANT_OOP 0 -#define FICL_PLATFORM_EXTEND 0 -#define FICL_MULTITHREAD 0 -#define FICL_ROBUST 0 -#define FICL_EXTENDED_PREFIX 0 -#endif - -/* -** FICL_PLATFORM_EXTEND -** Includes words defined in ficlCompilePlatform -*/ -#if !defined (FICL_PLATFORM_EXTEND) -#define FICL_PLATFORM_EXTEND 1 -#endif - -/* -** FICL_WANT_FLOAT -** Includes a floating point stack for the VM, and words to do float operations. -** Contributed by Guy Carver -*/ -#if !defined (FICL_WANT_FLOAT) -#define FICL_WANT_FLOAT 0 -#endif - -/* -** FICL_WANT_DEBUGGER -** Inludes a simple source level debugger -*/ -#if !defined (FICL_WANT_DEBUGGER) -#define FICL_WANT_DEBUGGER 1 -#endif - -/* -** User variables: per-instance variables bound to the VM. -** Kinda like thread-local storage. Could be implemented in a -** VM private dictionary, but I've chosen the lower overhead -** approach of an array of CELLs instead. -*/ -#if !defined FICL_WANT_USER -#define FICL_WANT_USER 1 -#endif - -#if !defined FICL_USER_CELLS -#define FICL_USER_CELLS 16 -#endif - -/* -** FICL_WANT_LOCALS controls the creation of the LOCALS wordset and -** a private dictionary for local variable compilation. -*/ -#if !defined FICL_WANT_LOCALS -#define FICL_WANT_LOCALS 1 -#endif - -/* Max number of local variables per definition */ -#if !defined FICL_MAX_LOCALS -#define FICL_MAX_LOCALS 16 -#endif - -/* -** FICL_WANT_OOP -** Inludes object oriented programming support (in softwords) -** OOP support requires locals and user variables! -*/ -#if !(FICL_WANT_LOCALS) || !(FICL_WANT_USER) -#if !defined (FICL_WANT_OOP) -#define FICL_WANT_OOP 0 -#endif -#endif - -#if !defined (FICL_WANT_OOP) -#define FICL_WANT_OOP 1 -#endif - -/* -** FICL_WANT_SOFTWORDS -** Controls inclusion of all softwords in softcore.c -*/ -#if !defined (FICL_WANT_SOFTWORDS) -#define FICL_WANT_SOFTWORDS 1 -#endif - -/* -** FICL_MULTITHREAD enables dictionary mutual exclusion -** wia the ficlLockDictionary system dependent function. -** Note: this implementation is experimental and poorly -** tested. Further, it's unnecessary unless you really -** intend to have multiple SESSIONS (poor choice of name -** on my part) - that is, threads that modify the dictionary -** at the same time. -*/ -#if !defined FICL_MULTITHREAD -#define FICL_MULTITHREAD 0 -#endif - -/* -** PORTABLE_LONGMULDIV causes ficlLongMul and ficlLongDiv to be -** defined in C in sysdep.c. Use this if you cannot easily -** generate an inline asm definition -*/ -#if !defined (PORTABLE_LONGMULDIV) -#define PORTABLE_LONGMULDIV 0 -#endif - -/* -** INLINE_INNER_LOOP causes the inner interpreter to be inline code -** instead of a function call. This is mainly because MS VC++ 5 -** chokes with an internal compiler error on the function version. -** in release mode. Sheesh. -*/ -#if !defined INLINE_INNER_LOOP -#if defined _DEBUG -#define INLINE_INNER_LOOP 0 -#else -#define INLINE_INNER_LOOP 1 -#endif -#endif - -/* -** FICL_ROBUST enables bounds checking of stacks and the dictionary. -** This will detect stack over and underflows and dictionary overflows. -** Any exceptional condition will result in an assertion failure. -** (As generated by the ANSI assert macro) -** FICL_ROBUST == 1 --> stack checking in the outer interpreter -** FICL_ROBUST == 2 also enables checking in many primitives -*/ - -#if !defined FICL_ROBUST -#define FICL_ROBUST 2 -#endif - -/* -** FICL_DEFAULT_STACK Specifies the default size (in CELLs) of -** a new virtual machine's stacks, unless overridden at -** create time. -*/ -#if !defined FICL_DEFAULT_STACK -#define FICL_DEFAULT_STACK 128 -#endif - -/* -** FICL_DEFAULT_DICT specifies the number of CELLs to allocate -** for the system dictionary by default. The value -** can be overridden at startup time as well. -** FICL_DEFAULT_ENV specifies the number of cells to allot -** for the environment-query dictionary. -*/ -#if !defined FICL_DEFAULT_DICT -#define FICL_DEFAULT_DICT 12288 -#endif - -#if !defined FICL_DEFAULT_ENV -#define FICL_DEFAULT_ENV 260 -#endif - -/* -** FICL_DEFAULT_VOCS specifies the maximum number of wordlists in -** the dictionary search order. See Forth DPANS sec 16.3.3 -** (file://dpans16.htm#16.3.3) -*/ -#if !defined FICL_DEFAULT_VOCS -#define FICL_DEFAULT_VOCS 16 -#endif - -/* -** FICL_MAX_PARSE_STEPS controls the size of an array in the FICL_SYSTEM structure -** that stores pointers to parser extension functions. I would never expect to have -** more than 8 of these, so that's the default limit. Too many of these functions -** will probably exact a nasty performance penalty. -*/ -#if !defined FICL_MAX_PARSE_STEPS -#define FICL_MAX_PARSE_STEPS 8 -#endif - -/* -** FICL_EXTENDED_PREFIX enables a bunch of extra prefixes in prefix.c and prefix.fr (if -** included as part of softcore.c) -*/ -#if !defined FICL_EXTENDED_PREFIX -#define FICL_EXTENDED_PREFIX 0 -#endif - -/* -** FICL_ALIGN is the power of two to which the dictionary -** pointer address must be aligned. This value is usually -** either 1 or 2, depending on the memory architecture -** of the target system; 2 is safe on any 16 or 32 bit -** machine. 3 would be appropriate for a 64 bit machine. -*/ -#if !defined FICL_ALIGN -#define FICL_ALIGN 3 -#define FICL_ALIGN_ADD ((1 << FICL_ALIGN) - 1) -#endif - -/* -** System dependent routines -- -** edit the implementations in sysdep.c to be compatible -** with your runtime environment... -** ficlTextOut sends a NULL terminated string to the -** default output device - used for system error messages -** ficlMalloc and ficlFree have the same semantics as malloc and free -** in standard C -** ficlLongMul multiplies two UNS32s and returns a 64 bit unsigned -** product -** ficlLongDiv divides an UNS64 by an UNS32 and returns UNS32 quotient -** and remainder -*/ -struct vm; -void ficlTextOut(struct vm *pVM, char *msg, int fNewline); -void *ficlMalloc (size_t size); -void ficlFree (void *p); -void *ficlRealloc(void *p, size_t size); -/* -** Stub function for dictionary access control - does nothing -** by default, user can redefine to guarantee exclusive dict -** access to a single thread for updates. All dict update code -** must be bracketed as follows: -** ficlLockDictionary(TRUE); -** -** ficlLockDictionary(FALSE); -** -** Returns zero if successful, nonzero if unable to acquire lock -** before timeout (optional - could also block forever) -** -** NOTE: this function must be implemented with lock counting -** semantics: nested calls must behave properly. -*/ -#if FICL_MULTITHREAD -int ficlLockDictionary(short fLock); -#else -#define ficlLockDictionary(x) 0 /* ignore */ -#endif - -/* -** 64 bit integer math support routines: multiply two UNS32s -** to get a 64 bit product, & divide the product by an UNS32 -** to get an UNS32 quotient and remainder. Much easier in asm -** on a 32 bit CPU than in C, which usually doesn't support -** the double length result (but it should). -*/ -DPUNS ficlLongMul(FICL_UNS x, FICL_UNS y); -UNSQR ficlLongDiv(DPUNS q, FICL_UNS y); - -#endif /*__SYSDEP_H__*/ Property changes on: head/stand/ficl/sparc64/sysdep.h ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/stand/libofw/libofw.h =================================================================== --- head/stand/libofw/libofw.h (revision 357453) +++ head/stand/libofw/libofw.h (revision 357454) @@ -1,85 +1,83 @@ /*- * Copyright (C) 2000 Benno Rice. * 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 Benno Rice ``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. * * $FreeBSD$ */ #include "openfirm.h" struct ofw_devdesc { struct devdesc dd; union { struct { ihandle_t d_handle; char d_path[256]; }; struct { uint64_t pool_guid; uint64_t root_guid; }; }; }; extern int ofw_getdev(void **vdev, const char *devspec, const char **path); extern ev_sethook_t ofw_setcurrdev; extern struct devsw ofwdisk; extern struct netif_driver ofwnet; int ofwn_getunit(const char *); ssize_t ofw_copyin(const void *src, vm_offset_t dest, const size_t len); ssize_t ofw_copyout(const vm_offset_t src, void *dest, const size_t len); ssize_t ofw_readin(const int fd, vm_offset_t dest, const size_t len); extern int ofw_boot(void); extern int ofw_autoload(void); void ofw_memmap(int); struct preloaded_file; struct file_format; /* MD code implementing MI interfaces */ -#if !defined(__sparc64__) vm_offset_t md_load(char *args, vm_offset_t *modulep, vm_offset_t *dtb); -#endif vm_offset_t md_load64(char *args, vm_offset_t *modulep, vm_offset_t *dtb); extern void reboot(void); struct ofw_reg { cell_t base; cell_t size; }; struct ofw_reg2 { cell_t base_hi; cell_t base_lo; cell_t size; }; extern int (*openfirmware)(void *); Index: head/stand/libsa/sparc64/_setjmp.S =================================================================== --- head/stand/libsa/sparc64/_setjmp.S (revision 357453) +++ head/stand/libsa/sparc64/_setjmp.S (nonexistent) @@ -1,94 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The 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. 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: _setjmp.s,v 1.1 91/07/06 16:45:53 torek Exp - */ - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)_setjmp.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: _setjmp.S,v 1.4 1998/10/08 02:27:59 eeh Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -__FBSDID("$FreeBSD$"); - -#define _JB_FP 0x0 -#define _JB_PC 0x8 -#define _JB_SP 0x10 - - .register %g2,#ignore - .register %g3,#ignore - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v?v:1)" from - * the last call to - * setjmp(a) - * by restoring the previous context. - */ - -ENTRY(_setjmp) - stx %sp, [%o0 + _JB_SP] - stx %o7, [%o0 + _JB_PC] - stx %fp, [%o0 + _JB_FP] - retl - clr %o0 -END(_setjmp) - -ENTRY(_longjmp) - mov 1, %g1 - movrnz %o1, %o1, %g1 - mov %o0, %g2 - ldx [%g2 + _JB_FP], %g3 -1: cmp %fp, %g3 - bl,a 1b - restore - be,a 2f - ldx [%g2 + _JB_SP], %o0 - -.Lbotch: - illtrap - -2: cmp %o0, %sp - bge,a 3f - mov %o0, %sp - b,a .Lbotch - nop -3: ldx [%g2 + _JB_PC], %o7 - retl - mov %g1, %o0 -END(_longjmp) Property changes on: head/stand/libsa/sparc64/_setjmp.S ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/stand/loader.mk =================================================================== --- head/stand/loader.mk (revision 357453) +++ head/stand/loader.mk (revision 357454) @@ -1,176 +1,173 @@ # $FreeBSD$ .PATH: ${LDRSRC} ${BOOTSRC}/libsa CFLAGS+=-I${LDRSRC} SRCS+= boot.c commands.c console.c devopen.c interp.c SRCS+= interp_backslash.c interp_parse.c ls.c misc.c SRCS+= module.c .if ${MACHINE} == "i386" || ${MACHINE_CPUARCH} == "amd64" SRCS+= load_elf32.c load_elf32_obj.c reloc_elf32.c SRCS+= load_elf64.c load_elf64_obj.c reloc_elf64.c .elif ${MACHINE_CPUARCH} == "aarch64" SRCS+= load_elf64.c reloc_elf64.c .elif ${MACHINE_CPUARCH} == "arm" SRCS+= load_elf32.c reloc_elf32.c .elif ${MACHINE_CPUARCH} == "powerpc" SRCS+= load_elf32.c reloc_elf32.c SRCS+= load_elf64.c reloc_elf64.c SRCS+= metadata.c -.elif ${MACHINE_CPUARCH} == "sparc64" -SRCS+= load_elf64.c reloc_elf64.c -SRCS+= metadata.c .elif ${MACHINE_ARCH:Mmips64*} != "" SRCS+= load_elf64.c reloc_elf64.c SRCS+= metadata.c .elif ${MACHINE} == "mips" SRCS+= load_elf32.c reloc_elf32.c SRCS+= metadata.c .endif .if ${LOADER_DISK_SUPPORT:Uyes} == "yes" SRCS+= disk.c part.c vdisk.c .endif .if ${LOADER_NET_SUPPORT:Uno} == "yes" SRCS+= dev_net.c .endif .if defined(HAVE_BCACHE) SRCS+= bcache.c .endif .if defined(MD_IMAGE_SIZE) CFLAGS+= -DMD_IMAGE_SIZE=${MD_IMAGE_SIZE} SRCS+= md.c .else CLEANFILES+= md.o .endif # Machine-independant ISA PnP .if defined(HAVE_ISABUS) SRCS+= isapnp.c .endif .if defined(HAVE_PNP) SRCS+= pnp.c .endif .if ${LOADER_INTERP} == "lua" SRCS+= interp_lua.c .include "${BOOTSRC}/lua.mk" LDR_INTERP= ${LIBLUA} LDR_INTERP32= ${LIBLUA32} CFLAGS.interp_lua.c= -DLUA_PATH=\"${LUAPATH}\" -I${FLUASRC}/modules .elif ${LOADER_INTERP} == "4th" SRCS+= interp_forth.c .include "${BOOTSRC}/ficl.mk" LDR_INTERP= ${LIBFICL} LDR_INTERP32= ${LIBFICL32} .elif ${LOADER_INTERP} == "simp" SRCS+= interp_simple.c .else .error Unknown interpreter ${LOADER_INTERP} .endif .if ${MK_LOADER_VERIEXEC} != "no" CFLAGS+= -DLOADER_VERIEXEC -I${SRCTOP}/lib/libsecureboot/h .endif .if ${MK_LOADER_VERIEXEC_PASS_MANIFEST} != "no" CFLAGS+= -DLOADER_VERIEXEC_PASS_MANIFEST -I${SRCTOP}/lib/libsecureboot/h .endif .if defined(BOOT_PROMPT_123) CFLAGS+= -DBOOT_PROMPT_123 .endif .if defined(LOADER_INSTALL_SUPPORT) SRCS+= install.c .endif # Filesystem support .if ${LOADER_CD9660_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_CD9660_SUPPORT .endif .if ${LOADER_EXT2FS_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_EXT2FS_SUPPORT .endif .if ${LOADER_MSDOS_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_MSDOS_SUPPORT .endif .if ${LOADER_UFS_SUPPORT:Uyes} == "yes" CFLAGS+= -DLOADER_UFS_SUPPORT .endif # Compression .if ${LOADER_GZIP_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_GZIP_SUPPORT .endif .if ${LOADER_BZIP2_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_BZIP2_SUPPORT .endif # Network related things .if ${LOADER_NET_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_NET_SUPPORT .endif .if ${LOADER_NFS_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_NFS_SUPPORT .endif .if ${LOADER_TFTP_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_TFTP_SUPPORT .endif # Partition support .if ${LOADER_GPT_SUPPORT:Uyes} == "yes" CFLAGS+= -DLOADER_GPT_SUPPORT .endif .if ${LOADER_MBR_SUPPORT:Uyes} == "yes" CFLAGS+= -DLOADER_MBR_SUPPORT .endif .if ${HAVE_ZFS:Uno} == "yes" CFLAGS+= -DLOADER_ZFS_SUPPORT CFLAGS+= -I${ZFSSRC} CFLAGS+= -I${SYSDIR}/cddl/boot/zfs SRCS+= zfs_cmd.c .endif LIBFICL= ${BOOTOBJ}/ficl/libficl.a .if ${MACHINE} == "i386" LIBFICL32= ${LIBFICL} .else LIBFICL32= ${BOOTOBJ}/ficl32/libficl.a .endif LIBLUA= ${BOOTOBJ}/liblua/liblua.a .if ${MACHINE} == "i386" LIBLUA32= ${LIBLUA} .else LIBLUA32= ${BOOTOBJ}/liblua32/liblua.a .endif CLEANFILES+= vers.c VERSION_FILE?= ${.CURDIR}/version .if ${MK_REPRODUCIBLE_BUILD} != no REPRO_FLAG= -r .endif vers.c: ${LDRSRC}/newvers.sh ${VERSION_FILE} sh ${LDRSRC}/newvers.sh ${REPRO_FLAG} ${VERSION_FILE} \ ${NEWVERSWHAT} .if ${MK_LOADER_VERBOSE} != "no" CFLAGS+= -DELF_VERBOSE .endif .if !empty(HELP_FILES) HELP_FILES+= ${LDRSRC}/help.common CLEANFILES+= loader.help FILES+= loader.help loader.help: ${HELP_FILES} cat ${HELP_FILES} | awk -f ${LDRSRC}/merge_help.awk > ${.TARGET} .endif Index: head/stand/man/loader.8 =================================================================== --- head/stand/man/loader.8 (revision 357453) +++ head/stand/man/loader.8 (revision 357454) @@ -1,1128 +1,1128 @@ .\" Copyright (c) 1999 Daniel C. Sobral .\" 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. .\" .\" $FreeBSD$ .\" .Dd August 15, 2018 .Dt LOADER 8 .Os .Sh NAME .Nm loader .Nd kernel bootstrapping final stage .Sh DESCRIPTION The program called .Nm is the final stage of .Fx Ns 's kernel bootstrapping process. On IA32 (i386) architectures, it is a .Pa BTX client. It is linked statically to .Xr libstand 3 and usually located in the directory .Pa /boot . .Pp It provides a scripting language that can be used to automate tasks, do pre-configuration or assist in recovery procedures. This scripting language is roughly divided in two main components. The smaller one is a set of commands designed for direct use by the casual user, called "builtin commands" for historical reasons. The main drive behind these commands is user-friendliness. The bigger component is an .Tn ANS Forth compatible Forth interpreter based on FICL, by .An John Sadler . .Pp During initialization, .Nm will probe for a console and set the .Va console variable, or set it to serial console .Pq Dq Li comconsole if the previous boot stage used that. If multiple consoles are selected, they will be listed separated by spaces. Then, devices are probed, .Va currdev and .Va loaddev are set, and .Va LINES is set to 24. Next, .Tn FICL is initialized, the builtin words are added to its vocabulary, and .Pa /boot/boot.4th is processed if it exists. No disk switching is possible while that file is being read. The inner interpreter .Nm will use with .Tn FICL is then set to .Ic interpret , which is .Tn FICL Ns 's default. After that, .Pa /boot/loader.rc is processed if available. These files are processed through the .Ic include command, which reads all of them into memory before processing them, making disk changes possible. .Pp At this point, if an .Ic autoboot has not been tried, and if .Va autoboot_delay is not set to .Dq Li NO (not case sensitive), then an .Ic autoboot will be tried. If the system gets past this point, .Va prompt will be set and .Nm will engage interactive mode. Please note that historically even when .Va autoboot_delay is set to .Dq Li 0 user will be able to interrupt autoboot process by pressing some key on the console while kernel and modules are being loaded. In some cases such behaviour may be undesirable, to prevent it set .Va autoboot_delay to .Dq Li -1 , in this case .Nm will engage interactive mode only if .Ic autoboot has failed. .Sh BUILTIN COMMANDS In .Nm , builtin commands take parameters from the command line. Presently, the only way to call them from a script is by using .Pa evaluate on a string. If an error condition occurs, an exception will be generated, which can be intercepted using .Tn ANS Forth exception handling words. If not intercepted, an error message will be displayed and the interpreter's state will be reset, emptying the stack and restoring interpreting mode. .Pp The builtin commands available are: .Pp .Bl -tag -width Ds -compact .It Ic autoboot Op Ar seconds Op Ar prompt Proceeds to bootstrap the system after a number of seconds, if not interrupted by the user. Displays a countdown prompt warning the user the system is about to be booted, unless interrupted by a key press. The kernel will be loaded first if necessary. Defaults to 10 seconds. .Pp .It Ic bcachestat Displays statistics about disk cache usage. For debugging only. .Pp .It Ic boot .It Ic boot Ar kernelname Op Cm ... .It Ic boot Fl flag Cm ... Immediately proceeds to bootstrap the system, loading the kernel if necessary. Any flags or arguments are passed to the kernel, but they must precede the kernel name, if a kernel name is provided. .Pp .Em WARNING : The behavior of this builtin is changed if .Xr loader.4th 8 is loaded. .Pp .It Ic echo Xo .Op Fl n .Op Aq message .Xc Displays text on the screen. A new line will be printed unless .Fl n is specified. .Pp .It Ic heap Displays memory usage statistics. For debugging purposes only. .Pp .It Ic help Op topic Op subtopic Shows help messages read from .Pa /boot/loader.help . The special topic .Em index will list the topics available. .Pp .It Ic include Ar file Op Ar Process script files. Each file, in turn, is completely read into memory, and then each of its lines is passed to the command line interpreter. If any error is returned by the interpreter, the include command aborts immediately, without reading any other files, and returns an error itself (see .Sx ERRORS ) . .Pp .It Ic load Xo .Op Fl t Ar type .Ar file Cm ... .Xc Loads a kernel, kernel loadable module (kld), disk image, or file of opaque contents tagged as being of the type .Ar type . Kernel and modules can be either in a.out or ELF format. Any arguments passed after the name of the file to be loaded will be passed as arguments to that file. Use the .Li md_image type to make the kernel create a file-backed .Xr md 4 disk. This is useful for booting from a temporary rootfs. Currently, argument passing does not work for the kernel. .Pp .It Ic load_geli Xo .Op Fl n Ar keyno .Ar prov Ar file .Xc Loads a .Xr geli 8 encryption keyfile for the given provider name. The key index can be specified via .Ar keyno or will default to zero. .Pp .It Ic ls Xo .Op Fl l .Op Ar path .Xc Displays a listing of files in the directory .Ar path , or the root directory if .Ar path is not specified. If .Fl l is specified, file sizes will be shown too. .Pp .It Ic lsdev Op Fl v Lists all of the devices from which it may be possible to load modules, as well as ZFS pools. If .Fl v is specified, more details are printed, including ZFS pool information in a format that resembles .Nm zpool Cm status output. .Pp .It Ic lsmod Op Fl v Displays loaded modules. If .Fl v is specified, more details are shown. .Pp .It Ic lszfs Ar filesystem A ZFS extended command that can be used to explore the ZFS filesystem hierarchy in a pool. Lists the immediate children of the .Ar filesystem . The filesystem hierarchy is rooted at a filesystem with the same name as the pool. .Pp .It Ic more Ar file Op Ar Display the files specified, with a pause at each .Va LINES displayed. .Pp .It Ic pnpscan Op Fl v Scans for Plug-and-Play devices. This is not functional at present. .Pp .It Ic read Xo .Op Fl t Ar seconds .Op Fl p Ar prompt .Op Va variable .Xc Reads a line of input from the terminal, storing it in .Va variable if specified. A timeout can be specified with .Fl t , though it will be canceled at the first key pressed. A prompt may also be displayed through the .Fl p flag. .Pp .It Ic reboot Immediately reboots the system. .Pp .It Ic set Ar variable .It Ic set Ar variable Ns = Ns Ar value Set loader's environment variables. .Pp .It Ic show Op Va variable Displays the specified variable's value, or all variables and their values if .Va variable is not specified. .Pp .It Ic unload Remove all modules from memory. .Pp .It Ic unset Va variable Removes .Va variable from the environment. .Pp .It Ic \&? Lists available commands. .El .Ss BUILTIN ENVIRONMENT VARIABLES The .Nm has actually two different kinds of .Sq environment variables. There are ANS Forth's .Em environmental queries , and a separate space of environment variables used by builtins, which are not directly available to Forth words. It is the latter type that this section covers. .Pp Environment variables can be set and unset through the .Ic set and .Ic unset builtins, and can have their values interactively examined through the use of the .Ic show builtin. Their values can also be accessed as described in .Sx BUILTIN PARSER . .Pp Notice that these environment variables are not inherited by any shell after the system has been booted. .Pp A few variables are set automatically by .Nm . Others can affect the behavior of either .Nm or the kernel at boot. Some options may require a value, while others define behavior just by being set. Both types of builtin variables are described below. .Bl -tag -width bootfile .It Va autoboot_delay Number of seconds .Ic autoboot will wait before booting. If this variable is not defined, .Ic autoboot will default to 10 seconds. .Pp If set to .Dq Li NO , no .Ic autoboot will be automatically attempted after processing .Pa /boot/loader.rc , though explicit .Ic autoboot Ns 's will be processed normally, defaulting to 10 seconds delay. .Pp If set to .Dq Li 0 , no delay will be inserted, but user still will be able to interrupt .Ic autoboot process and escape into the interactive mode by pressing some key on the console while kernel and modules are being loaded. .Pp If set to .Dq Li -1 , no delay will be inserted and .Nm will engage interactive mode only if .Ic autoboot has failed for some reason. .It Va boot_askname Instructs the kernel to prompt the user for the name of the root device when the kernel is booted. .It Va boot_cdrom Instructs the kernel to try to mount the root file system from CD-ROM. .It Va boot_ddb Instructs the kernel to start in the DDB debugger, rather than proceeding to initialize when booted. .It Va boot_dfltroot Instructs the kernel to mount the statically compiled-in root file system. .It Va boot_gdb Selects gdb-remote mode for the kernel debugger by default. .It Va boot_multicons Enables multiple console support in the kernel early on boot. In a running system, console configuration can be manipulated by the .Xr conscontrol 8 utility. .It Va boot_mute All kernel console output is suppressed when console is muted. In a running system, the state of console muting can be manipulated by the .Xr conscontrol 8 utility. .It Va boot_pause During the device probe, pause after each line is printed. .It Va boot_serial Force the use of a serial console even when an internal console is present. .It Va boot_single Prevents the kernel from initiating a multi-user startup; instead, a single-user mode will be entered when the kernel has finished device probing. .It Va boot_verbose Setting this variable causes extra debugging information to be printed by the kernel during the boot phase. .It Va bootfile List of semicolon-separated search path for bootable kernels. The default is .Dq Li kernel . .It Va comconsole_speed Defines the speed of the serial console (i386 and amd64 only). If the previous boot stage indicated that a serial console is in use then this variable is initialized to the current speed of the console serial port. Otherwise it is set to 9600 unless this was overridden using the .Va BOOT_COMCONSOLE_SPEED variable when .Nm was compiled. Changes to the .Va comconsole_speed variable take effect immediately. .It Va comconsole_port Defines the base i/o port used to access console UART (i386 and amd64 only). If the variable is not set, its assumed value is 0x3F8, which corresponds to PC port COM1, unless overridden by .Va BOOT_COMCONSOLE_PORT variable during the compilation of .Nm . Setting the .Va comconsole_port variable automatically set .Va hw.uart.console environment variable to provide a hint to kernel for location of the console. Loader console is changed immediately after variable .Va comconsole_port is set. .It Va comconsole_pcidev Defines the location of a PCI device of the 'simple communication' class to be used as the serial console UART (i386 and amd64 only). The syntax of the variable is .Li 'bus:device:function[:bar]' , where all members must be numeric, with possible .Li 0x prefix to indicate a hexadecimal value. The .Va bar member is optional and assumed to be 0x10 if omitted. The bar must decode i/o space. Setting the variable .Va comconsole_pcidev automatically sets the variable .Va comconsole_port to the base of the selected bar, and hint .Va hw.uart.console . Loader console is changed immediately after variable .Va comconsole_pcidev is set. .It Va console Defines the current console or consoles. Multiple consoles may be specified. In that case, the first listed console will become the default console for userland output (e.g.\& from .Xr init 8 ) . .It Va currdev Selects the default device. Syntax for devices is odd. .It Va dumpdev Sets the device for kernel dumps. This can be used to ensure that a device is configured before the corresponding .Va dumpdev directive from .Xr rc.conf 5 has been processed, allowing kernel panics that happen during the early stages of boot to be captured. .It Va init_chroot See .Xr init 8 . .It Va init_exec See .Xr init 8 . .It Va init_path Sets the list of binaries which the kernel will try to run as the initial process. The first matching binary is used. The default list is .Dq Li /sbin/init:/sbin/oinit:/sbin/init.bak:\:/rescue/init . .It Va init_script See .Xr init 8 . .It Va init_shell See .Xr init 8 . .It Va interpret Has the value .Dq Li OK if the Forth's current state is interpreting. .It Va LINES Define the number of lines on the screen, to be used by the pager. .It Va module_path Sets the list of directories which will be searched for modules named in a load command or implicitly required by a dependency. The default value for this variable is .Dq Li /boot/kernel;/boot/modules . .It Va num_ide_disks Sets the number of IDE disks as a workaround for some problems in finding the root disk at boot. This has been deprecated in favor of .Va root_disk_unit . .It Va prompt Value of .Nm Ns 's prompt. Defaults to .Dq Li "${interpret}" . If variable .Va prompt is unset, the default prompt is .Ql > . .It Va root_disk_unit If the code which detects the disk unit number for the root disk is confused, e.g.\& by a mix of SCSI and IDE disks, or IDE disks with gaps in the sequence (e.g.\& no primary slave), the unit number can be forced by setting this variable. .It Va rootdev By default the value of .Va currdev is used to set the root file system when the kernel is booted. This can be overridden by setting .Va rootdev explicitly. .El .Pp Other variables are used to override kernel tunable parameters. The following tunables are available: .Bl -tag -width Va .It Va efi.rt.disabled Disable UEFI runtime services in the kernel, if applicable. Runtime services are only available and used if the kernel is booted in a UEFI environment. .It Va hw.physmem Limit the amount of physical memory the system will use. By default the size is in bytes, but the .Cm k , K , m , M , g and .Cm G suffixes are also accepted and indicate kilobytes, megabytes and gigabytes respectively. An invalid suffix will result in the variable being ignored by the kernel. .It Va hw.pci.host_start_mem , hw.acpi.host_start_mem When not otherwise constrained, this limits the memory start address. The default is 0x80000000 and should be set to at least size of the memory and not conflict with other resources. Typically, only systems without PCI bridges need to set this variable since PCI bridges typically constrain the memory starting address (and the variable is only used when bridges do not constrain this address). .It Va hw.pci.enable_io_modes Enable PCI resources which are left off by some BIOSes or are not enabled correctly by the device driver. Tunable value set to ON (1) by default, but this may cause problems with some peripherals. .It Va kern.maxusers Set the size of a number of statically allocated system tables; see .Xr tuning 7 for a description of how to select an appropriate value for this tunable. When set, this tunable replaces the value declared in the kernel compile-time configuration file. .It Va kern.ipc.nmbclusters Set the number of mbuf clusters to be allocated. The value cannot be set below the default determined when the kernel was compiled. .It Va kern.ipc.nsfbufs Set the number of .Xr sendfile 2 buffers to be allocated. Overrides .Dv NSFBUFS . Not all architectures use such buffers; see .Xr sendfile 2 for details. .It Va kern.maxswzone Limits the amount of KVM to be used to hold swap metadata, which directly governs the maximum amount of swap the system can support, at the rate of approximately 200 MB of swap space per 1 MB of metadata. This value is specified in bytes of KVA space. If no value is provided, the system allocates enough memory to handle an amount of swap that corresponds to eight times the amount of physical memory present in the system. .Pp Note that swap metadata can be fragmented, which means that the system can run out of space before it reaches the theoretical limit. Therefore, care should be taken to not configure more swap than approximately half of the theoretical maximum. .Pp Running out of space for swap metadata can leave the system in an unrecoverable state. Therefore, you should only change this parameter if you need to greatly extend the KVM reservation for other resources such as the buffer cache or .Va kern.ipc.nmbclusters . Modifies kernel option .Dv VM_SWZONE_SIZE_MAX . .It Va kern.maxbcache Limits the amount of KVM reserved for use by the buffer cache, specified in bytes. The default maximum is 200MB on i386, -and 400MB on amd64 and sparc64. +and 400MB on amd64. This parameter is used to prevent the buffer cache from eating too much KVM in large-memory machine configurations. Only mess around with this parameter if you need to greatly extend the KVM reservation for other resources such as the swap zone or .Va kern.ipc.nmbclusters . Note that the NBUF parameter will override this limit. Modifies .Dv VM_BCACHE_SIZE_MAX . .It Va kern.msgbufsize Sets the size of the kernel message buffer. The default limit of 64KB is usually sufficient unless large amounts of trace data need to be collected between opportunities to examine the buffer or dump it to a file. Overrides kernel option .Dv MSGBUF_SIZE . .It Va machdep.disable_mtrrs Disable the use of i686 MTRRs (x86 only). .It Va net.inet.tcp.tcbhashsize Overrides the compile-time set value of .Dv TCBHASHSIZE or the preset default of 512. Must be a power of 2. .It Va twiddle_divisor Throttles the output of the .Sq twiddle I/O progress indicator displayed while loading the kernel and modules. This is useful on slow serial consoles where the time spent waiting for these characters to be written can add up to many seconds. The default is 1 (full speed); a value of 2 spins half as fast, and so on. .It Va vm.kmem_size Sets the size of kernel memory (bytes). This overrides the value determined when the kernel was compiled. Modifies .Dv VM_KMEM_SIZE . .It Va vm.kmem_size_min .It Va vm.kmem_size_max Sets the minimum and maximum (respectively) amount of kernel memory that will be automatically allocated by the kernel. These override the values determined when the kernel was compiled. Modifies .Dv VM_KMEM_SIZE_MIN and .Dv VM_KMEM_SIZE_MAX . .El .Ss ZFS FEATURES .Nm supports the following format for specifying ZFS filesystems which can be used wherever .Xr loader 8 refers to a device specification: .Pp .Ar zfs:pool/filesystem: .Pp where .Pa pool/filesystem is a ZFS filesystem name as described in .Xr zfs 8 . .Pp If .Pa /etc/fstab does not have an entry for the root filesystem and .Va vfs.root.mountfrom is not set, but .Va currdev refers to a ZFS filesystem, then .Nm will instruct kernel to use that filesystem as the root filesystem. .Ss BUILTIN PARSER When a builtin command is executed, the rest of the line is taken by it as arguments, and it is processed by a special parser which is not used for regular Forth commands. .Pp This special parser applies the following rules to the parsed text: .Bl -enum .It All backslash characters are preprocessed. .Bl -bullet .It \eb , \ef , \er , \en and \et are processed as in C. .It \es is converted to a space. .It \ev is converted to .Tn ASCII 11. .It \ez is just skipped. Useful for things like .Dq \e0xf\ez\e0xf . .It \e0xN and \e0xNN are replaced by the hex N or NN. .It \eNNN is replaced by the octal NNN .Tn ASCII character. .It \e" , \e' and \e$ will escape these characters, preventing them from receiving special treatment in Step 2, described below. .It \e\e will be replaced with a single \e . .It In any other occurrence, backslash will just be removed. .El .It Every string between non-escaped quotes or double-quotes will be treated as a single word for the purposes of the remaining steps. .It Replace any .Li $VARIABLE or .Li ${VARIABLE} with the value of the environment variable .Va VARIABLE . .It Space-delimited arguments are passed to the called builtin command. Spaces can also be escaped through the use of \e\e . .El .Pp An exception to this parsing rule exists, and is described in .Sx BUILTINS AND FORTH . .Ss BUILTINS AND FORTH All builtin words are state-smart, immediate words. If interpreted, they behave exactly as described previously. If they are compiled, though, they extract their arguments from the stack instead of the command line. .Pp If compiled, the builtin words expect to find, at execution time, the following parameters on the stack: .D1 Ar addrN lenN ... addr2 len2 addr1 len1 N where .Ar addrX lenX are strings which will compose the command line that will be parsed into the builtin's arguments. Internally, these strings are concatenated in from 1 to N, with a space put between each one. .Pp If no arguments are passed, a 0 .Em must be passed, even if the builtin accepts no arguments. .Pp While this behavior has benefits, it has its trade-offs. If the execution token of a builtin is acquired (through .Ic ' or .Ic ['] ) , and then passed to .Ic catch or .Ic execute , the builtin behavior will depend on the system state .Bf Em at the time .Ic catch or .Ic execute is processed! .Ef This is particularly annoying for programs that want or need to handle exceptions. In this case, the use of a proxy is recommended. For example: .Dl : (boot) boot ; .Sh FICL .Tn FICL is a Forth interpreter written in C, in the form of a forth virtual machine library that can be called by C functions and vice versa. .Pp In .Nm , each line read interactively is then fed to .Tn FICL , which may call .Nm back to execute the builtin words. The builtin .Ic include will also feed .Tn FICL , one line at a time. .Pp The words available to .Tn FICL can be classified into four groups. The .Tn ANS Forth standard words, extra .Tn FICL words, extra .Fx words, and the builtin commands; the latter were already described. The .Tn ANS Forth standard words are listed in the .Sx STANDARDS section. The words falling in the two other groups are described in the following subsections. .Ss FICL EXTRA WORDS .Bl -tag -width wid-set-super .It Ic .env .It Ic .ver .It Ic -roll .It Ic 2constant .It Ic >name .It Ic body> .It Ic compare This is the STRING word set's .Ic compare . .It Ic compile-only .It Ic endif .It Ic forget-wid .It Ic parse-word .It Ic sliteral This is the STRING word set's .Ic sliteral . .It Ic wid-set-super .It Ic w@ .It Ic w! .It Ic x. .It Ic empty .It Ic cell- .It Ic -rot .El .Ss FREEBSD EXTRA WORDS .Bl -tag -width XXXXXXXX .It Ic \&$ Pq -- Evaluates the remainder of the input buffer, after having printed it first. .It Ic \&% Pq -- Evaluates the remainder of the input buffer under a .Ic catch exception guard. .It Ic .# Works like .Ic "." but without outputting a trailing space. .It Ic fclose Pq Ar fd -- Closes a file. .It Ic fkey Pq Ar fd -- char Reads a single character from a file. .It Ic fload Pq Ar fd -- Processes a file .Em fd . .It Ic fopen Pq Ar addr len mode Li -- Ar fd Opens a file. Returns a file descriptor, or \-1 in case of failure. The .Ar mode parameter selects whether the file is to be opened for read access, write access, or both. The constants .Dv O_RDONLY , O_WRONLY , and .Dv O_RDWR are defined in .Pa /boot/support.4th , indicating read only, write only, and read-write access, respectively. .It Xo .Ic fread .Pq Ar fd addr len -- len' .Xc Tries to read .Em len bytes from file .Em fd into buffer .Em addr . Returns the actual number of bytes read, or -1 in case of error or end of file. .It Ic heap? Pq -- Ar cells Return the space remaining in the dictionary heap, in cells. This is not related to the heap used by dynamic memory allocation words. .It Ic inb Pq Ar port -- char Reads a byte from a port. .It Ic key Pq -- Ar char Reads a single character from the console. .It Ic key? Pq -- Ar flag Returns .Ic true if there is a character available to be read from the console. .It Ic ms Pq Ar u -- Waits .Em u microseconds. .It Ic outb Pq Ar port char -- Writes a byte to a port. .It Ic seconds Pq -- Ar u Returns the number of seconds since midnight. .It Ic tib> Pq -- Ar addr len Returns the remainder of the input buffer as a string on the stack. .It Ic trace! Pq Ar flag -- Activates or deactivates tracing. Does not work with .Ic catch . .El .Ss FREEBSD DEFINED ENVIRONMENTAL QUERIES .Bl -tag -width Ds .It arch-i386 .Ic TRUE if the architecture is IA32. .It FreeBSD_version .Fx version at compile time. .It loader_version .Nm version. .El .Sh SECURITY Access to the .Nm command line provides several ways of compromising system security, including, but not limited to: .Pp .Bl -bullet .It Booting from removable storage, by setting the .Va currdev or .Va loaddev variables .It Executing binary of choice, by setting the .Va init_path or .Va init_script variables .It Overriding ACPI DSDT to inject arbitrary code into the ACPI subsystem .El .Pp One can prevent unauthorized access to the .Nm command line by setting the .Va password , or setting .Va autoboot_delay to -1. See .Xr loader.conf 5 for details. In order for this to be effective, one should also configure the firmware (BIOS or UEFI) to prevent booting from unauthorized devices. .Sh FILES .Bl -tag -width /usr/share/examples/bootforth/ -compact .It Pa /boot/loader .Nm itself. .It Pa /boot/boot.4th Additional .Tn FICL initialization. .It Pa /boot/defaults/loader.conf .It Pa /boot/loader.4th Extra builtin-like words. .It Pa /boot/loader.conf .It Pa /boot/loader.conf.local .Nm configuration files, as described in .Xr loader.conf 5 . .It Pa /boot/loader.rc .Nm bootstrapping script. .It Pa /boot/loader.help Loaded by .Ic help . Contains the help messages. .It Pa /boot/support.4th .Pa loader.conf processing words. .It Pa /usr/share/examples/bootforth/ Assorted examples. .El .Sh EXAMPLES Boot in single user mode: .Pp .Dl boot -s .Pp Load the kernel, a splash screen, and then autoboot in five seconds. Notice that a kernel must be loaded before any other .Ic load command is attempted. .Bd -literal -offset indent load kernel load splash_bmp load -t splash_image_data /boot/chuckrulez.bmp autoboot 5 .Ed .Pp Set the disk unit of the root device to 2, and then boot. This would be needed in a system with two IDE disks, with the second IDE disk hardwired to ada2 instead of ada1. .Bd -literal -offset indent set root_disk_unit=2 boot /boot/kernel/kernel .Ed .Pp Set the default device used for loading a kernel from a ZFS filesystem: .Bd -literal -offset indent set currdev=zfs:tank/ROOT/knowngood: .Ed .Pp .Sh ERRORS The following values are thrown by .Nm : .Bl -tag -width XXXXX -offset indent .It 100 Any type of error in the processing of a builtin. .It -1 .Ic Abort executed. .It -2 .Ic Abort" executed. .It -56 .Ic Quit executed. .It -256 Out of interpreting text. .It -257 Need more text to succeed -- will finish on next run. .It -258 .Ic Bye executed. .It -259 Unspecified error. .El .Sh SEE ALSO .Xr libstand 3 , .Xr loader.conf 5 , .Xr tuning 7 , .Xr boot 8 , .Xr btxld 8 .Sh STANDARDS For the purposes of ANS Forth compliance, loader is an .Bf Em ANS Forth System with Environmental Restrictions, Providing .Ef .Bf Li .No .( , .No :noname , .No ?do , parse, pick, roll, refill, to, value, \e, false, true, .No <> , .No 0<> , compile\&, , erase, nip, tuck .Ef .Em and .Li marker .Bf Em from the Core Extensions word set, Providing the Exception Extensions word set, Providing the Locals Extensions word set, Providing the Memory-Allocation Extensions word set, Providing .Ef .Bf Li \&.s, bye, forget, see, words, \&[if], \&[else] .Ef .Em and .Li [then] .Bf Em from the Programming-Tools extension word set, Providing the Search-Order extensions word set. .Ef .Sh HISTORY The .Nm first appeared in .Fx 3.1 . .Sh AUTHORS .An -nosplit The .Nm was written by .An Michael Smith Aq msmith@FreeBSD.org . .Pp .Tn FICL was written by .An John Sadler Aq john_sadler@alum.mit.edu . .Sh BUGS The .Ic expect and .Ic accept words will read from the input buffer instead of the console. The latter will be fixed, but the former will not. Index: head/stand/sparc64/Makefile.inc =================================================================== --- head/stand/sparc64/Makefile.inc (revision 357453) +++ head/stand/sparc64/Makefile.inc (nonexistent) @@ -1,5 +0,0 @@ -# $FreeBSD$ - -LDFLAGS+= -nostdlib - -.include "../Makefile.inc" Property changes on: head/stand/sparc64/Makefile.inc ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/stand/sparc64/Makefile =================================================================== --- head/stand/sparc64/Makefile (revision 357453) +++ head/stand/sparc64/Makefile (nonexistent) @@ -1,10 +0,0 @@ -# $FreeBSD$ - -NO_OBJ=t - -.include - -SUBDIR.yes= boot1 loader -SUBDIR.${MK_LOADER_ZFS}+=zfsboot - -.include Property changes on: head/stand/sparc64/Makefile ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/stand/sparc64/boot1/_start.s =================================================================== --- head/stand/sparc64/boot1/_start.s (revision 357453) +++ head/stand/sparc64/boot1/_start.s (nonexistent) @@ -1,8 +0,0 @@ -/* $FreeBSD$ */ - - .text - .globl _start -_start: - call ofw_init - nop - sir Property changes on: head/stand/sparc64/boot1/_start.s ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/stand/sparc64/boot1/boot1.c =================================================================== --- head/stand/sparc64/boot1/boot1.c (revision 357453) +++ head/stand/sparc64/boot1/boot1.c (nonexistent) @@ -1,751 +0,0 @@ -/*- - * Copyright (c) 1998 Robert Nordier - * All rights reserved. - * Copyright (c) 2001 Robert Drehmel - * All rights reserved. - * - * Redistribution and use in source and binary forms are freely - * permitted provided that the above copyright notice and this - * paragraph and the following disclaimer are duplicated in all - * such forms. - * - * This software is provided "AS IS" and without any express or - * implied warranties, including, without limitation, the implied - * warranties of merchantability and fitness for a particular - * purpose. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include - -#include -#include - -#include "paths.h" - -#define READ_BUF_SIZE 8192 - -typedef int putc_func_t(char c, void *arg); -typedef int32_t ofwh_t; - -struct sp_data { - char *sp_buf; - u_int sp_len; - u_int sp_size; -}; - -static const char digits[] = "0123456789abcdef"; - -static char bootpath[128]; -static char bootargs[128]; - -static ofwh_t bootdev; - -static uint32_t fs_off; - -int main(int ac, char **av); -static void exit(int) __dead2; -static void usage(void); - -#ifdef ZFSBOOT -static void loadzfs(void); -static int zbread(char *buf, off_t off, size_t bytes); -#else -static void load(const char *); -#endif - -static void bcopy(const void *src, void *dst, size_t len); -static void bzero(void *b, size_t len); - -static int domount(const char *device); -static int dskread(void *buf, uint64_t lba, int nblk); - -static void panic(const char *fmt, ...) __dead2; -static int printf(const char *fmt, ...); -static int putchar(char c, void *arg); -static int vprintf(const char *fmt, va_list ap); -static int vsnprintf(char *str, size_t sz, const char *fmt, va_list ap); - -static int __printf(const char *fmt, putc_func_t *putc, void *arg, va_list ap); -static int __puts(const char *s, putc_func_t *putc, void *arg); -static int __sputc(char c, void *arg); -static char *__uitoa(char *buf, u_int val, int base); -static char *__ultoa(char *buf, u_long val, int base); - -/* - * Open Firmware interface functions - */ -typedef uint64_t ofwcell_t; -typedef uint32_t u_ofwh_t; -typedef int (*ofwfp_t)(ofwcell_t []); -static ofwfp_t ofw; /* the PROM Open Firmware entry */ - -void ofw_init(int, int, int, int, ofwfp_t); -static ofwh_t ofw_finddevice(const char *); -static ofwh_t ofw_open(const char *); -static int ofw_getprop(ofwh_t, const char *, void *, size_t); -static int ofw_read(ofwh_t, void *, size_t); -static int ofw_write(ofwh_t, const void *, size_t); -static int ofw_seek(ofwh_t, uint64_t); -static void ofw_exit(void) __dead2; - -static ofwh_t stdinh, stdouth; - -/* - * This has to stay here, as the PROM seems to ignore the - * entry point specified in the a.out header. (or elftoaout is broken) - */ - -void -ofw_init(int d, int d1, int d2, int d3, ofwfp_t ofwaddr) -{ - ofwh_t chosenh; - char *av[16]; - char *p; - int ac; - - ofw = ofwaddr; - - chosenh = ofw_finddevice("/chosen"); - ofw_getprop(chosenh, "stdin", &stdinh, sizeof(stdinh)); - ofw_getprop(chosenh, "stdout", &stdouth, sizeof(stdouth)); - ofw_getprop(chosenh, "bootargs", bootargs, sizeof(bootargs)); - ofw_getprop(chosenh, "bootpath", bootpath, sizeof(bootpath)); - - bootargs[sizeof(bootargs) - 1] = '\0'; - bootpath[sizeof(bootpath) - 1] = '\0'; - - ac = 0; - p = bootargs; - for (;;) { - while (*p == ' ' && *p != '\0') - p++; - if (*p == '\0' || ac >= 16) - break; - av[ac++] = p; - while (*p != ' ' && *p != '\0') - p++; - if (*p != '\0') - *p++ = '\0'; - } - - exit(main(ac, av)); -} - -static ofwh_t -ofw_finddevice(const char *name) -{ - ofwcell_t args[] = { - (ofwcell_t)"finddevice", - 1, - 1, - (ofwcell_t)name, - 0 - }; - - if ((*ofw)(args)) { - printf("ofw_finddevice: name=\"%s\"\n", name); - return (1); - } - return (args[4]); -} - -static int -ofw_getprop(ofwh_t ofwh, const char *name, void *buf, size_t len) -{ - ofwcell_t args[] = { - (ofwcell_t)"getprop", - 4, - 1, - (u_ofwh_t)ofwh, - (ofwcell_t)name, - (ofwcell_t)buf, - len, - 0 - }; - - if ((*ofw)(args)) { - printf("ofw_getprop: ofwh=0x%x buf=%p len=%u\n", - ofwh, buf, len); - return (1); - } - return (0); -} - -static ofwh_t -ofw_open(const char *path) -{ - ofwcell_t args[] = { - (ofwcell_t)"open", - 1, - 1, - (ofwcell_t)path, - 0 - }; - - if ((*ofw)(args)) { - printf("ofw_open: path=\"%s\"\n", path); - return (-1); - } - return (args[4]); -} - -static int -ofw_close(ofwh_t devh) -{ - ofwcell_t args[] = { - (ofwcell_t)"close", - 1, - 0, - (u_ofwh_t)devh - }; - - if ((*ofw)(args)) { - printf("ofw_close: devh=0x%x\n", devh); - return (1); - } - return (0); -} - -static int -ofw_read(ofwh_t devh, void *buf, size_t len) -{ - ofwcell_t args[] = { - (ofwcell_t)"read", - 3, - 1, - (u_ofwh_t)devh, - (ofwcell_t)buf, - len, - 0 - }; - - if ((*ofw)(args)) { - printf("ofw_read: devh=0x%x buf=%p len=%u\n", devh, buf, len); - return (1); - } - return (0); -} - -static int -ofw_write(ofwh_t devh, const void *buf, size_t len) -{ - ofwcell_t args[] = { - (ofwcell_t)"write", - 3, - 1, - (u_ofwh_t)devh, - (ofwcell_t)buf, - len, - 0 - }; - - if ((*ofw)(args)) { - printf("ofw_write: devh=0x%x buf=%p len=%u\n", devh, buf, len); - return (1); - } - return (0); -} - -static int -ofw_seek(ofwh_t devh, uint64_t off) -{ - ofwcell_t args[] = { - (ofwcell_t)"seek", - 3, - 1, - (u_ofwh_t)devh, - off >> 32, - off, - 0 - }; - - if ((*ofw)(args)) { - printf("ofw_seek: devh=0x%x off=0x%lx\n", devh, off); - return (1); - } - return (0); -} - -static void -ofw_exit(void) -{ - ofwcell_t args[3]; - - args[0] = (ofwcell_t)"exit"; - args[1] = 0; - args[2] = 0; - - for (;;) - (*ofw)(args); -} - -static void -bcopy(const void *src, void *dst, size_t len) -{ - const char *s = src; - char *d = dst; - - while (len-- != 0) - *d++ = *s++; -} - -static void -memcpy(void *dst, const void *src, size_t len) -{ - - bcopy(src, dst, len); -} - -static void -bzero(void *b, size_t len) -{ - char *p = b; - - while (len-- != 0) - *p++ = 0; -} - -static int -strcmp(const char *s1, const char *s2) -{ - - for (; *s1 == *s2 && *s1; s1++, s2++) - ; - return ((u_char)*s1 - (u_char)*s2); -} - -int -main(int ac, char **av) -{ - const char *path; - int i; - - path = PATH_LOADER; - for (i = 0; i < ac; i++) { - switch (av[i][0]) { - case '-': - switch (av[i][1]) { - default: - usage(); - } - break; - default: - path = av[i]; - break; - } - } - -#ifdef ZFSBOOT - printf(" \n>> FreeBSD/sparc64 ZFS boot block\n Boot path: %s\n", - bootpath); -#else - printf(" \n>> FreeBSD/sparc64 boot block\n Boot path: %s\n" - " Boot loader: %s\n", bootpath, path); -#endif - - if (domount(bootpath) == -1) - panic("domount"); - -#ifdef ZFSBOOT - loadzfs(); -#else - load(path); -#endif - return (1); -} - -static void -usage(void) -{ - - printf("usage: boot device [/path/to/loader]\n"); - exit(1); -} - -static void -exit(int code) -{ - - ofw_exit(); -} - -#ifdef ZFSBOOT - -#define VDEV_BOOT_OFFSET (2 * 256 * 1024) -static char zbuf[READ_BUF_SIZE]; - -static int -zbread(char *buf, off_t off, size_t bytes) -{ - size_t len; - off_t poff; - off_t soff; - char *p; - unsigned int nb; - unsigned int lb; - - p = buf; - soff = VDEV_BOOT_OFFSET + off; - lb = howmany(soff + bytes, DEV_BSIZE); - poff = soff; - while (poff < soff + bytes) { - nb = lb - poff / DEV_BSIZE; - if (nb > READ_BUF_SIZE / DEV_BSIZE) - nb = READ_BUF_SIZE / DEV_BSIZE; - if (dskread(zbuf, poff / DEV_BSIZE, nb)) - break; - if ((poff / DEV_BSIZE + nb) * DEV_BSIZE > soff + bytes) - len = soff + bytes - poff; - else - len = (poff / DEV_BSIZE + nb) * DEV_BSIZE - poff; - memcpy(p, zbuf + poff % DEV_BSIZE, len); - p += len; - poff += len; - } - return (poff - soff); -} - -static void -loadzfs(void) -{ - Elf64_Ehdr eh; - Elf64_Phdr ph; - caddr_t p; - int i; - - if (zbread((char *)&eh, 0, sizeof(eh)) != sizeof(eh)) { - printf("Can't read elf header\n"); - return; - } - if (!IS_ELF(eh)) { - printf("Not an ELF file\n"); - return; - } - for (i = 0; i < eh.e_phnum; i++) { - fs_off = eh.e_phoff + i * eh.e_phentsize; - if (zbread((char *)&ph, fs_off, sizeof(ph)) != sizeof(ph)) { - printf("Can't read program header %d\n", i); - return; - } - if (ph.p_type != PT_LOAD) - continue; - fs_off = ph.p_offset; - p = (caddr_t)ph.p_vaddr; - if (zbread(p, fs_off, ph.p_filesz) != ph.p_filesz) { - printf("Can't read content of section %d\n", i); - return; - } - if (ph.p_filesz != ph.p_memsz) - bzero(p + ph.p_filesz, ph.p_memsz - ph.p_filesz); - } - ofw_close(bootdev); - (*(void (*)(int, int, int, int, ofwfp_t))eh.e_entry)(0, 0, 0, 0, ofw); -} - -#else - -#include "ufsread.c" - -static struct dmadat __dmadat; - -static void -load(const char *fname) -{ - Elf64_Ehdr eh; - Elf64_Phdr ph; - caddr_t p; - ufs_ino_t ino; - int i; - - if ((ino = lookup(fname)) == 0) { - printf("File %s not found\n", fname); - return; - } - if (fsread(ino, &eh, sizeof(eh)) != sizeof(eh)) { - printf("Can't read elf header\n"); - return; - } - if (!IS_ELF(eh)) { - printf("Not an ELF file\n"); - return; - } - for (i = 0; i < eh.e_phnum; i++) { - fs_off = eh.e_phoff + i * eh.e_phentsize; - if (fsread(ino, &ph, sizeof(ph)) != sizeof(ph)) { - printf("Can't read program header %d\n", i); - return; - } - if (ph.p_type != PT_LOAD) - continue; - fs_off = ph.p_offset; - p = (caddr_t)ph.p_vaddr; - if (fsread(ino, p, ph.p_filesz) != ph.p_filesz) { - printf("Can't read content of section %d\n", i); - return; - } - if (ph.p_filesz != ph.p_memsz) - bzero(p + ph.p_filesz, ph.p_memsz - ph.p_filesz); - } - ofw_close(bootdev); - (*(void (*)(int, int, int, int, ofwfp_t))eh.e_entry)(0, 0, 0, 0, ofw); -} - -#endif /* ZFSBOOT */ - -static int -domount(const char *device) -{ - - if ((bootdev = ofw_open(device)) == -1) { - printf("domount: can't open device\n"); - return (-1); - } -#ifndef ZFSBOOT - dmadat = &__dmadat; - if (fsread(0, NULL, 0)) { - printf("domount: can't read superblock\n"); - return (-1); - } -#endif - return (0); -} - -static int -dskread(void *buf, uint64_t lba, int nblk) -{ - - /* - * The Open Firmware should open the correct partition for us. - * That means, if we read from offset zero on an open instance handle, - * we should read from offset zero of that partition. - */ - ofw_seek(bootdev, lba * DEV_BSIZE); - ofw_read(bootdev, buf, nblk * DEV_BSIZE); - return (0); -} - -static void -panic(const char *fmt, ...) -{ - char buf[128]; - va_list ap; - - va_start(ap, fmt); - vsnprintf(buf, sizeof buf, fmt, ap); - printf("panic: %s\n", buf); - va_end(ap); - - exit(1); -} - -static int -printf(const char *fmt, ...) -{ - va_list ap; - int ret; - - va_start(ap, fmt); - ret = vprintf(fmt, ap); - va_end(ap); - return (ret); -} - -static int -putchar(char c, void *arg) -{ - char buf; - - if (c == '\n') { - buf = '\r'; - ofw_write(stdouth, &buf, 1); - } - buf = c; - ofw_write(stdouth, &buf, 1); - return (1); -} - -static int -vprintf(const char *fmt, va_list ap) -{ - int ret; - - ret = __printf(fmt, putchar, 0, ap); - return (ret); -} - -static int -vsnprintf(char *str, size_t sz, const char *fmt, va_list ap) -{ - struct sp_data sp; - int ret; - - sp.sp_buf = str; - sp.sp_len = 0; - sp.sp_size = sz; - ret = __printf(fmt, __sputc, &sp, ap); - return (ret); -} - -static int -__printf(const char *fmt, putc_func_t *putc, void *arg, va_list ap) -{ - char buf[(sizeof(long) * 8) + 1]; - char *nbuf; - u_long ul; - u_int ui; - int lflag; - int sflag; - char *s; - int pad; - int ret; - int c; - - nbuf = &buf[sizeof buf - 1]; - ret = 0; - while ((c = *fmt++) != 0) { - if (c != '%') { - ret += putc(c, arg); - continue; - } - lflag = 0; - sflag = 0; - pad = 0; -reswitch: c = *fmt++; - switch (c) { - case '#': - sflag = 1; - goto reswitch; - case '%': - ret += putc('%', arg); - break; - case 'c': - c = va_arg(ap, int); - ret += putc(c, arg); - break; - case 'd': - if (lflag == 0) { - ui = (u_int)va_arg(ap, int); - if (ui < (int)ui) { - ui = -ui; - ret += putc('-', arg); - } - s = __uitoa(nbuf, ui, 10); - } else { - ul = (u_long)va_arg(ap, long); - if (ul < (long)ul) { - ul = -ul; - ret += putc('-', arg); - } - s = __ultoa(nbuf, ul, 10); - } - ret += __puts(s, putc, arg); - break; - case 'l': - lflag = 1; - goto reswitch; - case 'o': - if (lflag == 0) { - ui = (u_int)va_arg(ap, u_int); - s = __uitoa(nbuf, ui, 8); - } else { - ul = (u_long)va_arg(ap, u_long); - s = __ultoa(nbuf, ul, 8); - } - ret += __puts(s, putc, arg); - break; - case 'p': - ul = (u_long)va_arg(ap, void *); - s = __ultoa(nbuf, ul, 16); - ret += __puts("0x", putc, arg); - ret += __puts(s, putc, arg); - break; - case 's': - s = va_arg(ap, char *); - ret += __puts(s, putc, arg); - break; - case 'u': - if (lflag == 0) { - ui = va_arg(ap, u_int); - s = __uitoa(nbuf, ui, 10); - } else { - ul = va_arg(ap, u_long); - s = __ultoa(nbuf, ul, 10); - } - ret += __puts(s, putc, arg); - break; - case 'x': - if (lflag == 0) { - ui = va_arg(ap, u_int); - s = __uitoa(nbuf, ui, 16); - } else { - ul = va_arg(ap, u_long); - s = __ultoa(nbuf, ul, 16); - } - if (sflag) - ret += __puts("0x", putc, arg); - ret += __puts(s, putc, arg); - break; - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - pad = pad * 10 + c - '0'; - goto reswitch; - default: - break; - } - } - return (ret); -} - -static int -__sputc(char c, void *arg) -{ - struct sp_data *sp; - - sp = arg; - if (sp->sp_len < sp->sp_size) - sp->sp_buf[sp->sp_len++] = c; - sp->sp_buf[sp->sp_len] = '\0'; - return (1); -} - -static int -__puts(const char *s, putc_func_t *putc, void *arg) -{ - const char *p; - int ret; - - ret = 0; - for (p = s; *p != '\0'; p++) - ret += putc(*p, arg); - return (ret); -} - -static char * -__uitoa(char *buf, u_int ui, int base) -{ - char *p; - - p = buf; - *p = '\0'; - do - *--p = digits[ui % base]; - while ((ui /= base) != 0); - return (p); -} - -static char * -__ultoa(char *buf, u_long ul, int base) -{ - char *p; - - p = buf; - *p = '\0'; - do - *--p = digits[ul % base]; - while ((ul /= base) != 0); - return (p); -} Property changes on: head/stand/sparc64/boot1/boot1.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/stand/sparc64/boot1/Makefile =================================================================== --- head/stand/sparc64/boot1/Makefile (revision 357453) +++ head/stand/sparc64/boot1/Makefile (nonexistent) @@ -1,29 +0,0 @@ -# $FreeBSD$ - -.include - -PROG= boot1.elf -INTERNALPROG= -FILES?= boot1 -SRCS= _start.s boot1.c -CLEANFILES+=${FILES} boot1.aout - -BOOTBLOCKBASE= 0x4000 - -CFLAGS.clang+=-mcmodel=small -CFLAGS.gcc+=-mcmodel=medlow -CFLAGS+=-Os -I${LDRSRC} -LDFLAGS+=-Ttext ${BOOTBLOCKBASE} -Wl,-N - -# Construct boot1. sunlabel expects it to contain zeroed-out space for the -# label, and to be of the correct size. -${FILES}: boot1.aout - @set -- `ls -l ${.ALLSRC}`; x=$$((7680-$$5)); \ - echo "$$x bytes available"; test $$x -ge 0 - ${DD} if=/dev/zero of=${.TARGET} bs=512 count=16 - ${DD} if=${.ALLSRC} of=${.TARGET} bs=512 oseek=1 conv=notrunc - -boot1.aout: boot1.elf - elf2aout -o ${.TARGET} ${.ALLSRC} - -.include Property changes on: head/stand/sparc64/boot1/Makefile ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/stand/sparc64/loader/help.sparc64 =================================================================== Property changes on: head/stand/sparc64/loader/help.sparc64 ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -y \ No newline at end of property Index: head/stand/sparc64/loader/main.c =================================================================== --- head/stand/sparc64/loader/main.c (revision 357453) +++ head/stand/sparc64/loader/main.c (nonexistent) @@ -1,986 +0,0 @@ -/*- - * Initial implementation: - * Copyright (c) 2001 Robert Drehmel - * All rights reserved. - * - * As long as the above copyright statement and this notice remain - * unchanged, you can do what ever you want with this file. - */ -/*- - * Copyright (c) 2008 - 2012 Marius Strobl - * 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. - */ - -#include -__FBSDID("$FreeBSD$"); - -/* - * FreeBSD/sparc64 kernel loader - machine dependent part - * - * - implements copyin and readin functions that map kernel - * pages on demand. The machine independent code does not - * know the size of the kernel early enough to pre-enter - * TTEs and install just one 4MB mapping seemed to limiting - * to me. - */ - -#include -#include -#include -#include -#include -#include -#ifdef LOADER_ZFS_SUPPORT -#include -#include "libzfs.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "bootstrap.h" -#include "libofw.h" -#include "dev_net.h" - -enum { - HEAPVA = 0x800000, - HEAPSZ = 0x3000000, - LOADSZ = 0x1000000 /* for kernel and modules */ -}; - -/* At least Sun Fire V1280 require page sized allocations to be claimed. */ -CTASSERT(HEAPSZ % PAGE_SIZE == 0); - -static struct mmu_ops { - void (*tlb_init)(void); - int (*mmu_mapin)(vm_offset_t va, vm_size_t len); -} *mmu_ops; - -typedef void kernel_entry_t(vm_offset_t mdp, u_long o1, u_long o2, u_long o3, - void *openfirmware); - -static inline u_long dtlb_get_data_sun4u(u_int, u_int); -static int dtlb_enter_sun4u(u_int, u_long data, vm_offset_t); -static vm_offset_t dtlb_va_to_pa_sun4u(vm_offset_t); -static inline u_long itlb_get_data_sun4u(u_int, u_int); -static int itlb_enter_sun4u(u_int, u_long data, vm_offset_t); -static vm_offset_t itlb_va_to_pa_sun4u(vm_offset_t); -static void itlb_relocate_locked0_sun4u(void); -static int sparc64_autoload(void); -static ssize_t sparc64_readin(const int, vm_offset_t, const size_t); -static ssize_t sparc64_copyin(const void *, vm_offset_t, size_t); -static vm_offset_t claim_virt(vm_offset_t, size_t, int); -static vm_offset_t alloc_phys(size_t, int); -static int map_phys(int, size_t, vm_offset_t, vm_offset_t); -static void release_phys(vm_offset_t, u_int); -static int __elfN(exec)(struct preloaded_file *); -static int mmu_mapin_sun4u(vm_offset_t, vm_size_t); -static vm_offset_t init_heap(void); -static phandle_t find_bsp_sun4u(phandle_t, uint32_t); -const char *cpu_cpuid_prop_sun4u(void); -uint32_t cpu_get_mid_sun4u(void); -static void tlb_init_sun4u(void); - -#ifdef LOADER_DEBUG -typedef uint64_t tte_t; - -static void pmap_print_tlb_sun4u(void); -static void pmap_print_tte_sun4u(tte_t, tte_t); -#endif - -static struct mmu_ops mmu_ops_sun4u = { tlb_init_sun4u, mmu_mapin_sun4u }; - -/* sun4u */ -struct tlb_entry *dtlb_store; -struct tlb_entry *itlb_store; -u_int dtlb_slot; -u_int itlb_slot; -static int cpu_impl; -static u_int dtlb_slot_max; -static u_int itlb_slot_max; -static u_int tlb_locked; - -static vm_offset_t curkva = 0; -static vm_offset_t heapva; - -static char bootpath[64]; -static phandle_t root; - -#ifdef LOADER_ZFS_SUPPORT -static struct zfs_devdesc zfs_currdev; -#endif - -/* - * Machine dependent structures that the machine independent - * loader part uses. - */ -struct devsw *devsw[] = { -#ifdef LOADER_DISK_SUPPORT - &ofwdisk, -#endif -#ifdef LOADER_NET_SUPPORT - &netdev, -#endif -#ifdef LOADER_ZFS_SUPPORT - &zfs_dev, -#endif - NULL -}; - -struct arch_switch archsw; - -static struct file_format sparc64_elf = { - __elfN(loadfile), - __elfN(exec) -}; - -struct file_format *file_formats[] = { - &sparc64_elf, - NULL -}; - -struct fs_ops *file_system[] = { -#ifdef LOADER_ZFS_SUPPORT - &zfs_fsops, -#endif -#ifdef LOADER_UFS_SUPPORT - &ufs_fsops, -#endif -#ifdef LOADER_CD9660_SUPPORT - &cd9660_fsops, -#endif -#ifdef LOADER_ZIP_SUPPORT - &zipfs_fsops, -#endif -#ifdef LOADER_GZIP_SUPPORT - &gzipfs_fsops, -#endif -#ifdef LOADER_BZIP2_SUPPORT - &bzipfs_fsops, -#endif -#ifdef LOADER_NFS_SUPPORT - &nfs_fsops, -#endif -#ifdef LOADER_TFTP_SUPPORT - &tftp_fsops, -#endif - NULL -}; - -struct netif_driver *netif_drivers[] = { -#ifdef LOADER_NET_SUPPORT - &ofwnet, -#endif - NULL -}; - -extern struct console ofwconsole; -struct console *consoles[] = { - &ofwconsole, - NULL -}; - -#ifdef LOADER_DEBUG -static int -watch_phys_set_mask(vm_offset_t pa, u_long mask) -{ - u_long lsucr; - - stxa(AA_DMMU_PWPR, ASI_DMMU, pa & (((2UL << 38) - 1) << 3)); - lsucr = ldxa(0, ASI_LSU_CTL_REG); - lsucr = ((lsucr | LSU_PW) & ~LSU_PM_MASK) | - (mask << LSU_PM_SHIFT); - stxa(0, ASI_LSU_CTL_REG, lsucr); - return (0); -} - -static int -watch_phys_set(vm_offset_t pa, int sz) -{ - u_long off; - - off = (u_long)pa & 7; - /* Test for misaligned watch points. */ - if (off + sz > 8) - return (-1); - return (watch_phys_set_mask(pa, ((1 << sz) - 1) << off)); -} - - -static int -watch_virt_set_mask(vm_offset_t va, u_long mask) -{ - u_long lsucr; - - stxa(AA_DMMU_VWPR, ASI_DMMU, va & (((2UL << 41) - 1) << 3)); - lsucr = ldxa(0, ASI_LSU_CTL_REG); - lsucr = ((lsucr | LSU_VW) & ~LSU_VM_MASK) | - (mask << LSU_VM_SHIFT); - stxa(0, ASI_LSU_CTL_REG, lsucr); - return (0); -} - -static int -watch_virt_set(vm_offset_t va, int sz) -{ - u_long off; - - off = (u_long)va & 7; - /* Test for misaligned watch points. */ - if (off + sz > 8) - return (-1); - return (watch_virt_set_mask(va, ((1 << sz) - 1) << off)); -} -#endif - -/* - * archsw functions - */ -static int -sparc64_autoload(void) -{ - - return (0); -} - -static ssize_t -sparc64_readin(const int fd, vm_offset_t va, const size_t len) -{ - - mmu_ops->mmu_mapin(va, len); - return (read(fd, (void *)va, len)); -} - -static ssize_t -sparc64_copyin(const void *src, vm_offset_t dest, size_t len) -{ - - mmu_ops->mmu_mapin(dest, len); - memcpy((void *)dest, src, len); - return (len); -} - -/* - * other MD functions - */ -static vm_offset_t -claim_virt(vm_offset_t virt, size_t size, int align) -{ - vm_offset_t mva; - - if (OF_call_method("claim", mmu, 3, 1, virt, size, align, &mva) == -1) - return ((vm_offset_t)-1); - return (mva); -} - -static vm_offset_t -alloc_phys(size_t size, int align) -{ - cell_t phys_hi, phys_low; - - if (OF_call_method("claim", memory, 2, 2, size, align, &phys_low, - &phys_hi) == -1) - return ((vm_offset_t)-1); - return ((vm_offset_t)phys_hi << 32 | phys_low); -} - -static int -map_phys(int mode, size_t size, vm_offset_t virt, vm_offset_t phys) -{ - - return (OF_call_method("map", mmu, 5, 0, (uint32_t)phys, - (uint32_t)(phys >> 32), virt, size, mode)); -} - -static void -release_phys(vm_offset_t phys, u_int size) -{ - - (void)OF_call_method("release", memory, 3, 0, (uint32_t)phys, - (uint32_t)(phys >> 32), size); -} - -static int -__elfN(exec)(struct preloaded_file *fp) -{ - struct file_metadata *fmp; - vm_offset_t mdp; - Elf_Addr entry; - Elf_Ehdr *e; - int error; - - if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == 0) - return (EFTYPE); - e = (Elf_Ehdr *)&fmp->md_data; - - if ((error = md_load64(fp->f_args, &mdp, NULL)) != 0) - return (error); - - printf("jumping to kernel entry at %#lx.\n", e->e_entry); -#ifdef LOADER_DEBUG - pmap_print_tlb_sun4u(); -#endif - - dev_cleanup(); - - entry = e->e_entry; - - OF_release((void *)heapva, HEAPSZ); - - ((kernel_entry_t *)entry)(mdp, 0, 0, 0, openfirmware); - - panic("%s: exec returned", __func__); -} - -static inline u_long -dtlb_get_data_sun4u(u_int tlb, u_int slot) -{ - u_long data, pstate; - - slot = TLB_DAR_SLOT(tlb, slot); - /* - * We read ASI_DTLB_DATA_ACCESS_REG twice back-to-back in order to - * work around errata of USIII and beyond. - */ - pstate = rdpr(pstate); - wrpr(pstate, pstate & ~PSTATE_IE, 0); - (void)ldxa(slot, ASI_DTLB_DATA_ACCESS_REG); - data = ldxa(slot, ASI_DTLB_DATA_ACCESS_REG); - wrpr(pstate, pstate, 0); - return (data); -} - -static inline u_long -itlb_get_data_sun4u(u_int tlb, u_int slot) -{ - u_long data, pstate; - - slot = TLB_DAR_SLOT(tlb, slot); - /* - * We read ASI_DTLB_DATA_ACCESS_REG twice back-to-back in order to - * work around errata of USIII and beyond. - */ - pstate = rdpr(pstate); - wrpr(pstate, pstate & ~PSTATE_IE, 0); - (void)ldxa(slot, ASI_ITLB_DATA_ACCESS_REG); - data = ldxa(slot, ASI_ITLB_DATA_ACCESS_REG); - wrpr(pstate, pstate, 0); - return (data); -} - -static vm_offset_t -dtlb_va_to_pa_sun4u(vm_offset_t va) -{ - u_long pstate, reg; - u_int i, tlb; - - pstate = rdpr(pstate); - wrpr(pstate, pstate & ~PSTATE_IE, 0); - for (i = 0; i < dtlb_slot_max; i++) { - reg = ldxa(TLB_DAR_SLOT(tlb_locked, i), - ASI_DTLB_TAG_READ_REG); - if (TLB_TAR_VA(reg) != va) - continue; - reg = dtlb_get_data_sun4u(tlb_locked, i); - wrpr(pstate, pstate, 0); - reg >>= TD_PA_SHIFT; - if (cpu_impl == CPU_IMPL_SPARC64V || - cpu_impl >= CPU_IMPL_ULTRASPARCIII) - return (reg & TD_PA_CH_MASK); - return (reg & TD_PA_SF_MASK); - } - wrpr(pstate, pstate, 0); - return (-1); -} - -static vm_offset_t -itlb_va_to_pa_sun4u(vm_offset_t va) -{ - u_long pstate, reg; - int i; - - pstate = rdpr(pstate); - wrpr(pstate, pstate & ~PSTATE_IE, 0); - for (i = 0; i < itlb_slot_max; i++) { - reg = ldxa(TLB_DAR_SLOT(tlb_locked, i), - ASI_ITLB_TAG_READ_REG); - if (TLB_TAR_VA(reg) != va) - continue; - reg = itlb_get_data_sun4u(tlb_locked, i); - wrpr(pstate, pstate, 0); - reg >>= TD_PA_SHIFT; - if (cpu_impl == CPU_IMPL_SPARC64V || - cpu_impl >= CPU_IMPL_ULTRASPARCIII) - return (reg & TD_PA_CH_MASK); - return (reg & TD_PA_SF_MASK); - } - wrpr(pstate, pstate, 0); - return (-1); -} - -static int -dtlb_enter_sun4u(u_int index, u_long data, vm_offset_t virt) -{ - - return (OF_call_method("SUNW,dtlb-load", mmu, 3, 0, index, data, - virt)); -} - -static int -itlb_enter_sun4u(u_int index, u_long data, vm_offset_t virt) -{ - - if (cpu_impl == CPU_IMPL_ULTRASPARCIIIp && index == 0 && - (data & TD_L) != 0) - panic("%s: won't enter locked TLB entry at index 0 on USIII+", - __func__); - return (OF_call_method("SUNW,itlb-load", mmu, 3, 0, index, data, - virt)); -} - -static void -itlb_relocate_locked0_sun4u(void) -{ - u_long data, pstate, tag; - int i; - - if (cpu_impl != CPU_IMPL_ULTRASPARCIIIp) - return; - - pstate = rdpr(pstate); - wrpr(pstate, pstate & ~PSTATE_IE, 0); - - data = itlb_get_data_sun4u(tlb_locked, 0); - if ((data & (TD_V | TD_L)) != (TD_V | TD_L)) { - wrpr(pstate, pstate, 0); - return; - } - - /* Flush the mapping of slot 0. */ - tag = ldxa(TLB_DAR_SLOT(tlb_locked, 0), ASI_ITLB_TAG_READ_REG); - stxa(TLB_DEMAP_VA(TLB_TAR_VA(tag)) | TLB_DEMAP_PRIMARY | - TLB_DEMAP_PAGE, ASI_IMMU_DEMAP, 0); - flush(0); /* The USIII-family ignores the address. */ - - /* - * Search a replacement slot != 0 and enter the data and tag - * that formerly were in slot 0. - */ - for (i = 1; i < itlb_slot_max; i++) { - if ((itlb_get_data_sun4u(tlb_locked, i) & TD_V) != 0) - continue; - - stxa(AA_IMMU_TAR, ASI_IMMU, tag); - stxa(TLB_DAR_SLOT(tlb_locked, i), ASI_ITLB_DATA_ACCESS_REG, - data); - flush(0); /* The USIII-family ignores the address. */ - break; - } - wrpr(pstate, pstate, 0); - if (i == itlb_slot_max) - panic("%s: could not find a replacement slot", __func__); -} - -static int -mmu_mapin_sun4u(vm_offset_t va, vm_size_t len) -{ - vm_offset_t pa, mva; - u_long data; - u_int index; - - if (va + len > curkva) - curkva = va + len; - - pa = (vm_offset_t)-1; - len += va & PAGE_MASK_4M; - va &= ~PAGE_MASK_4M; - while (len) { - if (dtlb_va_to_pa_sun4u(va) == (vm_offset_t)-1 || - itlb_va_to_pa_sun4u(va) == (vm_offset_t)-1) { - /* Allocate a physical page, claim the virtual area. */ - if (pa == (vm_offset_t)-1) { - pa = alloc_phys(PAGE_SIZE_4M, PAGE_SIZE_4M); - if (pa == (vm_offset_t)-1) - panic("%s: out of memory", __func__); - mva = claim_virt(va, PAGE_SIZE_4M, 0); - if (mva != va) - panic("%s: can't claim virtual page " - "(wanted %#lx, got %#lx)", - __func__, va, mva); - /* - * The mappings may have changed, be paranoid. - */ - continue; - } - /* - * Actually, we can only allocate two pages less at - * most (depending on the kernel TSB size). - */ - if (dtlb_slot >= dtlb_slot_max) - panic("%s: out of dtlb_slots", __func__); - if (itlb_slot >= itlb_slot_max) - panic("%s: out of itlb_slots", __func__); - data = TD_V | TD_4M | TD_PA(pa) | TD_L | TD_CP | - TD_CV | TD_P | TD_W; - dtlb_store[dtlb_slot].te_pa = pa; - dtlb_store[dtlb_slot].te_va = va; - index = dtlb_slot_max - dtlb_slot - 1; - if (dtlb_enter_sun4u(index, data, va) < 0) - panic("%s: can't enter dTLB slot %d data " - "%#lx va %#lx", __func__, index, data, - va); - dtlb_slot++; - itlb_store[itlb_slot].te_pa = pa; - itlb_store[itlb_slot].te_va = va; - index = itlb_slot_max - itlb_slot - 1; - if (itlb_enter_sun4u(index, data, va) < 0) - panic("%s: can't enter iTLB slot %d data " - "%#lx va %#lxd", __func__, index, data, - va); - itlb_slot++; - pa = (vm_offset_t)-1; - } - len -= len > PAGE_SIZE_4M ? PAGE_SIZE_4M : len; - va += PAGE_SIZE_4M; - } - if (pa != (vm_offset_t)-1) - release_phys(pa, PAGE_SIZE_4M); - return (0); -} - -static vm_offset_t -init_heap(void) -{ - - /* There is no need for continuous physical heap memory. */ - heapva = (vm_offset_t)OF_claim((void *)HEAPVA, HEAPSZ, 32); - return (heapva); -} - -static phandle_t -find_bsp_sun4u(phandle_t node, uint32_t bspid) -{ - char type[sizeof("cpu")]; - phandle_t child; - uint32_t cpuid; - - for (; node > 0; node = OF_peer(node)) { - child = OF_child(node); - if (child > 0) { - child = find_bsp_sun4u(child, bspid); - if (child > 0) - return (child); - } else { - if (OF_getprop(node, "device_type", type, - sizeof(type)) <= 0) - continue; - if (strcmp(type, "cpu") != 0) - continue; - if (OF_getprop(node, cpu_cpuid_prop_sun4u(), &cpuid, - sizeof(cpuid)) <= 0) - continue; - if (cpuid == bspid) - return (node); - } - } - return (0); -} - -const char * -cpu_cpuid_prop_sun4u(void) -{ - - switch (cpu_impl) { - case CPU_IMPL_SPARC64: - case CPU_IMPL_SPARC64V: - case CPU_IMPL_ULTRASPARCI: - case CPU_IMPL_ULTRASPARCII: - case CPU_IMPL_ULTRASPARCIIi: - case CPU_IMPL_ULTRASPARCIIe: - return ("upa-portid"); - case CPU_IMPL_ULTRASPARCIII: - case CPU_IMPL_ULTRASPARCIIIp: - case CPU_IMPL_ULTRASPARCIIIi: - case CPU_IMPL_ULTRASPARCIIIip: - return ("portid"); - case CPU_IMPL_ULTRASPARCIV: - case CPU_IMPL_ULTRASPARCIVp: - return ("cpuid"); - default: - return (""); - } -} - -uint32_t -cpu_get_mid_sun4u(void) -{ - - switch (cpu_impl) { - case CPU_IMPL_SPARC64: - case CPU_IMPL_SPARC64V: - case CPU_IMPL_ULTRASPARCI: - case CPU_IMPL_ULTRASPARCII: - case CPU_IMPL_ULTRASPARCIIi: - case CPU_IMPL_ULTRASPARCIIe: - return (UPA_CR_GET_MID(ldxa(0, ASI_UPA_CONFIG_REG))); - case CPU_IMPL_ULTRASPARCIII: - case CPU_IMPL_ULTRASPARCIIIp: - return (FIREPLANE_CR_GET_AID(ldxa(AA_FIREPLANE_CONFIG, - ASI_FIREPLANE_CONFIG_REG))); - case CPU_IMPL_ULTRASPARCIIIi: - case CPU_IMPL_ULTRASPARCIIIip: - return (JBUS_CR_GET_JID(ldxa(0, ASI_JBUS_CONFIG_REG))); - case CPU_IMPL_ULTRASPARCIV: - case CPU_IMPL_ULTRASPARCIVp: - return (INTR_ID_GET_ID(ldxa(AA_INTR_ID, ASI_INTR_ID))); - default: - return (0); - } -} - -static void -tlb_init_sun4u(void) -{ - phandle_t bsp; - - cpu_impl = VER_IMPL(rdpr(ver)); - switch (cpu_impl) { - case CPU_IMPL_SPARC64: - case CPU_IMPL_ULTRASPARCI: - case CPU_IMPL_ULTRASPARCII: - case CPU_IMPL_ULTRASPARCIIi: - case CPU_IMPL_ULTRASPARCIIe: - tlb_locked = TLB_DAR_T32; - break; - case CPU_IMPL_ULTRASPARCIII: - case CPU_IMPL_ULTRASPARCIIIp: - case CPU_IMPL_ULTRASPARCIIIi: - case CPU_IMPL_ULTRASPARCIIIip: - case CPU_IMPL_ULTRASPARCIV: - case CPU_IMPL_ULTRASPARCIVp: - tlb_locked = TLB_DAR_T16; - break; - case CPU_IMPL_SPARC64V: - tlb_locked = TLB_DAR_FTLB; - break; - } - bsp = find_bsp_sun4u(OF_child(root), cpu_get_mid_sun4u()); - if (bsp == 0) - panic("%s: no node for bootcpu?!?!", __func__); - - if (OF_getprop(bsp, "#dtlb-entries", &dtlb_slot_max, - sizeof(dtlb_slot_max)) == -1 || - OF_getprop(bsp, "#itlb-entries", &itlb_slot_max, - sizeof(itlb_slot_max)) == -1) - panic("%s: can't get TLB slot max.", __func__); - - if (cpu_impl == CPU_IMPL_ULTRASPARCIIIp) { -#ifdef LOADER_DEBUG - printf("pre fixup:\n"); - pmap_print_tlb_sun4u(); -#endif - - /* - * Relocate the locked entry in it16 slot 0 (if existent) - * as part of working around Cheetah+ erratum 34. - */ - itlb_relocate_locked0_sun4u(); - -#ifdef LOADER_DEBUG - printf("post fixup:\n"); - pmap_print_tlb_sun4u(); -#endif - } - - dtlb_store = malloc(dtlb_slot_max * sizeof(*dtlb_store)); - itlb_store = malloc(itlb_slot_max * sizeof(*itlb_store)); - if (dtlb_store == NULL || itlb_store == NULL) - panic("%s: can't allocate TLB store", __func__); -} - -#ifdef LOADER_ZFS_SUPPORT - -static void -sparc64_zfs_probe(void) -{ - struct vtoc8 vtoc; - char alias[64], devname[sizeof(alias) + sizeof(":x") - 1]; - char type[sizeof("device_type")]; - char *bdev, *dev, *odev; - uint64_t guid, *guidp; - int fd, len, part; - phandle_t aliases, options; - - guid = 0; - - /* - * Get the GUIDs of the ZFS pools on any additional disks listed in - * the boot-device environment variable. - */ - if ((aliases = OF_finddevice("/aliases")) == -1) - goto out; - options = OF_finddevice("/options"); - len = OF_getproplen(options, "boot-device"); - if (len <= 0) - goto out; - bdev = odev = malloc(len + 1); - if (bdev == NULL) - goto out; - if (OF_getprop(options, "boot-device", bdev, len) <= 0) - goto out; - bdev[len] = '\0'; - while ((dev = strsep(&bdev, " ")) != NULL) { - if (*dev == '\0') - continue; - strcpy(alias, dev); - (void)OF_getprop(aliases, dev, alias, sizeof(alias)); - if (OF_getprop(OF_finddevice(alias), "device_type", type, - sizeof(type)) == -1) - continue; - if (strcmp(type, "block") != 0) - continue; - - /* Find freebsd-zfs slices in the VTOC. */ - fd = open(alias, O_RDONLY); - if (fd == -1) - continue; - lseek(fd, 0, SEEK_SET); - if (read(fd, &vtoc, sizeof(vtoc)) != sizeof(vtoc)) { - close(fd); - continue; - } - close(fd); - - for (part = 0; part < 8; part++) { - if (part == 2 || vtoc.part[part].tag != - VTOC_TAG_FREEBSD_ZFS) - continue; - (void)sprintf(devname, "%s:%c", alias, part + 'a'); - /* Get the GUID of the ZFS pool on the boot device. */ - if (strcmp(devname, bootpath) == 0) - guidp = &guid; - else - guidp = NULL; - if (zfs_probe_dev(devname, guidp) == ENXIO) - break; - } - } - free(odev); - - out: - if (guid != 0) { - zfs_currdev.pool_guid = guid; - zfs_currdev.root_guid = 0; - zfs_currdev.dd.d_dev = &zfs_dev; - } -} -#endif /* LOADER_ZFS_SUPPORT */ - -int -main(int (*openfirm)(void *)) -{ - char compatible[32]; - struct devsw **dp; - - /* - * Tell the Open Firmware functions where they find the OFW gate. - */ - OF_init(openfirm); - - archsw.arch_getdev = ofw_getdev; - archsw.arch_copyin = sparc64_copyin; - archsw.arch_copyout = ofw_copyout; - archsw.arch_readin = sparc64_readin; - archsw.arch_autoload = sparc64_autoload; -#ifdef LOADER_ZFS_SUPPORT - archsw.arch_zfs_probe = sparc64_zfs_probe; -#endif - - if (init_heap() == (vm_offset_t)-1) - OF_exit(); - setheap((void *)heapva, (void *)(heapva + HEAPSZ)); - - /* - * Probe for a console. - */ - cons_probe(); - - if ((root = OF_peer(0)) == -1) - panic("%s: can't get root phandle", __func__); - OF_getprop(root, "compatible", compatible, sizeof(compatible)); - mmu_ops = &mmu_ops_sun4u; - - mmu_ops->tlb_init(); - - /* - * Set up the current device. - */ - OF_getprop(chosen, "bootpath", bootpath, sizeof(bootpath)); - - /* - * Initialize devices. - */ - for (dp = devsw; *dp != NULL; dp++) - if ((*dp)->dv_init != 0) - (*dp)->dv_init(); - -#ifdef LOADER_ZFS_SUPPORT - if (zfs_currdev.pool_guid != 0) { - (void)strncpy(bootpath, zfs_fmtdev(&zfs_currdev), - sizeof(bootpath) - 1); - bootpath[sizeof(bootpath) - 1] = '\0'; - } else -#endif - - /* - * Sun compatible bootable CD-ROMs have a disk label placed before - * the ISO 9660 data, with the actual file system being in the first - * partition, while the other partitions contain pseudo disk labels - * with embedded boot blocks for different architectures, which may - * be followed by UFS file systems. - * The firmware will set the boot path to the partition it boots from - * ('f' in the sun4u/sun4v case), but we want the kernel to be loaded - * from the ISO 9660 file system ('a'), so the boot path needs to be - * altered. - */ - if (bootpath[strlen(bootpath) - 2] == ':' && - bootpath[strlen(bootpath) - 1] == 'f') - bootpath[strlen(bootpath) - 1] = 'a'; - - env_setenv("currdev", EV_VOLATILE, bootpath, - ofw_setcurrdev, env_nounset); - env_setenv("loaddev", EV_VOLATILE, bootpath, - env_noset, env_nounset); - - printf("\n%s", bootprog_info); - printf("bootpath=\"%s\"\n", bootpath); - - /* Give control to the machine independent loader code. */ - interact(); - return (1); -} - -COMMAND_SET(heap, "heap", "show heap usage", command_heap); - -static int -command_heap(int argc, char *argv[]) -{ - - mallocstats(); - printf("heap base at %p, top at %p, upper limit at %p\n", heapva, - sbrk(0), heapva + HEAPSZ); - return(CMD_OK); -} - -COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); - -static int -command_reboot(int argc, char *argv[]) -{ - int i; - - for (i = 0; devsw[i] != NULL; ++i) - if (devsw[i]->dv_cleanup != NULL) - (devsw[i]->dv_cleanup)(); - - printf("Rebooting...\n"); - OF_exit(); -} - -/* provide this for panic, as it's not in the startup code */ -void -exit(int code) -{ - - OF_exit(); -} - -#ifdef LOADER_DEBUG -static const char *const page_sizes[] = { - " 8k", " 64k", "512k", " 4m" -}; - -static void -pmap_print_tte_sun4u(tte_t tag, tte_t tte) -{ - - printf("%s %s ", - page_sizes[(tte >> TD_SIZE_SHIFT) & TD_SIZE_MASK], - tag & TD_G ? "G" : " "); - printf(tte & TD_W ? "W " : " "); - printf(tte & TD_P ? "\e[33mP\e[0m " : " "); - printf(tte & TD_E ? "E " : " "); - printf(tte & TD_CV ? "CV " : " "); - printf(tte & TD_CP ? "CP " : " "); - printf(tte & TD_L ? "\e[32mL\e[0m " : " "); - printf(tte & TD_IE ? "IE " : " "); - printf(tte & TD_NFO ? "NFO " : " "); - printf("pa=0x%lx va=0x%lx ctx=%ld\n", - TD_PA(tte), TLB_TAR_VA(tag), TLB_TAR_CTX(tag)); -} - -static void -pmap_print_tlb_sun4u(void) -{ - tte_t tag, tte; - u_long pstate; - int i; - - pstate = rdpr(pstate); - for (i = 0; i < itlb_slot_max; i++) { - wrpr(pstate, pstate & ~PSTATE_IE, 0); - tte = itlb_get_data_sun4u(tlb_locked, i); - wrpr(pstate, pstate, 0); - if (!(tte & TD_V)) - continue; - tag = ldxa(TLB_DAR_SLOT(tlb_locked, i), - ASI_ITLB_TAG_READ_REG); - printf("iTLB-%2u: ", i); - pmap_print_tte_sun4u(tag, tte); - } - for (i = 0; i < dtlb_slot_max; i++) { - wrpr(pstate, pstate & ~PSTATE_IE, 0); - tte = dtlb_get_data_sun4u(tlb_locked, i); - wrpr(pstate, pstate, 0); - if (!(tte & TD_V)) - continue; - tag = ldxa(TLB_DAR_SLOT(tlb_locked, i), - ASI_DTLB_TAG_READ_REG); - printf("dTLB-%2u: ", i); - pmap_print_tte_sun4u(tag, tte); - } -} -#endif Property changes on: head/stand/sparc64/loader/main.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/stand/sparc64/loader/version =================================================================== --- head/stand/sparc64/loader/version (revision 357453) +++ head/stand/sparc64/loader/version (nonexistent) @@ -1,6 +0,0 @@ -$FreeBSD$ - -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. - -1.0: I hate the loader. Property changes on: head/stand/sparc64/loader/version ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/stand/sparc64/loader/locore.S =================================================================== --- head/stand/sparc64/loader/locore.S (revision 357453) +++ head/stand/sparc64/loader/locore.S (nonexistent) @@ -1,42 +0,0 @@ -/*- - * Initial implementation: - * Copyright (c) 2001 Robert Drehmel - * All rights reserved. - * - * As long as the above copyright statement and this notice remain - * unchanged, you can do what ever you want with this file. - */ - -#include -__FBSDID("$FreeBSD$"); - -#define LOCORE - -#include -#include -#include -#include - -#define PAGE_SIZE 8192 -#define PAGE_SHIFT 13 - -#define STACK_SIZE (2 * PAGE_SIZE) - -ENTRY(_start) - /* Limit interrupts. */ - wrpr %g0, PIL_TICK - 1, %pil - - /* - * PSTATE: privileged, interrupts enabled, floating point - * unit enabled - */ - wrpr %g0, PSTATE_PRIV | PSTATE_IE | PSTATE_PEF, %pstate - wr %g0, FPRS_FEF, %fprs - - setx stack + STACK_SIZE - SPOFF - CCFSZ, %l7, %l6 - mov %l6, %sp - call main - mov %o4, %o0 - sir - - .comm stack, STACK_SIZE, 32 Property changes on: head/stand/sparc64/loader/locore.S ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/stand/sparc64/loader/Makefile =================================================================== --- head/stand/sparc64/loader/Makefile (revision 357453) +++ head/stand/sparc64/loader/Makefile (nonexistent) @@ -1,56 +0,0 @@ -# $FreeBSD$ - -HAVE_ZFS= ${MK_LOADER_ZFS} - -LOADER_DISK_SUPPORT?= yes -LOADER_UFS_SUPPORT?= yes -LOADER_CD9660_SUPPORT?= yes -LOADER_EXT2FS_SUPPORT?= no -LOADER_MSDOS_SUPPORT?= no -LOADER_NET_SUPPORT?= yes -LOADER_NFS_SUPPORT?= yes -LOADER_TFTP_SUPPORT?= yes -LOADER_GZIP_SUPPORT?= yes -LOADER_BZIP2_SUPPORT?= no -LOADER_DEBUG?= no - -.include - -PROG?= loader -NEWVERSWHAT?= "bootstrap loader" sparc64 -VERSION_FILE= ${.CURDIR}/../loader/version -INSTALLFLAGS= -b - -.if ${MK_LOADER_ZFS} != "no" -HAVE_ZFS= yes -.endif - -# Architecture-specific loader code -.PATH: ${BOOTSRC}/sparc64/loader -SRCS= locore.S main.c vers.c - -.if ${LOADER_DEBUG} == "yes" -CFLAGS+= -DLOADER_DEBUG -.endif - -.if exists(${.CURDIR}/help.sparc64) -HELP_FILES= ${.CURDIR}/help.sparc64 -.endif - -# Always add MI sources -.include "${BOOTSRC}/loader.mk" - -LDFLAGS+= -static - -.if ${MK_LOADER_ZFS} == "yes" -LINKS= ${BINDIR}/loader ${BINDIR}/zfsloader -.endif - -# Open Firmware standalone support library -LIBOFW= ${BOOTOBJ}/libofw/libofw.a -CFLAGS+= -I${BOOTSRC}/libofw - -DPADD= ${LDR_INTERP} ${LIBOFW} ${LIBSA} -LDADD= ${LDR_INTERP} ${LIBOFW} ${LIBSA} - -.include Property changes on: head/stand/sparc64/loader/Makefile ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/stand/sparc64/zfsboot/Makefile =================================================================== --- head/stand/sparc64/zfsboot/Makefile (revision 357453) +++ head/stand/sparc64/zfsboot/Makefile (nonexistent) @@ -1,9 +0,0 @@ -# $FreeBSD$ - -.PATH: ${.CURDIR}/../boot1 - -PROGNAME= zfsboot -CFLAGS+= -DZFSBOOT -FILES= zfsboot - -.include "${.CURDIR}/../boot1/Makefile" Property changes on: head/stand/sparc64/zfsboot/Makefile ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property