Vishal Bhoj | 82c8071 | 2015-12-15 21:13:33 +0530 | [diff] [blame^] | 1 | /*
|
| 2 | * Copyright (c) 1999, 2000
|
| 3 | * Intel Corporation.
|
| 4 | * All rights reserved.
|
| 5 | * Copyright (c) Huawei Technologies Co., Ltd. 2013. All rights reserved.
|
| 6 | *
|
| 7 | * Redistribution and use in source and binary forms, with or without modification,
|
| 8 | * are permitted provided that the following conditions are met:
|
| 9 | *
|
| 10 | * 1. Redistributions of source code must retain the above copyright notice,
|
| 11 | * this list of conditions and the following disclaimer.
|
| 12 | *
|
| 13 | * 2. Redistributions in binary form must reproduce the above copyright notice,
|
| 14 | * this list of conditions and the following disclaimer in the documentation
|
| 15 | * and/or other materials provided with the distribution.
|
| 16 | *
|
| 17 | * 3. All advertising materials mentioning features or use of this software must
|
| 18 | * display the following acknowledgement:
|
| 19 | *
|
| 20 | * This product includes software developed by Intel Corporation and its
|
| 21 | * contributors.
|
| 22 | *
|
| 23 | * 4. Neither the name of Intel Corporation or its contributors may be used to
|
| 24 | * endorse or promote products derived from this software without specific
|
| 25 | * prior written permission.
|
| 26 | *
|
| 27 | * THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION AND CONTRIBUTORS ``AS IS'' AND
|
| 28 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
| 29 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
| 30 | * DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR CONTRIBUTORS BE LIABLE FOR
|
| 31 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
| 32 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
| 33 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
| 34 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 35 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
| 36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 37 | *
|
| 38 | */
|
| 39 |
|
| 40 | #ifndef _FATFILESYSTEM_H_
|
| 41 | #define _FATFILESYSTEM_H_
|
| 42 |
|
| 43 | #pragma pack(1)
|
| 44 | /* RAM disk device path structure.
|
| 45 | * Will use Vendor Messaging Device Path.
|
| 46 | */
|
| 47 | typedef struct sRAM_DISK_DEVICE_PATH
|
| 48 | {
|
| 49 | EFI_DEVICE_PATH Header;
|
| 50 | EFI_GUID Guid;
|
| 51 | UINT8 DiskId[8];
|
| 52 | EFI_DEVICE_PATH EndDevicePath;
|
| 53 | } RAM_DISK_DEVICE_PATH;
|
| 54 |
|
| 55 | /* FAT16 boot sector definition */
|
| 56 | typedef struct sBOOTSEC
|
| 57 | {
|
| 58 | UINT8 BS_jmpBoot[3];
|
| 59 | UINT8 BS_OEMName[8];
|
| 60 | UINT16 BPB_BytsPerSec;
|
| 61 | UINT8 BPB_SecPerClus;
|
| 62 | UINT16 BPB_RsvdSecCnt;
|
| 63 | UINT8 BPB_NumFATs;
|
| 64 | UINT16 BPB_RootEntCnt;
|
| 65 | UINT16 BPB_TotSec16;
|
| 66 | UINT8 BPB_Media;
|
| 67 | UINT16 BPB_FATSz16;
|
| 68 | UINT16 BPB_SecPerTrk;
|
| 69 | UINT16 BPB_NumHeads;
|
| 70 | UINT32 BPB_HiddSec;
|
| 71 | UINT32 BPB_TotSec32;
|
| 72 | UINT8 BS_DrvNum;
|
| 73 | UINT8 BS_Reserved1;
|
| 74 | UINT8 BS_BootSig;
|
| 75 | UINT32 BS_VolID;
|
| 76 | UINT8 BS_VolLab[11];
|
| 77 | UINT8 BS_FilSysType[8];
|
| 78 | UINT8 BS_Code[448];
|
| 79 | UINT16 BS_Sig;
|
| 80 | } BOOTSEC;
|
| 81 |
|
| 82 | #pragma pack()
|
| 83 |
|
| 84 | /* structure for total sectors to cluster size lookup */
|
| 85 | typedef struct sFAT16TABLE
|
| 86 | {
|
| 87 | UINTN size;
|
| 88 | UINT8 spc;
|
| 89 | } FAT16TABLE;
|
| 90 |
|
| 91 | #define PBLOCK_DEVICE_SIGNATURE SIGNATURE_32('r', 'd', 's', 'k')
|
| 92 |
|
| 93 | /* Ramdisk device info structure */
|
| 94 | typedef struct sRAM_DISKDEV
|
| 95 | {
|
| 96 | UINTN Signature;
|
| 97 | EFI_HANDLE Handle;
|
| 98 | EFI_PHYSICAL_ADDRESS Start;
|
| 99 | EFI_BLOCK_IO BlkIo;
|
| 100 | EFI_BLOCK_IO_MEDIA Media;
|
| 101 | EFI_DEVICE_PATH *DevicePath;
|
| 102 | } RAM_DISK_DEV;
|
| 103 |
|
| 104 | /* Macro finds the device info structure given a ramdisk BlkIo interface */
|
| 105 | #define RAM_DISK_FROM_THIS(a) CR(a,RAM_DISK_DEV,BlkIo,PBLOCK_DEVICE_SIGNATURE)
|
| 106 |
|
| 107 | /* Prototypes */
|
| 108 | EFI_STATUS InitializeRamDiskDriver(
|
| 109 | IN EFI_HANDLE ImageHandle,
|
| 110 | IN EFI_SYSTEM_TABLE *SystemTable);
|
| 111 |
|
| 112 | STATIC VOID FormatRamdisk(
|
| 113 | IN VOID* pStart,
|
| 114 | IN UINT32 Size);
|
| 115 |
|
| 116 | STATIC EFI_STATUS RamDiskReadBlocks(
|
| 117 | IN EFI_BLOCK_IO *This,
|
| 118 | IN UINT32 MediaId,
|
| 119 | IN EFI_LBA LBA,
|
| 120 | IN UINTN BufferSize,
|
| 121 | OUT VOID *Buffer);
|
| 122 |
|
| 123 | STATIC EFI_STATUS RamDiskWriteBlocks(
|
| 124 | IN EFI_BLOCK_IO *This,
|
| 125 | IN UINT32 MediaId,
|
| 126 | IN EFI_LBA LBA,
|
| 127 | IN UINTN BufferSize,
|
| 128 | IN VOID *Buffer);
|
| 129 |
|
| 130 | STATIC EFI_STATUS RamDiskFlushBlocks(
|
| 131 | IN EFI_BLOCK_IO *This);
|
| 132 |
|
| 133 | #endif
|
| 134 |
|