diff options
Diffstat (limited to 'stand')
124 files changed, 546 insertions, 4444 deletions
diff --git a/stand/Makefile.amd64 b/stand/Makefile.amd64 index abecaa6..6e8c967 100644 --- a/stand/Makefile.amd64 +++ b/stand/Makefile.amd64 @@ -11,7 +11,7 @@ SUBDIR+= ficl32 SUBDIR+= efi SUBDIR+= userboot -.if ${LOADER_GELI_SUPPORT:Uyes} == "yes" +.if ${MK_LOADER_GELI} == "yes" SUBDIR+= geli .endif diff --git a/stand/Makefile.i386 b/stand/Makefile.i386 index fb53744..9664974 100644 --- a/stand/Makefile.i386 +++ b/stand/Makefile.i386 @@ -1,6 +1,6 @@ # $FreeBSD$ -.if ${LOADER_GELI_SUPPORT:Uyes} == "yes" +.if ${MK_LOADER_GELI} == "yes" SUBDIR+= geli .endif .if ${MK_ZFS} != "no" diff --git a/stand/Makefile.inc b/stand/Makefile.inc index 610acfa..d7b9d22 100644 --- a/stand/Makefile.inc +++ b/stand/Makefile.inc @@ -1,53 +1,3 @@ # $FreeBSD$ .include "defs.mk" - -.if !defined(__BOOT_MAKEFILE_INC__) -__BOOT_MAKEFILE_INC__=${MFILE} - -CFLAGS+=-I${SASRC} - -SSP_CFLAGS= - -# 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. riscv -# currently has no /boot/loader, but may soon. -CFLAGS+= -ffreestanding ${CFLAGS_NO_SIMD} -.if ${MACHINE_CPUARCH} == "aarch64" -CFLAGS+= -mgeneral-regs-only -.elif ${MACHINE_CPUARCH} != "riscv" -CFLAGS+= -msoft-float -.endif - -.if ${MACHINE_CPUARCH} == "i386" || (${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 1) -CFLAGS+= -march=i386 -CFLAGS.gcc+= -mpreferred-stack-boundary=2 -.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. -.if ${COMPILER_VERSION} < 30800 -CFLAGS.clang+= -mllvm -arm-use-movt=0 -.else -CFLAGS.clang+= -mno-movt -.endif -CFLAGS.clang+= -mfpu=none -.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 ${MK_LOADER_FORCE_LE} != "no" -.if ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -mlittle-endian -.endif -.endif - -.endif diff --git a/stand/arm/uboot/Makefile b/stand/arm/uboot/Makefile index 2070d8a..8c4023a 100644 --- a/stand/arm/uboot/Makefile +++ b/stand/arm/uboot/Makefile @@ -28,7 +28,7 @@ SRCS= start.S conf.c self_reloc.c vers.c CWARNFLAGS.self_reloc.c+= -Wno-error=maybe-uninitialized .endif -HELP_FILES+= help.uboot ${BOOTSRC}/fdt/help.fdt +HELP_FILES= ${.CURDIR}/help.uboot ${BOOTSRC}/fdt/help.fdt # Always add MI sources .include "${BOOTSRC}/loader.mk" diff --git a/stand/common/bootstrap.h b/stand/common/bootstrap.h index 2234e05..a570720 100644 --- a/stand/common/bootstrap.h +++ b/stand/common/bootstrap.h @@ -45,17 +45,17 @@ extern char command_errbuf[COMMAND_ERRBUFSZ]; #define CMD_FATAL 4 /* interp.c */ -void interact(const char *rc); +void interact(void); int include(const char *filename); /* interp_backslash.c */ -char *backslash(char *str); +char *backslash(const char *str); /* interp_parse.c */ -int parse(int *argc, char ***argv, char *str); +int parse(int *argc, char ***argv, const char *str); /* interp_forth.c */ -void bf_init(const char *rc); +void bf_init(void); int bf_run(char *line); /* boot.c */ diff --git a/stand/common/dev_net.c b/stand/common/dev_net.c index c5b1e0a..d461f74 100644 --- a/stand/common/dev_net.c +++ b/stand/common/dev_net.c @@ -382,7 +382,7 @@ net_print(int verbose) * It leaves just the pathname in the global rootpath. */ uint32_t -net_parse_rootpath() +net_parse_rootpath(void) { n_long addr = htonl(INADDR_NONE); size_t i; diff --git a/stand/common/interp.c b/stand/common/interp.c index f4117b9..6b1b8bb 100644 --- a/stand/common/interp.c +++ b/stand/common/interp.c @@ -39,11 +39,7 @@ __FBSDID("$FreeBSD$"); #ifdef BOOT_FORTH #include "ficl.h" -#define RETURN(x) stackPushINT(bf_vm->pStack,!x); return(x) - extern FICL_VM *bf_vm; -#else -#define RETURN(x) return(x) #endif #define MAXARGS 20 /* maximum number of arguments allowed */ @@ -51,12 +47,10 @@ extern FICL_VM *bf_vm; static void prompt(void); #ifndef BOOT_FORTH -static int perform(int argc, char *argv[]); - /* * Perform the command */ -int +static int perform(int argc, char *argv[]) { int result; @@ -82,7 +76,7 @@ perform(int argc, char *argv[]) } else { command_errmsg = "unknown command"; } - RETURN(result); + return(result); } #endif /* ! BOOT_FORTH */ @@ -90,7 +84,7 @@ perform(int argc, char *argv[]) * Interactive mode */ void -interact(const char *rc) +interact(void) { static char input[256]; /* big enough? */ #ifndef BOOT_FORTH @@ -99,14 +93,11 @@ interact(const char *rc) #endif #ifdef BOOT_FORTH - bf_init((rc) ? "" : NULL); + bf_init(); #endif - if (rc == NULL) { - /* Read our default configuration. */ - include("/boot/loader.rc"); - } else if (*rc != '\0') - include(rc); + /* Read our default configuration. */ + include("/boot/loader.rc"); printf("\n"); diff --git a/stand/common/interp_backslash.c b/stand/common/interp_backslash.c index 09b8f57..30874bd 100644 --- a/stand/common/interp_backslash.c +++ b/stand/common/interp_backslash.c @@ -28,7 +28,7 @@ __FBSDID("$FreeBSD$"); * processing" done on it. Original can be free'd if desired. */ char * -backslash(char *str) +backslash(const char *str) { /* * Remove backslashes from the strings. Turn \040 etc. into a single diff --git a/stand/common/interp_forth.c b/stand/common/interp_forth.c index a3b7776..d617ce8 100644 --- a/stand/common/interp_forth.c +++ b/stand/common/interp_forth.c @@ -250,7 +250,7 @@ bf_command(FICL_VM *vm) * Initialise the Forth interpreter, create all our commands as words. */ void -bf_init(const char *rc) +bf_init(void) { struct bootblk_command **cmdp; char create_buf[41]; /* 31 characters-long builtins */ @@ -280,14 +280,9 @@ bf_init(const char *rc) ficlSetEnv(bf_sys, "loader_version", bootprog_rev); /* try to load and run init file if present */ - if (rc == NULL) - rc = "/boot/boot.4th"; - if (*rc != '\0') { - fd = open(rc, O_RDONLY); - if (fd != -1) { - (void)ficlExecFD(bf_vm, fd); - close(fd); - } + if ((fd = open("/boot/boot.4th", O_RDONLY)) != -1) { + (void)ficlExecFD(bf_vm, fd); + close(fd); } } diff --git a/stand/common/interp_parse.c b/stand/common/interp_parse.c index 8d8a2e2..670273e 100644 --- a/stand/common/interp_parse.c +++ b/stand/common/interp_parse.c @@ -7,7 +7,7 @@ * 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. - * + * * Jordan K. Hubbard * 29 August 1998 * @@ -82,7 +82,7 @@ isdquote(int ch) } int -parse(int *argc, char ***argv, char *str) +parse(int *argc, char ***argv, const char *str) { int ac; char *val, *p, *q, *copy = NULL; diff --git a/stand/common/load_elf.c b/stand/common/load_elf.c index 679842b..4c1277b 100644 --- a/stand/common/load_elf.c +++ b/stand/common/load_elf.c @@ -37,7 +37,7 @@ __FBSDID("$FreeBSD$"); #include <machine/elf.h> #include <stand.h> #define FREEBSD_ELF -#include <link.h> +#include <sys/link_elf.h> #include "bootstrap.h" @@ -456,7 +456,7 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_t ef, u_int64_t off) * think the rule is going to have to be that you must strip a * file to remove symbols before gzipping it. */ - chunk = ehdr->e_shnum * ehdr->e_shentsize; + chunk = (size_t)ehdr->e_shnum * (size_t)ehdr->e_shentsize; if (chunk == 0 || ehdr->e_shoff == 0) goto nosyms; shdr = alloc_pread(ef->fd, ehdr->e_shoff, chunk); @@ -747,7 +747,7 @@ __elfN(load_modmetadata)(struct preloaded_file *fp, u_int64_t dest) goto out; } - size = ef.ehdr->e_shnum * ef.ehdr->e_shentsize; + size = (size_t)ef.ehdr->e_shnum * (size_t)ef.ehdr->e_shentsize; shdr = alloc_pread(ef.fd, ef.ehdr->e_shoff, size); if (shdr == NULL) { err = ENOMEM; diff --git a/stand/common/load_elf_obj.c b/stand/common/load_elf_obj.c index a32b9fd..57df57a 100644 --- a/stand/common/load_elf_obj.c +++ b/stand/common/load_elf_obj.c @@ -33,12 +33,12 @@ __FBSDID("$FreeBSD$"); #include <sys/exec.h> #include <sys/linker.h> #include <sys/module.h> -#include <inttypes.h> +#include <stdint.h> #include <string.h> #include <machine/elf.h> #include <stand.h> #define FREEBSD_ELF -#include <link.h> +#include <sys/link_elf.h> #include "bootstrap.h" diff --git a/stand/common/reloc_elf.c b/stand/common/reloc_elf.c index aa3b0f7..ce44b27 100644 --- a/stand/common/reloc_elf.c +++ b/stand/common/reloc_elf.c @@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$"); #include <stand.h> #define FREEBSD_ELF -#include <link.h> +#include <sys/link_elf.h> #include "bootstrap.h" diff --git a/stand/defs.mk b/stand/defs.mk index 20e9a77..79e5269 100644 --- a/stand/defs.mk +++ b/stand/defs.mk @@ -2,6 +2,8 @@ .include <src.opts.mk> +WARNS?=1 + .if !defined(__BOOT_DEFS_MK__) __BOOT_DEFS_MK__=${MFILE} @@ -22,15 +24,6 @@ BOOTOBJ= ${OBJTOP}/stand # BINDIR is where we install BINDIR?= /boot -# NB: The makefiles depend on these being empty when we don't build forth. -.if ${MK_FORTH} != "no" -LIBFICL= ${BOOTOBJ}/ficl/libficl.a -.if ${MACHINE} == "i386" -LIBFICL32= ${LIBFICL} -.else -LIBFICL32= ${BOOTOBJ}/ficl32/libficl.a -.endif -.endif LIBSA= ${BOOTOBJ}/libsa/libsa.a .if ${MACHINE} == "i386" LIBSA32= ${LIBSA} @@ -39,54 +32,16 @@ LIBSA32= ${BOOTOBJ}/libsa32/libsa32.a .endif # Standard options: - -# 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_NANDFS_SUPPORT:U${MK_NAND}} == "yes" -CFLAGS+= -DLOADER_NANDFS_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 - -# Disk and partition support -.if ${LOADER_DISK_SUPPORT:Uyes} == "yes" -CFLAGS+= -DLOADER_DISK_SUPPORT -.if ${LOADER_GPT_SUPPORT:Uyes} == "yes" -CFLAGS+= -DLOADER_GPT_SUPPORT -.endif -.if ${LOADER_MBR_SUPPORT:Uyes} == "yes" -CFLAGS+= -DLOADER_MBR_SUPPORT +CFLAGS+= -nostdinc +.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} -# GELI Support, with backward compat hooks +# GELI Support, with backward compat hooks (mostly) .if defined(HAVE_GELI) .if defined(LOADER_NO_GELI_SUPPORT) MK_LOADER_GELI=no @@ -100,11 +55,17 @@ MK_LOADER_GELI=yes CFLAGS+= -DLOADER_GELI_SUPPORT CFLAGS+= -I${BOOTSRC}/geli LIBGELIBOOT= ${BOOTOBJ}/geli/libgeliboot.a -.endif -.endif +.endif # MK_LOADER_GELI +.endif # HAVE_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 -CFLAGS+= -I${SYSDIR} +# Machine specific flags for all builds here # All PowerPC builds are 32 bit. We have no 64-bit loaders on powerpc # or powerpc64. @@ -122,6 +83,49 @@ LD_FLAGS+= -m elf_i386_fbsd AFLAGS+= --32 .endif +SSP_CFLAGS= + +# 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. riscv +# currently has no /boot/loader, but may soon. +CFLAGS+= -ffreestanding ${CFLAGS_NO_SIMD} +.if ${MACHINE_CPUARCH} == "aarch64" +CFLAGS+= -mgeneral-regs-only +.elif ${MACHINE_CPUARCH} != "riscv" +CFLAGS+= -msoft-float +.endif + +.if ${MACHINE_CPUARCH} == "i386" || (${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 1) +CFLAGS+= -march=i386 +CFLAGS.gcc+= -mpreferred-stack-boundary=2 +.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. +.if ${COMPILER_VERSION} < 30800 +CFLAGS.clang+= -mllvm -arm-use-movt=0 +.else +CFLAGS.clang+= -mno-movt +.endif +CFLAGS.clang+= -mfpu=none +.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 ${MK_LOADER_FORCE_LE} != "no" +.if ${MACHINE_ARCH} == "powerpc64" +CFLAGS+= -mlittle-endian +.endif +.endif + # Make sure we use the machine link we're about to create CFLAGS+=-I. @@ -164,8 +168,4 @@ ${_ILINKS}: ${ECHO} ${.TARGET:T} "->" $$path ; \ ln -fhs $$path ${.TARGET:T} -# For loader implementations, we generate a loader.help file. This can be suppressed by -# setting HELP_FILES to nothing. -HELP_FILES= ${LDRSRC}/help.common - .endif # __BOOT_DEFS_MK__ diff --git a/stand/efi/boot1/Makefile b/stand/efi/boot1/Makefile index f2e6946..7791b78 100644 --- a/stand/efi/boot1/Makefile +++ b/stand/efi/boot1/Makefile @@ -31,8 +31,9 @@ CWARNFLAGS.zfs_module.c += -Wno-unused-function SRCS= boot1.c self_reloc.c start.S ufs_module.c .if ${MK_ZFS} != "no" SRCS+= zfs_module.c -CFLAGS+= -I${ZFSSRC} -CFLAGS+= -I${SYSDIR}/cddl/boot/zfs +CFLAGS.zfs_module.c+= -I${ZFSSRC} +CFLAGS.zfs_module.c+= -I${SYSDIR}/cddl/boot/zfs +CFLAGS.zfs_module.c+= -I${SYSDIR}/crypto/skein CFLAGS+= -DEFI_ZFS_BOOT LIBZFSBOOT= ${BOOTOBJ}/zfs/libzfsboot.a .endif @@ -106,8 +107,6 @@ boot1.efi: ${PROG} -j .rela.dyn -j .reloc -j .eh_frame \ --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} -boot1.o: ${SASRC}/ufsread.c - # The following inserts our objects into a template FAT file system # created by generate-fat.sh diff --git a/stand/efi/boot1/boot1.c b/stand/efi/boot1/boot1.c index b7cb57f..7b51f03 100644 --- a/stand/efi/boot1/boot1.c +++ b/stand/efi/boot1/boot1.c @@ -29,7 +29,6 @@ __FBSDID("$FreeBSD$"); #include <efi.h> #include <eficonsctl.h> -typedef CHAR16 efi_char; #include <efichar.h> #include "boot_module.h" diff --git a/stand/efi/include/efichar.h b/stand/efi/include/efichar.h index 2fa4ed4..49ff43b 100644 --- a/stand/efi/include/efichar.h +++ b/stand/efi/include/efichar.h @@ -29,6 +29,12 @@ #ifndef _BOOT_EFI_EFICHAR_H_ #define _BOOT_EFI_EFICHAR_H_ +#ifdef _STANDALONE +#include <efi.h> + +typedef CHAR16 efi_char; +#endif + int ucs2_to_utf8(const efi_char *, char **); int utf8_to_ucs2(const char *, efi_char **, size_t *); int ucs2len(const efi_char *); diff --git a/stand/efi/libefi/Makefile b/stand/efi/libefi/Makefile index e0ffd7b..f5cf71e 100644 --- a/stand/efi/libefi/Makefile +++ b/stand/efi/libefi/Makefile @@ -52,6 +52,4 @@ CFLAGS+= ${FORMAT_EXTENSIONS} CFLAGS+= -DTERM_EMU .endif -CFLAGS+= -DLIBEFI - .include <bsd.lib.mk> diff --git a/stand/efi/libefi/efichar.c b/stand/efi/libefi/efichar.c index dad4e96..15aa5ca 100644 --- a/stand/efi/libefi/efichar.c +++ b/stand/efi/libefi/efichar.c @@ -29,16 +29,16 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <errno.h> -#ifdef LIBEFI +#ifdef _STANDALONE #include <stand.h> #else #include <stddef.h> #include <stdlib.h> #include <string.h> #include <unistd.h> -#endif #include <sys/efi.h> #include <machine/efi.h> +#endif #include "efichar.h" diff --git a/stand/efi/libefi/efipart.c b/stand/efi/libefi/efipart.c index 724233c..e0dfa87 100644 --- a/stand/efi/libefi/efipart.c +++ b/stand/efi/libefi/efipart.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include <efi.h> #include <efilib.h> #include <efiprot.h> +#include <efichar.h> #include <disk.h> static EFI_GUID blkio_guid = BLOCK_IO_PROTOCOL; @@ -196,6 +197,82 @@ efipart_floppy(EFI_DEVICE_PATH *node) } /* + * Determine if the provided device path is hdd. + * + * There really is no simple fool proof way to classify the devices. + * Since we do build three lists of devices - floppy, cd and hdd, we + * will try to see if the device is floppy or cd, and list anything else + * as hdd. + */ +static bool +efipart_hdd(EFI_DEVICE_PATH *dp) +{ + unsigned i, nin; + EFI_DEVICE_PATH *devpath, *node; + EFI_BLOCK_IO *blkio; + EFI_STATUS status; + + if (dp == NULL) + return (false); + + if ((node = efi_devpath_last_node(dp)) == NULL) + return (false); + + if (efipart_floppy(node) != NULL) + return (false); + + /* + * Test every EFI BLOCK IO handle to make sure dp is not device path + * for CD/DVD. + */ + nin = efipart_nhandles / sizeof (*efipart_handles); + for (i = 0; i < nin; i++) { + devpath = efi_lookup_devpath(efipart_handles[i]); + if (devpath == NULL) + return (false); + + /* Only continue testing when dp is prefix in devpath. */ + if (!efi_devpath_is_prefix(dp, devpath)) + continue; + + /* + * The device path has to have last node describing the + * device, or we can not test the type. + */ + if ((node = efi_devpath_last_node(devpath)) == NULL) + return (false); + + if (DevicePathType(node) == MEDIA_DEVICE_PATH && + DevicePathSubType(node) == MEDIA_CDROM_DP) { + return (false); + } + + /* Make sure we do have the media. */ + status = BS->HandleProtocol(efipart_handles[i], + &blkio_guid, (void **)&blkio); + if (EFI_ERROR(status)) + return (false); + + /* USB or SATA cd without the media. */ + if (blkio->Media->RemovableMedia && + !blkio->Media->MediaPresent) { + return (false); + } + + /* + * We assume the block size 512 or greater power of 2. + * iPXE is known to insert stub BLOCK IO device with + * BlockSize 1. + */ + if (blkio->Media->BlockSize < 512 || + !powerof2(blkio->Media->BlockSize)) { + return (false); + } + } + return (true); +} + +/* * Add or update entries with new handle data. */ static int @@ -308,9 +385,13 @@ efipart_updatecd(void) if ((node = efi_devpath_last_node(devpath)) == NULL) continue; + if (efipart_floppy(node) != NULL) continue; + if (efipart_hdd(devpath)) + continue; + status = BS->HandleProtocol(efipart_handles[i], &blkio_guid, (void **)&blkio); if (EFI_ERROR(status)) @@ -380,13 +461,21 @@ efipart_hdinfo_add(EFI_HANDLE disk_handle, EFI_HANDLE part_handle) pdinfo_t *hd, *pd, *last; disk_devpath = efi_lookup_devpath(disk_handle); - part_devpath = efi_lookup_devpath(part_handle); - if (disk_devpath == NULL || part_devpath == NULL) { + if (disk_devpath == NULL) return (ENOENT); + + if (part_handle != NULL) { + part_devpath = efi_lookup_devpath(part_handle); + if (part_devpath == NULL) + return (ENOENT); + node = (HARDDRIVE_DEVICE_PATH *) + efi_devpath_last_node(part_devpath); + if (node == NULL) + return (ENOENT); /* This should not happen. */ + } else { + part_devpath = NULL; + node = NULL; } - node = (HARDDRIVE_DEVICE_PATH *)efi_devpath_last_node(part_devpath); - if (node == NULL) - return (ENOENT); /* This should not happen. */ pd = calloc(1, sizeof(pdinfo_t)); if (pd == NULL) { @@ -397,6 +486,9 @@ efipart_hdinfo_add(EFI_HANDLE disk_handle, EFI_HANDLE part_handle) STAILQ_FOREACH(hd, &hdinfo, pd_link) { if (efi_devpath_match(hd->pd_devpath, disk_devpath) == true) { + if (part_devpath == NULL) + return (0); + /* Add the partition. */ pd->pd_handle = part_handle; pd->pd_unit = node->PartitionNumber; @@ -419,6 +511,9 @@ efipart_hdinfo_add(EFI_HANDLE disk_handle, EFI_HANDLE part_handle) hd->pd_devpath = disk_devpath; STAILQ_INSERT_TAIL(&hdinfo, hd, pd_link); + if (part_devpath == NULL) + return (0); + pd = calloc(1, sizeof(pdinfo_t)); if (pd == NULL) { printf("Failed to add partition, out of memory\n"); @@ -470,8 +565,7 @@ efipart_hdinfo_add_filepath(EFI_HANDLE disk_handle) unit = 0; /* FILEPATH_DEVICE_PATH has 0 terminated string */ - for (len = 0; node->PathName[len] != 0; len++) - ; + len = ucs2len(node->PathName); if ((pathname = malloc(len + 1)) == NULL) { printf("Failed to add disk, out of memory\n"); free(pd); @@ -541,7 +635,8 @@ efipart_updatehd(void) if ((node = efi_devpath_last_node(devpath)) == NULL) continue; - if (efipart_floppy(node) != NULL) + + if (!efipart_hdd(devpath)) continue; status = BS->HandleProtocol(efipart_handles[i], @@ -550,6 +645,12 @@ efipart_updatehd(void) continue; if (DevicePathType(node) == MEDIA_DEVICE_PATH && + DevicePathSubType(node) == MEDIA_FILEPATH_DP) { + efipart_hdinfo_add_filepath(efipart_handles[i]); + continue; + } + + if (DevicePathType(node) == MEDIA_DEVICE_PATH && DevicePathSubType(node) == MEDIA_HARDDRIVE_DP) { devpathcpy = efi_devpath_trim(devpath); if (devpathcpy == NULL) @@ -568,18 +669,16 @@ efipart_updatehd(void) continue; if ((node = efi_devpath_last_node(devpathcpy)) == NULL) continue; + if (DevicePathType(node) == MEDIA_DEVICE_PATH && DevicePathSubType(node) == MEDIA_HARDDRIVE_DP) continue; + efipart_hdinfo_add(handle, efipart_handles[i]); continue; } - if (DevicePathType(node) == MEDIA_DEVICE_PATH && - DevicePathSubType(node) == MEDIA_FILEPATH_DP) { - efipart_hdinfo_add_filepath(efipart_handles[i]); - continue; - } + efipart_hdinfo_add(efipart_handles[i], NULL); } } diff --git a/stand/efi/loader/Makefile b/stand/efi/loader/Makefile index 3b4c507..7102555 100644 --- a/stand/efi/loader/Makefile +++ b/stand/efi/loader/Makefile @@ -89,7 +89,6 @@ CFLAGS+= -DEFI_STAGING_SIZE=${EFI_STAGING_SIZE} .endif # Always add MI sources -HELP_FILES= .include "${BOOTSRC}/loader.mk" FILES+= loader.efi diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c index 129fd72..516c47e 100644 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -32,7 +32,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/reboot.h> #include <sys/boot.h> -#include <inttypes.h> +#include <stdint.h> #include <stand.h> #include <string.h> #include <setjmp.h> @@ -501,7 +501,7 @@ main(int argc, CHAR16 *argv[]) #endif } - interact(NULL); /* doesn't return */ + interact(); /* doesn't return */ return (EFI_SUCCESS); /* keep compiler happy */ } diff --git a/stand/ficl.mk b/stand/ficl.mk index a0a1320..14ae631 100644 --- a/stand/ficl.mk +++ b/stand/ficl.mk @@ -12,8 +12,6 @@ FICL_CPUARCH= mips64 FICL_CPUARCH= ${MACHINE_CPUARCH} .endif -.PATH: ${FICLSRC} ${FICLSRC}/${FICL_CPUARCH} - .if ${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 0 CFLAGS+= -fPIC .endif diff --git a/stand/ficl/Makefile b/stand/ficl/Makefile index 9a13614..a3aad2c 100644 --- a/stand/ficl/Makefile +++ b/stand/ficl/Makefile @@ -4,6 +4,8 @@ .include <bsd.init.mk> .include "${BOOTSRC}/ficl.mk" +.PATH: ${FICLSRC} ${FICLSRC}/${FICL_CPUARCH} + BASE_SRCS= dict.c ficl.c fileaccess.c float.c loader.c math64.c \ prefix.c search.c stack.c tools.c vm.c words.c diff --git a/stand/ficl/float.c b/stand/ficl/float.c index d757b23..b6cda15 100644 --- a/stand/ficl/float.c +++ b/stand/ficl/float.c @@ -43,14 +43,14 @@ /* $FreeBSD$ */ +#include "ficl.h" + +#if FICL_WANT_FLOAT #include <stdlib.h> #include <stdio.h> #include <string.h> #include <ctype.h> #include <math.h> -#include "ficl.h" - -#if FICL_WANT_FLOAT /******************************************************************* ** Do float addition r1 + r2. diff --git a/stand/geli/Makefile b/stand/geli/Makefile index c790431..ce54f82 100644 --- a/stand/geli/Makefile +++ b/stand/geli/Makefile @@ -2,6 +2,7 @@ # libgeliboot MAN= +DO32=1 .include <bsd.init.mk> MK_SSP= no @@ -11,19 +12,6 @@ INTERNALLIB= MK_PROFILE= no NO_PIC= -.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" -CFLAGS+= -march=i386 -.endif -.if ${MACHINE_ARCH} == "amd64" -CFLAGS+= -m32 -.endif - -WARNS?= 0 - -# string functions from libc -.PATH: ${SRCTOP}/lib/libc/string -SRCS+= bcmp.c bcopy.c bzero.c - # Our password input method SRCS+= pwgets.c @@ -45,7 +33,6 @@ SRCS+= rijndael-alg-fst.c rijndael-api-fst.c rijndael-api.c # local GELI Implementation .PATH: ${SYSDIR}/geom/eli -CFLAGS+= -D_STAND SRCS+= geliboot_crypto.c g_eli_hmac.c g_eli_key.c g_eli_key_cache.c pkcs5v2.c # aes diff --git a/stand/geli/geliboot.c b/stand/geli/geliboot.c index 2fca7ba..f475f41 100644 --- a/stand/geli/geliboot.c +++ b/stand/geli/geliboot.c @@ -222,7 +222,7 @@ geli_taste(int read_func(void *vdev, void *priv, off_t off, void *buf, */ static int geli_attach(struct geli_entry *ge, struct dsk *dskp, const char *passphrase, - const u_char *mkeyp) + u_char *mkeyp) { u_char key[G_ELI_USERKEYLEN], mkey[G_ELI_DATAIVKEYLEN], *mkp; u_int keynum; @@ -248,7 +248,7 @@ geli_attach(struct geli_entry *ge, struct dsk *dskp, const char *passphrase, } else if (geli_e->md.md_iterations == 0) { g_eli_crypto_hmac_update(&ctx, geli_e->md.md_salt, sizeof(geli_e->md.md_salt)); - g_eli_crypto_hmac_update(&ctx, passphrase, + g_eli_crypto_hmac_update(&ctx, (const uint8_t *)passphrase, strlen(passphrase)); } else if (geli_e->md.md_iterations > 0) { printf("Calculating GELI Decryption Key disk%dp%d @ %d" @@ -294,7 +294,7 @@ found_key: /* * The encryption key is: ekey = HMAC_SHA512(Data-Key, 0x10) */ - g_eli_crypto_hmac(mkp, G_ELI_MAXKEYLEN, "\x10", 1, + g_eli_crypto_hmac(mkp, G_ELI_MAXKEYLEN, (const uint8_t *)"\x10", 1, geli_e->sc.sc_ekey, 0); } explicit_bzero(mkey, sizeof(mkey)); diff --git a/stand/geli/geliboot_internal.h b/stand/geli/geliboot_internal.h index 1fad3c5..ac28db1 100644 --- a/stand/geli/geliboot_internal.h +++ b/stand/geli/geliboot_internal.h @@ -43,7 +43,7 @@ #include <bootstrap.h> /* Pull in the md5, sha256, and sha512 implementations */ -#include <md5.h> +#include <sys/md5.h> #include <crypto/sha2/sha256.h> #include <crypto/sha2/sha512.h> diff --git a/stand/i386/Makefile.inc b/stand/i386/Makefile.inc index 724e176..042ee1b 100644 --- a/stand/i386/Makefile.inc +++ b/stand/i386/Makefile.inc @@ -14,6 +14,8 @@ BTXCRT= ${BTXDIR}/lib/crt0.o BTXSRC= ${BOOTSRC}/i386/btx BTXLIB= ${BTXSRC}/lib +CFLAGS+= -I${BTXLIB} + # compact binary with no padding between text, data, bss LDSCRIPT= ${BOOTSRC}/i386/boot.ldscript # LDFLAGS_BIN=-e start -Ttext ${ORG} -Wl,-T,${LDSCRIPT},-S,--oformat,binary diff --git a/stand/i386/boot2/Makefile b/stand/i386/boot2/Makefile index c3146b3..53bfd9e 100644 --- a/stand/i386/boot2/Makefile +++ b/stand/i386/boot2/Makefile @@ -31,7 +31,6 @@ CFLAGS+=-fomit-frame-pointer \ -DSIOFMT=${B2SIOFMT} \ -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ -I${LDRSRC} \ - -I${BTXLIB} \ -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ diff --git a/stand/i386/common/cons.c b/stand/i386/common/cons.c index 5fb1a93..96e782f 100644 --- a/stand/i386/common/cons.c +++ b/stand/i386/common/cons.c @@ -22,9 +22,10 @@ __FBSDID("$FreeBSD$"); #include <btxv86.h> +#include "stand.h" + #include "lib.h" #include "rbx.h" -#include "util.h" #include "cons.h" #define SECOND 18 /* Circa that many ticks in a second. */ diff --git a/stand/i386/common/drv.c b/stand/i386/common/drv.c index a805c41..e2e4d55 100644 --- a/stand/i386/common/drv.c +++ b/stand/i386/common/drv.c @@ -21,8 +21,8 @@ __FBSDID("$FreeBSD$"); #include <btxv86.h> +#include "stand.h" #include "rbx.h" -#include "util.h" #include "drv.h" #include "edd.h" @@ -69,7 +69,7 @@ drvread(struct dsk *dskp, void *buf, daddr_t lba, unsigned nblk) v86.esi = VTOPOFF(&packet); v86int(); if (V86_CY(v86.efl)) { - printf("%s: error %u lba %u\n", + printf("%s: error %u lba %llu\n", BOOTPROG, v86.eax >> 8 & 0xff, lba); return (-1); } @@ -94,7 +94,7 @@ drvwrite(struct dsk *dskp, void *buf, daddr_t lba, unsigned nblk) v86.esi = VTOPOFF(&packet); v86int(); if (V86_CY(v86.efl)) { - printf("error %u lba %u\n", v86.eax >> 8 & 0xff, lba); + printf("error %u lba %llu\n", v86.eax >> 8 & 0xff, lba); return (-1); } return (0); diff --git a/stand/i386/gptboot/Makefile b/stand/i386/gptboot/Makefile index 9e62007..171a2ed 100644 --- a/stand/i386/gptboot/Makefile +++ b/stand/i386/gptboot/Makefile @@ -33,7 +33,6 @@ CFLAGS+=-DBOOTPROG=\"gptboot\" \ -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ -I${LDRSRC} \ -I${BOOTSRC}/i386/common \ - -I${BTXLIB} \ -I${BOOTSRC}/i386/boot2 \ -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ @@ -67,8 +66,6 @@ gptboot.bin: gptboot.out gptboot.out: ${BTXCRT} gptboot.o sio.o crc32.o drv.o cons.o ${OPENCRYPTO_XTS} ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBGELIBOOT} ${LIBSA32} -gptboot.o: ${SASRC}/ufsread.c - .include <bsd.prog.mk> # XXX: clang integrated-as doesn't grok .codeNN directives yet diff --git a/stand/i386/gptboot/gptboot.c b/stand/i386/gptboot/gptboot.c index dd06f0c..a9d54f4 100644 --- a/stand/i386/gptboot/gptboot.c +++ b/stand/i386/gptboot/gptboot.c @@ -32,11 +32,12 @@ __FBSDID("$FreeBSD$"); #include <btxv86.h> +#include "stand.h" + #include "bootargs.h" #include "lib.h" #include "rbx.h" #include "drv.h" -#include "util.h" #include "cons.h" #include "gpt.h" #include "paths.h" @@ -101,39 +102,14 @@ static struct bios_smap smap; static char *heap_next; static char *heap_end; -void exit(int); static void load(void); static int parse_cmds(char *, int *); static int dskread(void *, daddr_t, unsigned); -void *malloc(size_t n); -void free(void *ptr); #ifdef LOADER_GELI_SUPPORT static int vdev_read(void *vdev __unused, void *priv, off_t off, void *buf, size_t bytes); #endif -void * -malloc(size_t n) -{ - char *p = heap_next; - if (p + n > heap_end) { - printf("malloc failure\n"); - for (;;) - ; - /* NOTREACHED */ - return (0); - } - heap_next += n; - return (p); -} - -void -free(void *ptr) -{ - - return; -} - #include "ufsread.c" #include "gpt.c" #ifdef LOADER_GELI_SUPPORT @@ -254,7 +230,7 @@ gptinit(void) #ifdef LOADER_GELI_SUPPORT if (geli_taste(vdev_read, &dsk, (gpttable[curent].ent_lba_end - gpttable[curent].ent_lba_start)) == 0) { - if (geli_havekey(&dsk) != 0 && geli_passphrase(&gelipw, + if (geli_havekey(&dsk) != 0 && geli_passphrase(gelipw, dsk.unit, 'p', curent + 1, &dsk) != 0) { printf("%s: unable to decrypt GELI key\n", BOOTPROG); return (-1); @@ -266,6 +242,8 @@ gptinit(void) return (0); } +int main(void); + int main(void) { @@ -285,6 +263,7 @@ main(void) heap_next = (char *)dmadat + sizeof(*dmadat); heap_end = (char *)PTOV(bios_basemem); } + setheap(heap_next, heap_end); v86.ctl = V86_FLAGS; v86.efl = PSL_RESERVED_DEFAULT | PSL_I; @@ -385,6 +364,8 @@ main(void) void exit(int x) { + while (1); + __unreachable(); } static void diff --git a/stand/i386/gptboot/gptldr.S b/stand/i386/gptboot/gptldr.S index 088122f..c51a85a 100644 --- a/stand/i386/gptboot/gptldr.S +++ b/stand/i386/gptboot/gptldr.S @@ -46,7 +46,7 @@ .set SIZ_PAG,0x1000 # Page size .set SIZ_SEC,0x200 # Sector size .set COPY_BLKS,0x8 # Number of blocks - # to copy for boot2 + # to copy for boot2 (<= 15) .set COPY_BLK_SZ,0x8000 # Copy in 32k blocks; must be # a multiple of 16 bytes @@ -72,7 +72,7 @@ start: xor %cx,%cx # Zero * its header to find boot2. We need to copy boot2 to MEM_USR and BTX * to MEM_BTX. Since those might overlap, we have to copy boot2 * backwards first and then copy BTX. We aren't sure exactly how long - * boot2 is, but it's currently under 128kB so we'll copy 4 blocks of 32kB + * boot2 is, but it's currently under 256kB so we'll copy 8 blocks of 32kB * each; this can be adjusted via COPY_BLK and COPY_BLK_SZ above. */ mov $end,%bx # BTX diff --git a/stand/i386/gptzfsboot/Makefile b/stand/i386/gptzfsboot/Makefile index d4e06ec..08735c1 100644 --- a/stand/i386/gptzfsboot/Makefile +++ b/stand/i386/gptzfsboot/Makefile @@ -30,6 +30,7 @@ CFLAGS+=-DBOOTPROG=\"gptzfsboot\" \ -I${LDRSRC} \ -I${BOOTSRC}/i386/common \ -I${ZFSSRC} \ + -I${SYSDIR}/crypto/skein \ -I${SYSDIR}/cddl/boot/zfs \ -I${BOOTSRC}/i386/btx/lib \ -I${BOOTSRC}/i386/boot2 \ @@ -38,12 +39,9 @@ CFLAGS+=-DBOOTPROG=\"gptzfsboot\" \ -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ -Winline -Wno-pointer-sign -NO_WCAST_ALIGN= +CFLAGS.clang+= -Wno-tentative-definition-incomplete-type -.if ${COMPILER_TYPE} == "clang" || \ - (${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} > 40201) -CFLAGS+= -Wno-tentative-definition-incomplete-type -.endif +NO_WCAST_ALIGN= .if ${MACHINE} == "amd64" LIBZFSBOOT=${BOOTOBJ}/zfs32/libzfsboot.a diff --git a/stand/i386/libfirewire/Makefile b/stand/i386/libfirewire/Makefile index d3f88c4..f6e594f 100644 --- a/stand/i386/libfirewire/Makefile +++ b/stand/i386/libfirewire/Makefile @@ -12,7 +12,6 @@ SRCS+= dcons.c fwcrom.c CFLAGS+= -D_BOOT CFLAGS+= -I${LDRSRC} -CFLAGS+= -I${BTXLIB} CFLAGS+= -I${BOOTSRC}/i386/libi386 CFLAGS+= -Wformat -Wall diff --git a/stand/i386/libi386/Makefile b/stand/i386/libi386/Makefile index f058521..f54052c 100644 --- a/stand/i386/libi386/Makefile +++ b/stand/i386/libi386/Makefile @@ -47,7 +47,6 @@ CFLAGS+= -Dalloca=__builtin_alloca CFLAGS+= -I${BOOTSRC}/ficl -I${BOOTSRC}/ficl/i386 \ -I${LDRSRC} -I${BOOTSRC}/i386/common \ - -I${BTXLIB} \ -I${SYSDIR}/contrib/dev/acpica/include # Handle FreeBSD specific %b and %D printf format specifiers diff --git a/stand/i386/libi386/biosdisk.c b/stand/i386/libi386/biosdisk.c index a2147e2..2644514 100644 --- a/stand/i386/libi386/biosdisk.c +++ b/stand/i386/libi386/biosdisk.c @@ -146,8 +146,7 @@ enum isgeli { }; static enum isgeli geli_status[MAXBDDEV][MAXTBLENTS]; -int bios_read(void *vdev __unused, struct dsk *priv, off_t off, char *buf, - size_t bytes); +int bios_read(void *, void *, off_t off, void *buf, size_t bytes); #endif /* LOADER_GELI_SUPPORT */ struct devsw biosdisk = { @@ -482,10 +481,10 @@ bd_open(struct open_file *f, ...) /* Use the cached passphrase */ bcopy(passphrase, &gelipw, GELI_PW_MAXLEN); } - if (geli_passphrase(&gelipw, dskp.unit, 'p', + if (geli_passphrase(gelipw, dskp.unit, 'p', (dskp.slice > 0 ? dskp.slice : dskp.part), &dskp) == 0) { - setenv("kern.geom.eli.passphrase", &gelipw, 1); + setenv("kern.geom.eli.passphrase", gelipw, 1); bzero(gelipw, sizeof(gelipw)); geli_status[dev->d_unit][dskp.slice] = ISGELI_YES; geli_part++; @@ -882,7 +881,7 @@ bd_read(struct disk_devdesc *dev, daddr_t dblk, int blks, caddr_t dest) /* GELI needs the offset relative to the partition start */ p_off = alignlba - dskp.start; - err = geli_read(&dskp, p_off * BD(dev).bd_sectorsize, tmpbuf, + err = geli_read(&dskp, p_off * BD(dev).bd_sectorsize, (u_char *)tmpbuf, alignblks * BD(dev).bd_sectorsize); if (err) return (err); @@ -992,9 +991,10 @@ bd_getdev(struct i386_devdesc *d) #ifdef LOADER_GELI_SUPPORT int -bios_read(void *vdev __unused, struct dsk *priv, off_t off, char *buf, size_t bytes) +bios_read(void *vdev __unused, void *xpriv, off_t off, void *buf, size_t bytes) { struct disk_devdesc dev; + struct dsk *priv = xpriv; dev.d_dev = &biosdisk; dev.d_type = priv->type; diff --git a/stand/i386/libi386/multiboot.c b/stand/i386/libi386/multiboot.c index 9aac640..252a1f5 100644 --- a/stand/i386/libi386/multiboot.c +++ b/stand/i386/libi386/multiboot.c @@ -49,8 +49,8 @@ __FBSDID("$FreeBSD$"); #include "bootstrap.h" #include "multiboot.h" -#include "../i386/libi386/libi386.h" -#include "../i386/btx/lib/btxv86.h" +#include "libi386.h" +#include <btxv86.h> #define MULTIBOOT_SUPPORTED_FLAGS \ (MULTIBOOT_PAGE_ALIGN|MULTIBOOT_MEMORY_INFO) diff --git a/stand/i386/loader/Makefile b/stand/i386/loader/Makefile index 40ac46c..ca0d822 100644 --- a/stand/i386/loader/Makefile +++ b/stand/i386/loader/Makefile @@ -41,9 +41,7 @@ LIBFIREWIRE= ${BOOTOBJ}/i386/libfirewire/libfirewire.a .endif .if exists(${.CURDIR}/help.i386) -HELP_FILES+= help.i386 -.else -HELP_FILES= +HELP_FILES= ${.CURDIR}/help.i386 .endif # Always add MI sources @@ -58,9 +56,6 @@ LDFLAGS+= -static -Ttext 0x0 LIBI386= ${BOOTOBJ}/i386/libi386/libi386.a CFLAGS+= -I${BOOTSRC}/i386 -# BTX components -CFLAGS+= -I${BTXLIB} - # Debug me! #CFLAGS+= -g #LDFLAGS+= -g diff --git a/stand/i386/loader/main.c b/stand/i386/loader/main.c index 81bc2ff..543dae1 100644 --- a/stand/i386/loader/main.c +++ b/stand/i386/loader/main.c @@ -232,7 +232,7 @@ main(void) bios_getsmap(); - interact(NULL); + interact(); /* if we ever get here, it is an error */ return (1); diff --git a/stand/i386/zfsboot/Makefile b/stand/i386/zfsboot/Makefile index f0523df..35185de 100644 --- a/stand/i386/zfsboot/Makefile +++ b/stand/i386/zfsboot/Makefile @@ -29,8 +29,8 @@ CFLAGS+=-DBOOTPROG=\"zfsboot\" \ -I${BOOTSRC}/i386/common \ -I${BOOTSRC}/i386 \ -I${ZFSSRC} \ + -I${SYSDIR}/crypto/skein \ -I${SYSDIR}/cddl/boot/zfs \ - -I${BTXLIB} \ -I${BOOTSRC}/i386/boot2 \ -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ @@ -62,10 +62,10 @@ zfsldr.out: zfsldr.o CLEANFILES+= zfsboot2 zfsboot.ld zfsboot.ldr zfsboot.bin zfsboot.out \ zfsboot.o zfsboot.s zfsboot.s.tmp sio.o cons.o drv.o -# We currently allow 128k bytes for zfsboot - in practice it could be +# We currently allow 256k bytes for zfsboot - in practice it could be # any size up to 3.5Mb but keeping it fixed size simplifies zfsldr. # -BOOT2SIZE= 131072 +BOOT2SIZE= 262144 zfsboot2: zfsboot.ld @set -- `ls -l ${.ALLSRC}`; x=$$((${BOOT2SIZE}-$$5)); \ diff --git a/stand/i386/zfsboot/zfsboot.c b/stand/i386/zfsboot/zfsboot.c index 88b5231..fe75cd9 100644 --- a/stand/i386/zfsboot/zfsboot.c +++ b/stand/i386/zfsboot/zfsboot.c @@ -16,6 +16,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "stand.h" + #include <sys/param.h> #include <sys/errno.h> #include <sys/diskmbr.h> @@ -40,7 +42,6 @@ __FBSDID("$FreeBSD$"); #include "rbx.h" #include "drv.h" #include "edd.h" -#include "util.h" #include "cons.h" #include "bootargs.h" #include "paths.h" @@ -96,7 +97,6 @@ static int comspeed = SIOSPD; static struct bootinfo bootinfo; static uint32_t bootdev; static struct zfs_boot_args zfsargs; -static struct zfsmount zfsmount; vm_offset_t high_heap_base; uint32_t bios_basemem, bios_extmem, high_heap_size; @@ -124,40 +124,8 @@ void reboot(void); static void load(void); static int parse_cmd(void); static void bios_getmem(void); -void *malloc(size_t n); -void free(void *ptr); int main(void); -void * -malloc(size_t n) -{ - char *p = heap_next; - if (p + n > heap_end) { - printf("malloc failure\n"); - for (;;) - ; - /* NOTREACHED */ - return (0); - } - heap_next += n; - return (p); -} - -void -free(void *ptr) -{ - - return; -} - -static char * -strdup(const char *s) -{ - char *p = malloc(strlen(s) + 1); - strcpy(p, s); - return (p); -} - #ifdef LOADER_GELI_SUPPORT #include "geliboot.c" static char gelipw[GELI_PW_MAXLEN]; @@ -200,7 +168,7 @@ static vdev_t *primary_vdev; * buffer pointer crosses a 64k boundary. */ static int -vdev_read(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes) +vdev_read(void *xvdev, void *priv, off_t off, void *buf, size_t bytes) { char *p; daddr_t lba, alignlba; @@ -262,6 +230,13 @@ vdev_read(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes) return 0; } +/* Match the signature exactly due to signature madness */ +static int +vdev_read2(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes) +{ + return vdev_read(vdev, priv, off, buf, bytes); +} + static int vdev_write(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes) @@ -493,7 +468,6 @@ drvsize_ext(struct dsk *dskp) if (V86_CY(v86.efl) || /* carry set */ (v86.edx & 0xff) <= (unsigned)(dskp->drive & 0x7f)) /* unit # bad */ return (0); - cyl = ((v86.ecx & 0xc0) << 2) + ((v86.ecx & 0xff00) >> 8) + 1; /* Convert max head # -> # of heads */ hds = ((v86.edx & 0xff00) >> 8) + 1; @@ -557,7 +531,7 @@ probe_drive(struct dsk *dsk) /* * If we find a vdev on the whole disk, stop here. */ - if (vdev_probe(vdev_read, dsk, NULL) == 0) + if (vdev_probe(vdev_read2, dsk, NULL) == 0) return; #ifdef LOADER_GELI_SUPPORT @@ -572,9 +546,9 @@ probe_drive(struct dsk *dsk) elba--; } if (geli_taste(vdev_read, dsk, elba) == 0) { - if (geli_havekey(dsk) == 0 || geli_passphrase(&gelipw, dsk->unit, + if (geli_havekey(dsk) == 0 || geli_passphrase(gelipw, dsk->unit, ':', 0, dsk) == 0) { - if (vdev_probe(vdev_read, dsk, NULL) == 0) { + if (vdev_probe(vdev_read2, dsk, NULL) == 0) { return; } } @@ -621,7 +595,7 @@ probe_drive(struct dsk *dsk) dsk->size = ent->ent_lba_end - ent->ent_lba_start + 1; dsk->slice = part + 1; dsk->part = 255; - if (vdev_probe(vdev_read, dsk, NULL) == 0) { + if (vdev_probe(vdev_read2, dsk, NULL) == 0) { /* * This slice had a vdev. We need a new dsk * structure now since the vdev now owns this one. @@ -631,12 +605,12 @@ probe_drive(struct dsk *dsk) #ifdef LOADER_GELI_SUPPORT else if (geli_taste(vdev_read, dsk, ent->ent_lba_end - ent->ent_lba_start) == 0) { - if (geli_havekey(dsk) == 0 || geli_passphrase(&gelipw, + if (geli_havekey(dsk) == 0 || geli_passphrase(gelipw, dsk->unit, 'p', dsk->slice, dsk) == 0) { /* * This slice has GELI, check it for ZFS. */ - if (vdev_probe(vdev_read, dsk, NULL) == 0) { + if (vdev_probe(vdev_read2, dsk, NULL) == 0) { /* * This slice had a vdev. We need a new dsk * structure now since the vdev now owns this one. @@ -665,18 +639,18 @@ trymbr: dsk->start = dp[i].dp_start; dsk->size = dp[i].dp_size; dsk->slice = i + 1; - if (vdev_probe(vdev_read, dsk, NULL) == 0) { + if (vdev_probe(vdev_read2, dsk, NULL) == 0) { dsk = copy_dsk(dsk); } #ifdef LOADER_GELI_SUPPORT else if (geli_taste(vdev_read, dsk, dp[i].dp_size - dp[i].dp_start) == 0) { - if (geli_havekey(dsk) == 0 || geli_passphrase(&gelipw, dsk->unit, + if (geli_havekey(dsk) == 0 || geli_passphrase(gelipw, dsk->unit, 's', i, dsk) == 0) { /* * This slice has GELI, check it for ZFS. */ - if (vdev_probe(vdev_read, dsk, NULL) == 0) { + if (vdev_probe(vdev_read2, dsk, NULL) == 0) { /* * This slice had a vdev. We need a new dsk * structure now since the vdev now owns this one. @@ -711,6 +685,7 @@ main(void) heap_next = (char *)dmadat + sizeof(*dmadat); heap_end = (char *)PTOV(bios_basemem); } + setheap(heap_next, heap_end); dsk = malloc(sizeof(struct dsk)); dsk->drive = *(uint8_t *)PTOV(ARGS); diff --git a/stand/libsa/Makefile b/stand/libsa/Makefile index ea32f3e..ff50dd6 100644 --- a/stand/libsa/Makefile +++ b/stand/libsa/Makefile @@ -18,13 +18,10 @@ LIBC_SRC= ${SRCTOP}/lib/libc LIB?= sa NO_PIC= -WARNS?= 0 - -CFLAGS+= -I${SASRC} # standalone components and stuff we have modified locally -SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c environment.c getopt.c gets.c \ - globals.c pager.c panic.c printf.c strdup.c strerror.c strtol.c strtoul.c \ +SRCS+= gzguts.h zutil.h __main.c abort.c assert.c bcd.c environment.c getopt.c gets.c \ + globals.c pager.c panic.c printf.c strdup.c strerror.c \ random.c sbrk.c twiddle.c zalloc.c zalloc_malloc.c # private (pruned) versions of libc string functions @@ -41,6 +38,11 @@ SRCS+= bcmp.c bcopy.c bzero.c ffs.c fls.c \ qdivrem.c strcat.c strchr.c strcmp.c strcpy.c stpcpy.c stpncpy.c \ strcspn.c strlcat.c strlcpy.c strlen.c strncat.c strncmp.c strncpy.c \ strnlen.c strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c + +# stdlib functions from libc +.PATH: ${LIBC_SRC}/stdlib +SRCS+= abs.c strtol.c strtoll.c strtoul.c strtoull.c + .if ${MACHINE_CPUARCH} == "arm" .PATH: ${LIBC_SRC}/arm/gen @@ -90,48 +92,41 @@ SRCS+= _setjmp.S # loader(8) with LOADER_BZIP2_SUPPORT defined .PATH: ${SRCTOP}/contrib/bzip2 CFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS -SRCS+= libsa_bzlib_private.h -.for file in bzlib.c crctable.c decompress.c huffman.c randtable.c -SRCS+= _${file} -CLEANFILES+= _${file} - -_${file}: ${file} - sed "s|bzlib_private\.h|libsa_bzlib_private.h|" \ - ${.ALLSRC} > ${.TARGET} -.endfor - -CLEANFILES+= libsa_bzlib_private.h -libsa_bzlib_private.h: bzlib_private.h - sed -e 's|<stdlib.h>|"stand.h"|' \ - ${.ALLSRC} > ${.TARGET} +SRCS+=bzlib.c crctable.c decompress.c huffman.c randtable.c # decompression functionality from zlib .PATH: ${SRCTOP}/contrib/zlib CFLAGS+=-DHAVE_MEMCPY -I${SRCTOP}/contrib/zlib -SRCS+= adler32.c crc32.c libsa_zutil.h libsa_gzguts.h - -.for file in infback.c inffast.c inflate.c inftrees.c zutil.c -SRCS+= _${file} -CLEANFILES+= _${file} - -_${file}: ${file} - sed -e "s|zutil\.h|libsa_zutil.h|" \ - -e "s|gzguts\.h|libsa_gzguts.h|" \ - ${.ALLSRC} > ${.TARGET} -.endfor - -# depend on stand.h being able to be included multiple times -.for file in zutil.h gzguts.h -CLEANFILES+= libsa_${file} -libsa_${file}: ${file} - sed -e 's|<fcntl.h>|"stand.h"|' \ - -e 's|<stddef.h>|"stand.h"|' \ - -e 's|<string.h>|"stand.h"|' \ - -e 's|<stdio.h>|"stand.h"|' \ - -e 's|<stdlib.h>|"stand.h"|' \ - ${.ALLSRC} > ${.TARGET} -.endfor +SRCS+= adler32.c crc32.c +SRCS+= infback.c inffast.c inflate.c inftrees.c zutil.c + +# Create a subset of includes that are safe, as well as adjusting those that aren't +# The lists may drive people nuts, but they are explicitly opt-in +FAKE_DIRS=xlocale arpa +SAFE_INCS=a.out.h assert.h elf.h limits.h nlist.h setjmp.h stddef.h stdbool.h string.h strings.h time.h unistd.h uuid.h +STAND_H_INC=ctype.h fcntl.h signal.h stdio.h stdlib.h +OTHER_INC=stdarg.h errno.h stdint.h + +beforedepend: + echo beforedepend; \ + mkdir -p ${FAKE_DIRS}; \ + for i in ${SAFE_INCS}; do \ + ln -sf ${SRCTOP}/include/$$i $$i; \ + done; \ + ln -sf ${SYSDIR}/${MACHINE}/include/stdarg.h stdarg.h; \ + ln -sf ${SYSDIR}/sys/errno.h errno.h; \ + ln -sf ${SYSDIR}/sys/stdint.h stdint.h; \ + ln -sf ${SRCTOP}/include/arpa/inet.h arpa/inet.h; \ + ln -sf ${SRCTOP}/include/arpa/tftp.h arpa/tftp.h; \ + for i in _time.h _strings.h _string.h; do \ + [ -f xlocale/$$i ] || cp /dev/null xlocale/$$i; \ + done; \ + for i in ${STAND_H_INC}; do \ + ln -sf ${SASRC}/stand.h $$i; \ + done +CLEANDIRS+=${FAKE_DIRS} +CLEANFILES+= ${SAFE_INCS} ${STAND_H_INC} ${OTHER_INC} # io routines SRCS+= closeall.c dev.c ioctl.c nullfs.c stat.c \ @@ -152,6 +147,8 @@ SRCS+= pkgfs.c SRCS+= nandfs.c .endif +CFLAGS.bzipfs.c+= -I${SRCTOP}/contrib/bzip2 + # explicit_bzero .PATH: ${SYSDIR}/libkern SRCS+= explicit_bzero.c diff --git a/stand/libsa/abort.c b/stand/libsa/abort.c new file mode 100644 index 0000000..4b3a2c7 --- /dev/null +++ b/stand/libsa/abort.c @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018 Netflix. 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 <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <stand.h> + +void +abort(void) +{ + panic("Bootloader aborted by abort"); +} diff --git a/stand/libsa/bootp.c b/stand/libsa/bootp.c index 9f08faf..a6d5052 100644 --- a/stand/libsa/bootp.c +++ b/stand/libsa/bootp.c @@ -355,17 +355,6 @@ bad: return (-1); } -int -dhcp_try_rfc1048(u_char *cp, u_int len) -{ - - expected_dhcpmsgtype = DHCPACK; - if (bcmp(vm_rfc1048, cp, sizeof(vm_rfc1048)) == 0) { - return (vend_rfc1048(cp, len)); - } - return (-1); -} - static int vend_rfc1048(u_char *cp, u_int len) { diff --git a/stand/libsa/bootp.h b/stand/libsa/bootp.h index 2e7049b..fd99b77 100644 --- a/stand/libsa/bootp.h +++ b/stand/libsa/bootp.h @@ -146,6 +146,4 @@ struct cmu_vend { extern struct bootp *bootp_response; extern size_t bootp_response_size; -int dhcp_try_rfc1048(u_char *cp, u_int len); - #endif /* _BOOTP_H_ */ diff --git a/stand/libsa/cd9660.c b/stand/libsa/cd9660.c index c561883..a1711fb 100644 --- a/stand/libsa/cd9660.c +++ b/stand/libsa/cd9660.c @@ -43,8 +43,8 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <string.h> #include <sys/dirent.h> -#include <isofs/cd9660/iso.h> -#include <isofs/cd9660/cd9660_rrip.h> +#include <fs/cd9660/iso.h> +#include <fs/cd9660/cd9660_rrip.h> #include "stand.h" diff --git a/stand/libsa/gpt.c b/stand/libsa/gpt.c index 7ab3fc6..900f2d5 100644 --- a/stand/libsa/gpt.c +++ b/stand/libsa/gpt.c @@ -34,9 +34,9 @@ __FBSDID("$FreeBSD$"); #error gpt.c works only for little endian architectures #endif +#include "stand.h" #include "crc32.h" #include "drv.h" -#include "util.h" #include "gpt.h" static struct gpt_hdr hdr_primary, hdr_backup, *gpthdr; diff --git a/stand/libsa/net.h b/stand/libsa/net.h index f91435c..ac5414f 100644 --- a/stand/libsa/net.h +++ b/stand/libsa/net.h @@ -128,6 +128,4 @@ char *inet_ntoa(struct in_addr); char *intoa(n_long); /* similar to inet_ntoa */ n_long inet_addr(char *); -/* Machine-dependent functions: */ -time_t getsecs(void); #endif /* ! _STAND_NET_H */ diff --git a/stand/libsa/panic.c b/stand/libsa/panic.c index 6e4c76d..bc6e7e2 100644 --- a/stand/libsa/panic.c +++ b/stand/libsa/panic.c @@ -39,7 +39,18 @@ __FBSDID("$FreeBSD$"); #include <stand.h> #include <machine/stdarg.h> -extern void exit(int) __dead2; +/* + * Boot loaders and other standalone programs that wish to have a + * different panic policy can provide their own panic_action rotuine. + */ +__weak_symbol void +panic_action(void) +{ + printf("--> Press a key on the console to reboot <--\n"); + getchar(); + printf("Rebooting...\n"); + exit(1); +} void panic(const char *fmt,...) @@ -51,9 +62,5 @@ panic(const char *fmt,...) vprintf(fmt, ap); va_end(ap); printf("\n"); - - printf("--> Press a key on the console to reboot <--\n"); - getchar(); - printf("Rebooting...\n"); - exit(1); + panic_action(); } diff --git a/stand/libsa/sbrk.c b/stand/libsa/sbrk.c index 471e78e..00787fc 100644 --- a/stand/libsa/sbrk.c +++ b/stand/libsa/sbrk.c @@ -52,6 +52,9 @@ sbrk(int incr) { char *ret; + if (heapbase == 0) + panic("No heap setup\n"); + if ((heapsize + incr) <= maxheap) { ret = (char *)heapbase + heapsize; bzero(ret, incr); diff --git a/stand/libsa/stand.h b/stand/libsa/stand.h index deb6ad8..dd94b48 100644 --- a/stand/libsa/stand.h +++ b/stand/libsa/stand.h @@ -72,10 +72,7 @@ #define CHK(fmt, args...) printf("%s(%d): " fmt "\n", __func__, __LINE__ , ##args) #define PCHK(fmt, args...) {printf("%s(%d): " fmt "\n", __func__, __LINE__ , ##args); getchar();} -/* Avoid unwanted userlandish components */ -#define _KERNEL #include <sys/errno.h> -#undef _KERNEL /* special stand error codes */ #define EADAPT (ELAST+1) /* bad adaptor */ @@ -88,6 +85,9 @@ #define EOFFSET (ELAST+8) /* relative seek not supported */ #define ESALAST (ELAST+8) /* */ +/* Partial signal emulation for sig_atomic_t */ +#include <machine/signal.h> + struct open_file; /* @@ -235,6 +235,22 @@ static __inline int isalnum(int c) return isalpha(c) || isdigit(c); } +static __inline int iscntrl(int c) +{ + return (c >= 0 && c < ' ') || c == 127; +} + +static __inline int isgraph(int c) +{ + return c >= '!' && c <= '~'; +} + +static __inline int ispunct(int c) +{ + return (c >= '!' && c <= '/') || (c >= ':' && c <= '@') || + (c >= '[' && c <= '`') || (c >= '{' && c <= '~'); +} + static __inline int toupper(int c) { return islower(c) ? c - 'a' + 'A' : c; @@ -249,12 +265,6 @@ static __inline int tolower(int c) extern void setheap(void *base, void *top); extern char *sbrk(int incr); -/* Matt Dillon's zalloc/zmalloc */ -extern void *malloc(size_t bytes); -extern void free(void *ptr); -/*#define free(p) {CHK("free %p", p); free(p);} */ /* use for catching guard violations */ -extern void *calloc(size_t n1, size_t n2); -extern void *realloc(void *ptr, size_t size); extern void *reallocf(void *ptr, size_t size); extern void mallocstats(void); @@ -285,8 +295,6 @@ extern void srandom(u_long seed); extern long random(void); /* imports from stdlib, locally modified */ -extern long strtol(const char *, char **, int); -extern unsigned long strtoul(const char *, char **, int); extern char *optarg; /* getopt(3) external variables */ extern int optind, opterr, optopt, optreset; extern int getopt(int, char * const [], const char *); @@ -336,6 +344,14 @@ extern int unsetenv(const char *name); extern ev_sethook_t env_noset; /* refuse set operation */ extern ev_unsethook_t env_nounset; /* refuse unset operation */ +/* stdlib.h routines */ +extern int abs(int a); +extern void abort(void) __dead2; +extern long strtol(const char * __restrict, char ** __restrict, int); +extern long long strtoll(const char * __restrict, char ** __restrict, int); +extern unsigned long strtoul(const char * __restrict, char ** __restrict, int); +extern unsigned long long strtoull(const char * __restrict, char ** __restrict, int); + /* BCD conversions (undocumented) */ extern u_char const bcd2bin_data[]; extern u_char const bin2bcd_data[]; @@ -344,6 +360,7 @@ extern char const hex2ascii_data[]; #define bcd2bin(bcd) (bcd2bin_data[bcd]) #define bin2bcd(bin) (bin2bcd_data[bin]) #define hex2ascii(hex) (hex2ascii_data[hex]) +#define validbcd(bcd) (bcd == 0 || (bcd > 0 && bcd <= 0x99 && bcd2bin_data[bcd] != 0)) /* min/max (undocumented) */ static __inline int imax(int a, int b) { return (a > b ? a : b); } @@ -357,7 +374,6 @@ static __inline quad_t qmin(quad_t a, quad_t b) { return (a < b ? a : b); } static __inline u_long ulmax(u_long a, u_long b) { return (a > b ? a : b); } static __inline u_long ulmin(u_long a, u_long b) { return (a < b ? a : b); } - /* null functions for device/filesystem switches (undocumented) */ extern int nodev(void); extern int noioctl(struct open_file *, u_long, void *); @@ -376,13 +392,15 @@ extern int null_readdir(struct open_file *f, struct dirent *d); * Machine dependent functions and data, must be provided or stubbed by * the consumer */ -extern void exit(int); +extern void exit(int) __dead2; extern int getchar(void); extern int ischar(void); extern void putchar(int); extern int devopen(struct open_file *, const char *, const char **); extern int devclose(struct open_file *f); extern void panic(const char *, ...) __dead2 __printflike(1, 2); +extern void panic_action(void) __weak_symbol __dead2; +extern time_t getsecs(void); extern struct fs_ops *file_system[]; extern struct fs_ops *exclusive_file_system; extern struct devsw *devsw[]; @@ -411,7 +429,7 @@ void *Calloc(size_t, size_t, const char *, int); void *Realloc(void *, size_t, const char *, int); void Free(void *, const char *, int); -#if 1 +#ifdef DEBUG_MALLOC #define malloc(x) Malloc(x, __FILE__, __LINE__) #define calloc(x, y) Calloc(x, y, __FILE__, __LINE__) #define free(x) Free(x, __FILE__, __LINE__) diff --git a/stand/libsa/strtol.c b/stand/libsa/strtol.c deleted file mode 100644 index be82fb1..0000000 --- a/stand/libsa/strtol.c +++ /dev/null @@ -1,132 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strtol.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include "stand.h" -#include <limits.h> - -/* - * Convert a string to a long integer. - * - * Ignores `locale' stuff. Assumes that the upper and lower case - * alphabets and digits are each contiguous. - */ -long -strtol(nptr, endptr, base) - const char *nptr; - char **endptr; - int base; -{ - const char *s; - unsigned long acc; - unsigned char c; - unsigned long cutoff; - int neg = 0, any, cutlim; - - /* Be sensible about NULL strings */ - if (nptr == NULL) - nptr = ""; - s = nptr; - - /* - * Skip white space and pick up leading +/- sign if any. - * If base is 0, allow 0x for hex and 0 for octal, else - * assume decimal; if base is already 16, allow 0x. - */ - do { - c = *s++; - } while (isspace(c)); - if (c == '-') { - neg = 1; - c = *s++; - } else if (c == '+') - c = *s++; - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == '0' ? 8 : 10; - - /* - * Compute the cutoff value between legal numbers and illegal - * numbers. That is the largest legal value, divided by the - * base. An input number that is greater than this value, if - * followed by a legal input character, is too big. One that - * is equal to this value may be valid or not; the limit - * between valid and invalid numbers is then based on the last - * digit. For instance, if the range for longs is - * [-2147483648..2147483647] and the input base is 10, - * cutoff will be set to 214748364 and cutlim to either - * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated - * a value > 214748364, or equal but the next digit is > 7 (or 8), - * the number is too big, and we will return a range error. - * - * Set any if any `digits' consumed; make it negative to indicate - * overflow. - */ - cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; - cutlim = cutoff % (unsigned long)base; - cutoff /= (unsigned long)base; - for (acc = 0, any = 0;; c = *s++) { - if (!isascii(c)) - break; - if (isdigit(c)) - c -= '0'; - else if (isalpha(c)) - c -= isupper(c) ? 'A' - 10 : 'a' - 10; - else - break; - if (c >= base) - break; - if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) - any = -1; - else { - any = 1; - acc *= base; - acc += c; - } - } - if (any < 0) { - acc = neg ? LONG_MIN : LONG_MAX; - errno = ERANGE; - } else if (neg) - acc = -acc; - if (endptr != NULL) - *endptr = (char *)(any ? s - 1 : nptr); - return (acc); -} diff --git a/stand/libsa/strtoul.c b/stand/libsa/strtoul.c deleted file mode 100644 index 5735d20..0000000 --- a/stand/libsa/strtoul.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. - * Portions of this software were developed by David Chisnall - * under sponsorship from the FreeBSD Foundation. - * - * 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. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strtoul.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include "stand.h" -#include <limits.h> - -/* - * Convert a string to an unsigned long integer. - * - * Assumes that the upper and lower case - * alphabets and digits are each contiguous. - */ -unsigned long -strtoul(const char * __restrict nptr, char ** __restrict endptr, int base) -{ - const char *s; - unsigned long acc; - char c; - unsigned long cutoff; - int neg, any, cutlim; - - /* - * See strtol for comments as to the logic used. - */ - s = nptr; - do { - c = *s++; - } while (isspace((unsigned char)c)); - if (c == '-') { - neg = 1; - c = *s++; - } else { - neg = 0; - if (c == '+') - c = *s++; - } - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X') && - ((s[1] >= '0' && s[1] <= '9') || - (s[1] >= 'A' && s[1] <= 'F') || - (s[1] >= 'a' && s[1] <= 'f'))) { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == '0' ? 8 : 10; - acc = any = 0; - if (base < 2 || base > 36) - goto noconv; - - cutoff = ULONG_MAX / base; - cutlim = ULONG_MAX % base; - for ( ; ; c = *s++) { - if (c >= '0' && c <= '9') - c -= '0'; - else if (c >= 'A' && c <= 'Z') - c -= 'A' - 10; - else if (c >= 'a' && c <= 'z') - c -= 'a' - 10; - else - break; - if (c >= base) - break; - if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) - any = -1; - else { - any = 1; - acc *= base; - acc += c; - } - } - if (any < 0) { - acc = ULONG_MAX; - errno = ERANGE; - } else if (!any) { -noconv: - errno = EINVAL; - } else if (neg) - acc = -acc; - if (endptr != NULL) - *endptr = (char *)(any ? s - 1 : nptr); - return (acc); -} diff --git a/stand/libsa/util.c b/stand/libsa/util.c deleted file mode 100644 index 49f42eb..0000000 --- a/stand/libsa/util.c +++ /dev/null @@ -1,182 +0,0 @@ -/*- - * Copyright (c) 1998 Robert Nordier - * Copyright (c) 2010 Pawel Jakub Dawidek <pjd@FreeBSD.org> - * 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 <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> - -#include <stdarg.h> - -#include "cons.h" -#include "util.h" - -void -memcpy(void *dst, const void *src, int len) -{ - const char *s = src; - char *d = dst; - - while (len--) - *d++ = *s++; -} - -void -memset(void *b, int c, size_t len) -{ - char *bp = b; - - while (len--) - *bp++ = (unsigned char)c; -} - -int -memcmp(const void *b1, const void *b2, size_t len) -{ - const unsigned char *p1, *p2; - - for (p1 = b1, p2 = b2; len > 0; len--, p1++, p2++) { - if (*p1 != *p2) - return ((*p1) - (*p2)); - } - return (0); -} - -int -strcmp(const char *s1, const char *s2) -{ - - for (; *s1 == *s2 && *s1 != '\0'; s1++, s2++) - ; - return ((unsigned char)*s1 - (unsigned char)*s2); -} - -int -strncmp(const char *s1, const char *s2, size_t len) -{ - - for (; len > 0 && *s1 == *s2 && *s1 != '\0'; len--, s1++, s2++) - ; - return (len == 0 ? 0 : (unsigned char)*s1 - (unsigned char)*s2); -} - -void -strcpy(char *dst, const char *src) -{ - - while (*src != '\0') - *dst++ = *src++; - *dst = '\0'; -} - -void -strcat(char *dst, const char *src) -{ - - while (*dst != '\0') - dst++; - while (*src != '\0') - *dst++ = *src++; - *dst = '\0'; -} - -char * -strchr(const char *s, char ch) -{ - - for (; *s != '\0'; s++) { - if (*s == ch) - return ((char *)(uintptr_t)(const void *)s); - } - return (NULL); -} - -size_t -strlen(const char *s) -{ - size_t len = 0; - - while (*s++ != '\0') - len++; - return (len); -} - -int -printf(const char *fmt, ...) -{ - va_list ap; - const char *hex = "0123456789abcdef"; - char buf[32], *s; - uint16_t *S; - unsigned long long u; - int c, l; - - va_start(ap, fmt); - while ((c = *fmt++) != '\0') { - if (c != '%') { - putchar(c); - continue; - } - l = 0; -nextfmt: - c = *fmt++; - switch (c) { - case 'l': - l++; - goto nextfmt; - case 'c': - putchar(va_arg(ap, int)); - break; - case 's': - for (s = va_arg(ap, char *); *s != '\0'; s++) - putchar(*s); - break; - case 'S': /* Assume console can cope with wide chars */ - for (S = va_arg(ap, uint16_t *); *S != 0; S++) - putchar(*S); - break; - case 'd': /* A lie, always prints unsigned */ - case 'u': - case 'x': - switch (l) { - case 2: - u = va_arg(ap, unsigned long long); - break; - case 1: - u = va_arg(ap, unsigned long); - break; - default: - u = va_arg(ap, unsigned int); - break; - } - s = buf; - if (c == 'd' || c == 'u') { - do - *s++ = '0' + (u % 10U); - while (u /= 10); - } else { - do - *s++ = hex[u & 0xfu]; - while (u >>= 4); - } - while (--s >= buf) - putchar(*s); - break; - } - } - va_end(ap); - return (0); -} diff --git a/stand/libsa/util.h b/stand/libsa/xlocale_private.h index 88a99f1..96eed37 100644 --- a/stand/libsa/util.h +++ b/stand/libsa/xlocale_private.h @@ -1,6 +1,5 @@ /*- - * Copyright (c) 2010 Pawel Jakub Dawidek <pjd@FreeBSD.org> - * All rights reserved. + * Copyright (c) 2018 Netflix * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -11,10 +10,10 @@ * 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 AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * 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 AUTHORS OR CONTRIBUTORS BE LIABLE + * 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) @@ -26,28 +25,12 @@ * $FreeBSD$ */ -#ifndef _UTIL_H_ -#define _UTIL_H_ +#ifndef STAND_XLOCALE_PRIVATE_H +#define STAND_XLOCALE_PRIVATE_H 1 -#include <sys/types.h> +typedef int locale_t; +#define FIX_LOCALE(x) +#define isspace_l(c, l) isspace(c) +#define __get_locale() 0 -#include <stdarg.h> - -void memcpy(void *dst, const void *src, int len); -void memset(void *b, int c, size_t len); -int memcmp(const void *b1, const void *b2, size_t len); - -#define bcopy(src, dst, len) memcpy((dst), (src), (len)) -#define bzero(buf, size) memset((buf), 0, (size)) -#define bcmp(b1, b2, len) (memcmp((b1), (b2), (len)) != 0) - -int strcmp(const char *s1, const char *s2); -int strncmp(const char *s1, const char *s2, size_t len); -void strcpy(char *dst, const char *src); -void strcat(char *dst, const char *src); -char *strchr(const char *s, char ch); -size_t strlen(const char *s); - -int printf(const char *fmt, ...); - -#endif /* !_UTIL_H_ */ +#endif /* STAND_XLOCALE_PRIVATE_H */ diff --git a/stand/loader.mk b/stand/loader.mk index 66fc2ce..b811c93 100644 --- a/stand/loader.mk +++ b/stand/loader.mk @@ -71,6 +71,50 @@ CFLAGS+= -DBOOT_PROMPT_123 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_NANDFS_SUPPORT:U${MK_NAND}} == "yes" +CFLAGS+= -DLOADER_NANDFS_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 defined(HAVE_ZFS) CFLAGS+= -DLOADER_ZFS_SUPPORT CFLAGS+= -I${ZFSSRC} @@ -84,6 +128,16 @@ LIBZFSBOOT= ${BOOTOBJ}/zfs/libzfsboot.a .endif .endif +# NB: The makefiles depend on these being empty when we don't build forth. +.if ${MK_FORTH} != "no" +LIBFICL= ${BOOTOBJ}/ficl/libficl.a +.if ${MACHINE} == "i386" +LIBFICL32= ${LIBFICL} +.else +LIBFICL32= ${BOOTOBJ}/ficl32/libficl.a +.endif +.endif + CLEANFILES+= vers.c VERSION_FILE?= ${.CURDIR}/version .if ${MK_REPRODUCIBLE_BUILD} != no @@ -94,6 +148,8 @@ vers.c: ${LDRSRC}/newvers.sh ${VERSION_FILE} ${NEWVERSWHAT} .if !empty(HELP_FILES) +HELP_FILES+= ${LDRSRC}/help.common + CLEANFILES+= loader.help FILES+= loader.help diff --git a/stand/mips/beri/boot2/Makefile b/stand/mips/beri/boot2/Makefile index c46a157..ce09b6e 100644 --- a/stand/mips/beri/boot2/Makefile +++ b/stand/mips/beri/boot2/Makefile @@ -47,17 +47,13 @@ MAN= AFLAGS= -G0 -CFLAGS+= -I${.CURDIR} \ - -I${SASRC} \ - -I${LDRSRC} \ - -D_KERNEL \ +CFLAGS+= -I${LDRSRC} \ -Wall \ -G0 \ -fno-pic -mno-abicalls \ -g -LDFLAGS= -nostdlib \ - -static \ +LDFLAGS+= -static \ -Wl,-N \ -G0 \ -L${.CURDIR} diff --git a/stand/mips/beri/boot2/boot2.c b/stand/mips/beri/boot2/boot2.c index 3db33c4..8dba050 100644 --- a/stand/mips/beri/boot2/boot2.c +++ b/stand/mips/beri/boot2/boot2.c @@ -500,7 +500,7 @@ parse() */ unit = q[len-1]; if (unit < '0' || unit > '9') { - printf("Invalid device: invalid unit\n", q, + printf("Invalid device: invalid unit %c\n", unit); return (-1); } diff --git a/stand/mips/beri/common/altera_jtag_uart.c b/stand/mips/beri/common/altera_jtag_uart.c index 7edb451..4bed67d 100644 --- a/stand/mips/beri/common/altera_jtag_uart.c +++ b/stand/mips/beri/common/altera_jtag_uart.c @@ -30,7 +30,7 @@ * $FreeBSD$ */ -#include "util.h" +#include "stand.h" #include "mips.h" /*- @@ -131,13 +131,6 @@ uart_control_write(uint32_t v) } static int -uart_writable(void) -{ - - return ((uart_control_read() & ALTERA_JTAG_UART_CONTROL_WSPACE) != 0); -} - -static int uart_readable(void) { uint32_t v; diff --git a/stand/mips/beri/common/cfi.c b/stand/mips/beri/common/cfi.c index a6798f4..cd788de 100644 --- a/stand/mips/beri/common/cfi.c +++ b/stand/mips/beri/common/cfi.c @@ -30,7 +30,7 @@ * $FreeBSD$ */ -#include "util.h" +#include "stand.h" #include "mips.h" #include "cfi.h" diff --git a/stand/mips/beri/common/sdcard.c b/stand/mips/beri/common/sdcard.c index e50f4e7..4de3db4 100644 --- a/stand/mips/beri/common/sdcard.c +++ b/stand/mips/beri/common/sdcard.c @@ -109,10 +109,10 @@ ALTERA_SDCARD_RR1_COMMANDCRCFAILED | ALTERA_SDCARD_RR1_ADDRESSMISALIGNED |\ ALTERA_SDCARD_RR1_ADDRBLOCKRANGE) -extern void __cheri_sdcard_vaddr__; +extern uint8_t __cheri_sdcard_vaddr__[]; #define ALTERA_SDCARD_PTR(type, offset) \ - (volatile type *)((uint8_t *)&__cheri_sdcard_vaddr__ + (offset)) + (volatile type *)(&__cheri_sdcard_vaddr__[(offset)]) static __inline uint16_t altera_sdcard_read_uint16(u_int offset) diff --git a/stand/mips/beri/loader/Makefile b/stand/mips/beri/loader/Makefile index f232489..46b927f 100644 --- a/stand/mips/beri/loader/Makefile +++ b/stand/mips/beri/loader/Makefile @@ -67,7 +67,7 @@ SRCS+= altera_jtag_uart.c \ # Since we don't have a backward compatibility issue, default to this on BERI. CFLAGS+= -DBOOT_PROMPT_123 -HELP_FILES+= help.mips +HELP_FILES= ${.CURDIR}/help.mips # Always add MI sources .include "${BOOTSRC}/loader.mk" @@ -85,8 +85,7 @@ CFLAGS+= -G0 \ -mno-abicalls \ -g -LDFLAGS= -nostdlib \ - -static \ +LDFLAGS+= -static \ -T ${.CURDIR}/loader.ldscript \ -L${.CURDIR} \ -e __start diff --git a/stand/mips/beri/loader/devicename.c b/stand/mips/beri/loader/devicename.c index 4a2c273..968c946 100644 --- a/stand/mips/beri/loader/devicename.c +++ b/stand/mips/beri/loader/devicename.c @@ -88,7 +88,7 @@ beri_arch_parsedev(struct disk_devdesc **dev, const char *devspec, struct disk_devdesc *idev; struct devsw *dv; int i, unit, err; - const char *cp; + char *cp; const char *np; /* minimum length check */ @@ -130,8 +130,10 @@ beri_arch_parsedev(struct disk_devdesc **dev, const char *devspec, goto fail; } } else { - cp = np; + err = EUNIT; + goto fail; } + if (*cp && (*cp != ':')) { err = EINVAL; goto fail; diff --git a/stand/mips/beri/loader/exec.c b/stand/mips/beri/loader/exec.c index 382b6a1..68e149d 100644 --- a/stand/mips/beri/loader/exec.c +++ b/stand/mips/beri/loader/exec.c @@ -119,7 +119,7 @@ beri_elf64_exec(struct preloaded_file *fp) * least bootinfop. */ (*entry)(boot2_argc, (register_t)boot2_argv, (register_t)boot2_envv, - &bootinfo); + (register_t)&bootinfo); panic("exec returned"); } diff --git a/stand/mips/beri/loader/loader.h b/stand/mips/beri/loader/loader.h index e4152e7..4005caa 100644 --- a/stand/mips/beri/loader/loader.h +++ b/stand/mips/beri/loader/loader.h @@ -41,6 +41,7 @@ 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 **); diff --git a/stand/mips/beri/loader/main.c b/stand/mips/beri/loader/main.c index 2d201d8..086b550 100644 --- a/stand/mips/beri/loader/main.c +++ b/stand/mips/beri/loader/main.c @@ -78,8 +78,8 @@ struct console *consoles[] = { NULL }; -extern void __bss_start, __bss_end; -extern void __heap_start, __heap_end; +extern uint8_t __bss_start, __bss_end; +extern uint8_t __heap_start, __heap_end; static int __elfN(exec)(struct preloaded_file *fp) @@ -108,14 +108,14 @@ 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, (uintptr_t)&__bss_end - (uintptr_t)&__bss_start); + 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((void *)&__heap_start, (void *)&__heap_end); + setheap(&__heap_start, &__heap_end); /* * Pick up console settings from boot2; probe console. @@ -149,7 +149,7 @@ main(int argc, char *argv[], char *envv[], struct bootinfo *bootinfop) printf("bootpath=\"%s\"\n", bootpath); #endif - interact(NULL); + interact(); return (0); } @@ -193,6 +193,7 @@ abort(void) printf("error: loader abort\n"); while (1); + __unreachable(); } void @@ -201,6 +202,7 @@ exit(int code) printf("error: loader exit\n"); while (1); + __unreachable(); } void @@ -209,6 +211,7 @@ longjmperror(void) printf("error: loader longjmp error\n"); while (1); + __unreachable(); } time_t diff --git a/stand/mips/uboot/Makefile b/stand/mips/uboot/Makefile index c605af1..4a7350a 100644 --- a/stand/mips/uboot/Makefile +++ b/stand/mips/uboot/Makefile @@ -24,7 +24,7 @@ UBLDR_LOADADDR?= 0xffffffff80800000 # Architecture-specific loader code SRCS= start.S conf.c vers.c -HELP_FILES+= help.uboot ${BOOTSRC}/fdt/help.fdt +HELP_FILES= ${.CURDIR}/help.uboot ${BOOTSRC}/fdt/help.fdt # Always add MI sources .include "${BOOTSRC}/loader.mk" diff --git a/stand/mips/uboot/conf.c b/stand/mips/uboot/conf.c index 3579b6a..f711a8c 100644 --- a/stand/mips/uboot/conf.c +++ b/stand/mips/uboot/conf.c @@ -105,6 +105,7 @@ abort(void) printf("error: loader abort\n"); while (1); + __unreachable(); } void @@ -113,6 +114,7 @@ longjmperror(void) printf("error: loader longjmp error\n"); while (1); + __unreachable(); } int debug = 1; diff --git a/stand/ofw/common/main.c b/stand/ofw/common/main.c index 3c0bbdf..128542c9 100644 --- a/stand/ofw/common/main.c +++ b/stand/ofw/common/main.c @@ -157,7 +157,7 @@ main(int (*openfirm)(void *)) archsw.arch_readin = ofw_readin; archsw.arch_autoload = ofw_autoload; - interact(NULL); /* doesn't return */ + interact(); /* doesn't return */ OF_exit(); diff --git a/stand/ofw/libofw/elf_freebsd.c b/stand/ofw/libofw/elf_freebsd.c index 80ece7e..a2e48a7 100644 --- a/stand/ofw/libofw/elf_freebsd.c +++ b/stand/ofw/libofw/elf_freebsd.c @@ -32,6 +32,9 @@ __FBSDID("$FreeBSD$"); #include <machine/metadata.h> #include <machine/elf.h> +#if defined(__powerpc__) +#include <machine/md_var.h> +#endif #include <stand.h> @@ -88,10 +91,10 @@ __elfN(ofw_exec)(struct preloaded_file *fp) if (dtbp != 0) { OF_quiesce(); ((int (*)(u_long, u_long, u_long, void *, u_long))entry)(dtbp, 0, 0, - mdp, sizeof(mdp)); + (void *)mdp, sizeof(mdp)); } else { OF_chain((void *)reloc, end - (char *)reloc, (void *)entry, - (void *)mdp, sizeof(mdp)); + (void *)mdp, 0xfb5d104d); } panic("exec returned"); diff --git a/stand/ofw/libofw/libofw.h b/stand/ofw/libofw/libofw.h index 87e9095..b8c4014 100644 --- a/stand/ofw/libofw/libofw.h +++ b/stand/ofw/libofw/libofw.h @@ -67,6 +67,10 @@ struct file_format; int ofw_elf_loadfile(char *, vm_offset_t, struct preloaded_file **); int ofw_elf_exec(struct preloaded_file *); +/* MD code implementing MI interfaces */ +vm_offset_t md_load(char *args, vm_offset_t *modulep, vm_offset_t *dtb); +vm_offset_t md_load64(char *args, vm_offset_t *modulep, vm_offset_t *dtb); + extern struct file_format ofw_elf; #ifdef __powerpc__ extern struct file_format ofw_elf64; diff --git a/stand/ofw/libofw/openfirm.c b/stand/ofw/libofw/openfirm.c index 1ccae60..84e81d9 100644 --- a/stand/ofw/libofw/openfirm.c +++ b/stand/ofw/libofw/openfirm.c @@ -242,7 +242,7 @@ OF_instance_to_package(ihandle_t instance) /* Get the length of a property of a package. */ int -OF_getproplen(phandle_t package, char *propname) +OF_getproplen(phandle_t package, const char *propname) { static struct { cell_t name; @@ -266,7 +266,7 @@ OF_getproplen(phandle_t package, char *propname) /* Get the value of a property of a package. */ int -OF_getprop(phandle_t package, char *propname, void *buf, int buflen) +OF_getprop(phandle_t package, const char *propname, void *buf, int buflen) { static struct { cell_t name; @@ -294,7 +294,7 @@ OF_getprop(phandle_t package, char *propname, void *buf, int buflen) /* Get the next property of a package. */ int -OF_nextprop(phandle_t package, char *previous, char *buf) +OF_nextprop(phandle_t package, const char *previous, char *buf) { static struct { cell_t name; @@ -321,7 +321,7 @@ OF_nextprop(phandle_t package, char *previous, char *buf) /* Set the value of a property of a package. */ /* XXX Has a bug on FirePower */ int -OF_setprop(phandle_t package, char *propname, void *buf, int len) +OF_setprop(phandle_t package, const char *propname, void *buf, int len) { static struct { cell_t name; diff --git a/stand/ofw/libofw/openfirm.h b/stand/ofw/libofw/openfirm.h index 9fe77c6..b83cf4b 100644 --- a/stand/ofw/libofw/openfirm.h +++ b/stand/ofw/libofw/openfirm.h @@ -89,10 +89,10 @@ phandle_t OF_peer(phandle_t); phandle_t OF_child(phandle_t); phandle_t OF_parent(phandle_t); phandle_t OF_instance_to_package(ihandle_t); -int OF_getproplen(phandle_t, char *); -int OF_getprop(phandle_t, char *, void *, int); -int OF_nextprop(phandle_t, char *, char *); -int OF_setprop(phandle_t, char *, void *, int); +int OF_getproplen(phandle_t, const char *); +int OF_getprop(phandle_t, const char *, void *, int); +int OF_nextprop(phandle_t, const char *, char *); +int OF_setprop(phandle_t, const char *, void *, int); int OF_canon(const char *, char *, int); phandle_t OF_finddevice(const char *); int OF_instance_to_path(ihandle_t, char *, int); diff --git a/stand/ofw/libofw/ppc64_elf_freebsd.c b/stand/ofw/libofw/ppc64_elf_freebsd.c index b411da4..9132e9d 100644 --- a/stand/ofw/libofw/ppc64_elf_freebsd.c +++ b/stand/ofw/libofw/ppc64_elf_freebsd.c @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include <machine/metadata.h> #include <machine/elf.h> +#include <machine/md_var.h> #include <stand.h> @@ -81,7 +82,7 @@ ppc64_ofw_elf_exec(struct preloaded_file *fp) if ((e->e_flags & 3) == 2) entry = e->e_entry; else - entry = *(uint64_t *)e->e_entry; + entry = *(uint64_t *)(intptr_t)e->e_entry; if ((error = md_load64(fp->f_args, &mdp, &dtbp)) != 0) return (error); @@ -93,11 +94,11 @@ ppc64_ofw_elf_exec(struct preloaded_file *fp) if (dtbp != 0) { OF_quiesce(); - ((int (*)(u_long, u_long, u_long, void *, u_long))entry)(dtbp, 0, 0, - mdp, sizeof(mdp)); + ((int (*)(u_long, u_long, u_long, void *, u_long))entry)(dtbp, + 0, 0, (void *)mdp, 0xfb5d104d); } else { OF_chain((void *)reloc, end - (char *)reloc, (void *)entry, - (void *)mdp, sizeof(mdp)); + (void *)mdp, 0xfb5d104d); } panic("exec returned"); diff --git a/stand/powerpc/Makefile b/stand/powerpc/Makefile index 969eee8..c8bbb17 100644 --- a/stand/powerpc/Makefile +++ b/stand/powerpc/Makefile @@ -3,9 +3,6 @@ .include <bsd.init.mk> SUBDIR= boot1.chrp ofw uboot -.if ${MACHINE_ARCH} != "powerpcspe" -SUBDIR+= ps3 -.endif .if ${MK_FDT} == "yes" SUBDIR+= kboot .endif diff --git a/stand/powerpc/boot1.chrp/Makefile b/stand/powerpc/boot1.chrp/Makefile index ee32ff5..d865248 100644 --- a/stand/powerpc/boot1.chrp/Makefile +++ b/stand/powerpc/boot1.chrp/Makefile @@ -2,8 +2,6 @@ .include <bsd.init.mk> -SSP_CFLAGS= - PROG= boot1.elf NEWVERSWHAT= "Open Firmware boot block" ${MACHINE_ARCH} INSTALLFLAGS= -b @@ -13,7 +11,7 @@ SRCS= boot1.c ashldi3.c syncicache.c MAN= -CFLAGS= -I${LDRSRC} -I${SYSDIR} -I${SASRC} -D_STANDALONE +CFLAGS+=-I${LDRSRC} LDFLAGS=-nostdlib -static -Wl,-N .PATH: ${SYSDIR}/libkern ${SRCTOP}/lib/libc/powerpc/gen ${.CURDIR} @@ -34,7 +32,5 @@ boot1.hfs: boot1.elf bootinfo.txt CLEANFILES+= boot1.hfs -boot1.o: ${SASRC}/ufsread.c - .include <bsd.prog.mk> diff --git a/stand/powerpc/boot1.chrp/boot1.c b/stand/powerpc/boot1.chrp/boot1.c index 8de8e9f..e73186a 100644 --- a/stand/powerpc/boot1.chrp/boot1.c +++ b/stand/powerpc/boot1.chrp/boot1.c @@ -22,6 +22,7 @@ __FBSDID("$FreeBSD$"); #include <sys/dirent.h> #include <machine/elf.h> #include <machine/stdarg.h> +#include <machine/md_var.h> #include "paths.h" @@ -75,8 +76,6 @@ static int __sputc(char c, void *arg); static char *__uitoa(char *buf, u_int val, int base); static char *__ultoa(char *buf, u_long val, int base); -void __syncicache(void *, int); - /* * Open Firmware interface functions */ diff --git a/stand/powerpc/kboot/Makefile b/stand/powerpc/kboot/Makefile index b51a068..e91421d 100644 --- a/stand/powerpc/kboot/Makefile +++ b/stand/powerpc/kboot/Makefile @@ -28,7 +28,6 @@ SRCS+= ucmpdi2.c CFLAGS+= -mcpu=powerpc64 # Always add MI sources -HELP_FILES= # Disable .include "${BOOTSRC}/loader.mk" .PATH: ${SYSDIR}/libkern @@ -45,6 +44,4 @@ CFLAGS+= -Wa,-mppc64bridge DPADD= ${LIBFICL} ${LIBOFW} ${LIBFDT} ${LIBSA} LDADD= ${LIBFICL} ${LIBOFW} ${LIBFDT} ${LIBSA} -HELP_FILES+= ${FDTSRC}/help.fdt - .include <bsd.prog.mk> diff --git a/stand/powerpc/kboot/host_syscall.h b/stand/powerpc/kboot/host_syscall.h index 0d47bd5..349c54e 100644 --- a/stand/powerpc/kboot/host_syscall.h +++ b/stand/powerpc/kboot/host_syscall.h @@ -33,7 +33,7 @@ ssize_t host_read(int fd, void *buf, size_t nbyte); ssize_t host_write(int fd, const void *buf, size_t nbyte); ssize_t host_seek(int fd, int64_t offset, int whence); -int host_open(char *path, int flags, int mode); +int host_open(const char *path, int flags, int mode); int host_close(int fd); void *host_mmap(void *addr, size_t len, int prot, int flags, int fd, int); #define host_getmem(size) host_mmap(0, size, 3 /* RW */, 0x22 /* ANON */, -1, 0); diff --git a/stand/powerpc/kboot/hostdisk.c b/stand/powerpc/kboot/hostdisk.c index 22f5406..26d3959 100644 --- a/stand/powerpc/kboot/hostdisk.c +++ b/stand/powerpc/kboot/hostdisk.c @@ -94,7 +94,7 @@ hostdisk_open(struct open_file *f, ...) if (desc->d_unit <= 0) { printf("hostdisk_open: couldn't open %s: %d\n", - desc->d_opendata, desc->d_unit); + (char *)desc->d_opendata, desc->d_unit); return (ENOENT); } diff --git a/stand/powerpc/kboot/kbootfdt.c b/stand/powerpc/kboot/kbootfdt.c index 5ab3c3d..67a2082 100644 --- a/stand/powerpc/kboot/kbootfdt.c +++ b/stand/powerpc/kboot/kbootfdt.c @@ -119,7 +119,7 @@ fdt_linux_fixups(void *fdtp) offset = fdt_path_offset(fdtp, "/ibm,opal"); if (offset > 0) { - uint64_t *base, *size; + const uint64_t *base, *size; base = fdt_getprop(fdtp, offset, "opal-base-address", &len); size = fdt_getprop(fdtp, offset, "opal-runtime-size", @@ -130,7 +130,7 @@ fdt_linux_fixups(void *fdtp) } offset = fdt_path_offset(fdtp, "/rtas"); if (offset > 0) { - uint32_t *base, *size; + const uint32_t *base, *size; base = fdt_getprop(fdtp, offset, "linux,rtas-base", &len); size = fdt_getprop(fdtp, offset, "rtas-size", &len); if (base != NULL && size != NULL) diff --git a/stand/powerpc/kboot/main.c b/stand/powerpc/kboot/main.c index 7a24c16..cbd1161 100644 --- a/stand/powerpc/kboot/main.c +++ b/stand/powerpc/kboot/main.c @@ -122,7 +122,7 @@ main(int argc, const char **argv) setenv("loaddev", bootdev, 1); setenv("LINES", "24", 1); - interact(NULL); /* doesn't return */ + interact(); /* doesn't return */ return (0); } @@ -130,7 +130,8 @@ main(int argc, const char **argv) void exit(int code) { - /* XXX: host_exit */ + while (1); /* XXX: host_exit */ + __unreachable(); } void diff --git a/stand/powerpc/kboot/ppc64_elf_freebsd.c b/stand/powerpc/kboot/ppc64_elf_freebsd.c index 22fa7b5..987565e 100644 --- a/stand/powerpc/kboot/ppc64_elf_freebsd.c +++ b/stand/powerpc/kboot/ppc64_elf_freebsd.c @@ -46,6 +46,8 @@ extern size_t szkerneltramp; extern int nkexec_segments; extern void * loaded_segments; +vm_offset_t md_load64(char *args, vm_offset_t *modulep, vm_offset_t *dtb); + int ppc64_elf_loadfile(char *filename, u_int64_t dest, struct preloaded_file **result) @@ -96,7 +98,7 @@ ppc64_elf_exec(struct preloaded_file *fp) trampoline[3] = dtb; trampoline[6] = mdp; - trampoline[7] = sizeof(mdp); + trampoline[7] = 0xfb5d104d; printf("Kernel entry at %#jx (%#x) ...\n", e->e_entry, trampoline[2]); printf("DTB at %#x, mdp at %#x\n", dtb, mdp); diff --git a/stand/powerpc/ofw/Makefile b/stand/powerpc/ofw/Makefile index b28665d..e24b7af 100644 --- a/stand/powerpc/ofw/Makefile +++ b/stand/powerpc/ofw/Makefile @@ -27,7 +27,7 @@ SRCS+= ucmpdi2.c SRCS+= ofwfdt.c .endif -HELP_FILES+= ${FDTSRC}/help.fdt +HELP_FILES= ${FDTSRC}/help.fdt # Always add MI sources .include "${BOOTSRC}/loader.mk" diff --git a/stand/powerpc/ofw/start.c b/stand/powerpc/ofw/start.c index 911a2ec..5e0744b 100644 --- a/stand/powerpc/ofw/start.c +++ b/stand/powerpc/ofw/start.c @@ -67,6 +67,8 @@ _start: \n\ 2: b startup \n\ "); +void main(int (*openfirm)(void *)); + void startup(void *vpd, int res, int (*openfirm)(void *), char *arg, int argl) { diff --git a/stand/powerpc/ps3/Makefile b/stand/powerpc/ps3/Makefile deleted file mode 100644 index fc6ec9c..0000000 --- a/stand/powerpc/ps3/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -# $FreeBSD$ - -LOADER_UFS_SUPPORT?= yes -LOADER_CD9660_SUPPORT?= yes -LOADER_EXT2FS_SUPPORT?= yes -LOADER_NET_SUPPORT?= yes -LOADER_NFS_SUPPORT?= yes -LOADER_TFTP_SUPPORT?= no -LOADER_GZIP_SUPPORT?= yes -LOADER_BZIP2_SUPPORT?= no - -.include <bsd.init.mk> -MK_SSP= no -MAN= - -PROG= loader.ps3 -NEWVERSWHAT= "Playstation 3 loader" ${MACHINE_ARCH} -INSTALLFLAGS= -b - -# Architecture-specific loader code -SRCS= start.S conf.c metadata.c vers.c main.c devicename.c ppc64_elf_freebsd.c -SRCS+= lv1call.S ps3cons.c font.h ps3mmu.c ps3net.c ps3repo.c \ - ps3stor.c ps3disk.c ps3cdrom.c -SRCS+= ucmpdi2.c - -CFLAGS+= -mcpu=powerpc64 - -# Always add MI sources -HELP_FILES= # Disable -.include "${BOOTSRC}/loader.mk" -.PATH: ${SYSDIR}/libkern - -CFLAGS+= -Wall -DAIM -# load address. set in linker script -RELOC?= 0x0 -CFLAGS+= -DRELOC=${RELOC} - -LDFLAGS= -nostdlib -static -T ${.CURDIR}/ldscript.powerpc - -DPADD= ${LIBFICL} ${LIBOFW} ${LIBSA} -LDADD= ${LIBFICL} ${LIBOFW} ${LIBSA} - -SC_DFLT_FONT=cp437 - -font.h: - uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x16.fnt && file2c 'u_char dflt_font_16[16*256] = {' '};' < ${SC_DFLT_FONT}-8x16 > font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x14.fnt && file2c 'u_char dflt_font_14[14*256] = {' '};' < ${SC_DFLT_FONT}-8x14 >> font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x8.fnt && file2c 'u_char dflt_font_8[8*256] = {' '};' < ${SC_DFLT_FONT}-8x8 >> font.h - -.include <bsd.prog.mk> diff --git a/stand/powerpc/ps3/conf.c b/stand/powerpc/ps3/conf.c deleted file mode 100644 index 3a5ae4c..0000000 --- a/stand/powerpc/ps3/conf.c +++ /dev/null @@ -1,123 +0,0 @@ -/*- - * Copyright (C) 1999 Michael Smith <msmith@freebsd.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, 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 <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <stand.h> -#include "bootstrap.h" - -#if defined(LOADER_NET_SUPPORT) -#include "dev_net.h" -#endif - -extern struct devsw ps3disk; -extern struct devsw ps3cdrom; - -/* - * We could use linker sets for some or all of these, but - * then we would have to control what ended up linked into - * the bootstrap. So it's easier to conditionalise things - * here. - * - * XXX rename these arrays to be consistent and less namespace-hostile - */ - -/* Exported for libstand */ -struct devsw *devsw[] = { -#if defined(LOADER_CD9660_SUPPORT) - &ps3cdrom, -#endif -#if defined(LOADER_DISK_SUPPORT) - &ps3disk, -#endif -#if defined(LOADER_NET_SUPPORT) - &netdev, -#endif - NULL -}; - -struct fs_ops *file_system[] = { -#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 -}; - -extern struct netif_driver ps3net; - -struct netif_driver *netif_drivers[] = { -#if defined(LOADER_NET_SUPPORT) - &ps3net, -#endif - NULL, -}; - -/* Exported for PowerPC only */ -/* - * Sort formats so that those that can detect based on arguments - * rather than reading the file go first. - */ - -extern struct file_format ppc_elf64; - -struct file_format *file_formats[] = { - &ppc_elf64, - NULL -}; - -/* - * Consoles - */ -extern struct console ps3console; - -struct console *consoles[] = { - &ps3console, - NULL -}; - -/* - * reloc - our load address - */ -vm_offset_t reloc = RELOC; diff --git a/stand/powerpc/ps3/devicename.c b/stand/powerpc/ps3/devicename.c deleted file mode 100644 index 041f853..0000000 --- a/stand/powerpc/ps3/devicename.c +++ /dev/null @@ -1,238 +0,0 @@ -/*- - * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, 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 <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/disklabel.h> - -#include <stand.h> -#include <string.h> - -#include "bootstrap.h" -#include "ps3.h" -#include "ps3devdesc.h" - -static int ps3_parsedev(struct ps3_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 -ps3_getdev(void **vdev, const char *devspec, const char **path) -{ - struct ps3_devdesc **dev = (struct ps3_devdesc **)vdev; - int rv = 0; - - /* - * 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)) { - rv = ps3_parsedev(dev, getenv("currdev"), NULL); - - if (rv == 0 && path != NULL) - *path = devspec; - return(rv); - } - - /* - * Try to parse the device name off the beginning of the devspec. - */ - return (ps3_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<unit>[<partition>]: - * - */ -static int -ps3_parsedev(struct ps3_devdesc **dev, const char *devspec, const char **path) -{ - struct ps3_devdesc *idev; - struct devsw *dv; - char *cp; - const char *np; - int i, unit, pnum, ptype, err; - - /* 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 ps3_devdesc)); - err = 0; - np = (devspec + strlen(dv->dv_name)); - - switch(dv->dv_type) { - case DEVT_NONE: - break; - - case DEVT_DISK: - unit = -1; - pnum = -1; - ptype = -1; - if (*np && (*np != ':')) { - /* next comes the unit number */ - unit = strtol(np, &cp, 10); - if (cp == np) { - err = EUNIT; - goto fail; - } - if (*cp && (*cp != ':')) { - /* get partition */ - if (*cp == 'p' && *(cp + 1) && - *(cp + 1) != ':') { - pnum = strtol(cp + 1, &cp, 10); - ptype = PTYPE_GPT; - } else { - pnum = *cp - 'a'; - ptype = PTYPE_BSDLABEL; - if ((pnum < 0) || - (pnum >= MAXPARTITIONS)) { - err = EPART; - goto fail; - } - cp++; - } - } - } - if (*cp && (*cp != ':')) { - err = EINVAL; - goto fail; - } - - idev->d_unit = unit; - idev->d_disk.pnum = pnum; - idev->d_disk.ptype = ptype; - idev->d_disk.data = NULL; - if (path != NULL) - *path = (*cp == 0) ? cp : cp + 1; - break; - - case DEVT_NET: - case DEVT_CD: - /* - * PS3 only has one network interface (well, two, but - * netbooting over wireless is not something I'm going - * to worry about. - */ - - idev->d_unit = 0; - break; - - default: - err = EINVAL; - goto fail; - } - idev->d_dev = dv; - idev->d_type = dv->dv_type; - if (dev == NULL) { - free(idev); - } else { - *dev = idev; - } - return (0); - -fail: - free(idev); - return (err); -} - - -char * -ps3_fmtdev(void *vdev) -{ - struct ps3_devdesc *dev = (struct ps3_devdesc *)vdev; - char *cp; - static char buf[128]; - - switch(dev->d_type) { - case DEVT_NONE: - strcpy(buf, "(no device)"); - break; - - case DEVT_DISK: - cp = buf; - cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_unit); - if (dev->d_kind.disk.pnum >= 0) { - if (dev->d_kind.disk.ptype == PTYPE_BSDLABEL) - cp += sprintf(cp, "%c", - dev->d_kind.disk.pnum + 'a'); - else if (dev->d_kind.disk.ptype == PTYPE_GPT) - cp += sprintf(cp, "p%i", - dev->d_kind.disk.pnum); - } - - strcat(cp, ":"); - break; - - case DEVT_NET: - case DEVT_CD: - sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit); - break; - } - return(buf); -} - -/* - * Set currdev to suit the value being supplied in (value). - */ -int -ps3_setcurrdev(struct env_var *ev, int flags, const void *value) -{ - struct ps3_devdesc *ncurr; - int rv; - - if ((rv = ps3_parsedev(&ncurr, value, NULL)) != 0) - return (rv); - free(ncurr); - env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); - return (0); -} diff --git a/stand/powerpc/ps3/ldscript.powerpc b/stand/powerpc/ps3/ldscript.powerpc deleted file mode 100644 index 12f3e75..0000000 --- a/stand/powerpc/ps3/ldscript.powerpc +++ /dev/null @@ -1,111 +0,0 @@ -/* $FreeBSD$ */ - -OUTPUT_FORMAT("elf32-powerpc-freebsd", "elf32-powerpc-freebsd", - "elf32-powerpc-freebsd") -OUTPUT_ARCH(powerpc:common) -ENTRY(_start) -SEARCH_DIR(/usr/lib); -PROVIDE (__stack = 0); -SECTIONS -{ - /* Read-only sections, merged into text segment: */ - . = 0x0; - .text : - { - *(.text) - /* .gnu.warning sections are handled specially by elf32.em. */ - *(.gnu.warning) - *(.gnu.linkonce.t*) - } =0 - _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.sbss : { *(.rela.sbss) } - .rela.sbss2 : { *(.rela.sbss2) } - .text : - { - *(.text) - /* .gnu.warning sections are handled specially by elf32.em. */ - *(.gnu.warning) - *(.gnu.linkonce.t*) - } =0 - _etext = .; - PROVIDE (etext = .); - .init : { *(.init) } =0 - .fini : { *(.fini) } =0 - .rodata : { *(.rodata) *(.gnu.linkonce.r*) } - .rodata1 : { *(.rodata1) } - .sbss2 : { *(.sbss2) } - /* Adjust the address for the data segment to the next page up. */ - . = ((. + 0x1000) & ~(0x1000 - 1)); - .data : - { - *(.data) - *(.gnu.linkonce.d*) - CONSTRUCTORS - } - .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_ = .); - _edata = .; - PROVIDE (edata = .); - .sbss : - { - PROVIDE (__sbss_start = .); - *(.sbss) - *(.scommon) - *(.dynsbss) - PROVIDE (__sbss_end = .); - } - .plt : { *(.plt) } - .bss : - { - PROVIDE (__bss_start = .); - *(.dynbss) - *(.bss) - *(COMMON) - } - . = ALIGN(4096); - _end = . ; - PROVIDE (end = .); -} - diff --git a/stand/powerpc/ps3/lv1call.S b/stand/powerpc/ps3/lv1call.S deleted file mode 100644 index a399a9c..0000000 --- a/stand/powerpc/ps3/lv1call.S +++ /dev/null @@ -1,346 +0,0 @@ -/*- - * Copyright (C) 2010 Nathan Whitehorn - * Copyright (C) 2011 glevand (geoffrey.levand@mail.ru) - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -/* Hypercall stubs. Note: this is all a hack and should die. */ - -#define hc .long 0x44000022 - -#define LD64_IM(r, highest, higher, high, low) \ - lis r,highest; \ - addi r,r,higher; \ - sldi r,r,32; \ - addis r,r,high; \ - addi r,r,low; - -#define SIMPLE_HVCALL(x, c) \ -.global x; \ -x: \ - mflr %r0; \ - stw %r0,4(%r1); \ - clrldi %r3,%r3,32; \ - clrldi %r4,%r4,32; \ - clrldi %r5,%r5,32; \ - clrldi %r6,%r6,32; \ - clrldi %r7,%r7,32; \ - clrldi %r8,%r8,32; \ - clrldi %r9,%r9,32; \ - clrldi %r10,%r10,32; \ - li %r11,c; \ - hc; \ - extsw %r3,%r3; \ - lwz %r0,4(%r1); \ - mtlr %r0; \ - blr - -SIMPLE_HVCALL(lv1_open_device, 170) -SIMPLE_HVCALL(lv1_close_device, 171) -SIMPLE_HVCALL(lv1_gpu_open, 210) -SIMPLE_HVCALL(lv1_gpu_context_attribute, 225) -SIMPLE_HVCALL(lv1_panic, 255) -SIMPLE_HVCALL(lv1_net_start_tx_dma, 187) -SIMPLE_HVCALL(lv1_net_stop_tx_dma, 188) -SIMPLE_HVCALL(lv1_net_start_rx_dma, 189) -SIMPLE_HVCALL(lv1_net_stop_rx_dma, 190) - -.global lv1_get_physmem -lv1_get_physmem: - mflr %r0 - stw %r0,4(%r1) - stw %r3,-8(%r1) /* Address for maxmem */ - - li %r11,69 /* Get PU ID */ - hc - std %r4,-16(%r1) - - li %r11,74 /* Get LPAR ID */ - hc - std %r4,-24(%r1) - - ld %r3,-24(%r1) - LD64_IM(%r4,0x0000,0x0000,0x6269,0x0000 /* "bi" */) - LD64_IM(%r5,0x7075,0x0000,0x0000,0x0000 /* "pu" */) - ld %r6,-16(%r1) - LD64_IM(%r7,0x726d,0x5f73,0x697a,0x6500 /* "rm_size" */) - li %r11,91 - hc - extsw %r3,%r3 - - lwz %r5,-8(%r1) - std %r4,0(%r5) - - lwz %r0,4(%r1) - mtlr %r0 - blr - -.global lv1_setup_address_space -lv1_setup_address_space: - mflr %r0 - stw %r0,4(%r1) - - stw %r3,-4(%r1) - stw %r4,-8(%r1) - - li %r3,18 /* PT size: log2(256 KB) */ - li %r4,2 /* Two page sizes */ - li %r5,24 /* Page sizes: (24 << 56) | (16 << 48) */ - sldi %r5,%r5,24 - li %r6,16 - sldi %r6,%r6,16 - or %r5,%r5,%r6 - sldi %r5,%r5,32 - - li %r11,2 /* lv1_construct_virtual_address_space */ - hc - - lwz %r6,-4(%r1) - lwz %r7,-8(%r1) - std %r4,0(%r6) - std %r5,0(%r7) - - /* AS_ID in r4 */ - mr %r3,%r4 - li %r11,7 /* lv1_select_virtual_address_space */ - hc - extsw %r3,%r3 - - lwz %r0,4(%r1) - mtlr %r0 - blr - -.global lv1_insert_pte -lv1_insert_pte: - mflr %r0 - stw %r0,4(%r1) - - mr %r11,%r4 /* Save R4 */ - - clrldi %r3,%r3,32 - clrldi %r7,%r5,32 - - sldi %r4,%r3,3 /* Convert ptegidx into base PTE slot */ - li %r3,0 /* Current address space */ - ld %r5,0(%r11) - ld %r6,8(%r11) - li %r8,0 /* No other flags */ - - li %r11,158 - hc - extsw %r3,%r3 - - lwz %r0,4(%r1) - mtlr %r0 - blr - -.global lv1_gpu_context_allocate -lv1_gpu_context_allocate: - mflr %r0 - stw %r0,4(%r1) - stw %r7,-4(%r1) - - sldi %r3,%r3,32 - clrldi %r4,%r4,32 - or %r3,%r3,%r4 - clrldi %r4,%r5,32 - clrldi %r5,%r6,32 - - li %r11,217 - hc - extsw %r3,%r3 - - lwz %r7,-4(%r1) - std %r4,0(%r7) - - lwz %r0,4(%r1) - mtlr %r0 - blr - -.global lv1_gpu_memory_allocate -lv1_gpu_memory_allocate: - mflr %r0 - stw %r0,4(%r1) - stw %r8,-4(%r1) - stw %r9,-8(%r1) - - li %r11,214 - hc - extsw %r3,%r3 - - lwz %r8,-4(%r1) - lwz %r9,-8(%r1) - std %r4,0(%r8) - std %r5,0(%r9) - - lwz %r0,4(%r1) - mtlr %r0 - blr - -.global lv1_net_control -lv1_net_control: - mflr %r0 - stw %r0,4(%r1) - stw %r9,-4(%r1) - - li %r11,194 - hc - extsw %r3,%r3 - - lwz %r8,-4(%r1) - std %r4,0(%r8) - - lwz %r0,4(%r1) - mtlr %r0 - blr - -.global lv1_setup_dma -lv1_setup_dma: - mflr %r0 - stw %r0,4(%r1) - stw %r3,-4(%r1) - stw %r4,-8(%r1) - stw %r5,-12(%r1) - - lwz %r3,-4(%r1) - lwz %r4,-8(%r1) - lis %r5,0x0800 /* 128 MB */ - li %r6,24 /* log2(IO_PAGESIZE) */ - li %r7,0 /* flags */ - li %r11,174 /* lv1_allocate_device_dma_region */ - hc - extsw %r3,%r3 - cmpdi %r3,0 - bne 1f - std %r4,-24(%r1) - - lwz %r3,-4(%r1) - lwz %r4,-8(%r1) - li %r5,0 - ld %r6,-24(%r1) - lis %r7,0x0800 /* 128 MB */ - lis %r8,0xf800 /* flags */ - sldi %r8,%r8,32 - li %r11,176 /* lv1_map_device_dma_region */ - hc - extsw %r3,%r3 - - lwz %r9,-12(%r1) - ld %r6,-24(%r1) - std %r6,0(%r9) - -1: lwz %r0,4(%r1) - mtlr %r0 - blr - -.global lv1_get_repository_node_value -lv1_get_repository_node_value: - mflr %r0 - stw %r0,4(%r1) - - sldi %r3,%r3,32 - clrldi %r4,%r4,32 - or %r3,%r3,%r4 - sldi %r4,%r5,32 - clrldi %r5,%r6,32 - or %r4,%r4,%r5 - sldi %r5,%r7,32 - clrldi %r6,%r8,32 - or %r5,%r5,%r6 - sldi %r6,%r9,32 - clrldi %r7,%r10,32 - or %r6,%r6,%r7 - lwz %r7,8(%r1) - lwz %r8,12(%r1) - sldi %r7,%r7,32 - or %r7,%r7,%r8 - - li %r11,91 - hc - extsw %r3,%r3 - - lwz %r6,16(%r1) - std %r4,0(%r6) - lwz %r6,20(%r1) - std %r5,0(%r6) - - lwz %r0,4(%r1) - mtlr %r0 - blr - -.global lv1_storage_read -lv1_storage_read: - mflr %r0 - stw %r0,4(%r1) - - sldi %r3,%r3,32 - clrldi %r4,%r4,32 - or %r3,%r3,%r4 - sldi %r4,%r5,32 - clrldi %r5,%r6,32 - or %r4,%r4,%r5 - sldi %r5,%r7,32 - clrldi %r6,%r8,32 - or %r5,%r5,%r6 - sldi %r6,%r9,32 - clrldi %r7,%r10,32 - or %r6,%r6,%r7 - ld %r7,8(%r1) - ld %r8,16(%r1) - - li %r11,245 - hc - extsw %r3,%r3 - - lwz %r5,24(%r1) - std %r4,0(%r5) - - lwz %r0,4(%r1) - mtlr %r0 - blr - -.global lv1_storage_check_async_status -lv1_storage_check_async_status: - mflr %r0 - stw %r0,4(%r1) - stw %r7,-4(%r1) - - sldi %r3,%r3,32 - clrldi %r4,%r4,32 - or %r3,%r3,%r4 - sldi %r4,%r5,32 - clrldi %r5,%r6,32 - or %r4,%r4,%r5 - - li %r11,254 - hc - extsw %r3,%r3 - - lwz %r5,-4(%r1) - std %r4,0(%r5) - - lwz %r0,4(%r1) - mtlr %r0 - blr diff --git a/stand/powerpc/ps3/lv1call.h b/stand/powerpc/ps3/lv1call.h deleted file mode 100644 index fb80448..0000000 --- a/stand/powerpc/ps3/lv1call.h +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * Copyright (C) 2010 Nathan Whitehorn - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _PS3_LV1CALL_H -#define _PS3_LV1CALL_H - -#include <machine/pte.h> - -int lv1_get_physmem(uint64_t *maxmem); -int lv1_setup_address_space(uint64_t *as_id, uint64_t *ptsize); -int lv1_insert_pte(u_int ptegidx, struct lpte *pte, int lockflags); -int lv1_panic(int reboot); - -#define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_MODE_SET 0x0100 -#define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC 0x0101 -#define L1GPU_DISPLAY_SYNC_HSYNC 1 -#define L1GPU_DISPLAY_SYNC_VSYNC 2 -#define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP 0x0102 - -int lv1_gpu_open(int); -int lv1_gpu_context_attribute(int context, int op, int, int, int, int); -int lv1_gpu_memory_allocate(int size, int, int, int, int, uint64_t *handle, - uint64_t *paddr); -int lv1_gpu_context_allocate(uint64_t handle, int, uint64_t *context); - -int lv1_open_device(int, int, int /* 0 */); -int lv1_close_device(int, int); -int lv1_setup_dma(int, int, uint64_t *dmabase); - -#define GELIC_GET_MAC_ADDRESS 0x0001 -#define GELIC_GET_LINK_STATUS 0x0002 -#define GELIC_LINK_UP 0x0001 -#define GELIC_FULL_DUPLEX 0x0002 -#define GELIC_AUTO_NEG 0x0004 -#define GELIC_SPEED_10 0x0010 -#define GELIC_SPEED_100 0x0020 -#define GELIC_SPEED_1000 0x0040 -#define GELIC_GET_VLAN_ID 0x0004 - -int lv1_net_init(int bus, int dev); -int lv1_net_control(int bus, int dev, int, int, int, int, uint64_t *); -int lv1_net_start_tx_dma(int bus, int dev, uint32_t addr, int); -int lv1_net_start_rx_dma(int bus, int dev, uint32_t addr, int); -int lv1_net_stop_tx_dma(int bus, int dev, int); -int lv1_net_stop_rx_dma(int bus, int dev, int); - -int lv1_get_repository_node_value(uint64_t lpar_id, uint64_t n1, uint64_t n2, - uint64_t n3, uint64_t n4, uint64_t *v1, uint64_t *v2); - -int lv1_storage_read(uint64_t dev_id, uint64_t region_id, uint64_t start_sector, - uint64_t sector_count, uint64_t flags, uint64_t buf, uint64_t *tag); -int lv1_storage_check_async_status(uint64_t dev_id, uint64_t tag, - uint64_t *status); - -#endif - diff --git a/stand/powerpc/ps3/main.c b/stand/powerpc/ps3/main.c deleted file mode 100644 index be8708a..0000000 --- a/stand/powerpc/ps3/main.c +++ /dev/null @@ -1,248 +0,0 @@ -/*- - * Copyright (C) 2010 Nathan Whitehorn - * Copyright (C) 2011 glevand (geoffrey.levand@mail.ru) - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <stand.h> -#include <sys/param.h> - -#define _KERNEL -#include <machine/cpufunc.h> - -#include "bootstrap.h" -#include "lv1call.h" -#include "ps3.h" -#include "ps3devdesc.h" - -struct arch_switch archsw; -extern void *_end; - -extern char bootprog_info[]; - -int ps3_getdev(void **vdev, const char *devspec, const char **path); -ssize_t ps3_copyin(const void *src, vm_offset_t dest, const size_t len); -ssize_t ps3_copyout(vm_offset_t src, void *dest, const size_t len); -ssize_t ps3_readin(const int fd, vm_offset_t dest, const size_t len); -int ps3_autoload(void); -int ps3_setcurrdev(struct env_var *ev, int flags, const void *value); - -static uint64_t basetb; - -int -main(void) -{ - uint64_t maxmem = 0; - void *heapbase; - int i, err; - struct ps3_devdesc currdev; - struct open_file f; - - lv1_get_physmem(&maxmem); - - ps3mmu_init(maxmem); - - /* - * Set up console. - */ - cons_probe(); - - /* - * Set the heap to one page after the end of the loader. - */ - heapbase = (void *)(maxmem - 0x80000); - setheap(heapbase, maxmem); - - /* - * March through the device switch probing for things. - */ - for (i = 0; devsw[i] != NULL; i++) { - if (devsw[i]->dv_init != NULL) { - err = (devsw[i]->dv_init)(); - if (err) { - printf("\n%s: initialization failed err=%d\n", - devsw[i]->dv_name, err); - continue; - } - } - - currdev.d_dev = devsw[i]; - currdev.d_type = currdev.d_dev->dv_type; - - if (strcmp(devsw[i]->dv_name, "cd") == 0) { - f.f_devdata = &currdev; - currdev.d_unit = 0; - - if (devsw[i]->dv_open(&f, &currdev) == 0) - break; - } - - if (strcmp(devsw[i]->dv_name, "disk") == 0) { - f.f_devdata = &currdev; - currdev.d_unit = 3; - currdev.d_disk.pnum = 1; - currdev.d_disk.ptype = PTYPE_GPT; - - if (devsw[i]->dv_open(&f, &currdev) == 0) - break; - } - - if (strcmp(devsw[i]->dv_name, "net") == 0) - break; - } - - if (devsw[i] == NULL) - panic("No boot device found!"); - else - printf("Boot device: %s\n", devsw[i]->dv_name); - - /* - * Get timebase at boot. - */ - basetb = mftb(); - - archsw.arch_getdev = ps3_getdev; - archsw.arch_copyin = ps3_copyin; - archsw.arch_copyout = ps3_copyout; - archsw.arch_readin = ps3_readin; - archsw.arch_autoload = ps3_autoload; - - printf("\n%s", bootprog_info); - printf("Memory: %lldKB\n", maxmem / 1024); - - env_setenv("currdev", EV_VOLATILE, ps3_fmtdev(&currdev), - ps3_setcurrdev, env_nounset); - env_setenv("loaddev", EV_VOLATILE, ps3_fmtdev(&currdev), env_noset, - env_nounset); - setenv("LINES", "24", 1); - setenv("hw.platform", "ps3", 1); - - interact(NULL); /* doesn't return */ - - return (0); -} - -void -ppc_exception(int code, vm_offset_t where, register_t msr) -{ - mtmsr(PSL_IR | PSL_DR | PSL_RI); - printf("Exception %x at %#lx!\n", code, where); - printf("Rebooting in 5 seconds...\n"); - delay(10000000); - lv1_panic(1); -} - -const u_int ns_per_tick = 12; - -void -exit(int code) -{ - lv1_panic(code); -} - -void -delay(int usecs) -{ - uint64_t tb,ttb; - tb = mftb(); - - ttb = tb + howmany(usecs * 1000, ns_per_tick); - while (tb < ttb) - tb = mftb(); -} - -time_t -getsecs(void) -{ - return ((time_t)((mftb() - basetb)*ns_per_tick/1000000000)); -} - -time_t -time(time_t *tloc) -{ - time_t rv; - - rv = getsecs(); - if (tloc != NULL) - *tloc = rv; - - return (rv); -} - -ssize_t -ps3_copyin(const void *src, vm_offset_t dest, const size_t len) -{ - bcopy(src, (void *)dest, len); - return (len); -} - -ssize_t -ps3_copyout(vm_offset_t src, void *dest, const size_t len) -{ - bcopy((void *)src, dest, len); - return (len); -} - -ssize_t -ps3_readin(const int fd, vm_offset_t dest, const size_t len) -{ - void *buf; - size_t resid, chunk, get; - ssize_t got; - vm_offset_t p; - - p = dest; - - chunk = min(PAGE_SIZE, len); - buf = malloc(chunk); - if (buf == NULL) { - printf("ps3_readin: buf malloc failed\n"); - return(0); - } - - for (resid = len; resid > 0; resid -= got, p += got) { - get = min(chunk, resid); - got = read(fd, buf, get); - if (got <= 0) { - if (got < 0) - printf("ps3_readin: read failed\n"); - break; - } - - bcopy(buf, (void *)p, got); - } - - free(buf); - return (len - resid); -} - -int -ps3_autoload(void) -{ - - return (0); -} - diff --git a/stand/powerpc/ps3/metadata.c b/stand/powerpc/ps3/metadata.c deleted file mode 100644 index 6f29c57..0000000 --- a/stand/powerpc/ps3/metadata.c +++ /dev/null @@ -1,333 +0,0 @@ -/*- - * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, 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 <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <stand.h> -#include <sys/param.h> -#include <sys/reboot.h> -#include <sys/linker.h> -#include <sys/boot.h> - -#include <machine/metadata.h> - -#include "bootstrap.h" - -int -md_getboothowto(char *kargs) -{ - char *cp; - int howto; - int active; - int i; - - /* Parse kargs */ - howto = 0; - if (kargs != NULL) { - cp = kargs; - active = 0; - while (*cp != 0) { - if (!active && (*cp == '-')) { - active = 1; - } else if (active) - switch (*cp) { - case 'a': - howto |= RB_ASKNAME; - break; - case 'C': - howto |= RB_CDROM; - break; - case 'd': - howto |= RB_KDB; - break; - case 'D': - howto |= RB_MULTIPLE; - break; - case 'm': - howto |= RB_MUTE; - break; - case 'g': - howto |= RB_GDB; - break; - case 'h': - howto |= RB_SERIAL; - break; - case 'p': - howto |= RB_PAUSE; - break; - case 'r': - howto |= RB_DFLTROOT; - break; - case 's': - howto |= RB_SINGLE; - break; - case 'v': - howto |= RB_VERBOSE; - break; - default: - active = 0; - break; - } - cp++; - } - } - /* get equivalents from the environment */ - for (i = 0; howto_names[i].ev != NULL; i++) - if (getenv(howto_names[i].ev) != NULL) - howto |= howto_names[i].mask; - if (!strcmp(getenv("console"), "comconsole")) - howto |= RB_SERIAL; - 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 <name>=<value>, with a single nul - * separating each variable, and a double nul terminating the environment. - */ -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) { \ - u_int32_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); \ -} - -vm_offset_t -md_copymodules(vm_offset_t addr, int kern64) -{ - struct preloaded_file *fp; - struct file_metadata *md; - uint64_t scratch64; - 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 { - MOD_ADDR(addr, fp->f_addr, 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 powerpc 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. - */ -int -md_load_dual(char *args, vm_offset_t *modulep, 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; - vm_offset_t size; - uint64_t scratch64; - char *rootdevname; - int howto; - - 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); - - 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); - scratch64 = kernend; - file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof scratch64, &scratch64); - } else { - file_addmetadata(kfp, MODINFOMD_ENVP, sizeof envp, &envp); - file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof kernend, &kernend); - } - - *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); - } - - (void)md_copymodules(addr, kern64); - - return(0); -} - -int -md_load(char *args, vm_offset_t *modulep) -{ - return (md_load_dual(args, modulep, 0)); -} - -int -md_load64(char *args, vm_offset_t *modulep) -{ - return (md_load_dual(args, modulep, 1)); -} - diff --git a/stand/powerpc/ps3/ppc64_elf_freebsd.c b/stand/powerpc/ps3/ppc64_elf_freebsd.c deleted file mode 100644 index 3eb991e..0000000 --- a/stand/powerpc/ps3/ppc64_elf_freebsd.c +++ /dev/null @@ -1,101 +0,0 @@ -/*- - * Copyright (c) 2001 Benno Rice <benno@FreeBSD.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, 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 <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#define __ELF_WORD_SIZE 64 - -#include <sys/param.h> -#include <sys/linker.h> - -#include <machine/metadata.h> -#include <machine/elf.h> - -#include <stand.h> - -#include "bootstrap.h" - -extern char end[]; -extern vm_offset_t reloc; /* From <arch>/conf.c */ - -int -ppc64_elf_loadfile(char *filename, u_int64_t dest, - struct preloaded_file **result) -{ - int r; - - r = __elfN(loadfile)(filename, dest, result); - if (r != 0) - return (r); - - /* - * 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); - return (0); -} - -int -ppc64_elf_exec(struct preloaded_file *fp) -{ - struct file_metadata *fmp; - vm_offset_t mdp; - Elf_Ehdr *e; - int error; - int (*entry)(u_long, u_long, u_long, void *, u_long); - - if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) { - return(EFTYPE); - } - e = (Elf_Ehdr *)&fmp->md_data; - - /* Handle function descriptor for ELFv1 kernels */ - if ((e->e_flags & 3) == 2) - entry = e->e_entry; - else - entry = (void *)(uintptr_t)(*(uint64_t *)e->e_entry); - - if ((error = md_load64(fp->f_args, &mdp)) != 0) - return (error); - - printf("Kernel entry at %p ...\n", entry); - - dev_cleanup(); - - entry(0 /* FDT */, 0 /* Phys. mem offset */, 0 /* OF entry */, - (void *)mdp, sizeof(mdp)); - - panic("exec returned"); -} - -struct file_format ppc_elf64 = -{ - ppc64_elf_loadfile, - ppc64_elf_exec -}; diff --git a/stand/powerpc/ps3/ps3.h b/stand/powerpc/ps3/ps3.h deleted file mode 100644 index 1a77002..0000000 --- a/stand/powerpc/ps3/ps3.h +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * Copyright (C) 2010 Nathan Whitehorn - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _PS3_H -#define _PS3_H - -int ps3mmu_init(int maxmem); -int ps3mmu_map(uint64_t va, uint64_t pa); -void *ps3mmu_mapdev(uint64_t pa, size_t length); - -#endif diff --git a/stand/powerpc/ps3/ps3bus.h b/stand/powerpc/ps3/ps3bus.h deleted file mode 100644 index a3b20f3..0000000 --- a/stand/powerpc/ps3/ps3bus.h +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * Copyright (C) 2011 glevand (geoffrey.levand@mail.ru) - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _PS3_BUS_H -#define _PS3_BUS_H - -enum { - PS3_BUS_TYPE_STOR = 5, -}; - -enum { - PS3_DEV_TYPE_STOR_DISK = 0, - PS3_DEV_TYPE_STOR_CDROM = 5, - PS3_DEV_TYPE_STOR_FLASH = 14, -}; - -#endif diff --git a/stand/powerpc/ps3/ps3cdrom.c b/stand/powerpc/ps3/ps3cdrom.c deleted file mode 100644 index d8d41fd..0000000 --- a/stand/powerpc/ps3/ps3cdrom.c +++ /dev/null @@ -1,156 +0,0 @@ -/*- - * Copyright (C) 2011 glevand <geoffrey.levand@mail.ru> - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include <sys/param.h> -#include <sys/endian.h> -#include <machine/stdarg.h> -#include <stand.h> - -#include "bootstrap.h" -#include "ps3bus.h" -#include "ps3devdesc.h" -#include "ps3stor.h" - -#define dev_printf(dev, fmt, args...) \ - printf("%s%d: " fmt "\n", dev->d_dev->dv_name, dev->d_unit, ##args) - -#ifdef CD_DEBUG -#define DEBUG(fmt, args...) printf("%s:%d: " fmt "\n", __func__, __LINE__, ##args) -#else -#define DEBUG(fmt, args...) -#endif - -static int ps3cdrom_init(void); -static int ps3cdrom_strategy(void *devdata, int flag, daddr_t dblk, - size_t size, char *buf, size_t *rsize); -static int ps3cdrom_open(struct open_file *f, ...); -static int ps3cdrom_close(struct open_file *f); -static int ps3cdrom_print(int verbose); - -struct devsw ps3cdrom = { - "cd", - DEVT_CD, - ps3cdrom_init, - ps3cdrom_strategy, - ps3cdrom_open, - ps3cdrom_close, - noioctl, - ps3cdrom_print, -}; - -static struct ps3_stordev stor_dev; - -static int ps3cdrom_init(void) -{ - int err; - - err = ps3stor_setup(&stor_dev, PS3_DEV_TYPE_STOR_CDROM); - if (err) - return err; - - return 0; -} - -static int ps3cdrom_strategy(void *devdata, int flag, daddr_t dblk, - size_t size, char *buf, size_t *rsize) -{ - struct ps3_devdesc *dev = (struct ps3_devdesc *) devdata; - int err; - - DEBUG("d_unit=%u dblk=%llu size=%u", dev->d_unit, dblk, size); - - flag &= F_MASK; - if (flag != F_READ) { - dev_printf(dev, "write operation is not supported!"); - return EROFS; - } - - if (dblk % (stor_dev.sd_blksize / DEV_BSIZE) != 0) - return EINVAL; - - dblk /= (stor_dev.sd_blksize / DEV_BSIZE); - - if (size % stor_dev.sd_blksize) { - dev_printf(dev, - "size=%u is not multiple of device block size=%llu", size, - stor_dev.sd_blksize); - return EINVAL; - } - - if (rsize) - *rsize = 0; - - err = ps3stor_read_sectors(&stor_dev, dev->d_unit, dblk, - size / stor_dev.sd_blksize, 0, buf); - - if (!err && rsize) - *rsize = size; - - if (err) - dev_printf(dev, - "read operation failed dblk=%llu size=%d err=%d", dblk, - size, err); - - return err; -} - -static int ps3cdrom_open(struct open_file *f, ...) -{ - char buf[2048]; - va_list ap; - struct ps3_devdesc *dev; - int err; - - va_start(ap, f); - dev = va_arg(ap, struct ps3_devdesc *); - va_end(ap); - - if (dev->d_unit > 0) { - dev_printf(dev, "attempt to open nonexistent disk"); - return ENXIO; - } - - err = ps3stor_read_sectors(&stor_dev, dev->d_unit, 16, 1, 0, buf); - if (err) - return EIO; - - /* Do not attach if not ISO9660 (workaround for buggy firmware) */ - if (memcmp(buf, "\001CD001", 6) != 0) - return EIO; - - return 0; -} - -static int ps3cdrom_close(struct open_file *f) -{ - return 0; -} - -static int ps3cdrom_print(int verbose) -{ - return (0); -} diff --git a/stand/powerpc/ps3/ps3cons.c b/stand/powerpc/ps3/ps3cons.c deleted file mode 100644 index fa9ef32..0000000 --- a/stand/powerpc/ps3/ps3cons.c +++ /dev/null @@ -1,173 +0,0 @@ -/*- - * Copyright (C) 2010 Nathan Whitehorn - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <stand.h> -#include "bootstrap.h" -#include "font.h" -#include "lv1call.h" -#include "ps3.h" - -#define FONT_SIZE 14 -#define FONT dflt_font_14 -#define XMARGIN 40 -#define YMARGIN 30 -#define BG_COLOR 0x00000000 -#define FG_COLOR 0xffffffff - -#define FB_SIZE (16*1024*1024) -uint64_t fb_paddr = 0; -uint32_t *fb_vaddr; - -int fb_width, fb_height; -int x, y; - -static void ps3cons_probe(struct console *cp); -static int ps3cons_init(int arg); -static void ps3cons_putchar(int c); -static int ps3cons_getchar(); -static int ps3cons_poll(); - -struct console ps3console = { - "ps3", - "Playstation 3 Framebuffer", - 0, - ps3cons_probe, - ps3cons_init, - ps3cons_putchar, - ps3cons_getchar, - ps3cons_poll, -}; - -static void -ps3cons_probe(struct console *cp) -{ - /* XXX: Get from HV */ - fb_width = 720; - fb_height = 480; - - cp->c_flags |= C_PRESENTIN|C_PRESENTOUT; -} - -static int -ps3cons_init(int arg) -{ - uint64_t fbhandle, fbcontext; - int i; - - lv1_gpu_open(0); - lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_MODE_SET, - 0,0,0,0); - lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_MODE_SET, - 0,0,1,0); - lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, - 0,L1GPU_DISPLAY_SYNC_VSYNC,0,0); - lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, - 1,L1GPU_DISPLAY_SYNC_VSYNC,0,0); - lv1_gpu_memory_allocate(FB_SIZE, 0, 0, 0, 0, &fbhandle, &fb_paddr); - lv1_gpu_context_allocate(fbhandle, 0, &fbcontext); - - lv1_gpu_context_attribute(fbcontext, - L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 0, 0, 0, 0); - lv1_gpu_context_attribute(fbcontext, - L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 1, 0, 0, 0); - - fb_vaddr = ps3mmu_mapdev(fb_paddr, FB_SIZE); - - x = y = 0; - - /* Blank console */ - for (i = 0; i < fb_width*fb_height; i++) - fb_vaddr[i] = BG_COLOR; - - return (0); -} - -static void -ps3cons_putchar(int c) -{ - uint32_t fg, bg; - uint32_t *addr; - int i, j, k; - u_char *p; - - fg = FG_COLOR; - bg = BG_COLOR; - - switch (c) { - case '\0': - break; - case '\r': - x = 0; - break; - case '\n': - y += FONT_SIZE; - break; - case '\b': - x = max(0, x - 8); - break; - default: - /* Wrap long lines */ - if (x + XMARGIN + FONT_SIZE > fb_width - XMARGIN) { - y += FONT_SIZE; - x = 0; - } - - if (y + YMARGIN + FONT_SIZE > fb_height - YMARGIN) - y = 0; - - addr = fb_vaddr + (y + YMARGIN)*fb_width + (x + XMARGIN); - p = FONT + c*FONT_SIZE; - - for (i = 0; i < FONT_SIZE; i++) { - for (j = 0, k = 7; j < 8; j++, k--) { - if ((p[i] & (1 << k)) == 0) - *(addr + j) = bg; - else - *(addr + j) = fg; - } - - addr += fb_width; - } - - x += 8; - break; - } -} - -static int -ps3cons_getchar() -{ - return (-1); -} - -static int -ps3cons_poll() -{ - return (0); -} - diff --git a/stand/powerpc/ps3/ps3devdesc.h b/stand/powerpc/ps3/ps3devdesc.h deleted file mode 100644 index 5a6e52f..0000000 --- a/stand/powerpc/ps3/ps3devdesc.h +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (C) 2000 Benno Rice. - * Copyright (C) 2007 Semihalf, Rafal Jaworowski <raj@semihalf.com> - * Copyright (C) 2011 glevand (geoffrey.levand@mail.ru) - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _PS3_DEV_DESC_H -#define _PS3_DEV_DESC_H - -/* Note: Must match the 'struct devdesc' in bootstrap.h */ -struct ps3_devdesc { - struct devsw *d_dev; - int d_type; - int d_unit; - - union { - struct { - void *data; - int pnum; - int ptype; - } disk; - } d_kind; -}; - -#define d_disk d_kind.disk - -#define PTYPE_BSDLABEL 1 -#define PTYPE_GPT 2 - -#endif diff --git a/stand/powerpc/ps3/ps3disk.c b/stand/powerpc/ps3/ps3disk.c deleted file mode 100644 index c33a023..0000000 --- a/stand/powerpc/ps3/ps3disk.c +++ /dev/null @@ -1,315 +0,0 @@ -/*- - * Copyright (C) 2008 Semihalf, Rafal Jaworowski - * Copyright (C) 2009 Semihalf, Piotr Ziecik - * Copyright (C) 2011 glevand (geoffrey.levand@mail.ru) - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include <sys/endian.h> -#include <machine/stdarg.h> -#include <stand.h> -#include <uuid.h> - -#define FSTYPENAMES -#include <sys/disklabel.h> -#include <sys/diskmbr.h> -#include <sys/gpt.h> - -#include "bootstrap.h" -#include "ps3bus.h" -#include "ps3devdesc.h" -#include "ps3stor.h" - -#define dev_printf(dev, fmt, args...) \ - printf("%s%d: " fmt "\n" , dev->d_dev->dv_name, dev->d_unit, ##args) - -#ifdef DISK_DEBUG -#define DEBUG(fmt, args...) printf("%s:%d: " fmt "\n" , __func__ , __LINE__, ##args) -#else -#define DEBUG(fmt, args...) -#endif - -struct open_dev; - -static int ps3disk_open_gpt(struct ps3_devdesc *dev, struct open_dev *od); -static void ps3disk_uuid_letoh(uuid_t *uuid); - -static int ps3disk_init(void); -static int ps3disk_strategy(void *devdata, int flag, daddr_t dblk, - size_t size, char *buf, size_t *rsize); -static int ps3disk_open(struct open_file *f, ...); -static int ps3disk_close(struct open_file *f); -static int ps3disk_print(int verbose); - -struct devsw ps3disk = { - "disk", - DEVT_DISK, - ps3disk_init, - ps3disk_strategy, - ps3disk_open, - ps3disk_close, - noioctl, - ps3disk_print, -}; - -struct gpt_part { - int gp_index; - uuid_t gp_type; - uint64_t gp_start; - uint64_t gp_end; -}; - -struct open_dev { - uint64_t od_start; - - union { - struct { - int nparts; - struct gpt_part *parts; - } gpt; - } od_kind; -}; - -#define od_gpt_nparts od_kind.gpt.nparts -#define od_gpt_parts od_kind.gpt.parts - -static struct ps3_stordev stor_dev; - -static int ps3disk_init(void) -{ - int err; - - err = ps3stor_setup(&stor_dev, PS3_DEV_TYPE_STOR_DISK); - if (err) - return err; - - return 0; -} - -static int ps3disk_strategy(void *devdata, int flag, daddr_t dblk, - size_t size, char *buf, size_t *rsize) -{ - struct ps3_devdesc *dev = (struct ps3_devdesc *) devdata; - struct open_dev *od = (struct open_dev *) dev->d_disk.data; - int err; - - flag &= F_MASK; - if (flag != F_READ) { - dev_printf(dev, "write operation is not supported!\n"); - return EROFS; - } - - if (size % stor_dev.sd_blksize) { - dev_printf(dev, "size=%u is not multiple of device block size=%llu\n", - size, stor_dev.sd_blksize); - return EIO; - } - - if (rsize) - *rsize = 0; - - err = ps3stor_read_sectors(&stor_dev, dev->d_unit, od->od_start + dblk, - size / stor_dev.sd_blksize, 0, buf); - - if (!err && rsize) - *rsize = size; - - if (err) - dev_printf(dev, "read operation failed dblk=%llu size=%d err=%d\n", - dblk, size, err); - - return err; -} - -static int ps3disk_open(struct open_file *f, ...) -{ - va_list ap; - struct ps3_devdesc *dev; - struct open_dev *od; - int err; - - va_start(ap, f); - dev = va_arg(ap, struct ps3_devdesc *); - va_end(ap); - - od = malloc(sizeof(struct open_dev)); - if (!od) { - dev_printf(dev, "couldn't allocate memory for new open_dev\n"); - return ENOMEM; - } - - err = ps3disk_open_gpt(dev, od); - - if (err) { - dev_printf(dev, "couldn't open GPT disk error=%d\n", err); - free(od); - } else { - ((struct ps3_devdesc *) (f->f_devdata))->d_disk.data = od; - } - - return err; -} - -static int ps3disk_close(struct open_file *f) -{ - struct ps3_devdesc *dev = f->f_devdata; - struct open_dev *od = dev->d_disk.data; - - if (dev->d_disk.ptype == PTYPE_GPT && od->od_gpt_nparts) - free(od->od_gpt_parts); - - free(od); - - dev->d_disk.data = NULL; - - return 0; -} - -static int ps3disk_print(int verbose) -{ - return (0); -} - -static int ps3disk_open_gpt(struct ps3_devdesc *dev, struct open_dev *od) -{ - char buf[512]; - struct gpt_hdr *hdr; - struct gpt_ent *ent; - daddr_t slba, elba, lba; - int nparts, eps, i, part, err; - - od->od_gpt_nparts = 0; - od->od_gpt_parts = NULL; - - err = ps3stor_read_sectors(&stor_dev, dev->d_unit, 0, 1, 0, buf); - if (err) { - err = EIO; - goto out; - } - - if (le16toh(*((uint16_t *) (buf + DOSMAGICOFFSET))) != DOSMAGIC) { - err = ENXIO; - goto out; - } - - err = ps3stor_read_sectors(&stor_dev, dev->d_unit, 1, 1, 0, buf); - if (err) { - err = EIO; - goto out; - } - - hdr = (struct gpt_hdr *) buf; - - if (bcmp(hdr->hdr_sig, GPT_HDR_SIG, sizeof(hdr->hdr_sig)) || - le64toh(hdr->hdr_lba_self) != 1 || le32toh(hdr->hdr_revision) < 0x00010000 || - le32toh(hdr->hdr_entsz) < sizeof(struct gpt_ent) || - stor_dev.sd_blksize % le32toh(hdr->hdr_entsz) != 0) { - err = ENXIO; - goto out; - } - - nparts = 0; - eps = stor_dev.sd_blksize / le32toh(hdr->hdr_entsz); - slba = le64toh(hdr->hdr_lba_table); - elba = slba + le32toh(hdr->hdr_entries) / eps; - - for (lba = slba; lba < elba; lba++) { - err = ps3stor_read_sectors(&stor_dev, dev->d_unit, lba, 1, 0, buf); - if (err) { - err = EIO; - goto out; - } - - ent = (struct gpt_ent *) buf; - - for (i = 0; i < eps; i++) { - if (uuid_is_nil(&ent[i].ent_type, NULL) || - le64toh(ent[i].ent_lba_start) == 0 || - le64toh(ent[i].ent_lba_end) < le64toh(ent[i].ent_lba_start)) - continue; - - nparts++; - } - } - - if (nparts) { - od->od_gpt_nparts = nparts; - - od->od_gpt_parts = malloc(nparts * sizeof(struct gpt_part)); - if (!od->od_gpt_parts) { - err = ENOMEM; - goto out; - } - - for (lba = slba, part = 0; lba < elba; lba++) { - err = ps3stor_read_sectors(&stor_dev, dev->d_unit, lba, 1, 0, buf); - if (err) { - err = EIO; - goto out; - } - - ent = (struct gpt_ent *) buf; - - for (i = 0; i < eps; i++) { - if (uuid_is_nil(&ent[i].ent_type, NULL) || - le64toh(ent[i].ent_lba_start) == 0 || - le64toh(ent[i].ent_lba_end) < le64toh(ent[i].ent_lba_start)) - continue; - - od->od_gpt_parts[part].gp_index = (lba - slba) * eps + i + 1; - od->od_gpt_parts[part].gp_type = ent[i].ent_type; - od->od_gpt_parts[part].gp_start = le64toh(ent[i].ent_lba_start); - od->od_gpt_parts[part].gp_end = le64toh(ent[i].ent_lba_end); - ps3disk_uuid_letoh(&od->od_gpt_parts[part].gp_type); - part++; - } - } - } - - dev->d_disk.ptype = PTYPE_GPT; - - if (od->od_gpt_nparts && !dev->d_disk.pnum) - dev->d_disk.pnum = od->od_gpt_parts[0].gp_index; - - for (i = 0; i < od->od_gpt_nparts; i++) - if (od->od_gpt_parts[i].gp_index == dev->d_disk.pnum) - od->od_start = od->od_gpt_parts[i].gp_start; - - err = 0; - -out: - - if (err && od->od_gpt_parts) - free(od->od_gpt_parts); - - return err; -} - -static void ps3disk_uuid_letoh(uuid_t *uuid) -{ - uuid->time_low = le32toh(uuid->time_low); - uuid->time_mid = le16toh(uuid->time_mid); - uuid->time_hi_and_version = le16toh(uuid->time_hi_and_version); -} diff --git a/stand/powerpc/ps3/ps3mmu.c b/stand/powerpc/ps3/ps3mmu.c deleted file mode 100644 index 08dcf75..0000000 --- a/stand/powerpc/ps3/ps3mmu.c +++ /dev/null @@ -1,120 +0,0 @@ -/*- - * Copyright (C) 2010 Nathan Whitehorn - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <stand.h> -#include <stdint.h> - -#define _KERNEL -#include <machine/cpufunc.h> -#include <machine/psl.h> -#include <machine/pte.h> -#include <machine/slb.h> -#include <machine/param.h> - -#include "bootstrap.h" -#include "lv1call.h" -#include "ps3.h" - -register_t pteg_count, pteg_mask; -uint64_t as_id; -uint64_t virtual_avail; - -int -ps3mmu_map(uint64_t va, uint64_t pa) -{ - struct lpte pt; - int shift; - uint64_t vsid, ptegidx; - - if (pa < 0x8000000) { /* Phys mem? */ - pt.pte_hi = LPTE_BIG; - pt.pte_lo = LPTE_M; - shift = 24; - vsid = 0; - } else { - pt.pte_hi = 0; - pt.pte_lo = LPTE_I | LPTE_G | LPTE_M | LPTE_NOEXEC; - shift = ADDR_PIDX_SHFT; - vsid = 1; - } - - pt.pte_hi |= (vsid << LPTE_VSID_SHIFT) | - (((uint64_t)(va & ADDR_PIDX) >> ADDR_API_SHFT64) & LPTE_API); - pt.pte_lo |= pa; - ptegidx = vsid ^ (((uint64_t)va & ADDR_PIDX) >> shift); - - pt.pte_hi |= LPTE_LOCKED | LPTE_VALID; - ptegidx &= pteg_mask; - - return (lv1_insert_pte(ptegidx, &pt, LPTE_LOCKED)); -} - -void * -ps3mmu_mapdev(uint64_t pa, size_t length) -{ - uint64_t spa; - void *mapstart; - int err; - - mapstart = (void *)(uintptr_t)virtual_avail; - - for (spa = pa; spa < pa + length; spa += PAGE_SIZE) { - err = ps3mmu_map(virtual_avail, spa); - virtual_avail += PAGE_SIZE; - if (err != 0) - return (NULL); - } - - return (mapstart); -} - -int -ps3mmu_init(int maxmem) -{ - uint64_t ptsize; - int i; - - i = lv1_setup_address_space(&as_id, &ptsize); - pteg_count = ptsize / sizeof(struct lpteg); - pteg_mask = pteg_count - 1; - - for (i = 0; i < maxmem; i += 16*1024*1024) - ps3mmu_map(i,i); - - virtual_avail = 0x10000000; - - __asm __volatile ("slbia; slbmte %0, %1; slbmte %2,%3" :: - "r"((0 << SLBV_VSID_SHIFT) | SLBV_L), "r"(0 | SLBE_VALID), - "r"(1 << SLBV_VSID_SHIFT), - "r"((1 << SLBE_ESID_SHIFT) | SLBE_VALID | 1)); - - mtmsr(PSL_IR | PSL_DR | PSL_RI | PSL_ME); - - return (0); -} - diff --git a/stand/powerpc/ps3/ps3net.c b/stand/powerpc/ps3/ps3net.c deleted file mode 100644 index 142eab8..0000000 --- a/stand/powerpc/ps3/ps3net.c +++ /dev/null @@ -1,278 +0,0 @@ -/*- - * Copyright (C) 2010 Nathan Whitehorn - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/socket.h> - -#include <net/if.h> -#include <netinet/in.h> -#include <netinet/in_systm.h> -#include <netinet/if_ether.h> -#include <netinet/ip.h> - -#define _KERNEL -#include <machine/cpufunc.h> - -#include <stand.h> -#include <net.h> -#include <netif.h> -#include "bootstrap.h" -#include "lv1call.h" -#include "ps3.h" - -#define GELIC_DESCR_OWNED 0xa0000000 -#define GELIC_CMDSTAT_NOIPSEC 0x00080000 -#define GELIC_CMDSTAT_LAST 0x00040000 -#define GELIC_RXERRORS 0x7def8000 - -#define GELIC_POLL_PERIOD 100 /* microseconds */ - -static int ps3net_probe(struct netif *, void *); -static int ps3net_match(struct netif *, void *); -static void ps3net_init(struct iodesc *, void *); -static int ps3net_get(struct iodesc *, void *, size_t, time_t); -static int ps3net_put(struct iodesc *, void *, size_t); -static void ps3net_end(struct netif *); - -struct netif_stats ps3net_stats[1]; -struct netif_dif ps3net_ifs[] = {{0, 1, ps3net_stats, 0}}; - -/* XXX: Get from firmware, not hardcoding */ -static int busid = 1; -static int devid = 0; -static int vlan; -static uint64_t dma_base; - -struct gelic_dmadesc { - uint32_t paddr; - uint32_t len; - uint32_t next; - uint32_t cmd_stat; - uint32_t result_size; - uint32_t valid_size; - uint32_t data_stat; - uint32_t rxerror; -}; - -struct netif_driver ps3net = { - "net", - ps3net_match, - ps3net_probe, - ps3net_init, - ps3net_get, - ps3net_put, - ps3net_end, - ps3net_ifs, 1 -}; - -static int -ps3net_match(struct netif *nif, void *machdep_hint) -{ - return (1); -} - -static int -ps3net_probe(struct netif *nif, void *machdep_hint) -{ - return (0); -} - -static int -ps3net_put(struct iodesc *desc, void *pkt, size_t len) -{ - volatile static struct gelic_dmadesc txdesc __aligned(32); - volatile static char txbuf[1536] __aligned(128); - size_t sendlen; - int err; - -#if defined(NETIF_DEBUG) - struct ether_header *eh; - - printf("net_put: desc %p, pkt %p, len %d\n", desc, pkt, len); - eh = pkt; - printf("dst: %s ", ether_sprintf(eh->ether_dhost)); - printf("src: %s ", ether_sprintf(eh->ether_shost)); - printf("type: 0x%x\n", eh->ether_type & 0xffff); -#endif - - while (txdesc.cmd_stat & GELIC_DESCR_OWNED) { - printf("Stalled XMIT!\n"); - delay(10); - } - - /* - * We must add 4 extra bytes to this packet to store the destination - * VLAN. - */ - memcpy(txbuf, pkt, 12); - sendlen = 12; - - if (vlan >= 0) { - sendlen += 4; - ((uint8_t *)txbuf)[12] = 0x81; - ((uint8_t *)txbuf)[13] = 0x00; - ((uint8_t *)txbuf)[14] = vlan >> 8; - ((uint8_t *)txbuf)[15] = vlan & 0xff; - } - memcpy((void *)txbuf + sendlen, pkt + 12, len - 12); - sendlen += len - 12; - - bzero(&txdesc, sizeof(txdesc)); - txdesc.paddr = dma_base + (uint32_t)txbuf; - txdesc.len = sendlen; - txdesc.cmd_stat = GELIC_CMDSTAT_NOIPSEC | GELIC_CMDSTAT_LAST | - GELIC_DESCR_OWNED; - - powerpc_sync(); - - do { - err = lv1_net_start_tx_dma(busid, devid, - dma_base + (uint32_t)&txdesc, 0); - delay(1); - if (err != 0) - printf("TX Error: %d\n",err); - } while (err != 0); - - return (len); -} - -static int -ps3net_get(struct iodesc *desc, void *pkt, size_t len, time_t timeout) -{ - volatile static struct gelic_dmadesc rxdesc __aligned(32); - volatile static char rxbuf[1536] __aligned(128); - int err = 0; - - if (len == 0) - goto restartdma; - - timeout *= 1000000; /* convert to microseconds */ - while (rxdesc.cmd_stat & GELIC_DESCR_OWNED) { - if (timeout < GELIC_POLL_PERIOD) - return (ETIMEDOUT); - delay(GELIC_POLL_PERIOD); - timeout -= GELIC_POLL_PERIOD; - } - - delay(200); - if (rxdesc.rxerror & GELIC_RXERRORS) { - err = -1; - goto restartdma; - } - - /* - * Copy the packet to the receive buffer, leaving out the - * 2 byte VLAN header. - */ - len = min(len, rxdesc.valid_size - 2); - memcpy(pkt, (u_char *)rxbuf + 2, len); - err = len; - -#if defined(NETIF_DEBUG) -{ - struct ether_header *eh; - - printf("net_get: desc %p, pkt %p, len %d\n", desc, pkt, len); - eh = pkt; - printf("dst: %s ", ether_sprintf(eh->ether_dhost)); - printf("src: %s ", ether_sprintf(eh->ether_shost)); - printf("type: 0x%x\n", eh->ether_type & 0xffff); -} -#endif - -restartdma: - lv1_net_stop_rx_dma(busid, devid, 0); - powerpc_sync(); - - bzero(&rxdesc, sizeof(rxdesc)); - rxdesc.paddr = dma_base + (uint32_t)rxbuf; - rxdesc.len = sizeof(rxbuf); - rxdesc.next = 0; - rxdesc.cmd_stat = GELIC_DESCR_OWNED; - powerpc_sync(); - - lv1_net_start_rx_dma(busid, devid, dma_base + (uint32_t)&rxdesc, 0); - - return (err); -} - -static void -ps3net_init(struct iodesc *desc, void *machdep_hint) -{ - uint64_t mac, val; - int i,err; - - err = lv1_open_device(busid, devid, 0); - - lv1_net_stop_tx_dma(busid, devid, 0); - lv1_net_stop_rx_dma(busid, devid, 0); - - /* - * Wait for link to come up - */ - - for (i = 0; i < 1000; i++) { - lv1_net_control(busid, devid, GELIC_GET_LINK_STATUS, 2, 0, - 0, &val); - if (val & GELIC_LINK_UP) - break; - delay(500); - } - - /* - * Set up DMA IOMMU entries - */ - - err = lv1_setup_dma(busid, devid, &dma_base); - - /* - * Get MAC address and VLAN IDs - */ - - lv1_net_control(busid, devid, GELIC_GET_MAC_ADDRESS, 0, 0, 0, &mac); - bcopy(&((uint8_t *)&mac)[2], desc->myea, sizeof(desc->myea)); - - vlan = -1; - err = lv1_net_control(busid, devid, GELIC_GET_VLAN_ID, 2, 0, - 0, &val); - if (err == 0) - vlan = val; - - /* - * Start RX DMA engine - */ - - ps3net_get(NULL, NULL, 0, 0); -} - -static void -ps3net_end(struct netif *nif) -{ - lv1_close_device(busid, devid); -} - diff --git a/stand/powerpc/ps3/ps3repo.c b/stand/powerpc/ps3/ps3repo.c deleted file mode 100644 index 0064769..0000000 --- a/stand/powerpc/ps3/ps3repo.c +++ /dev/null @@ -1,249 +0,0 @@ -/*- - * Copyright (C) 2011 glevand (geoffrey.levand@mail.ru) - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include <stand.h> - -#include "lv1call.h" -#include "ps3.h" -#include "ps3repo.h" - -static uint64_t make_n1(const char *text, unsigned int index) -{ - uint64_t n1; - - n1 = 0; - strncpy((char *) &n1, text, sizeof(n1)); - n1 = (n1 >> 32) + index; - - return n1; -} - -static uint64_t make_n(const char *text, unsigned int index) -{ - uint64_t n; - - n = 0; - strncpy((char *) &n, text, sizeof(n)); - n = n + index; - - return n; -} - -int ps3repo_read_bus_type(unsigned int bus_index, uint64_t *bus_type) -{ - uint64_t v1, v2; - int err; - - err = lv1_get_repository_node_value(PS3_LPAR_ID_PME, make_n1("bus", bus_index), - make_n("type", 0), 0, 0, &v1, &v2); - - *bus_type = v1; - - return err; -} - -int ps3repo_read_bus_id(unsigned int bus_index, uint64_t *bus_id) -{ - uint64_t v1, v2; - int err; - - err = lv1_get_repository_node_value(PS3_LPAR_ID_PME, make_n1("bus", bus_index), - make_n("id", 0), 0, 0, &v1, &v2); - - *bus_id = v1; - - return err; -} - -int ps3repo_read_bus_num_dev(unsigned int bus_index, uint64_t *num_dev) -{ - uint64_t v1, v2; - int err; - - err = lv1_get_repository_node_value(PS3_LPAR_ID_PME, make_n1("bus", bus_index), - make_n("num_dev", 0), 0, 0, &v1, &v2); - - *num_dev = v1; - - return err; -} - -int ps3repo_read_bus_dev_type(unsigned int bus_index, unsigned int dev_index, uint64_t *dev_type) -{ - uint64_t v1, v2; - int err; - - err = lv1_get_repository_node_value(PS3_LPAR_ID_PME, make_n1("bus", bus_index), - make_n("dev", dev_index), make_n("type", 0), 0, &v1, &v2); - - *dev_type = v1; - - return err; -} - -int ps3repo_read_bus_dev_id(unsigned int bus_index, unsigned int dev_index, uint64_t *dev_id) -{ - uint64_t v1, v2; - int err; - - err = lv1_get_repository_node_value(PS3_LPAR_ID_PME, make_n1("bus", bus_index), - make_n("dev", dev_index), make_n("id", 0), 0, &v1, &v2); - - *dev_id = v1; - - return err; -} - -int ps3repo_read_bus_dev_blk_size(unsigned int bus_index, unsigned int dev_index, uint64_t *blk_size) -{ - uint64_t v1, v2; - int err; - - err = lv1_get_repository_node_value(PS3_LPAR_ID_PME, make_n1("bus", bus_index), - make_n("dev", dev_index), make_n("blk_size", 0), 0, &v1, &v2); - - *blk_size = v1; - - return err; -} - -int ps3repo_read_bus_dev_nblocks(unsigned int bus_index, unsigned int dev_index, uint64_t *nblocks) -{ - uint64_t v1, v2; - int err; - - err = lv1_get_repository_node_value(PS3_LPAR_ID_PME, make_n1("bus", bus_index), - make_n("dev", dev_index), make_n("n_blocks", 0), 0, &v1, &v2); - - *nblocks = v1; - - return err; -} - -int ps3repo_read_bus_dev_nregs(unsigned int bus_index, unsigned int dev_index, uint64_t *nregs) -{ - uint64_t v1, v2; - int err; - - err = lv1_get_repository_node_value(PS3_LPAR_ID_PME, make_n1("bus", bus_index), - make_n("dev", dev_index), make_n("n_regs", 0), 0, &v1, &v2); - - *nregs = v1; - - return err; -} - -int ps3repo_read_bus_dev_reg_id(unsigned int bus_index, unsigned int dev_index, - unsigned int reg_index, uint64_t *reg_id) -{ - uint64_t v1, v2; - int err; - - err = lv1_get_repository_node_value(PS3_LPAR_ID_PME, make_n1("bus", bus_index), - make_n("dev", dev_index), make_n("region", reg_index), make_n("id", 0), &v1, &v2); - - *reg_id = v1; - - return err; -} - -int ps3repo_read_bus_dev_reg_start(unsigned int bus_index, unsigned int dev_index, - unsigned int reg_index, uint64_t *reg_start) -{ - uint64_t v1, v2; - int err; - - err = lv1_get_repository_node_value(PS3_LPAR_ID_PME, make_n1("bus", bus_index), - make_n("dev", dev_index), make_n("region", reg_index), make_n("start", 0), &v1, &v2); - - *reg_start = v1; - - return err; -} - -int ps3repo_read_bus_dev_reg_size(unsigned int bus_index, unsigned int dev_index, - unsigned int reg_index, uint64_t *reg_size) -{ - uint64_t v1, v2; - int err; - - err = lv1_get_repository_node_value(PS3_LPAR_ID_PME, make_n1("bus", bus_index), - make_n("dev", dev_index), make_n("region", reg_index), make_n("size", 0), &v1, &v2); - - *reg_size = v1; - - return err; -} - -int ps3repo_find_bus_by_type(uint64_t bus_type, unsigned int *bus_index) -{ - unsigned int i; - uint64_t type; - int err; - - for (i = 0; i < 10; i++) { - err = ps3repo_read_bus_type(i, &type); - if (err) { - *bus_index = (unsigned int) -1; - return err; - } - - if (type == bus_type) { - *bus_index = i; - return 0; - } - } - - *bus_index = (unsigned int) -1; - - return ENODEV; -} - -int ps3repo_find_bus_dev_by_type(unsigned int bus_index, uint64_t dev_type, - unsigned int *dev_index) -{ - unsigned int i; - uint64_t type; - int err; - - for (i = 0; i < 10; i++) { - err = ps3repo_read_bus_dev_type(bus_index, i, &type); - if (err) { - *dev_index = (unsigned int) -1; - return err; - } - - if (type == dev_type) { - *dev_index = i; - return 0; - } - } - - *dev_index = (unsigned int) -1; - - return ENODEV; -} diff --git a/stand/powerpc/ps3/ps3repo.h b/stand/powerpc/ps3/ps3repo.h deleted file mode 100644 index 68001df..0000000 --- a/stand/powerpc/ps3/ps3repo.h +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (C) 2011 glevand (geoffrey.levand@mail.ru) - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _PS3_REPO_H -#define _PS3_REPO_H - -#define PS3_LPAR_ID_PME 1 - -int ps3repo_read_bus_type(unsigned int bus_index, uint64_t *bus_type); -int ps3repo_read_bus_id(unsigned int bus_index, uint64_t *bus_id); -int ps3repo_read_bus_num_dev(unsigned int bus_index, uint64_t *num_dev); -int ps3repo_read_bus_dev_type(unsigned int bus_index, unsigned int dev_index, uint64_t *dev_type); -int ps3repo_read_bus_dev_id(unsigned int bus_index, unsigned int dev_index, uint64_t *dev_id); -int ps3repo_read_bus_dev_blk_size(unsigned int bus_index, unsigned int dev_index, uint64_t *blk_size); -int ps3repo_read_bus_dev_nblocks(unsigned int bus_index, unsigned int dev_index, uint64_t *nblocks); -int ps3repo_read_bus_dev_nregs(unsigned int bus_index, unsigned int dev_index, uint64_t *nregs); -int ps3repo_read_bus_dev_reg_id(unsigned int bus_index, unsigned int dev_index, - unsigned int reg_index, uint64_t *reg_id); -int ps3repo_read_bus_dev_reg_start(unsigned int bus_index, unsigned int dev_index, - unsigned int reg_index, uint64_t *reg_start); -int ps3repo_read_bus_dev_reg_size(unsigned int bus_index, unsigned int dev_index, - unsigned int reg_index, uint64_t *reg_size); -int ps3repo_find_bus_by_type(uint64_t bus_type, unsigned int *bus_index); -int ps3repo_find_bus_dev_by_type(unsigned int bus_index, uint64_t dev_type, - unsigned int *dev_index); - -#endif diff --git a/stand/powerpc/ps3/ps3stor.c b/stand/powerpc/ps3/ps3stor.c deleted file mode 100644 index bbfc56a..0000000 --- a/stand/powerpc/ps3/ps3stor.c +++ /dev/null @@ -1,176 +0,0 @@ -/*- - * Copyright (C) 2011 glevand (geoffrey.levand@mail.ru) - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include <stand.h> - -#include "bootstrap.h" -#include "lv1call.h" -#include "ps3bus.h" -#include "ps3repo.h" -#include "ps3stor.h" - -int ps3stor_setup(struct ps3_stordev *sd, int type) -{ - unsigned int i; - int err; - - sd->sd_type = type; - - err = ps3repo_find_bus_by_type(PS3_BUS_TYPE_STOR, &sd->sd_busidx); - if (err) - goto out; - - err = ps3repo_read_bus_id(sd->sd_busidx, &sd->sd_busid); - if (err) - goto out; - - err = ps3repo_find_bus_dev_by_type(sd->sd_busidx, type, &sd->sd_devidx); - if (err) - goto out; - - err = ps3repo_read_bus_dev_id(sd->sd_busidx, sd->sd_devidx, - &sd->sd_devid); - if (err) - goto out; - - err = ps3repo_read_bus_dev_blk_size(sd->sd_busidx, sd->sd_devidx, - &sd->sd_blksize); - if (err) - goto out; - - err = ps3repo_read_bus_dev_nblocks(sd->sd_busidx, sd->sd_devidx, - &sd->sd_nblocks); - if (err) - goto out; - - err = ps3repo_read_bus_dev_nregs(sd->sd_busidx, sd->sd_devidx, - &sd->sd_nregs); - if (err) - goto out; - - for (i = 0; i < sd->sd_nregs; i++) { - err = ps3repo_read_bus_dev_reg_id(sd->sd_busidx, sd->sd_devidx, - i, &sd->sd_regs[i].sr_id); - if (err) - goto out; - - err = ps3repo_read_bus_dev_reg_start(sd->sd_busidx, - sd->sd_devidx, i, &sd->sd_regs[i].sr_start); - if (err) - goto out; - - err = ps3repo_read_bus_dev_reg_size(sd->sd_busidx, - sd->sd_devidx, i, &sd->sd_regs[i].sr_size); - if (err) - goto out; - } - - if (!sd->sd_nregs) { - err = ENODEV; - goto out; - } - - err = lv1_open_device(sd->sd_busid, sd->sd_devid, 0); - if (err) - goto out; - - err = lv1_setup_dma(sd->sd_busid, sd->sd_devid, &sd->sd_dmabase); - if (err) - goto close_dev; - - return 0; - -close_dev: - - lv1_close_device(sd->sd_busid, sd->sd_devid); - -out: - - return err; -} - -static char dma_buf[2048] __aligned(2048); - -int ps3stor_read_sectors(struct ps3_stordev *sd, int regidx, - uint64_t start_sector, uint64_t sector_count, uint64_t flags, char *buf) -{ -#define MIN(a, b) ((a) <= (b) ? (a) : (b)) -#define BOUNCE_SECTORS (sizeof(dma_buf) / sd->sd_blksize) -#define ASYNC_STATUS_POLL_PERIOD 100 /* microseconds */ - - struct ps3_storreg *reg = &sd->sd_regs[regidx]; - uint64_t nleft, nread, nsectors; - uint64_t tag, status; - unsigned int timeout; - int err = 0; - - nleft = sector_count; - nread = 0; - - while (nleft) { - nsectors = MIN(nleft, BOUNCE_SECTORS); - - err = lv1_storage_read(sd->sd_devid, reg->sr_id, - start_sector + nread, nsectors, flags, (uint32_t)dma_buf, - &tag); - if (err) - return err; - - timeout = 5000000; /* microseconds */ - - while (1) { - if (timeout < ASYNC_STATUS_POLL_PERIOD) - return ETIMEDOUT; - - err = lv1_storage_check_async_status(sd->sd_devid, tag, - &status); - if (!err && !status) - break; - - delay(ASYNC_STATUS_POLL_PERIOD); - timeout -= ASYNC_STATUS_POLL_PERIOD; - } - - if (status != 0) - return EIO; - - memcpy(buf + nread * sd->sd_blksize, (u_char *)dma_buf, - nsectors * sd->sd_blksize); - nread += nsectors; - nleft -= nsectors; - } - - return err; - -#undef MIN -#undef BOUNCE_SECTORS -#undef ASYNC_STATUS_POLL_PERIOD -} - -void ps3stor_print(struct ps3_stordev *sd) -{ -} diff --git a/stand/powerpc/ps3/ps3stor.h b/stand/powerpc/ps3/ps3stor.h deleted file mode 100644 index 350b716..0000000 --- a/stand/powerpc/ps3/ps3stor.h +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (C) 2011 glevand (geoffrey.levand@mail.ru) - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _PS3_STOR_H -#define _PS3_STOR_H - -#define PS3_STOR_DEV_MAXREGS 8 - -struct ps3_storreg { - uint64_t sr_id; - uint64_t sr_start; - uint64_t sr_size; -}; - -struct ps3_stordev { - int sd_type; - unsigned int sd_busidx; - unsigned int sd_devidx; - uint64_t sd_busid; - uint64_t sd_devid; - uint64_t sd_blksize; - uint64_t sd_nblocks; - uint64_t sd_nregs; - struct ps3_storreg sd_regs[PS3_STOR_DEV_MAXREGS]; - uint64_t sd_dmabase; -}; - -int ps3stor_setup(struct ps3_stordev *sd, int type); - -int ps3stor_read_sectors(struct ps3_stordev *sd, int regidx, - uint64_t start_sector, uint64_t sector_count, uint64_t flags, char *buf); - -void ps3stor_print(struct ps3_stordev *sd); - -#endif diff --git a/stand/powerpc/ps3/start.S b/stand/powerpc/ps3/start.S deleted file mode 100644 index 570b3f5..0000000 --- a/stand/powerpc/ps3/start.S +++ /dev/null @@ -1,169 +0,0 @@ -/*- - * Copyright (C) 2010 Nathan Whitehorn - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#define LOCORE - -#include <machine/trap.h> - -/* - * KBoot and simulators will start this program from the _start symbol, with - * r3 pointing to a flattened device tree (kexec), r4 the physical address - * at which we were loaded, and r5 0 (kexec) or a pointer to Open Firmware - * (simulator). If r4 is non-zero, the first order of business is relocating - * ourselves to 0. In the kboot case, the PPE secondary thread will enter - * at 0x60. - * - * If started directly by the LV1 hypervisor, we are loaded to address 0 - * and execution on both threads begins at 0x100 (EXC_RST). - */ - -#define CACHELINE_SIZE 128 -#define SPR_CTRL 136 - -/* KBoot thread 0 entry -- do relocation, then jump to main */ -.global _start -_start: - mfmsr %r31 - clrldi %r31,%r31,1 - mtmsrd %r31 - isync - cmpwi %r4,0 - bne relocate_self -relocated_start: - lis %r1,0x100 - bl main - -. = 0x40 -.global secondary_spin_sem -secondary_spin_sem: - .long 0 - -. = 0x60 -thread1_start_kboot: - mfmsr %r31 - clrldi %r31,%r31,1 - mtmsrd %r31 - isync - - ba thread1_start /* kboot copies the first 256 bytes to - * address 0, so we are safe to jump - * (and stay) there */ - -thread1_start: - li %r3,secondary_spin_sem@l -1: lwz %r1,0(%r3) /* Spin on SECONDARY_SPIN_SEM_ADDRESS */ - cmpwi %r1,0 - beq 1b /* If the semaphore is still zero, spin again */ - - /* We have been woken up by thread 0 */ - li %r0,0x100 /* Invalidate reset vector cache line */ - icbi 0,%r0 - isync - sync - ba 0x100 /* Jump to the reset vector */ - -. = EXC_RST -exc_rst: - mfmsr %r31 - clrldi %r31,%r31,1 - mtmsrd %r31 - isync - - mfspr %r3,SPR_CTRL - /* The first two bits of r0 are 01 (thread 1) or 10 (thread 0) */ - cntlzw %r3,%r3 /* Now 0 for thread 0, 1 for thread 1 */ - - cmpwi %r3,0 - bne thread1_start /* Send thread 1 to wait */ - - b relocated_start /* Main entry point for thread 0 */ - -#define EXCEPTION_HANDLER(exc) \ -. = exc; \ - li %r3, exc; \ - mfsrr0 %r4; \ - mfmsr %r5; \ - clrldi %r6,%r5,1; \ - mtmsrd %r6; \ - isync; \ - lis %r1,0x100; \ - bl ppc_exception - -EXCEPTION_HANDLER(EXC_MCHK) -EXCEPTION_HANDLER(EXC_DSI) -EXCEPTION_HANDLER(EXC_DSE) -EXCEPTION_HANDLER(EXC_ISI) -EXCEPTION_HANDLER(EXC_ISE) -EXCEPTION_HANDLER(EXC_EXI) -EXCEPTION_HANDLER(EXC_ALI) -EXCEPTION_HANDLER(EXC_PGM) -EXCEPTION_HANDLER(EXC_FPU) -EXCEPTION_HANDLER(EXC_DECR) -EXCEPTION_HANDLER(EXC_SC) - -relocate_self: - /* We enter this with r4 the physical offset for our relocation */ - lis %r8,_end@ha /* r8: copy length */ - addi %r8,%r8,_end@l - li %r5,0x100 /* r5: dest address */ -1: add %r6,%r4,%r5 /* r6: source address */ - ld %r7,0(%r6) - std %r7,0(%r5) - addi %r5,%r5,8 - cmpw %r5,%r8 - blt 1b - - /* - * Now invalidate the cacheline with the second half of relocate_self, - * and do an absolute branch there in case we overwrote part of - * ourselves. - */ - - lis %r9,relocate_self_cache@ha - addi %r9,%r9,relocate_self_cache@l - dcbst 0,%r9 - sync - icbi 0,%r9 - sync - isync - ba relocate_self_cache - -relocate_self_cache: - /* Now invalidate the icache */ - li %r5,0x100 -2: dcbst 0,%r5 - sync - icbi 0,%r5 - sync - isync - cmpw %r5,%r8 - addi %r5,%r5,CACHELINE_SIZE - blt 2b - - /* All done: absolute jump to relocated entry point */ - ba relocated_start - diff --git a/stand/powerpc/ps3/version b/stand/powerpc/ps3/version deleted file mode 100644 index fdac54e..0000000 --- a/stand/powerpc/ps3/version +++ /dev/null @@ -1,8 +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.3: Added GPT support to disk. -0.2: Added disk support. -0.1: Initial PS3/PowerPC version. diff --git a/stand/powerpc/uboot/Makefile b/stand/powerpc/uboot/Makefile index 6622cf1..623c464 100644 --- a/stand/powerpc/uboot/Makefile +++ b/stand/powerpc/uboot/Makefile @@ -21,7 +21,6 @@ SRCS= start.S conf.c vers.c SRCS+= ucmpdi2.c # Always add MI sources -HELP_FILES= # Disable .include "${BOOTSRC}/loader.mk" .PATH: ${SYSDIR}/libkern diff --git a/stand/sparc64/boot1/Makefile b/stand/sparc64/boot1/Makefile index 36e3968..97bfa67 100644 --- a/stand/sparc64/boot1/Makefile +++ b/stand/sparc64/boot1/Makefile @@ -27,6 +27,4 @@ ${FILES}: boot1.aout boot1.aout: boot1.elf elf2aout -o ${.TARGET} ${.ALLSRC} -boot1.o: ${SASRC}/ufsread.c - .include <bsd.prog.mk> diff --git a/stand/sparc64/loader/Makefile b/stand/sparc64/loader/Makefile index 5388761..5b7c09a 100644 --- a/stand/sparc64/loader/Makefile +++ b/stand/sparc64/loader/Makefile @@ -30,9 +30,7 @@ CFLAGS+= -DLOADER_DEBUG .endif .if exists(${.CURDIR}/help.sparc64) -HELP_FILES+= help.sparc64 -.else -HELP_FILES= +HELP_FILES= ${.CURDIR}/help.sparc64 .endif # Always add MI sources diff --git a/stand/sparc64/loader/main.c b/stand/sparc64/loader/main.c index e8cdf5f..140885d 100644 --- a/stand/sparc64/loader/main.c +++ b/stand/sparc64/loader/main.c @@ -101,7 +101,6 @@ static inline u_long itlb_get_data_sun4u(u_int, u_int); static int itlb_enter_sun4u(u_int, u_long data, vm_offset_t); static vm_offset_t itlb_va_to_pa_sun4u(vm_offset_t); static void itlb_relocate_locked0_sun4u(void); -extern vm_offset_t md_load(char *, vm_offset_t *, vm_offset_t *); static int sparc64_autoload(void); static ssize_t sparc64_readin(const int, vm_offset_t, const size_t); static ssize_t sparc64_copyin(const void *, vm_offset_t, size_t); @@ -903,7 +902,7 @@ main(int (*openfirm)(void *)) printf("bootpath=\"%s\"\n", bootpath); /* Give control to the machine independent loader code. */ - interact(NULL); + interact(); return (1); } diff --git a/stand/sparc64/loader/metadata.c b/stand/sparc64/loader/metadata.c index a3b3eb5..51b3d7e 100644 --- a/stand/sparc64/loader/metadata.c +++ b/stand/sparc64/loader/metadata.c @@ -275,7 +275,7 @@ md_copymodules(vm_offset_t addr) * - The kernel environment is copied into kernel space. * - Module metadata are formatted and placed in kernel space. */ -int +vm_offset_t md_load(char *args, vm_offset_t *modulep, vm_offset_t *dtbp) { struct preloaded_file *kfp; diff --git a/stand/uboot/common/main.c b/stand/uboot/common/main.c index c4efb1f..a88a8bd 100644 --- a/stand/uboot/common/main.c +++ b/stand/uboot/common/main.c @@ -500,7 +500,7 @@ main(int argc, char **argv) archsw.arch_readin = uboot_readin; archsw.arch_autoload = uboot_autoload; - interact(NULL); /* doesn't return */ + interact(); /* doesn't return */ return (0); } @@ -526,7 +526,8 @@ command_reboot(int argc, char *argv[]) ub_reset(); printf("Reset failed!\n"); - while(1); + while (1); + __unreachable(); } COMMAND_SET(devinfo, "devinfo", "show U-Boot devices", command_devinfo); diff --git a/stand/uboot/lib/glue.c b/stand/uboot/lib/glue.c index 312075a..016d435 100644 --- a/stand/uboot/lib/glue.c +++ b/stand/uboot/lib/glue.c @@ -187,6 +187,8 @@ ub_reset(void) { syscall(API_RESET, NULL); + while (1); /* fallback if API_RESET failed */ + __unreachable(); } static struct mem_region mr[UB_MAX_MR]; diff --git a/stand/uboot/lib/glue.h b/stand/uboot/lib/glue.h index 4c2da66..cb012ed 100644 --- a/stand/uboot/lib/glue.h +++ b/stand/uboot/lib/glue.h @@ -78,7 +78,7 @@ void ub_putc(char); void ub_puts(const char *); /* system */ -void ub_reset(void); +void ub_reset(void) __dead2; struct sys_info *ub_get_sys_info(void); /* time */ diff --git a/stand/userboot/test/Makefile b/stand/userboot/test/Makefile index 1bc6679..e40a7bc 100644 --- a/stand/userboot/test/Makefile +++ b/stand/userboot/test/Makefile @@ -9,6 +9,6 @@ MK_SSP= no PROG= test INTERNALPROG= -CFLAGS+= -I${BOOTSRC}/userboot +CFLAGS= -I${BOOTSRC}/userboot .include <bsd.prog.mk> diff --git a/stand/userboot/test/test.c b/stand/userboot/test/test.c index 6c885c3..5efe1d3 100644 --- a/stand/userboot/test/test.c +++ b/stand/userboot/test/test.c @@ -422,7 +422,7 @@ int main(int argc, char** argv) { void *h; - void (*func)(struct loader_callbacks *, void *, int, int); + void (*func)(struct loader_callbacks *, void *, int, int) __dead2; int opt; char *disk_image = NULL; const char *userboot_obj = "/boot/userboot.so"; diff --git a/stand/userboot/userboot/Makefile b/stand/userboot/userboot/Makefile index cf235a9..5946257 100644 --- a/stand/userboot/userboot/Makefile +++ b/stand/userboot/userboot/Makefile @@ -49,7 +49,6 @@ LIBZFSBOOT= ${BOOTOBJ}/zfs/libzfsboot.a .endif # Always add MI sources -HELP_FILES= # Disable .include "${BOOTSRC}/loader.mk" CFLAGS+= -I. DPADD+= ${LIBFICL} ${LIBZFSBOOT} ${LIBSA} diff --git a/stand/userboot/userboot/main.c b/stand/userboot/userboot/main.c index 7f59eb7..95bff17 100644 --- a/stand/userboot/userboot/main.c +++ b/stand/userboot/userboot/main.c @@ -142,7 +142,7 @@ loader_main(struct loader_callbacks *cb, void *arg, int version, int ndisks) if (setjmp(jb)) return; - interact(NULL); /* doesn't return */ + interact(); /* doesn't return */ exit(0); } diff --git a/stand/zfs/zfsimpl.c b/stand/zfs/zfsimpl.c index 6e0d9b6..d525085 100644 --- a/stand/zfs/zfsimpl.c +++ b/stand/zfs/zfsimpl.c @@ -43,6 +43,7 @@ struct zfsmount { objset_phys_t objset; uint64_t rootobj; }; +static struct zfsmount zfsmount __unused; /* * List of all vdevs, chained through v_alllink. @@ -913,7 +914,7 @@ spa_all_status(void) return (ret); } -uint64_t +static uint64_t vdev_label_offset(uint64_t psize, int l, uint64_t offset) { uint64_t label_offset; |