From: Marco Gerards <mgerards@xs4all.nl>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: Idea: elimination of the normal mode (revised version)
Date: Sun, 20 Jul 2008 22:02:50 +0200 [thread overview]
Message-ID: <873am4ias5.fsf@xs4all.nl> (raw)
In-Reply-To: <ca0f59980807061729s1c0c0ea4se8558e1cac7f8ed6@mail.gmail.com> (bean123ch@gmail.com's message of "Mon, 7 Jul 2008 08:29:42 +0800")
Hi,
Bean <bean123ch@gmail.com> writes:
> 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.
pre parser?
> 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:
What is a handler and what are its responsibilities?
> 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,
> };
Sometimes the input and output are tightly coupled. How do you want
to handle this?
> 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
> };
What I had in mind was a twofold. I wrote a parser part that actually
parses the script and code to manage the AST and to execute it. It
would be easy to extend the current design with other languages.
Although I think we should not add more than one to SVN, otherwise it
will become bloated.
> 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.
How does this differ from what we have now? You can register all
kinds of objects and deregister them.
--
Marco
next prev parent reply other threads:[~2008-07-20 20:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-07 0:29 Idea: elimination of the normal mode (revised version) Bean
2008-07-17 3:24 ` Bean
2008-07-17 18:58 ` Pavel Roskin
2008-07-18 4:47 ` Bean
2008-07-18 14:46 ` Colin D Bennett
2008-07-18 15:14 ` Bean
2008-07-20 20:02 ` Marco Gerards [this message]
2008-07-20 20:23 ` Bean
2008-07-21 17:27 ` Marco Gerards
2008-07-21 18:03 ` Bean
2008-07-21 18:42 ` Bean
2008-07-22 21:26 ` Marco Gerards
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=873am4ias5.fsf@xs4all.nl \
--to=mgerards@xs4all.nl \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.