On Oct 8, 2012, at 7:18 AM, Michael Lorer wrote:
> Hello Andrew,
>
> I have to correct myself. I mixed something up.
> I was able to find the GPT UniquePartitionGUID as part of the DevicePath.
> But I have to look for the Partition TYPE GUID and Attribute in
> GPT_PARTITION_ENTRY.
>
> But I’m just not able to build a correct ReadBlock()-Command to get the
> correct data.
> Any hints on that?
>
Look at the example code in the Partition driver.
> Thanks,
> Michael
>
> Von: Andrew Fish [mailto:af...@apple.com]
> Gesendet: Freitag, 5. Oktober 2012 16:51
> An: edk2-devel@lists.sourceforge.net
> Betreff: Re: [edk2] Get the GUIDs of all partitions out of the GPT
>
> What information are you trying to get? The GPT UniquePartitionGUID is
> discoverable from the DevicePath.
>
> The partition driver has created BlockIo protocol instances for each
> partition. So LBA 0 is the first LBA of the partition that start at LBA N on
> the disk. If you are looking for that BlockIo instance then you should be
> searching the device paths. That would be change your gBS->HandleProtocol
> (Handle[i], &gEfiBlockIoProtocolGuid, &BlockIo) over to
> gEfiDevicePathProtocolGuid and search the devices path for the
> UniquePartitionGUID.
>
> If you need to discover if a drive contains GPT and read the GPT header you
> should look at the algorithm in the partition driver. You can not assume that
> a BlockIo device contains GPT, it could be MBR, FAT, ISO-9660, ... A robust
> detection is a non trivial chunk of code, so you are better off using the
> device path if all you need to do is match GPT UniquePartitionGUID.
>
> Andrew Fish
>
> https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c
>
> This is the code in the PartitionDriver, for GPT, that is building the device
> path node that will get appended to the physical BlockIo devices device path.
> This device path is placed on the handle that contains the BlockIo instance
> for the partition.
>
> EFI_PARTITION_ENTRY *Entry;
> HARDDRIVE_DEVICE_PATH HdDev;
> ZeroMem (&HdDev, sizeof (HdDev));
> HdDev.Header.Type = MEDIA_DEVICE_PATH;
> HdDev.Header.SubType = MEDIA_HARDDRIVE_DP;
> SetDevicePathNodeLength (&HdDev.Header, sizeof (HdDev));
>
> HdDev.PartitionNumber = (UINT32) Index + 1;
> HdDev.MBRType = MBR_TYPE_EFI_PARTITION_TABLE_HEADER;
> HdDev.SignatureType = SIGNATURE_TYPE_GUID;
> HdDev.PartitionStart = Entry->StartingLBA;
> HdDev.PartitionSize = Entry->EndingLBA - Entry->StartingLBA + 1;
> CopyMem (HdDev.Signature, &Entry->UniquePartitionGUID, sizeof (EFI_GUID));
>
>
>
> On Oct 5, 2012, at 7:05 AM, Michael Lorer wrote:
>
>
> Hello,
>
> I’ve got a harddisk with a GPT and different partitions on it.
> Now I want to get the GUID of every partition (because I’m looking for a
> specific GUID).
>
> I tried it that way:
> // Get all BlockIO-protocols
> Status = gBS->LocateHandleBuffer(
> ByProtocol,
> &gEfiBlockIoProtocolGuid,
> NULL,
> &Count,
> &Handle);
>
> // Loop through it
> for( i=0; i<Count; i++ )
> {
> Status = gBS->HandleProtocol(Handle[i],
> &gEfiBlockIoProtocolGuid, &BlockIo);
>
> if (!BlockIo->Media->LogicalPartition)
> continue;
>
> Size=sizeof(GPT_HEADER);
> AdjustBufferSize(BlockIo, &Size);
>
> // Allocate memory to hold the data GPT header
> Status = gBS->AllocatePool(EfiBootServicesData, Size, &Gpt);
>
> // Read primary GPT
> BlockIo->ReadBlocks(BlockIo, BlockIo->Media->MediaId, 1,
> Size, Gpt);
>
> // Right now I should get a good value for
> Gpt->NumberOfPartitionEntries
> // but that is not the case.
> // In most cases Gpt->NumberOfPartitionEntries is empty and
> the only other value
> // is far too big to be the actual number of partitions
> // All other entries in the Gpt structure have the same
> disturbing values…
>
> }
>
> I had a look here:
> http://feishare.com/efimail/messages/20101023-0646-Re__edk2__Need_pointers_on_how_to_handle_GPT_disk_in_EDK2-Andrew_Fish.html
> And I think I’ve done it exactly as suggested. What am I missing?
>
> Thank you.
>
> Regards,
> Michael
> ------------------------------------------------------------------------------
> Don't let slow site performance ruin your business. Deploy New Relic APM
> Deploy New Relic app performance management and know exactly
> what is happening inside your Ruby, Python, PHP, Java, and .NET app
> Try New Relic at no cost today and get our sweet Data Nerd shirt too!
> http://p.sf.net/sfu/newrelic-dev2dev_______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>
> ------------------------------------------------------------------------------
> Don't let slow site performance ruin your business. Deploy New Relic APM
> Deploy New Relic app performance management and know exactly
> what is happening inside your Ruby, Python, PHP, Java, and .NET app
> Try New Relic at no cost today and get our sweet Data Nerd shirt too!
> http://p.sf.net/sfu/newrelic-dev2dev_______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel