|
我是这样改的。
主要是不想把处理模块方面的代码放在 disk_io.c 里面,感觉怪怪的。
- diff --git build build
- index 80b8e2d..e57201d 100755
- --- build
- +++ build
- @@ -136,13 +136,12 @@ make || exit $?
- #复制pre_stage2.exec
- mkdir $GRUB4DOS_TEMP/x86_64-efi
- cp stage2/pre_stage2.exec $GRUB4DOS_TEMP/x86_64-efi/kernel.img
- -cp $SOURCE_DIR/moddep.lst $GRUB4DOS_TEMP/x86_64-efi/moddep.lst
- platform=`uname -m`
- if [ $platform = 'x86_64' ]
- then
- - $SOURCE_DIR/grub-mkimage64 -d $GRUB4DOS_TEMP/x86_64-efi -p /efi/grub -o BOOTX64.EFI -O x86_64-efi -c preset_menu.lst
- + $SOURCE_DIR/mkimage -d $GRUB4DOS_TEMP/x86_64-efi -p /efi/grub -o BOOTX64.EFI -O x86_64-efi -c preset_menu.lst
- else
- - $SOURCE_DIR/grub-mkimage -d $GRUB4DOS_TEMP/x86_64-efi -p /efi/grub -o BOOTX64.EFI -O x86_64-efi -c preset_menu.lst
- + $SOURCE_DIR/mkimage.i386 -d $GRUB4DOS_TEMP/x86_64-efi -p /efi/grub -o BOOTX64.EFI -O x86_64-efi -c preset_menu.lst
- fi
-
- #**********************************************
- @@ -159,12 +158,11 @@ make clean
- make || exit $?
- mkdir $GRUB4DOS_TEMP/i386-efi
- cp stage2/pre_stage2.exec $GRUB4DOS_TEMP/i386-efi/kernel.img
- -cp $SOURCE_DIR/moddep.lst $GRUB4DOS_TEMP/i386-efi/moddep.lst
- if [ $platform = 'x86_64' ]
- then
- - $SOURCE_DIR/grub-mkimage64 -d $GRUB4DOS_TEMP/i386-efi -p /efi/grub -o BOOTIA32.EFI -O i386-efi -c preset_menu.lst
- + $SOURCE_DIR/mkimage -d $GRUB4DOS_TEMP/i386-efi -p /efi/grub -o BOOTIA32.EFI -O i386-efi -c preset_menu.lst
- else
- - $SOURCE_DIR/grub-mkimage -d $GRUB4DOS_TEMP/i386-efi -p /efi/grub -o BOOTIA32.EFI -O i386-efi -c preset_menu.lst
- + $SOURCE_DIR/mkimage.i386 -d $GRUB4DOS_TEMP/i386-efi -p /efi/grub -o BOOTIA32.EFI -O i386-efi -c preset_menu.lst
- fi
-
- #转到源目录
- @@ -176,7 +174,7 @@ cd $SOURCE_DIR
- rm -f ${RELEASE}.zip ${RELEASE}.rar ${RELEASE}.tar.gz || exit $?
- if ! 7z a ${RELEASE}.7z ${GRUB4DOS_TEMP}/BOOTX64.EFI ${GRUB4DOS_TEMP}/BOOTIA32.EFI $SOURCE_DIR/ChangeLog_UEFI.txt \
- $SOURCE_DIR/menu.lst ${GRUB4DOS_TEMP}/Get_Source_of_This_Build.txt ${GRUB4DOS_TEMP}/grub4dos_${CURR_REVISION}.diff \
- - ${GRUB4DOS_TEMP}/i386-efi ${GRUB4DOS_TEMP}/x86_64-efi grub-mkimage.exe; then
- + ${GRUB4DOS_TEMP}/i386-efi ${GRUB4DOS_TEMP}/x86_64-efi mkimage.exe; then
- echo 7z failed. Continue with zip or tar...
- fi
-
- diff --git stage2/builtins.c stage2/builtins.c
- index 7c25f41..91f4593 100644
- --- stage2/builtins.c
- +++ stage2/builtins.c
- @@ -3562,12 +3562,54 @@ static struct builtin builtin_command =
- "--set-ext sets default extensions for executable files."
- };
-
- +static int insmod_embed (void)
- +{
- + struct grub_module_header *header = 0;
- + char *embed_mod = NULL;
- + grub_size_t embed_mod_size = 0;
- + char embed_mod_path[64];
- + FOR_MODULES (header)
- + {
- + if (header->type != OBJ_TYPE_MEMDISK)
- + continue;
- +
- + embed_mod_size = header->size - header->pad_size - sizeof (struct grub_module_header);
- + embed_mod = grub_malloc (embed_mod_size + 0x1ff);
- + if (!embed_mod)
- + return 0;
- +
- + embed_mod = (char *)(grub_size_t)(((unsigned long long)(grub_size_t)embed_mod + 0x1ff) & 0xfffffffffffffe00);
- + grub_memmove (embed_mod, (char *) header + sizeof (struct grub_module_header),
- + embed_mod_size);
- + grub_sprintf (embed_mod_path, "(md)0x%lx+0x%lx,0x%lx",
- + ((grub_size_t) embed_mod) >> 9, (embed_mod_size + 0x1ff) >> 9, embed_mod_size);
- +
- + /* load file.mod */
- + if (!GRUB_MOD_ADDR)
- + {
- + GRUB_MOD_ADDR = grub_malloc (0x100000); //模块缓存
- + mod_end = GRUB_MOD_ADDR;
- + }
- + struct exec_array *p_mod = (struct exec_array *) embed_mod;
- + //skip grub4dos moduld head.
- + if (strcmp(p_mod->name.sn,"\x05\x18\x05\x03\xBA\xA7\xBA\xBC") == 0)
- + ++p_mod;
- + while ((char *)p_mod < embed_mod + embed_mod_size && grub_mod_add (p_mod))
- + {
- + p_mod = (struct exec_array *)(p_mod->data + p_mod->len);
- + }
- + grub_free (embed_mod);
- + return 1;
- + }
- + return 0;
- +}
- +
- static int insmod_func(char *arg,int flags);
- static int insmod_func(char *arg,int flags)
- {
- errnum = 0;
- if (arg == NULL || *arg == '\0')
- - return 0;
- + return insmod_embed ();
- char *name = skip_to(1|SKIP_WITH_TERMINATE,arg);
-
- if (!GRUB_MOD_ADDR)
- @@ -10782,11 +10824,38 @@ ok:
- }
- if (!UNIFONT_START)
- {
- - //进入图形模式,加载袖珍字库,防止黑屏。这样也可以使防止加载精简中文字库(不包含英文字符)的问题。
- - grub_memmove ((char *)0x10000, mini_font_lzma, 820);
- - font_func ("(md)0x80+2", 1); //如果是gz压缩格式,要明确压缩文件尺寸,如:font_func ("(md)0x80+2,820", 1);
- + struct grub_module_header *header = 0;
- + char *embed_font = NULL;
- + grub_size_t embed_font_size = 0;
- + char embed_font_path[64];
- + FOR_MODULES (header)
- + {
- + if (header->type != OBJ_TYPE_FONT) //字体
- + continue;
- +
- + embed_font_size = header->size - header->pad_size - sizeof (struct grub_module_header);
- + embed_font = grub_malloc (embed_font_size + 0x1ff);
- + if (!embed_font)
- + break;
- +
- + embed_font = (char *)(grub_size_t)(((unsigned long long)(grub_size_t)embed_font + 0x1ff) & 0xfffffffffffffe00);
- + grub_memmove (embed_font, (char *) header + sizeof (struct grub_module_header),
- + embed_font_size);
- + break;
- + }
- + if (!embed_font)
- + {
- + embed_font = (char *)0x10000;
- + embed_font_size = 820;
- + //进入图形模式,加载袖珍字库,防止黑屏。这样也可以使防止加载精简中文字库(不包含英文字符)的问题。
- + grub_memmove ((char *)0x10000, mini_font_lzma, 820);
- + }
- + grub_sprintf (embed_font_path, "(md)0x%lx+0x%lx,0x%lx",
- + ((grub_size_t) embed_font) >> 9, (embed_font_size + 0x1ff) >> 9, embed_font_size);
- + font_func (embed_font_path, 1);
- + grub_free (embed_font);
- }
- -
- +
- return graphics_mode;
- bad_arg:
- errnum = ERR_BAD_ARGUMENT;
- diff --git stage2/disk_io.c stage2/disk_io.c
- index 311fe8c..a661b26 100644
- --- stage2/disk_io.c
- +++ stage2/disk_io.c
- @@ -4269,7 +4269,8 @@ grub_efidisk_init (void) //efidisk初始化
-
- //初始化变量空间
- run_line((char *)"set ?_BOOT=%@root%",1);
- - QUOTE_CHAR = '"';
- + QUOTE_CHAR = '"';
- + run_line ((char *) "insmod", 1);
- #if 0
- run_line((char *)"errorcheck off",1);
- if (!ret || i == 0xff)
- @@ -4277,5 +4278,6 @@ grub_efidisk_init (void) //efidisk初始化
- run_line((char *)"configfile /efi/grub/menu.lst",1);
- run_line((char *)"errorcheck on",1);
- #endif
- +
- cmain ();
- }
- diff --git stage2/shared.h stage2/shared.h
- index f4851c4..0d09ed9 100644
- --- stage2/shared.h
- +++ stage2/shared.h
- @@ -5304,24 +5304,22 @@ extern grub_efi_device_path_t *efi_file_path;
- extern grub_efi_handle_t efi_handle;
- extern void grub_machine_fini (void);
-
- -enum //对象类型
- -{
- - OBJ_TYPE_ELF, //ELF 00
- - OBJ_TYPE_MEMDISK, //内存盘 01
- - OBJ_TYPE_CONFIG, //配置 02
- - OBJ_TYPE_PREFIX, //前缀 03
- - OBJ_TYPE_PUBKEY, //公共密钥 04
- - OBJ_TYPE_DTB //数据传输总线 05
- -};
- +#define OBJ_TYPE_ELF 0x00 // 外部命令
- +#define OBJ_TYPE_MEMDISK 0x01 // MOD文件
- +#define OBJ_TYPE_CONFIG 0x02 // 配置菜单
- +#define OBJ_TYPE_PREFIX 0x03 // 前缀路径
- +#define OBJ_TYPE_FONT 0x04 // 字体
-
- -/* The module header. 模块标题*/
- +/* The module header. */
- struct grub_module_header
- {
- - /* The type of object. 对象的类型*/
- - grub_uint32_t type;
- - /* The size of object (including this header). 对象的大小(包括此标题)*/
- + /* The type of object. */
- + grub_uint16_t type;
- + /* real_size = size - sizeof (struct grub_module_header) - pad_size */
- + grub_uint16_t pad_size;
- + /* The size of object (including this header). */
- grub_uint32_t size;
- -};
- +} GRUB_PACKED;
-
- /* "gmim" (GRUB Module Info Magic). GRUB模块信息魔法 */
- #define GRUB_MODULE_MAGIC 0x676d696d
复制代码
|
|