summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/boot/ia64/Makefile2
-rw-r--r--sys/boot/ia64/libski/Makefile36
-rw-r--r--sys/boot/ia64/libski/bootinfo.c227
-rw-r--r--sys/boot/ia64/libski/copy.c59
-rw-r--r--sys/boot/ia64/libski/delay.c36
-rw-r--r--sys/boot/ia64/libski/devicename.c237
-rw-r--r--sys/boot/ia64/libski/elf_freebsd.c240
-rw-r--r--sys/boot/ia64/libski/exit.c44
-rw-r--r--sys/boot/ia64/libski/libski.h90
-rw-r--r--sys/boot/ia64/libski/module.c42
-rw-r--r--sys/boot/ia64/libski/skiconsole.c98
-rw-r--r--sys/boot/ia64/libski/skifs.c192
-rw-r--r--sys/boot/ia64/libski/ssc.c42
-rw-r--r--sys/boot/ia64/libski/time.c65
-rw-r--r--sys/boot/ia64/ski/Makefile81
-rw-r--r--sys/boot/ia64/ski/bootinfo.c227
-rw-r--r--sys/boot/ia64/ski/conf.c88
-rw-r--r--sys/boot/ia64/ski/copy.c59
-rw-r--r--sys/boot/ia64/ski/delay.c36
-rw-r--r--sys/boot/ia64/ski/devicename.c237
-rw-r--r--sys/boot/ia64/ski/elf_freebsd.c240
-rw-r--r--sys/boot/ia64/ski/exit.c44
-rw-r--r--sys/boot/ia64/ski/ldscript.ia64135
-rw-r--r--sys/boot/ia64/ski/libski.h90
-rw-r--r--sys/boot/ia64/ski/main.c136
-rw-r--r--sys/boot/ia64/ski/skiconsole.c98
-rw-r--r--sys/boot/ia64/ski/skifs.c192
-rw-r--r--sys/boot/ia64/ski/ssc.c42
-rw-r--r--sys/boot/ia64/ski/time.c65
-rw-r--r--sys/boot/ia64/ski/version6
-rw-r--r--sys/boot/ia64/skiload/Makefile81
-rw-r--r--sys/boot/ia64/skiload/conf.c88
-rw-r--r--sys/boot/ia64/skiload/ldscript.ia64135
-rw-r--r--sys/boot/ia64/skiload/main.c136
-rw-r--r--sys/boot/ia64/skiload/version6
35 files changed, 3631 insertions, 1 deletions
diff --git a/sys/boot/ia64/Makefile b/sys/boot/ia64/Makefile
index 4dfb082..b8d7f32 100644
--- a/sys/boot/ia64/Makefile
+++ b/sys/boot/ia64/Makefile
@@ -1,5 +1,5 @@
# $FreeBSD$
-SUBDIR=
+SUBDIR= libski skiload
.include <bsd.subdir.mk>
diff --git a/sys/boot/ia64/libski/Makefile b/sys/boot/ia64/libski/Makefile
new file mode 100644
index 0000000..2e5e968
--- /dev/null
+++ b/sys/boot/ia64/libski/Makefile
@@ -0,0 +1,36 @@
+# $FreeBSD$
+
+LIB= ski
+NOPIC= true
+NOPROFILE= true
+INTERNALLIB= true
+INTERNALSTATICLIB= true
+
+SRCS= skiconsole.c time.c copy.c devicename.c module.c exit.c
+SRCS+= delay.c skifs.c elf_freebsd.c bootinfo.c ssc.c
+
+CFLAGS+= -fpic -g
+CFLAGS+= -I${.CURDIR}/../include
+CFLAGS+= -I${.CURDIR}/../include/${MACHINE_ARCH}
+CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/
+
+# Pick up the bootstrap header for some interface items
+CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I.
+
+.if ${MACHINE_ARCH} == "powerpc"
+CFLAGS+= -msoft-float
+.endif
+
+.ifdef(BOOT_DISK_DEBUG)
+# Make the disk code more talkative
+CFLAGS+= -DDISK_DEBUG
+.endif
+
+machine:
+ ln -sf ${.CURDIR}/../../../${MACHINE_ARCH}/include machine
+
+CLEANFILES+= machine
+
+.include <bsd.lib.mk>
+
+beforedepend ${OBJS}: machine
diff --git a/sys/boot/ia64/libski/bootinfo.c b/sys/boot/ia64/libski/bootinfo.c
new file mode 100644
index 0000000..d3d95ca
--- /dev/null
+++ b/sys/boot/ia64/libski/bootinfo.c
@@ -0,0 +1,227 @@
+/*-
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+#include <stand.h>
+#include <string.h>
+#include <sys/param.h>
+#include <sys/reboot.h>
+#include <sys/linker.h>
+#include <machine/elf.h>
+#include <machine/bootinfo.h>
+#include "bootstrap.h"
+
+extern char *ski_fmtdev(void *vdev);
+
+/*
+ * 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
+bi_copyenv(vm_offset_t addr)
+{
+ struct env_var *ep;
+
+ /* traverse the environment */
+ for (ep = environ; ep != NULL; ep = ep->ev_next) {
+ ski_copyin(ep->ev_name, addr, strlen(ep->ev_name));
+ addr += strlen(ep->ev_name);
+ ski_copyin("=", addr, 1);
+ addr++;
+ if (ep->ev_value != NULL) {
+ ski_copyin(ep->ev_value, addr, strlen(ep->ev_value));
+ addr += strlen(ep->ev_value);
+ }
+ ski_copyin("", addr, 1);
+ addr++;
+ }
+ ski_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
+ */
+#define COPY32(v, a) { \
+ u_int32_t x = (v); \
+ ski_copyin(&x, a, sizeof(x)); \
+ a += sizeof(x); \
+}
+
+#define MOD_STR(t, a, s) { \
+ COPY32(t, a); \
+ COPY32(strlen(s) + 1, a); \
+ ski_copyin(s, a, strlen(s) + 1); \
+ a += roundup(strlen(s) + 1, sizeof(u_int64_t));\
+}
+
+#define MOD_NAME(a, s) MOD_STR(MODINFO_NAME, a, s)
+#define MOD_TYPE(a, s) MOD_STR(MODINFO_TYPE, a, s)
+#define MOD_ARGS(a, s) MOD_STR(MODINFO_ARGS, a, s)
+
+#define MOD_VAR(t, a, s) { \
+ COPY32(t, a); \
+ COPY32(sizeof(s), a); \
+ ski_copyin(&s, a, sizeof(s)); \
+ a += roundup(sizeof(s), sizeof(u_int64_t)); \
+}
+
+#define MOD_ADDR(a, s) MOD_VAR(MODINFO_ADDR, a, s)
+#define MOD_SIZE(a, s) MOD_VAR(MODINFO_SIZE, a, s)
+
+#define MOD_METADATA(a, mm) { \
+ COPY32(MODINFO_METADATA | mm->md_type, a); \
+ COPY32(mm->md_size, a); \
+ ski_copyin(mm->md_data, a, mm->md_size); \
+ a += roundup(mm->md_size, sizeof(u_int64_t));\
+}
+
+#define MOD_END(a) { \
+ COPY32(MODINFO_END, a); \
+ COPY32(0, a); \
+}
+
+vm_offset_t
+bi_copymodules(vm_offset_t addr)
+{
+ struct preloaded_file *fp;
+ struct file_metadata *md;
+
+ /* 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); /* this field must come first */
+ MOD_TYPE(addr, fp->f_type);
+ if (fp->f_args)
+ MOD_ARGS(addr, fp->f_args);
+ MOD_ADDR(addr, fp->f_addr);
+ MOD_SIZE(addr, fp->f_size);
+ for (md = fp->f_metadata; md != NULL; md = md->md_next)
+ if (!(md->md_type & MODINFOMD_NOCOPY))
+ MOD_METADATA(addr, md);
+ }
+ MOD_END(addr);
+ return(addr);
+}
+
+/*
+ * Load the information expected by an alpha kernel.
+ *
+ * - The kernel environment is copied into kernel space.
+ * - Module metadata are formatted and placed in kernel space.
+ */
+int
+bi_load(struct bootinfo *bi, struct preloaded_file *fp)
+{
+ char *rootdevname;
+ struct ski_devdesc *rootdev;
+ struct preloaded_file *xp;
+ vm_offset_t addr, bootinfo_addr;
+ u_int pad;
+ char *kernelname;
+ vm_offset_t ssym, esym;
+ struct file_metadata *md;
+
+ /*
+ * 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");
+ ski_getdev((void **)(&rootdev), rootdevname, NULL);
+ if (rootdev == NULL) { /* bad $rootdev/$currdev */
+ printf("can't determine root device\n");
+ return(EINVAL);
+ }
+
+ /* Try reading the /etc/fstab file to select the root device */
+ getrootmount(ski_fmtdev((void *)rootdev));
+ free(rootdev);
+
+ ssym = esym = 0;
+ if ((md = file_findmetadata(fp, MODINFOMD_SSYM)) != NULL)
+ ssym = *((vm_offset_t *)&(md->md_data));
+ if ((md = file_findmetadata(fp, MODINFOMD_ESYM)) != NULL)
+ esym = *((vm_offset_t *)&(md->md_data));
+ if (ssym == 0 || esym == 0)
+ ssym = esym = 0; /* sanity */
+
+ bi->bi_symtab = ssym;
+ bi->bi_esymtab = esym;
+
+ /* 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 */
+ pad = (u_int)addr & PAGE_MASK;
+ if (pad != 0) {
+ pad = PAGE_SIZE - pad;
+ addr += pad;
+ }
+
+ /* copy our environment */
+ bi->bi_envp = addr;
+ addr = bi_copyenv(addr);
+
+ /* pad to a page boundary */
+ pad = (u_int)addr & PAGE_MASK;
+ if (pad != 0) {
+ pad = PAGE_SIZE - pad;
+ addr += pad;
+ }
+ /* copy module list and metadata */
+ bi->bi_modulep = addr;
+ addr = bi_copymodules(addr);
+
+ /* all done copying stuff in, save end of loaded object space */
+ bi->bi_kernend = addr;
+
+ kernelname = getenv("kernelname");
+ if (kernelname) {
+ strncpy(bi->bi_kernel, kernelname, sizeof(bi->bi_kernel) - 1);
+ }
+
+ return(0);
+}
diff --git a/sys/boot/ia64/libski/copy.c b/sys/boot/ia64/libski/copy.c
new file mode 100644
index 0000000..4445460
--- /dev/null
+++ b/sys/boot/ia64/libski/copy.c
@@ -0,0 +1,59 @@
+/*-
+ * 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.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
+
+/*
+ * MD primitives supporting placement of module data
+ *
+ * XXX should check load address/size against memory top.
+ */
+#include <stand.h>
+
+#include <machine/ia64_cpu.h>
+
+int
+ski_copyin(void *src, vm_offset_t dest, size_t len)
+{
+ bcopy(src, (void*) IA64_RR_MASK(dest), len);
+ return (len);
+}
+
+int
+ski_copyout(vm_offset_t src, void *dest, size_t len)
+{
+ bcopy((void*) IA64_RR_MASK(src), dest, len);
+ return (len);
+}
+
+int
+ski_readin(int fd, vm_offset_t dest, size_t len)
+{
+ return (read(fd, (void*) IA64_RR_MASK(dest), len));
+}
diff --git a/sys/boot/ia64/libski/delay.c b/sys/boot/ia64/libski/delay.c
new file mode 100644
index 0000000..b4e9dff
--- /dev/null
+++ b/sys/boot/ia64/libski/delay.c
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2001 Doug Rabson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
+
+void
+delay(int usecs)
+{
+ return;
+}
diff --git a/sys/boot/ia64/libski/devicename.c b/sys/boot/ia64/libski/devicename.c
new file mode 100644
index 0000000..35356c3
--- /dev/null
+++ b/sys/boot/ia64/libski/devicename.c
@@ -0,0 +1,237 @@
+/*-
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+#include <stand.h>
+#include <string.h>
+#include <sys/disklabel.h>
+#include "bootstrap.h"
+#include "libski.h"
+
+static int ski_parsedev(struct ski_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
+ski_getdev(void **vdev, const char *devspec, const char **path)
+{
+ struct ski_devdesc **dev = (struct ski_devdesc **)vdev;
+ int rv;
+
+ /*
+ * If it looks like this is just a path and no
+ * device, go with the current device.
+ */
+ if ((devspec == NULL) ||
+ (devspec[0] == '/') ||
+ (strchr(devspec, ':') == NULL)) {
+
+ if (((rv = ski_parsedev(dev, getenv("currdev"), NULL)) == 0) &&
+ (path != NULL))
+ *path = devspec;
+ return(rv);
+ }
+
+ /*
+ * Try to parse the device name off the beginning of the devspec
+ */
+ return(ski_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>[s<slice>][<partition>]:
+ *
+ */
+static int
+ski_parsedev(struct ski_devdesc **dev, const char *devspec, const char **path)
+{
+ struct ski_devdesc *idev;
+ struct devsw *dv;
+ int i, unit, slice, partition, err;
+ char *cp;
+ const char *np;
+
+ /* minimum length check */
+ if (strlen(devspec) < 2)
+ return(EINVAL);
+
+ /* look for a device that matches */
+ for (i = 0, dv = NULL; devsw[i] != NULL; i++) {
+ if (!strncmp(devspec, devsw[i]->dv_name, strlen(devsw[i]->dv_name))) {
+ dv = devsw[i];
+ break;
+ }
+ }
+
+ if (dv == NULL)
+ return(ENOENT);
+ idev = malloc(sizeof(struct ski_devdesc));
+ err = 0;
+ np = (devspec + strlen(dv->dv_name));
+
+ switch(dv->dv_type) {
+ case DEVT_NONE: /* XXX what to do here? Do we care? */
+ break;
+
+ case DEVT_DISK:
+ unit = -1;
+ slice = -1;
+ partition = -1;
+ if (*np && (*np != ':')) {
+ unit = strtol(np, &cp, 10); /* next comes the unit number */
+ if (cp == np) {
+ err = EUNIT;
+ goto fail;
+ }
+ if (*cp == 's') { /* got a slice number */
+ np = cp + 1;
+ slice = strtol(np, &cp, 10);
+ if (cp == np) {
+ err = ESLICE;
+ goto fail;
+ }
+ }
+ if (*cp && (*cp != ':')) {
+ partition = *cp - 'a'; /* get a partition number */
+ if ((partition < 0) || (partition >= MAXPARTITIONS)) {
+ err = EPART;
+ goto fail;
+ }
+ cp++;
+ }
+ }
+ if (*cp && (*cp != ':')) {
+ err = EINVAL;
+ goto fail;
+ }
+
+ idev->d_kind.skidisk.unit = unit;
+ idev->d_kind.skidisk.slice = slice;
+ idev->d_kind.skidisk.partition = partition;
+
+ if (path != NULL)
+ *path = (*cp == 0) ? cp : cp + 1;
+ break;
+
+ case DEVT_NET:
+ unit = 0;
+
+ if (*np && (*np != ':')) {
+ unit = strtol(np, &cp, 0); /* get unit number if present */
+ if (cp == np) {
+ err = EUNIT;
+ goto fail;
+ }
+ }
+ if (*cp && (*cp != ':')) {
+ err = EINVAL;
+ goto fail;
+ }
+
+ idev->d_kind.netif.unit = unit;
+ if (path != NULL)
+ *path = (*cp == 0) ? cp : cp + 1;
+ break;
+
+ default:
+ err = EINVAL;
+ goto fail;
+ }
+ idev->d_dev = dv;
+ idev->d_type = dv->dv_type;
+ if (dev == NULL) {
+ free(idev);
+ } else {
+ *dev = idev;
+ }
+ return(0);
+
+ fail:
+ free(idev);
+ return(err);
+}
+
+
+char *
+ski_fmtdev(void *vdev)
+{
+ struct ski_devdesc *dev = (struct ski_devdesc *)vdev;
+ static char buf[128]; /* XXX device length constant? */
+ char *cp;
+
+ switch(dev->d_type) {
+ case DEVT_NONE:
+ strcpy(buf, "(no device)");
+ break;
+
+ case DEVT_DISK:
+ cp = buf;
+ cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_kind.skidisk.unit);
+ if (dev->d_kind.skidisk.slice > 0)
+ cp += sprintf(cp, "s%d", dev->d_kind.skidisk.slice);
+ if (dev->d_kind.skidisk.partition >= 0)
+ cp += sprintf(cp, "%c", dev->d_kind.skidisk.partition + 'a');
+ strcat(cp, ":");
+ break;
+
+ case DEVT_NET:
+ sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_kind.netif.unit);
+ break;
+ }
+ return(buf);
+}
+
+
+/*
+ * Set currdev to suit the value being supplied in (value)
+ */
+int
+ski_setcurrdev(struct env_var *ev, int flags, void *value)
+{
+ struct ski_devdesc *ncurr;
+ int rv;
+
+ if ((rv = ski_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/sys/boot/ia64/libski/elf_freebsd.c b/sys/boot/ia64/libski/elf_freebsd.c
new file mode 100644
index 0000000..336048e
--- /dev/null
+++ b/sys/boot/ia64/libski/elf_freebsd.c
@@ -0,0 +1,240 @@
+/* $FreeBSD$ */
+/* $NetBSD: loadfile.c,v 1.10 1998/06/25 06:45:46 ross Exp $ */
+
+/*-
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)boot.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <stand.h>
+#include <string.h>
+
+#include <sys/param.h>
+#include <sys/linker.h>
+#include <machine/elf.h>
+#include <machine/bootinfo.h>
+
+#include "bootstrap.h"
+#include "libski.h"
+
+#define _KERNEL
+
+static int elf_exec(struct preloaded_file *amp);
+int bi_load(struct bootinfo *, struct preloaded_file *);
+
+struct file_format ia64_elf = { elf_loadfile, elf_exec };
+
+#define PTE_MA_WB 0
+#define PTE_MA_UC 4
+#define PTE_MA_UCE 5
+#define PTE_MA_WC 6
+#define PTE_MA_NATPAGE 7
+
+#define PTE_PL_KERN 0
+#define PTE_PL_USER 3
+
+#define PTE_AR_R 0
+#define PTE_AR_RX 1
+#define PTE_AR_RW 2
+#define PTE_AR_RWX 3
+#define PTE_AR_R_RW 4
+#define PTE_AR_RX_RWX 5
+#define PTE_AR_RWX_RW 6
+#define PTE_AR_X_RX 7
+
+/*
+ * A short-format VHPT entry. Also matches the TLB insertion format.
+ */
+struct ia64_pte {
+ u_int64_t pte_p :1; /* bits 0..0 */
+ u_int64_t pte_rv1 :1; /* bits 1..1 */
+ u_int64_t pte_ma :3; /* bits 2..4 */
+ u_int64_t pte_a :1; /* bits 5..5 */
+ u_int64_t pte_d :1; /* bits 6..6 */
+ u_int64_t pte_pl :2; /* bits 7..8 */
+ u_int64_t pte_ar :3; /* bits 9..11 */
+ u_int64_t pte_ppn :38; /* bits 12..49 */
+ u_int64_t pte_rv2 :2; /* bits 50..51 */
+ u_int64_t pte_ed :1; /* bits 52..52 */
+ u_int64_t pte_ig :11; /* bits 53..63 */
+};
+
+void
+enter_kernel(const char* filename, u_int64_t start)
+{
+ printf("Entering %s at 0x%lx...\n", filename, start);
+
+ while (*filename == '/')
+ filename++;
+ ssc(0, (u_int64_t) filename, 0, 0, SSC_LOAD_SYMBOLS);
+
+ __asm __volatile("mov cr.ipsr=%0"
+ :: "r"(IA64_PSR_IC
+ | IA64_PSR_DT
+ | IA64_PSR_RT
+ | IA64_PSR_IT
+ | IA64_PSR_BN));
+ __asm __volatile("mov cr.iip=%0" :: "r"(start));
+ __asm __volatile("mov cr.ifs=r0;;");
+ __asm __volatile("rfi;;");
+}
+
+static int
+elf_exec(struct preloaded_file *fp)
+{
+ struct file_metadata *md;
+ Elf_Ehdr *hdr;
+ struct ia64_pte pte;
+ struct bootinfo *bi;
+
+ if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL)
+ return(EFTYPE); /* XXX actually EFUCKUP */
+ hdr = (Elf_Ehdr *)&(md->md_data);
+
+ /*
+ * Ugly hack, similar to linux. Dump the bootinfo into a
+ * special page reserved in the link map.
+ */
+ bi = (struct bootinfo *) 0x508000;
+ bzero(bi, sizeof(struct bootinfo));
+ bi_load(bi, fp);
+
+ /*
+ * Region 6 is direct mapped UC and region 7 is direct mapped
+ * WC. The details of this is controlled by the Alt {I,D}TLB
+ * handlers. Here we just make sure that they have the largest
+ * possible page size to minimise TLB usage.
+ */
+ ia64_set_rr(IA64_RR_BASE(6), (6 << 8) | (28 << 2));
+ ia64_set_rr(IA64_RR_BASE(7), (7 << 8) | (28 << 2));
+
+ bzero(&pte, sizeof(pte));
+ pte.pte_p = 1;
+ pte.pte_ma = PTE_MA_WB;
+ pte.pte_a = 1;
+ pte.pte_d = 1;
+ pte.pte_pl = PTE_PL_KERN;
+ pte.pte_ar = PTE_AR_RWX;
+ pte.pte_ppn = 0;
+
+ __asm __volatile("mov cr.ifa=%0" :: "r"(IA64_RR_BASE(7)));
+ __asm __volatile("mov cr.itir=%0" :: "r"(28 << 2));
+ __asm __volatile("srlz.i;;");
+ __asm __volatile("itr.i itr[%0]=%1;;"
+ :: "r"(0), "r"(*(u_int64_t*)&pte));
+ __asm __volatile("itr.d dtr[%0]=%1;;"
+ :: "r"(0), "r"(*(u_int64_t*)&pte));
+ __asm __volatile("srlz.i;;");
+
+ enter_kernel(fp->f_name, hdr->e_entry);
+
+#if 0
+ static struct bootinfo_v1 bootinfo_v1;
+ struct file_metadata *md;
+ Elf_Ehdr *hdr;
+ int err;
+
+ if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL)
+ return(EFTYPE); /* XXX actually EFUCKUP */
+ hdr = (Elf_Ehdr *)&(md->md_data);
+
+ /* XXX ffp_save does not appear to be used in the kernel.. */
+ bzero(&bootinfo_v1, sizeof(bootinfo_v1));
+ err = bi_load(&bootinfo_v1, &ffp_save, fp);
+ if (err)
+ return(err);
+
+ /*
+ * Fill in the bootinfo for the kernel.
+ */
+ strncpy(bootinfo_v1.booted_kernel, fp->f_name,
+ sizeof(bootinfo_v1.booted_kernel));
+ prom_getenv(PROM_E_BOOTED_OSFLAGS, bootinfo_v1.boot_flags,
+ sizeof(bootinfo_v1.boot_flags));
+ bootinfo_v1.hwrpb = (void *)HWRPB_ADDR;
+ bootinfo_v1.hwrpbsize = ((struct rpb *)HWRPB_ADDR)->rpb_size;
+ bootinfo_v1.cngetc = NULL;
+ bootinfo_v1.cnputc = NULL;
+ bootinfo_v1.cnpollc = NULL;
+
+ printf("Entering %s at 0x%lx...\n", fp->f_name, hdr->e_entry);
+ exit(0);
+ closeall();
+ alpha_pal_imb();
+ (*(void (*)())hdr->e_entry)(ffp_save, ptbr_save,
+ BOOTINFO_MAGIC, &bootinfo_v1, 1, 0);
+#endif
+}
+
+
+
diff --git a/sys/boot/ia64/libski/exit.c b/sys/boot/ia64/libski/exit.c
new file mode 100644
index 0000000..5648580
--- /dev/null
+++ b/sys/boot/ia64/libski/exit.c
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 2000 Doug Rabson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <stddef.h>
+#include <stand.h>
+#include <stdarg.h>
+
+#include "libski.h"
+
+void
+exit(int code)
+{
+ ssc(code, 0, 0, 0, SSC_EXIT);
+}
diff --git a/sys/boot/ia64/libski/libski.h b/sys/boot/ia64/libski/libski.h
new file mode 100644
index 0000000..e4d0932
--- /dev/null
+++ b/sys/boot/ia64/libski/libski.h
@@ -0,0 +1,90 @@
+/*-
+ * Copyright (c) 2001 Doug Rabson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * SKI fully-qualified device descriptor
+ */
+struct ski_devdesc {
+ struct devsw *d_dev;
+ int d_type;
+#define DEVT_NONE 0
+#define DEVT_DISK 1
+#define DEVT_NET 2
+ union {
+ struct {
+ int unit;
+ int slice;
+ int partition;
+ } skidisk;
+ struct {
+ int unit; /* XXX net layer lives over these? */
+ } netif;
+ } d_kind;
+};
+
+extern int ski_getdev(void **vdev, const char *devspec, const char **path);
+extern char *ski_fmtdev(void *vdev);
+extern int ski_setcurrdev(struct env_var *ev, int flags, void *value);
+
+#define MAXDEV 31 /* maximum number of distinct devices */
+
+typedef unsigned long physaddr_t;
+
+/* exported devices XXX rename? */
+extern struct devsw skifs_dev;
+extern struct devsw ski_disk;
+extern struct netif_driver ski_net;
+
+/* Wrapper over SKI filesystems. */
+extern struct fs_ops ski_fsops;
+
+/* this is in startup code */
+extern void delay(int);
+extern void reboot(void);
+
+extern ssize_t ski_copyin(const void *src, vm_offset_t dest, size_t len);
+extern ssize_t ski_copyout(const vm_offset_t src, void *dest, size_t len);
+extern ssize_t ski_readin(int fd, vm_offset_t dest, size_t len);
+
+extern int ski_boot(void);
+extern int ski_autoload(void);
+
+#define SSC_CONSOLE_INIT 20
+#define SSC_GETCHAR 21
+#define SSC_PUTCHAR 31
+#define SSC_OPEN 50
+#define SSC_CLOSE 51
+#define SSC_READ 52
+#define SSC_WRITE 53
+#define SSC_GET_COMPLETION 54
+#define SSC_WAIT_COMPLETION 55
+#define SSC_EXIT 66
+#define SSC_LOAD_SYMBOLS 69
+
+u_int64_t ssc(u_int64_t in0, u_int64_t in1, u_int64_t in2, u_int64_t in3,
+ int which);
diff --git a/sys/boot/ia64/libski/module.c b/sys/boot/ia64/libski/module.c
new file mode 100644
index 0000000..596add7
--- /dev/null
+++ b/sys/boot/ia64/libski/module.c
@@ -0,0 +1,42 @@
+/*-
+ * 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.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
+
+#include <stand.h>
+
+/*
+ * Use voodoo to load modules required by current hardware.
+ */
+int
+ski_autoload(void)
+{
+ /* XXX use PnP to locate stuff here */
+ return (0);
+}
diff --git a/sys/boot/ia64/libski/skiconsole.c b/sys/boot/ia64/libski/skiconsole.c
new file mode 100644
index 0000000..5038ce1
--- /dev/null
+++ b/sys/boot/ia64/libski/skiconsole.c
@@ -0,0 +1,98 @@
+/*-
+ * Copyright (c) 2000 Doug Rabson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
+
+#include <stand.h>
+
+#include "bootstrap.h"
+#include "libski.h"
+
+static void
+ski_cons_probe(struct console *cp)
+{
+ cp->c_flags |= C_PRESENTIN | C_PRESENTOUT;
+}
+
+static int
+ski_cons_init(int arg)
+{
+ ssc(0, 0, 0, 0, SSC_CONSOLE_INIT);
+ return 0;
+}
+
+void
+ski_cons_putchar(int c)
+{
+ ssc(c, 0, 0, 0, SSC_PUTCHAR);
+}
+
+static int pollchar = -1;
+
+int
+ski_cons_getchar()
+{
+ int c;
+
+ if (pollchar > 0) {
+ c = pollchar;
+ pollchar = -1;
+ return c;
+ }
+
+ do {
+ c = ssc(0, 0, 0, 0, SSC_GETCHAR);
+ } while (c == 0);
+
+ return c;
+}
+
+int
+ski_cons_poll()
+{
+ int c;
+ if (pollchar > 0)
+ return 1;
+ c = ssc(0, 0, 0, 0, SSC_GETCHAR);
+ if (!c)
+ return 0;
+ pollchar = c;
+ return 1;
+}
+
+struct console ski_console = {
+ "ski",
+ "ia64 SKI console",
+ 0,
+ ski_cons_probe,
+ ski_cons_init,
+ ski_cons_putchar,
+ ski_cons_getchar,
+ ski_cons_poll
+};
diff --git a/sys/boot/ia64/libski/skifs.c b/sys/boot/ia64/libski/skifs.c
new file mode 100644
index 0000000..d5b0ee9
--- /dev/null
+++ b/sys/boot/ia64/libski/skifs.c
@@ -0,0 +1,192 @@
+/*-
+ * Copyright (c) 2001 Doug Rabson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <stddef.h>
+#include <stand.h>
+#include <stdarg.h>
+
+#include "libski.h"
+
+struct disk_req {
+ unsigned long addr;
+ unsigned len;
+};
+
+struct disk_stat {
+ int fd;
+ unsigned count;
+};
+
+static int
+skifs_open(const char *path, struct open_file *f)
+{
+ int fd;
+
+ /*
+ * Skip leading '/' so that our pretend filesystem starts in
+ * the current working directory.
+ */
+ while (*path == '/')
+ path++;
+
+ fd = ssc((u_int64_t) path, 1, 0, 0, SSC_OPEN);
+ if (fd > 0) {
+ f->f_fsdata = (void*)(u_int64_t) fd;
+ return 0;
+ }
+ return ENOENT;
+}
+
+static int
+skifs_close(struct open_file *f)
+{
+ ssc((u_int64_t) f->f_fsdata, 0, 0, 0, SSC_CLOSE);
+ return 0;
+}
+
+static int
+skifs_read(struct open_file *f, void *buf, size_t size, size_t *resid)
+{
+ struct disk_req req;
+ struct disk_stat stat;
+
+ req.len = size;
+ req.addr = (u_int64_t) buf;
+ ssc((u_int64_t) f->f_fsdata, 1, (u_int64_t) &req, f->f_offset, SSC_READ);
+ stat.fd = (u_int64_t) f->f_fsdata;
+ ssc((u_int64_t)&stat, 0, 0, 0, SSC_WAIT_COMPLETION);
+
+ *resid = size - stat.count;
+ f->f_offset += stat.count;
+ return 0;
+}
+
+static off_t
+skifs_seek(struct open_file *f, off_t offset, int where)
+{
+ u_int64_t base;
+
+ switch (where) {
+ case SEEK_SET:
+ base = 0;
+ break;
+
+ case SEEK_CUR:
+ base = f->f_offset;
+ break;
+
+ case SEEK_END:
+ printf("can't find end of file in SKI\n");
+ base = f->f_offset;
+ break;
+ }
+
+ f->f_offset = base + offset;
+ return base;
+}
+
+static int
+skifs_stat(struct open_file *f, struct stat *sb)
+{
+ bzero(sb, sizeof(*sb));
+ sb->st_mode = S_IFREG | S_IRUSR;
+ return 0;
+}
+
+static int
+skifs_readdir(struct open_file *f, struct dirent *d)
+{
+ return ENOENT;
+}
+
+struct fs_ops ski_fsops = {
+ "fs",
+ skifs_open,
+ skifs_close,
+ skifs_read,
+ null_write,
+ skifs_seek,
+ skifs_stat,
+ skifs_readdir
+};
+
+static int
+skifs_dev_init(void)
+{
+ return 0;
+}
+
+/*
+ * Print information about disks
+ */
+static void
+skifs_dev_print(int verbose)
+{
+}
+
+/*
+ * Attempt to open the disk described by (dev) for use by (f).
+ *
+ * Note that the philosophy here is "give them exactly what
+ * they ask for". This is necessary because being too "smart"
+ * about what the user might want leads to complications.
+ * (eg. given no slice or partition value, with a disk that is
+ * sliced - are they after the first BSD slice, or the DOS
+ * slice before it?)
+ */
+static int
+skifs_dev_open(struct open_file *f, ...)
+{
+ return 0;
+}
+
+static int
+skifs_dev_close(struct open_file *f)
+{
+
+ return 0;
+}
+
+static int
+skifs_dev_strategy(void *devdata, int rw, daddr_t dblk, size_t size, char *buf, size_t *rsize)
+{
+ return 0;
+}
+
+struct devsw skifs_dev = {
+ "fs",
+ DEVT_DISK,
+ skifs_dev_init,
+ skifs_dev_strategy,
+ skifs_dev_open,
+ skifs_dev_close,
+ noioctl,
+ skifs_dev_print
+};
diff --git a/sys/boot/ia64/libski/ssc.c b/sys/boot/ia64/libski/ssc.c
new file mode 100644
index 0000000..b15cf25
--- /dev/null
+++ b/sys/boot/ia64/libski/ssc.c
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 2001 Doug Rabson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <stand.h>
+#include "libski.h"
+
+u_int64_t
+ssc(u_int64_t in0, u_int64_t in1, u_int64_t in2, u_int64_t in3, int which)
+{
+ register u_int64_t ret0 __asm("r8");
+
+ __asm __volatile("mov r15=%1\n\t"
+ "break 0x80001"
+ : "=r"(ret0)
+ : "r"(which), "r"(in0), "r"(in1), "r"(in2), "r"(in3));
+ return ret0;
+}
diff --git a/sys/boot/ia64/libski/time.c b/sys/boot/ia64/libski/time.c
new file mode 100644
index 0000000..1005528
--- /dev/null
+++ b/sys/boot/ia64/libski/time.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 1999, 2000
+ * Intel Corporation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ *
+ * This product includes software developed by Intel Corporation and
+ * its contributors.
+ *
+ * 4. Neither the name of Intel Corporation or its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION 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 INTEL CORPORATION OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
+
+#include <time.h>
+#include <sys/time.h>
+
+/*
+// Accurate only for the past couple of centuries;
+// that will probably do.
+//
+// (#defines From FreeBSD 3.2 lib/libc/stdtime/tzfile.h)
+*/
+
+#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
+#define SECSPERHOUR ( 60*60 )
+#define SECSPERDAY (24 * SECSPERHOUR)
+
+
+time_t
+time(time_t *tloc)
+{
+ return 0; /* XXX */
+}
diff --git a/sys/boot/ia64/ski/Makefile b/sys/boot/ia64/ski/Makefile
new file mode 100644
index 0000000..d3e6cf3
--- /dev/null
+++ b/sys/boot/ia64/ski/Makefile
@@ -0,0 +1,81 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../common
+
+PROG= skiload
+NOMAN=
+NEWVERSWHAT= "ia64 SKI boot" ${MACHINE_ARCH}
+
+SRCS+= main.c conf.c
+
+# Enable BootForth
+BOOT_FORTH= yes
+CFLAGS+= -g
+CFLAGS+= -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/alpha
+.if BOOT_FORTH
+CFLAGS+= -DBOOT_FORTH
+.if exists(${.OBJDIR}/../../ficl/libficl.a)
+LIBFICL= ${.OBJDIR}/../../ficl/libficl.a
+.else
+LIBFICL= ${.CURDIR}/../../ficl/libficl.a
+.endif
+.else
+LIBFICL=
+.endif
+
+LIBSTAND= -lstand
+LIBSKI= ${.CURDIR}/../libski/libski.a
+
+# Always add MI sources
+.PATH: ${.CURDIR}/../../common
+.include <${.CURDIR}/../../common/Makefile.inc>
+
+CFLAGS+= -I-
+CFLAGS+= -I${.CURDIR}/../include
+CFLAGS+= -I${.CURDIR}/../include/${MACHINE_ARCH}
+CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}
+CFLAGS+= -I${.CURDIR}/../../.. -I.
+CFLAGS+= -I${.CURDIR}/../libski
+CFLAGS+= -DLOADER
+
+LDFLAGS= -nostdlib -T ldscript.ia64
+
+CLEANFILES+= vers.c vers.o ${PROG}.list
+CLEANFILES+= loader.help
+CLEANFILES+= machine
+
+all: ${PROG}
+
+vers.o: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
+ sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
+ ${CC} -c vers.c
+
+${PROG}.help: help.common help.efi
+ cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk \
+ > ${.TARGET}
+
+beforeinstall:
+.if exists(${.OBJDIR}/loader.help)
+ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
+ ${.OBJDIR}/${PROG}.help ${DESTDIR}/boot
+.else
+ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
+ ${.CURDIR}/${PROG}.help ${DESTDIR}/boot
+.endif
+
+# Other fragments still to be brought in from ../Makfile.booters?
+start.o: ${.CURDIR}/../libefi/arch/${MACHINE_ARCH}/start.S
+ ${CC} -c ${CFLAGS} ${.IMPSRC}
+
+machine:
+ ln -sf ${.CURDIR}/../../../${MACHINE_ARCH}/include machine
+
+${PROG}: ${OBJS} ${LIBFICL} ${LIBSTAND} ${LIBSKI} vers.o
+ ${LD} ${LDFLAGS} -o ${PROG} -M \
+ ${OBJS} vers.o \
+ ${LIBFICL} ${LIBSTAND} ${LIBSKI} ${LIBSTAND} \
+ > ${.OBJDIR}/${PROG}.list
+
+.include <bsd.prog.mk>
+
+beforedepend ${OBJS}: machine
diff --git a/sys/boot/ia64/ski/bootinfo.c b/sys/boot/ia64/ski/bootinfo.c
new file mode 100644
index 0000000..d3d95ca
--- /dev/null
+++ b/sys/boot/ia64/ski/bootinfo.c
@@ -0,0 +1,227 @@
+/*-
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+#include <stand.h>
+#include <string.h>
+#include <sys/param.h>
+#include <sys/reboot.h>
+#include <sys/linker.h>
+#include <machine/elf.h>
+#include <machine/bootinfo.h>
+#include "bootstrap.h"
+
+extern char *ski_fmtdev(void *vdev);
+
+/*
+ * 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
+bi_copyenv(vm_offset_t addr)
+{
+ struct env_var *ep;
+
+ /* traverse the environment */
+ for (ep = environ; ep != NULL; ep = ep->ev_next) {
+ ski_copyin(ep->ev_name, addr, strlen(ep->ev_name));
+ addr += strlen(ep->ev_name);
+ ski_copyin("=", addr, 1);
+ addr++;
+ if (ep->ev_value != NULL) {
+ ski_copyin(ep->ev_value, addr, strlen(ep->ev_value));
+ addr += strlen(ep->ev_value);
+ }
+ ski_copyin("", addr, 1);
+ addr++;
+ }
+ ski_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
+ */
+#define COPY32(v, a) { \
+ u_int32_t x = (v); \
+ ski_copyin(&x, a, sizeof(x)); \
+ a += sizeof(x); \
+}
+
+#define MOD_STR(t, a, s) { \
+ COPY32(t, a); \
+ COPY32(strlen(s) + 1, a); \
+ ski_copyin(s, a, strlen(s) + 1); \
+ a += roundup(strlen(s) + 1, sizeof(u_int64_t));\
+}
+
+#define MOD_NAME(a, s) MOD_STR(MODINFO_NAME, a, s)
+#define MOD_TYPE(a, s) MOD_STR(MODINFO_TYPE, a, s)
+#define MOD_ARGS(a, s) MOD_STR(MODINFO_ARGS, a, s)
+
+#define MOD_VAR(t, a, s) { \
+ COPY32(t, a); \
+ COPY32(sizeof(s), a); \
+ ski_copyin(&s, a, sizeof(s)); \
+ a += roundup(sizeof(s), sizeof(u_int64_t)); \
+}
+
+#define MOD_ADDR(a, s) MOD_VAR(MODINFO_ADDR, a, s)
+#define MOD_SIZE(a, s) MOD_VAR(MODINFO_SIZE, a, s)
+
+#define MOD_METADATA(a, mm) { \
+ COPY32(MODINFO_METADATA | mm->md_type, a); \
+ COPY32(mm->md_size, a); \
+ ski_copyin(mm->md_data, a, mm->md_size); \
+ a += roundup(mm->md_size, sizeof(u_int64_t));\
+}
+
+#define MOD_END(a) { \
+ COPY32(MODINFO_END, a); \
+ COPY32(0, a); \
+}
+
+vm_offset_t
+bi_copymodules(vm_offset_t addr)
+{
+ struct preloaded_file *fp;
+ struct file_metadata *md;
+
+ /* 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); /* this field must come first */
+ MOD_TYPE(addr, fp->f_type);
+ if (fp->f_args)
+ MOD_ARGS(addr, fp->f_args);
+ MOD_ADDR(addr, fp->f_addr);
+ MOD_SIZE(addr, fp->f_size);
+ for (md = fp->f_metadata; md != NULL; md = md->md_next)
+ if (!(md->md_type & MODINFOMD_NOCOPY))
+ MOD_METADATA(addr, md);
+ }
+ MOD_END(addr);
+ return(addr);
+}
+
+/*
+ * Load the information expected by an alpha kernel.
+ *
+ * - The kernel environment is copied into kernel space.
+ * - Module metadata are formatted and placed in kernel space.
+ */
+int
+bi_load(struct bootinfo *bi, struct preloaded_file *fp)
+{
+ char *rootdevname;
+ struct ski_devdesc *rootdev;
+ struct preloaded_file *xp;
+ vm_offset_t addr, bootinfo_addr;
+ u_int pad;
+ char *kernelname;
+ vm_offset_t ssym, esym;
+ struct file_metadata *md;
+
+ /*
+ * 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");
+ ski_getdev((void **)(&rootdev), rootdevname, NULL);
+ if (rootdev == NULL) { /* bad $rootdev/$currdev */
+ printf("can't determine root device\n");
+ return(EINVAL);
+ }
+
+ /* Try reading the /etc/fstab file to select the root device */
+ getrootmount(ski_fmtdev((void *)rootdev));
+ free(rootdev);
+
+ ssym = esym = 0;
+ if ((md = file_findmetadata(fp, MODINFOMD_SSYM)) != NULL)
+ ssym = *((vm_offset_t *)&(md->md_data));
+ if ((md = file_findmetadata(fp, MODINFOMD_ESYM)) != NULL)
+ esym = *((vm_offset_t *)&(md->md_data));
+ if (ssym == 0 || esym == 0)
+ ssym = esym = 0; /* sanity */
+
+ bi->bi_symtab = ssym;
+ bi->bi_esymtab = esym;
+
+ /* 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 */
+ pad = (u_int)addr & PAGE_MASK;
+ if (pad != 0) {
+ pad = PAGE_SIZE - pad;
+ addr += pad;
+ }
+
+ /* copy our environment */
+ bi->bi_envp = addr;
+ addr = bi_copyenv(addr);
+
+ /* pad to a page boundary */
+ pad = (u_int)addr & PAGE_MASK;
+ if (pad != 0) {
+ pad = PAGE_SIZE - pad;
+ addr += pad;
+ }
+ /* copy module list and metadata */
+ bi->bi_modulep = addr;
+ addr = bi_copymodules(addr);
+
+ /* all done copying stuff in, save end of loaded object space */
+ bi->bi_kernend = addr;
+
+ kernelname = getenv("kernelname");
+ if (kernelname) {
+ strncpy(bi->bi_kernel, kernelname, sizeof(bi->bi_kernel) - 1);
+ }
+
+ return(0);
+}
diff --git a/sys/boot/ia64/ski/conf.c b/sys/boot/ia64/ski/conf.c
new file mode 100644
index 0000000..1322a81
--- /dev/null
+++ b/sys/boot/ia64/ski/conf.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 1997
+ * Matthias Drochner. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Matthias Drochner.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $NetBSD: conf.c,v 1.2 1997/03/22 09:03:29 thorpej Exp $
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
+
+#include <stand.h>
+
+#include "libski.h"
+
+/*
+ * We could use linker sets for some or all of these, but
+ * then we would have to control what ended up linked into
+ * the bootstrap. So it's easier to conditionalise things
+ * here.
+ *
+ * XXX rename these arrays to be consistent and less namespace-hostile
+ */
+
+/* Exported for libstand */
+struct devsw *devsw[] = {
+ &skifs_dev,
+ NULL
+};
+
+struct fs_ops *file_system[] = {
+ &ski_fsops,
+ &ufs_fsops,
+ &zipfs_fsops,
+ NULL
+};
+
+/* Exported for ia64 only */
+/*
+ * Sort formats so that those that can detect based on arguments
+ * rather than reading the file go first.
+ */
+extern struct file_format ia64_elf;
+
+struct file_format *file_formats[] = {
+ &ia64_elf,
+ NULL
+};
+
+/*
+ * Consoles
+ *
+ * We don't prototype these in libalpha.h because they require
+ * data structures from bootstrap.h as well.
+ */
+extern struct console ski_console;
+
+struct console *consoles[] = {
+ &ski_console,
+ NULL
+};
diff --git a/sys/boot/ia64/ski/copy.c b/sys/boot/ia64/ski/copy.c
new file mode 100644
index 0000000..4445460
--- /dev/null
+++ b/sys/boot/ia64/ski/copy.c
@@ -0,0 +1,59 @@
+/*-
+ * 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.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
+
+/*
+ * MD primitives supporting placement of module data
+ *
+ * XXX should check load address/size against memory top.
+ */
+#include <stand.h>
+
+#include <machine/ia64_cpu.h>
+
+int
+ski_copyin(void *src, vm_offset_t dest, size_t len)
+{
+ bcopy(src, (void*) IA64_RR_MASK(dest), len);
+ return (len);
+}
+
+int
+ski_copyout(vm_offset_t src, void *dest, size_t len)
+{
+ bcopy((void*) IA64_RR_MASK(src), dest, len);
+ return (len);
+}
+
+int
+ski_readin(int fd, vm_offset_t dest, size_t len)
+{
+ return (read(fd, (void*) IA64_RR_MASK(dest), len));
+}
diff --git a/sys/boot/ia64/ski/delay.c b/sys/boot/ia64/ski/delay.c
new file mode 100644
index 0000000..b4e9dff
--- /dev/null
+++ b/sys/boot/ia64/ski/delay.c
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2001 Doug Rabson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
+
+void
+delay(int usecs)
+{
+ return;
+}
diff --git a/sys/boot/ia64/ski/devicename.c b/sys/boot/ia64/ski/devicename.c
new file mode 100644
index 0000000..35356c3
--- /dev/null
+++ b/sys/boot/ia64/ski/devicename.c
@@ -0,0 +1,237 @@
+/*-
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+#include <stand.h>
+#include <string.h>
+#include <sys/disklabel.h>
+#include "bootstrap.h"
+#include "libski.h"
+
+static int ski_parsedev(struct ski_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
+ski_getdev(void **vdev, const char *devspec, const char **path)
+{
+ struct ski_devdesc **dev = (struct ski_devdesc **)vdev;
+ int rv;
+
+ /*
+ * If it looks like this is just a path and no
+ * device, go with the current device.
+ */
+ if ((devspec == NULL) ||
+ (devspec[0] == '/') ||
+ (strchr(devspec, ':') == NULL)) {
+
+ if (((rv = ski_parsedev(dev, getenv("currdev"), NULL)) == 0) &&
+ (path != NULL))
+ *path = devspec;
+ return(rv);
+ }
+
+ /*
+ * Try to parse the device name off the beginning of the devspec
+ */
+ return(ski_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>[s<slice>][<partition>]:
+ *
+ */
+static int
+ski_parsedev(struct ski_devdesc **dev, const char *devspec, const char **path)
+{
+ struct ski_devdesc *idev;
+ struct devsw *dv;
+ int i, unit, slice, partition, err;
+ char *cp;
+ const char *np;
+
+ /* minimum length check */
+ if (strlen(devspec) < 2)
+ return(EINVAL);
+
+ /* look for a device that matches */
+ for (i = 0, dv = NULL; devsw[i] != NULL; i++) {
+ if (!strncmp(devspec, devsw[i]->dv_name, strlen(devsw[i]->dv_name))) {
+ dv = devsw[i];
+ break;
+ }
+ }
+
+ if (dv == NULL)
+ return(ENOENT);
+ idev = malloc(sizeof(struct ski_devdesc));
+ err = 0;
+ np = (devspec + strlen(dv->dv_name));
+
+ switch(dv->dv_type) {
+ case DEVT_NONE: /* XXX what to do here? Do we care? */
+ break;
+
+ case DEVT_DISK:
+ unit = -1;
+ slice = -1;
+ partition = -1;
+ if (*np && (*np != ':')) {
+ unit = strtol(np, &cp, 10); /* next comes the unit number */
+ if (cp == np) {
+ err = EUNIT;
+ goto fail;
+ }
+ if (*cp == 's') { /* got a slice number */
+ np = cp + 1;
+ slice = strtol(np, &cp, 10);
+ if (cp == np) {
+ err = ESLICE;
+ goto fail;
+ }
+ }
+ if (*cp && (*cp != ':')) {
+ partition = *cp - 'a'; /* get a partition number */
+ if ((partition < 0) || (partition >= MAXPARTITIONS)) {
+ err = EPART;
+ goto fail;
+ }
+ cp++;
+ }
+ }
+ if (*cp && (*cp != ':')) {
+ err = EINVAL;
+ goto fail;
+ }
+
+ idev->d_kind.skidisk.unit = unit;
+ idev->d_kind.skidisk.slice = slice;
+ idev->d_kind.skidisk.partition = partition;
+
+ if (path != NULL)
+ *path = (*cp == 0) ? cp : cp + 1;
+ break;
+
+ case DEVT_NET:
+ unit = 0;
+
+ if (*np && (*np != ':')) {
+ unit = strtol(np, &cp, 0); /* get unit number if present */
+ if (cp == np) {
+ err = EUNIT;
+ goto fail;
+ }
+ }
+ if (*cp && (*cp != ':')) {
+ err = EINVAL;
+ goto fail;
+ }
+
+ idev->d_kind.netif.unit = unit;
+ if (path != NULL)
+ *path = (*cp == 0) ? cp : cp + 1;
+ break;
+
+ default:
+ err = EINVAL;
+ goto fail;
+ }
+ idev->d_dev = dv;
+ idev->d_type = dv->dv_type;
+ if (dev == NULL) {
+ free(idev);
+ } else {
+ *dev = idev;
+ }
+ return(0);
+
+ fail:
+ free(idev);
+ return(err);
+}
+
+
+char *
+ski_fmtdev(void *vdev)
+{
+ struct ski_devdesc *dev = (struct ski_devdesc *)vdev;
+ static char buf[128]; /* XXX device length constant? */
+ char *cp;
+
+ switch(dev->d_type) {
+ case DEVT_NONE:
+ strcpy(buf, "(no device)");
+ break;
+
+ case DEVT_DISK:
+ cp = buf;
+ cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_kind.skidisk.unit);
+ if (dev->d_kind.skidisk.slice > 0)
+ cp += sprintf(cp, "s%d", dev->d_kind.skidisk.slice);
+ if (dev->d_kind.skidisk.partition >= 0)
+ cp += sprintf(cp, "%c", dev->d_kind.skidisk.partition + 'a');
+ strcat(cp, ":");
+ break;
+
+ case DEVT_NET:
+ sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_kind.netif.unit);
+ break;
+ }
+ return(buf);
+}
+
+
+/*
+ * Set currdev to suit the value being supplied in (value)
+ */
+int
+ski_setcurrdev(struct env_var *ev, int flags, void *value)
+{
+ struct ski_devdesc *ncurr;
+ int rv;
+
+ if ((rv = ski_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/sys/boot/ia64/ski/elf_freebsd.c b/sys/boot/ia64/ski/elf_freebsd.c
new file mode 100644
index 0000000..336048e
--- /dev/null
+++ b/sys/boot/ia64/ski/elf_freebsd.c
@@ -0,0 +1,240 @@
+/* $FreeBSD$ */
+/* $NetBSD: loadfile.c,v 1.10 1998/06/25 06:45:46 ross Exp $ */
+
+/*-
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)boot.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <stand.h>
+#include <string.h>
+
+#include <sys/param.h>
+#include <sys/linker.h>
+#include <machine/elf.h>
+#include <machine/bootinfo.h>
+
+#include "bootstrap.h"
+#include "libski.h"
+
+#define _KERNEL
+
+static int elf_exec(struct preloaded_file *amp);
+int bi_load(struct bootinfo *, struct preloaded_file *);
+
+struct file_format ia64_elf = { elf_loadfile, elf_exec };
+
+#define PTE_MA_WB 0
+#define PTE_MA_UC 4
+#define PTE_MA_UCE 5
+#define PTE_MA_WC 6
+#define PTE_MA_NATPAGE 7
+
+#define PTE_PL_KERN 0
+#define PTE_PL_USER 3
+
+#define PTE_AR_R 0
+#define PTE_AR_RX 1
+#define PTE_AR_RW 2
+#define PTE_AR_RWX 3
+#define PTE_AR_R_RW 4
+#define PTE_AR_RX_RWX 5
+#define PTE_AR_RWX_RW 6
+#define PTE_AR_X_RX 7
+
+/*
+ * A short-format VHPT entry. Also matches the TLB insertion format.
+ */
+struct ia64_pte {
+ u_int64_t pte_p :1; /* bits 0..0 */
+ u_int64_t pte_rv1 :1; /* bits 1..1 */
+ u_int64_t pte_ma :3; /* bits 2..4 */
+ u_int64_t pte_a :1; /* bits 5..5 */
+ u_int64_t pte_d :1; /* bits 6..6 */
+ u_int64_t pte_pl :2; /* bits 7..8 */
+ u_int64_t pte_ar :3; /* bits 9..11 */
+ u_int64_t pte_ppn :38; /* bits 12..49 */
+ u_int64_t pte_rv2 :2; /* bits 50..51 */
+ u_int64_t pte_ed :1; /* bits 52..52 */
+ u_int64_t pte_ig :11; /* bits 53..63 */
+};
+
+void
+enter_kernel(const char* filename, u_int64_t start)
+{
+ printf("Entering %s at 0x%lx...\n", filename, start);
+
+ while (*filename == '/')
+ filename++;
+ ssc(0, (u_int64_t) filename, 0, 0, SSC_LOAD_SYMBOLS);
+
+ __asm __volatile("mov cr.ipsr=%0"
+ :: "r"(IA64_PSR_IC
+ | IA64_PSR_DT
+ | IA64_PSR_RT
+ | IA64_PSR_IT
+ | IA64_PSR_BN));
+ __asm __volatile("mov cr.iip=%0" :: "r"(start));
+ __asm __volatile("mov cr.ifs=r0;;");
+ __asm __volatile("rfi;;");
+}
+
+static int
+elf_exec(struct preloaded_file *fp)
+{
+ struct file_metadata *md;
+ Elf_Ehdr *hdr;
+ struct ia64_pte pte;
+ struct bootinfo *bi;
+
+ if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL)
+ return(EFTYPE); /* XXX actually EFUCKUP */
+ hdr = (Elf_Ehdr *)&(md->md_data);
+
+ /*
+ * Ugly hack, similar to linux. Dump the bootinfo into a
+ * special page reserved in the link map.
+ */
+ bi = (struct bootinfo *) 0x508000;
+ bzero(bi, sizeof(struct bootinfo));
+ bi_load(bi, fp);
+
+ /*
+ * Region 6 is direct mapped UC and region 7 is direct mapped
+ * WC. The details of this is controlled by the Alt {I,D}TLB
+ * handlers. Here we just make sure that they have the largest
+ * possible page size to minimise TLB usage.
+ */
+ ia64_set_rr(IA64_RR_BASE(6), (6 << 8) | (28 << 2));
+ ia64_set_rr(IA64_RR_BASE(7), (7 << 8) | (28 << 2));
+
+ bzero(&pte, sizeof(pte));
+ pte.pte_p = 1;
+ pte.pte_ma = PTE_MA_WB;
+ pte.pte_a = 1;
+ pte.pte_d = 1;
+ pte.pte_pl = PTE_PL_KERN;
+ pte.pte_ar = PTE_AR_RWX;
+ pte.pte_ppn = 0;
+
+ __asm __volatile("mov cr.ifa=%0" :: "r"(IA64_RR_BASE(7)));
+ __asm __volatile("mov cr.itir=%0" :: "r"(28 << 2));
+ __asm __volatile("srlz.i;;");
+ __asm __volatile("itr.i itr[%0]=%1;;"
+ :: "r"(0), "r"(*(u_int64_t*)&pte));
+ __asm __volatile("itr.d dtr[%0]=%1;;"
+ :: "r"(0), "r"(*(u_int64_t*)&pte));
+ __asm __volatile("srlz.i;;");
+
+ enter_kernel(fp->f_name, hdr->e_entry);
+
+#if 0
+ static struct bootinfo_v1 bootinfo_v1;
+ struct file_metadata *md;
+ Elf_Ehdr *hdr;
+ int err;
+
+ if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL)
+ return(EFTYPE); /* XXX actually EFUCKUP */
+ hdr = (Elf_Ehdr *)&(md->md_data);
+
+ /* XXX ffp_save does not appear to be used in the kernel.. */
+ bzero(&bootinfo_v1, sizeof(bootinfo_v1));
+ err = bi_load(&bootinfo_v1, &ffp_save, fp);
+ if (err)
+ return(err);
+
+ /*
+ * Fill in the bootinfo for the kernel.
+ */
+ strncpy(bootinfo_v1.booted_kernel, fp->f_name,
+ sizeof(bootinfo_v1.booted_kernel));
+ prom_getenv(PROM_E_BOOTED_OSFLAGS, bootinfo_v1.boot_flags,
+ sizeof(bootinfo_v1.boot_flags));
+ bootinfo_v1.hwrpb = (void *)HWRPB_ADDR;
+ bootinfo_v1.hwrpbsize = ((struct rpb *)HWRPB_ADDR)->rpb_size;
+ bootinfo_v1.cngetc = NULL;
+ bootinfo_v1.cnputc = NULL;
+ bootinfo_v1.cnpollc = NULL;
+
+ printf("Entering %s at 0x%lx...\n", fp->f_name, hdr->e_entry);
+ exit(0);
+ closeall();
+ alpha_pal_imb();
+ (*(void (*)())hdr->e_entry)(ffp_save, ptbr_save,
+ BOOTINFO_MAGIC, &bootinfo_v1, 1, 0);
+#endif
+}
+
+
+
diff --git a/sys/boot/ia64/ski/exit.c b/sys/boot/ia64/ski/exit.c
new file mode 100644
index 0000000..5648580
--- /dev/null
+++ b/sys/boot/ia64/ski/exit.c
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 2000 Doug Rabson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <stddef.h>
+#include <stand.h>
+#include <stdarg.h>
+
+#include "libski.h"
+
+void
+exit(int code)
+{
+ ssc(code, 0, 0, 0, SSC_EXIT);
+}
diff --git a/sys/boot/ia64/ski/ldscript.ia64 b/sys/boot/ia64/ski/ldscript.ia64
new file mode 100644
index 0000000..cb35a4b
--- /dev/null
+++ b/sys/boot/ia64/ski/ldscript.ia64
@@ -0,0 +1,135 @@
+/* $FreeBSD$ */
+OUTPUT_FORMAT("elf64-ia64-little", "elf64-ia64-little", "elf64-ia64-little")
+OUTPUT_ARCH(ia64)
+ENTRY(__start)
+SECTIONS
+{
+ /* Read-only sections, merged into text segment: */
+ . = 0x100000;
+
+ .text :
+ {
+ *(.text.ivt)
+ . += 8192;
+ *(.text)
+ *(.stub)
+ /* .gnu.warning sections are handled specially by elf32.em. */
+ *(.gnu.warning)
+ *(.gnu.linkonce.t*)
+ } =0x47ff041f
+ .interp : { *(.interp) }
+ .hash : { *(.hash) }
+ .dynsym : { *(.dynsym) }
+ .dynstr : { *(.dynstr) }
+ .gnu.version : { *(.gnu.version) }
+ .gnu.version_d : { *(.gnu.version_d) }
+ .gnu.version_r : { *(.gnu.version_r) }
+ .rel.text :
+ { *(.rel.text) *(.rel.gnu.linkonce.t*) }
+ .rela.text :
+ { *(.rela.text) *(.rela.gnu.linkonce.t*) }
+ .rel.data :
+ { *(.rel.data) *(.rel.gnu.linkonce.d*) }
+ .rela.data :
+ { *(.rela.data) *(.rela.gnu.linkonce.d*) }
+ .rel.rodata :
+ { *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
+ .rela.rodata :
+ { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
+ .rel.got : { *(.rel.got) }
+ .rela.got : { *(.rela.got) }
+ .rel.ctors : { *(.rel.ctors) }
+ .rela.ctors : { *(.rela.ctors) }
+ .rel.dtors : { *(.rel.dtors) }
+ .rela.dtors : { *(.rela.dtors) }
+ .rel.init : { *(.rel.init) }
+ .rela.init : { *(.rela.init) }
+ .rel.fini : { *(.rel.fini) }
+ .rela.fini : { *(.rela.fini) }
+ .rel.bss : { *(.rel.bss) }
+ .rela.bss : { *(.rela.bss) }
+ .rel.plt : { *(.rel.plt) }
+ .rela.plt : { *(.rela.plt) }
+ .init : { *(.init) } =0x47ff041f
+ _etext = .;
+ PROVIDE (etext = .);
+ .fini : { *(.fini) } =0x47ff041f
+ .rodata : { *(.rodata) *(.gnu.linkonce.r*) }
+ .rodata1 : { *(.rodata1) }
+ .reginfo : { *(.reginfo) }
+ /* Adjust the address for the data segment. We want to adjust up to
+ the same address within the page on the next page up. */
+ . = .;
+ .data :
+ {
+ *(.data)
+ *(.gnu.linkonce.d*)
+ CONSTRUCTORS
+ }
+ .data1 : { *(.data1) }
+ .ctors :
+ {
+ *(.ctors)
+ }
+ .dtors :
+ {
+ *(.dtors)
+ }
+ .plt : { *(.plt) }
+ /* gp points at .got+(1<<21) */
+ __gp = ALIGN(8) + 0x200000;
+ .got : { *(.got.plt) *(.got) }
+ .dynamic : { *(.dynamic) }
+ /* We want the small data sections together, so single-instruction offsets
+ can access them all, and initialized data all before uninitialized, so
+ we can shorten the on-disk segment size. */
+ .sdata : { *(.sdata) }
+ _edata = .;
+ PROVIDE (edata = .);
+ __bss_start = .;
+ .sbss : { *(.sbss) *(.scommon) }
+ .bss :
+ {
+ *(.dynbss)
+ *(.bss)
+ *(COMMON)
+ }
+ . = ALIGN(64 / 8);
+ _end = . ;
+ PROVIDE (end = .);
+ /* Stabs debugging sections. */
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
+ .stab.excl 0 : { *(.stab.excl) }
+ .stab.exclstr 0 : { *(.stab.exclstr) }
+ .stab.index 0 : { *(.stab.index) }
+ .stab.indexstr 0 : { *(.stab.indexstr) }
+ .comment 0 : { *(.comment) }
+ /* DWARF debug sections.
+ Symbols in the DWARF debugging sections are relative to the beginning
+ of the section so we begin them at 0. */
+ /* DWARF 1 */
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+ /* GNU DWARF 1 extensions */
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+ /* DWARF 1.1 and DWARF 2 */
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ /* DWARF 2 */
+ .debug_info 0 : { *(.debug_info) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+ /* SGI/MIPS DWARF 2 extensions */
+ .debug_weaknames 0 : { *(.debug_weaknames) }
+ .debug_funcnames 0 : { *(.debug_funcnames) }
+ .debug_typenames 0 : { *(.debug_typenames) }
+ .debug_varnames 0 : { *(.debug_varnames) }
+ /* These must appear regardless of . */
+}
+
diff --git a/sys/boot/ia64/ski/libski.h b/sys/boot/ia64/ski/libski.h
new file mode 100644
index 0000000..e4d0932
--- /dev/null
+++ b/sys/boot/ia64/ski/libski.h
@@ -0,0 +1,90 @@
+/*-
+ * Copyright (c) 2001 Doug Rabson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * SKI fully-qualified device descriptor
+ */
+struct ski_devdesc {
+ struct devsw *d_dev;
+ int d_type;
+#define DEVT_NONE 0
+#define DEVT_DISK 1
+#define DEVT_NET 2
+ union {
+ struct {
+ int unit;
+ int slice;
+ int partition;
+ } skidisk;
+ struct {
+ int unit; /* XXX net layer lives over these? */
+ } netif;
+ } d_kind;
+};
+
+extern int ski_getdev(void **vdev, const char *devspec, const char **path);
+extern char *ski_fmtdev(void *vdev);
+extern int ski_setcurrdev(struct env_var *ev, int flags, void *value);
+
+#define MAXDEV 31 /* maximum number of distinct devices */
+
+typedef unsigned long physaddr_t;
+
+/* exported devices XXX rename? */
+extern struct devsw skifs_dev;
+extern struct devsw ski_disk;
+extern struct netif_driver ski_net;
+
+/* Wrapper over SKI filesystems. */
+extern struct fs_ops ski_fsops;
+
+/* this is in startup code */
+extern void delay(int);
+extern void reboot(void);
+
+extern ssize_t ski_copyin(const void *src, vm_offset_t dest, size_t len);
+extern ssize_t ski_copyout(const vm_offset_t src, void *dest, size_t len);
+extern ssize_t ski_readin(int fd, vm_offset_t dest, size_t len);
+
+extern int ski_boot(void);
+extern int ski_autoload(void);
+
+#define SSC_CONSOLE_INIT 20
+#define SSC_GETCHAR 21
+#define SSC_PUTCHAR 31
+#define SSC_OPEN 50
+#define SSC_CLOSE 51
+#define SSC_READ 52
+#define SSC_WRITE 53
+#define SSC_GET_COMPLETION 54
+#define SSC_WAIT_COMPLETION 55
+#define SSC_EXIT 66
+#define SSC_LOAD_SYMBOLS 69
+
+u_int64_t ssc(u_int64_t in0, u_int64_t in1, u_int64_t in2, u_int64_t in3,
+ int which);
diff --git a/sys/boot/ia64/ski/main.c b/sys/boot/ia64/ski/main.c
new file mode 100644
index 0000000..01b407d
--- /dev/null
+++ b/sys/boot/ia64/ski/main.c
@@ -0,0 +1,136 @@
+/*-
+ * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
+ * Copyright (c) 1998,2000 Doug Rabson <dfr@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.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
+
+#include <stand.h>
+#include <string.h>
+#include <setjmp.h>
+#include <machine/fpu.h>
+
+#include "bootstrap.h"
+#include "libski.h"
+
+extern char bootprog_name[];
+extern char bootprog_rev[];
+extern char bootprog_date[];
+extern char bootprog_maker[];
+
+struct ski_devdesc currdev; /* our current device */
+struct arch_switch archsw; /* MI/MD interface boundary */
+
+void
+__start(void)
+{
+ static char stack[16384] __attribute__((aligned (16)));
+ static char malloc[512*1024];
+ int i;
+
+ __asm __volatile("movl gp=__gp;;");
+ __asm __volatile("mov sp=%0" :: "r"(&stack[16384]));
+ __asm __volatile("bsw.1;;");
+ __asm __volatile("mov ar.fpsr=%0" :: "r"(IA64_FPSR_DEFAULT));
+
+ /*
+ * initialise the heap as early as possible. Once this is done,
+ * alloc() is usable. The stack is buried inside us, so this is
+ * safe.
+ */
+ setheap((void *)malloc, (void *)(malloc + 512*1024));
+
+ /*
+ * XXX Chicken-and-egg problem; we want to have console output
+ * early, but some console attributes may depend on reading from
+ * eg. the boot device, which we can't do yet. We can use
+ * printf() etc. once this is done.
+ */
+ cons_probe();
+
+ /*
+ * Initialise the block cache
+ */
+ bcache_init(32, 512); /* 16k XXX tune this */
+
+ /*
+ * March through the device switch probing for things.
+ */
+ for (i = 0; devsw[i] != NULL; i++)
+ if (devsw[i]->dv_init != NULL)
+ (devsw[i]->dv_init)();
+
+ printf("\n");
+ printf("%s, Revision %s\n", bootprog_name, bootprog_rev);
+ printf("(%s, %s)\n", bootprog_maker, bootprog_date);
+#if 0
+ printf("Memory: %ld k\n", memsize() / 1024);
+#endif
+
+ /* XXX presumes that biosdisk is first in devsw */
+ currdev.d_dev = devsw[0];
+ currdev.d_type = currdev.d_dev->dv_type;
+ currdev.d_kind.skidisk.unit = 0;
+ /* XXX should be able to detect this, default to autoprobe */
+ currdev.d_kind.skidisk.slice = -1;
+ /* default to 'a' */
+ currdev.d_kind.skidisk.partition = 0;
+
+#if 0
+ /* Create arc-specific variables */
+ bootfile = GetEnvironmentVariable(ARCENV_BOOTFILE);
+ if (bootfile)
+ setenv("bootfile", bootfile, 1);
+#endif
+
+ env_setenv("currdev", EV_VOLATILE, ski_fmtdev(&currdev),
+ ski_setcurrdev, env_nounset);
+ env_setenv("loaddev", EV_VOLATILE, ski_fmtdev(&currdev), env_noset,
+ env_nounset);
+
+ setenv("LINES", "24", 1); /* optional */
+
+ archsw.arch_autoload = ski_autoload;
+ archsw.arch_getdev = ski_getdev;
+ archsw.arch_copyin = ski_copyin;
+ archsw.arch_copyout = ski_copyout;
+ archsw.arch_readin = ski_readin;
+
+ interact(); /* doesn't return */
+
+ exit(0);
+}
+
+COMMAND_SET(quit, "quit", "exit the loader", command_quit);
+
+static int
+command_quit(int argc, char *argv[])
+{
+ exit(0);
+ return (CMD_OK);
+}
diff --git a/sys/boot/ia64/ski/skiconsole.c b/sys/boot/ia64/ski/skiconsole.c
new file mode 100644
index 0000000..5038ce1
--- /dev/null
+++ b/sys/boot/ia64/ski/skiconsole.c
@@ -0,0 +1,98 @@
+/*-
+ * Copyright (c) 2000 Doug Rabson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
+
+#include <stand.h>
+
+#include "bootstrap.h"
+#include "libski.h"
+
+static void
+ski_cons_probe(struct console *cp)
+{
+ cp->c_flags |= C_PRESENTIN | C_PRESENTOUT;
+}
+
+static int
+ski_cons_init(int arg)
+{
+ ssc(0, 0, 0, 0, SSC_CONSOLE_INIT);
+ return 0;
+}
+
+void
+ski_cons_putchar(int c)
+{
+ ssc(c, 0, 0, 0, SSC_PUTCHAR);
+}
+
+static int pollchar = -1;
+
+int
+ski_cons_getchar()
+{
+ int c;
+
+ if (pollchar > 0) {
+ c = pollchar;
+ pollchar = -1;
+ return c;
+ }
+
+ do {
+ c = ssc(0, 0, 0, 0, SSC_GETCHAR);
+ } while (c == 0);
+
+ return c;
+}
+
+int
+ski_cons_poll()
+{
+ int c;
+ if (pollchar > 0)
+ return 1;
+ c = ssc(0, 0, 0, 0, SSC_GETCHAR);
+ if (!c)
+ return 0;
+ pollchar = c;
+ return 1;
+}
+
+struct console ski_console = {
+ "ski",
+ "ia64 SKI console",
+ 0,
+ ski_cons_probe,
+ ski_cons_init,
+ ski_cons_putchar,
+ ski_cons_getchar,
+ ski_cons_poll
+};
diff --git a/sys/boot/ia64/ski/skifs.c b/sys/boot/ia64/ski/skifs.c
new file mode 100644
index 0000000..d5b0ee9
--- /dev/null
+++ b/sys/boot/ia64/ski/skifs.c
@@ -0,0 +1,192 @@
+/*-
+ * Copyright (c) 2001 Doug Rabson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <stddef.h>
+#include <stand.h>
+#include <stdarg.h>
+
+#include "libski.h"
+
+struct disk_req {
+ unsigned long addr;
+ unsigned len;
+};
+
+struct disk_stat {
+ int fd;
+ unsigned count;
+};
+
+static int
+skifs_open(const char *path, struct open_file *f)
+{
+ int fd;
+
+ /*
+ * Skip leading '/' so that our pretend filesystem starts in
+ * the current working directory.
+ */
+ while (*path == '/')
+ path++;
+
+ fd = ssc((u_int64_t) path, 1, 0, 0, SSC_OPEN);
+ if (fd > 0) {
+ f->f_fsdata = (void*)(u_int64_t) fd;
+ return 0;
+ }
+ return ENOENT;
+}
+
+static int
+skifs_close(struct open_file *f)
+{
+ ssc((u_int64_t) f->f_fsdata, 0, 0, 0, SSC_CLOSE);
+ return 0;
+}
+
+static int
+skifs_read(struct open_file *f, void *buf, size_t size, size_t *resid)
+{
+ struct disk_req req;
+ struct disk_stat stat;
+
+ req.len = size;
+ req.addr = (u_int64_t) buf;
+ ssc((u_int64_t) f->f_fsdata, 1, (u_int64_t) &req, f->f_offset, SSC_READ);
+ stat.fd = (u_int64_t) f->f_fsdata;
+ ssc((u_int64_t)&stat, 0, 0, 0, SSC_WAIT_COMPLETION);
+
+ *resid = size - stat.count;
+ f->f_offset += stat.count;
+ return 0;
+}
+
+static off_t
+skifs_seek(struct open_file *f, off_t offset, int where)
+{
+ u_int64_t base;
+
+ switch (where) {
+ case SEEK_SET:
+ base = 0;
+ break;
+
+ case SEEK_CUR:
+ base = f->f_offset;
+ break;
+
+ case SEEK_END:
+ printf("can't find end of file in SKI\n");
+ base = f->f_offset;
+ break;
+ }
+
+ f->f_offset = base + offset;
+ return base;
+}
+
+static int
+skifs_stat(struct open_file *f, struct stat *sb)
+{
+ bzero(sb, sizeof(*sb));
+ sb->st_mode = S_IFREG | S_IRUSR;
+ return 0;
+}
+
+static int
+skifs_readdir(struct open_file *f, struct dirent *d)
+{
+ return ENOENT;
+}
+
+struct fs_ops ski_fsops = {
+ "fs",
+ skifs_open,
+ skifs_close,
+ skifs_read,
+ null_write,
+ skifs_seek,
+ skifs_stat,
+ skifs_readdir
+};
+
+static int
+skifs_dev_init(void)
+{
+ return 0;
+}
+
+/*
+ * Print information about disks
+ */
+static void
+skifs_dev_print(int verbose)
+{
+}
+
+/*
+ * Attempt to open the disk described by (dev) for use by (f).
+ *
+ * Note that the philosophy here is "give them exactly what
+ * they ask for". This is necessary because being too "smart"
+ * about what the user might want leads to complications.
+ * (eg. given no slice or partition value, with a disk that is
+ * sliced - are they after the first BSD slice, or the DOS
+ * slice before it?)
+ */
+static int
+skifs_dev_open(struct open_file *f, ...)
+{
+ return 0;
+}
+
+static int
+skifs_dev_close(struct open_file *f)
+{
+
+ return 0;
+}
+
+static int
+skifs_dev_strategy(void *devdata, int rw, daddr_t dblk, size_t size, char *buf, size_t *rsize)
+{
+ return 0;
+}
+
+struct devsw skifs_dev = {
+ "fs",
+ DEVT_DISK,
+ skifs_dev_init,
+ skifs_dev_strategy,
+ skifs_dev_open,
+ skifs_dev_close,
+ noioctl,
+ skifs_dev_print
+};
diff --git a/sys/boot/ia64/ski/ssc.c b/sys/boot/ia64/ski/ssc.c
new file mode 100644
index 0000000..b15cf25
--- /dev/null
+++ b/sys/boot/ia64/ski/ssc.c
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 2001 Doug Rabson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <stand.h>
+#include "libski.h"
+
+u_int64_t
+ssc(u_int64_t in0, u_int64_t in1, u_int64_t in2, u_int64_t in3, int which)
+{
+ register u_int64_t ret0 __asm("r8");
+
+ __asm __volatile("mov r15=%1\n\t"
+ "break 0x80001"
+ : "=r"(ret0)
+ : "r"(which), "r"(in0), "r"(in1), "r"(in2), "r"(in3));
+ return ret0;
+}
diff --git a/sys/boot/ia64/ski/time.c b/sys/boot/ia64/ski/time.c
new file mode 100644
index 0000000..1005528
--- /dev/null
+++ b/sys/boot/ia64/ski/time.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 1999, 2000
+ * Intel Corporation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ *
+ * This product includes software developed by Intel Corporation and
+ * its contributors.
+ *
+ * 4. Neither the name of Intel Corporation or its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION 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 INTEL CORPORATION OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
+
+#include <time.h>
+#include <sys/time.h>
+
+/*
+// Accurate only for the past couple of centuries;
+// that will probably do.
+//
+// (#defines From FreeBSD 3.2 lib/libc/stdtime/tzfile.h)
+*/
+
+#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
+#define SECSPERHOUR ( 60*60 )
+#define SECSPERDAY (24 * SECSPERHOUR)
+
+
+time_t
+time(time_t *tloc)
+{
+ return 0; /* XXX */
+}
diff --git a/sys/boot/ia64/ski/version b/sys/boot/ia64/ski/version
new file mode 100644
index 0000000..b87ca50
--- /dev/null
+++ b/sys/boot/ia64/ski/version
@@ -0,0 +1,6 @@
+$FreeBSD$
+
+NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this
+file is important. Make sure the current version number is on line 6.
+
+0.1: Initial SKI version.
diff --git a/sys/boot/ia64/skiload/Makefile b/sys/boot/ia64/skiload/Makefile
new file mode 100644
index 0000000..d3e6cf3
--- /dev/null
+++ b/sys/boot/ia64/skiload/Makefile
@@ -0,0 +1,81 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../common
+
+PROG= skiload
+NOMAN=
+NEWVERSWHAT= "ia64 SKI boot" ${MACHINE_ARCH}
+
+SRCS+= main.c conf.c
+
+# Enable BootForth
+BOOT_FORTH= yes
+CFLAGS+= -g
+CFLAGS+= -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/alpha
+.if BOOT_FORTH
+CFLAGS+= -DBOOT_FORTH
+.if exists(${.OBJDIR}/../../ficl/libficl.a)
+LIBFICL= ${.OBJDIR}/../../ficl/libficl.a
+.else
+LIBFICL= ${.CURDIR}/../../ficl/libficl.a
+.endif
+.else
+LIBFICL=
+.endif
+
+LIBSTAND= -lstand
+LIBSKI= ${.CURDIR}/../libski/libski.a
+
+# Always add MI sources
+.PATH: ${.CURDIR}/../../common
+.include <${.CURDIR}/../../common/Makefile.inc>
+
+CFLAGS+= -I-
+CFLAGS+= -I${.CURDIR}/../include
+CFLAGS+= -I${.CURDIR}/../include/${MACHINE_ARCH}
+CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}
+CFLAGS+= -I${.CURDIR}/../../.. -I.
+CFLAGS+= -I${.CURDIR}/../libski
+CFLAGS+= -DLOADER
+
+LDFLAGS= -nostdlib -T ldscript.ia64
+
+CLEANFILES+= vers.c vers.o ${PROG}.list
+CLEANFILES+= loader.help
+CLEANFILES+= machine
+
+all: ${PROG}
+
+vers.o: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
+ sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
+ ${CC} -c vers.c
+
+${PROG}.help: help.common help.efi
+ cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk \
+ > ${.TARGET}
+
+beforeinstall:
+.if exists(${.OBJDIR}/loader.help)
+ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
+ ${.OBJDIR}/${PROG}.help ${DESTDIR}/boot
+.else
+ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
+ ${.CURDIR}/${PROG}.help ${DESTDIR}/boot
+.endif
+
+# Other fragments still to be brought in from ../Makfile.booters?
+start.o: ${.CURDIR}/../libefi/arch/${MACHINE_ARCH}/start.S
+ ${CC} -c ${CFLAGS} ${.IMPSRC}
+
+machine:
+ ln -sf ${.CURDIR}/../../../${MACHINE_ARCH}/include machine
+
+${PROG}: ${OBJS} ${LIBFICL} ${LIBSTAND} ${LIBSKI} vers.o
+ ${LD} ${LDFLAGS} -o ${PROG} -M \
+ ${OBJS} vers.o \
+ ${LIBFICL} ${LIBSTAND} ${LIBSKI} ${LIBSTAND} \
+ > ${.OBJDIR}/${PROG}.list
+
+.include <bsd.prog.mk>
+
+beforedepend ${OBJS}: machine
diff --git a/sys/boot/ia64/skiload/conf.c b/sys/boot/ia64/skiload/conf.c
new file mode 100644
index 0000000..1322a81
--- /dev/null
+++ b/sys/boot/ia64/skiload/conf.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 1997
+ * Matthias Drochner. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Matthias Drochner.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $NetBSD: conf.c,v 1.2 1997/03/22 09:03:29 thorpej Exp $
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
+
+#include <stand.h>
+
+#include "libski.h"
+
+/*
+ * We could use linker sets for some or all of these, but
+ * then we would have to control what ended up linked into
+ * the bootstrap. So it's easier to conditionalise things
+ * here.
+ *
+ * XXX rename these arrays to be consistent and less namespace-hostile
+ */
+
+/* Exported for libstand */
+struct devsw *devsw[] = {
+ &skifs_dev,
+ NULL
+};
+
+struct fs_ops *file_system[] = {
+ &ski_fsops,
+ &ufs_fsops,
+ &zipfs_fsops,
+ NULL
+};
+
+/* Exported for ia64 only */
+/*
+ * Sort formats so that those that can detect based on arguments
+ * rather than reading the file go first.
+ */
+extern struct file_format ia64_elf;
+
+struct file_format *file_formats[] = {
+ &ia64_elf,
+ NULL
+};
+
+/*
+ * Consoles
+ *
+ * We don't prototype these in libalpha.h because they require
+ * data structures from bootstrap.h as well.
+ */
+extern struct console ski_console;
+
+struct console *consoles[] = {
+ &ski_console,
+ NULL
+};
diff --git a/sys/boot/ia64/skiload/ldscript.ia64 b/sys/boot/ia64/skiload/ldscript.ia64
new file mode 100644
index 0000000..cb35a4b
--- /dev/null
+++ b/sys/boot/ia64/skiload/ldscript.ia64
@@ -0,0 +1,135 @@
+/* $FreeBSD$ */
+OUTPUT_FORMAT("elf64-ia64-little", "elf64-ia64-little", "elf64-ia64-little")
+OUTPUT_ARCH(ia64)
+ENTRY(__start)
+SECTIONS
+{
+ /* Read-only sections, merged into text segment: */
+ . = 0x100000;
+
+ .text :
+ {
+ *(.text.ivt)
+ . += 8192;
+ *(.text)
+ *(.stub)
+ /* .gnu.warning sections are handled specially by elf32.em. */
+ *(.gnu.warning)
+ *(.gnu.linkonce.t*)
+ } =0x47ff041f
+ .interp : { *(.interp) }
+ .hash : { *(.hash) }
+ .dynsym : { *(.dynsym) }
+ .dynstr : { *(.dynstr) }
+ .gnu.version : { *(.gnu.version) }
+ .gnu.version_d : { *(.gnu.version_d) }
+ .gnu.version_r : { *(.gnu.version_r) }
+ .rel.text :
+ { *(.rel.text) *(.rel.gnu.linkonce.t*) }
+ .rela.text :
+ { *(.rela.text) *(.rela.gnu.linkonce.t*) }
+ .rel.data :
+ { *(.rel.data) *(.rel.gnu.linkonce.d*) }
+ .rela.data :
+ { *(.rela.data) *(.rela.gnu.linkonce.d*) }
+ .rel.rodata :
+ { *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
+ .rela.rodata :
+ { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
+ .rel.got : { *(.rel.got) }
+ .rela.got : { *(.rela.got) }
+ .rel.ctors : { *(.rel.ctors) }
+ .rela.ctors : { *(.rela.ctors) }
+ .rel.dtors : { *(.rel.dtors) }
+ .rela.dtors : { *(.rela.dtors) }
+ .rel.init : { *(.rel.init) }
+ .rela.init : { *(.rela.init) }
+ .rel.fini : { *(.rel.fini) }
+ .rela.fini : { *(.rela.fini) }
+ .rel.bss : { *(.rel.bss) }
+ .rela.bss : { *(.rela.bss) }
+ .rel.plt : { *(.rel.plt) }
+ .rela.plt : { *(.rela.plt) }
+ .init : { *(.init) } =0x47ff041f
+ _etext = .;
+ PROVIDE (etext = .);
+ .fini : { *(.fini) } =0x47ff041f
+ .rodata : { *(.rodata) *(.gnu.linkonce.r*) }
+ .rodata1 : { *(.rodata1) }
+ .reginfo : { *(.reginfo) }
+ /* Adjust the address for the data segment. We want to adjust up to
+ the same address within the page on the next page up. */
+ . = .;
+ .data :
+ {
+ *(.data)
+ *(.gnu.linkonce.d*)
+ CONSTRUCTORS
+ }
+ .data1 : { *(.data1) }
+ .ctors :
+ {
+ *(.ctors)
+ }
+ .dtors :
+ {
+ *(.dtors)
+ }
+ .plt : { *(.plt) }
+ /* gp points at .got+(1<<21) */
+ __gp = ALIGN(8) + 0x200000;
+ .got : { *(.got.plt) *(.got) }
+ .dynamic : { *(.dynamic) }
+ /* We want the small data sections together, so single-instruction offsets
+ can access them all, and initialized data all before uninitialized, so
+ we can shorten the on-disk segment size. */
+ .sdata : { *(.sdata) }
+ _edata = .;
+ PROVIDE (edata = .);
+ __bss_start = .;
+ .sbss : { *(.sbss) *(.scommon) }
+ .bss :
+ {
+ *(.dynbss)
+ *(.bss)
+ *(COMMON)
+ }
+ . = ALIGN(64 / 8);
+ _end = . ;
+ PROVIDE (end = .);
+ /* Stabs debugging sections. */
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
+ .stab.excl 0 : { *(.stab.excl) }
+ .stab.exclstr 0 : { *(.stab.exclstr) }
+ .stab.index 0 : { *(.stab.index) }
+ .stab.indexstr 0 : { *(.stab.indexstr) }
+ .comment 0 : { *(.comment) }
+ /* DWARF debug sections.
+ Symbols in the DWARF debugging sections are relative to the beginning
+ of the section so we begin them at 0. */
+ /* DWARF 1 */
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+ /* GNU DWARF 1 extensions */
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+ /* DWARF 1.1 and DWARF 2 */
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ /* DWARF 2 */
+ .debug_info 0 : { *(.debug_info) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+ /* SGI/MIPS DWARF 2 extensions */
+ .debug_weaknames 0 : { *(.debug_weaknames) }
+ .debug_funcnames 0 : { *(.debug_funcnames) }
+ .debug_typenames 0 : { *(.debug_typenames) }
+ .debug_varnames 0 : { *(.debug_varnames) }
+ /* These must appear regardless of . */
+}
+
diff --git a/sys/boot/ia64/skiload/main.c b/sys/boot/ia64/skiload/main.c
new file mode 100644
index 0000000..01b407d
--- /dev/null
+++ b/sys/boot/ia64/skiload/main.c
@@ -0,0 +1,136 @@
+/*-
+ * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
+ * Copyright (c) 1998,2000 Doug Rabson <dfr@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.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
+
+#include <stand.h>
+#include <string.h>
+#include <setjmp.h>
+#include <machine/fpu.h>
+
+#include "bootstrap.h"
+#include "libski.h"
+
+extern char bootprog_name[];
+extern char bootprog_rev[];
+extern char bootprog_date[];
+extern char bootprog_maker[];
+
+struct ski_devdesc currdev; /* our current device */
+struct arch_switch archsw; /* MI/MD interface boundary */
+
+void
+__start(void)
+{
+ static char stack[16384] __attribute__((aligned (16)));
+ static char malloc[512*1024];
+ int i;
+
+ __asm __volatile("movl gp=__gp;;");
+ __asm __volatile("mov sp=%0" :: "r"(&stack[16384]));
+ __asm __volatile("bsw.1;;");
+ __asm __volatile("mov ar.fpsr=%0" :: "r"(IA64_FPSR_DEFAULT));
+
+ /*
+ * initialise the heap as early as possible. Once this is done,
+ * alloc() is usable. The stack is buried inside us, so this is
+ * safe.
+ */
+ setheap((void *)malloc, (void *)(malloc + 512*1024));
+
+ /*
+ * XXX Chicken-and-egg problem; we want to have console output
+ * early, but some console attributes may depend on reading from
+ * eg. the boot device, which we can't do yet. We can use
+ * printf() etc. once this is done.
+ */
+ cons_probe();
+
+ /*
+ * Initialise the block cache
+ */
+ bcache_init(32, 512); /* 16k XXX tune this */
+
+ /*
+ * March through the device switch probing for things.
+ */
+ for (i = 0; devsw[i] != NULL; i++)
+ if (devsw[i]->dv_init != NULL)
+ (devsw[i]->dv_init)();
+
+ printf("\n");
+ printf("%s, Revision %s\n", bootprog_name, bootprog_rev);
+ printf("(%s, %s)\n", bootprog_maker, bootprog_date);
+#if 0
+ printf("Memory: %ld k\n", memsize() / 1024);
+#endif
+
+ /* XXX presumes that biosdisk is first in devsw */
+ currdev.d_dev = devsw[0];
+ currdev.d_type = currdev.d_dev->dv_type;
+ currdev.d_kind.skidisk.unit = 0;
+ /* XXX should be able to detect this, default to autoprobe */
+ currdev.d_kind.skidisk.slice = -1;
+ /* default to 'a' */
+ currdev.d_kind.skidisk.partition = 0;
+
+#if 0
+ /* Create arc-specific variables */
+ bootfile = GetEnvironmentVariable(ARCENV_BOOTFILE);
+ if (bootfile)
+ setenv("bootfile", bootfile, 1);
+#endif
+
+ env_setenv("currdev", EV_VOLATILE, ski_fmtdev(&currdev),
+ ski_setcurrdev, env_nounset);
+ env_setenv("loaddev", EV_VOLATILE, ski_fmtdev(&currdev), env_noset,
+ env_nounset);
+
+ setenv("LINES", "24", 1); /* optional */
+
+ archsw.arch_autoload = ski_autoload;
+ archsw.arch_getdev = ski_getdev;
+ archsw.arch_copyin = ski_copyin;
+ archsw.arch_copyout = ski_copyout;
+ archsw.arch_readin = ski_readin;
+
+ interact(); /* doesn't return */
+
+ exit(0);
+}
+
+COMMAND_SET(quit, "quit", "exit the loader", command_quit);
+
+static int
+command_quit(int argc, char *argv[])
+{
+ exit(0);
+ return (CMD_OK);
+}
diff --git a/sys/boot/ia64/skiload/version b/sys/boot/ia64/skiload/version
new file mode 100644
index 0000000..b87ca50
--- /dev/null
+++ b/sys/boot/ia64/skiload/version
@@ -0,0 +1,6 @@
+$FreeBSD$
+
+NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this
+file is important. Make sure the current version number is on line 6.
+
+0.1: Initial SKI version.
OpenPOWER on IntegriCloud