Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Lpy5O-00082X-55 for mharc-grub-devel@gnu.org; Sat, 04 Apr 2009 01:06:30 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lpy5K-0007zG-Ta for grub-devel@gnu.org; Sat, 04 Apr 2009 01:06:26 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lpy5E-0007sI-Tg for grub-devel@gnu.org; Sat, 04 Apr 2009 01:06:25 -0400 Received: from [199.232.76.173] (port=46420 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lpy5E-0007s7-Pw for grub-devel@gnu.org; Sat, 04 Apr 2009 01:06:20 -0400 Received: from ti-out-0910.google.com ([209.85.142.187]:8494) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Lpy5E-0007Qu-0O for grub-devel@gnu.org; Sat, 04 Apr 2009 01:06:20 -0400 Received: by ti-out-0910.google.com with SMTP id y8so1132167tia.10 for ; Fri, 03 Apr 2009 22:06:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=Aq9vozveZfpR5X/+qdzQhOOhuLzMl8baMlvqM/rTksg=; b=mLzhXltR4cx9kbAv52z6nItozsRgFyjwsoQEACJ4CKt6A4OtWz0b/dBIDQd/WbzT8p HC0bv5iZ71jEVxof/hgyq1lpHwL32wmNe4AJPOgtbTKN9EjZAyx0hXeQtoaPv49vBB9y h6rJjI5n78hj6PrJEqlar4pKhIKYwywIiwdBA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=N1hAZn9lHRCW8cPynl24M4m7lUTZWNQmaW43sjIB4G0sQvLsUjLrOjdAzjTcJdgAHg zZVjaCwnoUXaYSaOd2xuDogQvylhj2T/4scy9rvTJa11XGbfKdwJD8wkoq5eOsyN+0xG hdsnVTh0DBBkpq0gDZQT+MnxXnhkl93fZ+Wr0= MIME-Version: 1.0 Received: by 10.110.92.8 with SMTP id p8mr2857924tib.56.1238821578233; Fri, 03 Apr 2009 22:06:18 -0700 (PDT) In-Reply-To: <200904040512.15522.okuji@enbug.org> References: <200904040340.33570.okuji@enbug.org> <200904040512.15522.okuji@enbug.org> Date: Sat, 4 Apr 2009 13:06:18 +0800 Message-ID: From: Bean To: The development of GRUB 2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: [PATCH] Split of normal mode (version 2) X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Apr 2009 05:06:27 -0000 On Sat, Apr 4, 2009 at 4:12 AM, Yoshinori K. Okuji wrote: > On Saturday 04 April 2009 04:49:36 Bean wrote: >> On Sat, Apr 4, 2009 at 2:40 AM, Yoshinori K. Okuji wrote: >> > On Tuesday 31 March 2009 02:41:14 Bean wrote: >> >> Hi, >> >> >> >> This new patch make some changes based on the discussion of previous >> >> patch. >> >> >> >> 1, Move script engine to script/sh (sh.mod) >> >> 2, Move generic menu code to menu (menu.mod) >> >> 3, Move text menu viewer to menu/text (textmenu.mod) >> >> 4, Move misc function to lib (misc.mod) >> >> 5, Move setjmp to lib (setjmp.mod) >> > >> > I don't agree on the last two. Also, I don't like that you have just >> > removed the rescue command. >> >> Hi, >> >> The reason for a separate misc.mod is that it contains pure function >> and has no side effect, so other modules can use them freely. In the >> other hand, normal.mod does a lot of tasks in the init function, it's >> not a good place for common function. Besides, there are already >> helper function in the lib directory, like crc and hexdump, it's not >> piratical to put each one in a new module, we might just merge them >> into one helper module. > > We can just put them in the normal.mod. What is wrong? Frankly, your argument > reminds me of the old discussion about monolithic vs. micro kernels... > One of the problem for normal.mod dependency is its side effect. For example, currently ls.mod depend on normal.mod just for grub_normal_print_device_info. If we want to embed ls.mod in core.img, we must embedded normal.mod as well, along with a lot of initialization actions that we may not want. >> The problem with setjmp is that it's platform dependent, so if we keep >> it in normal.mod, we must define it in very platform rmk file. But now >> setjmp is not used in normal.mod anymore, we could move it out, and >> thus make normal.mod platform independent. > > setjmp is required for the switch between rescue mode and normal mode. Don't > remove it. "Hey, this is easier to maintain" is not a good reason to drop an > useful feature. If your intention is to reduce the maintenance cost, you can > simply define a variable for common files in common.rmk and use it in each > machine-specific rmk file. > No, setjmp is not required for the switch between rescue mode and normal mode anymore. In fact, to enter rescue mode, you use: handler reader rescue To switch back to normal mode: handler reader normal It is not recursive, so no need for setjmp. >> >> Now normal.mod only contains the reader code. To configure script >> >> engine and viewer, you should add these lines at the beginning of >> >> grub.cfg: >> >> >> >> insmod sh >> >> handler parser sh >> >> insmod textmenu >> > >> > I prefer a more sophisticated approach (note: I hate manual loading). >> > >> > For example, we can allow a config file to have a shebang, like "#!sh". >> > If not specified, GRUB can assume that "sh" is used, and load it >> > automatically. This kind of technique could even allow for using >> > different languages in one setup. >> > >> > For textmenu, I think it makes sense to have a command "textmenu". Just >> > like "boot", GRUB can execute "textmenu" implicitly if a config file >> > defines any menu entry but does not execute any menu command. This way, >> > textmenu is automatically loaded. >> >> I'm thinking about using environment variable to set handler, for >> example, we could set it like this: >> >> set parser=sh >> set menu=textmenu >> set terminal_output=gfxterm >> >> We could use variable hooks to load the modules on demand. >> >> For textmenu, we could add some test in normal.mod. After the main >> config file is parsed, if it still doesn't contain a menu viewer, we >> load textmenu automatically. > > I agree that terminal_output (and so terminal_input as well) can be > implemented as environment variables, but it is very questionable whether a > parser or a menu interface can be considered as an environment variable. An > important question is how you would determine the name of a module from the > name of a parser or a menu interface. We can generate a handler.lst by scanning source for grub_parser_register, etc, just like commands.lst: parser.sh: sh reader.normal: normal menu.textmenu: textmenu terminal_outout.gfxterm: gfxterm We can then read it in normal.mod and set the hooks for all handler classes. -- Bean