David,

It is best to think about device attributes as advertised by the 
EFI_BLOCK_IO_MEDIA structure in the Block I/O Protocol.  Using the 
RemovableMedia, MediaPresent, ReadOnly, BlockSize, LastBlock, and 
LogicalPartition fields, you can determine if a device has the attributes of a 
Floppy, Optical Drive, or Hard Drive.


1)      Floppy: RemovableMedia = TRUE.  ReadOnly = FALSE.  LogicalPartition = 
FALSE.


2)      Optical Drive (CD/DVD/BD): RemovableMedia = TRUE.  ReadOnly = TRUE.  
LogicalPartition = FALSE.  If you want to distinguish CD from DVD from BD, then 
look at the size of the media by evaluating LastBlock * BlockSize.  However, 
this only works if media is present in the drive.  If the drive supports 
multiple formats, then you can only get the size of the current media.



3)      Hard Drive: RemovableMedia = FALSE.  ReadOnly = FALSE.  
LogicalPartition = FALSE.

typedef struct {
  ///
  /// The curent media Id. If the media changes, this value is changed.
  ///
  UINT32  MediaId;

  ///
  /// TRUE if the media is removable; otherwise, FALSE.
  ///
  BOOLEAN RemovableMedia;

  ///
  /// TRUE if there is a media currently present in the device;
  /// othersise, FALSE. THis field shows the media present status
  /// as of the most recent ReadBlocks() or WriteBlocks() call.
  ///
  BOOLEAN MediaPresent;

  ///
  /// TRUE if LBA 0 is the first block of a partition; otherwise
  /// FALSE. For media with only one partition this would be TRUE.
  ///
  BOOLEAN LogicalPartition;

  ///
  /// TRUE if the media is marked read-only otherwise, FALSE.
  /// This field shows the read-only status as of the most recent WriteBlocks 
() call.
  ///
  BOOLEAN ReadOnly;

  ///
  /// TRUE if the WriteBlock () function caches write data.
  ///
  BOOLEAN WriteCaching;

  ///
  /// The intrinsic block size of the device. If the media changes, then
  /// this field is updated.
  ///
  UINT32  BlockSize;

  ///
  /// Supplies the alignment requirement for any buffer to read or write 
block(s).
  ///
  UINT32  IoAlign;

  ///
  /// The last logical block address on the device.
  /// If the media changes, then this field is updated.
  ///
  EFI_LBA LastBlock;

  ///
  /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
  /// EFI_BLOCK_IO_PROTOCOL_REVISION2. Returns the first LBA is aligned to
  /// a physical block boundary.
  ///
  EFI_LBA LowestAlignedLba;

  ///
  /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
  /// EFI_BLOCK_IO_PROTOCOL_REVISION2. Returns the number of logical blocks
  /// per physical block.
  ///
  UINT32 LogicalBlocksPerPhysicalBlock;

  ///
  /// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
  /// EFI_BLOCK_IO_PROTOCOL_REVISION3. Returns the optimal transfer length
  /// granularity as a number of logical blocks.
  ///
  UINT32 OptimalTransferLengthGranularity;
} EFI_BLOCK_IO_MEDIA;

Best regards.

Mike

From: David F. [mailto:df7...@gmail.com]
Sent: Monday, February 11, 2013 10:08 AM
To: edk2-devel@lists.sourceforge.net
Subject: Re: [edk2] Device Type?

Hmm, but is the driver name in a fixed format that will indicate the device 
type?   Or am I going to be stuck having to do a bunch of if ata/atapi type 
device then send identify device command, if it's scsi, send inquiry, if usb, 
do that, if it's 1394, do something else, etc..   The basic IO to the device 
seems to be abstract as well as the scsi passthrough seems like it would be 
able to handle atapi, 1394, usb, and scsi devices (those all using scsi cdb's) 
for special commands.  But I'd really like/need to know the basic device type, 
is it tape, cd/dvd/bd type, hard drive (dasd) , floppy, some other type?  I may 
want to only handle a certain type in a certain way and not touch the others...

On Mon, Feb 11, 2013 at 9:46 AM, Andrew Fish 
<af...@apple.com<mailto:af...@apple.com>> wrote:

On Feb 9, 2013, at 11:51 AM, David F. 
<df7...@gmail.com<mailto:df7...@gmail.com>> wrote:

> Hi,
>
> I see lots of good information in device paths, I expected to see a "device 
> type" but don't??  So maybe in a block protocol of some type, but couldn't 
> find it.  How are you supposed to determine the device type in a generic way 
> - similar to scsi device types 0 = DASD (or hard drive), 5 = 
> cdrom/dvd/etc..., etc... ?  Is there some EFI_DEV_TYPE_PROTOCOL that can be 
> queried to get that (floppy, cd, hard drive, other block devices)?
>
The device path was intended as something that could be stored in NVRAM and be 
valid from boot to boot. So for example the PCI bus is not stored in the device 
path as it can change from boot to boot (just Dev/Func from the root). The 
device path is also used to communicate with the OS about what devices should 
be consoles or boot options. But the focus of the device path is a programatic 
path to talk to the device.

We decided to not be like legacy BIOS and try and make assumptions about the 
hardware in the system. So from a UI perspective there is the Component Name 
protocol that returns a Unicode string that describes the devices. This way 
technology can advance and the specification does not need to keep changing.

There is a chapter in UEFI specification about device paths and there is also 
info on component name. http://www.uefi.org/specs/

Thanks,

Andrew Fish

> TIA!!
>
>
> ------------------------------------------------------------------------------
> Free Next-Gen Firewall Hardware Offer
> Buy your Sophos next-gen firewall before the end March 2013
> and get the hardware for free! Learn more.
> http://p.sf.net/sfu/sophos-d2d-feb_______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net<mailto:edk2-devel@lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/edk2-devel


------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net<mailto:edk2-devel@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to