All of lore.kernel.org
 help / color / mirror / Atom feed
* map command for grub2 draft
@ 2007-06-07 15:34 adrian15
  2007-06-11 14:45 ` adrian15
  0 siblings, 1 reply; 7+ messages in thread
From: adrian15 @ 2007-06-07 15:34 UTC (permalink / raw)
  To: The development of GRUB 2

	I want to implement the map command for grub2 as long as it is an
interesting thing for stupid windows oses and because it's the clue for
making an "usbshift" equivalent command (See Super Grub Disk usbshift
command for more details).


1st) Where to save an array?
=============================

	If I mimic the grub legacy map command I need to save an array with the
map definitions.

	static unsigned short bios_drive_map[DRIVE_MAP_SIZE + 1];
	
	So that each time I call something like:
	map (hd0) (hd1)
	it modifies this vector.

Any example on where should I define this vector so that I can use it
from each command ?

2nd) boot_func and actual mapping
====================================

	If you look at grub legacy boot command


     case KERNEL_TYPE_CHAINLOADER:
       /* Chainloader */

       /* Check if we should set the int13 handler.  */
       if (bios_drive_map[0] != 0)
	{
	  int i;
	
	  /* Search for SAVED_DRIVE.  */
	  for (i = 0; i < DRIVE_MAP_SIZE; i++)
	    {
	      if (! bios_drive_map[i])
		break;
	      else if ((bios_drive_map[i] & 0xFF) == saved_drive)
		{
		  /* Exchage SAVED_DRIVE with the mapped drive.  */
		  saved_drive = (bios_drive_map[i] >> 8) & 0xFF;
		  break;
		}
	    }
	
	  /* Set the handler. This is somewhat dangerous.  */
	  set_int13_handler (bios_drive_map);
	}

       gateA20 (0);
       boot_drive = saved_drive;
       chain_stage1 (0, BOOTSEC_LOCATION, boot_part_addr);
       break;




you will see that among other things it detects if you want to do a
chainloader boot. If you do a chainloader boot it checks the
bios_drive_map array,... run some BIOS calls so that there's an actual
map and then it finally boots.

	When I told marco_g that I want to modificy grub2's boot command he
became scared because the boot command was arquitecture specific (or
maybe not, I actually did not understood what he meant) and as long as I
understood I was not meant to modify it.

	how should I implement this then?



adrian15




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: map command for grub2 draft
  2007-06-07 15:34 map command for grub2 draft adrian15
@ 2007-06-11 14:45 ` adrian15
  2007-06-15 18:22   ` Marco Gerards
  2007-06-16 17:19   ` adrian15
  0 siblings, 2 replies; 7+ messages in thread
From: adrian15 @ 2007-06-11 14:45 UTC (permalink / raw)
  To: The development of GRUB 2

adrian15 escribió:
> 1st) Where to save an array?
> =============================
> 
>     If I mimic the grub legacy map command I need to save an array with the
> map definitions.
> 
>     static unsigned short bios_drive_map[DRIVE_MAP_SIZE + 1];
>     
>     So that each time I call something like:
>     map (hd0) (hd1)
>     it modifies this vector.
> 
> Any example on where should I define this vector so that I can use it
> from each command ?

I ask the question again.

I've begun to implement commands/i386/pc/map.c  (I suppose the map.c is
pc specific althought I am not sure).

The question is how do I get the bios number for a given hard disk?
Thank you. You know hd0 is usually 0x80, that's the number that I want.

Here is the source code written so far which I have not compiled.

adrian15

static grub_err_t
grub_cmd_map (struct grub_arg_list *state __attribute__ ((unused)),
	       int argc, char **args)
{
   grub_disk_t map_disk_1,map_disk_2;

   if (argc != 2)
     return grub_error (GRUB_ERR_BAD_ARGUMENT, "Two devices required");

   map_disk_1 = grub_disk_open (args[0]);
   if (! map_disk_1)
     return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown 1st disk");
   map_disk_2 = grub_disk_open (args[1]);
   if (! map_disk_2)
     return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown 2nd disk");

/* How do I get the BIOS number for a given disk */






^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: map command for grub2 draft
  2007-06-11 14:45 ` adrian15
@ 2007-06-15 18:22   ` Marco Gerards
  2007-06-15 18:45     ` Bean
  2007-06-16 17:19   ` adrian15
  1 sibling, 1 reply; 7+ messages in thread
From: Marco Gerards @ 2007-06-15 18:22 UTC (permalink / raw)
  To: The development of GRUB 2

adrian15 <adrian15@raulete.net> writes:

> adrian15 escribió:
>> 1st) Where to save an array?
>> =============================
>>
>>     If I mimic the grub legacy map command I need to save an array with the
>> map definitions.
>>
>>     static unsigned short bios_drive_map[DRIVE_MAP_SIZE + 1];
>>         So that each time I call something like:
>>     map (hd0) (hd1)
>>     it modifies this vector.
>>
>> Any example on where should I define this vector so that I can use it
>> from each command ?
>
> I ask the question again.

What is this vector supposed to do?  Do you really need it outside
map.c?

Can you describe the design of the map command?

--
Marco





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: map command for grub2 draft
  2007-06-15 18:22   ` Marco Gerards
@ 2007-06-15 18:45     ` Bean
  2007-06-15 18:56       ` Marco Gerards
  0 siblings, 1 reply; 7+ messages in thread
From: Bean @ 2007-06-15 18:45 UTC (permalink / raw)
  To: The development of GRUB 2

On Fri, Jun 15, 2007 at 08:22:16PM +0200, Marco Gerards wrote:
> adrian15 <adrian15@raulete.net> writes:
> 
> > adrian15 escribió:
> >> 1st) Where to save an array?
> >> =============================
> >>
> >>     If I mimic the grub legacy map command I need to save an array with the
> >> map definitions.
> >>
> >>     static unsigned short bios_drive_map[DRIVE_MAP_SIZE + 1];
> >>         So that each time I call something like:
> >>     map (hd0) (hd1)
> >>     it modifies this vector.
> >>
> >> Any example on where should I define this vector so that I can use it
> >> from each command ?
> >
> > I ask the question again.
> 
> What is this vector supposed to do?  Do you really need it outside
> map.c?
> 
> Can you describe the design of the map command?

I happen to know something about the map command in GRUB Legacy, it works
by hooking INT 13.

It first reserves a small range of memory from the top of convensional
memory by decreasing value at 0x413, then copy its INT 13 interrupt handler
and the drive map to this area. Finally, it modifies the IVT table so that
INT 13 points to the new handler.

Inside the handler, it uses the drive map to translate the current drive
stored in %dl to the real drive, then jump to the original handler.

-- 
Bean <bean123@126.com>




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: map command for grub2 draft
  2007-06-15 18:45     ` Bean
@ 2007-06-15 18:56       ` Marco Gerards
  2007-06-15 19:10         ` Bean
  0 siblings, 1 reply; 7+ messages in thread
From: Marco Gerards @ 2007-06-15 18:56 UTC (permalink / raw)
  To: The development of GRUB 2

Bean <bean123@126.com> writes:

> On Fri, Jun 15, 2007 at 08:22:16PM +0200, Marco Gerards wrote:
>> adrian15 <adrian15@raulete.net> writes:
>> 
>> > adrian15 escribió:
>> >> 1st) Where to save an array?
>> >> =============================
>> >>
>> >>     If I mimic the grub legacy map command I need to save an array with the
>> >> map definitions.
>> >>
>> >>     static unsigned short bios_drive_map[DRIVE_MAP_SIZE + 1];
>> >>         So that each time I call something like:
>> >>     map (hd0) (hd1)
>> >>     it modifies this vector.
>> >>
>> >> Any example on where should I define this vector so that I can use it
>> >> from each command ?
>> >
>> > I ask the question again.
>> 
>> What is this vector supposed to do?  Do you really need it outside
>> map.c?
>> 
>> Can you describe the design of the map command?
>
> I happen to know something about the map command in GRUB Legacy, it works
> by hooking INT 13.
>
> It first reserves a small range of memory from the top of convensional
> memory by decreasing value at 0x413, then copy its INT 13 interrupt handler
> and the drive map to this area. Finally, it modifies the IVT table so that
> INT 13 points to the new handler.
>
> Inside the handler, it uses the drive map to translate the current drive
> stored in %dl to the real drive, then jump to the original handler.

Right, but the problem Adrian brought up was that he though he needs
to add a vector which describes the mapping as a global.  I do not see
why this is required.  So I wonder what he had in mind.

I think the main issue here is how to hook this into GRUB 2 so that
the hook becomes effective just before booting.

--
Marco




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: map command for grub2 draft
  2007-06-15 18:56       ` Marco Gerards
@ 2007-06-15 19:10         ` Bean
  0 siblings, 0 replies; 7+ messages in thread
From: Bean @ 2007-06-15 19:10 UTC (permalink / raw)
  To: The development of GRUB 2

On Fri, Jun 15, 2007 at 08:56:00PM +0200, Marco Gerards wrote:
> Bean <bean123@126.com> writes:
> 
> > On Fri, Jun 15, 2007 at 08:22:16PM +0200, Marco Gerards wrote:
> >> adrian15 <adrian15@raulete.net> writes:
> >> 
> >> > adrian15 escribió:
> >> >> 1st) Where to save an array?
> >> >> =============================
> >> >>
> >> >>     If I mimic the grub legacy map command I need to save an array with the
> >> >> map definitions.
> >> >>
> >> >>     static unsigned short bios_drive_map[DRIVE_MAP_SIZE + 1];
> >> >>         So that each time I call something like:
> >> >>     map (hd0) (hd1)
> >> >>     it modifies this vector.
> >> >>
> >> >> Any example on where should I define this vector so that I can use it
> >> >> from each command ?
> >> >
> >> > I ask the question again.
> >> 
> >> What is this vector supposed to do?  Do you really need it outside
> >> map.c?
> >> 
> >> Can you describe the design of the map command?
> >
> > I happen to know something about the map command in GRUB Legacy, it works
> > by hooking INT 13.
> >
> > It first reserves a small range of memory from the top of convensional
> > memory by decreasing value at 0x413, then copy its INT 13 interrupt handler
> > and the drive map to this area. Finally, it modifies the IVT table so that
> > INT 13 points to the new handler.
> >
> > Inside the handler, it uses the drive map to translate the current drive
> > stored in %dl to the real drive, then jump to the original handler.
> 
> Right, but the problem Adrian brought up was that he though he needs
> to add a vector which describes the mapping as a global.  I do not see
> why this is required.  So I wonder what he had in mind.

Yes, it doesn't need to be a global variable.

> 
> I think the main issue here is how to hook this into GRUB 2 so that
> the hook becomes effective just before booting.

It can be done in a grub_map_real_boot function in kern/i386/pc/startup.S

-- 
Bean <bean123@126.com>




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: map command for grub2 draft
  2007-06-11 14:45 ` adrian15
  2007-06-15 18:22   ` Marco Gerards
