aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeyi Guo <heyi.guo@linaro.org>2016-06-14 11:00:38 +0800
committerLeif Lindholm <leif.lindholm@linaro.org>2016-06-16 11:33:39 +0100
commit6e841039b596269b241f747e055806cb42854f39 (patch)
treefaa25f9a733e3c90160303f67adb8883c9a2c53a
parent1fc401afa7dd33d958d2c3c1589e9e6219ff1d54 (diff)
Drivers/Block/ramdisk: Modified to be an EDKII driver
Modify ramdisk module to be an EDKII driver, to support RAM emulated FAT32 file system, so that we can have file system even without real persistent storage. Substantial coding-style fixes. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Heyi Guo <heyi.guo@linaro.org> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
-rw-r--r--Drivers/Block/ramdisk/ramdisk.c720
-rw-r--r--Drivers/Block/ramdisk/ramdisk.h123
-rw-r--r--Drivers/Block/ramdisk/ramdisk.inf54
-rw-r--r--Drivers/ramdisk/ramdisk.mak95
-rw-r--r--Include/Guid/RamDiskGuid.h26
-rw-r--r--OpenPlatformPkg.dec4
6 files changed, 566 insertions, 456 deletions
diff --git a/Drivers/Block/ramdisk/ramdisk.c b/Drivers/Block/ramdisk/ramdisk.c
index 32a7f4a..21e090b 100644
--- a/Drivers/Block/ramdisk/ramdisk.c
+++ b/Drivers/Block/ramdisk/ramdisk.c
@@ -1,28 +1,29 @@
+
/*
* Copyright (c) 1999, 2000
* Intel Corporation.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* 3. All advertising materials mentioning features or use of this software must
* display the following acknowledgement:
- *
+ *
* This product includes software developed by Intel Corporation and its
* contributors.
- *
+ *
* 4. Neither the name of Intel Corporation or its contributors may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -33,82 +34,137 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
*/
-#include <efi.h>
-#include <efilib.h>
-#include "./ramdisk.h"
+#include <Uefi.h>
-#define DEFAULT_DISK_SIZE 3 /* in MBs */
-#define MIN(x, y) (x < y ? x : y)
-#define MAX(x, y) (x > y ? x : y)
+#include <Protocol/BlockIo.h>
+#include <Protocol/LoadedImage.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include <Library/BaseLib.h>
+#include <Library/PcdLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/DevicePathLib.h>
-UINT32 GetDiskSize( EFI_HANDLE ImageHandle );
+#include <Guid/RamDiskGuid.h>
+#include "ramdisk.h"
+
+
+UINT32 GetDiskSize( EFI_HANDLE ImageHandle );
/* Embedded version string for VERS utility */
-static char v[] = "version_number=1.00 ";
+//static char v[] = "version_number=1.00 ";
/* EFI device path definition */
static RAM_DISK_DEVICE_PATH RamDiskDevicePath =
{
- MESSAGING_DEVICE_PATH,
- MSG_VENDOR_DP,
- sizeof(RAM_DISK_DEVICE_PATH) - END_DEVICE_PATH_LENGTH,
- 0,
- // {06ED4DD0-FF78-11d3-BDC4-00A0C94053D1}
- 0x6ed4dd0, 0xff78, 0x11d3, 0xbd, 0xc4, 0x0, 0xa0, 0xc9, 0x40, 0x53, 0xd1,
- 0,0,0,0,0,0,0,0, // ID assigned below
- END_DEVICE_PATH_TYPE,
- END_ENTIRE_DEVICE_PATH_SUBTYPE,
- END_DEVICE_PATH_LENGTH
+ {MESSAGING_DEVICE_PATH,
+ MSG_VENDOR_DP,
+ {sizeof(RAM_DISK_DEVICE_PATH) - END_DEVICE_PATH_LENGTH,
+ 0}},
+ RAM_DISK_GUID,
+ {0,0,0,0,0,0,0,0}, // ID assigned below
+ {END_DEVICE_PATH_TYPE,
+ END_ENTIRE_DEVICE_PATH_SUBTYPE,
+ {END_DEVICE_PATH_LENGTH}}
};
/* Lookup table of total sectors vs. cluster size.
* Ramdisk sizes between 0x20D0 (4.1MB) and 0x100000 (512MB) sectors are valid FAT16 drive sizes.
*/
-/* #define MIN_DISK_SIZE 5 */
-#define MIN_DISK_SIZE 1
-#define MAX_DISK_SIZE 512
+#define MIN_DISK_SIZE 1
+#define MAX_DISK_SIZE 512
static FAT16TABLE fat16tbl[] =
{
- /* {0x000020D0, 0}, */
- {0x00000800, 1}, /* 800 sectors * 1 sec/cluster * 512 bytes = 1 M */
- {0x00001000, 1}, /* 1000 sectors * 1 sec/cluster * 512 bytes = 2 M */
- {0x00001800, 1}, /* 1800 sectors * 1 sec/cluster * 512 bytes = 3 M */
- {0x00007FA8, 2},
- {0x00040000, 4},
- {0x00080000, 8},
- {0x00100000,16},
- {0xFFFFFFFF, 0}
+ {0x00000800, 1}, /* 800 sectors * 1 sec/cluster * 512 bytes = 1 M */
+ {0x00001000, 1}, /* 1000 sectors * 1 sec/cluster * 512 bytes = 2 M */
+ {0x00001800, 1}, /* 1800 sectors * 1 sec/cluster * 512 bytes = 3 M */
+ {0x00007FA8, 2},
+ {0x00040000, 4},
+ {0x00080000, 8},
+ {0x00100000,16},
+ {0xFFFFFFFF, 0}
};
-/* RAM pseudo-boot sector. No code.
- * Needs BS_Sig, BPB_SecPerClus, BPB_TotSec32, g_bs.BPB_TotSec16,
- * and BPB_FATSz16 filled out properly by FormatRamdisk().
- */
-static BOOTSEC g_bs =
+VOID CopyBOOTSEC(VOID* Start,BOOTSEC* bsc)
{
- /* BS_jmpBoot */ {0xeb,0x0,0x90},
- /* BS_OEMName */ {'E','F','I','R','D','I','S','K'},
- /* BPB_BytsPerSec */ 512,
- /* BPB_SecPerClus */ 0,
- /* BPB_RsvdSecCnt */ 1,
- /* BPB_NumFATs */ 2,
- /* BPB_RootEntCnt */ 512,
- /* BPB_TotSec16 */ 0,
- /* BPB_Media */ 0xF8,
- /* BPB_FATSz16 */ 0,
- /* BPB_SecPerTrk */ 0,
- /* BPB_NumHeads */ 0,
- /* BPB_HiddSec */ 0,
- /* BPB_TotSec32 */ 0,
- /* BS_DrvNum */ 0,
- /* BS_Reserved1 */ 0,
- /* BS_BootSig */ 0x29,
- /* BS_VolID */ 0,
- /* BS_VolLab */ {'N','O',' ','N','A','M','E',' ',' ',' '},
- /* BS_FilSysType */ {'F','A','T','1','6',' ',' ',' '}
-};
+UINT32 index=0;
+UINT8* pStart=(UINT8*)Start;
+
+CopyMem(&(pStart[index]), &(bsc->BS_jmpBoot[0]), sizeof(bsc->BS_jmpBoot));
+index+=sizeof(bsc->BS_jmpBoot);
+
+CopyMem(&(pStart[index]), &(bsc->BS_OEMName[0]), sizeof(bsc->BS_OEMName));
+index+=sizeof(bsc->BS_OEMName);
+
+CopyMem(&(pStart[index]), &(bsc->BPB_BytsPerSec), sizeof(bsc->BPB_BytsPerSec));
+index+=sizeof(bsc->BPB_BytsPerSec);
+
+CopyMem(&(pStart[index]), &(bsc->BPB_SecPerClus), sizeof(bsc->BPB_SecPerClus));
+index+=sizeof(bsc->BPB_SecPerClus);
+
+CopyMem(&(pStart[index]), &(bsc->BPB_RsvdSecCnt), sizeof(bsc->BPB_RsvdSecCnt));
+index+=sizeof(bsc->BPB_RsvdSecCnt);
+
+CopyMem(&(pStart[index]), &(bsc->BPB_NumFATs), sizeof(bsc->BPB_NumFATs));
+index+=sizeof(bsc->BPB_NumFATs);
+
+CopyMem(&(pStart[index]), &(bsc->BPB_NumFATs), sizeof(bsc->BPB_NumFATs));
+index+=sizeof(bsc->BPB_NumFATs);
+
+CopyMem(&(pStart[index]), &(bsc->BPB_RootEntCnt), sizeof(bsc->BPB_RootEntCnt));
+index+=sizeof(bsc->BPB_RootEntCnt);
+
+CopyMem(&(pStart[index]), &(bsc->BPB_TotSec16), sizeof(bsc->BPB_TotSec16));
+index+=sizeof(bsc->BPB_TotSec16);
+
+CopyMem(&(pStart[index]), &(bsc->BPB_Media), sizeof(bsc->BPB_Media));
+index+=sizeof(bsc->BPB_Media);
+
+CopyMem(&(pStart[index]), &(bsc->BPB_FATSz16), sizeof(bsc->BPB_FATSz16));
+index+=sizeof(bsc->BPB_FATSz16);
+
+CopyMem(&(pStart[index]), &(bsc->BPB_SecPerTrk), sizeof(bsc->BPB_SecPerTrk));
+index+=sizeof(bsc->BPB_SecPerTrk);
+
+CopyMem(&(pStart[index]), &(bsc->BPB_NumHeads), sizeof(bsc->BPB_NumHeads));
+index+=sizeof(bsc->BPB_NumHeads);
+
+CopyMem(&(pStart[index]), &(bsc->BPB_HiddSec), sizeof(bsc->BPB_HiddSec));
+index+=sizeof(bsc->BPB_HiddSec);
+
+CopyMem(&(pStart[index]), &(bsc->BPB_TotSec32), sizeof(bsc->BPB_TotSec32));
+index+=sizeof(bsc->BPB_TotSec32);
+
+CopyMem(&(pStart[index]), &(bsc->BS_DrvNum), sizeof(bsc->BS_DrvNum));
+index+=sizeof(bsc->BS_DrvNum);
+
+CopyMem(&(pStart[index]), &(bsc->BS_Reserved1), sizeof(bsc->BS_Reserved1));
+index+=sizeof(bsc->BS_Reserved1);
+
+CopyMem(&(pStart[index]), &(bsc->BS_BootSig), sizeof(bsc->BS_BootSig));
+index+=sizeof(bsc->BS_BootSig);
+
+CopyMem(&(pStart[index]), &(bsc->BS_VolID), sizeof(bsc->BS_VolID));
+index+=sizeof(bsc->BS_VolID);
+
+CopyMem(&(pStart[index]), &(bsc->BS_VolLab[0]), sizeof(bsc->BS_VolLab));
+index+=sizeof(bsc->BS_VolLab);
+
+CopyMem(&(pStart[index]), &(bsc->BS_FilSysType[0]), sizeof(bsc->BS_FilSysType));
+index+=sizeof(bsc->BS_FilSysType);
+
+CopyMem(&(pStart[index]), &(bsc->BS_Code[0]), sizeof(bsc->BS_Code));
+index+=sizeof(bsc->BS_Code);
+
+CopyMem(&(pStart[index]), &(bsc->BS_Sig), sizeof(bsc->BS_Sig));
+
+}
+
/* Helper function to compute cluster size
@@ -116,163 +172,178 @@ static BOOTSEC g_bs =
*/
STATIC UINT8 size2spc(UINT32 ts)
{
- int i = 0;
-
- while(fat16tbl[i].size != 0xFFFFFFFF)
- {
- if(ts <= fat16tbl[i].size)
- return fat16tbl[i].spc;
- ++i;
- }
-
- return 0;
+ int i = 0;
+
+ while(fat16tbl[i].size != 0xFFFFFFFF)
+ {
+ if(ts <= fat16tbl[i].size)
+ return fat16tbl[i].spc;
+ ++i;
+ }
+
+ return 0;
+}
+
+UINT8 TestSize(UINT32 ts)
+{
+ int i = 0;
+
+ while(fat16tbl[i].size != 0xFFFFFFFF)
+ {
+ if(ts <= fat16tbl[i].size)
+ return fat16tbl[i].spc;
+ ++i;
+ }
+
+ return 0;
}
-EFI_SYSTEM_TABLE BackupSystemTable;
+EFI_SYSTEM_TABLE BackupSystemTable;
/*
* Entry point for RamDisk driver.
*/
-EFI_DRIVER_ENTRY_POINT(InitializeRamDiskDriver)
EFI_STATUS InitializeRamDiskDriver(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable)
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable)
{
- EFI_STATUS Status;
- RAM_DISK_DEV *RamDiskDev;
- UINT32 RamDiskSize;
- UINT32 NumPages;
- UINT32 BlockSize;
- UINT64 DiskId;
-
- /*
- * Make a copy of the system table to workaround load command bug
- */
- CopyMem(&BackupSystemTable,SystemTable,sizeof(BackupSystemTable));
-
- /*
- * Initialize EFI library
- */
- InitializeLib(ImageHandle,&BackupSystemTable);
-
- /* IA64 compiler is removing version string (unused?) so I use it */
- v[0] = 'v';
-
- /*
- * Set the disk size
- */
- RamDiskSize = GetDiskSize(ImageHandle);
- BlockSize = 512;
-
- /* Allocate storage for ramdisk device info on the heap.
- */
- RamDiskDev = AllocateZeroPool(sizeof(RAM_DISK_DEV));
- if(RamDiskDev == NULL)
- return EFI_OUT_OF_RESOURCES;
-
- /*
- * Compute the number of 4KB pages needed by the ramdisk and allocate the memory.
- */
- NumPages = RamDiskSize / EFI_PAGE_SIZE;
- if(NumPages % RamDiskSize)
- NumPages++;
-
- Status = BS->AllocatePages(AllocateAnyPages,EfiBootServicesData,NumPages,&RamDiskDev->Start);
- if(EFI_ERROR(Status)) {
- FreePool(RamDiskDev);
- return Status;
- }
-
- /*
- * Initialize the ramdisk's device info.
- */
- (void)BS->GetNextMonotonicCount(&DiskId);
- CopyMem(&RamDiskDevicePath.DiskId, &DiskId, sizeof(DiskId));
-
- RamDiskDev->Signature = PBLOCK_DEVICE_SIGNATURE;
- RamDiskDev->BlkIo.Revision = EFI_BLOCK_IO_INTERFACE_REVISION;
- RamDiskDev->BlkIo.Media = &RamDiskDev->Media;
- RamDiskDev->Media.RemovableMedia = FALSE;
- RamDiskDev->Media.MediaPresent = TRUE;
-
- RamDiskDev->Media.LastBlock = RamDiskSize/BlockSize - 1;
- RamDiskDev->Media.BlockSize = BlockSize;
- RamDiskDev->Media.LogicalPartition = TRUE;
- RamDiskDev->Media.ReadOnly = FALSE;
- RamDiskDev->Media.WriteCaching = TRUE;
-
- RamDiskDev->BlkIo.ReadBlocks = RamDiskReadBlocks;
- RamDiskDev->BlkIo.WriteBlocks = RamDiskWriteBlocks;
- RamDiskDev->BlkIo.FlushBlocks = RamDiskFlushBlocks;
-
- RamDiskDev->DevicePath = DuplicateDevicePath((EFI_DEVICE_PATH*)&RamDiskDevicePath);
-
- /*
- * Build a FAT16 file system on the ramdisk.
- */
- FormatRamdisk((VOID*)RamDiskDev->Start,RamDiskSize);
-
- /*
- * Install the device.
- */
- Status = LibInstallProtocolInterfaces(
- &ImageHandle,
- &BlockIoProtocol,
- &RamDiskDev->BlkIo,
- &DevicePathProtocol,
- RamDiskDev->DevicePath,
- NULL);
-
- return Status;
+ EFI_STATUS Status;
+ RAM_DISK_DEV *RamDiskDev;
+ UINT32 RamDiskSize;
+ UINT32 NumPages;
+ UINT32 BlockSize;
+ UINT64 DiskId;
+
+ /*
+ * Make a copy of the system table to workaround load command bug
+ */
+ CopyMem(&BackupSystemTable,SystemTable,sizeof(BackupSystemTable));
+
+ /*
+ * Initialize EFI library
+ */
+ //InitializeLib(ImageHandle,&BackupSystemTable);
+
+ /* IA64 compiler is removing version string (unused?) so I use it */
+ //v[0] = 'v';
+
+ /*
+ * Set the disk size
+ */
+ RamDiskSize = GetDiskSize(ImageHandle);
+ BlockSize = 512;
+
+ /* Allocate storage for ramdisk device info on the heap.
+ */
+ RamDiskDev = AllocateZeroPool(sizeof(RAM_DISK_DEV));
+ if(RamDiskDev == NULL)
+ return EFI_OUT_OF_RESOURCES;
+
+ /*
+ * Compute the number of 4KB pages needed by the ramdisk and allocate the memory.
+ */
+ NumPages = RamDiskSize / EFI_PAGE_SIZE;
+ if(NumPages % RamDiskSize)
+ NumPages++;
+
+ Status = gBS->AllocatePages(AllocateAnyPages,EfiBootServicesData,NumPages,&RamDiskDev->Start);
+ if(EFI_ERROR(Status)) {
+ FreePool(RamDiskDev);
+ return Status;
+ }
+
+ /*
+ * Initialize the ramdisk's device info.
+ */
+ (void)gBS->GetNextMonotonicCount(&DiskId);
+ CopyMem(&RamDiskDevicePath.DiskId, &DiskId, sizeof(DiskId));
+
+ RamDiskDev->Signature = PBLOCK_DEVICE_SIGNATURE;
+ RamDiskDev->BlkIo.Revision = EFI_BLOCK_IO_INTERFACE_REVISION;
+ RamDiskDev->BlkIo.Media = &RamDiskDev->Media;
+ RamDiskDev->Media.RemovableMedia = FALSE;
+ RamDiskDev->Media.MediaPresent = TRUE;
+
+ RamDiskDev->Media.LastBlock = RamDiskSize/BlockSize - 1;
+ RamDiskDev->Media.BlockSize = BlockSize;
+ RamDiskDev->Media.LogicalPartition = TRUE;
+ RamDiskDev->Media.ReadOnly = FALSE;
+ RamDiskDev->Media.WriteCaching = TRUE;
+
+ RamDiskDev->BlkIo.ReadBlocks = RamDiskReadBlocks;
+ RamDiskDev->BlkIo.WriteBlocks = RamDiskWriteBlocks;
+ RamDiskDev->BlkIo.FlushBlocks = RamDiskFlushBlocks;
+
+ RamDiskDev->DevicePath = DuplicateDevicePath((EFI_DEVICE_PATH*)&RamDiskDevicePath);
+
+ /*
+ * Build a FAT16 file system on the ramdisk.
+ */
+ FormatRamdisk((VOID*)(UINTN)RamDiskDev->Start,RamDiskSize);
+
+ /*
+ * Install the device.
+ */
+
+ Status = gBS->InstallMultipleProtocolInterfaces(
+ &ImageHandle,
+ &gEfiBlockIoProtocolGuid,
+ &RamDiskDev->BlkIo,
+ &gEfiDevicePathProtocolGuid,
+ RamDiskDev->DevicePath,
+ NULL);
+
+DEBUG((EFI_D_ERROR,"ramdisk:blckio install. Status=%r\n",Status));
+ return Status;
}
UINT32
GetDiskSize( EFI_HANDLE ImageHandle )
{
- EFI_STATUS Status;
- EFI_LOADED_IMAGE *Image;
- UINT32 DiskSize = DEFAULT_DISK_SIZE;
-
- /*
- * Check load options to see if they want to specify disk size in MBs
- */
- Status = BS->HandleProtocol(ImageHandle, &LoadedImageProtocol, (void**)&Image);
- if (!EFI_ERROR(Status)) {
- if (Image->LoadOptions && Image->LoadOptionsSize) {
-#define MAX_ARG_SIZE 32
- CHAR16 Size[ MAX_ARG_SIZE ];
- CHAR16 *CmdLine = Image->LoadOptions;
- INT32 CmdLen = (INT32)Image->LoadOptionsSize;
-
- /*
- * Get past program name
- */
- while( CmdLen > 0 && *CmdLine != L' ' ) {
- CmdLen -= sizeof(CHAR16);
- CmdLine++;
- }
-
- if ( CmdLen > 0 ) {
- /*
- * Make sure we're null terminated
- */
- CopyMem( Size, CmdLine, MIN(CmdLen, sizeof(Size)));
- Size[MAX_ARG_SIZE - 1] = 0;
-
- /*
- * Atoi() will skip any leading white space
- */
- DiskSize = (UINT32)Atoi(Size);
- if (DiskSize == 0)
- DiskSize = DEFAULT_DISK_SIZE;
- DiskSize = MAX(DiskSize, MIN_DISK_SIZE);
- DiskSize = MIN(DiskSize, MAX_DISK_SIZE);
- }
- }
- }
-
- return (DiskSize * 1024 * 1024);
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE *Image;
+ UINT32 DiskSize = PcdGet32(PcdRamDiskMaxSize);
+
+ /*
+ * Check load options to see if they want to specify disk size in MBs
+ */
+ Status = gBS->HandleProtocol(ImageHandle, &gEfiLoadedImageProtocolGuid, (void**)&Image);
+ if (!EFI_ERROR(Status)) {
+ if (Image->LoadOptions && Image->LoadOptionsSize) {
+#define MAX_ARG_SIZE 32
+ CHAR16 Size[ MAX_ARG_SIZE ];
+ CHAR16 *CmdLine = Image->LoadOptions;
+ INT32 CmdLen = (INT32)Image->LoadOptionsSize;
+
+ /*
+ * Get past program name
+ */
+ while( CmdLen > 0 && *CmdLine != L' ' ) {
+ CmdLen -= sizeof(CHAR16);
+ CmdLine++;
+ }
+
+ if ( CmdLen > 0 ) {
+ /*
+ * Make sure we're null terminated
+ */
+ CopyMem( Size, CmdLine, MIN(CmdLen, (INT32)sizeof(Size)));
+ Size[MAX_ARG_SIZE - 1] = 0;
+
+ /*
+ * Atoi() will skip any leading white space
+ */
+ DiskSize = (UINT32)StrDecimalToUintn(Size);
+ if (DiskSize == 0)
+ DiskSize = PcdGet32(PcdRamDiskMaxSize);
+ DiskSize = MAX(DiskSize, MIN_DISK_SIZE);
+ DiskSize = MIN(DiskSize, MAX_DISK_SIZE);
+ }
+ }
+ }
+
+ return (DiskSize * 1024 * 1024);
}
/* Given a block of memory representing a ramdisk, build a pseudo-boot sector
@@ -283,128 +354,173 @@ GetDiskSize( EFI_HANDLE ImageHandle )
* is between 4.1MB and 512MB as appropriate for FAT16 file system.
*/
STATIC VOID FormatRamdisk(
- IN VOID* pStart,
- IN UINT32 Size)
+ IN VOID* pStart,
+ IN UINT32 Size)
{
- UINT32 TotalSectors,RootDirSectors,FatSz,tmp1,tmp2;
- UINT8 *Fat1,*Fat2;
-
- /* The boot signature needs to be filled out */
- g_bs.BS_Sig = 0xAA55;
-
- /* Compute the total sectors and appropriate cluster size */
- TotalSectors = Size / g_bs.BPB_BytsPerSec;
- g_bs.BPB_SecPerClus = size2spc(TotalSectors);
- ASSERT(g_bs.BPB_SecPerClus != 0);
-
- /* Compute how many root directory sectors are needed */
- RootDirSectors = (g_bs.BPB_RootEntCnt * 32 + g_bs.BPB_BytsPerSec - 1) / g_bs.BPB_BytsPerSec;
-
- /* Compute how many sectors are required per FAT */
- tmp1 = TotalSectors - (g_bs.BPB_RsvdSecCnt + RootDirSectors);
- tmp2 = 256 * g_bs.BPB_SecPerClus + g_bs.BPB_NumFATs;
- FatSz = (tmp1 + tmp2 - 1) / tmp2;
- ASSERT(FatSz <= 0xFFFF);
-
- /* Store the total sectors and fat size values */
- if(TotalSectors > 0xFFFF)
- g_bs.BPB_TotSec32 = TotalSectors;
- else
- g_bs.BPB_TotSec16 = (UINT16)TotalSectors;
-
- g_bs.BPB_FATSz16 = (UINT16)FatSz;
-
- /* The FAT table and root directory need to be all zeroes.
- * We'll zero the whole drive.
- */
- ZeroMem(pStart,Size);
-
- /* Write the completed boot sector to the ramdisk */
- CopyMem(pStart,&g_bs,512);
-
- /* Compute the starting offsets of the two FATs */
- Fat1 = (UINT8*)pStart + g_bs.BPB_RsvdSecCnt * 512;
- Fat2 = (UINT8*)pStart + (g_bs.BPB_RsvdSecCnt + FatSz) * 512;
-
- /* Initialize FAT1 */
- Fat1[0] = g_bs.BPB_Media;
- Fat1[1] = 0xFF;
- Fat1[2] = 0xFF;
- Fat1[3] = 0xFF;
-
- /* Initialize FAT2 */
- Fat2[0] = g_bs.BPB_Media;
- Fat2[1] = 0xFF;
- Fat2[2] = 0xFF;
- Fat2[3] = 0xFF;
+ UINT32 TotalSectors,RootDirSectors,FatSz,tmp1,tmp2;
+ UINT8 *Fat1,*Fat2;
+ BOOTSEC g_bs;
+
+ g_bs.BS_jmpBoot[0] = 0xeb;
+ g_bs.BS_jmpBoot[1] = 0x0;
+ g_bs.BS_jmpBoot[2] = 0x90;
+ g_bs.BS_OEMName[0] = 'E';
+ g_bs.BS_OEMName[1] = 'F';
+ g_bs.BS_OEMName[2] = 'I';
+ g_bs.BS_OEMName[3] = 'R';
+ g_bs.BS_OEMName[4] = 'D';
+ g_bs.BS_OEMName[5] = 'I';
+ g_bs.BS_OEMName[6] = 'S';
+ g_bs.BS_OEMName[7] = 'K';
+ g_bs.BPB_BytsPerSec = 512;
+ g_bs.BPB_SecPerClus = 0;
+ g_bs.BPB_RsvdSecCnt = 1;
+ g_bs.BPB_NumFATs = 2;
+ g_bs.BPB_RootEntCnt = 512;
+ g_bs.BPB_TotSec16 = 0;
+ g_bs.BPB_Media = 0xF8;
+ g_bs.BPB_FATSz16 = 0;
+ g_bs.BPB_SecPerTrk = 0;
+ g_bs.BPB_NumHeads = 0;
+ g_bs.BPB_HiddSec = 0;
+ g_bs.BPB_TotSec32 = 0;
+ g_bs.BS_DrvNum = 0;
+ g_bs.BS_Reserved1 = 0;
+ g_bs.BS_BootSig = 0x29;
+ g_bs.BS_VolID = 0;
+ g_bs.BS_VolLab[0] = 'N';
+ g_bs.BS_VolLab[1] = 'O';
+ g_bs.BS_VolLab[2] = ' ';
+ g_bs.BS_VolLab[3] = 'N';
+ g_bs.BS_VolLab[4] = 'A';
+ g_bs.BS_VolLab[5] = 'M';
+ g_bs.BS_VolLab[6] = 'E';
+ g_bs.BS_VolLab[7] = ' ';
+ g_bs.BS_VolLab[8] = ' ';
+ g_bs.BS_FilSysType[0] = 'F';
+ g_bs.BS_FilSysType[1] = 'A';
+ g_bs.BS_FilSysType[2] = 'T';
+ g_bs.BS_FilSysType[3] = '1';
+ g_bs.BS_FilSysType[4] = '6';
+ g_bs.BS_FilSysType[5] = ' ';
+ g_bs.BS_FilSysType[6] = ' ';
+ g_bs.BS_FilSysType[7] = ' ';
+ /* The boot signature needs to be filled out */
+ g_bs.BS_Sig = 0xAA55;
+
+ /* Compute the total sectors and appropriate cluster size */
+ TotalSectors = Size / g_bs.BPB_BytsPerSec;
+ g_bs.BPB_SecPerClus = size2spc(TotalSectors);
+ ASSERT(g_bs.BPB_SecPerClus != 0);
+
+ /* Compute how many root directory sectors are needed */
+ RootDirSectors = (g_bs.BPB_RootEntCnt * 32 + g_bs.BPB_BytsPerSec - 1) / g_bs.BPB_BytsPerSec;
+
+ /* Compute how many sectors are required per FAT */
+ tmp1 = TotalSectors - (g_bs.BPB_RsvdSecCnt + RootDirSectors);
+ tmp2 = 256 * g_bs.BPB_SecPerClus + g_bs.BPB_NumFATs;
+ FatSz = (tmp1 + tmp2 - 1) / tmp2;
+ ASSERT(FatSz <= 0xFFFF);
+
+ /* Store the total sectors and fat size values */
+ if(TotalSectors > 0xFFFF)
+ g_bs.BPB_TotSec32 = TotalSectors;
+ else
+ g_bs.BPB_TotSec16 = (UINT16)TotalSectors;
+
+ g_bs.BPB_FATSz16 = (UINT16)FatSz;
+
+ /* The FAT table and root directory need to be all zeroes.
+ * We'll zero the whole drive.
+ */
+ ZeroMem(pStart,Size);
+
+ /* Write the completed boot sector to the ramdisk */
+ CopyMem(pStart,&g_bs,512);
+
+ /* Compute the starting offsets of the two FATs */
+ Fat1 = (UINT8*)pStart + g_bs.BPB_RsvdSecCnt * 512;
+ Fat2 = (UINT8*)pStart + (UINTN)(g_bs.BPB_RsvdSecCnt + FatSz) * 512;
+
+ /* Initialize FAT1 */
+ Fat1[0] = g_bs.BPB_Media;
+ Fat1[1] = 0xFF;
+ Fat1[2] = 0xFF;
+ Fat1[3] = 0xFF;
+
+ /* Initialize FAT2 */
+ Fat2[0] = g_bs.BPB_Media;
+ Fat2[1] = 0xFF;
+ Fat2[2] = 0xFF;
+ Fat2[3] = 0xFF;
}
/* Implementation of block I/O read */
STATIC EFI_STATUS RamDiskReadBlocks(
- IN EFI_BLOCK_IO *This,
- IN UINT32 MediaId,
- IN EFI_LBA LBA,
- IN UINTN BufferSize,
- OUT VOID *Buffer)
+ IN EFI_BLOCK_IO *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA LBA,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer)
{
- EFI_BLOCK_IO_MEDIA *Media;
- RAM_DISK_DEV *RamDiskDev;
- EFI_PHYSICAL_ADDRESS RamDiskLBA;
+ EFI_BLOCK_IO_MEDIA *Media;
+ RAM_DISK_DEV *RamDiskDev;
+ EFI_PHYSICAL_ADDRESS RamDiskLBA;
- Media = This->Media;
+ Media = This->Media;
- if(BufferSize % Media->BlockSize != 0)
- return EFI_BAD_BUFFER_SIZE;
+ if(BufferSize % Media->BlockSize != 0)
+ return EFI_BAD_BUFFER_SIZE;
- if(LBA > Media->LastBlock)
- return EFI_DEVICE_ERROR;
+ if(LBA > Media->LastBlock)
+ return EFI_DEVICE_ERROR;
- if(LBA + BufferSize / Media->BlockSize - 1 > Media->LastBlock)
- return EFI_DEVICE_ERROR;
+ if(LBA + BufferSize / Media->BlockSize - 1 > Media->LastBlock)
+ return EFI_DEVICE_ERROR;
- RamDiskDev = RAM_DISK_FROM_THIS(This);
- RamDiskLBA = RamDiskDev->Start + MultU64x32(LBA,Media->BlockSize);
- CopyMem(Buffer,(VOID*)RamDiskLBA,BufferSize);
+ RamDiskDev = RAM_DISK_FROM_THIS(This);
+ RamDiskLBA = RamDiskDev->Start + MultU64x32(LBA,Media->BlockSize);
+ CopyMem(Buffer,(VOID*)(UINTN)RamDiskLBA,BufferSize);
- return EFI_SUCCESS;
+ return EFI_SUCCESS;
}
/* Implementation of block I/O write */
STATIC EFI_STATUS RamDiskWriteBlocks(
- IN EFI_BLOCK_IO *This,
- IN UINT32 MediaId,
- IN EFI_LBA LBA,
- IN UINTN BufferSize,
- IN VOID *Buffer)
+ IN EFI_BLOCK_IO *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA LBA,
+ IN UINTN BufferSize,
+ IN VOID *Buffer)
{
- EFI_BLOCK_IO_MEDIA *Media;
- RAM_DISK_DEV *RamDiskDev;
- EFI_PHYSICAL_ADDRESS RamDiskLBA;
+ EFI_BLOCK_IO_MEDIA *Media;
+ RAM_DISK_DEV *RamDiskDev;
+ EFI_PHYSICAL_ADDRESS RamDiskLBA;
- Media = This->Media;
- if(Media->ReadOnly)
- return EFI_WRITE_PROTECTED;
+ Media = This->Media;
+ if(Media->ReadOnly)
+ return EFI_WRITE_PROTECTED;
- if(BufferSize % Media->BlockSize != 0)
- return EFI_BAD_BUFFER_SIZE;
+ if(BufferSize % Media->BlockSize != 0)
+ return EFI_BAD_BUFFER_SIZE;
- if(LBA > Media->LastBlock)
- return EFI_DEVICE_ERROR;
+ if(LBA > Media->LastBlock)
+ return EFI_DEVICE_ERROR;
- if(LBA + BufferSize / Media->BlockSize - 1 > Media->LastBlock)
- return EFI_DEVICE_ERROR;
+ if(LBA + BufferSize / Media->BlockSize - 1 > Media->LastBlock)
+ return EFI_DEVICE_ERROR;
- RamDiskDev = RAM_DISK_FROM_THIS(This);
- RamDiskLBA = RamDiskDev->Start + MultU64x32(LBA,Media->BlockSize);
- CopyMem((VOID*)RamDiskLBA,Buffer,BufferSize);
+ RamDiskDev = RAM_DISK_FROM_THIS(This);
+ RamDiskLBA = RamDiskDev->Start + MultU64x32(LBA,Media->BlockSize);
+ CopyMem((VOID*)(UINTN)RamDiskLBA,Buffer,BufferSize);
- return EFI_SUCCESS;
+ return EFI_SUCCESS;
}
/* Implementation of block I/O flush */
STATIC EFI_STATUS RamDiskFlushBlocks(
- IN EFI_BLOCK_IO *This)
+ IN EFI_BLOCK_IO *This)
{
- return EFI_SUCCESS;
+ return EFI_SUCCESS;
}
diff --git a/Drivers/Block/ramdisk/ramdisk.h b/Drivers/Block/ramdisk/ramdisk.h
index 6cf8168..398c916 100644
--- a/Drivers/Block/ramdisk/ramdisk.h
+++ b/Drivers/Block/ramdisk/ramdisk.h
@@ -2,27 +2,27 @@
* Copyright (c) 1999, 2000
* Intel Corporation.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* 3. All advertising materials mentioning features or use of this software must
* display the following acknowledgement:
- *
+ *
* This product includes software developed by Intel Corporation and its
* contributors.
- *
+ *
* 4. Neither the name of Intel Corporation or its contributors may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -33,47 +33,49 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
*/
-#pragma pack(1)
+#ifndef _RAMDISK_H_
+#define _RAMDISK_H_
+#pragma pack(1)
/* RAM disk device path structure.
* Will use Vendor Messaging Device Path.
*/
typedef struct sRAM_DISK_DEVICE_PATH
{
- EFI_DEVICE_PATH Header;
- EFI_GUID Guid;
- UINT8 DiskId[8];
- EFI_DEVICE_PATH EndDevicePath;
+ EFI_DEVICE_PATH Header;
+ EFI_GUID Guid;
+ UINT8 DiskId[8];
+ EFI_DEVICE_PATH EndDevicePath;
} RAM_DISK_DEVICE_PATH;
/* FAT16 boot sector definition */
typedef struct sBOOTSEC
{
- UINT8 BS_jmpBoot[3];
- UINT8 BS_OEMName[8];
- UINT16 BPB_BytsPerSec;
- UINT8 BPB_SecPerClus;
- UINT16 BPB_RsvdSecCnt;
- UINT8 BPB_NumFATs;
- UINT16 BPB_RootEntCnt;
- UINT16 BPB_TotSec16;
- UINT8 BPB_Media;
- UINT16 BPB_FATSz16;
- UINT16 BPB_SecPerTrk;
- UINT16 BPB_NumHeads;
- UINT32 BPB_HiddSec;
- UINT32 BPB_TotSec32;
- UINT8 BS_DrvNum;
- UINT8 BS_Reserved1;
- UINT8 BS_BootSig;
- UINT32 BS_VolID;
- UINT8 BS_VolLab[11];
- UINT8 BS_FilSysType[8];
- UINT8 BS_Code[448];
- UINT16 BS_Sig;
+ UINT8 BS_jmpBoot[3];
+ UINT8 BS_OEMName[8];
+ UINT16 BPB_BytsPerSec;
+ UINT8 BPB_SecPerClus;
+ UINT16 BPB_RsvdSecCnt;
+ UINT8 BPB_NumFATs;
+ UINT16 BPB_RootEntCnt;
+ UINT16 BPB_TotSec16;
+ UINT8 BPB_Media;
+ UINT16 BPB_FATSz16;
+ UINT16 BPB_SecPerTrk;
+ UINT16 BPB_NumHeads;
+ UINT32 BPB_HiddSec;
+ UINT32 BPB_TotSec32;
+ UINT8 BS_DrvNum;
+ UINT8 BS_Reserved1;
+ UINT8 BS_BootSig;
+ UINT32 BS_VolID;
+ UINT8 BS_VolLab[11];
+ UINT8 BS_FilSysType[8];
+ UINT8 BS_Code[448];
+ UINT16 BS_Sig;
} BOOTSEC;
#pragma pack()
@@ -81,21 +83,21 @@ typedef struct sBOOTSEC
/* structure for total sectors to cluster size lookup */
typedef struct sFAT16TABLE
{
- UINTN size;
- UINT8 spc;
+ UINTN size;
+ UINT8 spc;
} FAT16TABLE;
-#define PBLOCK_DEVICE_SIGNATURE 'rdsk'
+#define PBLOCK_DEVICE_SIGNATURE SIGNATURE_32('r', 'd', 's', 'k')
/* Ramdisk device info structure */
typedef struct sRAM_DISKDEV
{
- UINTN Signature;
- EFI_HANDLE Handle;
- EFI_PHYSICAL_ADDRESS Start;
- EFI_BLOCK_IO BlkIo;
- EFI_BLOCK_IO_MEDIA Media;
- EFI_DEVICE_PATH *DevicePath;
+ UINTN Signature;
+ EFI_HANDLE Handle;
+ EFI_PHYSICAL_ADDRESS Start;
+ EFI_BLOCK_IO BlkIo;
+ EFI_BLOCK_IO_MEDIA Media;
+ EFI_DEVICE_PATH *DevicePath;
} RAM_DISK_DEV;
/* Macro finds the device info structure given a ramdisk BlkIo interface */
@@ -103,26 +105,29 @@ typedef struct sRAM_DISKDEV
/* Prototypes */
EFI_STATUS InitializeRamDiskDriver(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable);
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable);
STATIC VOID FormatRamdisk(
- IN VOID* pStart,
- IN UINT32 Size);
+ IN VOID* pStart,
+ IN UINT32 Size);
STATIC EFI_STATUS RamDiskReadBlocks(
- IN EFI_BLOCK_IO *This,
- IN UINT32 MediaId,
- IN EFI_LBA LBA,
- IN UINTN BufferSize,
- OUT VOID *Buffer);
+ IN EFI_BLOCK_IO *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA LBA,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer);
STATIC EFI_STATUS RamDiskWriteBlocks(
- IN EFI_BLOCK_IO *This,
- IN UINT32 MediaId,
- IN EFI_LBA LBA,
- IN UINTN BufferSize,
- IN VOID *Buffer);
+ IN EFI_BLOCK_IO *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA LBA,
+ IN UINTN BufferSize,
+ IN VOID *Buffer);
STATIC EFI_STATUS RamDiskFlushBlocks(
- IN EFI_BLOCK_IO *This);
+ IN EFI_BLOCK_IO *This);
+
+#endif
+
diff --git a/Drivers/Block/ramdisk/ramdisk.inf b/Drivers/Block/ramdisk/ramdisk.inf
new file mode 100644
index 0000000..de80e32
--- /dev/null
+++ b/Drivers/Block/ramdisk/ramdisk.inf
@@ -0,0 +1,54 @@
+#/*++
+#
+# Copyright (c) 2004, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+#
+#Mem.c
+#
+# Abstract:
+#
+# Component description file for set cmd reg module.
+#
+#--*/
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = ramdisk
+ FILE_GUID = A8D2D6E6-D256-4c7a-B835-D6D1422212DB
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = InitializeRamDiskDriver
+
+[Sources]
+ ramdisk.c
+ ramdisk.h
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ OpenPlatformPkg/OpenPlatformPkg.dec
+
+[LibraryClasses]
+ MemoryAllocationLib
+ BaseLib
+ UefiLib
+ UefiDriverEntryPoint
+ BaseMemoryLib
+ DebugLib
+ PcdLib
+ UefiBootServicesTableLib
+
+[Protocols]
+ gEfiBlockIoProtocolGuid
+ gEfiLoadedImageProtocolGuid
+[PCD]
+ gOpenPlatformTokenSpaceGuid.PcdRamDiskMaxSize
diff --git a/Drivers/ramdisk/ramdisk.mak b/Drivers/ramdisk/ramdisk.mak
deleted file mode 100644
index 39cb979..0000000
--- a/Drivers/ramdisk/ramdisk.mak
+++ /dev/null
@@ -1,95 +0,0 @@
-#
-# Copyright (c) 1999, 2000
-# Intel Corporation.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without modification,
-# are permitted provided that the following conditions are met:
-#
-# 1. Redistributions of source code must retain the above copyright notice,
-# this list of conditions and the following disclaimer.
-#
-# 2. Redistributions in binary form must reproduce the above copyright notice,
-# this list of conditions and the following disclaimer in the documentation
-# and/or other materials provided with the distribution.
-#
-# 3. All advertising materials mentioning features or use of this software must
-# display the following acknowledgement:
-#
-# This product includes software developed by Intel Corporation and its
-# contributors.
-#
-# 4. Neither the name of Intel Corporation or its contributors may be used to
-# endorse or promote products derived from this software without specific
-# prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR CONTRIBUTORS BE LIABLE FOR
-# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-#
-# Include sdk.env environment
-#
-
-!include $(SDK_INSTALL_DIR)\build\$(SDK_BUILD_ENV)\sdk.env
-
-#
-# Set the base output name and entry point
-#
-
-BASE_NAME = ramdisk
-IMAGE_ENTRY_POINT = InitializeRamDiskDriver
-
-#
-# Globals needed by master.mak
-#
-
-TARGET_BS_DRIVER = $(BASE_NAME)
-SOURCE_DIR = $(SDK_INSTALL_DIR)\protocols\$(BASE_NAME)
-BUILD_DIR = $(SDK_BUILD_DIR)\protocols\$(BASE_NAME)
-
-#
-# Include paths
-#
-
-!include $(SDK_INSTALL_DIR)\include\$(EFI_INC_DIR)\makefile.hdr
-INC = -I $(SDK_INSTALL_DIR)\include\$(EFI_INC_DIR) \
- -I $(SDK_INSTALL_DIR)\include\$(EFI_INC_DIR)\$(PROCESSOR) $(INC)
-
-#
-# Libraries
-#
-
-LIBS = $(LIBS) $(SDK_BUILD_DIR)\lib\libefi\libefi.lib
-
-#
-# Default target
-#
-
-all : dirs $(LIBS) $(OBJECTS)
-
-#
-# Program object files
-#
-
-OBJECTS = $(OBJECTS) $(BUILD_DIR)\$(BASE_NAME).obj
-
-#
-# Source file dependencies
-#
-
-$(BUILD_DIR)\$(BASE_NAME).obj : $(*B).c ramdisk.h $(INC_DEPS)
-
-#
-# Handoff to master.mak
-#
-
-!include $(SDK_INSTALL_DIR)\build\master.mak
diff --git a/Include/Guid/RamDiskGuid.h b/Include/Guid/RamDiskGuid.h
new file mode 100644
index 0000000..6d304ae
--- /dev/null
+++ b/Include/Guid/RamDiskGuid.h
@@ -0,0 +1,26 @@
+/** @file
+*
+* Copyright (c) 2015, Hisilicon Limited. All rights reserved.
+* Copyright (c) 2015, Linaro Limited. All rights reserved.
+*
+* This program and the accompanying materials
+* are licensed and made available under the terms and conditions of the BSD License
+* which accompanies this distribution. The full text of the license may be found at
+* http://opensource.org/licenses/bsd-license.php
+*
+* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+*
+**/
+
+
+#ifndef _RAM_DISK_GUID_H_
+#define _RAM_DISK_GUID_H_
+
+// {06ED4DD0-FF78-11d3-BDC4-00A0C94053D1}
+#define RAM_DISK_GUID \
+ {0x6ed4dd0, 0xff78, 0x11d3, {0xbd, 0xc4, 0x0, 0xa0, 0xc9, 0x40, 0x53, 0xd1}}
+
+extern EFI_GUID gRamDiskGuid;
+
+#endif
diff --git a/OpenPlatformPkg.dec b/OpenPlatformPkg.dec
index 2ae950b..af38488 100644
--- a/OpenPlatformPkg.dec
+++ b/OpenPlatformPkg.dec
@@ -28,9 +28,13 @@
[Guids]
gOpenPlatformTokenSpaceGuid = {0xCD7CC258, 0x31DB, 0x11E6, {0x9F, 0xD3, 0x63, 0xB0, 0xB8, 0xEF, 0xD7, 0xB6}}
+ ## Vendor GUID for RAM disk device path
+ gRamDiskGuid = {0x6ED4DD0, 0xFF78, 0x11D3, {0xBD, 0xC4, 0x00, 0xA0, 0xC9, 0x40, 0x53, 0xD1}}
[LibraryClasses]
[PcdsFixedAtBuild]
+ ## Indicates the size in MB for RAM disk.
+ gOpenPlatformTokenSpaceGuid.PcdRamDiskMaxSize|0|UINT32|0x00000001
[PcdsFeatureFlag]