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