Date: Fri, 30 Jan 2004 08:35:14 -0800 (PST) From: Andrew Reisse <areisse@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 46197 for review Message-ID: <200401301635.i0UGZESl098126@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=46197 Change 46197 by areisse@areisse_ibook on 2004/01/30 08:34:18 Support loading files that are made available to the kernel. To use this, add entries with the nvram command load_<name>=<path>. From the kernel, use preload_find_data to retrive the contents. Don't put symbolic links in the path, which must use \ instead of /. Affected files ... .. //depot/projects/trustedbsd/sedarwin/apsl/BootX/bootx.tproj/include.subproj/boot_args.h#2 edit .. //depot/projects/trustedbsd/sedarwin/apsl/BootX/bootx.tproj/sl.subproj/main.c#2 edit Differences ... ==== //depot/projects/trustedbsd/sedarwin/apsl/BootX/bootx.tproj/include.subproj/boot_args.h#2 (text+ko) ==== @@ -58,7 +58,7 @@ // Boot argument structure - passed into kernel at boot time. -#define kBootArgsRevision (1) +#define kBootArgsRevision (2) #define kBootArgsVersion (1) #define BOOT_LINE_LENGTH (256) @@ -73,6 +73,8 @@ void *deviceTreeP; /* Base of flattened device tree */ unsigned long deviceTreeLength; /* Length of flattened tree */ unsigned long topOfKernelData; /* Last address of kernel data area*/ + void *exdata; + unsigned long exdatalen; }; typedef struct boot_args boot_args, *boot_args_ptr; ==== //depot/projects/trustedbsd/sedarwin/apsl/BootX/bootx.tproj/sl.subproj/main.c#2 (text+ko) ==== @@ -467,6 +467,39 @@ args->deviceTreeP = (void *)gDeviceTreeAddr; args->deviceTreeLength = gDeviceTreeSize; + + /* Load arbitrary data */ + args->exdata = NULL; + args->exdatalen = 0; + + char *prevname = "", *propname; + while (1) { + if (1 != NextProp (gOptionsPH, prevname, propname)) + break; + prevname = propname; + if (!strncmp (propname, "load_", 5)) { + char pfilename[255]; + size = GetProp(gOptionsPH, propname, pfilename, 255); + + if (size > 0) { + char datfile[512]; + strcpy (datfile, gRootDir); + strcat (datfile, pfilename); + size = LoadFile (datfile); + if (size > 0) { + int *v = (int *) AllocateKernelMemory (size + sizeof (int) * 5); + *v = size; + strcpy ((char *) (v + 1), propname + 5); + memcpy (v + 5, kLoadAddr, size); + + if (args->exdata == NULL) + args->exdata = v; + args->exdatalen += size + sizeof(int) * 5; + } + } + } + } + args->topOfKernelData = AllocateKernelMemory(0); return 0;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200401301635.i0UGZESl098126>