diff --git a/stand/common/metadata.c b/stand/common/metadata.c index e0a9518ab233..a9c81added02 100644 --- a/stand/common/metadata.c +++ b/stand/common/metadata.c @@ -1,362 +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 static int md_getboothowto(char *kargs) { int howto; /* Parse kargs */ howto = boot_parse_cmdline(kargs); howto |= boot_env_to_howto(); if (!strcmp(getenv("console"), "comconsole")) howto |= RB_SERIAL; if (!strcmp(getenv("console"), "nullconsole")) howto |= RB_MUTE; 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 *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); } int md_load(char *args, vm_offset_t *modulep, vm_offset_t *dtb) { return (md_load_dual(args, modulep, dtb, 0)); } -#if defined(__mips__) || defined(__powerpc__) +#if defined(__powerpc__) int md_load64(char *args, vm_offset_t *modulep, vm_offset_t *dtb) { return (md_load_dual(args, modulep, dtb, 1)); } #endif diff --git a/stand/defs.mk b/stand/defs.mk index 765fd046a879..e9c97f7720ab 100644 --- a/stand/defs.mk +++ b/stand/defs.mk @@ -1,259 +1,255 @@ # $FreeBSD$ .if !defined(__BOOT_DEFS_MK__) __BOOT_DEFS_MK__=${MFILE} # We need to define all the MK_ options before including src.opts.mk # because it includes bsd.own.mk which needs the right MK_ values, # espeically MK_CTF. MK_CTF= no MK_SSP= no MK_PROFILE= no MK_PIE= no MAN= .if !defined(PIC) NO_PIC= INTERNALLIB= .endif # Should be NO_CPU_FLAGS, but bsd.cpu.mk is included too early in bsd.init.mk # via the early include of bsd.opts.mk. Moving Makefile.inc include earlier in # that file causes weirdness, so this is the next best thing. We need to do this # because the loader needs very specific flags to work right, and things like # CPUTYPE?=native prevent that, and introduce an endless game of whack-a-mole # to disable more and more features. Boot loader performance is never improved # enough to make that hassle worth chasing. _CPUCFLAGS= .if ${LDFLAGS:M-nostdlib} # Sanitizers won't work unless we link against libc (e.g. in userboot/test). MK_ASAN:= no MK_UBSAN:= no .endif .include .include WARNS?= 1 BOOTSRC= ${SRCTOP}/stand EFISRC= ${BOOTSRC}/efi EFIINC= ${EFISRC}/include EFIINCMD= ${EFIINC}/${MACHINE} FDTSRC= ${BOOTSRC}/fdt FICLSRC= ${BOOTSRC}/ficl LDRSRC= ${BOOTSRC}/common LIBLUASRC= ${BOOTSRC}/liblua LIBOFWSRC= ${BOOTSRC}/libofw LUASRC= ${SRCTOP}/contrib/lua/src SASRC= ${BOOTSRC}/libsa SYSDIR= ${SRCTOP}/sys UBOOTSRC= ${BOOTSRC}/uboot ZFSSRC= ${SASRC}/zfs OZFS= ${SRCTOP}/sys/contrib/openzfs ZFSOSSRC= ${OZFS}/module/os/freebsd/ ZFSOSINC= ${OZFS}/include/os/freebsd LIBCSRC= ${SRCTOP}/lib/libc BOOTOBJ= ${OBJTOP}/stand # BINDIR is where we install BINDIR?= /boot # LUAPATH is where we search for and install lua scripts. LUAPATH?= /boot/lua FLUASRC?= ${SRCTOP}/libexec/flua LIBSA= ${BOOTOBJ}/libsa/libsa.a .if ${MACHINE} == "i386" LIBSA32= ${LIBSA} .else LIBSA32= ${BOOTOBJ}/libsa32/libsa32.a .endif # Standard options: CFLAGS+= -nostdinc # Allow CFLAGS_EARLY.file/target so that code that needs specific stack # of include paths can set them up before our include paths. Normally # the only thing that should be there are -I directives, and as few of # those as possible. CFLAGS+= ${CFLAGS_EARLY} ${CFLAGS_EARLY.${.IMPSRC:T}} ${CFLAGS_EARLY.${.TARGET:T}} .if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1 CFLAGS+= -I${BOOTOBJ}/libsa32 .else CFLAGS+= -I${BOOTOBJ}/libsa .endif CFLAGS+= -I${SASRC} -D_STANDALONE CFLAGS+= -I${SYSDIR} # Spike the floating point interfaces CFLAGS+= -Ddouble=jagged-little-pill -Dfloat=floaty-mcfloatface .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" # Slim down the image. This saves about 15% in size with clang 6 on x86 # Our most constrained /boot/loader env is BIOS booting on x86, where # our text + data + BTX have to fit into 640k below the ISA hole. # Experience has shown that problems arise between ~520k to ~530k. CFLAGS.clang+= -Oz CFLAGS.gcc+= -Os CFLAGS+= -ffunction-sections -fdata-sections .endif # GELI Support, with backward compat hooks (mostly) .if defined(LOADER_NO_GELI_SUPPORT) MK_LOADER_GELI=no .warning "Please move from LOADER_NO_GELI_SUPPORT to WITHOUT_LOADER_GELI" .endif .if defined(LOADER_GELI_SUPPORT) MK_LOADER_GELI=yes .warning "Please move from LOADER_GELI_SUPPORT to WITH_LOADER_GELI" .endif .if ${MK_LOADER_GELI} == "yes" CFLAGS+= -DLOADER_GELI_SUPPORT CFLAGS+= -I${SASRC}/geli .endif # MK_LOADER_GELI # These should be confined to loader.mk, but can't because uboot/lib # also uses it. It's part of loader, but isn't a loader so we can't # just include loader.mk .if ${LOADER_DISK_SUPPORT:Uyes} == "yes" CFLAGS+= -DLOADER_DISK_SUPPORT .endif # Machine specific flags for all builds here # Ensure PowerPC64 and PowerPC64LE boot loaders are compiled as 32 bit. # PowerPC64LE boot loaders are 32-bit little-endian. .if ${MACHINE_ARCH} == "powerpc64" CFLAGS+= -m32 -mcpu=powerpc -mbig-endian .elif ${MACHINE_ARCH} == "powerpc64le" CFLAGS+= -m32 -mcpu=powerpc -mlittle-endian .endif # For amd64, there's a bit of mixed bag. Some of the tree (i386, lib*32) is # build 32-bit and some 64-bit (lib*, efi). Centralize all the 32-bit magic here # and activate it when DO32 is explicitly defined to be 1. .if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1 CFLAGS+= -m32 # LD_FLAGS is passed directly to ${LD}, not via ${CC}: LD_FLAGS+= -m elf_i386_fbsd AFLAGS+= --32 .endif # Add in the no float / no SIMD stuff and announce we're freestanding # aarch64 and riscv don't have -msoft-float, but all others do. CFLAGS+= -ffreestanding ${CFLAGS_NO_SIMD} .if ${MACHINE_CPUARCH} == "aarch64" CFLAGS+= -mgeneral-regs-only -ffixed-x18 -fPIC .elif ${MACHINE_CPUARCH} == "riscv" CFLAGS+= -march=rv64imac -mabi=lp64 -fPIC CFLAGS.clang+= -mcmodel=medium CFLAGS.gcc+= -mcmodel=medany .else CFLAGS+= -msoft-float .endif # -msoft-float seems to be insufficient for powerpcspe .if ${MACHINE_ARCH} == "powerpcspe" CFLAGS+= -mno-spe .endif .if ${MACHINE_CPUARCH} == "i386" || (${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 1) CFLAGS+= -march=i386 CFLAGS.gcc+= -mpreferred-stack-boundary=2 .endif .if ${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 0 CFLAGS+= -fPIC -mno-red-zone .endif .if ${MACHINE_CPUARCH} == "arm" # Do not generate movt/movw, because the relocation fixup for them does not # translate to the -Bsymbolic -pie format required by self_reloc() in loader(8). # Also, the fpu is not available in a standalone environment. CFLAGS.clang+= -mno-movt CFLAGS.clang+= -mfpu=none CFLAGS+= -fPIC .endif # Some RISC-V linkers have support for relaxations, while some (lld) do not # yet. If this is the case we inhibit the compiler from emitting relaxations. .if ${LINKER_FEATURES:Mriscv-relaxations} == "" CFLAGS+= -mno-relax .endif # The boot loader build uses dd status=none, where possible, for reproducible # build output (since performance varies from run to run). Trouble is that # option was recently (10.3) added to FreeBSD and is non-standard. Only use it # when this test succeeds rather than require dd to be a bootstrap tool. DD_NOSTATUS!=(dd status=none count=0 2> /dev/null && echo status=none) || true DD=dd ${DD_NOSTATUS} -.if ${MACHINE_CPUARCH} == "mips" -CFLAGS+= -G0 -fno-pic -mno-abicalls -.endif - # # Have a sensible default # .if ${MK_LOADER_LUA} == "yes" LOADER_DEFAULT_INTERP?=lua .elif ${MK_FORTH} == "yes" LOADER_DEFAULT_INTERP?=4th .else LOADER_DEFAULT_INTERP?=simp .endif LOADER_INTERP?=${LOADER_DEFAULT_INTERP} # Make sure we use the machine link we're about to create CFLAGS+=-I. all: ${PROG} CLEANFILES+= teken_state.h teken.c: teken_state.h teken_state.h: ${SYSDIR}/teken/sequences awk -f ${SYSDIR}/teken/gensequences \ ${SYSDIR}/teken/sequences > teken_state.h .if !defined(NO_OBJ) _ILINKS=include/machine .if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64" _ILINKS+=include/${MACHINE_CPUARCH} .endif .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" _ILINKS+=include/x86 .endif CFLAGS+= -Iinclude CLEANDIRS+= include beforedepend: ${_ILINKS} beforebuild: ${_ILINKS} # Ensure that the links exist without depending on it when it exists which # causes all the modules to be rebuilt when the directory pointed to changes. .for _link in ${_ILINKS} .if !exists(${.OBJDIR}/${_link}) ${OBJS}: ${_link} .endif # _link exists .endfor .NOPATH: ${_ILINKS} ${_ILINKS}: .NOMETA @case ${.TARGET:T} in \ machine) \ if [ ${DO32:U0} -eq 0 ]; then \ path=${SYSDIR}/${MACHINE}/include ; \ else \ path=${SYSDIR}/${MACHINE:C/amd64/i386/}/include ; \ fi ;; \ *) \ path=${SYSDIR}/${.TARGET:T}/include ;; \ esac ; \ case ${.TARGET} in \ */*) mkdir -p ${.TARGET:H};; \ esac ; \ path=`(cd $$path && /bin/pwd)` ; \ ${ECHO} ${.TARGET} "->" $$path ; \ ln -fns $$path ${.TARGET} .endif # !NO_OBJ .endif # __BOOT_DEFS_MK__ diff --git a/stand/ficl.mk b/stand/ficl.mk index 2adbccb34f9d..e9fa1eb84f4b 100644 --- a/stand/ficl.mk +++ b/stand/ficl.mk @@ -1,20 +1,18 @@ # $FreeBSD$ # Common flags to build FICL related files .if ${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 1 FICL_CPUARCH= i386 -.elif ${MACHINE_ARCH:Mmips64*} != "" -FICL_CPUARCH= mips64 .else FICL_CPUARCH= ${MACHINE_CPUARCH} .endif .if ${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 0 CFLAGS+= -fPIC .endif CFLAGS+= -I${FICLSRC} -I${FICLSRC}/${FICL_CPUARCH} -I${LDRSRC} CFLAGS+= -DBF_DICTSIZE=30000 .include "${BOOTSRC}/veriexec.mk" diff --git a/stand/libsa/zalloc_defs.h b/stand/libsa/zalloc_defs.h index bb7c593ba822..66f943549340 100644 --- a/stand/libsa/zalloc_defs.h +++ b/stand/libsa/zalloc_defs.h @@ -1,83 +1,83 @@ /* * This module derived from code donated to the FreeBSD Project by * Matthew Dillon * * Copyright (c) 1998 The FreeBSD Project * 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$ */ /* * DEFS.H */ #ifndef _ZALLOC_DEFS_H #define _ZALLOC_DEFS_H #define USEGUARD /* use stard/end guard bytes */ #define USEENDGUARD #define DMALLOCDEBUG /* add debugging code to gather stats */ #define ZALLOCDEBUG #include #include "stand.h" #include "zalloc_mem.h" #define Library extern /* * block extension for sbrk() */ #define BLKEXTEND (4 * 1024) #define BLKEXTENDMASK (BLKEXTEND - 1) /* * Required malloc alignment. * * Embedded platforms using the u-boot API drivers require that all I/O buffers * be on a cache line sized boundary. The worst case size for that is 64 bytes. * For other platforms, 16 bytes works fine. The alignment also must be at * least sizeof(struct MemNode); this is asserted in zalloc.c. */ -#if defined(__arm__) || defined(__mips__) || defined(__powerpc__) +#if defined(__arm__) || defined(__powerpc__) #define MALLOCALIGN 64 #else #define MALLOCALIGN 16 #endif #define MALLOCALIGN_MASK (MALLOCALIGN - 1) typedef struct Guard { size_t ga_Bytes; size_t ga_Magic; /* must be at least 32 bits */ } Guard; #define GAMAGIC 0x55FF44FD #define GAFREE 0x5F54F4DF #include "zalloc_protos.h" #endif /* _ZALLOC_DEFS_H */ diff --git a/stand/loader.mk b/stand/loader.mk index fc20344ab051..49e9e88c842d 100644 --- a/stand/loader.mk +++ b/stand/loader.mk @@ -1,181 +1,175 @@ # $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 nvstore.c pnglite.c tslog.c CFLAGS.module.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite .PATH: ${SRCTOP}/contrib/pnglite CFLAGS.pnglite.c+= -I${SRCTOP}/contrib/pnglite CFLAGS.pnglite.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib .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_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 .elif ${MACHINE_CPUARCH} == "riscv" SRCS+= load_elf64.c reloc_elf64.c SRCS+= metadata.c .endif # elf loaders set frame buffer things, so add includes for that. CFLAGS.load_elf32.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite CFLAGS.load_elf64.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite .if ${LOADER_DISK_SUPPORT:Uyes} == "yes" CFLAGS.part.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib 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 .include "${BOOTSRC}/veriexec.mk" .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 CFLAGS+= -I${SYSDIR}/cddl/contrib/opensolaris/uts/common 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 diff --git a/stand/mips/Makefile b/stand/mips/Makefile deleted file mode 100644 index 90341b2f7e50..000000000000 --- a/stand/mips/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# $FreeBSD$ - -NO_OBJ=t - -SUBDIR= uboot - -# -# The BERI boot loader port works only on 64-bit MIPS; not a hard port to -# 32-bit if someone is interested. Build on all 64-bit MIPS platforms to -# ensure it gets adequate build-test coverage. -# -.if ${MACHINE_ARCH} == "mips64" -SUBDIR+= beri -.endif - -.include diff --git a/stand/mips/Makefile.inc b/stand/mips/Makefile.inc deleted file mode 100644 index 265f86d1ed55..000000000000 --- a/stand/mips/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $FreeBSD$ - -.include "../Makefile.inc" diff --git a/stand/mips/beri/Makefile b/stand/mips/beri/Makefile deleted file mode 100644 index afcb538816b8..000000000000 --- a/stand/mips/beri/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# $FreeBSD$ - -SUBDIR= boot2 loader - -.include diff --git a/stand/mips/beri/Makefile.inc b/stand/mips/beri/Makefile.inc deleted file mode 100644 index a95ca3dc1861..000000000000 --- a/stand/mips/beri/Makefile.inc +++ /dev/null @@ -1,9 +0,0 @@ -# $FreeBSD$ - -LDFLAGS+= -nostdlib - -# BERI boot loader is built with '-mno-abicalls' flag, -# which is incompatible with PIE -MK_PIE= no - -.include "../Makefile.inc" diff --git a/stand/mips/beri/boot2/Makefile b/stand/mips/beri/boot2/Makefile deleted file mode 100644 index afc061b4eb05..000000000000 --- a/stand/mips/beri/boot2/Makefile +++ /dev/null @@ -1,78 +0,0 @@ -#- -# Copyright (c) 2013-2014 Robert N. M. Watson -# All rights reserved. -# -# This software was developed by SRI International and the University of -# Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) -# ("CTSRD"), as part of the DARPA CRASH research programme. -# -# 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$ - -.include - -INSTALLFLAGS= -b - -LOADERS= flashboot jtagboot -FILES= ${LOADERS} ${LOADERS:S/$/.md5/} - -SRCS= relocate.S \ - start.S \ - boot2.c \ - altera_jtag_uart.c \ - cfi.c \ - sdcard.c - -AFLAGS= -G0 - -CFLAGS+= -I${LDRSRC} \ - -Wall \ - -G0 \ - -fno-pic -mno-abicalls \ - -g - -LDFLAGS+= -static \ - -Wl,-N \ - -G0 \ - -L${.CURDIR} - -.PATH: ${BOOTSRC}/mips/beri/common -CFLAGS+= -I${BOOTSRC}/mips/beri/common - -flashboot.elf: relocate.o start.o boot2.o altera_jtag_uart.o cfi.o sdcard.o - ${CC:N${CCACHE_BIN}} ${LDFLAGS} -T ${.CURDIR}/flashboot.ldscript \ - -o ${.TARGET} ${.ALLSRC} ${LIBSA} -flashboot: flashboot.elf - ${OBJCOPY} -S -O binary ${.TARGET}.elf ${.TARGET} -flashboot.md5: flashboot - md5 flashboot > flashboot.md5 - -jtagboot: start.o boot2.o altera_jtag_uart.o cfi.o sdcard.o - ${CC:N${CCACHE_BIN}} ${LDFLAGS} -T ${.CURDIR}/jtagboot.ldscript \ - -o ${.TARGET} ${.ALLSRC} ${LIBSA} -jtagboot.md5: jtagboot - md5 jtagboot > jtagboot.md5 - -CLEANFILES+= flashboot.elf - -.include diff --git a/stand/mips/beri/boot2/boot2.c b/stand/mips/beri/boot2/boot2.c deleted file mode 100644 index f771da856e4c..000000000000 --- a/stand/mips/beri/boot2/boot2.c +++ /dev/null @@ -1,669 +0,0 @@ -/*- - * Copyright (c) 2013-2014 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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. - * - * Copyright (c) 1998 Robert Nordier - * 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 -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "paths.h" -#include "rbx.h" - -static int beri_argc; -static const char **beri_argv, **beri_envv; -static uint64_t beri_memsize; - -#define IO_KEYBOARD 1 -#define IO_SERIAL 2 - -#define SECOND 1 /* Circa that many ticks in a second. */ - -#define ARGS 0x900 -#define NOPT 14 -#define MEM_BASE 0x12 -#define MEM_EXT 0x15 - -/* - * XXXRW: I think this has to do with whether boot2 expects a partition - * table? - */ -#define DRV_HARD 0x80 -#define DRV_MASK 0x7f - -/* Default to using CFI flash. */ -#define TYPE_DEFAULT BOOTINFO_DEV_TYPE_SDCARD - -/* Hard-coded assumption about location of JTAG-loaded kernel. */ -#define DRAM_KERNEL_ADDR ((void *)mips_phys_to_cached(0x20000)) - -extern uint32_t _end; - -static const char optstr[NOPT] = "DhaCcdgmnpqrsv"; /* Also 'P', 'S' */ -static const unsigned char flags[NOPT] = { - RBX_DUAL, - RBX_SERIAL, - RBX_ASKNAME, - RBX_CDROM, - RBX_CONFIG, - RBX_KDB, - RBX_GDB, - RBX_MUTE, - RBX_NOINTR, - RBX_PAUSE, - RBX_QUIET, - RBX_DFLTROOT, - RBX_SINGLE, - RBX_VERBOSE -}; - -/* These must match BOOTINFO_DEV_TYPE constants. */ -static const char *const dev_nm[] = {"dram", "cfi", "sdcard"}; -static const u_int dev_nm_count = nitems(dev_nm); - -static struct dsk { - unsigned type; /* BOOTINFO_DEV_TYPE_x object type. */ - uintptr_t unitptr; /* Unit number or pointer to object. */ - uint8_t slice; - uint8_t part; -#if 0 - unsigned start; - int init; -#endif -} dsk; -static char cmd[512], cmddup[512], knamebuf[1024]; -static const char *kname; -uint32_t opts; -#if 0 -static int comspeed = SIOSPD; -#endif -struct bootinfo bootinfo; -static uint8_t ioctrl = IO_KEYBOARD; - -void putchar(int); -static void boot_fromdram(void); -static void boot_fromfs(void); -static void load(void); -static int parse(void); -static int dskread(void *, unsigned, unsigned); -static int xputc(int); -static int xgetc(int); - -#define UFS_SMALL_CGBASE -#include "ufsread.c" - -static struct dmadat __dmadat; - -static inline int -xfsread(ufs_ino_t inode, void *buf, size_t nbyte) -{ - if ((size_t)fsread(inode, buf, nbyte) != nbyte) { - printf("Invalid %s\n", "format"); - return -1; - } - return 0; -} - -static inline void -getstr(void) -{ - char *s; - int c; - - s = cmd; - for (;;) { - switch (c = xgetc(0)) { - case 0: - break; - case '\177': - case '\b': - if (s > cmd) { - s--; - printf("\b \b"); - } - break; - case '\n': - case '\r': - putchar('\n'); - *s = 0; - return; - default: - if (s - cmd < sizeof(cmd) - 1) - *s++ = c; - putchar(c); - } - } -} - -int -main(u_int argc, const char *argv[], const char *envv[], uint64_t memsize) -{ - uint8_t autoboot; - ufs_ino_t ino; - size_t nbyte; - - /* Arguments from Miniboot. */ - beri_argc = argc; - beri_argv = argv; - beri_envv = envv; - beri_memsize = memsize; - - dmadat = &__dmadat; -#if 0 - /* XXXRW: more here. */ - v86.ctl = V86_FLAGS; - v86.efl = PSL_RESERVED_DEFAULT | PSL_I; - dsk.drive = *(uint8_t *)PTOV(ARGS); -#endif - dsk.type = TYPE_DEFAULT; -#if 0 - dsk.unit = dsk.drive & DRV_MASK; - dsk.slice = *(uint8_t *)PTOV(ARGS + 1) + 1; -#endif - bootinfo.bi_version = BOOTINFO_VERSION; - bootinfo.bi_size = sizeof(bootinfo); - - /* Process configuration file */ - - autoboot = 1; - - if ((ino = lookup(PATH_CONFIG)) || - (ino = lookup(PATH_DOTCONFIG))) { - nbyte = fsread(ino, cmd, sizeof(cmd) - 1); - cmd[nbyte] = '\0'; - } - - if (*cmd) { - memcpy(cmddup, cmd, sizeof(cmd)); - if (parse()) - autoboot = 0; - if (!OPT_CHECK(RBX_QUIET)) - printf("%s: %s", PATH_CONFIG, cmddup); - /* Do not process this command twice */ - *cmd = 0; - } - - /* - * Try to exec stage 3 boot loader. If interrupted by a keypress, - * or in case of failure, try to load a kernel directly instead. - */ - - if (!kname) { - kname = PATH_LOADER; - if (autoboot && !keyhit(3*SECOND)) { - boot_fromfs(); - kname = PATH_KERNEL; - } - } - - /* Present the user with the boot2 prompt. */ - - for (;;) { - if (!autoboot || !OPT_CHECK(RBX_QUIET)) - printf("\nFreeBSD/mips boot\n" - "Default: %s%ju:%s\n" - "boot: ", - dev_nm[dsk.type], dsk.unitptr, kname); -#if 0 - if (ioctrl & IO_SERIAL) - sio_flush(); -#endif - if (!autoboot || keyhit(3*SECOND)) - getstr(); - else if (!autoboot || !OPT_CHECK(RBX_QUIET)) - putchar('\n'); - autoboot = 0; - if (parse()) - putchar('\a'); - else - load(); - } -} - -static void -boot(void *entryp, int argc, const char *argv[], const char *envv[]) -{ - - bootinfo.bi_kernelname = (bi_ptr_t)kname; - bootinfo.bi_boot2opts = opts & RBX_MASK; - bootinfo.bi_boot_dev_type = dsk.type; - bootinfo.bi_boot_dev_unitptr = dsk.unitptr; - bootinfo.bi_memsize = beri_memsize; -#if 0 - /* - * XXXRW: A possible future way to distinguish Miniboot passing a memory - * size vs DTB..? - */ - if (beri_memsize <= BERI_MEMVSDTB) - bootinfo.bi_memsize = beri_memsize; - else - bootinfo.bi_dtb = beri_memsize; -#endif - ((void(*)(int, const char **, const char **, void *))entryp)(argc, argv, - envv, &bootinfo); -} - -/* - * Boot a kernel that has mysteriously (i.e., by JTAG) appeared in DRAM; - * assume that it is already properly relocated, etc, and invoke its entry - * address without question or concern. - */ -static void -boot_fromdram(void) -{ - void *kaddr = DRAM_KERNEL_ADDR; /* XXXRW: Something better here. */ - Elf64_Ehdr *ehp = kaddr; - - if (!IS_ELF(*ehp)) { - printf("Invalid %s\n", "format"); - return; - } - boot((void *)ehp->e_entry, beri_argc, beri_argv, beri_envv); -} - -static void -boot_fromfs(void) -{ - union { - Elf64_Ehdr eh; - } hdr; - static Elf64_Phdr ep[2]; -#if 0 - static Elf64_Shdr es[2]; -#endif - caddr_t p; - ufs_ino_t ino; - uint64_t addr; - int i, j; - - if (!(ino = lookup(kname))) { - if (!ls) - printf("No %s\n", kname); - return; - } - if (xfsread(ino, &hdr, sizeof(hdr))) - return; - - if (IS_ELF(hdr.eh)) { - fs_off = hdr.eh.e_phoff; - for (j = i = 0; i < hdr.eh.e_phnum && j < 2; i++) { - if (xfsread(ino, ep + j, sizeof(ep[0]))) - return; - if (ep[j].p_type == PT_LOAD) - j++; - } - for (i = 0; i < 2; i++) { - p = (caddr_t)ep[i].p_paddr; - fs_off = ep[i].p_offset; - if (xfsread(ino, p, ep[i].p_filesz)) - return; - } - p += roundup2(ep[1].p_memsz, PAGE_SIZE); -#if 0 - bootinfo.bi_symtab = VTOP(p); - if (hdr.eh.e_shnum == hdr.eh.e_shstrndx + 3) { - fs_off = hdr.eh.e_shoff + sizeof(es[0]) * - (hdr.eh.e_shstrndx + 1); - if (xfsread(ino, &es, sizeof(es))) - return; - for (i = 0; i < 2; i++) { - *(Elf32_Word *)p = es[i].sh_size; - p += sizeof(es[i].sh_size); - fs_off = es[i].sh_offset; - if (xfsread(ino, p, es[i].sh_size)) - return; - p += es[i].sh_size; - } - } -#endif - addr = hdr.eh.e_entry; -#if 0 - bootinfo.bi_esymtab = VTOP(p); -#endif - } else { - printf("Invalid %s\n", "format"); - return; - } - boot((void *)addr, beri_argc, beri_argv, beri_envv); -} - -static void -load(void) -{ - - switch (dsk.type) { - case BOOTINFO_DEV_TYPE_DRAM: - boot_fromdram(); - break; - - default: - boot_fromfs(); - break; - } -} - -static int -parse() -{ - char *arg = cmd; - char *ep, *p, *q; - char unit; - size_t len; - const char *cp; -#if 0 - int c, i, j; -#else - int c, i; -#endif - - while ((c = *arg++)) { - if (c == ' ' || c == '\t' || c == '\n') - continue; - for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++); - ep = p; - if (*p) - *p++ = 0; - if (c == '-') { - while ((c = *arg++)) { - if (c == 'P') { - cp = "yes"; -#if 0 - } else { - opts |= OPT_SET(RBX_DUAL) | OPT_SET(RBX_SERIAL); - cp = "no"; - } -#endif - printf("Keyboard: %s\n", cp); - continue; -#if 0 - } else if (c == 'S') { - j = 0; - while ((unsigned int)(i = *arg++ - '0') <= 9) - j = j * 10 + i; - if (j > 0 && i == -'0') { - comspeed = j; - break; - } - /* Fall through to error below ('S' not in optstr[]). */ -#endif - } - for (i = 0; c != optstr[i]; i++) - if (i == NOPT - 1) - return -1; - opts ^= OPT_SET(flags[i]); - } - ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) : - OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD; -#if 0 - if (ioctrl & IO_SERIAL) { - if (sio_init(115200 / comspeed) != 0) - ioctrl &= ~IO_SERIAL; - } -#endif - } else { - /*- - * Parse a device/kernel name. Format(s): - * - * path - * deviceX:path - * - * NB: Utterly incomprehensible but space-efficient ARM/i386 - * parsing removed in favour of larger but easier-to-read C. This - * is still not great, however -- e.g., relating to unit handling. - * - * TODO: it would be nice if a DRAM pointer could be specified - * here. - * - * XXXRW: Pick up pieces here. - */ - - /* - * Search for a parens; if none, then it's just a path. - * Otherwise, it's a devicename. - */ - arg--; - q = strsep(&arg, ":"); - if (arg != NULL) { - len = strlen(q); - if (len < 2) { - printf("Invalid device: name too short\n"); - return (-1); - } - - /* - * First, handle one-digit unit. - */ - unit = q[len-1]; - if (unit < '0' || unit > '9') { - printf("Invalid device: invalid unit %c\n", - unit); - return (-1); - } - unit -= '0'; - q[len-1] = '\0'; - - /* - * Next, find matching device. - */ - for (i = 0; i < dev_nm_count; i++) { - if (strcmp(q, dev_nm[i]) == 0) - break; - } - if (i == dev_nm_count) { - printf("Invalid device: no driver match\n"); - return (-1); - } - dsk.type = i; - dsk.unitptr = unit; /* Someday: also a DRAM pointer? */ - } else - arg = q; - if ((i = ep - arg)) { - if ((size_t)i >= sizeof(knamebuf)) - return -1; - memcpy(knamebuf, arg, i + 1); - kname = knamebuf; - } - } - arg = p; - } - return 0; -} - -static int -drvread(void *buf, unsigned lba, unsigned nblk) -{ - - /* XXXRW: eventually, we may want to pass 'drive' and 'unit' here. */ - switch (dsk.type) { - case BOOTINFO_DEV_TYPE_CFI: - return (cfi_read(buf, lba, nblk)); - - case BOOTINFO_DEV_TYPE_SDCARD: - return (altera_sdcard_read(buf, lba, nblk)); - - default: - return (-1); - } -} - -static int -dskread(void *buf, unsigned lba, unsigned nblk) -{ -#if 0 - /* - * XXXRW: For now, assume no partition table around the file system; it's - * just in raw flash. - */ - struct dos_partition *dp; - struct disklabel *d; - char *sec; - unsigned i; - uint8_t sl; - - if (!dsk_meta) { - sec = dmadat->secbuf; - dsk.start = 0; - if (drvread(sec, DOSBBSECTOR, 1)) - return -1; - dp = (void *)(sec + DOSPARTOFF); - sl = dsk.slice; - if (sl < BASE_SLICE) { - for (i = 0; i < NDOSPART; i++) - if (dp[i].dp_typ == DOSPTYP_386BSD && - (dp[i].dp_flag & 0x80 || sl < BASE_SLICE)) { - sl = BASE_SLICE + i; - if (dp[i].dp_flag & 0x80 || - dsk.slice == COMPATIBILITY_SLICE) - break; - } - if (dsk.slice == WHOLE_DISK_SLICE) - dsk.slice = sl; - } - if (sl != WHOLE_DISK_SLICE) { - if (sl != COMPATIBILITY_SLICE) - dp += sl - BASE_SLICE; - if (dp->dp_typ != DOSPTYP_386BSD) { - printf("Invalid %s\n", "slice"); - return -1; - } - dsk.start = le32toh(dp->dp_start); - } - if (drvread(sec, dsk.start + LABELSECTOR, 1)) - return -1; - d = (void *)(sec + LABELOFFSET); - if (le32toh(d->d_magic) != DISKMAGIC || - le32toh(d->d_magic2) != DISKMAGIC) { - if (dsk.part != RAW_PART) { - printf("Invalid %s\n", "label"); - return -1; - } - } else { - if (!dsk.init) { - if (le16toh(d->d_type) == DTYPE_SCSI) - dsk.type = TYPE_DA; - dsk.init++; - } - if (dsk.part >= le16toh(d->d_npartitions) || - !(le32toh(d->d_partitions[dsk.part].p_size))) { - printf("Invalid %s\n", "partition"); - return -1; - } - dsk.start += le32toh(d->d_partitions[dsk.part].p_offset); - dsk.start -= le32toh(d->d_partitions[RAW_PART].p_offset); - } - } - return drvread(buf, dsk.start + lba, nblk); -#else - return drvread(buf, lba, nblk); -#endif -} - -void -putchar(int c) -{ - if (c == '\n') - xputc('\r'); - xputc(c); -} - -static int -xputc(int c) -{ - if (ioctrl & IO_KEYBOARD) - beri_putc(c); -#if 0 - if (ioctrl & IO_SERIAL) - sio_putc(c); -#endif - return c; -} - -static int -xgetc(int fn) -{ - if (OPT_CHECK(RBX_NOINTR)) - return 0; - for (;;) { - if (ioctrl & IO_KEYBOARD && keyhit(0)) - return fn ? 1 : beri_getc(); -#if 0 - if (ioctrl & IO_SERIAL && sio_ischar()) - return fn ? 1 : sio_getc(); -#endif - if (fn) - return 0; - } -} - -int -getchar(void) -{ - - return xgetc(0); -} - -void -exit(int code) -{ - - printf("error: loader exit\n"); - while (1); - __unreachable(); -} diff --git a/stand/mips/beri/boot2/flashboot.ldscript b/stand/mips/beri/boot2/flashboot.ldscript deleted file mode 100644 index 4d61438bd9b8..000000000000 --- a/stand/mips/beri/boot2/flashboot.ldscript +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * Copyright (c) 2011-2014 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$ - */ - -INCLUDE ../common/common.ldscript - -/* - * When boot2 is loaded via JTAG, it's dropped at 0x10000, and will not need - * to self-relocate, since it will be in DRAM. - */ -__boot2_base__ = 0x100000; -__boot2_base_vaddr__ = __mips64_xkphys_cached__ + __boot2_base__; - -/* - * XXXRW: Currently, miniboot interprets the ELF header rather than jumping - * straight into the loader. For now, give the location where we know it will - * be. - */ -ENTRY(prerelocate_start) -SECTIONS -{ - . = __boot2_base_vaddr__; - . += SIZEOF_HEADERS; - .text ALIGN(0x10): { - relocate.o(.text) - start.o(.text) - *(EXCLUDE_FILE (relocate.o start.o) .text) - } - .data ALIGN(0x10): { *(.data)} - .bss ALIGN(0x10): { *(.bss) } - - __heap = ALIGN(0x8); /* 64-bit aligned heap pointer */ - __data_end = .; - __boot_loader_len__ = . - __boot2_base_vaddr__; - __bss_start = ADDR(.bss); - __bss_end = ALIGN(__bss_start + SIZEOF(.bss), 0x8); -} diff --git a/stand/mips/beri/boot2/jtagboot.ldscript b/stand/mips/beri/boot2/jtagboot.ldscript deleted file mode 100644 index 064c6e15d038..000000000000 --- a/stand/mips/beri/boot2/jtagboot.ldscript +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * Copyright (c) 2011-2014 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$ - */ - -INCLUDE ../common/common.ldscript - -/* - * When boot2 is loaded via JTAG, it's dropped at 0x10000, and will not need - * to self-relocate, since it will be in DRAM. - */ -__boot2_base__ = 0x100000; -__boot2_base_vaddr__ = __mips64_xkphys_cached__ + __boot2_base__; - -/* - * XXXRW: Currently, miniboot interprets the ELF header rather than jumping - * straight into the loader. For now, give the location where we know it will - * be. - */ -ENTRY(start) -SECTIONS -{ - . = __boot2_base_vaddr__; - . += SIZEOF_HEADERS; - .text ALIGN(0x10): { - start.o(.text) - *(EXCLUDE_FILE (start.o) .text) - } - .data ALIGN(0x10): { *(.data)} - .bss ALIGN(0x10): { *(.bss) } - - __heap = ALIGN(0x8); /* 64-bit aligned heap pointer */ - __data_end = .; - __boot_loader_len__ = . - __boot2_base_vaddr__; - __bss_start = ADDR(.bss); - __bss_end = ALIGN(__bss_start + SIZEOF(.bss), 0x8); -} diff --git a/stand/mips/beri/boot2/relocate.S b/stand/mips/beri/boot2/relocate.S deleted file mode 100644 index d704eb54c69c..000000000000 --- a/stand/mips/beri/boot2/relocate.S +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * Copyright (c) 2013-2014 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$ - */ - -.set mips64 -.set noreorder -.set nobopt -.set noat - -/* - * Save arguments from the BERI firmware for use in C-land, and jump into - * main. Assume that registers/stack/etc are sufficiently initialised to get - * going. Notice that we use only temporaries while relocating, as we want to - * retain argument registers to pass in to main(). - * - * Note slightly surprising structure: boot2 is linked for a specific address, - * but we may start running the code somewhere else (e.g., in DRAM as inserted - * with JTAG, or in flash). The starting assembly is therefore PIC, but the - * main body of the code is not PIC. - */ - - - .text - .global prerelocate_start - .ent prerelocate_start -prerelocate_start: - - /* - * Calculate the actual run-time, pre-relocated value of - * 'start', which we will use as the source address for - * memcpy(). Note that although a symbol is used here, this - * should generate code for a short relative branch, leaving - * the previous $pc in $ra. - */ - bal baltarget - nop -baltarget: - dsub $t1, $ra, 8 /* Src. */ - - /* - * Relocate boot2 to DRAM where we can write back global - * variable values; jump to it. Assume all values are 32-bit - * aligned. Use an inline PIC version of memcpy() - * pre-relocation; strong alignment assumptions. - */ - dla $t0, __boot2_base_vaddr__ /* Dst. */ - dla $t2, __boot_loader_len__ /* Len. */ - -memcpy_loop: - beq $t2, 0, memcopy_done - nop - lw $at, 0($t1) - sw $at, 0($t0) - daddiu $t0, 4 - daddiu $t1, 4 - daddi $t2, -4 - b memcpy_loop - nop - -memcopy_done: - /* - * We can now jump into the relocated code, running from - * cached DRAM rather than uncached flash. Note that a - * relative branch instruction cannot be used. - */ - dla $at, relocated_start - jr $at - nop - -relocated_start: - dla $at, start - jr $at - nop - - .end prerelocate_start diff --git a/stand/mips/beri/boot2/start.S b/stand/mips/beri/boot2/start.S deleted file mode 100644 index c1fcce5812e8..000000000000 --- a/stand/mips/beri/boot2/start.S +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * Copyright (c) 2013-2014 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$ - */ - -.set mips64 -.set noreorder -.set nobopt -.set noat - -/* - * Save arguments from the BERI firmware for use in C-land, and jump into - * main. Assume that registers/stack/etc are sufficiently initialised to get - * going. Notice that we use only temporaries while relocating, as we want to - * retain argument registers to pass in to main(). - * - * Note slightly surprising structure: boot2 is linked for a specific address, - * but we may start running the code somewhere else (e.g., in DRAM as inserted - * with JTAG, or in flash). The starting assembly is therefore PIC, but the - * main body of the code is not PIC. - */ - - - .text - .global start - .ent start -start: - - /* - * Zero BSS. Run from cached memory as this will speed up - * code execution noticeably. Assuming 64-bit alignment of - * everything here. - */ - dla $t0, __bss_start - dla $t1, __bss_end - -bss_loop: - beq $t0, $t1, bss_done - nop - sd $zero, 0($t0) - daddiu $t0, 8 - b bss_loop - nop - -bss_done: - jal main - nop - - /* - * Ideally we wouldn't get here, but just in case. - */ -loop: - b loop - nop - .end start diff --git a/stand/mips/beri/common/altera_jtag_uart.c b/stand/mips/beri/common/altera_jtag_uart.c deleted file mode 100644 index 173672eac792..000000000000 --- a/stand/mips/beri/common/altera_jtag_uart.c +++ /dev/null @@ -1,175 +0,0 @@ -/*- - * Copyright (c) 2011, 2013 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$ - */ - -#include "stand.h" -#include "mips.h" - -/*- - * Routines for interacting with the CHERI console UART. Programming details - * from the June 2011 "Embedded Peripherals User Guide" by Altera - * Corporation, tables 6-2 (JTAG UART Core Register Map), 6-3 (Data Register - * Bits), and 6-4 (Control Register Bits). - * - * Hard-coded physical address for the first JTAG UART -- true on all BERI and - * CHERI boards. - */ -#define CHERI_UART_BASE 0x7f000000 /* JTAG UART */ - -/* - * - * Offsets of data and control registers relative to the base. Altera - * conventions are maintained in CHERI. - */ -#define ALTERA_JTAG_UART_DATA_OFF 0x00000000 -#define ALTERA_JTAG_UART_CONTROL_OFF 0x00000004 - -/* - * Offset 0: 'data' register -- bits 31-16 (RAVAIL), 15 (RVALID), - * 14-8 (Reserved), 7-0 (DATA). - * - * DATA - One byte read or written. - * RAVAIL - Bytes available to read (excluding the current byte). - * RVALID - Whether the byte in DATA is valid. - */ -#define ALTERA_JTAG_UART_DATA_DATA 0x000000ff -#define ALTERA_JTAG_UART_DATA_RESERVED 0x00007f00 -#define ALTERA_JTAG_UART_DATA_RVALID 0x00008000 -#define ALTERA_JTAG_UART_DATA_RAVAIL 0xffff0000 -#define ALTERA_JTAG_UART_DATA_RAVAIL_SHIFT 16 - -/*- - * Offset 1: 'control' register -- bits 31-16 (WSPACE), 15-11 (Reserved), - * 10 (AC), 9 (WI), 8 (RI), 7..2 (Reserved), 1 (WE), 0 (RE). - * - * RE - Enable read interrupts. - * WE - Enable write interrupts. - * RI - Read interrupt pending. - * WI - Write interrupt pending. - * AC - Activity bit; set to '1' to clear to '0'. - * WSPACE - Space available in the write FIFO. - */ -#define ALTERA_JTAG_UART_CONTROL_RE 0x00000001 -#define ALTERA_JTAG_UART_CONTROL_WE 0x00000002 -#define ALTERA_JTAG_UART_CONTROL_RESERVED0 0x000000fc -#define ALTERA_JTAG_UART_CONTROL_RI 0x00000100 -#define ALTERA_JTAG_UART_CONTROL_WI 0x00000200 -#define ALTERA_JTAG_UART_CONTROL_AC 0x00000400 -#define ALTERA_JTAG_UART_CONTROL_RESERVED1 0x0000f800 -#define ALTERA_JTAG_UART_CONTROL_WSPACE 0xffff0000 -#define ALTERA_JTAG_UART_CONTROL_WSPACE_SHIFT 16 - -/* - * One-byte buffer as we can't check whether the UART is readable without - * actually reading from it. - */ -static char buffer_data; -static int buffer_valid; - -/* - * Low-level read and write register routines; the Altera UART is little - * endian, so we byte swap 32-bit reads and writes. - */ -static inline uint32_t -uart_data_read(void) -{ - - return (mips_ioread_uint32le(mips_phys_to_uncached(CHERI_UART_BASE + - ALTERA_JTAG_UART_DATA_OFF))); -} - -static inline void -uart_data_write(uint32_t v) -{ - - mips_iowrite_uint32le(mips_phys_to_uncached(CHERI_UART_BASE + - ALTERA_JTAG_UART_DATA_OFF), v); -} - -static inline uint32_t -uart_control_read(void) -{ - - return (mips_ioread_uint32le(mips_phys_to_uncached(CHERI_UART_BASE + - ALTERA_JTAG_UART_CONTROL_OFF))); -} - -static inline void -uart_control_write(uint32_t v) -{ - - mips_iowrite_uint32le(mips_phys_to_uncached(CHERI_UART_BASE + - ALTERA_JTAG_UART_DATA_OFF), v); -} - -static int -uart_readable(void) -{ - uint32_t v; - - if (buffer_valid) - return (1); - v = uart_data_read(); - if ((v & ALTERA_JTAG_UART_DATA_RVALID) != 0) { - buffer_valid = 1; - buffer_data = (v & ALTERA_JTAG_UART_DATA_DATA); - } - return (0); -} - -int -keyhit(int seconds) -{ - register_t stoptime; - - stoptime = cp0_count_get() + seconds * 100000000; /* 100 MHz. */ - do { - if (uart_readable()) - return (1); - } while (cp0_count_get() < stoptime); - return (0); -} - -int -beri_getc(void) -{ - - while (!(uart_readable())); - buffer_valid = 0; - return (buffer_data); -} - -void -beri_putc(int ch) -{ - - uart_data_write(ch); -} diff --git a/stand/mips/beri/common/beri.h b/stand/mips/beri/common/beri.h deleted file mode 100644 index e6ccae861009..000000000000 --- a/stand/mips/beri/common/beri.h +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * Copyright (c) 2013-2014 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$ - */ - -#ifndef _BOOT_BERI_H_ -#define _BOOT_BERI_H_ - -/* - * Older BERI boot loaders pass in physical memory size as $a3; newer ones - * pass in FDT DTB data. This constant helps us tell the difference. - */ -#define BERI_MEMVSDTB (256*1024*1024*1024ULL) - -#endif diff --git a/stand/mips/beri/common/cfi.c b/stand/mips/beri/common/cfi.c deleted file mode 100644 index cd788de56e7f..000000000000 --- a/stand/mips/beri/common/cfi.c +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * Copyright (c) 2013 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$ - */ - -#include "stand.h" -#include "mips.h" -#include "cfi.h" - -/* - * Memory-mapped Intel StrataFlash mini-driver. Very mini. Nothing fancy -- - * and few seatbelts. - * - * XXXRW: Should we be making some effort to reset isf to a known-good state - * before starting, in case there was a soft reset mid-transaction. - * - * XXXRW: Would be nice to support multiple devices and also handle SD cards - * here ... and probably not too hard. - */ -extern void *__cheri_flash_bootfs_vaddr__; -extern void *__cheri_flash_bootfs_len__; - -#define CHERI_BOOTFS_BASE ((uintptr_t)&__cheri_flash_bootfs_vaddr__) -#define CHERI_BOOTFS_LENGTH ((uintptr_t)&__cheri_flash_bootfs_len__) - -int -cfi_read(void *buf, unsigned lba, unsigned nblk) -{ - - if ((lba << 9) + (nblk << 9) > CHERI_BOOTFS_LENGTH) - return (-1); - memcpy(buf, (void *)(CHERI_BOOTFS_BASE + (lba << 9)), nblk << 9); - return (0); -} - -uint64_t -cfi_get_mediasize(void) -{ - - return (CHERI_BOOTFS_LENGTH); -} - -uint64_t -cfi_get_sectorsize(void) -{ - - return (512); /* Always a good sector size. */ -} diff --git a/stand/mips/beri/common/cfi.h b/stand/mips/beri/common/cfi.h deleted file mode 100644 index 3dfe48c8c729..000000000000 --- a/stand/mips/beri/common/cfi.h +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * Copyright (c) 2013 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$ - */ - -#ifndef _CFI_H_ -#define _CFI_H_ - -int cfi_read(void *buf, unsigned lba, unsigned blk); -uint64_t cfi_get_mediasize(void); -uint64_t cfi_get_sectorsize(void); - -#endif diff --git a/stand/mips/beri/common/common.ldscript b/stand/mips/beri/common/common.ldscript deleted file mode 100644 index 6266646cfc3c..000000000000 --- a/stand/mips/beri/common/common.ldscript +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * Copyright (c) 2011-2014 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$ - */ - -/* - * MIPS segment definitions. - */ -__mips_ckseg_cached__ = 0xffffffff80000000; /* BSD kernel here. */ -__mips64_xkphys_cached__ = 0x9800000000000000; /* Device memory here. */ -__mips64_xkphys_uncached__ = 0x9000000000000000; /* Device I/O here. */ - -/* - * Physical addresses of various peripherals. - */ -__cheri_flash_base__ = 0x74000000; -__cheri_sdcard_base__ = 0x7f008000; - -/* - * Location of boot2 in flash. - */ -__cheri_flash_boot_loader_base_ = 0x03fe0000; -__cheri_flash_boot_loader_vaddr__ = __mips64_xkphys_cached__ + - __cheri_flash_base__ + __cheri_flash_boot_loader_base_; - -/* - * Location of boot file system in flash. - */ -__cheri_flash_bootfs_base__ = 0x1820000; -__cheri_flash_bootfs_len__ = 0x27c0000; -__cheri_flash_bootfs_vaddr__ = __mips64_xkphys_cached__ + - __cheri_flash_base__ + __cheri_flash_bootfs_base__; - -/* - * Location of SD card controller. - */ -__cheri_sdcard_vaddr__ = __mips64_xkphys_uncached__ + __cheri_sdcard_base__; - -/* - * Location where the production kernel gets put. This must agree with other - * definitions, such as in the kernel's own linker script. - * - * (As it happens, in the short run, we also place boot2 here, as Miniboot - * expects to find an ELF binary there -- but that will change.) - */ -__kernel_base__ = 0x100000; -__kernel_vaddr__ = __mips64_xkphys_cached__ + __kernel_base__; - -OUTPUT_ARCH(mips) diff --git a/stand/mips/beri/common/cons.h b/stand/mips/beri/common/cons.h deleted file mode 100644 index 7d27173bc835..000000000000 --- a/stand/mips/beri/common/cons.h +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * Copyright (c) 2013 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$ - */ - -#ifndef _CONS_H_ -#define _CONS_H_ - -int beri_getc(void); -int keyhit(int); -void beri_putc(int); - -#endif diff --git a/stand/mips/beri/common/mips.h b/stand/mips/beri/common/mips.h deleted file mode 100644 index c63d475313a4..000000000000 --- a/stand/mips/beri/common/mips.h +++ /dev/null @@ -1,156 +0,0 @@ -/*- - * Copyright (c) 2011 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$ - */ - -#ifndef _MIPS_H_ -#define _MIPS_H_ - -/* - * 64-bit MIPS types. - */ -#if 0 -typedef unsigned long register_t; /* 64-bit MIPS register */ -#endif -typedef unsigned long paddr_t; /* Physical address */ -typedef unsigned long vaddr_t; /* Virtual address */ - -#if 0 -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -typedef unsigned long uint64_t; -#endif - -/* - * MIPS address space layout. - */ -#define MIPS_XKPHYS_UNCACHED_BASE 0x9000000000000000 -#define MIPS_XKPHYS_CACHED_NC_BASE 0x9800000000000000 - -static inline vaddr_t -mips_phys_to_cached(paddr_t phys) -{ - - return (phys | MIPS_XKPHYS_CACHED_NC_BASE); -} - -static inline vaddr_t -mips_phys_to_uncached(paddr_t phys) -{ - - return (phys | MIPS_XKPHYS_UNCACHED_BASE); -} - -/* - * Endian conversion routines for use in I/O -- most Altera devices are little - * endian, but our processor is big endian. - */ -static inline uint16_t -byteswap16(uint16_t v) -{ - - return ((v & 0xff00) >> 8 | (v & 0xff) << 8); -} - -static inline uint32_t -byteswap32(uint32_t v) -{ - - return ((v & 0xff000000) >> 24 | (v & 0x00ff0000) >> 8 | - (v & 0x0000ff00) << 8 | (v & 0x000000ff) << 24); -} - -/* - * MIPS simple I/O routines -- arguments are virtual addresses so that the - * caller can determine required caching properties. - */ -static inline uint8_t -mips_ioread_uint8(vaddr_t vaddr) -{ - uint8_t v; - - __asm__ __volatile__ ("lb %0, 0(%1)" : "=r" (v) : "r" (vaddr)); - return (v); -} - -static inline void -mips_iowrite_uint8(vaddr_t vaddr, uint8_t v) -{ - - __asm__ __volatile__ ("sb %0, 0(%1)" : : "r" (v), "r" (vaddr)); -} - -static inline uint32_t -mips_ioread_uint32(vaddr_t vaddr) -{ - uint32_t v; - - __asm__ __volatile__ ("lw %0, 0(%1)" : "=r" (v) : "r" (vaddr)); - return (v); -} - -static inline void -mips_iowrite_uint32(vaddr_t vaddr, uint32_t v) -{ - - __asm__ __volatile__ ("sw %0, 0(%1)" : : "r" (v), "r" (vaddr)); -} - -/* - * Little-endian versions of 32-bit I/O routines. - */ -static inline uint32_t -mips_ioread_uint32le(vaddr_t vaddr) -{ - - return (byteswap32(mips_ioread_uint32(vaddr))); -} - -static inline void -mips_iowrite_uint32le(vaddr_t vaddr, uint32_t v) -{ - - mips_iowrite_uint32(vaddr, byteswap32(v)); -} - -/* - * Coprocessor 0 interfaces. - */ -static inline register_t -cp0_count_get(void) -{ - register_t count; - - __asm__ __volatile__ ("dmfc0 %0, $9" : "=r" (count)); - return (count); -} - -#endif diff --git a/stand/mips/beri/common/sdcard.c b/stand/mips/beri/common/sdcard.c deleted file mode 100644 index 14b52875ed4d..000000000000 --- a/stand/mips/beri/common/sdcard.c +++ /dev/null @@ -1,333 +0,0 @@ -/*- - * Copyright (c) 2012-2014 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$ - */ - -#include -#include - -#include - - -/* - * Altera University Program SD Card micro-driver for boot2 and loader. - * - * XXXRW: It might be nice to add 'unit' arguments to all APIs to allow - * multiple instances to be addressed. - */ - -/* Constants lifted from altera_sdcard.h -- possibly we should share headers? */ -#define ALTERA_SDCARD_OFF_RXTX_BUFFER 0 /* 512-byte I/O buffer */ -#define ALTERA_SDCARD_OFF_CID 512 /* 16-byte Card ID number */ -#define ALTERA_SDCARD_OFF_CSD 528 /* 16-byte Card Specific Data */ -#define ALTERA_SDCARD_OFF_OCR 544 /* Operating Conditions Reg */ -#define ALTERA_SDCARD_OFF_SR 548 /* SD Card Status Register */ -#define ALTERA_SDCARD_OFF_RCA 552 /* Relative Card Address Reg */ -#define ALTERA_SDCARD_OFF_CMD_ARG 556 /* Command Argument Register */ -#define ALTERA_SDCARD_OFF_CMD 560 /* Command Register */ -#define ALTERA_SDCARD_OFF_ASR 564 /* Auxiliary Status Register */ -#define ALTERA_SDCARD_OFF_RR1 568 /* Response R1 */ - -#define ALTERA_SDCARD_SECTORSIZE 512 - -#define ALTERA_SDCARD_CMD_SEND_RCA 0x03 /* Retrieve card RCA. */ -#define ALTERA_SDCARD_CMD_SEND_CSD 0x09 /* Retrieve CSD register. */ -#define ALTERA_SDCARD_CMD_SEND_CID 0x0A /* Retrieve CID register. */ -#define ALTERA_SDCARD_CMD_READ_BLOCK 0x11 /* Read block from disk. */ -#define ALTERA_SDCARD_CMD_WRITE_BLOCK 0x18 /* Write block to disk. */ - -#define ALTERA_SDCARD_ASR_CMDVALID 0x0001 -#define ALTERA_SDCARD_ASR_CARDPRESENT 0x0002 -#define ALTERA_SDCARD_ASR_CMDINPROGRESS 0x0004 -#define ALTERA_SDCARD_ASR_SRVALID 0x0008 -#define ALTERA_SDCARD_ASR_CMDTIMEOUT 0x0010 -#define ALTERA_SDCARD_ASR_CMDDATAERROR 0x0020 - -#define ALTERA_SDCARD_RR1_INITPROCRUNNING 0x0100 -#define ALTERA_SDCARD_RR1_ERASEINTERRUPTED 0x0200 -#define ALTERA_SDCARD_RR1_ILLEGALCOMMAND 0x0400 -#define ALTERA_SDCARD_RR1_COMMANDCRCFAILED 0x0800 -#define ALTERA_SDCARD_RR1_ADDRESSMISALIGNED 0x1000 -#define ALTERA_SDCARD_RR1_ADDRBLOCKRANGE 0x2000 - -#define ALTERA_SDCARD_CSD_STRUCTURE_BYTE 15 -#define ALTERA_SDCARD_CSD_STRUCTURE_MASK 0xc0 /* 2 bits */ -#define ALTERA_SDCARD_CSD_STRUCTURE_RSHIFT 6 -#define ALTERA_SDCARD_CSD_SIZE 16 -#define ALTERA_SDCARD_CSD_READ_BL_LEN_BYTE 10 -#define ALTERA_SDCARD_CSD_READ_BL_LEN_MASK 0x0f /* 4 bits */ -#define ALTERA_SDCARD_CSD_C_SIZE_BYTE0 7 -#define ALTERA_SDCARD_CSD_C_SIZE_MASK0 0xc0 /* top 2 bits */ -#define ALTERA_SDCARD_CSD_C_SIZE_RSHIFT0 6 -#define ALTERA_SDCARD_CSD_C_SIZE_BYTE1 8 -#define ALTERA_SDCARD_CSD_C_SIZE_MASK1 0xff /* 8 bits */ -#define ALTERA_SDCARD_CSD_C_SIZE_LSHIFT1 2 -#define ALTERA_SDCARD_CSD_C_SIZE_BYTE2 9 -#define ALTERA_SDCARD_CSD_C_SIZE_MASK2 0x03 /* bottom 2 bits */ -#define ALTERA_SDCARD_CSD_C_SIZE_LSHIFT2 10 -#define ALTERA_SDCARD_CSD_C_SIZE_MULT_BYTE0 5 -#define ALTERA_SDCARD_CSD_C_SIZE_MULT_MASK0 0x80 /* top 1 bit */ -#define ALTERA_SDCARD_CSD_C_SIZE_MULT_RSHIFT0 7 -#define ALTERA_SDCARD_CSD_C_SIZE_MULT_BYTE1 6 -#define ALTERA_SDCARD_CSD_C_SIZE_MULT_MASK1 0x03 /* bottom 2 bits */ -#define ALTERA_SDCARD_CSD_C_SIZE_MULT_LSHIFT1 1 - -/* - * Not all RR1 values are "errors" per se -- check only for the ones that are - * when performing error handling. - */ -#define ALTERA_SDCARD_RR1_ERRORMASK \ - (ALTERA_SDCARD_RR1_ERASEINTERRUPTED | ALTERA_SDCARD_RR1_ILLEGALCOMMAND | \ - ALTERA_SDCARD_RR1_COMMANDCRCFAILED | ALTERA_SDCARD_RR1_ADDRESSMISALIGNED |\ - ALTERA_SDCARD_RR1_ADDRBLOCKRANGE) - -extern uint8_t __cheri_sdcard_vaddr__[]; - -#define ALTERA_SDCARD_PTR(type, offset) \ - (volatile type *)(&__cheri_sdcard_vaddr__[(offset)]) - -static __inline uint16_t -altera_sdcard_read_uint16(u_int offset) -{ - volatile uint16_t *p; - - p = ALTERA_SDCARD_PTR(uint16_t, offset); - return (le16toh(*p)); -} - -static __inline void -altera_sdcard_write_uint16(u_int offset, uint16_t v) -{ - volatile uint16_t *p; - - p = ALTERA_SDCARD_PTR(uint16_t, offset); - *p = htole16(v); -} - -static __inline void -altera_sdcard_write_uint32(u_int offset, uint32_t v) -{ - volatile uint32_t *p; - - p = ALTERA_SDCARD_PTR(uint32_t, offset); - *p = htole32(v); -} - -static __inline uint16_t -altera_sdcard_read_asr(void) -{ - - return (altera_sdcard_read_uint16(ALTERA_SDCARD_OFF_ASR)); -} - -static __inline uint16_t -altera_sdcard_read_rr1(void) -{ - - return (altera_sdcard_read_uint16(ALTERA_SDCARD_OFF_RR1)); -} - -static __inline void -altera_sdcard_write_cmd(uint16_t cmd) -{ - - altera_sdcard_write_uint16(ALTERA_SDCARD_OFF_CMD, cmd); -} - -static __inline void -altera_sdcard_write_cmd_arg(uint32_t cmd_arg) -{ - - altera_sdcard_write_uint32(ALTERA_SDCARD_OFF_CMD_ARG, cmd_arg); -} - -/* NB: Use 16-bit aligned buffer due to hardware features, so 16-bit type. */ -static __inline void -altera_sdcard_read_csd(uint16_t *csdp) -{ - volatile uint16_t *hw_csdp; - u_int i; - - hw_csdp = ALTERA_SDCARD_PTR(uint16_t, ALTERA_SDCARD_OFF_CSD); - for (i = 0; i < ALTERA_SDCARD_CSD_SIZE / sizeof(uint16_t); i++) - csdp[i] = hw_csdp[i]; -} - -/* - * Private interface: load exactly one block of size ALTERA_SDCARD_SECTORSIZE - * from block #lba. - */ -static int -altera_sdcard_read_block(void *buf, unsigned lba) -{ - volatile uint32_t *rxtxp; - uint32_t *bufp; - uint16_t asr, rr1; - int i; - - if (!(altera_sdcard_read_asr() & ALTERA_SDCARD_ASR_CARDPRESENT)) { - printf("SD Card: card not present\n"); - return (-1); - } - - bufp = (uint32_t *)buf; - rxtxp = ALTERA_SDCARD_PTR(uint32_t, ALTERA_SDCARD_OFF_RXTX_BUFFER); - - /* - * Issue read block command. - */ - altera_sdcard_write_cmd_arg(lba * ALTERA_SDCARD_SECTORSIZE); - altera_sdcard_write_cmd(ALTERA_SDCARD_CMD_READ_BLOCK); - - /* - * Wait for device to signal completion of command. - */ - while ((asr = altera_sdcard_read_asr()) & - ALTERA_SDCARD_ASR_CMDINPROGRESS); - - /* - * Due to hardware bugs/features, interpretting this field is messy. - */ - rr1 = altera_sdcard_read_rr1(); - rr1 &= ~ALTERA_SDCARD_RR1_COMMANDCRCFAILED; /* HW bug. */ - if (asr & ALTERA_SDCARD_ASR_CMDTIMEOUT) { - printf("SD Card: timeout\n"); - return (-1); - } - if ((asr & ALTERA_SDCARD_ASR_CMDDATAERROR) && - (rr1 & ALTERA_SDCARD_RR1_ERRORMASK)) { - printf("SD Card: asr %u rr1 %u\n", asr, rr1); - return (-1); - } - - /* - * We can't use a regular memcpy() due to byte-enable bugs in the - * Altera IP core: instead copy in 32-bit units. - */ - for (i = 0; i < ALTERA_SDCARD_SECTORSIZE/sizeof(uint32_t); i++) - bufp[i] = rxtxp[i]; - return (0); -} - -/* - * Public interface: load 'nblk' blocks from block #lba into *buf. - */ -int -altera_sdcard_read(void *buf, unsigned lba, unsigned nblk) -{ - uint8_t *bufp = buf; - int i; - - for (i = 0; i < nblk; i++) { - if (altera_sdcard_read_block(bufp + i * - ALTERA_SDCARD_SECTORSIZE, lba + i) < 0) { - printf("SD Card: block read %u failed\n", i); - return (-1); - } - } - return (0); -} - -/* - * Public interface: query (current) media size. - */ -uint64_t -altera_sdcard_get_mediasize(void) -{ - uint64_t mediasize; - uint64_t c_size, c_size_mult, read_bl_len; - uint16_t csd16[ALTERA_SDCARD_CSD_SIZE/sizeof(uint16_t)]; - uint8_t *csd8p = (uint8_t *)&csd16; - uint8_t byte0, byte1, byte2; - - altera_sdcard_read_csd(csd16); /* Provide 16-bit alignment. */ - - read_bl_len = csd8p[ALTERA_SDCARD_CSD_READ_BL_LEN_BYTE]; - read_bl_len &= ALTERA_SDCARD_CSD_READ_BL_LEN_MASK; - - byte0 = csd8p[ALTERA_SDCARD_CSD_C_SIZE_BYTE0]; - byte0 &= ALTERA_SDCARD_CSD_C_SIZE_MASK0; - byte1 = csd8p[ALTERA_SDCARD_CSD_C_SIZE_BYTE1]; - byte2 = csd8p[ALTERA_SDCARD_CSD_C_SIZE_BYTE2]; - byte2 &= ALTERA_SDCARD_CSD_C_SIZE_MASK2; - c_size = (byte0 >> ALTERA_SDCARD_CSD_C_SIZE_RSHIFT0) | - (byte1 << ALTERA_SDCARD_CSD_C_SIZE_LSHIFT1) | - (byte2 << ALTERA_SDCARD_CSD_C_SIZE_LSHIFT2); - - byte0 = csd8p[ALTERA_SDCARD_CSD_C_SIZE_MULT_BYTE0]; - byte0 &= ALTERA_SDCARD_CSD_C_SIZE_MULT_MASK0; - byte1 = csd8p[ALTERA_SDCARD_CSD_C_SIZE_MULT_BYTE1]; - byte1 &= ALTERA_SDCARD_CSD_C_SIZE_MULT_MASK1; - c_size_mult = (byte0 >> ALTERA_SDCARD_CSD_C_SIZE_MULT_RSHIFT0) | - (byte1 << ALTERA_SDCARD_CSD_C_SIZE_MULT_LSHIFT1); - - mediasize = (c_size + 1) * (1 << (c_size_mult + 2)) * - (1 << read_bl_len); - return (mediasize); -} - -/* - * Public interface: is media present / supported? - */ -int -altera_sdcard_get_present(void) -{ - uint16_t csd16[ALTERA_SDCARD_CSD_SIZE/sizeof(uint16_t)]; - uint8_t *csd8p = (uint8_t *)&csd16; - uint8_t csd_structure; - - /* First: does status bit think it is there? */ - if (!(altera_sdcard_read_asr() & ALTERA_SDCARD_ASR_CARDPRESENT)) { - printf("SD Card: not present\n"); - return (0); - } - - /* Second: do we understand the CSD structure version? */ - altera_sdcard_read_csd(csd16); /* Provide 16-bit alignment. */ - csd_structure = csd8p[ALTERA_SDCARD_CSD_STRUCTURE_BYTE]; - csd_structure &= ALTERA_SDCARD_CSD_STRUCTURE_MASK; - csd_structure >>= ALTERA_SDCARD_CSD_STRUCTURE_RSHIFT; - if (csd_structure != 0) { - printf("SD Card: unrecognised csd %u\n", csd_structure); - return (0); - } - - return (1); -} - -/* - * Public interface: query sector size. - */ -uint64_t -altera_sdcard_get_sectorsize(void) -{ - - return (ALTERA_SDCARD_SECTORSIZE); -} diff --git a/stand/mips/beri/common/sdcard.h b/stand/mips/beri/common/sdcard.h deleted file mode 100644 index 0eb77604d766..000000000000 --- a/stand/mips/beri/common/sdcard.h +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * Copyright (c) 2014 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$ - */ - -#ifndef _SDCARD_H_ -#define _SDCARD_H_ - -int altera_sdcard_read(void *buf, unsigned lba, unsigned nblk); -uint64_t altera_sdcard_get_mediasize(void); -int altera_sdcard_get_present(void); -uint64_t altera_sdcard_get_sectorsize(void); - -#endif /* !_SDCARD_H_ */ diff --git a/stand/mips/beri/loader/Makefile b/stand/mips/beri/loader/Makefile deleted file mode 100644 index fa0d48388ea3..000000000000 --- a/stand/mips/beri/loader/Makefile +++ /dev/null @@ -1,109 +0,0 @@ -#- -# Copyright (c) 2013-2014 Robert N. M. Watson -# All rights reserved. -# -# This software was developed by SRI International and the University of -# Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) -# ("CTSRD"), as part of the DARPA CRASH research programme. -# -# 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$ - -LOADER_MSDOS_SUPPORT?= yes -LOADER_UFS_SUPPORT?= yes -LOADER_CD9660_SUPPORT?= no -LOADER_EXT2FS_SUPPORT?= no -LOADER_GZIP_SUPPORT?= yes -LOADER_BZIP2_SUPPORT?= yes - -.include - -PROG?= loader -NEWVERSWHAT= "BERI loader" ${MACHINE_CPUARCH} -INSTALLFLAGS= -b - -# Architecture-specific loader code -SRCS= start.S \ - main.c \ - devicename.c \ - exec.c \ - vers.c \ - arch.c \ - gfx_fb.c - -# libstand front-ends for shared driver code -SRCS+= beri_console.c \ - beri_disk_cfi.c \ - beri_disk_sdcard.c - -# Common code with boot2 -SRCS+= altera_jtag_uart.c \ - cfi.c \ - sdcard.c - -CFLAGS.gfx_fb.c += -I${SRCTOP}/contrib/pnglite -CFLAGS.gfx_fb.c += -I${SRCTOP}/sys/teken - -# Since we don't have a backward compatibility issue, default to this on BERI. -CFLAGS+= -DBOOT_PROMPT_123 - -HELP_FILES= ${.CURDIR}/help.mips - -# Always add MI sources -.include "${BOOTSRC}/loader.mk" - -# BERI files common to boot2 and loader -.PATH: ${BOOTSRC}/mips/beri/common -CFLAGS+= -I${BOOTSRC}/mips/beri/common - -# Loader-specific MD headers -CFLAGS+= -I${.CURDIR} - -# Generate code appropriate for the loader environment -CFLAGS+= -G0 \ - -fno-pic \ - -mno-abicalls \ - -g - -LDFLAGS+= -static \ - -T ${.CURDIR}/loader.ldscript \ - -L${.CURDIR} \ - -e __start - -DPADD= ${LDR_INTERP} ${LIBSA} -LDADD= ${LDR_INTERP} ${LIBSA} - -.if defined(LOADER_USB_SUPPORT) -# Do garbage collection -CFLAGS+= -ffunction-sections -fdata-sections -CFLAGS+= -Wl,--gc-sections -# Link USB BOOT library -LDADD+= ${BOOTOBJ}/usb/libusbboot.a -CFLAGS+= -I${BOOTSRC}/usb -# Define USB SUPPORT -CFLAGS+= -DLOADER_USB_SUPPORT -.endif - -all: loader - -.include diff --git a/stand/mips/beri/loader/arch.c b/stand/mips/beri/loader/arch.c deleted file mode 100644 index a30f18dfbce9..000000000000 --- a/stand/mips/beri/loader/arch.c +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * Copyright (c) 2013 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$"); - -#include - -#include - -#include -#include -#include -#include - -static int beri_arch_autoload(void); -static ssize_t beri_arch_copyin(const void *src, vm_offset_t va, size_t len); -static ssize_t beri_arch_copyout(vm_offset_t va, void *dst, size_t len); -static uint64_t beri_arch_loadaddr(u_int type, void *data, uint64_t addr); -static ssize_t beri_arch_readin(readin_handle_t fd, vm_offset_t va, size_t len); - -struct arch_switch archsw = { - .arch_autoload = beri_arch_autoload, - .arch_getdev = beri_arch_getdev, - .arch_copyin = beri_arch_copyin, - .arch_copyout = beri_arch_copyout, - .arch_loadaddr = beri_arch_loadaddr, - .arch_readin = beri_arch_readin, - -}; - -static int -beri_arch_autoload(void) -{ - - return (0); -} - -static ssize_t -beri_arch_copyin(const void *src, vm_offset_t va, size_t len) -{ - - memcpy((void *)va, src, len); - return (len); -} - -static ssize_t -beri_arch_copyout(vm_offset_t va, void *dst, size_t len) -{ - - memcpy(dst, (void *)va, len); - return (len); -} - -static uint64_t -beri_arch_loadaddr(u_int type, void *data, uint64_t addr) -{ - uint64_t align; - - /* Align ELF objects at page boundaries; others at cache lines. */ - align = (type == LOAD_ELF) ? PAGE_SIZE : CACHE_LINE_SIZE; - return (roundup2(addr, align)); -} - -static ssize_t -beri_arch_readin(readin_handle_t fd, vm_offset_t va, size_t len) -{ - - return (VECTX_READ(fd, (void *)va, len)); -} diff --git a/stand/mips/beri/loader/beri_console.c b/stand/mips/beri/loader/beri_console.c deleted file mode 100644 index 3c95d753150b..000000000000 --- a/stand/mips/beri/loader/beri_console.c +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * Copyright (c) 2013 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$"); - -#include - -#include - -#include - -static void c_probe(struct console *); -static int c_init(int); -static void c_out(int); -static int c_in(void); -static int c_ready(void); - -struct console altera_jtag_uart_console = { - .c_name = "comconsole", - .c_desc = "altera jtag uart", - .c_flags = 0, - .c_probe = c_probe, - .c_init = c_init, - .c_out = c_out, - .c_in = c_in, - .c_ready = c_ready, -}; - -static void -c_probe(struct console *cp) -{ - - cp->c_flags |= C_PRESENTIN|C_PRESENTOUT; -} - -static int -c_init(int arg) -{ - - return (0); -} - -static void -c_out(int c) -{ - - beri_putc(c); -} - -static int -c_in(void) -{ - - return (beri_getc()); -} - -static int -c_ready(void) -{ - - return (keyhit(0)); -} diff --git a/stand/mips/beri/loader/beri_disk_cfi.c b/stand/mips/beri/loader/beri_disk_cfi.c deleted file mode 100644 index d6e62662b0ab..000000000000 --- a/stand/mips/beri/loader/beri_disk_cfi.c +++ /dev/null @@ -1,141 +0,0 @@ -/*- - * Copyright (c) 2013-2014 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$"); - -#include - -#include -#include - -#include -#include - -#include - -static int beri_cfi_disk_init(void); -static int beri_cfi_disk_open(struct open_file *, ...); -static int beri_cfi_disk_close(struct open_file *); -static int beri_cfi_disk_strategy(void *, int, daddr_t, size_t, - char *, size_t *); -static int beri_cfi_disk_print(int); - -struct devsw beri_cfi_disk = { - .dv_name = "cfi", - .dv_type = DEVT_DISK, - .dv_init = beri_cfi_disk_init, - .dv_strategy = beri_cfi_disk_strategy, - .dv_open = beri_cfi_disk_open, - .dv_close = beri_cfi_disk_close, - .dv_ioctl = noioctl, - .dv_print = beri_cfi_disk_print, - .dv_cleanup = NULL, -}; - -static int -beri_cfi_disk_init(void) -{ - - return (0); -} - -static int -beri_cfi_disk_strategy(void *devdata, int flag, daddr_t dblk, size_t size, - char *buf, size_t *rsizep) -{ - int error; - - flag &= F_MASK; - if (flag == F_WRITE) - return (EROFS); - if (flag != F_READ) - return (EINVAL); - if (rsizep != NULL) - *rsizep = 0; - error = cfi_read(buf, dblk, size >> 9); - if (error == 0 && rsizep != NULL) - *rsizep = size; - else if (error != 0) - printf("%s: error %d\n", __func__, error); - return (error); -} - -static int -beri_cfi_disk_open(struct open_file *f, ...) -{ - va_list ap; - struct disk_devdesc *dev; - - va_start(ap, f); - dev = va_arg(ap, struct disk_devdesc *); - va_end(ap); - - if (dev->dd.d_unit != 0) - return (EIO); - return (disk_open(dev, cfi_get_mediasize(), cfi_get_sectorsize())); -} - -static int -beri_cfi_disk_close(struct open_file *f) -{ - struct disk_devdesc *dev; - - dev = (struct disk_devdesc *)f->f_devdata; - return (disk_close(dev)); -} - -static int -beri_cfi_disk_print(int verbose) -{ - struct disk_devdesc dev; - char line[80]; - int ret; - - printf("%s devices:", beri_cfi_disk.dv_name); - if ((ret = pager_output("\n")) != 0) - return (ret); - - snprintf(line, sizeof(line), " cfi%d CFI flash device\n", 0); - ret = pager_output(line); - if (ret != 0) - return (ret); - dev.dd.d_dev = &beri_cfi_disk; - dev.dd.d_unit = 0; - dev.d_slice = D_SLICENONE; - dev.d_partition = D_PARTNONE; - if (disk_open(&dev, cfi_get_mediasize(), cfi_get_sectorsize()) == 0) { - snprintf(line, sizeof(line), " cfi%d", 0); - ret = disk_print(&dev, line, verbose); - disk_close(&dev); - } - - return (ret); -} diff --git a/stand/mips/beri/loader/beri_disk_sdcard.c b/stand/mips/beri/loader/beri_disk_sdcard.c deleted file mode 100644 index 820b0cea1600..000000000000 --- a/stand/mips/beri/loader/beri_disk_sdcard.c +++ /dev/null @@ -1,147 +0,0 @@ -/*- - * Copyright (c) 2013-2014 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$"); - -#include - -#include -#include - -#include -#include - -#include - -static int beri_sdcard_disk_init(void); -static int beri_sdcard_disk_open(struct open_file *, ...); -static int beri_sdcard_disk_close(struct open_file *); -static int beri_sdcard_disk_strategy(void *, int, daddr_t, size_t, - char *, size_t *); -static int beri_sdcard_disk_print(int); - -struct devsw beri_sdcard_disk = { - .dv_name = "sdcard", - .dv_type = DEVT_DISK, - .dv_init = beri_sdcard_disk_init, - .dv_strategy = beri_sdcard_disk_strategy, - .dv_open = beri_sdcard_disk_open, - .dv_close = beri_sdcard_disk_close, - .dv_ioctl = noioctl, - .dv_print = beri_sdcard_disk_print, - .dv_cleanup = NULL, -}; - -static int -beri_sdcard_disk_init(void) -{ - - return (0); -} - -static int -beri_sdcard_disk_strategy(void *devdata, int flag, daddr_t dblk, size_t size, - char *buf, size_t *rsizep) -{ - int error; - - flag &= F_MASK; - if (flag == F_WRITE) - return (EROFS); - if (flag != F_READ) - return (EINVAL); - if (rsizep != NULL) - *rsizep = 0; - error = altera_sdcard_read(buf, dblk, size >> 9); - if (error == 0 && rsizep != NULL) - *rsizep = size; - else if (error != 0) - printf("%s: error %d\n", __func__, error); - return (error); -} - -static int -beri_sdcard_disk_open(struct open_file *f, ...) -{ - va_list ap; - struct disk_devdesc *dev; - - va_start(ap, f); - dev = va_arg(ap, struct disk_devdesc *); - va_end(ap); - - if (!(altera_sdcard_get_present())) { - printf("SD card not present or not supported\n"); - return (ENXIO); - } - - if (dev->dd.d_unit != 0) - return (EIO); - return (disk_open(dev, altera_sdcard_get_mediasize(), - altera_sdcard_get_sectorsize())); -} - -static int -beri_sdcard_disk_close(struct open_file *f) -{ - struct disk_devdesc *dev; - - dev = (struct disk_devdesc *)f->f_devdata; - return (disk_close(dev)); -} - -static int -beri_sdcard_disk_print(int verbose) -{ - struct disk_devdesc dev; - char line[80]; - int ret; - - printf("%s devices:", beri_sdcard_disk.dv_name); - if ((ret = pager_output("\n")) != 0) - return (ret); - - snprintf(line, sizeof(line), " sdcard%d Altera SD card drive\n", 0); - ret = pager_output(line); - if (ret != 0) - return (ret); - dev.dd.d_dev = &beri_sdcard_disk; - dev.dd.d_unit = 0; - dev.d_slice = D_SLICENONE; - dev.d_partition = D_PARTNONE; - if (disk_open(&dev, altera_sdcard_get_mediasize(), - altera_sdcard_get_sectorsize()) == 0) { - snprintf(line, sizeof(line), " sdcard%d", 0); - ret = disk_print(&dev, line, verbose); - disk_close(&dev); - } - return (ret); -} diff --git a/stand/mips/beri/loader/devicename.c b/stand/mips/beri/loader/devicename.c deleted file mode 100644 index b1f0afd5bc1f..000000000000 --- a/stand/mips/beri/loader/devicename.c +++ /dev/null @@ -1,206 +0,0 @@ -/*- - * 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. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include - -#include "bootstrap.h" -#include "disk.h" - -static int beri_arch_parsedev(struct disk_devdesc **dev, - const char *devspec, const char **path); - -/* - * Point (dev) at an allocated device specifier for the device matching the - * path in (devspec). If it contains an explicit device specification, - * use that. If not, use the default device. - */ -int -beri_arch_getdev(void **vdev, const char *devspec, const char **path) -{ - struct disk_devdesc **dev = (struct disk_devdesc **)vdev; - int rv; - - /* - * If it looks like this is just a path and no - * device, go with the current device. - */ - if ((devspec == NULL) || - (devspec[0] == '/') || - (strchr(devspec, ':') == NULL)) { - - if (((rv = beri_arch_parsedev(dev, getenv("currdev"), NULL)) == 0) && - (path != NULL)) - *path = devspec; - return(rv); - } - - /* - * Try to parse the device name off the beginning of the devspec - */ - return(beri_arch_parsedev(dev, devspec, path)); -} - -/* - * Point (dev) at an allocated device specifier matching the string version - * at the beginning of (devspec). Return a pointer to the remaining - * text in (path). - * - * In all cases, the beginning of (devspec) is compared to the names - * of known devices in the device switch, and then any following text - * is parsed according to the rules applied to the device type. - * - * For disk-type devices, the syntax is: - * - * disk[s][]: - * - */ -static int -beri_arch_parsedev(struct disk_devdesc **dev, const char *devspec, - const char **path) -{ - struct disk_devdesc *idev; - struct devsw *dv; - int i, unit, err; - char *cp; - const char *np; - - /* minimum length check */ - if (strlen(devspec) < 2) - return(EINVAL); - - /* look for a device that matches */ - for (i = 0, dv = NULL; devsw[i] != NULL; i++) { - if (!strncmp(devspec, devsw[i]->dv_name, strlen(devsw[i]->dv_name))) { - dv = devsw[i]; - break; - } - } - if (dv == NULL) - return(ENOENT); - idev = malloc(sizeof(struct disk_devdesc)); - err = 0; - np = (devspec + strlen(dv->dv_name)); - - switch(dv->dv_type) { - case DEVT_NONE: /* XXX what to do here? Do we care? */ - break; - - case DEVT_DISK: - err = disk_parsedev(idev, np, path); - if (err != 0) - goto fail; - break; - - case DEVT_CD: - case DEVT_NET: - case DEVT_ZFS: - unit = 0; - - if (*np && (*np != ':')) { - unit = strtol(np, &cp, 0); /* get unit number if present */ - if (cp == np) { - err = EUNIT; - goto fail; - } - } else { - err = EUNIT; - goto fail; - } - - if (*cp && (*cp != ':')) { - err = EINVAL; - goto fail; - } - - idev->dd.d_unit = unit; - if (path != NULL) - *path = (*cp == 0) ? cp : cp + 1; - break; - - default: - err = EINVAL; - goto fail; - } - idev->dd.d_dev = dv; - if (dev == NULL) { - free(idev); - } else { - *dev = idev; - } - return(0); - - fail: - free(idev); - return(err); -} - - -char * -beri_arch_fmtdev(void *vdev) -{ - struct disk_devdesc *dev = (struct disk_devdesc *)vdev; - static char buf[128]; /* XXX device length constant? */ - - switch(dev->dd.d_dev->dv_type) { - case DEVT_NONE: - strcpy(buf, "(no device)"); - break; - - case DEVT_CD: - sprintf(buf, "%s%d:", dev->dd.d_dev->dv_name, dev->dd.d_unit); - break; - - case DEVT_DISK: - return (disk_fmtdev(vdev)); - - case DEVT_NET: - case DEVT_ZFS: - sprintf(buf, "%s%d:", dev->dd.d_dev->dv_name, dev->dd.d_unit); - break; - } - return(buf); -} - - -/* - * Set currdev to suit the value being supplied in (value) - */ -int -beri_arch_setcurrdev(struct env_var *ev, int flags, const void *value) -{ - struct disk_devdesc *ncurr; - int rv; - - if ((rv = beri_arch_parsedev(&ncurr, value, NULL)) != 0) - return (rv); - free(ncurr); - - return (mount_currdev(ev, flags, value)); -} diff --git a/stand/mips/beri/loader/exec.c b/stand/mips/beri/loader/exec.c deleted file mode 100644 index 5399e8acc359..000000000000 --- a/stand/mips/beri/loader/exec.c +++ /dev/null @@ -1,125 +0,0 @@ -/*- - * Copyright (c) 2013-2014 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$"); - -#include -#include - -#include -#include - -#include -#include -#include -#include - -static int beri_elf64_loadfile(char *, uint64_t, - struct preloaded_file **); -static int beri_elf64_exec(struct preloaded_file *fp); - -struct file_format beri_elf = { - .l_load = beri_elf64_loadfile, - .l_exec = beri_elf64_exec, -}; - -/* - * bootinfo that we will pass onto the kernel; some fields derived from - * *boot2_bootinfop, others filled in by loader. - */ -struct bootinfo bootinfo; - -static int -beri_elf64_loadfile(char *filename, uint64_t dest, - struct preloaded_file **result) -{ - - /* - * Some platforms require invalidation of instruction caches here; we - * don't need that currently. - */ - return (__elfN(loadfile)(filename, dest, result)); -} - -static int -beri_elf64_exec(struct preloaded_file *fp) -{ - void (*entry)(register_t, register_t, register_t, register_t); - struct file_metadata *md; - vm_offset_t mdp; - Elf_Ehdr *ehdr; - int error; - - md = file_findmetadata(fp, MODINFOMD_ELFHDR); - if (md == NULL) { - printf("%s: file_findmetadata failed\n", fp->f_name); - return (EFTYPE); - } - ehdr = (Elf_Ehdr *)md->md_data; - - error = md_load64(fp->f_args, &mdp, NULL); - if (error) { - printf("%s: md_load64 failed\n", fp->f_name); - return (error); - } - - entry = (void *)ehdr->e_entry; - printf("Kernel entry at %p\n", entry); - - dev_cleanup(); /* XXXRW: Required? */ - printf("Kernel args: %s\n", fp->f_args); - - /* - * Configure bootinfo for the loaded kernel. Some values are - * inherited from the bootinfo passed to us by boot2 (e.g., DTB - * pointer); others are local to the loader (e.g., kernel boot flags). - */ - bzero(&bootinfo, sizeof(bootinfo)); - bootinfo.bi_version = BOOTINFO_VERSION; - bootinfo.bi_size = sizeof(bootinfo); - bootinfo.bi_boot2opts = boot2_bootinfo.bi_boot2opts; - /* NB: bi_kernelname used only by boot2. */ - /* NB: bi_nfs_diskless not yet. */ - bootinfo.bi_dtb = boot2_bootinfo.bi_dtb; - bootinfo.bi_memsize = boot2_bootinfo.bi_memsize; - bootinfo.bi_modulep = mdp; - - /* - * XXXRW: For now, pass 'memsize' rather than dtb or bootinfo. This - * is the 'old' ABI spoken by Miniboot and the kernel. To pass in - * boot2opts, modules, etc, we will need to fix this to pass in at - * least bootinfop. - */ - (*entry)(boot2_argc, (register_t)boot2_argv, (register_t)boot2_envv, - (register_t)&bootinfo); - - panic("exec returned"); -} diff --git a/stand/mips/beri/loader/gfx_fb.c b/stand/mips/beri/loader/gfx_fb.c deleted file mode 100644 index 74ff34cf9bd2..000000000000 --- a/stand/mips/beri/loader/gfx_fb.c +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * Copyright 2021 Toomas Soome - * 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$"); - -/* - * mips beri specific gfx stubs. - */ - -#include -#include -#include "bootstrap.h" -#include "gfx_fb.h" - -font_list_t fonts = STAILQ_HEAD_INITIALIZER(fonts); -teken_gfx_t gfx_state = { 0 }; - -void -gfx_fb_setpixel(uint32_t x __unused, uint32_t y __unused) -{ -} - -void -gfx_fb_drawrect(uint32_t x1 __unused, uint32_t y1 __unused, - uint32_t x2 __unused, uint32_t y2 __unused, uint32_t fill __unused) -{ -} - -void -gfx_term_drawrect(uint32_t x1 __unused, uint32_t y1 __unused, - uint32_t x2 __unused, uint32_t y2 __unused) -{ -} - -void -gfx_fb_line(uint32_t x0 __unused, uint32_t y0 __unused, - uint32_t x1 __unused, uint32_t y1 __unused, uint32_t w __unused) -{ -} - -void -gfx_fb_bezier(uint32_t x0 __unused, uint32_t y0 __unused, - uint32_t x1 __unused, uint32_t y1 __unused, uint32_t x2 __unused, - uint32_t y2 __unused, uint32_t w __unused) -{ -} - -int -gfx_fb_putimage(png_t *png __unused, uint32_t ux1 __unused, - uint32_t uy1 __unused, uint32_t ux2 __unused, uint32_t uy2 __unused, - uint32_t flags __unused) -{ - return (1); -} diff --git a/stand/mips/beri/loader/help.mips b/stand/mips/beri/loader/help.mips deleted file mode 100644 index 5873eb0512d2..000000000000 --- a/stand/mips/beri/loader/help.mips +++ /dev/null @@ -1 +0,0 @@ -$FreeBSD$ diff --git a/stand/mips/beri/loader/loader.h b/stand/mips/beri/loader/loader.h deleted file mode 100644 index 3c80a6e4f5c4..000000000000 --- a/stand/mips/beri/loader/loader.h +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * Copyright (c) 2013-2014 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$ - */ - -#ifndef _BOOT_LOADER_H_ -#define _BOOT_LOADER_H_ - -/* beri_console.c */ -extern struct console altera_jtag_uart_console; - -/* beri_disk.c */ -extern struct devsw beri_cfi_disk; -extern struct devsw beri_sdcard_disk; - -/* devicename.c */ -struct env_var; -int beri_arch_setcurrdev(struct env_var *, int, const void *); -char *beri_arch_fmtdev(void *); -int beri_arch_getdev(void **, const char *, const char **); - -/* exec.c */ -extern struct file_format beri_elf; - -/* main.c */ -extern int boot2_argc; -extern char **boot2_argv; -extern char **boot2_envv; -extern struct bootinfo boot2_bootinfo; - -/* metadata.c */ -int md_load64(char *args, vm_offset_t *modulep, vm_offset_t *dtbp); - -#endif /* !_BOOT_LOADER_H_ */ diff --git a/stand/mips/beri/loader/loader.ldscript b/stand/mips/beri/loader/loader.ldscript deleted file mode 100644 index deb4865c28ee..000000000000 --- a/stand/mips/beri/loader/loader.ldscript +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * Copyright (c) 2011-2014 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$ - */ - -INCLUDE ../common/common.ldscript - -/* - * Location where loader will execute. - */ -__loader_base__ = 0x20000; -__loader_base_vaddr__ = __mips64_xkphys_cached__ + __loader_base__; - -/* - * Highest address the loader is allowed to use below the kernel. - */ -__loader_end__ = 0x100000; -__loader_end_vaddr__ = __mips64_xkphys_cached__ + __loader_end__; - -OUTPUT_ARCH(mips) -ENTRY(start) -SECTIONS -{ - /* - * We rely on boot2 having (a) configured a stack, and (b) loaded us - * to an appropriate bit of physical/virtual memory such that no - * self-relocating code is required here. - */ - . = __loader_base_vaddr__; - . += SIZEOF_HEADERS; - - .text ALIGN(0x10): { - start.o(.text*) - *(EXCLUDE_FILE (start.o) .text*) - *(.rodata*) - - __start_set_Xcommand_set = .; - KEEP(*(set_Xcommand_set)) - __stop_set_Xcommand_set = .; - - __start_set_Xficl_compile_set = .; - KEEP(*(set_Xficl_compile_set)) - __stop_set_Xficl_compile_set = .; - } - .data ALIGN(0x10): { *(.data*)} - .bss ALIGN(0x10): { *(.bss*) } - - __heap = ALIGN(0x8); /* 64-bit aligned heap pointer */ - __data_end = .; - __boot_loader_len__ = . - __loader_base_vaddr__; - __bss_start = ADDR(.bss); - __bss_end = ALIGN(__bss_start + SIZEOF(.bss), 0x8); - - __heap_start = .; - __heap_end = __loader_end_vaddr__; - __heap_len = __heap_end - __heap_start; -} diff --git a/stand/mips/beri/loader/main.c b/stand/mips/beri/loader/main.c deleted file mode 100644 index ad0feb413a40..000000000000 --- a/stand/mips/beri/loader/main.c +++ /dev/null @@ -1,245 +0,0 @@ -/*- - * Copyright (c) 2013-2014 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$"); - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#ifdef LOADER_USB_SUPPORT -#include -#endif - -static int __elfN(exec)(struct preloaded_file *); -static void extract_currdev(struct bootinfo *); - -struct devsw *devsw[] = { - &beri_cfi_disk, - &beri_sdcard_disk, -#ifdef LOADER_USB_SUPPORT - &umass_disk, -#endif - NULL -}; - -struct file_format *file_formats[] = { - &beri_elf, - NULL -}; - -struct fs_ops *file_system[] = { -#ifdef LOADER_UFS_SUPPORT - &ufs_fsops, -#endif - NULL -}; - -struct console *consoles[] = { - &altera_jtag_uart_console, - NULL -}; - -extern uint8_t __bss_start, __bss_end; -extern uint8_t __heap_start, __heap_end; - -static int -__elfN(exec)(struct preloaded_file *fp) -{ - - return (EFTYPE); -} - -/* - * Capture arguments from boot2 for later reuse when launching the kernel. - * Note that we choose not to maintain a pointer to boo2_bootinfop after - * initial argument processing: this is because we might load the kernel over - * the spot where boot2 was running, so we can't pass that pointer on to the - * kernel. To be on the safe side, never reference it outside of the body of - * main(), instead preserving a copy. - */ -int boot2_argc; -char **boot2_argv; -char **boot2_envv; - -struct bootinfo boot2_bootinfo; - -int -main(int argc, char *argv[], char *envv[], struct bootinfo *bootinfop) -{ - struct devsw **dp; - - /* NB: Must be sure to bzero() before using any globals. */ - bzero(&__bss_start, &__bss_end - &__bss_start); - - boot2_argc = argc; - boot2_argv = argv; - boot2_envv = envv; - boot2_bootinfo = *bootinfop; /* Copy rather than by reference. */ - - setheap(&__heap_start, &__heap_end); - - /* - * Pick up console settings from boot2; probe console. - */ - if (bootinfop->bi_boot2opts & RB_MULTIPLE) { - if (bootinfop->bi_boot2opts & RB_SERIAL) - setenv("console", "comconsole vidconsole", 1); - else - setenv("console", "vidconsole comconsole", 1); - } else if (bootinfop->bi_boot2opts & RB_SERIAL) - setenv("console", "comconsole", 1); - else if (bootinfop->bi_boot2opts & RB_MUTE) - setenv("console", "nullconsole", 1); - cons_probe(); - setenv("LINES", "24", 1); - - printf("%s(%d, %p, %p, %p (%p))\n", __func__, argc, argv, envv, - bootinfop, (void *)bootinfop->bi_memsize); - - /* - * Initialise devices. - */ - for (dp = devsw; *dp != NULL; dp++) { - if ((*dp)->dv_init != NULL) - (*dp)->dv_init(); - } - extract_currdev(bootinfop); - - printf("\n%s", bootprog_info); -#if 0 - printf("bootpath=\"%s\"\n", bootpath); -#endif - - interact(); - return (0); -} - -static void -extract_currdev(struct bootinfo *bootinfop) -{ - const char *bootdev; - - /* - * Pick up boot device information from boot2. - * - * XXXRW: Someday: device units. - */ - switch(bootinfop->bi_boot_dev_type) { - case BOOTINFO_DEV_TYPE_DRAM: - bootdev = "dram0"; - break; - - case BOOTINFO_DEV_TYPE_CFI: - bootdev = "cfi0"; - break; - - case BOOTINFO_DEV_TYPE_SDCARD: - bootdev = "sdcard0"; - break; - - default: - bootdev = NULL; - } - - if (bootdev != NULL) { - env_setenv("currdev", EV_VOLATILE, bootdev, NULL, env_nounset); - env_setenv("loaddev", EV_VOLATILE, bootdev, env_noset, - env_nounset); - } -} - -void -abort(void) -{ - - printf("error: loader abort\n"); - while (1); - __unreachable(); -} - -void -exit(int code) -{ - - printf("error: loader exit\n"); - while (1); - __unreachable(); -} - -void -longjmperror(void) -{ - - printf("error: loader longjmp error\n"); - while (1); - __unreachable(); -} - -time_t -time(time_t *tloc) -{ - - /* We can't provide time since UTC, so just provide time since boot. */ - return (cp0_count_get() / 100000000); -} - -/* - * Delay - in usecs - * - * NOTE: We are assuming that the CPU is running at 100MHz. - */ -void -delay(int usecs) -{ - uint32_t delta; - uint32_t curr; - uint32_t last; - - last = cp0_count_get(); - while (usecs > 0) { - curr = cp0_count_get(); - delta = curr - last; - while (usecs > 0 && delta >= 100) { - usecs--; - last += 100; - delta -= 100; - } - } -} diff --git a/stand/mips/beri/loader/start.S b/stand/mips/beri/loader/start.S deleted file mode 100644 index d679caaa9894..000000000000 --- a/stand/mips/beri/loader/start.S +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * Copyright (c) 2013 Robert N. M. Watson - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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$"); - -.set mips64 -.set noreorder -.set nobopt -.set noat - -ASM_ENTRY(__start) -VECTOR(_loader_start, unknown) - /* Not much here yet. */ - jal main - nop - - /* If main() returns, spin. */ -loop: - b loop - nop -VECTOR_END(_loader_start) diff --git a/stand/mips/beri/loader/version b/stand/mips/beri/loader/version deleted file mode 100644 index ce8e1875844c..000000000000 --- a/stand/mips/beri/loader/version +++ /dev/null @@ -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. - -0.1: Initial MIPS version diff --git a/stand/mips/uboot/Makefile b/stand/mips/uboot/Makefile deleted file mode 100644 index 984582027de5..000000000000 --- a/stand/mips/uboot/Makefile +++ /dev/null @@ -1,64 +0,0 @@ -# $FreeBSD$ - -LOADER_CD9660_SUPPORT?= no -LOADER_EXT2FS_SUPPORT?= no -LOADER_MSDOS_SUPPORT?= yes -LOADER_UFS_SUPPORT?= yes -LOADER_NET_SUPPORT?= yes -LOADER_NFS_SUPPORT?= yes -LOADER_TFTP_SUPPORT?= no -LOADER_GZIP_SUPPORT?= no -LOADER_BZIP2_SUPPORT?= no - -.include - -FILES+= ubldr - -NEWVERSWHAT= "U-Boot loader" ${MACHINE_ARCH} -INSTALLFLAGS= -b -WARNS?= 1 -# Address at which ubldr will be loaded. -# This varies for different boards and SOCs. -.if ${MACHINE_ARCH:Mmips64*} -UBLDR_LOADADDR?= 0xffffffff80800000 -.else -UBLDR_LOADADDR?= 0x80800000 -.endif - -# Architecture-specific loader code -SRCS= start.S conf.c vers.c - -HELP_FILES= ${.CURDIR}/help.uboot ${BOOTSRC}/fdt/help.fdt - -# Always add MI sources -.include "${BOOTSRC}/loader.mk" - -CFLAGS+= -g - -LDFLAGS= -nostdlib -static -T ${.CURDIR}/ldscript.${MACHINE_CPUARCH} - -.include "${BOOTSRC}/uboot.mk" - -DPADD= ${LDR_INTERP} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} ${LIBSA} -LDADD= ${LDR_INTERP} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} ${LIBSA} - -OBJS+= ${SRCS:N*.h:R:S/$/.o/g} - -# ubldr on MIPS is built with '-mno-abicalls' flag, -# which is incompatible with PIE -MK_PIE= no - -ldscript.abs: - echo "UBLDR_LOADADDR = ${UBLDR_LOADADDR};" >${.TARGET} - -ldscript.pie: - echo "UBLDR_LOADADDR = 0;" >${.TARGET} - -ubldr: ${OBJS} ldscript.abs ${.CURDIR}/ldscript.${MACHINE_CPUARCH} ${DPADD} - ${CC} ${CFLAGS} -T ldscript.abs ${LDFLAGS} \ - -o ${.TARGET} ${OBJS} ${LDADD} - ${OBJCOPY} -S -O binary ubldr ubldr.bin - -CLEANFILES+= ldscript.abs ldscript.pie ubldr ubldr.pie ubldr.bin - -.include diff --git a/stand/mips/uboot/conf.c b/stand/mips/uboot/conf.c deleted file mode 100644 index 922f7680b616..000000000000 --- a/stand/mips/uboot/conf.c +++ /dev/null @@ -1,117 +0,0 @@ -/*- - * Copyright (c) 2008 Semihalf, Rafal Jaworowski - * 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$"); - -#include -#include "bootstrap.h" -#include "libuboot.h" - -#if defined(LOADER_NET_SUPPORT) -#include "dev_net.h" -#endif - -/* Make sure we have an explicit reference to exit so libsa's panic pulls in the MD exit */ -void (*exitfn)(int) = exit; - -struct devsw *devsw[] = { -#if defined(LOADER_DISK_SUPPORT) || defined(LOADER_CD9660_SUPPORT) - &uboot_storage, -#endif -#if defined(LOADER_NET_SUPPORT) - &netdev, -#endif - NULL -}; - -struct fs_ops *file_system[] = { -#if defined(LOADER_MSDOS_SUPPORT) - &dosfs_fsops, -#endif -#if defined(LOADER_UFS_SUPPORT) - &ufs_fsops, -#endif -#if defined(LOADER_CD9660_SUPPORT) - &cd9660_fsops, -#endif -#if defined(LOADER_EXT2FS_SUPPORT) - &ext2fs_fsops, -#endif -#if defined(LOADER_NFS_SUPPORT) - &nfs_fsops, -#endif -#if defined(LOADER_TFTP_SUPPORT) - &tftp_fsops, -#endif -#if defined(LOADER_GZIP_SUPPORT) - &gzipfs_fsops, -#endif -#if defined(LOADER_BZIP2_SUPPORT) - &bzipfs_fsops, -#endif - NULL -}; - -struct netif_driver *netif_drivers[] = { -#if defined(LOADER_NET_SUPPORT) - &uboot_net, -#endif - NULL, -}; - -struct file_format *file_formats[] = { - &uboot_elf, - NULL -}; - -extern struct console uboot_console; - -struct console *consoles[] = { - &uboot_console, - NULL -}; - -void -abort(void) -{ - - printf("error: loader abort\n"); - while (1); - __unreachable(); -} - -void -longjmperror(void) -{ - - printf("error: loader longjmp error\n"); - while (1); - __unreachable(); -} - -int debug = 1; diff --git a/stand/mips/uboot/help.uboot b/stand/mips/uboot/help.uboot deleted file mode 100644 index c1574af92715..000000000000 --- a/stand/mips/uboot/help.uboot +++ /dev/null @@ -1,27 +0,0 @@ -$FreeBSD$ - -############################################################################### -# Tubenv DShow or import U-Boot environment variables - - ubenv [varname ...] - - Display U-Boot environment variables, or import them into the - loader environment (which makes them available in the kernel). - -############################################################################### -# Tubenv Simport DImport U-Boot env vars - - ubenv import [varname ...] - - If no variable names are specified, all U-Boot environment - variables are imported. Each variable is prefixed with "uboot." - to avoid any possible conflicts with loader or kernel variables. - -############################################################################### -# Tubenv Sshow DShow U-Boot env vars - - ubenv show [varname ...] - - If no variable names are specified, all U-Boot environment - variables are shown. - diff --git a/stand/mips/uboot/ldscript.mips b/stand/mips/uboot/ldscript.mips deleted file mode 100644 index 815dabc74587..000000000000 --- a/stand/mips/uboot/ldscript.mips +++ /dev/null @@ -1,134 +0,0 @@ -/* $FreeBSD$ */ - -OUTPUT_ARCH(mips) -ENTRY(_start) -SECTIONS -{ - /* Read-only sections, merged into text segment: */ - /*. = UBLDR_LOADADDR + SIZEOF_HEADERS;*/ - . = UBLDR_LOADADDR; - .text : - { - start.o(.text*) - *(EXCLUDE_FILE (start.o) .text*) - /* .gnu.warning sections are handled specially by elf32.em. */ - *(.gnu.warning) - *(.gnu.linkonce.t*) - } =0 - _etext = .; - PROVIDE (etext = .); - .interp : { *(.interp) } - .hash : { *(.hash) } - .dynsym : { *(.dynsym) } - .dynstr : { *(.dynstr) } - .gnu.version : { *(.gnu.version) } - .gnu.version_d : { *(.gnu.version_d) } - .gnu.version_r : { *(.gnu.version_r) } - .rela.text : - { *(.rela.text) *(.rela.gnu.linkonce.t*) } - .rela.data : - { *(.rela.data) *(.rela.gnu.linkonce.d*) } - .rela.rodata : - { *(.rela.rodata) *(.rela.gnu.linkonce.r*) } - .rela.got : { *(.rela.got) } - .rela.got1 : { *(.rela.got1) } - .rela.got2 : { *(.rela.got2) } - .rela.ctors : { *(.rela.ctors) } - .rela.dtors : { *(.rela.dtors) } - .rela.init : { *(.rela.init) } - .rela.fini : { *(.rela.fini) } - .rela.bss : { *(.rela.bss) } - .rela.plt : { *(.rela.plt) } - .rela.sdata : { *(.rela.sdata) } - .rela.sbss : { *(.rela.sbss) } - .rela.sdata2 : { *(.rela.sdata2) } - .rela.sbss2 : { *(.rela.sbss2) } - .init : { *(.init) } =0 - .fini : { *(.fini) } =0 - .rodata : { *(.rodata) *(.gnu.linkonce.r*) } - .rodata1 : { *(.rodata1) } - .sdata2 : { *(.sdata2) } - .sbss2 : { *(.sbss2) } - /* Adjust the address for the data segment to the next page up. */ - . = ((. + 0x1000) & ~(0x1000 - 1)); - .data : - { - *(.data) - *(.gnu.linkonce.d*) - } - .data1 : { *(.data1) } - .got1 : { *(.got1) } - .dynamic : { *(.dynamic) } - /* Put .ctors and .dtors next to the .got2 section, so that the pointers - get relocated with -mrelocatable. Also put in the .fixup pointers. - The current compiler no longer needs this, but keep it around for 2.7.2 */ - PROVIDE (_GOT2_START_ = .); - .got2 : { *(.got2) } - PROVIDE (__CTOR_LIST__ = .); - .ctors : { *(.ctors) } - PROVIDE (__CTOR_END__ = .); - PROVIDE (__DTOR_LIST__ = .); - .dtors : { *(.dtors) } - PROVIDE (__DTOR_END__ = .); - PROVIDE (_FIXUP_START_ = .); - .fixup : { *(.fixup) } - PROVIDE (_FIXUP_END_ = .); - PROVIDE (_GOT2_END_ = .); - PROVIDE (_GOT_START_ = .); - .got : { *(.got) } - .got.plt : { *(.got.plt) } - PROVIDE (_GOT_END_ = .); - /* We want the small data sections together, so single-instruction offsets - can access them all, and initialized data all before uninitialized, so - we can shorten the on-disk segment size. */ - .sdata : { *(.sdata) } - _edata = .; - PROVIDE (edata = .); - .sbss : - { - PROVIDE (__sbss_start = .); - *(.sbss) - *(.scommon) - *(.dynsbss) - PROVIDE (__sbss_end = .); - } - .plt : { *(.plt) } - .bss : - { - PROVIDE (__bss_start = .); - *(.dynbss) - *(.bss) - *(COMMON) - } - _end = . ; - PROVIDE (end = .); - /* Stabs debugging sections. */ - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - /* DWARF debug sections. - Symbols in the DWARF debugging sections are relative to the beginning - of the section so we begin them at 0. */ - /* DWARF 1 */ - .debug 0 : { *(.debug) } - .line 0 : { *(.line) } - /* GNU DWARF 1 extensions */ - .debug_srcinfo 0 : { *(.debug_srcinfo) } - .debug_sfnames 0 : { *(.debug_sfnames) } - /* DWARF 1.1 and DWARF 2 */ - .debug_aranges 0 : { *(.debug_aranges) } - .debug_pubnames 0 : { *(.debug_pubnames) } - /* DWARF 2 */ - .debug_info 0 : { *(.debug_info) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_line 0 : { *(.debug_line) } - .debug_frame 0 : { *(.debug_frame) } - .debug_str 0 : { *(.debug_str) } - .debug_loc 0 : { *(.debug_loc) } - .debug_macinfo 0 : { *(.debug_macinfo) } - /* SGI/MIPS DWARF 2 extensions */ - .debug_weaknames 0 : { *(.debug_weaknames) } - .debug_funcnames 0 : { *(.debug_funcnames) } - .debug_typenames 0 : { *(.debug_typenames) } - .debug_varnames 0 : { *(.debug_varnames) } - /* These must appear regardless of . */ -} diff --git a/stand/mips/uboot/start.S b/stand/mips/uboot/start.S deleted file mode 100644 index 2ca68b2ef1f9..000000000000 --- a/stand/mips/uboot/start.S +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * Copyright (c) 2016 Stanislav Galabov - * 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$ - */ - -#include - - .text - .extern _C_LABEL(main) - .weak _DYNAMIC - -/* - * Entry point to the loader that U-Boot passes control to. - */ -ENTRY(_start) - PTR_S sp, uboot_address - j main - nop -END(_start) - -/* - * syscall() - */ -ENTRY(syscall) - PTR_S ra, ret_address - PTR_L t9, syscall_ptr - jalr t9 - nop - PTR_L ra, ret_address - jr ra - nop -END(syscall) - -/* - * Data section - */ - .data - .align 8 - .globl syscall_ptr -syscall_ptr: - .dword 0 - - .globl uboot_address -uboot_address: - .dword 0 - -ret_address: - .dword 0 diff --git a/stand/mips/uboot/version b/stand/mips/uboot/version deleted file mode 100644 index ec46b388b281..000000000000 --- a/stand/mips/uboot/version +++ /dev/null @@ -1,10 +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.3: Remove NAND FS support. -1.2: Extended with NAND FS support. -1.1: Flattened Device Tree blob support. -1.0: Added storage support. Booting from HDD, USB, etc. is now possible. -0.5: Initial U-Boot/arm version (netbooting only). diff --git a/stand/uboot/lib/elf_freebsd.c b/stand/uboot/lib/elf_freebsd.c index a11f0acb4593..802d6e96dee6 100644 --- a/stand/uboot/lib/elf_freebsd.c +++ b/stand/uboot/lib/elf_freebsd.c @@ -1,100 +1,96 @@ /*- * Copyright (c) 2001 Benno Rice * Copyright (c) 2007 Semihalf, Rafal Jaworowski * 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$"); #include #include -#ifdef __mips__ -#include -#include -#endif #include #include #include #include #include "bootstrap.h" #include "libuboot.h" extern vm_offset_t md_load(char *, vm_offset_t *, vm_offset_t *); int __elfN(uboot_load)(char *filename, uint64_t dest, struct preloaded_file **result) { int r; r = __elfN(loadfile)(filename, dest, result); if (r != 0) return (r); #if defined(__powerpc__) /* * No need to sync the icache for modules: this will * be done by the kernel after relocation. */ if (!strcmp((*result)->f_type, "elf kernel")) __syncicache((void *) (*result)->f_addr, (*result)->f_size); #endif return (0); } int __elfN(uboot_exec)(struct preloaded_file *fp) { struct file_metadata *fmp; vm_offset_t mdp; Elf_Ehdr *e; int error; void (*entry)(void *); if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) return (EFTYPE); e = (Elf_Ehdr *)&fmp->md_data; if ((error = md_load(fp->f_args, &mdp, NULL)) != 0) return (error); entry = (void *)e->e_entry; printf("Kernel entry at %p...\n", entry); dev_cleanup(); printf("Kernel args: %s\n", fp->f_args); (*entry)((void *)mdp); panic("exec returned"); } struct file_format uboot_elf = { __elfN(uboot_load), __elfN(uboot_exec) }; diff --git a/stand/uboot/lib/glue.h b/stand/uboot/lib/glue.h index c9fe4021003f..9399549fcc68 100644 --- a/stand/uboot/lib/glue.h +++ b/stand/uboot/lib/glue.h @@ -1,107 +1,98 @@ /*- * Copyright (c) 2008 Semihalf, Rafal Jaworowski * 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$ */ /* * This is the header file for conveniency wrapper routines (API glue) */ #ifndef _API_GLUE_H_ #define _API_GLUE_H_ #include "api_public.h" /* * Mask used to align the start address for API signature search to 1MiB */ #define API_SIG_SEARCH_MASK ~0x000fffff -#ifdef __mips__ -/* - * On MIPS, U-Boot passes us a hint address, which is very close to the end of - * RAM (less than 1MiB), so searching for the API signature within more than - * that leads to exception. - */ -#define API_SIG_SEARCH_LEN 0x00100000 -#else /* * Search for the API signature within 3MiB of the 1MiB-aligned address that * U-Boot has hinted us. */ #define API_SIG_SEARCH_LEN 0x00300000 -#endif int syscall(int, int *, ...); extern void *syscall_ptr; int api_parse_cmdline_sig(int argc, char **argv, struct api_signature **sig); int api_search_sig(struct api_signature **sig); #define UB_MAX_MR 16 /* max mem regions number */ #define UB_MAX_DEV 6 /* max devices number */ /* * The ub_ library calls are part of the application, not U-Boot code! They * are front-end wrappers that are used by the consumer application: they * prepare arguments for particular syscall and jump to the low level * syscall() */ /* console */ int ub_getc(void); int ub_tstc(void); void ub_putc(char); void ub_puts(const char *); /* system */ void ub_reset(void) __dead2; struct sys_info *ub_get_sys_info(void); /* time */ void ub_udelay(unsigned long); unsigned long ub_get_timer(unsigned long); /* env vars */ char *ub_env_get(const char *); void ub_env_set(const char *, char *); const char *ub_env_enum(const char *); /* devices */ int ub_dev_enum(void); int ub_dev_open(int); int ub_dev_close(int); int ub_dev_read(int, void *, lbasize_t, lbastart_t, lbasize_t *); int ub_dev_send(int, void *, int); int ub_dev_recv(int, void *, int, int *); struct device_info *ub_dev_get(int); void ub_dump_di(int); void ub_dump_si(struct sys_info *); char *ub_mem_type(int); char *ub_stor_type(int); #endif /* _API_GLUE_H_ */ diff --git a/stand/usb/Makefile b/stand/usb/Makefile index ab14a6d002a3..63e60155314b 100644 --- a/stand/usb/Makefile +++ b/stand/usb/Makefile @@ -1,53 +1,49 @@ # # $FreeBSD$ # # Copyright (c) 2013 Hans Petter Selasky. # Copyright (c) 2014 SRI International # All rights reserved. # # This software was developed by SRI International and the University of # Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237 # ("CTSRD"), as part of the DARPA CRASH research programme. # # 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. # LIB= usbboot INTERNALLIB= CFLAGS+= -DBOOTPROG=\"usbloader\" CFLAGS+= -ffunction-sections -fdata-sections CFLAGS+= -Wformat -Wall CFLAGS+= -g CFLAGS+= -fno-pic .if ${MACHINE_CPUARCH} == "amd64" CFLAGS+= -m32 .endif -.if ${MACHINE_CPUARCH} == "mips" -CFLAGS+= -mno-abicalls -.endif - .include "usbcore.mk" .include "../kshim/kshim.mk" .include