Re: [PATCH] hdparm.mod - get/set ATA disk parameters

2009-02-14 Thread Christian Franke

Christian Franke wrote:

...
New patch below. Function grub_ata_pass_through() now moved to new 
module ata_pthru.mod.




Committed. Now also includes a SMART status check.


grub.cfg example (assumes ata.mod is used):

...
insmod ata_pthru
insmod hdparm

# Make sure disks cannot be locked by an ATA password
hdparm --quiet --security-freeze (ata4)
hdparm --quiet --security-freeze (ata6)

menuentry "Boot" {

 # Check health
 if hdparm --quiet --health (ata4) ; then echo -n ; else
   echo "Warning: SMART status check failed"
   read
 fi

 # Set boot disk to "fast", disable spin down
 hdparm --quiet --aam=254 --standby-timeout=0 (ata4)

 # Set other disk to "quiet", spin down after 5min inactivity
 hdparm --quiet --aam=128 --standby-timeout=60 (ata6)

 # Boot ...
}

menuentry "Memory Test" {

 # Spin down both disks after 10min
 hdparm --quiet --standby-timeout=120 (ata4)
 hdparm --quiet --standby-timeout=120 (ata6)

 # Load memtest ...
}


Christian



___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] Handler support

2009-02-14 Thread Bean
Hi,

This new version of handler patch contain the following changes:

1, Register/unregister handler class automatically, so there is no
need to usel grub_handler_class_register/grub_handler_class_unregister
anymore.
2, Keep the original api function of term.c, so that there is no need
to change modules depend on it. Inside term.c, it rely on the handler
function to do the job.
3. Use a new method of compile time checking. Now, instead of using
void*, it uses normal type, for example:

void grub_handler_register (grub_handler_class_t class, grub_handler_t handler);

Codes that calls grub_handler_register should looks like this:

grub_handler_register (&grub_term_input_class, GRUB_AS_HANDLER (term));

macro GRUB_AS_HANDLER check the various fields required by
grub_handler_t is at the same location as term, and then cast it to
type grub_handler_t. Just as before, if the testing succeed, it
wouldn't generate extra runtime code.

If there is no objection, I'd commit this patch in a few days.

2009-02-14  Bean  

* commands/handler.c: New file.

* include/grub/list.h: Likewise.

* include/grub/handler.h: Likewise.

* kern/list.c: Likewise.

* kern/handler.c: Likewise.

* kern/term.h: Include header file .
(grub_term_input): Move next field to the beginning.
(grub_term_output): Likewise.
(grub_term_iterate_input): Removed.
(grub_term_iterate_output): Likewise.

* kern/term.c (grub_term_list_input): Removed.
(grub_term_list_output): Likewise.
(grub_term_input_class): New variable.
(grub_term_output_class): Likewise.
(grub_cur_term_input): Change varaible as macro.
(grub_cur_term_output): Likewise.
(grub_term_register_input): Call underlying handler function to do the
job.
(grub_term_register_output): Likewise.
(grub_term_unregister_input): Likewise.
(grub_term_unregister_output): Likewise.
(grub_term_set_current_input): Likewise.
(grub_term_set_current_output): Likewise.
(grub_term_iterate_input): Removed.
(grub_term_iterate_output): Likewise.
(grub_term_get_current_input): Use grub_term_input_class to retrive
the current handler.
(grub_term_get_current_output): Likewise.

* conf/common.rmk (pkglib_MODULES): Replace terminal with handler.
(terminal_mod_SOURCES): Likewise.
(terminal_mod_CFLAGS): Likewise.
(terminal_mod_LDFLAGS): Likewise.

* conf/i386-pc.rmk (grub_emu_SOURCES): Replace terminal.c with
handler.c.
(kernel_img_SOURCES): Add list.c and handler.c.
(kernel_img_HEADERS): Add list.h and handler.h.

* conf/i386-efi.rmk (grub_emu_SOURCES): Replace terminal.c with
handler.c.
(kernel_mod_SOURCES): Add list.c and handler.c.
(kernel_mod_HEADERS): Add list.h and handler.h.

* conf/i386-coreboot.rmk (grub_emu_SOURCES): Replace terminal.c with
handler.c.
(kernel_elf_SOURCES): Add list.c and handler.c.
(kernel_elf_HEADERS): Add list.h and handler.h.

