Discussion:
[edk2] Memory mapped file system on RAM used by EDK shell
Daniel Moral
2011-07-08 16:28:32 UTC
Permalink
Hi!

I want to build a memory mapped file system in order to use it with EDK1 Shell. What I want is to create a temporal file system using the RAM memory
of my board in order to store there files downloaded from a tftp server without needing an external flash memory. Therefore I could use the files
I download in other applications.

I am a bit lost on how I could do this. Would it be possible to create a virtual drive using the RAM memory and "trick" the shell so it thinks it is
just another volume? Or should I think in other possibilities?

Thank you very much.

BR

Daniel
Cohen, Eugene
2011-07-08 16:43:39 UTC
Permalink
I would recommend creating a RamDisk UEFI driver that publishes the EFI_BLOCK_IO_PROTOCOL. When you implement the protocol you can target a locally allocated RAM buffer for servicing ReadBlocks and WriteBlocks requests. Once you have this you will need a way to format the volume (FAT) and then the shell will mount it as an fsX entry. I believe there are existing applications that do this like efifmt.efi.

From: Daniel Moral [mailto:***@ericsson.com]
Sent: Friday, July 08, 2011 10:29 AM
To: edk2-***@lists.sourceforge.net; efidevkit-***@lists.sourceforge.net
Subject: [edk] Memory mapped file system on RAM used by EDK shell

Hi!

I want to build a memory mapped file system in order to use it with EDK1 Shell. What I want is to create a temporal file system using the RAM memory
of my board in order to store there files downloaded from a tftp server without needing an external flash memory. Therefore I could use the files
I download in other applications.

I am a bit lost on how I could do this. Would it be possible to create a virtual drive using the RAM memory and "trick" the shell so it thinks it is
just another volume? Or should I think in other possibilities?

Thank you very much.

BR

Daniel
Andrew Fish
2011-07-08 17:08:00 UTC
Permalink
Daniel,

I think there is a RAM Disk driver in the toolkit.... It produces the Block IO protocol. The only problem is you have to format the Block IO partition to put a file system on it. There is an EFI application to do that. If the Block IO protocol abstracts blocks that contain a FAT file system then when you connect that handle the file system driver will bind and you will get a Simple File System Protocol that would show up at the shell prompt.

It would be possible to write a Simple File System Driver that just treated files as linked lists. I've never seen this done, but it is quite possible.

These two chunks work together to make Simple File System on top of ANSI C APIs:
https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EmulatorPkg/Unix/Host/PosixFileSystem.c

Maybe this would be a good GSOC project at some point.

Andrew Fish
Post by Daniel Moral
Hi!
I want to build a memory mapped file system in order to use it with EDK1 Shell. What I want is to create a temporal file system using the RAM memory
of my board in order to store there files downloaded from a tftp server without needing an external flash memory. Therefore I could use the files
I download in other applications.
I am a bit lost on how I could do this. Would it be possible to create a virtual drive using the RAM memory and "trick" the shell so it thinks it is
just another volume? Or should I think in other possibilities?
Thank you very much.
BR
Daniel
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2_______________________________________________
edk2-devel mailing list
https://lists.sourceforge.net/lists/listinfo/edk2-devel
Daniel Moral
2011-07-11 14:08:12 UTC
Permalink
Thanks both for your help.

Here is what I am doing. In the toolkit there is an application called mkramdisk which installs the ramdisk driver and you can specify the number of bytes, for example:

fs0:\> mkramdisk.efi -s 2000 f
Device mapping table
f :BlockDevice - Alias (null)
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
Done: RAM Disk [ f ] with size [ 2000MB ]

That creates a 2000MB ram disk called f. Nevertheless it appears to be some problem with the name cause I get:

fs0:\> map -r
Device mapping table
fs0 :BlockDevice - Alias f0agonennapphibbndlnmeaakamjeafdnb blk0
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
fs1 :Removeable BlockDevice - Alias f40c0 blk1
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)
blk0 :BlockDevice - Alias f0agonennapphibbndlnmeaakamjeafdnb fs0
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
blk1 :Removeable BlockDevice - Alias f40c0 fs1
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)
f0agonennapphibbndlnmeaakamjeafdnb :BlockDevice - Alias fs0 blk0
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
f40c0 :Removeable BlockDevice - Alias fs1 blk1
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)

Where f0agonen... is a strange name.

There is a set of tools called EFI Disk utilities which I employed to format: http://www.intel.com/technology/efi/diskutil_overview.htm

First I tried using efifmt.efi directly on the created device, but it did not work:

fs1:\> EFIFMT.EFI blk0
EfiFmt Version 1.2. Based on EFI Version 2.10
IFSUTIL: Can't open drive. Status returned = C0000001.
Cannot determine file system of drive blk0.
Unable to determine file system type.
Cannot open volume for direct access.

What I do is first create a partition in the disk and then format it this way:

fs1:\> DISKPART.EFI
DiskPart Version 1.2. Based on EFI Version 2.10
DiskPart> list
### BlkSize BlkCount
--- ------- ----------------
0 200 100000
DiskPart> select 0
Selected Disk = 0
DiskPart> clean all
About to CLEAN (DESTROY) disk 0, are you SURE [y/n]?
CLEAN>> y
If you are REALLY SURE, type '$C'
CLEAN>> $C
DiskPart> new gpt
DiskPart> create name=partition type=efisys size=2000
DiskPart> exit
Exiting....

fs1:\> map -r
Device mapping table
fs0 :Removeable BlockDevice - Alias f40c0 blk0
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)
blk0 :Removeable BlockDevice - Alias f40c0 fs0
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)
blk1 :HardDisk - Alias (null)
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)/HD(Part1,Sig301D7800-1DD2-1000-9620-001A4B6FDBCA)
blk2 :BlockDevice - Alias (null)
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
f40c0 :Removeable BlockDevice - Alias fs0 blk0


Shell> EFIFMT.EFI blk1 /FS:FAT32
EfiFmt Version 1.2. Based on EFI Version 2.10
WARNING, ALL DATA ON EFI DEVICE
blk1 WILL BE LOST!
Proceed with Format (Y/N)? y
Formatting 511M
Initializing the File Allocation Table (FAT)...
Volume label (11 characters, ENTER for none)? ramdisk
Format complete.
535769088 bytes total disk space.
535764992 bytes available on disk.
4096 bytes in each allocation unit.
130802 allocation units available on disk.

32 bits in each FAT entry.

Volume Serial Number is 000040B3-00004A89

Then everything goes fine I can read, write, mkdir etc.. on that volume and when using dblk the output seems correct:

Shell> dblk blk0

LBA 0000000000000000 Size 00000200 bytes BlkIo 01F14F18
00000000: EB 58 90 4D 53 44 4F 53-35 2E 30 00 02 08 26 00 *.X.MSDOS5.0...&.*
00000010: 02 00 00 00 00 F8 00 00-01 00 01 00 00 00 00 00 *................*
00000020: 00 00 79 00 31 1E 00 00-00 00 00 00 02 00 00 00 *..y.1...........*
00000030: 01 00 06 00 00 00 00 00-00 00 00 00 00 00 00 00 *................*
00000040: 00 00 29 27 7A 7B C4 4E-4F 20 4E 41 4D 45 20 20 *..)'z..NO NAME *
00000050: 20 20 46 41 54 33 32 20-20 20 33 C9 8E D1 BC F4 * FAT32 3.....*
00000060: 7B 8E C1 8E D9 BD 00 7C-88 4E 02 8A 56 40 B4 08 ****@..*
00000070: CD 13 73 05 B9 FF FF 8A-F1 66 0F B6 C6 40 66 0F ****@f<mailto:****@f>.*
00000080: B6 D1 80 E2 3F F7 E2 86-CD C0 ED 06 41 66 0F B7 *....?.......Af..*
00000090: C9 66 F7 E1 66 89 46 F8-83 7E 16 00 75 38 83 7E *.f..f.F.....u8..*
000000A0: 2A 00 77 32 66 8B 46 1C-66 83 C0 0C BB 00 80 B9 **.w2f.F.f.......*
000000B0: 01 00 E8 2B 00 E9 48 03-A0 FA 7D B4 7D 8B F0 AC *...+..H.........*
000000C0: 84 C0 74 17 3C FF 74 09-B4 0E BB 07 00 CD 10 EB *..t.<.t.........*
000000D0: EE A0 FB 7D EB E5 A0 F9-7D EB E0 98 CD 16 CD 19 *................*
000000E0: 66 60 66 3B 46 F8 0F 82-4A 00 66 6A 00 66 50 06 *f`f;F...J.fj.fP.*
000000F0: 53 66 68 10 00 01 00 80-7E 02 00 0F 85 20 00 B4 *Sfh.......... ..*
00000100: 41 BB AA 55 8A 56 40 CD-13 0F 82 1C 00 81 FB 55 ****@........U<mailto:****@........U>*
00000110: AA 0F 85 14 00 F6 C1 01-0F 84 0D 00 FE 46 02 B4 *.............F..*
00000120: 42 8A 56 40 8B F4 CD 13-B0 F9 66 58 66 58 66 58 ****@......fXfXfX<mailto:****@......fXfXfX>*
00000130: 66 58 EB 2A 66 33 D2 66-0F B7 4E 18 66 F7 F1 FE *fX.*f3.f..N.f...*
00000140: C2 8A CA 66 8B D0 66 C1-EA 10 F7 76 1A 86 D6 8A *...f..f....v....*
00000150: 56 40 8A E8 C0 E4 06 0A-CC B8 01 02 CD 13 66 61 ****@............fa<mailto:****@............fa>*
00000160: 0F 82 54 FF 81 C3 00 02-66 40 49 0F 85 71 FF C3 ****@I..q<mailto:****@I..q>..*
00000170: 4E 54 4C 44 52 20 20 20-20 20 20 00 00 00 00 00 *NTLDR .....*
00000180: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 *................*
00000190: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 *................*
000001A0: 00 00 00 00 00 00 00 00-00 00 00 00 0D 0A 4E 54 *..............NT*
000001B0: 4C 44 52 20 69 73 20 6D-69 73 73 69 6E 67 FF 0D *LDR is missing..*
000001C0: 0A 44 69 73 6B 20 65 72-72 6F 72 FF 0D 0A 50 72 *.Disk error...Pr*
000001D0: 65 73 73 20 61 6E 79 20-6B 65 79 20 74 6F 20 72 *ess any key to r*
000001E0: 65 73 74 61 72 74 0D 0A-00 00 00 00 00 00 00 00 *estart..........*
000001F0: 00 00 00 00 00 00 00 00-00 AC BF CC 00 00 55 AA *..............U.*


But there is something that I do not understand. Why if I am reserving 2000MB when I format it it only recognizes 511MB?

Formatting 511M
I tried several times but I only got it to recognize the 511MB.

Thank you very much for your help again :)

BR

Daniel

________________________________
From: Andrew Fish [mailto:***@apple.com]
Sent: den 8 juli 2011 19:08
To: edk2-***@lists.sourceforge.net
Cc: efidevkit-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell

Daniel,

I think there is a RAM Disk driver in the toolkit.... It produces the Block IO protocol. The only problem is you have to format the Block IO partition to put a file system on it. There is an EFI application to do that. If the Block IO protocol abstracts blocks that contain a FAT file system then when you connect that handle the file system driver will bind and you will get a Simple File System Protocol that would show up at the shell prompt.

It would be possible to write a Simple File System Driver that just treated files as linked lists. I've never seen this done, but it is quite possible.

These two chunks work together to make Simple File System on top of ANSI C APIs:
https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EmulatorPkg/Unix/Host/PosixFileSystem.c

Maybe this would be a good GSOC project at some point.

Andrew Fish





On Jul 8, 2011, at 9:28 AM, Daniel Moral wrote:

Hi!

I want to build a memory mapped file system in order to use it with EDK1 Shell. What I want is to create a temporal file system using the RAM memory
of my board in order to store there files downloaded from a tftp server without needing an external flash memory. Therefore I could use the files
I download in other applications.

I am a bit lost on how I could do this. Would it be possible to create a virtual drive using the RAM memory and "trick" the shell so it thinks it is
just another volume? Or should I think in other possibilities?

Thank you very much.

BR

Daniel

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2_______________________________________________
edk2-devel mailing list
edk2-***@lists.sourceforge.net<mailto:edk2-***@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/edk2-devel
Daniel Moral
2011-07-11 16:27:30 UTC
Permalink
I have found that the problem is not on efifmt.efi. I have this memory map:


reserved : 47 Pages (192,512)
LoaderCode: 120 Pages (491,520)
LoaderData: 278 Pages (1,138,688)
BS_code : 723 Pages (2,961,408)
BS_data : 4,845 Pages (19,845,120)
RT_code : 74 Pages (303,104)
RT_data : 44 Pages (180,224)
available : 515,343 Pages (2,110,844,928)
ACPI_recl : 11 Pages (45,056)
ACPI_NVS : 659 Pages (2,699,264)
MemMapIO : 69,636 Pages (285,229,056)
Total Memory: 2,039 MB (2,138,509,312) Bytes

Which means more or less 2000MB free then I do:

fs0:\> mkramdisk.efi -s 2000 l
Device mapping table
l :BlockDevice - Alias (null)
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
Done: RAM Disk [ l ] with size [ 2000MB ]

But when I do partition:

fs0:\> DISKPART.EFI
DiskPart Version 1.2. Based on EFI Version 2.10
DiskPart> list
### BlkSize BlkCount
--- ------- ----------------
0 200 100000
DiskPart> select 0
Selected Disk = 0
DiskPart> clean all
About to CLEAN (DESTROY) disk 0, are you SURE [y/n]?
CLEAN>> y
If you are REALLY SURE, type '$C'
CLEAN>> $C
DiskPart> new gpt
DiskPart> create name=partition type=efisys ver
CmdCreate arguments:
SelectedDisk = 0
Name=PARTITION
TypeGuid = C12A7328-F81F-11D2-BA4B-00A0C93EC93B
TypeName = EFISYS
Requested OffsetInBlocks = 0
Requested SizeInMegaBytes = 0
Attributes = 0
Requested SizeInMegaBytes = 0
Resulting size in Blocks = 1048509
Results size in Bytes = 536836608

Any idea?






________________________________
From: Daniel Moral [mailto:***@ericsson.com]
Sent: den 11 juli 2011 16:08
To: edk2-***@lists.sourceforge.net
Cc: efidevkit-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell

Thanks both for your help.

Here is what I am doing. In the toolkit there is an application called mkramdisk which installs the ramdisk driver and you can specify the number of bytes, for example:

fs0:\> mkramdisk.efi -s 2000 f
Device mapping table
f :BlockDevice - Alias (null)
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
Done: RAM Disk [ f ] with size [ 2000MB ]

That creates a 2000MB ram disk called f. Nevertheless it appears to be some problem with the name cause I get:

fs0:\> map -r
Device mapping table
fs0 :BlockDevice - Alias f0agonennapphibbndlnmeaakamjeafdnb blk0
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
fs1 :Removeable BlockDevice - Alias f40c0 blk1
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)
blk0 :BlockDevice - Alias f0agonennapphibbndlnmeaakamjeafdnb fs0
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
blk1 :Removeable BlockDevice - Alias f40c0 fs1
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)
f0agonennapphibbndlnmeaakamjeafdnb :BlockDevice - Alias fs0 blk0
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
f40c0 :Removeable BlockDevice - Alias fs1 blk1
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)

Where f0agonen... is a strange name.

There is a set of tools called EFI Disk utilities which I employed to format: http://www.intel.com/technology/efi/diskutil_overview.htm

First I tried using efifmt.efi directly on the created device, but it did not work:

fs1:\> EFIFMT.EFI blk0
EfiFmt Version 1.2. Based on EFI Version 2.10
IFSUTIL: Can't open drive. Status returned = C0000001.
Cannot determine file system of drive blk0.
Unable to determine file system type.
Cannot open volume for direct access.

What I do is first create a partition in the disk and then format it this way:

fs1:\> DISKPART.EFI
DiskPart Version 1.2. Based on EFI Version 2.10
DiskPart> list
### BlkSize BlkCount
--- ------- ----------------
0 200 100000
DiskPart> select 0
Selected Disk = 0
DiskPart> clean all
About to CLEAN (DESTROY) disk 0, are you SURE [y/n]?
CLEAN>> y
If you are REALLY SURE, type '$C'
CLEAN>> $C
DiskPart> new gpt
DiskPart> create name=partition type=efisys size=2000
DiskPart> exit
Exiting....

fs1:\> map -r
Device mapping table
fs0 :Removeable BlockDevice - Alias f40c0 blk0
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)
blk0 :Removeable BlockDevice - Alias f40c0 fs0
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)
blk1 :HardDisk - Alias (null)
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)/HD(Part1,Sig301D7800-1DD2-1000-9620-001A4B6FDBCA)
blk2 :BlockDevice - Alias (null)
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
f40c0 :Removeable BlockDevice - Alias fs0 blk0


Shell> EFIFMT.EFI blk1 /FS:FAT32
EfiFmt Version 1.2. Based on EFI Version 2.10
WARNING, ALL DATA ON EFI DEVICE
blk1 WILL BE LOST!
Proceed with Format (Y/N)? y
Formatting 511M
Initializing the File Allocation Table (FAT)...
Volume label (11 characters, ENTER for none)? ramdisk
Format complete.
535769088 bytes total disk space.
535764992 bytes available on disk.
4096 bytes in each allocation unit.
130802 allocation units available on disk.

32 bits in each FAT entry.

Volume Serial Number is 000040B3-00004A89

Then everything goes fine I can read, write, mkdir etc.. on that volume and when using dblk the output seems correct:

Shell> dblk blk0

LBA 0000000000000000 Size 00000200 bytes BlkIo 01F14F18
00000000: EB 58 90 4D 53 44 4F 53-35 2E 30 00 02 08 26 00 *.X.MSDOS5.0...&.*
00000010: 02 00 00 00 00 F8 00 00-01 00 01 00 00 00 00 00 *................*
00000020: 00 00 79 00 31 1E 00 00-00 00 00 00 02 00 00 00 *..y.1...........*
00000030: 01 00 06 00 00 00 00 00-00 00 00 00 00 00 00 00 *................*
00000040: 00 00 29 27 7A 7B C4 4E-4F 20 4E 41 4D 45 20 20 *..)'z..NO NAME *
00000050: 20 20 46 41 54 33 32 20-20 20 33 C9 8E D1 BC F4 * FAT32 3.....*
00000060: 7B 8E C1 8E D9 BD 00 7C-88 4E 02 8A 56 40 B4 08 ****@..*
00000070: CD 13 73 05 B9 FF FF 8A-F1 66 0F B6 C6 40 66 0F ****@f<mailto:****@f>.*
00000080: B6 D1 80 E2 3F F7 E2 86-CD C0 ED 06 41 66 0F B7 *....?.......Af..*
00000090: C9 66 F7 E1 66 89 46 F8-83 7E 16 00 75 38 83 7E *.f..f.F.....u8..*
000000A0: 2A 00 77 32 66 8B 46 1C-66 83 C0 0C BB 00 80 B9 **.w2f.F.f.......*
000000B0: 01 00 E8 2B 00 E9 48 03-A0 FA 7D B4 7D 8B F0 AC *...+..H.........*
000000C0: 84 C0 74 17 3C FF 74 09-B4 0E BB 07 00 CD 10 EB *..t.<.t.........*
000000D0: EE A0 FB 7D EB E5 A0 F9-7D EB E0 98 CD 16 CD 19 *................*
000000E0: 66 60 66 3B 46 F8 0F 82-4A 00 66 6A 00 66 50 06 *f`f;F...J.fj.fP.*
000000F0: 53 66 68 10 00 01 00 80-7E 02 00 0F 85 20 00 B4 *Sfh.......... ..*
00000100: 41 BB AA 55 8A 56 40 CD-13 0F 82 1C 00 81 FB 55 ****@........U<mailto:****@........U>*
00000110: AA 0F 85 14 00 F6 C1 01-0F 84 0D 00 FE 46 02 B4 *.............F..*
00000120: 42 8A 56 40 8B F4 CD 13-B0 F9 66 58 66 58 66 58 ****@......fXfXfX<mailto:****@......fXfXfX>*
00000130: 66 58 EB 2A 66 33 D2 66-0F B7 4E 18 66 F7 F1 FE *fX.*f3.f..N.f...*
00000140: C2 8A CA 66 8B D0 66 C1-EA 10 F7 76 1A 86 D6 8A *...f..f....v....*
00000150: 56 40 8A E8 C0 E4 06 0A-CC B8 01 02 CD 13 66 61 ****@............fa<mailto:****@............fa>*
00000160: 0F 82 54 FF 81 C3 00 02-66 40 49 0F 85 71 FF C3 ****@I..q<mailto:****@I..q>..*
00000170: 4E 54 4C 44 52 20 20 20-20 20 20 00 00 00 00 00 *NTLDR .....*
00000180: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 *................*
00000190: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 *................*
000001A0: 00 00 00 00 00 00 00 00-00 00 00 00 0D 0A 4E 54 *..............NT*
000001B0: 4C 44 52 20 69 73 20 6D-69 73 73 69 6E 67 FF 0D *LDR is missing..*
000001C0: 0A 44 69 73 6B 20 65 72-72 6F 72 FF 0D 0A 50 72 *.Disk error...Pr*
000001D0: 65 73 73 20 61 6E 79 20-6B 65 79 20 74 6F 20 72 *ess any key to r*
000001E0: 65 73 74 61 72 74 0D 0A-00 00 00 00 00 00 00 00 *estart..........*
000001F0: 00 00 00 00 00 00 00 00-00 AC BF CC 00 00 55 AA *..............U.*


But there is something that I do not understand. Why if I am reserving 2000MB when I format it it only recognizes 511MB?

Formatting 511M
I tried several times but I only got it to recognize the 511MB.

Thank you very much for your help again :)

BR

Daniel

________________________________
From: Andrew Fish [mailto:***@apple.com]
Sent: den 8 juli 2011 19:08
To: edk2-***@lists.sourceforge.net
Cc: efidevkit-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell

Daniel,

I think there is a RAM Disk driver in the toolkit.... It produces the Block IO protocol. The only problem is you have to format the Block IO partition to put a file system on it. There is an EFI application to do that. If the Block IO protocol abstracts blocks that contain a FAT file system then when you connect that handle the file system driver will bind and you will get a Simple File System Protocol that would show up at the shell prompt.

It would be possible to write a Simple File System Driver that just treated files as linked lists. I've never seen this done, but it is quite possible.

These two chunks work together to make Simple File System on top of ANSI C APIs:
https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EmulatorPkg/Unix/Host/PosixFileSystem.c

Maybe this would be a good GSOC project at some point.

Andrew Fish





On Jul 8, 2011, at 9:28 AM, Daniel Moral wrote:

Hi!

I want to build a memory mapped file system in order to use it with EDK1 Shell. What I want is to create a temporal file system using the RAM memory
of my board in order to store there files downloaded from a tftp server without needing an external flash memory. Therefore I could use the files
I download in other applications.

I am a bit lost on how I could do this. Would it be possible to create a virtual drive using the RAM memory and "trick" the shell so it thinks it is
just another volume? Or should I think in other possibilities?

Thank you very much.

BR

Daniel

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2_______________________________________________
edk2-devel mailing list
edk2-***@lists.sourceforge.net<mailto:edk2-***@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/edk2-devel
Joe Thomas
2011-07-12 12:15:31 UTC
Permalink
Daniel,

The name 'f0agonennapphibbndlnmeaakamjeafdnb' is an encoding of the GUID value from the Vendor Message type of device that is created by the driver (VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1))

