Date: Thu, 1 Jan 2015 18:12:03 +0000 (UTC) From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r276507 - in user/nwhitehorn/kboot: fdt powerpc/kboot Message-ID: <201501011812.t01IC3mW071069@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: nwhitehorn Date: Thu Jan 1 18:12:02 2015 New Revision: 276507 URL: https://svnweb.freebsd.org/changeset/base/276507 Log: Commit the actually correct changes to get the FDT into the kernel. Modified: user/nwhitehorn/kboot/fdt/Makefile user/nwhitehorn/kboot/powerpc/kboot/Makefile user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h user/nwhitehorn/kboot/powerpc/kboot/kbootfdt.c user/nwhitehorn/kboot/powerpc/kboot/main.c user/nwhitehorn/kboot/powerpc/kboot/metadata.c user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c Modified: user/nwhitehorn/kboot/fdt/Makefile ============================================================================== --- user/nwhitehorn/kboot/fdt/Makefile Thu Jan 1 18:07:56 2015 (r276506) +++ user/nwhitehorn/kboot/fdt/Makefile Thu Jan 1 18:12:02 2015 (r276507) @@ -6,7 +6,8 @@ LIB= fdt INTERNALLIB= # Vendor sources of libfdt. -SRCS+= fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c +SRCS+= fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c \ + fdt_empty_tree.c # Loader's fdt commands extension sources. SRCS+= fdt_loader_cmd.c Modified: user/nwhitehorn/kboot/powerpc/kboot/Makefile ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/Makefile Thu Jan 1 18:07:56 2015 (r276506) +++ user/nwhitehorn/kboot/powerpc/kboot/Makefile Thu Jan 1 18:12:02 2015 (r276507) @@ -21,7 +21,7 @@ LOADER_NET_SUPPORT?= yes LOADER_NFS_SUPPORT?= yes LOADER_TFTP_SUPPORT?= no LOADER_GZIP_SUPPORT?= yes -LOADER_FDT_SUPPORT?= yes +LOADER_FDT_SUPPORT= yes LOADER_BZIP2_SUPPORT?= no .if ${LOADER_DISK_SUPPORT} == "yes" @@ -98,8 +98,8 @@ CFLAGS+= -Wa,-mppc64bridge LIBSTAND= ${.OBJDIR}/../../libstand32/libstand.a CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ -DPADD= ${LIBFICL} ${LIBOFW} ${LIBSTAND} -LDADD= ${LIBFICL} ${LIBOFW} ${LIBSTAND} +DPADD= ${LIBFICL} ${LIBOFW} ${LIBFDT} ${LIBSTAND} +LDADD= ${LIBFICL} ${LIBOFW} ${LIBFDT} ${LIBSTAND} SC_DFLT_FONT=cp437 Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Thu Jan 1 18:07:56 2015 (r276506) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Thu Jan 1 18:12:02 2015 (r276507) @@ -6,9 +6,10 @@ ENTRY(host_read) bso 1f blr 1: - li %r3, -1 + li %r3, 0 blr + ENTRY(host_write) li %r0, 4 # SYS_write sc @@ -49,11 +50,6 @@ ENTRY(host_select) blr ENTRY(kexec_load) - lis %r4,nkexec_segments@ha - ori %r4,%r4,nkexec_segments@l - lwz %r4,0(%r4) - lis %r5,loaded_segments@ha - ori %r5,%r5,loaded_segments@l lis %r6,21 # KEXEC_ARCH_PPC64 li %r0,268 # __NR_kexec_load sc Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h Thu Jan 1 18:07:56 2015 (r276506) +++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h Thu Jan 1 18:12:02 2015 (r276507) @@ -44,7 +44,7 @@ struct host_timeval { 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 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); Modified: user/nwhitehorn/kboot/powerpc/kboot/kbootfdt.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/kbootfdt.c Thu Jan 1 18:07:56 2015 (r276506) +++ user/nwhitehorn/kboot/powerpc/kboot/kbootfdt.c Thu Jan 1 18:12:02 2015 (r276507) @@ -33,25 +33,6 @@ __FBSDID("$FreeBSD$"); #include "host_syscall.h" static void -print_fdt(void *fdtp) -{ - int offset, depth, i; - const char *compat; - - offset = fdt_path_offset(fdtp, "/"); - - for (depth = 0, offset = fdt_next_node(fdtp, offset, &depth); - offset >= 0; offset = fdt_next_node(fdtp, offset, &depth)) { - for (i = 1; i < depth; i++) printf("\t"); - printf("%d: %s",offset, fdt_get_name(fdtp, offset, NULL)); - compat = fdt_getprop(fdtp, offset, "compatible", NULL); - if (compat != NULL) - printf(" (%s)", compat); - printf("\n"); - } -} - -static void add_node_to_fdt(void *buffer, const char *path, int fdt_offset) { int child_offset, fd, pfd, error, dentsize; @@ -70,7 +51,7 @@ add_node_to_fdt(void *buffer, const char struct host_dent *dent; int d_type; - fd = open(path, O_RDONLY); + fd = host_open(path, O_RDONLY, 0); while (1) { dentsize = host_getdents(fd, dents, sizeof(dents)); if (dentsize <= 0) @@ -94,15 +75,16 @@ add_node_to_fdt(void *buffer, const char add_node_to_fdt(buffer, subpath, child_offset); } else { - pfd = open(subpath, O_RDONLY); propbuf = malloc(1024); - proplen = read(pfd, propbuf, 1024); - if (proplen < 0) - proplen = 0; + proplen = 0; + pfd = host_open(subpath, O_RDONLY, 0); + if (pfd > 0) { + proplen = host_read(pfd, propbuf, 1024); + host_close(pfd); + } error = fdt_setprop(buffer, fdt_offset, dent->d_name, propbuf, proplen); free(propbuf); - close(pfd); if (error) printf("Error %d adding property %s to " "node %d\n", error, dent->d_name, @@ -111,7 +93,7 @@ add_node_to_fdt(void *buffer, const char } } - close(fd); + host_close(fd); } int @@ -125,7 +107,6 @@ fdt_platform_load_dtb(void) fdt_create_empty_tree(buffer, buflen); add_node_to_fdt(buffer, path, fdt_path_offset(buffer, "/")); fdt_pack(buffer); -printf("Device tree is %d total bytes\n", fdt_totalsize(buffer)); fdt_load_dtb_addr(buffer); Modified: user/nwhitehorn/kboot/powerpc/kboot/main.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/main.c Thu Jan 1 18:07:56 2015 (r276506) +++ user/nwhitehorn/kboot/powerpc/kboot/main.c Thu Jan 1 18:12:02 2015 (r276507) @@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); #include <stand.h> #include <sys/param.h> +#include <fdt_platform.h> #define _KERNEL #include <machine/cpufunc.h> @@ -49,6 +50,8 @@ ssize_t kboot_readin(const int fd, vm_of int kboot_autoload(void); int kboot_setcurrdev(struct env_var *ev, int flags, const void *value); +extern int command_fdt_internal(int argc, char *argv[]); + int kboot_getdev(void **vdev, const char *devspec, const char **path) { @@ -168,9 +171,9 @@ time(time_t *tloc) struct kexec_segment { void *buf; - size_t bufsz; + int bufsz; void *mem; - size_t memsz; + int memsz; }; struct kexec_segment loaded_segments[128]; @@ -181,7 +184,6 @@ get_phys_buffer(vm_offset_t dest, const { int i = 0; const size_t segsize = 2*1024*1024; - dest += 32*1024*1024; /* XXX Make nonoverlapping somehow */ for (i = 0; i < nkexec_segments; i++) { if (dest >= (vm_offset_t)loaded_segments[i].mem && @@ -287,3 +289,18 @@ _start(int argc, const char **argv, char main((int)sp[0], (const char **)&sp[1]); } +/* + * Since proper fdt command handling function is defined in fdt_loader_cmd.c, + * and declaring it as extern is in contradiction with COMMAND_SET() macro + * (which uses static pointer), we're defining wrapper function, which + * calls the proper fdt handling routine. + */ +static int +command_fdt(int argc, char *argv[]) +{ + + return (command_fdt_internal(argc, argv)); +} + +COMMAND_SET(fdt, "fdt", "flattened device tree handling", command_fdt); + Modified: user/nwhitehorn/kboot/powerpc/kboot/metadata.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/metadata.c Thu Jan 1 18:07:56 2015 (r276506) +++ user/nwhitehorn/kboot/powerpc/kboot/metadata.c Thu Jan 1 18:12:02 2015 (r276507) @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include <sys/reboot.h> #include <sys/linker.h> #include <sys/boot.h> +#include <fdt_platform.h> #include <machine/metadata.h> Modified: user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c ============================================================================== --- user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c Thu Jan 1 18:07:56 2015 (r276506) +++ user/nwhitehorn/kboot/powerpc/kboot/ppc64_elf_freebsd.c Thu Jan 1 18:12:02 2015 (r276507) @@ -44,6 +44,8 @@ extern char end[]; extern vm_offset_t reloc; /* From <arch>/conf.c */ extern void *kerneltramp; extern size_t szkerneltramp; +extern int nkexec_segments; +extern void * loaded_segments; int ppc64_elf_loadfile(char *filename, u_int64_t dest, @@ -66,7 +68,7 @@ ppc64_elf_exec(struct preloaded_file *fp Elf_Ehdr *e; int error; uint32_t *trampoline; - vm_offset_t trampolinebase = 32*1024*1024; /* XXX */ + vm_offset_t trampolinebase = 16*1024*1024; /* XXX */ if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) { return(EFTYPE); @@ -93,7 +95,7 @@ ppc64_elf_exec(struct preloaded_file *fp archsw.arch_copyin(trampoline, trampolinebase, szkerneltramp); free(trampoline); - error = kexec_load(trampolinebase); + error = kexec_load(trampolinebase, nkexec_segments, &loaded_segments); if (error != 0) panic("kexec_load returned error: %d", error); error = host_reboot(0xfee1dead, 672274793,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201501011812.t01IC3mW071069>