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 +#include +#include +#include +#include +#include +#include + +/* 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)); + +} + + +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 +#include +#include +#include +#include + +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; +} + + +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