As to the size, I'm not certain but is the 'size=xxxx' parameter in your DISKPART create in blocks or MB? [I would suspect that it's in block and if so, try size=100000 as shown in the 'list' command...]

-Joe Thomas

From: Daniel Moral [mailto:***@ericsson.com]
Sent: Monday, July 11, 2011 9:08 AM
To: edk2-***@lists.sourceforge.net
Cc: efidevkit-***@lists.sourceforge.net
Subject: Re: [edk] [edk2] Memory mapped file system on RAM used by EDK shell

Thanks both for your help.

Here is what I am doing. In the toolkit there is an application called mkramdisk which installs the ramdisk driver and you can specify the number of bytes, for example:

fs0:\> mkramdisk.efi -s 2000 f
Device mapping table
f :BlockDevice - Alias (null)
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
Done: RAM Disk [ f ] with size [ 2000MB ]

That creates a 2000MB ram disk called f. Nevertheless it appears to be some problem with the name cause I get:

fs0:\> map -r
Device mapping table
fs0 :BlockDevice - Alias f0agonennapphibbndlnmeaakamjeafdnb blk0
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
fs1 :Removeable BlockDevice - Alias f40c0 blk1
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)
blk0 :BlockDevice - Alias f0agonennapphibbndlnmeaakamjeafdnb fs0
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
blk1 :Removeable BlockDevice - Alias f40c0 fs1
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)
f0agonennapphibbndlnmeaakamjeafdnb :BlockDevice - Alias fs0 blk0
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
f40c0 :Removeable BlockDevice - Alias fs1 blk1
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)

Where f0agonen... is a strange name.

There is a set of tools called EFI Disk utilities which I employed to format: http://www.intel.com/technology/efi/diskutil_overview.htm

First I tried using efifmt.efi directly on the created device, but it did not work:

fs1:\> EFIFMT.EFI blk0
EfiFmt Version 1.2. Based on EFI Version 2.10
IFSUTIL: Can't open drive. Status returned = C0000001.
Cannot determine file system of drive blk0.
Unable to determine file system type.
Cannot open volume for direct access.

What I do is first create a partition in the disk and then format it this way:

fs1:\> DISKPART.EFI
DiskPart Version 1.2. Based on EFI Version 2.10
DiskPart> list
### BlkSize BlkCount
--- ------- ----------------
0 200 100000
DiskPart> select 0
Selected Disk = 0
DiskPart> clean all
About to CLEAN (DESTROY) disk 0, are you SURE [y/n]?
CLEAN>> y
If you are REALLY SURE, type '$C'
CLEAN>> $C
DiskPart> new gpt
DiskPart> create name=partition type=efisys size=2000
DiskPart> exit
Exiting....

fs1:\> map -r
Device mapping table
fs0 :Removeable BlockDevice - Alias f40c0 blk0
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)
blk0 :Removeable BlockDevice - Alias f40c0 fs0
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)
blk1 :HardDisk - Alias (null)
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)/HD(Part1,Sig301D7800-1DD2-1000-9620-001A4B6FDBCA)
blk2 :BlockDevice - Alias (null)
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
f40c0 :Removeable BlockDevice - Alias fs0 blk0


Shell> EFIFMT.EFI blk1 /FS:FAT32
EfiFmt Version 1.2. Based on EFI Version 2.10
WARNING, ALL DATA ON EFI DEVICE
blk1 WILL BE LOST!
Proceed with Format (Y/N)? y
Formatting 511M
Initializing the File Allocation Table (FAT)...
Volume label (11 characters, ENTER for none)? ramdisk
Format complete.
535769088 bytes total disk space.
535764992 bytes available on disk.
4096 bytes in each allocation unit.
130802 allocation units available on disk.

32 bits in each FAT entry.

Volume Serial Number is 000040B3-00004A89

Then everything goes fine I can read, write, mkdir etc.. on that volume and when using dblk the output seems correct:

Shell> dblk blk0

LBA 0000000000000000 Size 00000200 bytes BlkIo 01F14F18
00000000: EB 58 90 4D 53 44 4F 53-35 2E 30 00 02 08 26 00 *.X.MSDOS5.0...&.*
00000010: 02 00 00 00 00 F8 00 00-01 00 01 00 00 00 00 00 *................*
00000020: 00 00 79 00 31 1E 00 00-00 00 00 00 02 00 00 00 *..y.1...........*
00000030: 01 00 06 00 00 00 00 00-00 00 00 00 00 00 00 00 *................*
00000040: 00 00 29 27 7A 7B C4 4E-4F 20 4E 41 4D 45 20 20 *..)'z..NO NAME *
00000050: 20 20 46 41 54 33 32 20-20 20 33 C9 8E D1 BC F4 * FAT32 3.....*
00000060: 7B 8E C1 8E D9 BD 00 7C-88 4E 02 8A 56 40 B4 08 ****@..*<mailto:****@..*>
00000070: CD 13 73 05 B9 FF FF 8A-F1 66 0F B6 C6 40 66 0F ****@f<mailto:****@f>.*
00000080: B6 D1 80 E2 3F F7 E2 86-CD C0 ED 06 41 66 0F B7 *....?.......Af..*
00000090: C9 66 F7 E1 66 89 46 F8-83 7E 16 00 75 38 83 7E *.f..f.F.....u8..*
000000A0: 2A 00 77 32 66 8B 46 1C-66 83 C0 0C BB 00 80 B9 **.w2f.F.f.......*
000000B0: 01 00 E8 2B 00 E9 48 03-A0 FA 7D B4 7D 8B F0 AC *...+..H.........*
000000C0: 84 C0 74 17 3C FF 74 09-B4 0E BB 07 00 CD 10 EB *..t.<.t.........*
000000D0: EE A0 FB 7D EB E5 A0 F9-7D EB E0 98 CD 16 CD 19 *................*
000000E0: 66 60 66 3B 46 F8 0F 82-4A 00 66 6A 00 66 50 06 *f`f;F...J.fj.fP.*
000000F0: 53 66 68 10 00 01 00 80-7E 02 00 0F 85 20 00 B4 *Sfh.......... ..*
00000100: 41 BB AA 55 8A 56 40 CD-13 0F 82 1C 00 81 FB 55 ****@........U<mailto:****@........U>*
00000110: AA 0F 85 14 00 F6 C1 01-0F 84 0D 00 FE 46 02 B4 *.............F..*
00000120: 42 8A 56 40 8B F4 CD 13-B0 F9 66 58 66 58 66 58 ****@......fXfXfX<mailto:****@......fXfXfX>*
00000130: 66 58 EB 2A 66 33 D2 66-0F B7 4E 18 66 F7 F1 FE *fX.*f3.f..N.f...*
00000140: C2 8A CA 66 8B D0 66 C1-EA 10 F7 76 1A 86 D6 8A *...f..f....v....*
00000150: 56 40 8A E8 C0 E4 06 0A-CC B8 01 02 CD 13 66 61 ****@............fa<mailto:****@............fa>*
00000160: 0F 82 54 FF 81 C3 00 02-66 40 49 0F 85 71 FF C3 ****@I..q<mailto:****@I..q>..*
00000170: 4E 54 4C 44 52 20 20 20-20 20 20 00 00 00 00 00 *NTLDR .....*
00000180: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 *................*
00000190: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 *................*
000001A0: 00 00 00 00 00 00 00 00-00 00 00 00 0D 0A 4E 54 *..............NT*
000001B0: 4C 44 52 20 69 73 20 6D-69 73 73 69 6E 67 FF 0D *LDR is missing..*
000001C0: 0A 44 69 73 6B 20 65 72-72 6F 72 FF 0D 0A 50 72 *.Disk error...Pr*
000001D0: 65 73 73 20 61 6E 79 20-6B 65 79 20 74 6F 20 72 *ess any key to r*
000001E0: 65 73 74 61 72 74 0D 0A-00 00 00 00 00 00 00 00 *estart..........*
000001F0: 00 00 00 00 00 00 00 00-00 AC BF CC 00 00 55 AA *..............U.*


But there is something that I do not understand. Why if I am reserving 2000MB when I format it it only recognizes 511MB?

Formatting 511M
I tried several times but I only got it to recognize the 511MB.

Thank you very much for your help again :)

BR

Daniel

________________________________
From: Andrew Fish [mailto:***@apple.com]
Sent: den 8 juli 2011 19:08
To: edk2-***@lists.sourceforge.net
Cc: efidevkit-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell
Daniel,

I think there is a RAM Disk driver in the toolkit.... It produces the Block IO protocol. The only problem is you have to format the Block IO partition to put a file system on it. There is an EFI application to do that. If the Block IO protocol abstracts blocks that contain a FAT file system then when you connect that handle the file system driver will bind and you will get a Simple File System Protocol that would show up at the shell prompt.

It would be possible to write a Simple File System Driver that just treated files as linked lists. I've never seen this done, but it is quite possible.

These two chunks work together to make Simple File System on top of ANSI C APIs:
https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EmulatorPkg/Unix/Host/PosixFileSystem.c

Maybe this would be a good GSOC project at some point.

Andrew Fish




On Jul 8, 2011, at 9:28 AM, Daniel Moral wrote:


Hi!

I want to build a memory mapped file system in order to use it with EDK1 Shell. What I want is to create a temporal file system using the RAM memory
of my board in order to store there files downloaded from a tftp server without needing an external flash memory. Therefore I could use the files
I download in other applications.

I am a bit lost on how I could do this. Would it be possible to create a virtual drive using the RAM memory and "trick" the shell so it thinks it is
just another volume? Or should I think in other possibilities?

Thank you very much.

BR

Daniel

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2_______________________________________________
edk2-devel mailing list
edk2-***@lists.sourceforge.net<mailto:edk2-***@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/edk2-devel
Daniel Moral
2011-07-12 13:21:57 UTC
Permalink
Hi Joe,

Thank you for telling me from where dide the GUID came. I have found the problem, in the changelog of the toolkit:

Changes from Release 1.02.12.38
to Release 1.10.14.62

Fixed a bug where Mkramdisk.efi needed
ramdisk.efi to be located in the root directory.
Ramdisk.efi now will accommodate RAM disk sizes down
to 2 MB (the previous version would allow minimum RAM disk
sizes down only to 5 MB). The maximum RAM disk size
(assuming memory is available) is 512 MB.

Does anybody know why is this? Can this size be increased? Is there any way to create several 512RAM Disks and merge them?

Thank you very much.

BR

Daniel


________________________________
From: Joe Thomas [mailto:***@dothill.com]
Sent: den 12 juli 2011 14:16
To: efidevkit-***@lists.sourceforge.net; edk2-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell

Daniel,

The name 'f0agonennapphibbndlnmeaakamjeafdnb' is an encoding of the GUID value from the Vendor Message type of device that is created by the driver (VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1))

As to the size, I'm not certain but is the 'size=xxxx' parameter in your DISKPART create in blocks or MB? [I would suspect that it's in block and if so, try size=100000 as shown in the 'list' command...]

-Joe Thomas

From: Daniel Moral [mailto:***@ericsson.com]
Sent: Monday, July 11, 2011 9:08 AM
To: edk2-***@lists.sourceforge.net
Cc: efidevkit-***@lists.sourceforge.net
Subject: Re: [edk] [edk2] Memory mapped file system on RAM used by EDK shell

Thanks both for your help.

Here is what I am doing. In the toolkit there is an application called mkramdisk which installs the ramdisk driver and you can specify the number of bytes, for example:

fs0:\> mkramdisk.efi -s 2000 f
Device mapping table
f :BlockDevice - Alias (null)
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
Done: RAM Disk [ f ] with size [ 2000MB ]

That creates a 2000MB ram disk called f. Nevertheless it appears to be some problem with the name cause I get:

fs0:\> map -r
Device mapping table
fs0 :BlockDevice - Alias f0agonennapphibbndlnmeaakamjeafdnb blk0
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
fs1 :Removeable BlockDevice - Alias f40c0 blk1
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)
blk0 :BlockDevice - Alias f0agonennapphibbndlnmeaakamjeafdnb fs0
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
blk1 :Removeable BlockDevice - Alias f40c0 fs1
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)
f0agonennapphibbndlnmeaakamjeafdnb :BlockDevice - Alias fs0 blk0
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
f40c0 :Removeable BlockDevice - Alias fs1 blk1
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)

Where f0agonen... is a strange name.

There is a set of tools called EFI Disk utilities which I employed to format: http://www.intel.com/technology/efi/diskutil_overview.htm

First I tried using efifmt.efi directly on the created device, but it did not work:

fs1:\> EFIFMT.EFI blk0
EfiFmt Version 1.2. Based on EFI Version 2.10
IFSUTIL: Can't open drive. Status returned = C0000001.
Cannot determine file system of drive blk0.
Unable to determine file system type.
Cannot open volume for direct access.

What I do is first create a partition in the disk and then format it this way:

fs1:\> DISKPART.EFI
DiskPart Version 1.2. Based on EFI Version 2.10
DiskPart> list
### BlkSize BlkCount
--- ------- ----------------
0 200 100000
DiskPart> select 0
Selected Disk = 0
DiskPart> clean all
About to CLEAN (DESTROY) disk 0, are you SURE [y/n]?
CLEAN>> y
If you are REALLY SURE, type '$C'
CLEAN>> $C
DiskPart> new gpt
DiskPart> create name=partition type=efisys size=2000
DiskPart> exit
Exiting....

fs1:\> map -r
Device mapping table
fs0 :Removeable BlockDevice - Alias f40c0 blk0
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)
blk0 :Removeable BlockDevice - Alias f40c0 fs0
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)
blk1 :HardDisk - Alias (null)
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)/HD(Part1,Sig301D7800-1DD2-1000-9620-001A4B6FDBCA)
blk2 :BlockDevice - Alias (null)
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
f40c0 :Removeable BlockDevice - Alias fs0 blk0


Shell> EFIFMT.EFI blk1 /FS:FAT32
EfiFmt Version 1.2. Based on EFI Version 2.10
WARNING, ALL DATA ON EFI DEVICE
blk1 WILL BE LOST!
Proceed with Format (Y/N)? y
Formatting 511M
Initializing the File Allocation Table (FAT)...
Volume label (11 characters, ENTER for none)? ramdisk
Format complete.
535769088 bytes total disk space.
535764992 bytes available on disk.
4096 bytes in each allocation unit.
130802 allocation units available on disk.

32 bits in each FAT entry.

Volume Serial Number is 000040B3-00004A89

Then everything goes fine I can read, write, mkdir etc.. on that volume and when using dblk the output seems correct:

Shell> dblk blk0

LBA 0000000000000000 Size 00000200 bytes BlkIo 01F14F18
00000000: EB 58 90 4D 53 44 4F 53-35 2E 30 00 02 08 26 00 *.X.MSDOS5.0...&.*
00000010: 02 00 00 00 00 F8 00 00-01 00 01 00 00 00 00 00 *................*
00000020: 00 00 79 00 31 1E 00 00-00 00 00 00 02 00 00 00 *..y.1...........*
00000030: 01 00 06 00 00 00 00 00-00 00 00 00 00 00 00 00 *................*
00000040: 00 00 29 27 7A 7B C4 4E-4F 20 4E 41 4D 45 20 20 *..)'z..NO NAME *
00000050: 20 20 46 41 54 33 32 20-20 20 33 C9 8E D1 BC F4 * FAT32 3.....*
00000060: 7B 8E C1 8E D9 BD 00 7C-88 4E 02 8A 56 40 B4 08 ****@..*<mailto:****@..*>
00000070: CD 13 73 05 B9 FF FF 8A-F1 66 0F B6 C6 40 66 0F ****@f<mailto:****@f>.*
00000080: B6 D1 80 E2 3F F7 E2 86-CD C0 ED 06 41 66 0F B7 *....?.......Af..*
00000090: C9 66 F7 E1 66 89 46 F8-83 7E 16 00 75 38 83 7E *.f..f.F.....u8..*
000000A0: 2A 00 77 32 66 8B 46 1C-66 83 C0 0C BB 00 80 B9 **.w2f.F.f.......*
000000B0: 01 00 E8 2B 00 E9 48 03-A0 FA 7D B4 7D 8B F0 AC *...+..H.........*
000000C0: 84 C0 74 17 3C FF 74 09-B4 0E BB 07 00 CD 10 EB *..t.<.t.........*
000000D0: EE A0 FB 7D EB E5 A0 F9-7D EB E0 98 CD 16 CD 19 *................*
000000E0: 66 60 66 3B 46 F8 0F 82-4A 00 66 6A 00 66 50 06 *f`f;F...J.fj.fP.*
000000F0: 53 66 68 10 00 01 00 80-7E 02 00 0F 85 20 00 B4 *Sfh.......... ..*
00000100: 41 BB AA 55 8A 56 40 CD-13 0F 82 1C 00 81 FB 55 ****@........U<mailto:****@........U>*
00000110: AA 0F 85 14 00 F6 C1 01-0F 84 0D 00 FE 46 02 B4 *.............F..*
00000120: 42 8A 56 40 8B F4 CD 13-B0 F9 66 58 66 58 66 58 ****@......fXfXfX<mailto:****@......fXfXfX>*
00000130: 66 58 EB 2A 66 33 D2 66-0F B7 4E 18 66 F7 F1 FE *fX.*f3.f..N.f...*
00000140: C2 8A CA 66 8B D0 66 C1-EA 10 F7 76 1A 86 D6 8A *...f..f....v....*
00000150: 56 40 8A E8 C0 E4 06 0A-CC B8 01 02 CD 13 66 61 ****@............fa<mailto:****@............fa>*
00000160: 0F 82 54 FF 81 C3 00 02-66 40 49 0F 85 71 FF C3 ****@I..q<mailto:****@I..q>..*
00000170: 4E 54 4C 44 52 20 20 20-20 20 20 00 00 00 00 00 *NTLDR .....*
00000180: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 *................*
00000190: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 *................*
000001A0: 00 00 00 00 00 00 00 00-00 00 00 00 0D 0A 4E 54 *..............NT*
000001B0: 4C 44 52 20 69 73 20 6D-69 73 73 69 6E 67 FF 0D *LDR is missing..*
000001C0: 0A 44 69 73 6B 20 65 72-72 6F 72 FF 0D 0A 50 72 *.Disk error...Pr*
000001D0: 65 73 73 20 61 6E 79 20-6B 65 79 20 74 6F 20 72 *ess any key to r*
000001E0: 65 73 74 61 72 74 0D 0A-00 00 00 00 00 00 00 00 *estart..........*
000001F0: 00 00 00 00 00 00 00 00-00 AC BF CC 00 00 55 AA *..............U.*


But there is something that I do not understand. Why if I am reserving 2000MB when I format it it only recognizes 511MB?

Formatting 511M
I tried several times but I only got it to recognize the 511MB.

Thank you very much for your help again :)

BR

Daniel

________________________________
From: Andrew Fish [mailto:***@apple.com]
Sent: den 8 juli 2011 19:08
To: edk2-***@lists.sourceforge.net
Cc: efidevkit-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell
Daniel,

I think there is a RAM Disk driver in the toolkit.... It produces the Block IO protocol. The only problem is you have to format the Block IO partition to put a file system on it. There is an EFI application to do that. If the Block IO protocol abstracts blocks that contain a FAT file system then when you connect that handle the file system driver will bind and you will get a Simple File System Protocol that would show up at the shell prompt.

It would be possible to write a Simple File System Driver that just treated files as linked lists. I've never seen this done, but it is quite possible.

These two chunks work together to make Simple File System on top of ANSI C APIs:
https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EmulatorPkg/Unix/Host/PosixFileSystem.c

Maybe this would be a good GSOC project at some point.

Andrew Fish




On Jul 8, 2011, at 9:28 AM, Daniel Moral wrote:


Hi!

I want to build a memory mapped file system in order to use it with EDK1 Shell. What I want is to create a temporal file system using the RAM memory
of my board in order to store there files downloaded from a tftp server without needing an external flash memory. Therefore I could use the files
I download in other applications.

I am a bit lost on how I could do this. Would it be possible to create a virtual drive using the RAM memory and "trick" the shell so it thinks it is
just another volume? Or should I think in other possibilities?

Thank you very much.

BR

Daniel

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2_______________________________________________
edk2-devel mailing list
edk2-***@lists.sourceforge.net<mailto:edk2-***@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/edk2-devel
Carsey, Jaben
2011-07-12 14:49:36 UTC
Permalink
Looks in the code like there is just a maximum size defined. Maybe you can upgrade the ramdisk driver?

Search for MAX_DISK_SIZE in ramdisk.c.

-Jaben

From: Daniel Moral [mailto:***@ericsson.com]
Sent: Tuesday, July 12, 2011 6:22 AM
To: edk2-***@lists.sourceforge.net; efidevkit-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell

Hi Joe,

Thank you for telling me from where dide the GUID came. I have found the problem, in the changelog of the toolkit:

Changes from Release 1.02.12.38
to Release 1.10.14.62

Fixed a bug where Mkramdisk.efi needed
ramdisk.efi to be located in the root directory.
Ramdisk.efi now will accommodate RAM disk sizes down
to 2 MB (the previous version would allow minimum RAM disk
sizes down only to 5 MB). The maximum RAM disk size
(assuming memory is available) is 512 MB.

Does anybody know why is this? Can this size be increased? Is there any way to create several 512RAM Disks and merge them?

Thank you very much.

BR

Daniel


________________________________
From: Joe Thomas [mailto:***@dothill.com]
Sent: den 12 juli 2011 14:16
To: efidevkit-***@lists.sourceforge.net; edk2-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell
Daniel,

The name 'f0agonennapphibbndlnmeaakamjeafdnb' is an encoding of the GUID value from the Vendor Message type of device that is created by the driver (VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1))

As to the size, I'm not certain but is the 'size=xxxx' parameter in your DISKPART create in blocks or MB? [I would suspect that it's in block and if so, try size=100000 as shown in the 'list' command...]

-Joe Thomas

From: Daniel Moral [mailto:***@ericsson.com]
Sent: Monday, July 11, 2011 9:08 AM
To: edk2-***@lists.sourceforge.net
Cc: efidevkit-***@lists.sourceforge.net
Subject: Re: [edk] [edk2] Memory mapped file system on RAM used by EDK shell

Thanks both for your help.

Here is what I am doing. In the toolkit there is an application called mkramdisk which installs the ramdisk driver and you can specify the number of bytes, for example:

fs0:\> mkramdisk.efi -s 2000 f
Device mapping table
f :BlockDevice - Alias (null)
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
Done: RAM Disk [ f ] with size [ 2000MB ]

That creates a 2000MB ram disk called f. Nevertheless it appears to be some problem with the name cause I get:

fs0:\> map -r
Device mapping table
fs0 :BlockDevice - Alias f0agonennapphibbndlnmeaakamjeafdnb blk0
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
fs1 :Removeable BlockDevice - Alias f40c0 blk1
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)
blk0 :BlockDevice - Alias f0agonennapphibbndlnmeaakamjeafdnb fs0
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
blk1 :Removeable BlockDevice - Alias f40c0 fs1
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)
f0agonennapphibbndlnmeaakamjeafdnb :BlockDevice - Alias fs0 blk0
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
f40c0 :Removeable BlockDevice - Alias fs1 blk1
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)

Where f0agonen... is a strange name.

There is a set of tools called EFI Disk utilities which I employed to format: http://www.intel.com/technology/efi/diskutil_overview.htm

First I tried using efifmt.efi directly on the created device, but it did not work:

fs1:\> EFIFMT.EFI blk0
EfiFmt Version 1.2. Based on EFI Version 2.10
IFSUTIL: Can't open drive. Status returned = C0000001.
Cannot determine file system of drive blk0.
Unable to determine file system type.
Cannot open volume for direct access.

What I do is first create a partition in the disk and then format it this way:

fs1:\> DISKPART.EFI
DiskPart Version 1.2. Based on EFI Version 2.10
DiskPart> list
### BlkSize BlkCount
--- ------- ----------------
0 200 100000
DiskPart> select 0
Selected Disk = 0
DiskPart> clean all
About to CLEAN (DESTROY) disk 0, are you SURE [y/n]?
CLEAN>> y
If you are REALLY SURE, type '$C'
CLEAN>> $C
DiskPart> new gpt
DiskPart> create name=partition type=efisys size=2000
DiskPart> exit
Exiting....

fs1:\> map -r
Device mapping table
fs0 :Removeable BlockDevice - Alias f40c0 blk0
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)
blk0 :Removeable BlockDevice - Alias f40c0 fs0
Acpi(PNP0A03,0)/Pci(1D|7)/Usb(2, 0)
blk1 :HardDisk - Alias (null)
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)/HD(Part1,Sig301D7800-1DD2-1000-9620-001A4B6FDBCA)
blk2 :BlockDevice - Alias (null)
VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1)
f40c0 :Removeable BlockDevice - Alias fs0 blk0


Shell> EFIFMT.EFI blk1 /FS:FAT32
EfiFmt Version 1.2. Based on EFI Version 2.10
WARNING, ALL DATA ON EFI DEVICE
blk1 WILL BE LOST!
Proceed with Format (Y/N)? y
Formatting 511M
Initializing the File Allocation Table (FAT)...
Volume label (11 characters, ENTER for none)? ramdisk
Format complete.
535769088 bytes total disk space.
535764992 bytes available on disk.
4096 bytes in each allocation unit.
130802 allocation units available on disk.

32 bits in each FAT entry.

Volume Serial Number is 000040B3-00004A89

Then everything goes fine I can read, write, mkdir etc.. on that volume and when using dblk the output seems correct:

Shell> dblk blk0

LBA 0000000000000000 Size 00000200 bytes BlkIo 01F14F18
00000000: EB 58 90 4D 53 44 4F 53-35 2E 30 00 02 08 26 00 *.X.MSDOS5.0...&.*
00000010: 02 00 00 00 00 F8 00 00-01 00 01 00 00 00 00 00 *................*
00000020: 00 00 79 00 31 1E 00 00-00 00 00 00 02 00 00 00 *..y.1...........*
00000030: 01 00 06 00 00 00 00 00-00 00 00 00 00 00 00 00 *................*
00000040: 00 00 29 27 7A 7B C4 4E-4F 20 4E 41 4D 45 20 20 *..)'z..NO NAME *
00000050: 20 20 46 41 54 33 32 20-20 20 33 C9 8E D1 BC F4 * FAT32 3.....*
00000060: 7B 8E C1 8E D9 BD 00 7C-88 4E 02 8A 56 40 B4 08 ****@..*<mailto:****@..*>
00000070: CD 13 73 05 B9 FF FF 8A-F1 66 0F B6 C6 40 66 0F ****@f<mailto:****@f>.*
00000080: B6 D1 80 E2 3F F7 E2 86-CD C0 ED 06 41 66 0F B7 *....?.......Af..*
00000090: C9 66 F7 E1 66 89 46 F8-83 7E 16 00 75 38 83 7E *.f..f.F.....u8..*
000000A0: 2A 00 77 32 66 8B 46 1C-66 83 C0 0C BB 00 80 B9 **.w2f.F.f.......*
000000B0: 01 00 E8 2B 00 E9 48 03-A0 FA 7D B4 7D 8B F0 AC *...+..H.........*
000000C0: 84 C0 74 17 3C FF 74 09-B4 0E BB 07 00 CD 10 EB *..t.<.t.........*
000000D0: EE A0 FB 7D EB E5 A0 F9-7D EB E0 98 CD 16 CD 19 *................*
000000E0: 66 60 66 3B 46 F8 0F 82-4A 00 66 6A 00 66 50 06 *f`f;F...J.fj.fP.*
000000F0: 53 66 68 10 00 01 00 80-7E 02 00 0F 85 20 00 B4 *Sfh.......... ..*
00000100: 41 BB AA 55 8A 56 40 CD-13 0F 82 1C 00 81 FB 55 ****@........U<mailto:****@........U>*
00000110: AA 0F 85 14 00 F6 C1 01-0F 84 0D 00 FE 46 02 B4 *.............F..*
00000120: 42 8A 56 40 8B F4 CD 13-B0 F9 66 58 66 58 66 58 ****@......fXfXfX<mailto:****@......fXfXfX>*
00000130: 66 58 EB 2A 66 33 D2 66-0F B7 4E 18 66 F7 F1 FE *fX.*f3.f..N.f...*
00000140: C2 8A CA 66 8B D0 66 C1-EA 10 F7 76 1A 86 D6 8A *...f..f....v....*
00000150: 56 40 8A E8 C0 E4 06 0A-CC B8 01 02 CD 13 66 61 ****@............fa<mailto:****@............fa>*
00000160: 0F 82 54 FF 81 C3 00 02-66 40 49 0F 85 71 FF C3 ****@I..q<mailto:****@I..q>..*
00000170: 4E 54 4C 44 52 20 20 20-20 20 20 00 00 00 00 00 *NTLDR .....*
00000180: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 *................*
00000190: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 *................*
000001A0: 00 00 00 00 00 00 00 00-00 00 00 00 0D 0A 4E 54 *..............NT*
000001B0: 4C 44 52 20 69 73 20 6D-69 73 73 69 6E 67 FF 0D *LDR is missing..*
000001C0: 0A 44 69 73 6B 20 65 72-72 6F 72 FF 0D 0A 50 72 *.Disk error...Pr*
000001D0: 65 73 73 20 61 6E 79 20-6B 65 79 20 74 6F 20 72 *ess any key to r*
000001E0: 65 73 74 61 72 74 0D 0A-00 00 00 00 00 00 00 00 *estart..........*
000001F0: 00 00 00 00 00 00 00 00-00 AC BF CC 00 00 55 AA *..............U.*


But there is something that I do not understand. Why if I am reserving 2000MB when I format it it only recognizes 511MB?

Formatting 511M
I tried several times but I only got it to recognize the 511MB.

Thank you very much for your help again :)

BR

Daniel

________________________________
From: Andrew Fish [mailto:***@apple.com]
Sent: den 8 juli 2011 19:08
To: edk2-***@lists.sourceforge.net
Cc: efidevkit-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell
Daniel,

I think there is a RAM Disk driver in the toolkit.... It produces the Block IO protocol. The only problem is you have to format the Block IO partition to put a file system on it. There is an EFI application to do that. If the Block IO protocol abstracts blocks that contain a FAT file system then when you connect that handle the file system driver will bind and you will get a Simple File System Protocol that would show up at the shell prompt.

It would be possible to write a Simple File System Driver that just treated files as linked lists. I've never seen this done, but it is quite possible.

These two chunks work together to make Simple File System on top of ANSI C APIs:
https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EmulatorPkg/Unix/Host/PosixFileSystem.c

Maybe this would be a good GSOC project at some point.

Andrew Fish




On Jul 8, 2011, at 9:28 AM, Daniel Moral wrote:

Hi!

I want to build a memory mapped file system in order to use it with EDK1 Shell. What I want is to create a temporal file system using the RAM memory
of my board in order to store there files downloaded from a tftp server without needing an external flash memory. Therefore I could use the files
I download in other applications.

I am a bit lost on how I could do this. Would it be possible to create a virtual drive using the RAM memory and "trick" the shell so it thinks it is
just another volume? Or should I think in other possibilities?

Thank you very much.

BR

Daniel

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2_______________________________________________
edk2-devel mailing list
edk2-***@lists.sourceforge.net<mailto:edk2-***@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/edk2-devel
Daniel Moral
2011-07-12 14:53:46 UTC
Permalink
Yes, I already changed it to 1024 but when running the application it frozes. I think there might be a reason why they did that, I just do not know what is it. But I think I will have to touch more code.

The system it generates is FAT16 which as far as I know works fairly well for 512MB< disks. But the FAT16 limit is 2GB in theory and some times 4GB in practice.

I was also thinking on creating several disks and doing some kind of "raid" system or so, but I have no idea on how to do it.

________________________________
From: Carsey, Jaben [mailto:***@intel.com]
Sent: den 12 juli 2011 16:50
To: edk2-***@lists.sourceforge.net; efidevkit-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell

Looks in the code like there is just a maximum size defined. Maybe you can upgrade the ramdisk driver?

Search for MAX_DISK_SIZE in ramdisk.c.

-Jaben

From: Daniel Moral [mailto:***@ericsson.com]
Sent: Tuesday, July 12, 2011 6:22 AM
To: edk2-***@lists.sourceforge.net; efidevkit-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell

Hi Joe,

Thank you for telling me from where dide the GUID came. I have found the problem, in the changelog of the toolkit:

Changes from Release 1.02.12.38
to Release 1.10.14.62

Fixed a bug where Mkramdisk.efi needed
ramdisk.efi to be located in the root directory.
Ramdisk.efi now will accommodate RAM disk sizes down
to 2 MB (the previous version would allow minimum RAM disk
sizes down only to 5 MB). The maximum RAM disk size
(assuming memory is available) is 512 MB.

Does anybody know why is this? Can this size be increased? Is there any way to create several 512RAM Disks and merge them?

Thank you very much.

BR

Daniel


________________________________
From: Joe Thomas [mailto:***@dothill.com]
Sent: den 12 juli 2011 14:16
To: efidevkit-***@lists.sourceforge.net; edk2-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell
Daniel,

The name 'f0agonennapphibbndlnmeaakamjeafdnb' is an encoding of the GUID value from the Vendor Message type of device that is created by the driver (VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1))

As to the size, I'm not certain but is the 'size=xxxx' parameter in your DISKPART create in blocks or MB? [I would suspect that it's in block and if so, try size=100000 as shown in the 'list' command...]

-Joe Thomas
Carsey, Jaben
2011-07-12 15:09:22 UTC
Permalink
Did you verify that the 'fat16tbl' has the entries that you need?

I noticed that the size2spc function that parses the table has it's return value checked with an ASSERT. Hence if this fails the program will halt.

-Jaben

From: Daniel Moral [mailto:***@ericsson.com]
Sent: Tuesday, July 12, 2011 7:54 AM
To: edk2-***@lists.sourceforge.net; efidevkit-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell

Yes, I already changed it to 1024 but when running the application it frozes. I think there might be a reason why they did that, I just do not know what is it. But I think I will have to touch more code.

The system it generates is FAT16 which as far as I know works fairly well for 512MB< disks. But the FAT16 limit is 2GB in theory and some times 4GB in practice.

I was also thinking on creating several disks and doing some kind of "raid" system or so, but I have no idea on how to do it.

________________________________
From: Carsey, Jaben [mailto:***@intel.com]
Sent: den 12 juli 2011 16:50
To: edk2-***@lists.sourceforge.net; efidevkit-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell
Looks in the code like there is just a maximum size defined. Maybe you can upgrade the ramdisk driver?

Search for MAX_DISK_SIZE in ramdisk.c.

-Jaben

From: Daniel Moral [mailto:***@ericsson.com]
Sent: Tuesday, July 12, 2011 6:22 AM
To: edk2-***@lists.sourceforge.net; efidevkit-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell

Hi Joe,

Thank you for telling me from where dide the GUID came. I have found the problem, in the changelog of the toolkit:

Changes from Release 1.02.12.38
to Release 1.10.14.62

Fixed a bug where Mkramdisk.efi needed
ramdisk.efi to be located in the root directory.
Ramdisk.efi now will accommodate RAM disk sizes down
to 2 MB (the previous version would allow minimum RAM disk
sizes down only to 5 MB). The maximum RAM disk size
(assuming memory is available) is 512 MB.

Does anybody know why is this? Can this size be increased? Is there any way to create several 512RAM Disks and merge them?

Thank you very much.

BR

Daniel


________________________________
From: Joe Thomas [mailto:***@dothill.com]
Sent: den 12 juli 2011 14:16
To: efidevkit-***@lists.sourceforge.net; edk2-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell
Daniel,

The name 'f0agonennapphibbndlnmeaakamjeafdnb' is an encoding of the GUID value from the Vendor Message type of device that is created by the driver (VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1))

As to the size, I'm not certain but is the 'size=xxxx' parameter in your DISKPART create in blocks or MB? [I would suspect that it's in block and if so, try size=100000 as shown in the 'list' command...]

-Joe Thomas
Daniel Moral
2011-07-12 16:09:57 UTC
Permalink
You are right, it works :) In fact I think that the problem with the 2GB limit in FAT16 can be circumvected because using efifmt.efi you can format it later to FAT32, so I think I would be able to use any value. I cannot prove this yet because I only have a 2GB RAM board, but I will tell you when I try it.

Thank you

________________________________
From: Carsey, Jaben [mailto:***@intel.com]
Sent: den 12 juli 2011 17:09
To: edk2-***@lists.sourceforge.net; efidevkit-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell

Did you verify that the 'fat16tbl' has the entries that you need?

I noticed that the size2spc function that parses the table has it's return value checked with an ASSERT. Hence if this fails the program will halt.

-Jaben

From: Daniel Moral [mailto:***@ericsson.com]
Sent: Tuesday, July 12, 2011 7:54 AM
To: edk2-***@lists.sourceforge.net; efidevkit-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell

Yes, I already changed it to 1024 but when running the application it frozes. I think there might be a reason why they did that, I just do not know what is it. But I think I will have to touch more code.

The system it generates is FAT16 which as far as I know works fairly well for 512MB< disks. But the FAT16 limit is 2GB in theory and some times 4GB in practice.

I was also thinking on creating several disks and doing some kind of "raid" system or so, but I have no idea on how to do it.

________________________________
From: Carsey, Jaben [mailto:***@intel.com]
Sent: den 12 juli 2011 16:50
To: edk2-***@lists.sourceforge.net; efidevkit-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell
Looks in the code like there is just a maximum size defined. Maybe you can upgrade the ramdisk driver?

Search for MAX_DISK_SIZE in ramdisk.c.

-Jaben

From: Daniel Moral [mailto:***@ericsson.com]
Sent: Tuesday, July 12, 2011 6:22 AM
To: edk2-***@lists.sourceforge.net; efidevkit-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell

Hi Joe,

Thank you for telling me from where dide the GUID came. I have found the problem, in the changelog of the toolkit:

Changes from Release 1.02.12.38
to Release 1.10.14.62

Fixed a bug where Mkramdisk.efi needed
ramdisk.efi to be located in the root directory.
Ramdisk.efi now will accommodate RAM disk sizes down
to 2 MB (the previous version would allow minimum RAM disk
sizes down only to 5 MB). The maximum RAM disk size
(assuming memory is available) is 512 MB.

Does anybody know why is this? Can this size be increased? Is there any way to create several 512RAM Disks and merge them?

Thank you very much.

BR

Daniel


________________________________
From: Joe Thomas [mailto:***@dothill.com]
Sent: den 12 juli 2011 14:16
To: efidevkit-***@lists.sourceforge.net; edk2-***@lists.sourceforge.net
Subject: Re: [edk2] Memory mapped file system on RAM used by EDK shell
Daniel,

The name 'f0agonennapphibbndlnmeaakamjeafdnb' is an encoding of the GUID value from the Vendor Message type of device that is created by the driver (VenMsg(06ED4DD0-FF78-11D3-BDC4-00A0C94053D1))

As to the size, I'm not certain but is the 'size=xxxx' parameter in your DISKPART create in blocks or MB? [I would suspect that it's in block and if so, try size=100000 as shown in the 'list' command...]

-Joe Thomas

Loading...