* EFI disk probing problem
@ 2006-08-04 5:26 bibo,mao
2006-08-10 19:15 ` Yoshinori K. Okuji
0 siblings, 1 reply; 5+ messages in thread
From: bibo,mao @ 2006-08-04 5:26 UTC (permalink / raw)
To: grub-devel
hi,
My hard disk is MBR partition type, there is FAT partition in my logical
partition, bootloader grub.efi is in this partition. When grub efi
bootloader starts up, it cannot probe my hard disk. It is because that
parent device_path of current logical partition is extended partition, but
not my hard disk's device path.
Here I wrote one patch to solve this problem, I discarded the device
whose type is not GRUB_EFI_MEDIA_DEVICE_PATH_TYPE, added devices whose type
is GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE as hard-disk or cdrom disk.
Any suggestion is welcome:) I sent email to grub mailing list, but there
is no response, I do not know why.
thanks
bibo,mao
--- grub-1.94.org/disk/efi/efidisk.c 2006-05-01 05:09:37.000000000 +0800
+++ grub-1.94/disk/efi/efidisk.c 2006-07-26 13:00:09.000000000 +0800
@@ -87,6 +87,51 @@ find_last_device_path (const grub_efi_de
return p;
}
+static int compare_ancestor_path(const grub_efi_device_path_t *parent,
+ const grub_efi_device_path_t *dp2)
+{
+ if (! parent || ! dp2)
+ /* Return non-zero. */
+ return 1;
+
+ while (1){
+ grub_efi_uint8_t type1, type2;
+ grub_efi_uint8_t subtype1, subtype2;
+ grub_efi_uint16_t len1, len2;
+ int ret;
+
+ if (GRUB_EFI_END_ENTIRE_DEVICE_PATH(parent))
+ break;
+
+ type1 = GRUB_EFI_DEVICE_PATH_TYPE (parent);
+ type2 = GRUB_EFI_DEVICE_PATH_TYPE (dp2);
+
+ if (type1 != type2)
+ return (int) type2 - (int) type1;
+
+ subtype1 = GRUB_EFI_DEVICE_PATH_SUBTYPE (parent);
+ subtype2 = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp2);
+
+ if (subtype1 != subtype2)
+ return (int) subtype1 - (int) subtype2;
+
+ len1 = GRUB_EFI_DEVICE_PATH_LENGTH (parent);
+ len2 = GRUB_EFI_DEVICE_PATH_LENGTH (dp2);
+
+ if (len1 != len2)
+ return (int) len1 - (int) len2;
+
+ ret = grub_memcmp (parent, dp2, len1);
+ if (ret != 0)
+ return ret;
+
+ parent = (grub_efi_device_path_t *) ((char *) parent + len1);
+ dp2 = (grub_efi_device_path_t *) ((char *) dp2 + len2);
+ }
+
+ return 0;
+}
+
/* Compare device paths. */
static int
compare_device_paths (const grub_efi_device_path_t *dp1,
@@ -301,109 +346,34 @@ add_device (struct grub_efidisk_data **d
}
/* Name the devices. */
-static void
-name_devices (struct grub_efidisk_data *devices)
-{
- struct grub_efidisk_data *d;
-
- /* First, identify devices by media device paths. */
- for (d = devices; d; d = d->next)
- {
- grub_efi_device_path_t *dp;
+static void name_devices (struct grub_efidisk_data *devices){
+ struct grub_efidisk_data *d;
- dp = d->last_device_path;
- if (! dp)
- continue;
-
- if (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE)
- {
- int is_hard_drive = 0;
-
- switch (GRUB_EFI_DEVICE_PATH_SUBTYPE (dp))
- {
- case GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE:
- is_hard_drive = 1;
- /* Fall through by intention. */
- case GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE:
- {
- struct grub_efidisk_data *parent;
-
- parent = find_parent_device (devices, d);
- if (parent)
- {
- if (is_hard_drive)
- {
-#if 0
- grub_printf ("adding a hard drive by a partition: ");
- grub_print_device_path (parent->device_path);
-#endif
- add_device (&hd_devices, parent);
- }
- else
- {
-#if 0
- grub_printf ("adding a cdrom by a partition: ");
- grub_print_device_path (parent->device_path);
-#endif
- add_device (&cd_devices, parent);
- }
-
- /* Mark the parent as used. */
- parent->last_device_path = 0;
- }
- }
- /* Mark itself as used. */
- d->last_device_path = 0;
- break;
-
- default:
- /* For now, ignore the others. */
- break;
- }
- }
- }
-
- /* Let's see what can be added more. */
- for (d = devices; d; d = d->next)
- {
- grub_efi_device_path_t *dp;
- grub_efi_block_io_media_t *m;
-
- dp = d->last_device_path;
- if (! dp)
- continue;
-
- m = d->block_io->media;
- if (m->logical_partition)
- {
- /* Only one partition in a non-media device. Assume that this
- is a floppy drive. */
-#if 0
- grub_printf ("adding a floppy by guessing: ");
- grub_print_device_path (d->device_path);
-#endif
- add_device (&fd_devices, d);
- }
- else if (m->read_only && m->block_size > GRUB_DISK_SECTOR_SIZE)
- {
- /* This check is too heuristic, but assume that this is a
- CDROM drive. */
-#if 0
- grub_printf ("adding a cdrom by guessing: ");
- grub_print_device_path (d->device_path);
-#endif
- add_device (&cd_devices, d);
- }
- else
- {
- /* The default is a hard drive. */
-#if 0
- grub_printf ("adding a hard drive by guessing: ");
- grub_print_device_path (d->device_path);
-#endif
- add_device (&hd_devices, d);
+ /* Let's see what can be added more. */
+ for (d = devices; d; d = d->next){
+ grub_efi_device_path_t *dp;
+ grub_efi_block_io_media_t *m;
+
+ dp = d->last_device_path;
+ if (! dp)
+ continue;
+
+ m = d->block_io->media;
+
+ if (GRUB_EFI_DEVICE_PATH_TYPE(dp) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE){
+ if (m->read_only && m->block_size > GRUB_DISK_SECTOR_SIZE){
+ grub_printf("adding a cd by guessing\n");
+ add_device (&cd_devices, d);
+ } else{
+ grub_printf("adding a hd by guessing\n");
+ add_device (&hd_devices, d);
+ }
+ }
+ if (GRUB_EFI_DEVICE_PATH_TYPE(dp) == GRUB_EFI_ACPI_DEVICE_PATH_TYPE){
+ grub_printf ("adding a floppy by guessing\n");
+ add_device (&fd_devices, d);
+ }
}
- }
}
static void
@@ -751,7 +721,7 @@ grub_efidisk_get_device_name (grub_efi_h
struct grub_efidisk_data *d;
d = disk->data;
- if (compare_device_paths (d->device_path, dup_dp) == 0)
+ if (compare_ancestor_path(d->device_path, dp) == 0)
{
parent = disk;
return 1;
@@ -776,20 +746,7 @@ grub_efidisk_get_device_name (grub_efi_h
return 0;
}
- /* It is necessary to duplicate the device path so that GRUB
- can overwrite it. */
- dup_dp = duplicate_device_path (dp);
- if (! dup_dp)
- return 0;
-
- dup_ldp = find_last_device_path (dup_dp);
- dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
- dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
- dup_ldp->length[0] = sizeof (*dup_ldp);
- dup_ldp->length[1] = 0;
-
grub_efidisk_iterate (find_parent_disk);
- grub_free (dup_dp);
if (! parent)
return 0;
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: EFI disk probing problem 2006-08-04 5:26 EFI disk probing problem bibo,mao @ 2006-08-10 19:15 ` Yoshinori K. Okuji 2006-08-12 16:09 ` Johan Rydberg 0 siblings, 1 reply; 5+ messages in thread From: Yoshinori K. Okuji @ 2006-08-10 19:15 UTC (permalink / raw) To: The development of GRUB 2 On Friday 04 August 2006 07:26, bibo,mao wrote: > My hard disk is MBR partition type, there is FAT partition in my logical > partition, bootloader grub.efi is in this partition. When grub efi > bootloader starts up, it cannot probe my hard disk. It is because that > parent device_path of current logical partition is extended partition, but > not my hard disk's device path. I don't remember precisely, but I think I only added disk devices but not partition devices. On your system, don't disk devices as well as partition devices get enumerated? BTW, can you follow the GNU-style formatting rules? It is very difficult for me to read a different coding style. Thanks, Okuji ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: EFI disk probing problem 2006-08-10 19:15 ` Yoshinori K. Okuji @ 2006-08-12 16:09 ` Johan Rydberg 2006-08-15 12:21 ` Yoshinori K. Okuji 0 siblings, 1 reply; 5+ messages in thread From: Johan Rydberg @ 2006-08-12 16:09 UTC (permalink / raw) To: The development of GRUB 2 "Yoshinori K. Okuji" <okuji@enbug.org> writes: > I don't remember precisely, but I think I only added disk devices but not > partition devices. On your system, don't disk devices as well as partition > devices get enumerated? I'm not 100% sure about this, but I think EFI does not have to add a disk device node if there is only a single logical partition on the disk. ~j ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: EFI disk probing problem 2006-08-12 16:09 ` Johan Rydberg @ 2006-08-15 12:21 ` Yoshinori K. Okuji 2006-08-16 2:57 ` bibo,mao 0 siblings, 1 reply; 5+ messages in thread From: Yoshinori K. Okuji @ 2006-08-15 12:21 UTC (permalink / raw) To: The development of GRUB 2 On Saturday 12 August 2006 18:09, Johan Rydberg wrote: > "Yoshinori K. Okuji" <okuji@enbug.org> writes: > > I don't remember precisely, but I think I only added disk devices but not > > partition devices. On your system, don't disk devices as well as > > partition devices get enumerated? > > I'm not 100% sure about this, but I think EFI does not have to add a > disk device node if there is only a single logical partition on the > disk. Maybe you are right. I hope Mao will comment on this. Okuji ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: EFI disk probing problem 2006-08-15 12:21 ` Yoshinori K. Okuji @ 2006-08-16 2:57 ` bibo,mao 0 siblings, 0 replies; 5+ messages in thread From: bibo,mao @ 2006-08-16 2:57 UTC (permalink / raw) To: The development of GRUB 2 Hi, Sorry for late reply because of some other issues, here is my device mapping table, I describe it in tree format blk1 (floppy) blkA (BlockDevice cd-rom) blkB (BlockDevice harddisk) |----- blk2 (primary partition) |----- blk3 (primary partition) |----- blk4 (primary partition) |----- blk5 (extended partition) |-------- blk6 (logical partition) |-------- blk7 (logical partition) |-------- blk0 (logical partition) |-------- blk8 (logical partition) |-------- blk9 (logical partition) my harddisk is MBR partition type, blk0 is my grub FAT partition. EFI regards all partitions and disk node as block device, only that its type is different, parition block device's subtype is GRUB_EFI_MEDIA_DEVICE_PATH_TYPE, but disk nod is not, harddisk/cdrom nod type is GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE, floppy disk type is GRUB_EFI_ACPI_DEVICE_PATH_TYPE. In order to find root disk, current method is to find harddisk type device's parent device, parent device of block0 is blk5, so it will reagards blk5 as one block device. Actually it is only one extended partition. My patch discards all partition device(GRUB_EFI_MEDIA_DEVICE_PATH_TYPE). thanks bibo,mao blk1 :Floppy - Alias (null) Acpi(PNP0A03,0)/Pci(1F|0)/Acpi(PNP0604,0) blkA :BlockDevice - Alias (null) Acpi(PNP0A03,0)/Pci(1F|1)/Ata(Primary,Master) blkB :BlockDevice - Alias (null) Acpi(PNP0A03,0)/Pci(1F|2)/Ata(Primary,Master) blk2 :HardDisk - Alias (null) Acpi(PNP0A03,0)/Pci(1F|2)/Ata(Primary,Master)/HD(Part1,SigA3A3A3A3) blk3 :HardDisk - Alias (null) Acpi(PNP0A03,0)/Pci(1F|2)/Ata(Primary,Master)/HD(Part2,SigA3A3A3A3) blk4 :HardDisk - Alias (null) Acpi(PNP0A03,0)/Pci(1F|2)/Ata(Primary,Master)/HD(Part3,SigA3A3A3A3) blk5 :HardDisk - Alias (null) Acpi(PNP0A03,0)/Pci(1F|2)/Ata(Primary,Master)/HD(Part4,SigA3A3A3A3) blk6 :HardDisk - Alias (null) Acpi(PNP0A03,0)/Pci(1F|2)/Ata(Primary,Master)/HD(Part4,SigA3A3A3A3)/HD(Part1,Sig00000000) blk7 :HardDisk - Alias (null) Acpi(PNP0A03,0)/Pci(1F|2)/Ata(Primary,Master)/HD(Part4,SigA3A3A3A3)/HD(Part2,Sig00000000) blk0 :HardDisk - Alias hd31a4d fs0 Acpi(PNP0A03,0)/Pci(1F|2)/Ata(Primary,Master)/HD(Part4,SigA3A3A3A3)/HD(Part3,Sig00000000) blk8 :HardDisk - Alias (null) Acpi(PNP0A03,0)/Pci(1F|2)/Ata(Primary,Master)/HD(Part4,SigA3A3A3A3)/HD(Part4,Sig00000000) blk9 :HardDisk - Alias (null) Acpi(PNP0A03,0)/Pci(1F|2)/Ata(Primary,Master)/HD(Part4,SigA3A3A3A3)/HD(Part5,Sig00000000) Yoshinori K. Okuji wrote: > On Saturday 12 August 2006 18:09, Johan Rydberg wrote: > > "Yoshinori K. Okuji" <okuji@enbug.org> writes: > > > I don't remember precisely, but I think I only added disk devices > but not > > > partition devices. On your system, don't disk devices as well as > > > partition devices get enumerated? > > > > I'm not 100% sure about this, but I think EFI does not have to add a > > disk device node if there is only a single logical partition on the > > disk. > > Maybe you are right. I hope Mao will comment on this. > > Okuji > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-08-16 2:58 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2006-08-04 5:26 EFI disk probing problem bibo,mao 2006-08-10 19:15 ` Yoshinori K. Okuji 2006-08-12 16:09 ` Johan Rydberg 2006-08-15 12:21 ` Yoshinori K. Okuji 2006-08-16 2:57 ` bibo,mao
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.