Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KFebx-0000Ed-W8 for mharc-grub-devel@gnu.org; Sun, 06 Jul 2008 20:29:46 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KFebw-0000EY-UE for grub-devel@gnu.org; Sun, 06 Jul 2008 20:29:44 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KFebw-0000EL-CM for grub-devel@gnu.org; Sun, 06 Jul 2008 20:29:44 -0400 Received: from [199.232.76.173] (port=39184 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KFebw-0000EG-7A for grub-devel@gnu.org; Sun, 06 Jul 2008 20:29:44 -0400 Received: from ag-out-0708.google.com ([72.14.246.246]:43573) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KFebv-0005Wd-Lk for grub-devel@gnu.org; Sun, 06 Jul 2008 20:29:43 -0400 Received: by ag-out-0708.google.com with SMTP id 31so12330308agc.10 for ; Sun, 06 Jul 2008 17:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type:content-transfer-encoding :content-disposition; bh=y/6SES6XYiiA96DaasScybf2dWRzi31hUJdLI/pR4MM=; b=R0+DisZtOsc1qPPYXFkbKsdUm1jbk+7xY5mqAUG9aGJdMaA82PkSITv5Bew2d4xzYM BxV49I6jGZzYsWjlgcf5yYEpuKxLZ8mXtwOQzZH+LZ8pwRn63sGyUd3nW1mPYy6fcxDq Aq1cEtP4PtEVZFjXb45mkp7To6IpE/nR2eTrs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=niHCz4lESQQ2ua+qdg/ctxD+XtyxFpCb6JFoIwFSNCdfXKvWOKfQ0DG+wcvu/O5O4M RLc0+unY0BE4j3UUGxmb9eTdBBM/W04oXlOCQ/21IvFvPaFr+RFss9QYnqBgwLMDM/Iy Hfn1iRPBDXGahbxk2aH+50heDRH/KX8xJpYs0= Received: by 10.110.15.19 with SMTP id 19mr2082423tio.42.1215390582069; Sun, 06 Jul 2008 17:29:42 -0700 (PDT) Received: by 10.110.16.5 with HTTP; Sun, 6 Jul 2008 17:29:42 -0700 (PDT) Message-ID: Date: Mon, 7 Jul 2008 08:29:42 +0800 From: Bean To: "The development of GRUB 2" MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) Subject: Idea: elimination of the normal mode (revised version) 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: Mon, 07 Jul 2008 00:29:45 -0000 Hi, First of all, we can still keep rescue and normal command. But instead of depending on normal.mod, normal command depends on module arg, which is an option parser. Also, these two type of commands are of the same command set. In fact, module arg is implemented as a pre parser, which goes through the list of arguments and extract the options. In the case of rescue command, the pre parser field is null, which means it wants to parse options itself. Then, I think of a new structure to represent all configurable handlers of grub. Different types of handler have different fields, but they all share a command header: struct grub_handler { .next, .name, .init, .fini }; Same type of handlers are linked together. We first define an enum to list all types. For example: enum { GRUB_HANDLER_INPUT, GRUB_HANDLER_OUTPUT, GRUB_HANDLER_CONSOLE, GRUB_HANDLER_MENU, GRUB_HANDLER_SCRIPT, GRUB_HANDLER_NUM }; Then, we define an array to point to the head of handler linked list: grub_handler[GRUB_HANDLER_NUM]; Head is the default selection. When we insert a new handler module, it would automatically become the new default, although we can switch back to old handler using a command. Here are more details about different handlers: input: This is the input component of terminal: struct grub_handler_input { .next, .name, .init, .fini, .checkkey, .getkey .flags, }; output: This is the output component of terminal: struct grub_handler_output { .next, .name, .init, .fini, .putchar, .getcharwidth, .getxy, .gotoxy, .cls, .setcolorstate, .setcursor, .flags, }; console interface: It represent the grub console, users type commands and execute them line by line. struct grub_handler_console { .next, .name, .init, .fini, .run }; menu interface: It represent the menu, users select a menu item and execute it. struct grub_handler_menu { .next, .name, .init, .fini, .run }; script engine: It's responsible for parsing config file to get the menu list, and execution of commands. struct grub_handler_script { .next, .name, .init, .fini, .readconfig .getmenu .execute }; The handlers are independent of each other. When they need something, they called specific function of the default handler. For example, to read a key from the console, we can use grub_handler[GRUB_HANDLER_INPUT]->getkey. Also, to get the list of items to be displayed on screen, the menu handler can call grub_handler[GRUB_HANDLER_SCRIPT]->getmenu. -- Bean