* conf/i386-ieee1275.rmk (grub_emu_SOURCES): Replace terminal.c with
handler.c.
(kernel_elf_SOURCES): Add list.c and handler.c.
(kernel_elf_HEADERS): Add list.h and handler.h.

* conf/x86_64-efi.rmk (grub_emu_SOURCES): Replace terminal.c with
handler.c.
(kernel_mod_SOURCES): Add list.c and handler.c.
(kernel_mod_HEADERS): Add list.h and handler.h.

* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Replace terminal.c with
handler.c.
(kernel_elf_SOURCES): Add list.c and handler.c.
(kernel_elf_HEADERS): Add list.h and handler.h.

* conf/sparc64-ieee1275.rmk (grub_emu_SOURCES): Replace terminal.c with
handler.c.
(kernel_elf_SOURCES): Add list.c and handler.c.
(kernel_elf_HEADERS): Add list.h and handler.h.

-- 
Bean
diff --git a/commands/handler.c b/commands/handler.c
new file mode 100644
index 000..04f89f8
--- /dev/null
+++ b/commands/handler.c
@@ -0,0 +1,105 @@
+/* handler.c - test module for dynamic loading */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2009  Free Software Foundation, Inc.
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+#

Re: [PATCH] Handler support

2009-02-14 Thread Felix Zielcke
 A. Am Samstag, den 14.02.2009, 22:46 +0800 schrieb Bean:

> If there is no objection, I'd commit this patch in a few days.

Hello Bean,

if you want to drop termin_input and terminal_output command then please
don't forget to update util/grub.d/00_header.in 

+GRUB_MOD_INIT(handler)
+{
+  (void)mod;   /* To stop warning. */
+  grub_register_command ("handler", grub_cmd_handler,
GRUB_COMMAND_FLAG_BOTH,
+"handler [class [handler]]",
+"List or select a handler", 0);
+}
+
+GRUB_MOD_FINI(handler)
+{
+  grub_unregister_command ("hello");
+}

This should probable be grub_unregister_command ("handler").

-- 
Felix Zielcke



___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] Handler support

2009-02-14 Thread Bean
On Sat, Feb 14, 2009 at 11:11 PM, Felix Zielcke  wrote:
> A. Am Samstag, den 14.02.2009, 22:46 +0800 schrieb Bean:
>
>> If there is no objection, I'd commit this patch in a few days.
>
> Hello Bean,
>
> if you want to drop termin_input and terminal_output command then please
> don't forget to update util/grub.d/00_header.in
>
> +GRUB_MOD_INIT(handler)
> +{
> +  (void)mod;   /* To stop warning. */
> +  grub_register_command ("handler", grub_cmd_handler,
> GRUB_COMMAND_FLAG_BOTH,
> +"handler [class [handler]]",
> +"List or select a handler", 0);
> +}
> +
> +GRUB_MOD_FINI(handler)
> +{
> +  grub_unregister_command ("hello");
> +}
>
> This should probable be grub_unregister_command ("handler").

Hi,

Thanks for pointing out, this new patch should fix the problem.

-- 
Bean
diff --git a/commands/handler.c b/commands/handler.c
new file mode 100644
index 000..9f4e632
--- /dev/null
+++ b/commands/handler.c
@@ -0,0 +1,105 @@
+/* handler.c - test module for dynamic loading */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2009  Free Software Foundation, Inc.
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static grub_err_t
+grub_cmd_handler (struct grub_arg_list *state __attribute__ ((unused)),
+		  int argc, char **args)
+{
+  char *find_name;
+  void *find_result;
+  void *curr_item = 0;
+
+  auto int list_item (grub_handler_class_t item);
+  int list_item (grub_handler_class_t item)
+{
+  if (item == curr_item)
+	grub_putchar ('*');
+
+  grub_printf ("%s\n", item->name);
+
+  return 0;
+}
+
+  auto int find_item (grub_handler_class_t item);
+  int find_item (grub_handler_class_t item)
+{
+  if (! grub_strcmp (item->name, find_name))
+	{
+	  find_result = item;
+	  return 1;
+	}
+
+  return 0;
+}
+
+  if (argc == 0)
+{
+  grub_handler_class_iterate (list_item);
+}
+  else
+{
+  grub_handler_class_t class;
+
+  find_name = args[0];
+  find_result = 0;
+  grub_handler_class_iterate (find_item);
+  if (! find_result)
+	return grub_error (GRUB_ERR_FILE_NOT_FOUND, "class not found");
+
+  class = find_result;
+
+  if (argc == 1)
+	{
+	  curr_item = class->cur_handler;
+	  grub_handler_iterate (find_result, (grub_list_hook_t) list_item);
+	}
+  else
+	{
+	  find_name = args[1];
+	  find_result = 0;
+	  grub_handler_iterate (class, (grub_list_hook_t) find_item);
+
+	  if (! find_result)
+	return grub_error (GRUB_ERR_FILE_NOT_FOUND, "handler not found");
+
+	  grub_handler_set_current (class, find_result);
+	}
+}
+
+  return 0;
+}
+
+GRUB_MOD_INIT(handler)
+{
+  (void)mod;			/* To stop warning. */
+  grub_register_command ("handler", grub_cmd_handler, GRUB_COMMAND_FLAG_BOTH,
+			 "handler [class [handler]]",
+			 "List or select a handler", 0);
+}
+
+GRUB_MOD_FINI(handler)
+{
+  grub_unregister_command ("handler");
+}
diff --git a/conf/common.rmk b/conf/common.rmk
index dfd481a..9a62ac3 100644
--- a/conf/common.rmk
+++ b/conf/common.rmk
@@ -330,7 +330,7 @@ scsi_mod_CFLAGS = $(COMMON_CFLAGS)
 scsi_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 # Commands.
-pkglib_MODULES += hello.mod boot.mod terminal.mod ls.mod	\
+pkglib_MODULES += hello.mod boot.mod handler.mod ls.mod	\
 	cmp.mod cat.mod help.mod search.mod	\
 	loopback.mod fs_uuid.mod configfile.mod echo.mod	\
 	terminfo.mod test.mod blocklist.mod hexdump.mod		\
@@ -346,10 +346,10 @@ boot_mod_SOURCES = commands/boot.c
 boot_mod_CFLAGS = $(COMMON_CFLAGS)
 boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
-# For terminal.mod.
-terminal_mod_SOURCES = commands/terminal.c
-terminal_mod_CFLAGS = $(COMMON_CFLAGS)
-terminal_mod_LDFLAGS = $(COMMON_LDFLAGS)
+# For handler.mod.
+handler_mod_SOURCES = commands/handler.c
+handler_mod_CFLAGS = $(COMMON_CFLAGS)
+handler_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 # For ls.mod.
 ls_mod_SOURCES = commands/ls.c
diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk
index b97483b..4938665 100644
--- a/conf/i386-coreboot.rmk
+++ b/conf/i386-coreboot.rmk
@@ -17,7 +17,7 @@ kernel_elf_SOURCES = kern/i386/coreboot/startup.S \
 	kern/main.c kern/device.c \
 	kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
 	kern/misc.c kern/mm.c kern/loader.c kern/rescue.c kern/term.c \
-	kern/time.c \
+	kern/time.c kern/list.c kern/handler.c \

Design: partitions in partitions

2009-02-14 Thread phcoder
Hello I would like to implement partition in partitions support (it's on 
the TODO list) and necessary as a pre-requisite to access solaris' zfs 
partitions. I would also like to integrate current bsd partition support 
to it. I propose the following design:

Unified naming scheme: purely numerical. It means that
(hd0,1,a) becomes (hd0,1,1)

get_name is removed from grub_partition_map

Unlimited depth support. It means that partitions like
fdisk in sun in apple in gpt will be detected (silly but is 
theoretically possible)
Partitions describing whole parent partition or laying outside of parent 
partition will be filtered

An arbitrary limit may be put to avoid endless loop

Add pointer to struct grub_disk * in struct grub_partition.
Then the prototypes in grub_partition_map are:
  /* Call HOOK with each partition, until HOOK returns non-zero.  */
  grub_err_t (*iterate) (grub_partition_t parent,
 int (*hook) (struct grub_disk *disk,
  const grub_partition_t partition));

  /* Return the partition NUM on the partition PARENT.  */
  grub_partition_t (*probe) (grub_partition_t parent,
 int num);

