Hi,

This is a collection of miscellaneous patches, it includes:

1, move util/envblk.c to lib/envblk.c

As envblk.c is used by module loadenv and tool grub-editenv, I think
it's better to move it to lib directory.

2. seperate hexdump function, and move it to lib/hexdump.c

hexdump module consists of two parts, one is hexdump function, the
other is user land command. I move the hexdump function to lib, as
it's also used in other place, for example grub-fstest.

3. add new command crc

Just like hexdump, this module is split into two parts, lib/crc.c for
the crc function, commands/crc.c for the user land command that
calculate the crc checksum of selected file.

4. rename appleloader command to bootcamp

The name appleloader may be a little confusing, bootcamp seems to be a
better choice.

-- 
Bean
diff --git a/commands/crc.c b/commands/crc.c
new file mode 100644
index 0000000..5148648
--- /dev/null
+++ b/commands/crc.c
@@ -0,0 +1,66 @@
+/* crc.c - command to calculate the crc32 checksum of a file  */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2008  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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/arg.h>
+#include <grub/disk.h>
+#include <grub/file.h>
+#include <grub/misc.h>
+#include <grub/lib/crc.h>
+
+static grub_err_t
+grub_cmd_crc (struct grub_arg_list *state __attribute__ ((unused)),
+	      int argc, char **args)
+
+{
+  grub_file_t file;
+  char buf[GRUB_DISK_SECTOR_SIZE];
+  grub_ssize_t size;
+  grub_uint32_t crc;
+
+  if (argc != 1)
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
+
+  file = grub_file_open (args[0]);
+  if (! file)
+    return 0;
+
+  crc = 0;
+  while ((size = grub_file_read (file, buf, sizeof (buf))) > 0)
+    crc = grub_getcrc32 (crc, buf, size);
+
+  grub_file_close (file);
+
+  grub_printf ("%08x\n", crc);
+
+  return 0;
+}
+
+GRUB_MOD_INIT(crc)
+{
+  (void) mod;			/* To stop warning. */
+  grub_register_command ("crc", grub_cmd_crc, GRUB_COMMAND_FLAG_BOTH,
+			 "crc FILE", "Calculate the crc32 checksum of a file.", 0);
+}
+
+GRUB_MOD_FINI(crc)
+{
+  grub_unregister_command ("crc");
+}
diff --git a/commands/hexdump.c b/commands/hexdump.c
index c340638..5c0ddc0 100644
--- a/commands/hexdump.c
+++ b/commands/hexdump.c
@@ -24,8 +24,8 @@
 #include <grub/disk.h>
 #include <grub/misc.h>
 #include <grub/gzio.h>
-#include <grub/hexdump.h>
 #include <grub/partition.h>
+#include <grub/lib/hexdump.h>
 
 static const struct grub_arg_option options[] = {
   {"skip", 's', 0, "skip offset bytes from the beginning of file.", 0,
@@ -34,52 +34,6 @@ static const struct grub_arg_option options[] = {
   {0, 0, 0, 0, 0, 0}
 };
 
-void
-hexdump (unsigned long bse, char *buf, int len)
-{
-  int pos;
-  char line[80];
-
-  while (len > 0)
-    {
-      int cnt, i;
-
-      pos = grub_sprintf (line, "%08lx  ", bse);
-      cnt = 16;
-      if (cnt > len)
-	cnt = len;
-
-      for (i = 0; i < cnt; i++)
-	{
-	  pos += grub_sprintf (&line[pos], "%02x ", (unsigned char) buf[i]);
-	  if ((i & 7) == 7)
-	    line[pos++] = ' ';
-	}
-
-      for (; i < 16; i++)
-	{
-	  pos += grub_sprintf (&line[pos], "   ");
-	  if ((i & 7) == 7)
-	    line[pos++] = ' ';
-	}
-
-      line[pos++] = '|';
-
-      for (i = 0; i < cnt; i++)
-	line[pos++] = ((buf[i] >= 32) && (buf[i] < 127)) ? buf[i] : '.';
-
-      line[pos++] = '|';
-
-      line[pos] = 0;
-
-      grub_printf ("%s\n", line);
-
-      bse += 16;
-      buf += 16;
-      len -= cnt;
-    }
-}
-
 static grub_err_t
 grub_cmd_hexdump (struct grub_arg_list *state, int argc, char **args)
 {
diff --git a/commands/loadenv.c b/commands/loadenv.c
index 7359683..4dbf1d9 100644
--- a/commands/loadenv.c
+++ b/commands/loadenv.c
@@ -25,8 +25,8 @@
 #include <grub/disk.h>
 #include <grub/misc.h>
 #include <grub/env.h>
-#include <grub/envblk.h>
 #include <grub/partition.h>
+#include <grub/lib/envblk.h>
 
 static const struct grub_arg_option options[] =
   {
diff --git a/conf/common.rmk b/conf/common.rmk
index c0087f5..7db0b2a 100644
--- a/conf/common.rmk
+++ b/conf/common.rmk
@@ -26,7 +26,7 @@ util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h
 grub_fstest_SOURCES = util/grub-fstest.c util/hostfs.c util/misc.c 	\
 	kern/file.c kern/device.c kern/disk.c kern/err.c kern/misc.c	\
 	disk/host.c disk/loopback.c  normal/arg.c normal/misc.c		\
-	io/gzio.c commands/hexdump.c commands/blocklist.c commands/ls.c \
+	io/gzio.c lib/hexdump.c commands/blocklist.c commands/ls.c \
 	\
 	fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c			\
 	fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c		\
@@ -96,7 +96,7 @@ DISTCLEANFILES += grub_fstest_init.c
 
 # for grub-editenv
 bin_UTILITIES += grub-editenv
-grub_editenv_SOURCES = util/grub-editenv.c util/envblk.c util/misc.c kern/misc.c kern/err.c
+grub_editenv_SOURCES = util/grub-editenv.c lib/envblk.c util/misc.c kern/misc.c kern/err.c
 CLEANFILES += grub-editenv
 
 # for grub-pe2elf
@@ -274,7 +274,7 @@ pkglib_MODULES += hello.mod boot.mod terminal.mod ls.mod	\
 	cmp.mod cat.mod help.mod font.mod search.mod		\
 	loopback.mod fs_uuid.mod configfile.mod echo.mod	\
 	terminfo.mod test.mod blocklist.mod hexdump.mod		\
-	read.mod sleep.mod loadenv.mod
+	read.mod sleep.mod loadenv.mod crc.mod
 
 # For hello.mod.
 hello_mod_SOURCES = hello/hello.c
@@ -357,7 +357,7 @@ blocklist_mod_CFLAGS = $(COMMON_CFLAGS)
 blocklist_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 # For hexdump.mod.
-hexdump_mod_SOURCES = commands/hexdump.c
+hexdump_mod_SOURCES = commands/hexdump.c lib/hexdump.c
 hexdump_mod_CFLAGS = $(COMMON_CFLAGS)
 hexdump_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
@@ -372,10 +372,15 @@ sleep_mod_CFLAGS = $(COMMON_CFLAGS)
 sleep_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 # For loadenv.mod.
-loadenv_mod_SOURCES = commands/loadenv.c util/envblk.c
+loadenv_mod_SOURCES = commands/loadenv.c lib/envblk.c
 loadenv_mod_CFLAGS = $(COMMON_CFLAGS)
 loadenv_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
+# For crc.mod.
+crc_mod_SOURCES = commands/crc.c lib/crc.c
+crc_mod_CFLAGS = $(COMMON_CFLAGS)
+crc_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
 # Misc.
 pkglib_MODULES += gzio.mod elf.mod
 
diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk
index d2546be..5b110d9 100644
--- a/conf/i386-coreboot.rmk
+++ b/conf/i386-coreboot.rmk
@@ -61,7 +61,7 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c	\
 	commands/configfile.c commands/echo.c commands/help.c		\
 	commands/terminal.c commands/ls.c commands/test.c 		\
 	commands/search.c commands/blocklist.c commands/hexdump.c	\
-	commands/i386/cpuid.c						\
+	lib/hexdump.c commands/i386/cpuid.c				\
 	disk/host.c disk/loopback.c					\
 	\
 	fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c			\
diff --git a/conf/i386-efi.rmk b/conf/i386-efi.rmk
index 99bb0d4..ea2f0b7 100644
--- a/conf/i386-efi.rmk
+++ b/conf/i386-efi.rmk
@@ -36,7 +36,7 @@ util/grub-emu.c_DEPENDENCIES = grub_emu_init.h
 grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c 	\
 	commands/configfile.c commands/help.c				\
 	commands/terminal.c commands/ls.c commands/test.c 		\
-	commands/search.c commands/hexdump.c				\
+	commands/search.c commands/hexdump.c lib/hexdump.c		\
 	commands/halt.c commands/reboot.c				\
 	commands/i386/cpuid.c						\
 	disk/loopback.c							\
@@ -74,7 +74,7 @@ sbin_SCRIPTS = grub-install
 grub_install_SOURCES = util/i386/efi/grub-install.in
 
 # Modules.
-pkglib_MODULES = kernel.mod normal.mod _chain.mod chain.mod appleldr.mod \
+pkglib_MODULES = kernel.mod normal.mod _chain.mod chain.mod bootcamp.mod \
 	_linux.mod linux.mod cpuid.mod halt.mod reboot.mod pci.mod lspci.mod
 
 # For kernel.mod.
@@ -123,10 +123,10 @@ chain_mod_SOURCES = loader/efi/chainloader_normal.c
 chain_mod_CFLAGS = $(COMMON_CFLAGS)
 chain_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
-# For appleldr.mod.
-appleldr_mod_SOURCES = loader/efi/appleloader.c
-appleldr_mod_CFLAGS = $(COMMON_CFLAGS)
-appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS)
+# For bootcamp.mod.
+bootcamp_mod_SOURCES = loader/efi/bootcamp.c
+bootcamp_mod_CFLAGS = $(COMMON_CFLAGS)
+bootcamp_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 # For _linux.mod.
 _linux_mod_SOURCES = loader/i386/efi/linux.c
diff --git a/conf/i386-ieee1275.rmk b/conf/i386-ieee1275.rmk
index e4f2a66..03827ae 100644
--- a/conf/i386-ieee1275.rmk
+++ b/conf/i386-ieee1275.rmk
@@ -62,7 +62,7 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c	\
 	commands/configfile.c commands/echo.c commands/help.c		\
 	commands/terminal.c commands/ls.c commands/test.c 		\
 	commands/search.c commands/blocklist.c commands/hexdump.c	\
-	commands/halt.c commands/reboot.c				\
+	lib/hexdump.c commands/halt.c commands/reboot.c			\
 	commands/i386/cpuid.c						\
 	disk/host.c disk/loopback.c					\
 	\
diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk
index 84c0b7d..8617a92 100644
--- a/conf/i386-pc.rmk
+++ b/conf/i386-pc.rmk
@@ -111,7 +111,7 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c	\
 	commands/configfile.c commands/echo.c commands/help.c		\
 	commands/terminal.c commands/ls.c commands/test.c 		\
 	commands/search.c commands/blocklist.c commands/hexdump.c	\
-	commands/i386/pc/halt.c commands/reboot.c			\
+	lib/hexdump.c commands/i386/pc/halt.c commands/reboot.c		\
 	commands/i386/cpuid.c						\
 	disk/host.c disk/loopback.c					\
 	fs/fshelp.c 	\
diff --git a/conf/powerpc-ieee1275.rmk b/conf/powerpc-ieee1275.rmk
index bb04490..6ade1ab 100644
--- a/conf/powerpc-ieee1275.rmk
+++ b/conf/powerpc-ieee1275.rmk
@@ -49,7 +49,7 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c 	\
 	commands/configfile.c commands/help.c				\
 	commands/search.c commands/terminal.c commands/test.c 		\
 	commands/ls.c commands/blocklist.c commands/hexdump.c		\
-	commands/halt.c commands/reboot.c		\
+	lib/hexdump.c commands/halt.c commands/reboot.c			\
 	disk/loopback.c							\
 	\
 	fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c		\
diff --git a/conf/x86_64-efi.rmk b/conf/x86_64-efi.rmk
index daa416c..493627e 100644
--- a/conf/x86_64-efi.rmk
+++ b/conf/x86_64-efi.rmk
@@ -38,7 +38,7 @@ util/grub-emu.c_DEPENDENCIES = grub_emu_init.h
 grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c 	\
 	commands/configfile.c commands/help.c				\
 	commands/terminal.c commands/ls.c commands/test.c 		\
-	commands/search.c commands/hexdump.c				\
+	commands/search.c commands/hexdump.c lib/hexdump.c		\
 	commands/halt.c commands/reboot.c				\
 	commands/i386/cpuid.c						\
 	disk/loopback.c							\
@@ -76,7 +76,7 @@ sbin_SCRIPTS = grub-install
 grub_install_SOURCES = util/i386/efi/grub-install.in
 
 # Modules.
-pkglib_MODULES = kernel.mod normal.mod _chain.mod chain.mod appleldr.mod \
+pkglib_MODULES = kernel.mod normal.mod _chain.mod chain.mod bootcamp.mod \
 	cpuid.mod halt.mod reboot.mod _linux.mod linux.mod pci.mod lspci.mod
 
 # For kernel.mod.
@@ -126,10 +126,10 @@ chain_mod_SOURCES = loader/efi/chainloader_normal.c
 chain_mod_CFLAGS = $(COMMON_CFLAGS)
 chain_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
-# For appleldr.mod.
-appleldr_mod_SOURCES = loader/efi/appleloader.c
-appleldr_mod_CFLAGS = $(COMMON_CFLAGS)
-appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS)
+# For bootcamp.mod.
+bootcamp_mod_SOURCES = loader/efi/bootcamp.c
+bootcamp_mod_CFLAGS = $(COMMON_CFLAGS)
+bootcamp_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 # For _linux.mod.
 _linux_mod_SOURCES = loader/i386/efi/linux.c
diff --git a/include/grub/envblk.h b/include/grub/envblk.h
deleted file mode 100644
index 5c1157e..0000000
--- a/include/grub/envblk.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2008  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 <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GRUB_ENVBLK_HEADER
-#define GRUB_ENVBLK_HEADER	1
-
-#define GRUB_ENVBLK_SIGNATURE	0x764e6547	/* GeNv  */
-
-#define GRUB_ENVBLK_MAXLEN	8192
-
-#define GRUB_ENVBLK_DEFCFG	"grubenv"
-
-#ifndef ASM_FILE
-
-struct grub_envblk
-{
-  grub_uint32_t signature;
-  grub_uint16_t length;
-  char data[0];
-} __attribute__ ((packed));
-typedef struct grub_envblk *grub_envblk_t;
-
-grub_envblk_t grub_envblk_find (char *buf);
-int grub_envblk_insert (grub_envblk_t envblk, char *name, char *value);
-void grub_envblk_delete (grub_envblk_t envblk, char *name);
-void grub_envblk_iterate (grub_envblk_t envblk, int hook (char *name, char *value));
-
-#endif
-
-#endif /* ! GRUB_ENVBLK_HEADER */
diff --git a/include/grub/hexdump.h b/include/grub/hexdump.h
deleted file mode 100644
index 23c6fa6..0000000
--- a/include/grub/hexdump.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* hexdump.h - prototypes for dump */
-/*
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2007  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 <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GRUB_HEXDUMP_H
-#define GRUB_HEXDUMP_H	1
-
-void hexdump (unsigned long bse,char* buf,int len);
-
-#endif /* ! GRUB_HEXDUMP_H */
diff --git a/include/grub/lib/crc.h b/include/grub/lib/crc.h
new file mode 100644
index 0000000..ff7284d
--- /dev/null
+++ b/include/grub/lib/crc.h
@@ -0,0 +1,25 @@
+/* crc.h - prototypes for crc */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2008  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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_CRC_H
+#define GRUB_CRC_H	1
+
+grub_uint32_t grub_getcrc32 (grub_uint32_t crc, void *buf, int size);
+
+#endif /* ! GRUB_CRC_H */
diff --git a/include/grub/lib/envblk.h b/include/grub/lib/envblk.h
new file mode 100644
index 0000000..5c1157e
--- /dev/null
+++ b/include/grub/lib/envblk.h
@@ -0,0 +1,45 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2008  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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_ENVBLK_HEADER
+#define GRUB_ENVBLK_HEADER	1
+
+#define GRUB_ENVBLK_SIGNATURE	0x764e6547	/* GeNv  */
+
+#define GRUB_ENVBLK_MAXLEN	8192
+
+#define GRUB_ENVBLK_DEFCFG	"grubenv"
+
+#ifndef ASM_FILE
+
+struct grub_envblk
+{
+  grub_uint32_t signature;
+  grub_uint16_t length;
+  char data[0];
+} __attribute__ ((packed));
+typedef struct grub_envblk *grub_envblk_t;
+
+grub_envblk_t grub_envblk_find (char *buf);
+int grub_envblk_insert (grub_envblk_t envblk, char *name, char *value);
+void grub_envblk_delete (grub_envblk_t envblk, char *name);
+void grub_envblk_iterate (grub_envblk_t envblk, int hook (char *name, char *value));
+
+#endif
+
+#endif /* ! GRUB_ENVBLK_HEADER */
diff --git a/include/grub/lib/hexdump.h b/include/grub/lib/hexdump.h
new file mode 100644
index 0000000..23c6fa6
--- /dev/null
+++ b/include/grub/lib/hexdump.h
@@ -0,0 +1,25 @@
+/* hexdump.h - prototypes for dump */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2007  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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_HEXDUMP_H
+#define GRUB_HEXDUMP_H	1
+
+void hexdump (unsigned long bse,char* buf,int len);
+
+#endif /* ! GRUB_HEXDUMP_H */
diff --git a/lib/crc.c b/lib/crc.c
new file mode 100644
index 0000000..bc0d8aa
--- /dev/null
+++ b/lib/crc.c
@@ -0,0 +1,75 @@
+/* crc.c - crc function  */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2008  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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/lib/crc.h>
+
+static grub_uint32_t crc32_table [256];
+
+static void
+init_crc32_table (void)
+{
+  auto grub_uint32_t reflect (grub_uint32_t ref, int len);
+  grub_uint32_t reflect (grub_uint32_t ref, int len)
+    {
+      grub_uint32_t result = 0;
+      int i;
+
+      for (i = 1; i <= len; i++)
+        {
+          if (ref & 1)
+            result |= 1 << (len - i);
+          ref >>= 1;
+        }
+
+      return result;
+    }
+
+  grub_uint32_t polynomial = 0x04c11db7;
+  int i, j;
+
+  for(i = 0; i < 256; i++)
+    {
+      crc32_table[i] = reflect(i, 8) << 24;
+      for (j = 0; j < 8; j++)
+        crc32_table[i] = (crc32_table[i] << 1) ^
+            (crc32_table[i] & (1 << 31) ? polynomial : 0);
+      crc32_table[i] = reflect(crc32_table[i], 32);
+    }
+}
+
+grub_uint32_t
+grub_getcrc32 (grub_uint32_t crc, void *buf, int size)
+{
+  int i;
+  grub_uint8_t *data = buf;
+
+  if (! crc32_table[1])
+    init_crc32_table ();
+
+  crc^= 0xffffffff;
+
+  for (i = 0; i < size; i++)
+    {
+      crc = (crc >> 8) ^ crc32_table[(crc & 0xFF) ^ *data];
+      data++;
+    }
+
+  return crc ^ 0xffffffff;
+}
diff --git a/lib/envblk.c b/lib/envblk.c
new file mode 100644
index 0000000..6618d97
--- /dev/null
+++ b/lib/envblk.c
@@ -0,0 +1,156 @@
+/* envblk.c - Common function for environment block.  */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2008  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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/lib/envblk.h>
+
+grub_envblk_t
+grub_envblk_find (char *buf)
+{
+  grub_uint32_t *pd;
+  int len;
+
+  pd = (grub_uint32_t *) buf;
+
+  for (len = GRUB_ENVBLK_MAXLEN - 6; len > 0; len -= 4, pd++)
+    if (*pd == GRUB_ENVBLK_SIGNATURE)
+      {
+        grub_envblk_t p;
+
+        p = (grub_envblk_t) pd;
+        if (p->length <= len)
+          return p;
+      }
+
+  return 0;
+}
+
+int
+grub_envblk_insert (grub_envblk_t envblk, char *name, char *value)
+{
+  char *p, *pend;
+  char *found = 0;
+  int nl;
+
+  nl = grub_strlen (name);
+  p = envblk->data;
+  pend = p + envblk->length;
+
+  while (*p)
+    {
+      if ((! found) && (! grub_memcmp (name, p, nl)) && (p[nl] == '='))
+        found = p + nl + 1;
+
+      p += grub_strlen (p) + 1;
+      if (p >= pend)
+        return 1;
+    }
+
+  if (found)
+    {
+      int len1, len2;
+
+      len1 = grub_strlen (found);
+      len2 = grub_strlen (value);
+      if ((p - envblk->data) + 1 - len1 + len2 > envblk->length)
+        return 1;
+
+      grub_memcpy (found + len2 + 1, found + len1 + 1, (p - found) - len1);
+      grub_strcpy (found, value);
+    }
+  else
+    {
+      int len2 = grub_strlen (value);
+
+      if ((p - envblk->data) + nl + 1 + len2 + 2 > envblk->length)
+        return 1;
+
+      grub_strcpy (p, name);
+      p[nl] = '=';
+      grub_strcpy (p + nl + 1, value);
+      p[nl + 1 + len2 + 1] = 0;
+    }
+
+  return 0;
+}
+
+void
+grub_envblk_delete (grub_envblk_t envblk, char *name)
+{
+  char *p, *pend;
+  char *found = 0;
+  int nl;
+
+  nl = grub_strlen (name);
+  p = envblk->data;
+  pend = p + envblk->length;
+
+  while (*p)
+    {
+      if ((! found) && (! grub_memcmp (name, p, nl)) && (p[nl] == '='))
+        found = p;
+
+      p += grub_strlen (p) + 1;
+      if (p >= pend)
+        return;
+    }
+
+  if (found)
+    {
+      int len;
+
+      len = grub_strlen (found);
+      grub_memcpy (found, found + len + 1, (p - found) - len);
+    }
+}
+
+void
+grub_envblk_iterate (grub_envblk_t envblk,
+                     int hook (char *name, char *value))
+{
+  char *p, *pend;
+
+  p = envblk->data;
+  pend = p + envblk->length;
+
+  while (*p)
+    {
+      char *v;
+      int r;
+
+      v = grub_strchr (p, '=');
+      if (v)
+        {
+          *v = 0;
+          r = hook (p, v + 1);
+          *v = '=';
+        }
+      else
+        r = hook (p, "");
+
+      if (r)
+        break;
+
+      p += grub_strlen (p) + 1;
+      if (p >= pend)
+        break;
+    }
+}
diff --git a/lib/hexdump.c b/lib/hexdump.c
new file mode 100644
index 0000000..9b79f45
--- /dev/null
+++ b/lib/hexdump.c
@@ -0,0 +1,68 @@
+/* hexdump.c - hexdump function */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2008  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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/lib/hexdump.h>
+
+void
+hexdump (unsigned long bse, char *buf, int len)
+{
+  int pos;
+  char line[80];
+
+  while (len > 0)
+    {
+      int cnt, i;
+
+      pos = grub_sprintf (line, "%08lx  ", bse);
+      cnt = 16;
+      if (cnt > len)
+	cnt = len;
+
+      for (i = 0; i < cnt; i++)
+	{
+	  pos += grub_sprintf (&line[pos], "%02x ", (unsigned char) buf[i]);
+	  if ((i & 7) == 7)
+	    line[pos++] = ' ';
+	}
+
+      for (; i < 16; i++)
+	{
+	  pos += grub_sprintf (&line[pos], "   ");
+	  if ((i & 7) == 7)
+	    line[pos++] = ' ';
+	}
+
+      line[pos++] = '|';
+
+      for (i = 0; i < cnt; i++)
+	line[pos++] = ((buf[i] >= 32) && (buf[i] < 127)) ? buf[i] : '.';
+
+      line[pos++] = '|';
+
+      line[pos] = 0;
+
+      grub_printf ("%s\n", line);
+
+      bse += 16;
+      buf += 16;
+      len -= cnt;
+    }
+}
diff --git a/loader/efi/appleloader.c b/loader/efi/appleloader.c
deleted file mode 100644
index 910a13d..0000000
--- a/loader/efi/appleloader.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/* appleloader.c - apple legacy boot loader.  */
-/*
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2008  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 <http://www.gnu.org/licenses/>.
- */
-
-#include <grub/loader.h>
-#include <grub/err.h>
-#include <grub/mm.h>
-#include <grub/dl.h>
-#include <grub/misc.h>
-#include <grub/normal.h>
-#include <grub/efi/api.h>
-#include <grub/efi/efi.h>
-
-static grub_dl_t my_mod;
-
-static grub_efi_handle_t image_handle;
-static grub_efi_char16_t *cmdline;
-
-static grub_err_t
-grub_appleloader_unload (void)
-{
-  grub_efi_boot_services_t *b;
-
-  b = grub_efi_system_table->boot_services;
-  efi_call_1 (b->unload_image, image_handle);
-
-  grub_free (cmdline);
-  cmdline = 0;
-
-  grub_dl_unref (my_mod);
-  return GRUB_ERR_NONE;
-}
-
-static grub_err_t
-grub_appleloader_boot (void)
-{
-  grub_efi_boot_services_t *b;
-
-  b = grub_efi_system_table->boot_services;
-  efi_call_3 (b->start_image, image_handle, 0, 0);
-
-  grub_appleloader_unload ();
-
-  return grub_errno;
-}
-
-/* early 2006 Core Duo / Core Solo models  */
-static grub_uint8_t devpath_1[] =
-{
-  0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0xE0, 0xFF, 0x00, 0x00, 0x00, 0x00,
-  0xFF, 0xFF, 0xF9, 0xFF, 0x00, 0x00, 0x00, 0x00,
-  0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B,
-  0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B,
-  0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00,
-};
-
-/* mid-2006 Mac Pro (and probably other Core 2 models)  */
-static grub_uint8_t devpath_2[] =
-{
-  0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0xE0, 0xFF, 0x00, 0x00, 0x00, 0x00,
-  0xFF, 0xFF, 0xF7, 0xFF, 0x00, 0x00, 0x00, 0x00,
-  0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B,
-  0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B,
-  0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00,
-};
-
-/* mid-2007 MBP ("Santa Rosa" based models)  */
-static grub_uint8_t devpath_3[] =
-{
-  0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0xE0, 0xFF, 0x00, 0x00, 0x00, 0x00,
-  0xFF, 0xFF, 0xF8, 0xFF, 0x00, 0x00, 0x00, 0x00,
-  0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B,
-  0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B,
-  0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00,
-};
-
-/* early-2008 MBA  */
-static grub_uint8_t devpath_4[] =
-{
-  0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0xC0, 0xFF, 0x00, 0x00, 0x00, 0x00,
-  0xFF, 0xFF, 0xF8, 0xFF, 0x00, 0x00, 0x00, 0x00,
-  0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B,
-  0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B,
-  0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00,
-};
-
-struct devdata
-{
-  char *model;
-  grub_efi_device_path_t *devpath;
-};
-
-struct devdata devs[] =
-{
-  {"Core Duo/Solo", (grub_efi_device_path_t *) devpath_1},
-  {"Mac Pro", (grub_efi_device_path_t *) devpath_2},
-  {"MBP", (grub_efi_device_path_t *) devpath_3},
-  {"MBA", (grub_efi_device_path_t *) devpath_4},
-  {NULL, NULL},
-};
-
-static grub_err_t
-grub_cmd_appleloader (struct grub_arg_list *state __attribute__ ((unused)),
-                      int argc, char *argv[])
-{
-  grub_efi_boot_services_t *b;
-  grub_efi_loaded_image_t *loaded_image;
-  struct devdata *pdev;
-
-  grub_dl_ref (my_mod);
-
-  /* Initialize some global variables.  */
-  image_handle = 0;
-
-  b = grub_efi_system_table->boot_services;
-
-  for (pdev = devs ; pdev->devpath ; pdev++)
-    if (efi_call_6 (b->load_image, 0, grub_efi_image_handle, pdev->devpath,
-                    NULL, 0, &image_handle) == GRUB_EFI_SUCCESS)
-      break;
-
-  if (! pdev->devpath)
-    {
-      grub_error (GRUB_ERR_BAD_OS, "can't find model");
-      goto fail;
-    }
-
-  grub_printf ("Model : %s\n", pdev->model);
-
-  loaded_image = grub_efi_get_loaded_image (image_handle);
-  if (! loaded_image)
-    {
-      grub_error (GRUB_ERR_BAD_OS, "no loaded image available");
-      goto fail;
-    }
-
-  if (argc > 0)
-    {
-      int i, len;
-      grub_efi_char16_t *p16;
-
-      for (i = 0, len = 0; i < argc; i++)
-        len += grub_strlen (argv[i]) + 1;
-
-      len *= sizeof (grub_efi_char16_t);
-      cmdline = p16 = grub_malloc (len);
-      if (! cmdline)
-        goto fail;
-
-      for (i = 0; i < argc; i++)
-        {
-          char *p8;
-
-          p8 = argv[i];
-          while (*p8)
-            *(p16++) = *(p8++);
-
-          *(p16++) = ' ';
-        }
-      *(--p16) = 0;
-
-      loaded_image->load_options = cmdline;
-      loaded_image->load_options_size = len;
-    }
-
-  grub_loader_set (grub_appleloader_boot, grub_appleloader_unload, 0);
-
-  return 0;
-
- fail:
-
-  grub_dl_unref (my_mod);
-  return grub_errno;
-}
-
-GRUB_MOD_INIT(appleloader)
-{
-  grub_register_command ("appleloader", grub_cmd_appleloader,
-			 GRUB_COMMAND_FLAG_BOTH,
-			 "appleloader [OPTS]",
-			 "Boot legacy system.", 0);
-
-  my_mod = mod;
-}
-
-GRUB_MOD_FINI(appleloader)
-{
-  grub_unregister_command ("appleloader");
-}
diff --git a/loader/efi/bootcamp.c b/loader/efi/bootcamp.c
new file mode 100644
index 0000000..ccb4f9d
--- /dev/null
+++ b/loader/efi/bootcamp.c
@@ -0,0 +1,208 @@
+/* bootcamp.c - apple legacy boot loader.  */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2008  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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/loader.h>
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/normal.h>
+#include <grub/efi/api.h>
+#include <grub/efi/efi.h>
+
+static grub_dl_t my_mod;
+
+static grub_efi_handle_t image_handle;
+static grub_efi_char16_t *cmdline;
+
+static grub_err_t
+grub_bootcamp_unload (void)
+{
+  grub_efi_boot_services_t *b;
+
+  b = grub_efi_system_table->boot_services;
+  efi_call_1 (b->unload_image, image_handle);
+
+  grub_free (cmdline);
+  cmdline = 0;
+
+  grub_dl_unref (my_mod);
+  return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_bootcamp_boot (void)
+{
+  grub_efi_boot_services_t *b;
+
+  b = grub_efi_system_table->boot_services;
+  efi_call_3 (b->start_image, image_handle, 0, 0);
+
+  grub_bootcamp_unload ();
+
+  return grub_errno;
+}
+
+/* early 2006 Core Duo / Core Solo models  */
+static grub_uint8_t devpath_1[] =
+{
+  0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0xE0, 0xFF, 0x00, 0x00, 0x00, 0x00,
+  0xFF, 0xFF, 0xF9, 0xFF, 0x00, 0x00, 0x00, 0x00,
+  0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B,
+  0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B,
+  0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00,
+};
+
+/* mid-2006 Mac Pro (and probably other Core 2 models)  */
+static grub_uint8_t devpath_2[] =
+{
+  0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0xE0, 0xFF, 0x00, 0x00, 0x00, 0x00,
+  0xFF, 0xFF, 0xF7, 0xFF, 0x00, 0x00, 0x00, 0x00,
+  0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B,
+  0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B,
+  0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00,
+};
+
+/* mid-2007 MBP ("Santa Rosa" based models)  */
+static grub_uint8_t devpath_3[] =
+{
+  0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0xE0, 0xFF, 0x00, 0x00, 0x00, 0x00,
+  0xFF, 0xFF, 0xF8, 0xFF, 0x00, 0x00, 0x00, 0x00,
+  0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B,
+  0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B,
+  0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00,
+};
+
+/* early-2008 MBA  */
+static grub_uint8_t devpath_4[] =
+{
+  0x01, 0x03, 0x18, 0x00, 0x0B, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0xC0, 0xFF, 0x00, 0x00, 0x00, 0x00,
+  0xFF, 0xFF, 0xF8, 0xFF, 0x00, 0x00, 0x00, 0x00,
+  0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B,
+  0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B,
+  0x01, 0xAE, 0xF2, 0xB7, 0x7F, 0xFF, 0x04, 0x00,
+};
+
+struct devdata
+{
+  char *model;
+  grub_efi_device_path_t *devpath;
+};
+
+struct devdata devs[] =
+{
+  {"Core Duo/Solo", (grub_efi_device_path_t *) devpath_1},
+  {"Mac Pro", (grub_efi_device_path_t *) devpath_2},
+  {"MBP", (grub_efi_device_path_t *) devpath_3},
+  {"MBA", (grub_efi_device_path_t *) devpath_4},
+  {NULL, NULL},
+};
+
+static grub_err_t
+grub_cmd_bootcamp (struct grub_arg_list *state __attribute__ ((unused)),
+                   int argc, char *argv[])
+{
+  grub_efi_boot_services_t *b;
+  grub_efi_loaded_image_t *loaded_image;
+  struct devdata *pdev;
+
+  grub_dl_ref (my_mod);
+
+  /* Initialize some global variables.  */
+  image_handle = 0;
+
+  b = grub_efi_system_table->boot_services;
+
+  for (pdev = devs ; pdev->devpath ; pdev++)
+    if (efi_call_6 (b->load_image, 0, grub_efi_image_handle, pdev->devpath,
+                    NULL, 0, &image_handle) == GRUB_EFI_SUCCESS)
+      break;
+
+  if (! pdev->devpath)
+    {
+      grub_error (GRUB_ERR_BAD_OS, "can't find model");
+      goto fail;
+    }
+
+  grub_printf ("Model : %s\n", pdev->model);
+
+  loaded_image = grub_efi_get_loaded_image (image_handle);
+  if (! loaded_image)
+    {
+      grub_error (GRUB_ERR_BAD_OS, "no loaded image available");
+      goto fail;
+    }
+
+  if (argc > 0)
+    {
+      int i, len;
+      grub_efi_char16_t *p16;
+
+      for (i = 0, len = 0; i < argc; i++)
+        len += grub_strlen (argv[i]) + 1;
+
+      len *= sizeof (grub_efi_char16_t);
+      cmdline = p16 = grub_malloc (len);
+      if (! cmdline)
+        goto fail;
+
+      for (i = 0; i < argc; i++)
+        {
+          char *p8;
+
+          p8 = argv[i];
+          while (*p8)
+            *(p16++) = *(p8++);
+
+          *(p16++) = ' ';
+        }
+      *(--p16) = 0;
+
+      loaded_image->load_options = cmdline;
+      loaded_image->load_options_size = len;
+    }
+
+  grub_loader_set (grub_bootcamp_boot, grub_bootcamp_unload, 0);
+
+  return 0;
+
+ fail:
+
+  grub_dl_unref (my_mod);
+  return grub_errno;
+}
+
+GRUB_MOD_INIT(bootcamp)
+{
+  grub_register_command ("bootcamp", grub_cmd_bootcamp,
+			 GRUB_COMMAND_FLAG_BOTH,
+			 "bootcamp [OPTS]",
+			 "Boot legacy system.", 0);
+
+  my_mod = mod;
+}
+
+GRUB_MOD_FINI(bootcamp)
+{
+  grub_unregister_command ("bootcamp");
+}
diff --git a/util/envblk.c b/util/envblk.c
deleted file mode 100644
index 9cea7d6..0000000
--- a/util/envblk.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/* envblk.c - Common function for environment block.  */
-/*
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2008  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 <http://www.gnu.org/licenses/>.
- */
-
-#include <config.h>
-#include <grub/types.h>
-#include <grub/envblk.h>
-#include <grub/misc.h>
-
-grub_envblk_t
-grub_envblk_find (char *buf)
-{
-  grub_uint32_t *pd;
-  int len;
-
-  pd = (grub_uint32_t *) buf;
-
-  for (len = GRUB_ENVBLK_MAXLEN - 6; len > 0; len -= 4, pd++)
-    if (*pd == GRUB_ENVBLK_SIGNATURE)
-      {
-        grub_envblk_t p;
-
-        p = (grub_envblk_t) pd;
-        if (p->length <= len)
-          return p;
-      }
-
-  return 0;
-}
-
-int
-grub_envblk_insert (grub_envblk_t envblk, char *name, char *value)
-{
-  char *p, *pend;
-  char *found = 0;
-  int nl;
-
-  nl = grub_strlen (name);
-  p = envblk->data;
-  pend = p + envblk->length;
-
-  while (*p)
-    {
-      if ((! found) && (! grub_memcmp (name, p, nl)) && (p[nl] == '='))
-        found = p + nl + 1;
-
-      p += grub_strlen (p) + 1;
-      if (p >= pend)
-        return 1;
-    }
-
-  if (found)
-    {
-      int len1, len2;
-
-      len1 = grub_strlen (found);
-      len2 = grub_strlen (value);
-      if ((p - envblk->data) + 1 - len1 + len2 > envblk->length)
-        return 1;
-
-      grub_memcpy (found + len2 + 1, found + len1 + 1, (p - found) - len1);
-      grub_strcpy (found, value);
-    }
-  else
-    {
-      int len2 = grub_strlen (value);
-
-      if ((p - envblk->data) + nl + 1 + len2 + 2 > envblk->length)
-        return 1;
-
-      grub_strcpy (p, name);
-      p[nl] = '=';
-      grub_strcpy (p + nl + 1, value);
-      p[nl + 1 + len2 + 1] = 0;
-    }
-
-  return 0;
-}
-
-void
-grub_envblk_delete (grub_envblk_t envblk, char *name)
-{
-  char *p, *pend;
-  char *found = 0;
-  int nl;
-
-  nl = grub_strlen (name);
-  p = envblk->data;
-  pend = p + envblk->length;
-
-  while (*p)
-    {
-      if ((! found) && (! grub_memcmp (name, p, nl)) && (p[nl] == '='))
-        found = p;
-
-      p += grub_strlen (p) + 1;
-      if (p >= pend)
-        return;
-    }
-
-  if (found)
-    {
-      int len;
-
-      len = grub_strlen (found);
-      grub_memcpy (found, found + len + 1, (p - found) - len);
-    }
-}
-
-void
-grub_envblk_iterate (grub_envblk_t envblk,
-                     int hook (char *name, char *value))
-{
-  char *p, *pend;
-
-  p = envblk->data;
-  pend = p + envblk->length;
-
-  while (*p)
-    {
-      char *v;
-      int r;
-
-      v = grub_strchr (p, '=');
-      if (v)
-        {
-          *v = 0;
-          r = hook (p, v + 1);
-          *v = '=';
-        }
-      else
-        r = hook (p, "");
-
-      if (r)
-        break;
-
-      p += grub_strlen (p) + 1;
-      if (p >= pend)
-        break;
-    }
-}
diff --git a/util/grub-editenv.c b/util/grub-editenv.c
index 523e5c7..f53a9bb 100644
--- a/util/grub-editenv.c
+++ b/util/grub-editenv.c
@@ -20,8 +20,7 @@
 #include <config.h>
 #include <grub/types.h>
 #include <grub/util/misc.h>
-
-#include <grub/envblk.h>
+#include <grub/lib/envblk.h>
 
 #include <stdio.h>
 #include <unistd.h>
diff --git a/util/grub-fstest.c b/util/grub-fstest.c
index 3872ff1..35af6a5 100644
--- a/util/grub-fstest.c
+++ b/util/grub-fstest.c
@@ -29,7 +29,7 @@
 #include <grub/term.h>
 #include <grub/mm.h>
 #include <grub/normal.h>
-#include <grub/hexdump.h>
+#include <grub/lib/hexdump.h>
 
 #include <grub_fstest_init.h>
 
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to