1 /** @file
2   This file defines the EFI RAM Disk Protocol.
3 
4   Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
5   This program and the accompanying materials
6   are licensed and made available under the terms and conditions of the BSD License
7   which accompanies this distribution.  The full text of the license may be found at
8   http://opensource.org/licenses/bsd-license.php
9 
10   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 
13   @par Revision Reference:
14   This Protocol is introduced in UEFI Specification 2.6
15 
16 **/
17 
18 #ifndef __RAM_DISK_PROTOCOL_H__
19 #define __RAM_DISK_PROTOCOL_H__
20 
21 //
22 // EFI RAM Disk Protocol GUID value
23 //
24 #define EFI_RAM_DISK_PROTOCOL_GUID \
25   { 0xab38a0df, 0x6873, 0x44a9, { 0x87, 0xe6, 0xd4, 0xeb, 0x56, 0x14, 0x84, 0x49 }};
26 
27 //
28 // Forward reference for pure ANSI compatability
29 //
30 typedef struct _EFI_RAM_DISK_PROTOCOL  EFI_RAM_DISK_PROTOCOL;
31 
32 /**
33   Register a RAM disk with specified address, size and type.
34 
35   @param[in]  RamDiskBase    The base address of registered RAM disk.
36   @param[in]  RamDiskSize    The size of registered RAM disk.
37   @param[in]  RamDiskType    The type of registered RAM disk. The GUID can be
38                              any of the values defined in section 9.3.6.9, or a
39                              vendor defined GUID.
40   @param[in]  ParentDevicePath
41                              Pointer to the parent device path. If there is no
42                              parent device path then ParentDevicePath is NULL.
43   @param[out] DevicePath     On return, points to a pointer to the device path
44                              of the RAM disk device.
45                              If ParentDevicePath is not NULL, the returned
46                              DevicePath is created by appending a RAM disk node
47                              to the parent device path. If ParentDevicePath is
48                              NULL, the returned DevicePath is a RAM disk device
49                              path without appending. This function is
50                              responsible for allocating the buffer DevicePath
51                              with the boot service AllocatePool().
52 
53   @retval EFI_SUCCESS             The RAM disk is registered successfully.
54   @retval EFI_INVALID_PARAMETER   DevicePath or RamDiskType is NULL.
55                                   RamDiskSize is 0.
56   @retval EFI_ALREADY_STARTED     A Device Path Protocol instance to be created
57                                   is already present in the handle database.
58   @retval EFI_OUT_OF_RESOURCES    The RAM disk register operation fails due to
59                                   resource limitation.
60 
61 **/
62 typedef
63 EFI_STATUS
64 (EFIAPI *EFI_RAM_DISK_REGISTER_RAMDISK) (
65   IN UINT64                       RamDiskBase,
66   IN UINT64                       RamDiskSize,
67   IN EFI_GUID                     *RamDiskType,
68   IN EFI_DEVICE_PATH              *ParentDevicePath     OPTIONAL,
69   OUT EFI_DEVICE_PATH_PROTOCOL    **DevicePath
70   );
71 
72 /**
73   Unregister a RAM disk specified by DevicePath.
74 
75   @param[in] DevicePath      A pointer to the device path that describes a RAM
76                              Disk device.
77 
78   @retval EFI_SUCCESS             The RAM disk is unregistered successfully.
79   @retval EFI_INVALID_PARAMETER   DevicePath is NULL.
80   @retval EFI_UNSUPPORTED         The device specified by DevicePath is not a
81                                   valid ramdisk device path and not supported
82                                   by the driver.
83   @retval EFI_NOT_FOUND           The RAM disk pointed by DevicePath doesn't
84                                   exist.
85 
86 **/
87 typedef
88 EFI_STATUS
89 (EFIAPI *EFI_RAM_DISK_UNREGISTER_RAMDISK) (
90   IN  EFI_DEVICE_PATH_PROTOCOL    *DevicePath
91   );
92 
93 ///
94 /// RAM Disk Protocol structure.
95 ///
96 struct _EFI_RAM_DISK_PROTOCOL {
97   EFI_RAM_DISK_REGISTER_RAMDISK        Register;
98   EFI_RAM_DISK_UNREGISTER_RAMDISK      Unregister;
99 };
100 
101 ///
102 /// RAM Disk Protocol GUID variable.
103 ///
104 extern EFI_GUID gEfiRamDiskProtocolGuid;
105 
106 #endif
107