* How to properly get Simple File System Protocol on RAM Disk
@ 2023-04-24 19:08 Andy Falanga
0 siblings, 0 replies; only message in thread
From: Andy Falanga @ 2023-04-24 19:08 UTC (permalink / raw)
To: devel
[-- Attachment #1: Type: text/plain, Size: 3214 bytes --]
Hello to all,
I believe that I'm asking this question in the correct group. I asked this
on Stack Overflow too so I'm just posting that below. Since this is
straight text, please forgive the Markdown but hopefully it will help
separate things.
I have need to make a RAM Disk during the DXE phase of UEFI. Beginning in
version 2.6 of the UEFI spec, there is a RAM Disk protocol. I've
successfully used this to make a RAM Disk. This RAM Disk must also have a
FAT32 system on it.
I am building this FAT32 partition programmatically *before* I install the
RAM Disk. From reading the spec, it seems that *firmware* (i.e. black
magic), ".. automatically adds an EFI_DISK_IO_PROTOCOL to any
EFI_BLOCK_IO_PROTOCOL interface that is produced." (This is discussed [in
this paragraph](
https://uefi.org/specs/UEFI/2.10/13_Protocols_Media_Access.html#efi-disk-io-protocol).)
[Digging through the RAM Disk DXE driver](
https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c#L700),
it is the case that a BLOCK_IO_PROTOCOL is produced by firmware for any RAM
Disk that is instantiated.
So, from the spec, it would seem that *if a recognized file system format
is present on a supported block device or disk I/O device*, the firmware
should automatically associate the requisite protocols for this. This isn't
what is happening. Using QEMU to test my FW Volumes, when the UEFI Shell
starts, I have mappings for the block devices but no FS*n* mappings:
```
BLK1: Alias(s):
VirtualDisk(0x38B74018,0x3BB74017,0)
BLK2: Alias(s):
VirtualDisk(0x38B74018,0x3BB74017,0)/HD(1,GPT,CF0C3344-CAF3-46C5-A72B-920DFD878FB2,0x800,0x17000)
...
```
I am instantiating my RAM Disk with
``` c
EFI_STATUS
EFIAPI
RegisterMyRd()
{
EFI_STATUS stat;
EFI_RAM_DISK_PROTOCOL *pRdProto;
EFI_DEVICE_PATH_PROTOCOL *pRdPathProto;
/* There is a static EFI_PHYSICAL_ADDRESS *pRamDisk for this
compilation unit */
stat = gBS->LocateProtocol(
&gEfiRamDiskProtocolGuid,
NULL,
(VOID**)&pRdProto);
ASSERT_EFI_ERROR(stat);
stat = pRdProto->Register(
(UINT64)pRamDisk,
(UINT64)RAM_DISK_SIZE, /* a define for 1024 * 1024 * 48 */
&gEfiVirtualDiskGuid,
NULL,
&pRdPathProto);
ASSERT_EFI_ERROR(stat);
return stat;
}
```
So, my RAM Disk is made and the GUID Partition Table is even discovered.
There are BLOCK_IO_PROTOCOL(s) instantiated, but for some reason when the
Shell is invoked and the mappings are provided, [there aren't any File
System objects as expected](
https://github.com/tianocore/edk2/blob/master/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c#L1436).
Though a 48MiB RD is kinda small, using that very same sized "disk" to QEMU
works just fine, i.e. `qemu-system-x86_64 ... -hda my_disk.img` which
results in an `FS0:` mapping for the "disk" on the PCI bus.
Must I add an EFI_SIMPLE_FILE_SYSTEM_PROTOCOL onto the device handle for
the RAM Disk? Does that imply implementing my own functions for
`OpenVolume()` and then the many for `EFI_FILE_PROTOCOL`? My reading of the
spec suggests that it should "just happen" but since I'm not seeing this,
I'm missing something.
Thanks,
Andy
[-- Attachment #2: Type: text/html, Size: 3950 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-24 19:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-24 19:08 How to properly get Simple File System Protocol on RAM Disk Andy Falanga
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox