diff --git a/sys/boot/powerpc/kboot/host_syscall.S b/sys/boot/powerpc/kboot/host_syscall.S index 9e8a79746fcb..3607fdb0d2a1 100644 --- a/sys/boot/powerpc/kboot/host_syscall.S +++ b/sys/boot/powerpc/kboot/host_syscall.S @@ -1,67 +1,75 @@ +/* + * + * $FreeBSD$ + */ + #include ENTRY(host_read) li %r0, 3 # SYS_read sc bso 1f blr 1: li %r3, 0 blr ENTRY(host_write) li %r0, 4 # SYS_write sc blr ENTRY(host_seek) - li %r0, 19 # SYS_lseek + mr %r4,%r5 + mr %r5,%r6 + mr %r6,%r7 + li %r0, 140 # SYS_llseek sc blr ENTRY(host_open) li %r0, 5 # SYS_open sc bso 1f blr 1: li %r3, 0 blr ENTRY(host_close) li %r0, 6 # SYS_close sc blr ENTRY(host_mmap) li %r0, 90 # SYS_mmap sc blr ENTRY(host_gettimeofday) li %r0, 78 # SYS_gettimeofday sc blr ENTRY(host_select) li %r0, 142 # SYS_select sc blr ENTRY(kexec_load) lis %r6,21 # KEXEC_ARCH_PPC64 li %r0,268 # __NR_kexec_load sc blr ENTRY(host_reboot) li %r0,88 # SYS_reboot sc blr ENTRY(host_getdents) li %r0,141 # SYS_getdents sc blr diff --git a/sys/boot/powerpc/kboot/host_syscall.h b/sys/boot/powerpc/kboot/host_syscall.h index 58518a9cdee2..0d47bd58a44a 100644 --- a/sys/boot/powerpc/kboot/host_syscall.h +++ b/sys/boot/powerpc/kboot/host_syscall.h @@ -1,51 +1,51 @@ /*- * 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. * * $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, int offset, int whence); +ssize_t host_seek(int fd, int64_t offset, int whence); int host_open(char *path, int flags, int mode); int host_close(int fd); void *host_mmap(void *addr, size_t len, int prot, int flags, int fd, int); #define host_getmem(size) host_mmap(0, size, 3 /* RW */, 0x22 /* ANON */, -1, 0); struct host_timeval { int tv_sec; int tv_usec; }; int host_gettimeofday(struct host_timeval *a, void *b); int host_select(int nfds, long *readfds, long *writefds, long *exceptfds, struct host_timeval *timeout); int kexec_load(vm_offset_t start, int nsegs, void *segs); int host_reboot(int, int, int, void *); int host_getdents(int fd, void *dirp, int count); #endif diff --git a/sys/boot/powerpc/kboot/hostdisk.c b/sys/boot/powerpc/kboot/hostdisk.c index c6be8af47166..2deb95620fc2 100644 --- a/sys/boot/powerpc/kboot/hostdisk.c +++ b/sys/boot/powerpc/kboot/hostdisk.c @@ -1,126 +1,125 @@ /*- * 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 = { - "s", + "/dev", 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) + if (host_seek(desc->d_unit, pos, 0) < 0) { + printf("Seek error\n"); 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(desc->d_opendata, O_RDONLY, 0); - desc->d_unit = host_open(path, O_RDONLY, 0); - free(path); - - if (desc->d_unit <= 0) + if (desc->d_unit <= 0) { + printf("hostdisk_open: couldn't open %s: %d\n", + desc->d_opendata, desc->d_unit); 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) { }