diff --git a/stage2/asm.S b/stage2/asm.S index 904131f..4dc9718 100644 --- a/stage2/asm.S +++ b/stage2/asm.S @@ -293,14 +293,24 @@ VARIABLE(iso_types) //byte VARIABLE(menu_tab) //0x8311 菜单标签 byte .byte 0 -//位2: 0/1=显示按键帮助/不显示按键帮助 04 -//位3: 0/1=侧边对齐/中心对齐 08 -//位4: 0/1=高亮项目背景短/满 10 -//位5: 0/1=英文/中文 20 -//位6: 0/1=左对齐/右对齐 40 -//位7: 0/1=打印版本信息/不打印版本信息 80 - .byte 0 //未使用 - .byte 0 //未使用 +/* +位2: 0/1=显示按键帮助/不显示按键帮助 04 +位3: 0/1=侧边对齐/中心对齐 08 +位4: 0/1=高亮项目背景短/满 10 +位5: 0/1=英文/中文 20 +位6: 0/1=左对齐/右对齐 40 +位7: 0/1=打印版本信息/不打印版本信息 80 +*/ + +VARIABLE(menu_tab_ext) //0x8312 菜单标签 byte + .byte 0 +/* +位0: 1=已在图形模式 01 +位1: 1=已加载背景图像 02 +位2: 1=已加载字库 04 +*/ + + .byte 0 //0x8313 未使用 VARIABLE(errnum) //0x8314 错误号 grub_error_t 64位是8字节? .long 0 @@ -625,7 +635,7 @@ VARIABLE(system_functions) //IMG(0x8300) .extent ABS(EXT_C(builtin_cmd)) //44 .extent ABS(EXT_C(get_datetime)) //45 .extent ABS(EXT_C(find_command)) //46 - .extent 0 //47 reserved + .extent 0 //47 reserved g4d是get_mmap_entry .extent ABS(EXT_C(grub_memalign)) //48 void * .extent ABS(EXT_C(grub_zalloc)) //49 void * .extent ABS(EXT_C(grub_malloc)) //50 void * diff --git a/stage2/builtins.c b/stage2/builtins.c index e740e9a..20bafba 100644 --- a/stage2/builtins.c +++ b/stage2/builtins.c @@ -148,7 +148,7 @@ unsigned long long initrd_start_sector; grub_efi_uint64_t part_addr; grub_efi_uint64_t part_size; grub_efi_uint32_t cd_boot_entry; -grub_efi_uint16_t cd_boot_start; +grub_efi_uint32_t cd_boot_start; grub_efi_uint32_t cd_boot_size; grub_efi_uint32_t cd_Image_part_start; grub_efi_uint32_t cd_Image_disk_size; @@ -1911,9 +1911,9 @@ configfile_func (char *arg, int flags) return sprintf(CMD_RUN_ON_EXIT,"\xEC configfile %.128s",arg); } char *new_config = config_file; +#if 0 if (*arg == 0 && *config_file) { -#if 0 if (pxe_restart_config == 0) { if (configfile_in_menu_init == 0) @@ -1925,10 +1925,8 @@ configfile_func (char *arg, int flags) saved_partition = install_partition; *saved_dir = 0; /* clear saved_dir */ arg = config_file; -#else - return 1; -#endif } +#endif if (grub_strlen(saved_dir) + grub_strlen(arg) + 20 >= (int)sizeof(chainloader_file_orig)) return ! (errnum = ERR_WONT_FIT); @@ -2851,6 +2849,7 @@ splashimage_func(char *arg, int flags) } fontx = backup_x; fonty = backup_y; + menu_tab_ext |= 2; return 1; } @@ -4728,6 +4727,9 @@ font_func (char *arg, int flags) } } grub_close(); + if (! valid_lines) // if no valid lines, + return valid_lines; + menu_tab_ext |= 4; //old_narrow_char_indicator = narrow_indicator; //#undef old_narrow_char_indicator @@ -11820,6 +11822,7 @@ graphicsmode_func (char *arg, int flags) //进入图形模式,加载袖珍字库,防止黑屏。这样也可以使防止加载精简中文字库(不包含英文字符)的问题。 grub_memmove ((char *)0x10000, mini_font_lzma, 820); font_func ("(md)0x80+2", 1); //如果是gz压缩格式,要明确压缩文件尺寸,如:font_func ("(md)0x80+2,820", 1); + menu_tab_ext &= 0xfb; } } @@ -11843,6 +11846,10 @@ graphicsmode_func (char *arg, int flags) } //else if (safe_parse_maxint (&arg, &tmp_graphicsmode)) #endif ok: + if (graphics_mode > 0xFF) + menu_tab_ext |= 1; + else + menu_tab_ext &= 0xfe; return graphics_mode; bad_arg: errnum = ERR_BAD_ARGUMENT; @@ -12959,6 +12966,7 @@ setmenu_func(char *arg, int flags) else if (grub_memcmp (arg, "--u", 3) == 0) { menu_tab = 0; + menu_tab_ext = 0; num_string = 0; DateTime_enable = 0; menu_font_spacing = 0; diff --git a/stage2/console.c b/stage2/console.c index 5d8ecca..7b1d0f1 100644 --- a/stage2/console.c +++ b/stage2/console.c @@ -359,6 +359,8 @@ grub_console_getkey (int flags) //控制台获得键 控制台终端输入-> DateTime_refresh(); if (ext_timer) (*ext_timer)(0,-1); + if (timeout_enable) + timeout_refresh(); if (!key) { diff --git a/stage2/disk_io.c b/stage2/disk_io.c index 1a4d2e7..a6e0431 100644 --- a/stage2/disk_io.c +++ b/stage2/disk_io.c @@ -3879,7 +3879,7 @@ vdisk_install (int drive, int partition) //安装虚拟磁盘(驱动器号) grub_efi_handle_t *handles; //句柄集 api返回 grub_efi_handle_t *handle; //句柄 grub_efi_uintn_t count0 = 0, count1 = 0; - struct grub_part_data *p; + struct grub_part_data *p = 0; struct grub_disk_data *d = get_device_by_drive(drive,0); //由驱动器号获得设备 grub_efi_guid_t dp_guid = GRUB_EFI_DEVICE_PATH_GUID; //设备路径GUID grub_efi_guid_t blk_io_guid = GRUB_EFI_BLOCK_IO_GUID; //块IO_GUID @@ -4030,6 +4030,8 @@ vdisk_install (int drive, int partition) //安装虚拟磁盘(驱动器号) } } + if (!p->part_handle) + return (errnum = 0x1234); //设置错误号>=MAX_ERR_NUM,不打印err_list[errnum],错误信息由相应程序处理。设置错误号,可以避免死机。 2023-03-15 return GRUB_EFI_SUCCESS; } diff --git a/stage2/graphics.c b/stage2/graphics.c index a8bea2b..461a964 100644 --- a/stage2/graphics.c +++ b/stage2/graphics.c @@ -1925,11 +1925,11 @@ void rectangle(int left, int top, int length, int width, int line) y = 0; z = current_bytes_per_pixel; lfb = (unsigned char *)(grub_size_t)(current_phys_base + top * current_bytes_per_scanline + left * z); + source = current_color_64bit & 0xffffffff; if (!length) goto vert; - source = current_color_64bit & 0xffffffff; for (i=0;i>16); + *(unsigned short *)(p+y) = *(unsigned short *)p = (unsigned short)source; + *(p+y+2) = *(p+2) = (unsigned char)(source>>16); } else if(z == 4) { - *(unsigned int *)(p+y) = *(unsigned int *)p = (unsigned int)current_color_64bit; + *(unsigned int *)(p+y) = *(unsigned int *)p = (unsigned int)source; } else - *(unsigned short *)(p+y) = *(unsigned short *)p = (unsigned short)pixel_shift((unsigned int)current_color_64bit); + *(unsigned short *)(p+y) = *(unsigned short *)p = (unsigned short)pixel_shift((unsigned int)source); p += current_bytes_per_scanline; } } diff --git a/stage2/shared.h b/stage2/shared.h index feeb6a9..2fc0f8b 100644 --- a/stage2/shared.h +++ b/stage2/shared.h @@ -1359,6 +1359,7 @@ extern int quit_print; extern struct linux_kernel_header *linux_header; extern unsigned char menu_tab; +extern unsigned char menu_tab_ext; extern unsigned char num_string; extern unsigned char menu_font_spacing; extern unsigned char menu_line_spacing; @@ -1882,6 +1883,8 @@ extern int show_menu; extern int silent_hiddenmenu; extern char *mbr; extern int grub_timeout; +extern unsigned char timeout_enable; +extern void timeout_refresh(void); extern char *wee_skip_to (char *cmdline, int flags); extern char *skip_to (int flags, char *cmdline); @@ -5818,7 +5821,7 @@ typedef struct grub_packed_guid grub_packed_guid_t; extern grub_packed_guid_t VDISK_GUID; extern grub_efi_uint32_t cd_boot_entry; -extern grub_efi_uint16_t cd_boot_start; +extern grub_efi_uint32_t cd_boot_start; extern grub_efi_uint32_t cd_boot_size; extern grub_efi_uint32_t cd_Image_part_start; extern grub_efi_uint32_t cd_Image_disk_size; diff --git a/stage2/stage2.c b/stage2/stage2.c index facbf48..8723ef1 100644 --- a/stage2/stage2.c +++ b/stage2/stage2.c @@ -819,6 +819,7 @@ clear_delay_display (int entryno) current_term->setcolorstate (COLOR_STATE_HELPTEXT); grub_timeout = -1; + timeout_enable = 0; fallback_entryno = -1; if (! (current_term->flags & TERM_DUMB)) gotoxy (MENU_BOX_E, MENU_BOX_Y + entryno); @@ -830,16 +831,29 @@ int new_menu; int new_hotkey; int color_counting; int password_x; +unsigned char timeout_enable = 0; +int time0 = 0, time1 = 0; static int fallbacked_entries; static int old_c; static int old_c_count; static int old_c_count_end; +void timeout_refresh(void); +void timeout_refresh(void) +{ + time0++; + if (time0 == 1000) + { + time0 = 0; + time1++; + } +} + static void run_menu (char *menu_entries, char *config_entries, /*int num_entries,*/ char *heap, int entryno); static void run_menu (char *menu_entries, char *config_entries, /*int num_entries,*/ char *heap, int entryno) { - int i, time1, time2 = -1, first_entry = 0; + int i, /*time1,*/ time2 = -1, first_entry = 0; unsigned short c; char *cur_entry = 0; char *pass_config = 0; @@ -885,8 +899,10 @@ run_menu (char *menu_entries, char *config_entries, /*int num_entries,*/ char *h if (! show_menu) { /* Get current time. */ - while ((time1 = getrtsecs ()) == 0xFF) - ; +// while ((time1 = getrtsecs ()) == 0xFF) +// ; + if (grub_timeout >= 0) + timeout_enable = 1; while (1) { @@ -916,18 +932,20 @@ run_menu (char *menu_entries, char *config_entries, /*int num_entries,*/ char *h } } grub_timeout = -1; + timeout_enable = 0; show_menu = 1; break; } /* If GRUB_TIMEOUT is expired, boot the default entry. */ if (grub_timeout >=0 - && (time1 = getrtsecs ()) != time2 +// && (time1 = getrtsecs ()) != time2 + && time1 != time2 /* && time1 != 0xFF */) { if (grub_timeout <= 0) { - grub_timeout = -1; +// grub_timeout = -1; goto boot_entry; } @@ -1093,7 +1111,9 @@ run_menu (char *menu_entries, char *config_entries, /*int num_entries,*/ char *h if (menu_init_script_file[0] != 0 ) command_func(menu_init_script_file,BUILTIN_MENU); /* XX using RT clock now, need to initialize value */ - while ((time1 = getrtsecs()) == 0xFF); +// while ((time1 = getrtsecs()) == 0xFF); + if (grub_timeout >= 0) + timeout_enable = 1; old_c = 0; old_c_count = 0; @@ -1105,11 +1125,13 @@ run_menu (char *menu_entries, char *config_entries, /*int num_entries,*/ char *h while (1) { /* Initialize to NULL just in case... */ - if (grub_timeout >= 0 && (time1 = getrtsecs()) != time2 /* && time1 != 0xFF */) +// if (grub_timeout >= 0 && (time1 = getrtsecs()) != time2 /* && time1 != 0xFF */) + if (grub_timeout >= 0 && time1 != time2 /* && time1 != 0xFF */) { if (grub_timeout <= 0) { grub_timeout = -1; + timeout_enable = 0; break; } @@ -1715,6 +1737,13 @@ run_menu (char *menu_entries, char *config_entries, /*int num_entries,*/ char *h /* Attempt to boot an entry. */ boot_entry: + grub_timeout = -1; + timeout_enable = 0; + if (ext_timer) + { + grub_free (ext_timer); + ext_timer = 0; + } setcursor (1); /* show cursor and disable splashimage */ animated_enable_backup = animated_enable; animated_enable = 0; @@ -1901,6 +1930,7 @@ reset (void) fallback_entryno = -1; fallback_entries[0] = -1; grub_timeout = -1; + timeout_enable = 0; menu_num_ctrl[0] = 0; }