Skip to content

Commit

Permalink
. 修正splashimage函数。issues #401
Browse files Browse the repository at this point in the history
  修正partnew函数。issues #402
  修正map函数的unmap功能。issues #403
  • Loading branch information
yaya committed Mar 29, 2023
1 parent 36f94df commit fa99f0f
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 26 deletions.
7 changes: 7 additions & 0 deletions ChangeLog_UEFI.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
更新说明:
2023-03-29 (yaya)
完善外部命令进度条。
改进ISO启动。
修正splashimage函数。issues #401
修正partnew函数。issues #402
修正map函数的unmap功能。issues #403

2023-03-19 (a1ive)
支持多行 initrd 命令
支持 cpio newc initrd
Expand Down
63 changes: 43 additions & 20 deletions stage2/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,8 @@ boot_func (char *arg, int flags)
map_to_svbus(grub4dos_self_address); //为svbus复制插槽
//不能释放,否则无法启动
//grub_efi_fini ();
if (!image_handle)
return 0;
printf_debug ("StartImage: %x\n", image_handle); //开始映射
status = efi_call_3 (b->start_image, image_handle, 0, NULL); //启动映像
printf_debug ("StartImage returned 0x%lx\n", (grub_size_t) status); //开始映射返回
Expand Down Expand Up @@ -1323,6 +1325,8 @@ chainloader_func (char *arg, int flags)
errnum = 0;
}
image_handle = grub_load_image (current_drive, EFI_REMOVABLE_MEDIA_FILE_NAME, 0, 0, &dev_handle); //虚拟磁盘启动
if (!image_handle)
goto failure_exec_format_0;
if (debug > 1)
{
grub_efi_loaded_image_t *image0 = grub_efi_get_loaded_image (image_handle); //通过映像句柄,获得加载映像
Expand Down Expand Up @@ -1371,6 +1375,8 @@ chainloader_func (char *arg, int flags)
}

image_handle = grub_load_image (current_drive, arg1, boot_image, filemax, &dev_handle);
if (!image_handle)
goto failure_exec_format_0;
grub_efi_loaded_image_t *image1 = grub_efi_get_loaded_image (image_handle); //通过映像句柄,获得加载映像
//UEFI固件已经设置了“image1->device_handle = d->handle”。他没有分区信息,启动不了某些bootmgfw.efi。必须在此填充对应分区的句柄。
// d = get_device_by_drive (current_drive,0);
Expand Down Expand Up @@ -6952,7 +6958,11 @@ add_part_data (int drive)
{
if (*next_partition_type == 0 || *next_partition_type == 5 || *next_partition_type == 0xf)
continue;

//如果分区已经存在,则跳过
p = get_partition_info (current_drive, *next_partition_partition); //2023-03-26
if (p && p->partition_start)
continue;

p = grub_zalloc (sizeof (*p)); //分配内存
if(! p) //如果分配内存失败
return;
Expand Down Expand Up @@ -6983,6 +6993,7 @@ add_part_data (int drive)
if (get_efi_device_boot_path (drive, 1))
{
part_data = get_partition_info (drive, part_data->partition);
if (part_data) //2023-03-26
part_data->partition_boot = 1;
}

Expand Down Expand Up @@ -7267,28 +7278,16 @@ struct drive_map_slot
if (drive != INITRD_DRIVE && in_range (p, drive)) //如果驱动器不是0x22及0x23,并且排列存在
{
df = get_device_by_drive (drive,0);
if (!df) //避免驱动器不存在时死机 2023-03-26
continue;
if (df->drive == drive && df->sector_count) //是映射驱动器
{
//卸载碎片插槽
if (df && df->fragment == 1) //有碎片
{
if (df->fragment == 1) //有碎片
unload_fragment_slot (drive);
#if 0
q = (struct fragment_map_slot *)&disk_fragment_map; //q=碎片映射插槽起始位置 *q=插槽尺寸 b6e0
filename = (char *)q + FRAGMENT_MAP_SLOT_SIZE; //碎片映射插槽终止位置
q = fragment_map_slot_find(q, drive); //q=from驱动器在碎片映射插槽起始位置
if (q) //0/1=没有找到驱动器/找到驱动器位置
{
void *start = filename - q->slot_len;
int len = q->slot_len;
grub_memmove (q, (char *)q + q->slot_len, filename - (char *)q - q->slot_len);
grub_memset (start, 0, len);
}
#endif
}
//卸载映射磁盘,卸载映射分区
uninstall (drive, df); //2023-03-28
}
//卸载映射磁盘,卸载映射分区
uninstall (drive, df);
}
}
#endif
Expand Down Expand Up @@ -9018,6 +9017,27 @@ partnew_func (char *arg, int flags)
if (! rawwrite (current_drive, 0, (unsigned long long)(grub_size_t)mbr))
return 0;

if (new_type == 0 && new_start == 0 && new_len == 0) //删除分区 2023-03-26
{
struct grub_part_data *p, *p_previous = 0;
for (p = partition_info; p; p_previous = p, p = p->next)
{
if (p->drive != current_drive || p->partition != current_partition)
continue;

if (p == partition_info) //首位
{
if (p->next == 0)
partition_info = 0;
else
partition_info = p->next;
}
else if (p_previous) //其他
p_previous->next = p->next;
}
}
else
add_part_data (current_drive); //使立即生效 2023-03-26
return 1;
}

Expand Down Expand Up @@ -11805,7 +11825,9 @@ graphicsmode_func (char *arg, int flags)