For the first level a fake grub_partition_t describing the whole disk 
will be created


What do you think about such a design?
Regards
Vladimir 'phcoder' Serbinenko


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Bugfix: ata pass-through broke compilation

2009-02-14 Thread phcoder

Hello. Here is bugfix
Regards
Vladimir 'phcoder' Serbinenko
Index: kern/disk.c
===
--- kern/disk.c (revision 1994)
+++ kern/disk.c (working copy)
@@ -47,7 +47,7 @@
 int grub_disk_firmware_is_tainted;
 
 grub_err_t (* grub_disk_ata_pass_through) (grub_disk_t,
-   struct grub_ata_pass_through_cmd *);
+   struct grub_disk_ata_pass_through_parms *);
 
 
 #if 0
Index: ChangeLog
===
--- ChangeLog   (revision 1994)
+++ ChangeLog   (working copy)
@@ -1,3 +1,120 @@
+2009-02-13  Vladimir Serbinenko  
+
+   Corrected wrong declaration
+
+   * kern/disk.c: corrected declaration of grub_disk_ata_pass_through
+   
 2009-02-14  Christian Franke  
 
* gendistlist.sh: Ignore `.svn' directories.
___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: Bugfix: ata pass-through broke compilation

2009-02-14 Thread Christian Franke

phcoder wrote:


Hello. Here is bugfix


Thanks!

Yes, I should rename all occurences...
(gcc 3.4.4 did not detect this).

Committed.

Christian



___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] Handler support

2009-02-14 Thread Vesa Jääskeläinen
Bean wrote:
> On Sat, Feb 14, 2009 at 11:11 PM, Felix Zielcke  wrote:
>> A. Am Samstag, den 14.02.2009, 22:46 +0800 schrieb Bean:
>>
>>> If there is no objection, I'd commit this patch in a few days.
>> Hello Bean,
>>
>> if you want to drop termin_input and terminal_output command then please
>> don't forget to update util/grub.d/00_header.in
>>
>> +GRUB_MOD_INIT(handler)
>> +{
>> +  (void)mod;   /* To stop warning. */
>> +  grub_register_command ("handler", grub_cmd_handler,
>> GRUB_COMMAND_FLAG_BOTH,
>> +"handler [class [handler]]",
>> +"List or select a handler", 0);
>> +}
>> +
>> +GRUB_MOD_FINI(handler)
>> +{
>> +  grub_unregister_command ("hello");
>> +}
>>
>> This should probable be grub_unregister_command ("handler").
> 
> Hi,
> 
> Thanks for pointing out, this new patch should fix the problem.

Hi,

Ok. I a way this functionality could be used. I just don't like how it
is visible to the user.

> +if handler output ${GRUB_TERMINAL_OUTPUT} ; then true ; else
> +  # For backward compatibility with versions that uses terminal.mod instead
> +  # of handler.mod
> +  if terminal_output ${GRUB_TERMINAL_OUTPUT} ; then true ; else
> +# For backward compatibility with versions of terminal.mod that don't
> +# understand terminal_output
> +terminal ${GRUB_TERMINAL_OUTPUT}
> +  fi

If we look at this snippet, for me keyword handler doesn't say a thing.
where it could be terminal for terminal handlers.

So I would propose to change it in following ways:

1. Do not register handler command unless you need to enumerate those or
allow more flexibility to configuration
2. Register command functions/alias to more understandable grub commands.

So following could be:

terminal output 

or keep it what it is (I would prefer above line)

terminal_output

Good idea with this handler stuff would be that if someone writes following:

terminal console

It would lookup if this console provides input and output service and
would use them out of the box.

Now if some-one writes something like:

terminal --input usbkbd --input console --output console

or:

terminal --input usbkbd
terminal --input console
terminal --output console

or

terminal_input usbkbd
terminal_input console
terminal_output console

or

terminal_input usbkbd console
terminal_output console

or

terminal_input console
terminal_output console
termianl_input --add usbkbd

User would now get two input sources like ps2 keyboard and usb keyboard
and then output to console.

Anyway... my point being... handler does not say anything to me in a
sens what does it logically give to user. It hinders the understanding
of the user for grub 2 usage...



___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel