From owner-freebsd-arch@FreeBSD.ORG Thu Feb 1 22:54:36 2007 Return-Path: X-Original-To: freebsd-arch@freebsd.org Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6F07416A400 for ; Thu, 1 Feb 2007 22:54:36 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.freebsd.org (Postfix) with ESMTP id 00A6313C47E for ; Thu, 1 Feb 2007 22:54:35 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.6/8.13.6) with ESMTP id l11MsNRK094270; Thu, 1 Feb 2007 17:54:27 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: Luigi Rizzo Date: Thu, 1 Feb 2007 16:14:48 -0500 User-Agent: KMail/1.9.1 References: <20070131115148.A60420@xorpc.icir.org> <20070201.110206.1102529050.imp@bsdimp.com> <20070201104506.B82313@xorpc.icir.org> In-Reply-To: <20070201104506.B82313@xorpc.icir.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200702011614.48712.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Thu, 01 Feb 2007 17:54:28 -0500 (EST) X-Virus-Scanned: ClamAV 0.88.3/2513/Thu Feb 1 11:48:53 2007 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: freebsd-arch@freebsd.org Subject: Re: configurable device (and other) tables in the kernel ? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Feb 2007 22:54:36 -0000 On Thursday 01 February 2007 13:45, Luigi Rizzo wrote: > On Thu, Feb 01, 2007 at 11:02:06AM -0700, M. Warner Losh wrote: > ... > > : plain text files! > > : > > : too obvious to think of it :) > > : > > : but, where can i find an example of a piece of kernel code that can > > : read from a file "safely" (i.e. say in the modevent handler or maybe > > : at device probe time) ? > > : Something like > > : > > : char *load_file_into_kernel_memody(filename, max_size, &error); > > : > > : I have looked at the kernel side of execve and kldload, they are not > > : exactly straightforward (at least there are seveal indirections). > > : Maybe there are other simpler ones ? > > > > Look at the firmware routines. However, they won't work until / is > > mounted, which is after all the device probing happens. > > unfortunately firmare images are embedded in .ko files, so the loading > is done elsewhere - but ok, i can spend some time figuring out > what LINKER_LOAD_FILE() does and whether it is just plain loading > of the file in memory or more than that, whether it can be made to > work even with an unstructured file, and so on. > > Re. the availability of / - one of the requirements i had written > was the ability to preload the table at compile time - that's the > easy part, in the end it is just some macro/scripting magic to embed > the initial table in the object. > Short of putting into the table some hooks to give control > to the console and ask the user to manually type in > the 'alias ID' you were referring to (in the good old times > maybe someone would have even conceived a 'please type > the full driver image in hex') Why not do what firmware(9) does? You can take a table and turn it into a module and then either load that via the loader or kldload it at runtime (or use linker_reference_module(9) at runtime). Granted, I still think the concept is not really a good idea, but I think firmware(9) is actually a good model for this sort of thing. -- John Baldwin