if (IMAGE_BUFFER)
grub_free (IMAGE_BUFFER);
IMAGE_BUFFER = grub_malloc (current_x_resolution * current_y_resolution * current_bytes_per_pixel);//应当在加载图像前设置
// IMAGE_BUFFER = grub_malloc (current_x_resolution * current_y_resolution * current_bytes_per_pixel);//应当在加载图像前设置
//可能info->pixels_per_scanline >= info->width 2023-03-26
IMAGE_BUFFER = grub_malloc (current_bytes_per_scanline * current_y_resolution);//应当在加载图像前设置
if (!JPG_FILE)
{
JPG_FILE = grub_malloc (0x8000);
Expand Down Expand Up @@ -11861,11 +11883,12 @@ struct builtin builtin_graphicsmode =
"graphicsmode",
graphicsmode_func,
BUILTIN_MENU | BUILTIN_CMDLINE | BUILTIN_SCRIPT | BUILTIN_HELP_LIST,
"graphicsmode [--info] [MODE] [-1 | RANGE_X_RESOLUTION]",
"graphicsmode [--info] [--test] [MODE] [-1 | RANGE_X_RESOLUTION]",
"Examples:\n"
"graphicsmode (display graphic information)\n"
"graphicsmode ;; set /A GMODE=%@retval% (get current mode)\n"
"graphicsmode --info (Returns the currently supported graphics mode)\n"
"graphicsmode --test (Test whether the specified graphics mode exists)\n"
"graphicsmode -1 (auto select mode)\n"
"graphicsmode -1 800 (switch to highest mode for 800 pixel width)\n"
"graphicsmode -1 100:1000 (The highest mode available in the range of x = 100-1000)"
Expand Down
18 changes: 15 additions & 3 deletions stage2/disk_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -3156,6 +3156,8 @@ partition_info_init (struct efidisk_data *devices)
for (d1 = devices; d1; d1 = d1->next)
{
d = get_device_by_drive (drive, 0);
if (!d) //如果设备=0, 错误 2023-03-26
return;
dp1 = grub_efi_get_device_path (d->device_handle); //获得设备路径
if (grub_efi_compare_device_paths (dp1, d1->device_path) == -1)
{
Expand All @@ -3171,6 +3173,7 @@ partition_info_init (struct efidisk_data *devices)
if (get_efi_device_boot_path (drive, 0))
{
part_data = get_partition_info (drive, part_data->partition);
if (part_data) //2023-03-26
part_data->partition_boot = 1;
}
}
Expand Down Expand Up @@ -3791,7 +3794,10 @@ vpart_install (int drive, struct grub_part_data *part) //安装虚拟分区
grub_efi_boot_services_t *b;
b = grub_efi_system_table->boot_services;
// int present;
struct grub_disk_data *d = get_device_by_drive(drive,0);
struct grub_disk_data *d;
d = get_device_by_drive(drive,0);
if (!d) //如果设备=0, 错误 2023-03-26
return GRUB_EFI_NOT_FOUND;
vpart = 0;
vpart = grub_zalloc (sizeof(grub_efivdisk_t));
if (vpart == 0)
Expand Down Expand Up @@ -3880,7 +3886,10 @@ vdisk_install (int drive, int partition) //安装虚拟磁盘(驱动器号)
grub_efi_handle_t *handle; //句柄
grub_efi_uintn_t count0 = 0, count1 = 0;
struct grub_part_data *p = 0;
struct grub_disk_data *d = get_device_by_drive(drive,0); //由驱动器号获得设备
struct grub_disk_data *d;
d = get_device_by_drive(drive,0); //由驱动器号获得设备
if (!d) //如果设备=0, 错误 2023-03-26
return GRUB_EFI_NOT_FOUND;
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
vdisk = 0;
Expand Down Expand Up @@ -4153,7 +4162,10 @@ grub_load_image (unsigned int drive, const char *filename, void *boot_image, uns
if (drive >= 0xa0)
{
//windows启动cdrom时,只启动第一个cdrom,因此如果有多个cdrom,必须把要启动的cdrom移动到第一位。
struct grub_disk_data *d = get_device_by_drive (drive,0);
struct grub_disk_data *d;
d = get_device_by_drive (drive,0);
if (!d) //如果设备=0, 错误 2023-03-26
return NULL;
saved_handle = d->device_handle; //不能使用“*devhandle”。启动WePE_64_V2.2.iso时错误提示:0xc000000f。可能对应的块IO驱动不对。
if (!orig_locate_handle)
{
Expand Down
12 changes: 9 additions & 3 deletions stage2/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,12 +623,17 @@ void vbe_fill_color (unsigned int color);
void
vbe_fill_color (unsigned int color)
{
unsigned int i;
// unsigned int i;
unsigned int x, y;
unsigned char *p;

for (i=0;i<(current_x_resolution*current_y_resolution);i++)
// for (i=0;i<(current_x_resolution*current_y_resolution);i++)
for(y=0;y<current_y_resolution;++y)
{
for(x=0;x<current_x_resolution;++x)
{
p = (unsigned char *)IMAGE_BUFFER + 16 + i*current_bytes_per_pixel;
// p = (unsigned char *)IMAGE_BUFFER + 16 + i*current_bytes_per_pixel;
p = (unsigned char *)IMAGE_BUFFER + 16 + x*current_bytes_per_pixel + y*current_bytes_per_scanline;
switch (current_bits_per_pixel)
{
case 32:
Expand All @@ -643,6 +648,7 @@ vbe_fill_color (unsigned int color)
break;
}
}
}
}


Expand Down

0 comments on commit fa99f0f

Please sign in to comment.