Index: user/nwhitehorn/kboot/powerpc/kboot/Makefile =================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/Makefile (revision 276354) +++ user/nwhitehorn/kboot/powerpc/kboot/Makefile (revision 276355) @@ -1,130 +1,130 @@ # $FreeBSD$ .include MK_SSP= no PROG= loader.kboot NEWVERSWHAT= "kboot loader" ${MACHINE_ARCH} BINDIR?= /boot INSTALLFLAGS= -b # Architecture-specific loader code SRCS= conf.c metadata.c vers.c main.c ppc64_elf_freebsd.c -SRCS+= host_syscall.S hostcons.c +SRCS+= host_syscall.S hostcons.c hostdisk.c SRCS+= ucmpdi2.c LOADER_DISK_SUPPORT?= yes LOADER_UFS_SUPPORT?= yes LOADER_CD9660_SUPPORT?= yes LOADER_EXT2FS_SUPPORT?= yes LOADER_NET_SUPPORT?= yes LOADER_NFS_SUPPORT?= yes LOADER_TFTP_SUPPORT?= no LOADER_GZIP_SUPPORT?= yes LOADER_FDT_SUPPORT?= no LOADER_BZIP2_SUPPORT?= no .if ${LOADER_DISK_SUPPORT} == "yes" CFLAGS+= -DLOADER_DISK_SUPPORT .endif .if ${LOADER_UFS_SUPPORT} == "yes" CFLAGS+= -DLOADER_UFS_SUPPORT .endif .if ${LOADER_CD9660_SUPPORT} == "yes" CFLAGS+= -DLOADER_CD9660_SUPPORT .endif .if ${LOADER_EXT2FS_SUPPORT} == "yes" CFLAGS+= -DLOADER_EXT2FS_SUPPORT .endif .if ${LOADER_GZIP_SUPPORT} == "yes" CFLAGS+= -DLOADER_GZIP_SUPPORT .endif .if ${LOADER_BZIP2_SUPPORT} == "yes" CFLAGS+= -DLOADER_BZIP2_SUPPORT .endif .if ${LOADER_NET_SUPPORT} == "yes" CFLAGS+= -DLOADER_NET_SUPPORT .endif .if ${LOADER_NFS_SUPPORT} == "yes" CFLAGS+= -DLOADER_NFS_SUPPORT .endif .if ${LOADER_TFTP_SUPPORT} == "yes" CFLAGS+= -DLOADER_TFTP_SUPPORT .endif .if ${LOADER_FDT_SUPPORT} == "yes" CFLAGS+= -I${.CURDIR}/../../fdt CFLAGS+= -I${.OBJDIR}/../../fdt CFLAGS+= -DLOADER_FDT_SUPPORT LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a .endif .if ${MK_FORTH} != "no" # Enable BootForth BOOT_FORTH= yes CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/powerpc LIBFICL= ${.OBJDIR}/../../ficl/libficl.a .endif # Avoid the open-close-dance for every file access as some firmwares perform # an auto-negotiation on every open of the network interface and thus causes # netbooting to take horribly long. CFLAGS+= -DNETIF_OPEN_CLOSE_ONCE -mcpu=powerpc64 # Always add MI sources .PATH: ${.CURDIR}/../../common ${.CURDIR}/../../../libkern .include "${.CURDIR}/../../common/Makefile.inc" CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. CFLAGS+= -I. CLEANFILES+= vers.c loader.help CFLAGS+= -Wall -ffreestanding -msoft-float -DAIM # load address. set in linker script RELOC?= 0x0 CFLAGS+= -DRELOC=${RELOC} LDFLAGS= -nostdlib -static -T ${.CURDIR}/ldscript.powerpc # 64-bit bridge extensions CFLAGS+= -Wa,-mppc64bridge # Pull in common loader code #.PATH: ${.CURDIR}/../../ofw/common #.include "${.CURDIR}/../../ofw/common/Makefile.inc" # where to get libstand from LIBSTAND= ${.OBJDIR}/../../libstand32/libstand.a CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ DPADD= ${LIBFICL} ${LIBOFW} ${LIBSTAND} LDADD= ${LIBFICL} ${LIBOFW} ${LIBSTAND} SC_DFLT_FONT=cp437 font.h: uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x16.fnt && file2c 'u_char dflt_font_16[16*256] = {' '};' < ${SC_DFLT_FONT}-8x16 > font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x14.fnt && file2c 'u_char dflt_font_14[14*256] = {' '};' < ${SC_DFLT_FONT}-8x14 >> font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x8.fnt && file2c 'u_char dflt_font_8[8*256] = {' '};' < ${SC_DFLT_FONT}-8x8 >> font.h vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} loader.help: help.common help.kboot ${.CURDIR}/../../fdt/help.fdt cat ${.ALLSRC} | \ awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} .PATH: ${.CURDIR}/../../forth FILES= loader.help loader.4th support.4th loader.conf FILES+= screen.4th frames.4th FILES+= beastie.4th brand.4th check-password.4th color.4th delay.4th FILES+= menu.4th menu-commands.4th menusets.4th shortcuts.4th version.4th FILESDIR_loader.conf= /boot/defaults .if !exists(${DESTDIR}/boot/loader.rc) FILES+= loader.rc .endif .if !exists(${DESTDIR}/boot/menu.rc) FILES+= menu.rc .endif .include Index: user/nwhitehorn/kboot/powerpc/kboot/conf.c =================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/conf.c (revision 276354) +++ user/nwhitehorn/kboot/powerpc/kboot/conf.c (revision 276355) @@ -1,127 +1,121 @@ /*- * Copyright (C) 1999 Michael Smith * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include "bootstrap.h" #if defined(LOADER_NET_SUPPORT) #include "dev_net.h" #endif -extern struct devsw kbootdisk; -extern struct devsw kbootcdrom; +extern struct devsw hostdisk; /* * We could use linker sets for some or all of these, but * then we would have to control what ended up linked into * the bootstrap. So it's easier to conditionalise things * here. * * XXX rename these arrays to be consistent and less namespace-hostile */ /* Exported for libstand */ struct devsw *devsw[] = { -#if 0 /* XXX */ -#if defined(LOADER_CD9660_SUPPORT) - &kbootcdrom, -#endif -#if defined(LOADER_DISK_SUPPORT) - &kbootdisk, -#endif +#if defined(LOADER_DISK_SUPPORT) || defined(LOADER_CD9660_SUPPORT) + &hostdisk, #endif #if defined(LOADER_NET_SUPPORT) &netdev, #endif NULL }; struct fs_ops *file_system[] = { #if defined(LOADER_UFS_SUPPORT) &ufs_fsops, #endif #if defined(LOADER_CD9660_SUPPORT) &cd9660_fsops, #endif #if defined(LOADER_EXT2FS_SUPPORT) &ext2fs_fsops, #endif #if defined(LOADER_NFS_SUPPORT) &nfs_fsops, #endif #if defined(LOADER_TFTP_SUPPORT) &tftp_fsops, #endif #if defined(LOADER_GZIP_SUPPORT) &gzipfs_fsops, #endif #if defined(LOADER_BZIP2_SUPPORT) &bzipfs_fsops, #endif NULL }; extern struct netif_driver kbootnet; struct netif_driver *netif_drivers[] = { #if 0 /* XXX */ #if defined(LOADER_NET_SUPPORT) &kbootnet, #endif #endif NULL, }; /* Exported for PowerPC only */ /* * Sort formats so that those that can detect based on arguments * rather than reading the file go first. */ extern struct file_format ppc_elf64; struct file_format *file_formats[] = { &ppc_elf64, NULL }; /* * Consoles */ extern struct console hostconsole; struct console *consoles[] = { &hostconsole, NULL }; /* * reloc - our load address */ vm_offset_t reloc = RELOC; Index: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S =================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S (revision 276354) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S (revision 276355) @@ -1,31 +1,36 @@ #include ENTRY(host_read) li %r0, 3 # SYS_read sc blr ENTRY(host_write) li %r0, 4 # SYS_write sc blr +ENTRY(host_seek) + li %r0, 478 # SYS_lseek + sc + blr + ENTRY(host_open) li %r0, 5 # SYS_open sc blr ENTRY(host_close) li %r0, 6 # SYS_close sc blr ENTRY(host_getmem) /* addr, size */ li %r5, 3 # PROT_READ | PROT_WRITE li %r6, 0x1000 # MAP_ANON li %r7, -1 li %r8, 0 li %r0, 477 # SYS_mmap sc blr Index: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h =================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h (revision 276354) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h (revision 276355) @@ -1,39 +1,40 @@ /*- * Copyright (C) 2010 Nathan Whitehorn * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD$ */ #ifndef _HOST_SYSCALL_H #define _HOST_SYSCALL_H #include ssize_t host_read(int fd, void *buf, size_t nbyte); ssize_t host_write(int fd, const void *buf, size_t nbyte); +ssize_t host_seek(int fd, uint64_t offset, int whence); int host_open(char *path, int flags, int mode); int host_close(int fd); void *host_getmem(void *addr, size_t len); #endif Index: user/nwhitehorn/kboot/powerpc/kboot/hostcons.c =================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/hostcons.c (revision 276354) +++ user/nwhitehorn/kboot/powerpc/kboot/hostcons.c (revision 276355) @@ -1,88 +1,88 @@ /*- * Copyright (C) 2014 Nathan Whitehorn * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include "bootstrap.h" #include "host_syscall.h" static void hostcons_probe(struct console *cp); static int hostcons_init(int arg); static void hostcons_putchar(int c); static int hostcons_getchar(); static int hostcons_poll(); struct console hostconsole = { "host", "Host Console", 0, hostcons_probe, hostcons_init, hostcons_putchar, hostcons_getchar, hostcons_poll, }; static void hostcons_probe(struct console *cp) { cp->c_flags |= C_PRESENTIN|C_PRESENTOUT; } static int hostcons_init(int arg) { /* XXX: set nonblocking */ return (0); } static void hostcons_putchar(int c) { uint8_t ch = c; host_write(1, &ch, 1); } static int hostcons_getchar() { uint8_t ch; - host_read(1, &ch, 1); + host_read(0, &ch, 1); return (ch); } static int hostcons_poll() { return (0); } Index: user/nwhitehorn/kboot/powerpc/kboot/hostdisk.c =================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/hostdisk.c (nonexistent) +++ user/nwhitehorn/kboot/powerpc/kboot/hostdisk.c (revision 276355) @@ -0,0 +1,126 @@ +/*- + * Copyright (C) 2014 Nathan Whitehorn + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include "bootstrap.h" +#include "host_syscall.h" + +static int hostdisk_init(void); +static int hostdisk_strategy(void *devdata, int flag, daddr_t dblk, + size_t size, char *buf, size_t *rsize); +static int hostdisk_open(struct open_file *f, ...); +static int hostdisk_close(struct open_file *f); +static int hostdisk_ioctl(struct open_file *f, u_long cmd, void *data); +static void hostdisk_print(int verbose); + +struct devsw hostdisk = { + "a", + DEVT_DISK, + hostdisk_init, + hostdisk_strategy, + hostdisk_open, + hostdisk_close, + hostdisk_ioctl, + hostdisk_print, +}; + +static int +hostdisk_init(void) +{ + + return (0); +} + +static int +hostdisk_strategy(void *devdata, int flag, daddr_t dblk, size_t size, + char *buf, size_t *rsize) +{ + struct devdesc *desc = devdata; + daddr_t pos; + int n; + + pos = dblk * 512; + + if (host_seek(desc->d_unit, pos, 0) < 0) + return (EIO); + n = host_read(desc->d_unit, buf, size); + + if (n < 0) + return (EIO); + + *rsize = n; + return (0); +} + +static int +hostdisk_open(struct open_file *f, ...) +{ + struct devdesc *desc; + char *path; + va_list vl; + + va_start(vl, f); + desc = va_arg(vl, struct devdesc *); + va_end(vl); + + path = malloc(strlen((char *)(desc->d_opendata)) + 6); + strcpy(path, "/dev/"); + strcat(path, (char *)(desc->d_opendata)); + + desc->d_unit = host_open(path, O_RDONLY, 0); + free(path); + + if (desc->d_unit < 0) + return (ENOENT); + + return (0); +} + +static int +hostdisk_close(struct open_file *f) +{ + struct devdesc *desc = f->f_devdata; + + host_close(desc->d_unit); + return (0); +} + +static int +hostdisk_ioctl(struct open_file *f, u_long cmd, void *data) +{ + + return (EINVAL); +} + +static void +hostdisk_print(int verbose) +{ + +} + Property changes on: user/nwhitehorn/kboot/powerpc/kboot/hostdisk.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: user/nwhitehorn/kboot/powerpc/kboot/main.c =================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/main.c (revision 276354) +++ user/nwhitehorn/kboot/powerpc/kboot/main.c (revision 276355) @@ -1,210 +1,218 @@ /*- * Copyright (C) 2010-2014 Nathan Whitehorn * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include #define _KERNEL #include #include "bootstrap.h" #include "host_syscall.h" struct arch_switch archsw; extern void *_end; extern char bootprog_name[]; extern char bootprog_rev[]; extern char bootprog_date[]; extern char bootprog_maker[]; int kboot_getdev(void **vdev, const char *devspec, const char **path); ssize_t kboot_copyin(const void *src, vm_offset_t dest, const size_t len); ssize_t kboot_copyout(vm_offset_t src, void *dest, const size_t len); ssize_t kboot_readin(const int fd, vm_offset_t dest, const size_t len); int kboot_autoload(void); int kboot_setcurrdev(struct env_var *ev, int flags, const void *value); int kboot_getdev(void **vdev, const char *devspec, const char **path) { int i; const char *devpath, *filepath; struct devsw *dv; + struct devdesc *desc; - if (devspec[0] == '/') { - devpath = getenv("currdev"); - filepath = devspec; - } else { + if (strchr(devspec, ':') != NULL) { devpath = devspec; - if (strchr(devspec, ':') == NULL) - filepath = NULL; - else - filepath = strchr(devspec, ':') + 1; + filepath = strchr(devspec, ':') + 1; + } else { + devpath = getenv("currdev"); + filepath = &devspec[1]; } + for (i = 0; (dv = devsw[i]) != NULL; i++) { if (strncmp(dv->dv_name, devpath, strlen(dv->dv_name)) == 0) goto found; } return (ENOENT); found: - if (path != NULL) + if (path != NULL && filepath != NULL) *path = filepath; else if (path != NULL) *path = strchr(devspec, ':') + 1; - *vdev = strdup(devpath); + + if (vdev != NULL) { + desc = malloc(sizeof(*desc)); + desc->d_dev = dv; + desc->d_unit = 0; + desc->d_opendata = strdup(devpath); + *vdev = desc; + } + + return (0); } int main(int argc, const char **argv) { void *heapbase; /* * Set the heap to one page after the end of the loader. */ heapbase = host_getmem(0, 0x100000); setheap(heapbase, heapbase + 0x100000); /* * Set up console. */ cons_probe(); printf("Boot device: %s\n", argv[1]); archsw.arch_getdev = kboot_getdev; archsw.arch_copyin = kboot_copyin; archsw.arch_copyout = kboot_copyout; archsw.arch_readin = kboot_readin; archsw.arch_autoload = kboot_autoload; printf("\n"); printf("%s, Revision %s\n", bootprog_name, bootprog_rev); printf("(%s, %s)\n", bootprog_maker, bootprog_date); setenv("currdev", argv[1], 1); setenv("loaddev", argv[1], 1); setenv("LINES", "24", 1); interact(NULL); /* doesn't return */ return (0); } void exit(int code) { /* XXX: host_exit */ } void delay(int usecs) { /* XXX */ } int getsecs() { /* XXX */ return (0); } time_t time(time_t *tloc) { time_t rv; rv = getsecs(); if (tloc != NULL) *tloc = rv; return (rv); } ssize_t kboot_copyin(const void *src, vm_offset_t dest, const size_t len) { bcopy(src, (void *)dest, len); return (len); } ssize_t kboot_copyout(vm_offset_t src, void *dest, const size_t len) { bcopy((void *)src, dest, len); return (len); } ssize_t kboot_readin(const int fd, vm_offset_t dest, const size_t len) { void *buf; size_t resid, chunk, get; ssize_t got; vm_offset_t p; p = dest; chunk = min(PAGE_SIZE, len); buf = malloc(chunk); if (buf == NULL) { printf("kboot_readin: buf malloc failed\n"); return(0); } for (resid = len; resid > 0; resid -= got, p += got) { get = min(chunk, resid); got = read(fd, buf, get); if (got <= 0) { if (got < 0) printf("kboot_readin: read failed\n"); break; } bcopy(buf, (void *)p, got); } free(buf); return (len - resid); } int kboot_autoload(void) { return (0); } void _start(int argc, const char **argv, char **env) { main(argc, argv); }