@ 2007-06-16 17:19   ` adrian15
  1 sibling, 0 replies; 7+ messages in thread
From: adrian15 @ 2007-06-16 17:19 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 3542 bytes --]

	Here I am again with another question...

	How do I check that a given string: (hd0), (hd1,0), (hd1) is an
existent drive?

	I supposed that I had to use grub_disk_open because I did not want to
use grub_device_open can open (hd1,0) and (hd1,0) is not a drive but a
partition.

	Here there is my map.c source code (which does compile) and some more
doubts that I have:

I attach a patch that contains an unfinished and untested pause command too.


> #include <grub/normal.h>
> #include <grub/dl.h>
> #include <grub/arg.h>
> #include <grub/disk.h>
> #include <grub/term.h>
> #include <grub/misc.h>
> #include <grub/device.h>
Is there any include that I do not need at all?
> 
> /* The size of the drive map.  */
> #define DRIVE_MAP_SIZE		16
> /* The BIOS drive map.  */
> static unsigned short bios_drive_map[DRIVE_MAP_SIZE + 1];
I've finally decided to put this here. I will put the other commands:
mapboot (the bios hook) and usbshift (A complex map command that maps
many drives) in this same file.
> 
> int real_map_func (unsigned long to, unsigned long from) {
> int i;
>   /* Search for an empty slot in BIOS_DRIVE_MAP.  */
>   for (i = 0; i < DRIVE_MAP_SIZE; i++)
>     {
>       /* Perhaps the user wants to override the map.  */
>       if ((bios_drive_map[i] & 0xff) == from)
> 	break;
>       
>       if (! bios_drive_map[i])
> 	break;
>     }
> 
>   if (i == DRIVE_MAP_SIZE)
>     {
>       return GRUB_ERR_OUT_OF_RANGE;
>     }
> 
>   if (to == from)
>     /* If TO is equal to FROM, delete the entry.  */
>     grub_memmove ((char *) &bios_drive_map[i], (char *) &bios_drive_map[i + 1],
> 		  sizeof (unsigned short) * (DRIVE_MAP_SIZE - i));
>   else
>     bios_drive_map[i] = from | (to << 8);
>   
>   return 0;
> 
> 
> }
Copy-Pasted from grub legacy. :)
Should I improve it, removing the break or not ?
> 
> 
> 
> static grub_err_t
> grub_cmd_map (struct grub_arg_list *state __attribute__ ((unused)),
> 	       int argc, char **args)
> {
>   grub_disk_t map_disk_to,map_disk_from;
I want to check disks not devices this is why I use grub_disk_t.

>   
>   if (argc != 2)
>     return grub_error (GRUB_ERR_BAD_ARGUMENT, "Two devices required");
> 
>   map_disk_to = grub_disk_open (args[0]);
> /* TODO: Check map arguments from grub2 engine */
This means that in a future the grub2 engine should be able to read an
string like: <DISK1,DISK2> and check itself if the strings are disks or
not thus I would not have to write the checks inside this file.
>   if (! map_disk_to)
>     return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown TO disk");
>   map_disk_from = grub_disk_open (args[1]);
>   if (! map_disk_from)
>     return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown FROM disk");
> 
>   return (real_map_func(map_disk_to->id,map_disk_from->id));
Do you want me to merge the two functions in one maybe?
>   
> }
> 
> \f
> GRUB_MOD_INIT(map)
> {
>   (void)mod;			/* To stop warning. */
>   grub_register_command ("map", grub_cmd_map, GRUB_COMMAND_FLAG_BOTH,
> 			 "map TODEVICE FROMDEVICE", "Map a drive to another", 0);
> }
> 
> GRUB_MOD_FINI(map)
> {
>   grub_unregister_command ("map");
> }


One more question marco_g told me that I had to check the field "name"
from grub_disk_t struct. If it read: "biosdisk" then it was ok for the
map command. If it did not read this then it was an error.

I am sorry about the noob question but how should I compare two strings
on grub2?

And why isn't there an enum type for grub_disk_t name field (as the
grub2 errors)? Do we have a new name for disk everyday ?



adrian15


[-- Attachment #2: map_draft_1.patch --]
[-- Type: text/x-patch, Size: 10837 bytes --]

diff -urN grub2_2007_05_31_original/commands/i386/pc/map.c grub2_2007_05_31_map/commands/i386/pc/map.c
--- grub2_2007_05_31_original/commands/i386/pc/map.c	1970-01-01 01:00:00.000000000 +0100
+++ grub2_2007_05_31_map/commands/i386/pc/map.c	2007-06-16 12:09:28.000000000 +0200
@@ -0,0 +1,98 @@
+/* map.c - Define map vector  */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005  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 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/arg.h>
+#include <grub/disk.h>
+#include <grub/term.h>
+#include <grub/misc.h>
+#include <grub/device.h>
+
+/* The size of the drive map.  */
+#define DRIVE_MAP_SIZE		16
+/* The BIOS drive map.  */
+static unsigned short bios_drive_map[DRIVE_MAP_SIZE + 1];
+
+int real_map_func (unsigned long to, unsigned long from) {
+int i;
+  /* Search for an empty slot in BIOS_DRIVE_MAP.  */
+  for (i = 0; i < DRIVE_MAP_SIZE; i++)
+    {
+      /* Perhaps the user wants to override the map.  */
+      if ((bios_drive_map[i] & 0xff) == from)
+	break;
+      
+      if (! bios_drive_map[i])
+	break;
+    }
+
+  if (i == DRIVE_MAP_SIZE)
+    {
+      return GRUB_ERR_OUT_OF_RANGE;
+    }
+
+  if (to == from)
+    /* If TO is equal to FROM, delete the entry.  */
+    grub_memmove ((char *) &bios_drive_map[i], (char *) &bios_drive_map[i + 1],
+		  sizeof (unsigned short) * (DRIVE_MAP_SIZE - i));
+  else
+    bios_drive_map[i] = from | (to << 8);
+  
+  return 0;
+
+
+}
+
+
+
+static grub_err_t
+grub_cmd_map (struct grub_arg_list *state __attribute__ ((unused)),
+	       int argc, char **args)
+{
+  grub_disk_t map_disk_to,map_disk_from;
+  
+  if (argc != 2)
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, "Two devices required");
+
+  map_disk_to = grub_disk_open (args[0]);
+/* TODO: Check map arguments from grub2 engine */
+  if (! map_disk_to)
+    return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown TO disk");
+  map_disk_from = grub_disk_open (args[1]);
+  if (! map_disk_from)
+    return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown FROM disk");
+
+  return (real_map_func(map_disk_to->id,map_disk_from->id));
+  
+}
+
+\f
+GRUB_MOD_INIT(map)
+{
+  (void)mod;			/* To stop warning. */
+  grub_register_command ("map", grub_cmd_map, GRUB_COMMAND_FLAG_BOTH,
+			 "map TODEVICE FROMDEVICE", "Map a drive to another", 0);
+}
+
+GRUB_MOD_FINI(map)
+{
+  grub_unregister_command ("map");
+}
diff -urN grub2_2007_05_31_original/commands/pause.c grub2_2007_05_31_map/commands/pause.c
--- grub2_2007_05_31_original/commands/pause.c	1970-01-01 01:00:00.000000000 +0100
+++ grub2_2007_05_31_map/commands/pause.c	2007-06-12 12:02:37.000000000 +0200
@@ -0,0 +1,52 @@
+/* pause.c - command to pause and show a message.  */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2003,2005  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 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/arg.h>
+#include <grub/term.h>
+#include <grub/misc.h>
+
+static grub_err_t
+grub_cmd_pause (struct grub_arg_list *state __attribute__ ((unused)),
+	      int argc, char **args)
+
+{
+
+  char key;
+  if (argc!=0) 
+    grub_cmd_echo(state,argc,args);
+  key = grub_getkey ();
+  
+  return 0;
+}
+
+\f
+GRUB_MOD_INIT(pause)
+{
+  (void) mod;			/* To stop warning. */
+  grub_register_command ("pause", grub_cmd_pause, GRUB_COMMAND_FLAG_BOTH,
+			 "pause [MESSAGE]", "Pause and optionally show a message with echo command.", 0);
+}
+
+GRUB_MOD_FINI(pause)
+{
+  grub_unregister_command ("pause");
+}
diff -urN grub2_2007_05_31_original/conf/i386-pc.mk grub2_2007_05_31_map/conf/i386-pc.mk
--- grub2_2007_05_31_original/conf/i386-pc.mk	2007-06-11 11:53:27.000000000 +0200
+++ grub2_2007_05_31_map/conf/i386-pc.mk	2007-06-14 12:50:57.000000000 +0200
@@ -1,5 +1,7 @@
 # -*- makefile -*-
 
+
+
 COMMON_ASFLAGS = -nostdinc -fno-builtin -m32
 COMMON_CFLAGS = -fno-builtin -mrtd -mregparm=3 -m32
 COMMON_LDFLAGS = -m32 -nostdlib
@@ -813,7 +815,7 @@
 pkgdata_MODULES = _chain.mod _linux.mod linux.mod normal.mod \
 	_multiboot.mod chain.mod multiboot.mod reboot.mod halt.mod	\
 	vbe.mod vbetest.mod vbeinfo.mod video.mod gfxterm.mod \
-	videotest.mod play.mod bitmap.mod tga.mod cpuid.mod
+	videotest.mod map.mod play.mod bitmap.mod tga.mod cpuid.mod
 
 # For _chain.mod.
 _chain_mod_SOURCES = loader/i386/pc/chainloader.c
@@ -1691,6 +1693,58 @@
 vbetest_mod_CFLAGS = $(COMMON_CFLAGS)
 vbetest_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
+# For map.mod.
+map_mod_SOURCES = commands/i386/pc/map.c
+CLEANFILES += map.mod mod-map.o mod-map.c pre-map.o map_mod-commands_i386_pc_map.o und-map.lst
+ifneq ($(map_mod_EXPORTS),no)
+CLEANFILES += def-map.lst
+DEFSYMFILES += def-map.lst
+endif
+MOSTLYCLEANFILES += map_mod-commands_i386_pc_map.d
+UNDSYMFILES += und-map.lst
+
+map.mod: pre-map.o mod-map.o
+	-rm -f $@
+	$(TARGET_CC) $(map_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^
+	$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
+
+pre-map.o: $(map_mod_DEPENDENCIES) map_mod-commands_i386_pc_map.o
+	-rm -f $@
+	$(TARGET_CC) $(map_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ map_mod-commands_i386_pc_map.o
+
+mod-map.o: mod-map.c
+	$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(map_mod_CFLAGS) -c -o $@ $<
+
+mod-map.c: moddep.lst genmodsrc.sh
+	sh $(srcdir)/genmodsrc.sh 'map' $< > $@ || (rm -f $@; exit 1)
+
+ifneq ($(map_mod_EXPORTS),no)
+def-map.lst: pre-map.o
+	$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 map/' > $@
+endif
+
+und-map.lst: pre-map.o
+	echo 'map' > $@
+	$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
+
+map_mod-commands_i386_pc_map.o: commands/i386/pc/map.c
+	$(TARGET_CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(map_mod_CFLAGS) -MD -c -o $@ $<
+-include map_mod-commands_i386_pc_map.d
+
+CLEANFILES += cmd-map_mod-commands_i386_pc_map.lst fs-map_mod-commands_i386_pc_map.lst
+COMMANDFILES += cmd-map_mod-commands_i386_pc_map.lst
+FSFILES += fs-map_mod-commands_i386_pc_map.lst
+
+cmd-map_mod-commands_i386_pc_map.lst: commands/i386/pc/map.c gencmdlist.sh
+	set -e; 	  $(TARGET_CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(map_mod_CFLAGS) -E $< 	  | sh $(srcdir)/gencmdlist.sh map > $@ || (rm -f $@; exit 1)
+
+fs-map_mod-commands_i386_pc_map.lst: commands/i386/pc/map.c genfslist.sh
+	set -e; 	  $(TARGET_CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(map_mod_CFLAGS) -E $< 	  | sh $(srcdir)/genfslist.sh map > $@ || (rm -f $@; exit 1)
+
+
+map_mod_CFLAGS = $(COMMON_CFLAGS)
+map_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
 # For play.mod.
 play_mod_SOURCES = commands/i386/pc/play.c
 CLEANFILES += play.mod mod-play.o mod-play.c pre-play.o play_mod-commands_i386_pc_play.o und-play.lst
diff -urN grub2_2007_05_31_original/conf/i386-pc.rmk grub2_2007_05_31_map/conf/i386-pc.rmk
--- grub2_2007_05_31_original/conf/i386-pc.rmk	2007-06-11 11:53:27.000000000 +0200
+++ grub2_2007_05_31_map/conf/i386-pc.rmk	2007-06-14 12:38:00.000000000 +0200
@@ -1,5 +1,7 @@
 # -*- makefile -*-
 
+
+
 COMMON_ASFLAGS = -nostdinc -fno-builtin -m32
 COMMON_CFLAGS = -fno-builtin -mrtd -mregparm=3 -m32
 COMMON_LDFLAGS = -m32 -nostdlib
@@ -121,7 +123,7 @@
 pkgdata_MODULES = _chain.mod _linux.mod linux.mod normal.mod \
 	_multiboot.mod chain.mod multiboot.mod reboot.mod halt.mod	\
 	vbe.mod vbetest.mod vbeinfo.mod video.mod gfxterm.mod \
-	videotest.mod play.mod bitmap.mod tga.mod cpuid.mod
+	videotest.mod map.mod play.mod bitmap.mod tga.mod cpuid.mod
 
 # For _chain.mod.
 _chain_mod_SOURCES = loader/i386/pc/chainloader.c
@@ -195,6 +197,11 @@
 vbetest_mod_CFLAGS = $(COMMON_CFLAGS)
 vbetest_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
+# For map.mod.
+map_mod_SOURCES = commands/i386/pc/map.c
+map_mod_CFLAGS = $(COMMON_CFLAGS)
+map_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
 # For play.mod.
 play_mod_SOURCES = commands/i386/pc/play.c
 play_mod_CFLAGS = $(COMMON_CFLAGS)
diff -urN grub2_2007_05_31_original/gendistlist grub2_2007_05_31_map/gendistlist
--- grub2_2007_05_31_original/gendistlist	1970-01-01 01:00:00.000000000 +0100
+++ grub2_2007_05_31_map/gendistlist	2007-06-14 12:09:39.000000000 +0200
@@ -0,0 +1,38 @@
+#! /bin/sh
+#
+# Copyright (C) 2005  Free Software Foundation, Inc.
+#
+# This gendistlist.sh is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+# Generate a list of distributed files.
+
+EXTRA_DISTFILES="AUTHORS COPYING ChangeLog DISTLIST INSTALL NEWS README \
+	THANKS TODO Makefile.in aclocal.m4 autogen.sh config.guess \
+	config.h.in config.sub configure configure.ac gencmdlist.sh \
+	gendistlist.sh genfslist.sh genkernsyms.sh genmk.rb \
+	genmodsrc.sh gensymlist.sh install-sh mkinstalldirs stamp-h.in"
+
+DISTDIRS="boot commands conf disk font fs hello include io kern loader \
+	normal partmap term util video"
+
+for f in $EXTRA_DISTFILES; do
+    echo $f
+done
+
+dir=`dirname $0`
+cd $dir
+
+for dir in $DISTDIRS; do
+  for d in `find $dir -type d | sort`; do
+    find $d -maxdepth 1 -name '*.[chS]' -o -name '*.mk' -o -name '*.rmk' \
+      -o -name '*.rb' -o -name '*.in' \
+      | sort
+  done
+done


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-06-16 17:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-07 15:34 map command for grub2 draft adrian15
2007-06-11 14:45 ` adrian15
2007-06-15 18:22   ` Marco Gerards
2007-06-15 18:45     ` Bean
2007-06-15 18:56       ` Marco Gerards
2007-06-15 19:10         ` Bean
2007-06-16 17:19   ` adrian15

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.