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