summaryrefslogtreecommitdiffstats
path: root/PrmPkg/Include/PrmContextBuffer.h
blob: 8f8144545e64bcf67788ac38d2d6afeb19d10288 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/** @file

  Definitions for the Platform Runtime Mechanism (PRM) context buffer structures.

  Copyright (c) Microsoft Corporation
  SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#ifndef PRM_CONTEXT_BUFFER_H_
#define PRM_CONTEXT_BUFFER_H_

#include <PrmDataBuffer.h>
#include <PrmMmio.h>
#include <Uefi.h>

#define PRM_CONTEXT_BUFFER_SIGNATURE          SIGNATURE_32('P','R','M','C')
#define PRM_CONTEXT_BUFFER_INTERFACE_VERSION  1

#pragma pack(push, 1)

//
// This is the context buffer structure that is passed to a PRM handler.
//
// At OS runtime, the OS will allocate and populate this structure and
// place virtual addresses in the pointer fields.
//
// It is also reused internally in FW (in the PRM_MODULE_CONTEXT_BUFFERS structure)
// to track context buffers within a given PRM module. In that internal usage,
// the addresses will be physical addresses.
//
typedef struct {
  ///
  /// Signature of this interface.
  ///
  UINT32                                  Signature;

  ///
  /// Version of this interface.
  ///
  UINT16                                  Version;

  ///
  /// Reserved field.
  ///
  UINT16                                  Reserved;

  ///
  /// The GUID of the PRM handler represented by this context instance.
  ///
  EFI_GUID                                HandlerGuid;

  ///
  /// A virtual address pointer to the static data buffer allocated for
  /// the PRM handler represented by this context instance.
  ///
  /// The static buffer is intended to be populated in the PRM module
  /// configuration library and treated as read-only data at OS runtime.
  ///
  /// This pointer may be NULL if a static data buffer is not needed.
  ///
  PRM_DATA_BUFFER                         *StaticDataBuffer;

  ///
  /// A virtual address pointer to an array of PRM_RUNTIME_MMIO_RANGE
  /// structures that describe MMIO physical address ranges mapped to
  /// virtual memory addresses for access at OS runtime.
  ///
  /// This pointer is ignored in firmware internal usage of this structure
  /// as this field is present to allow a PRM handler to get the list
  /// of MMIO ranges described as accessible by its PRM module.
  ///
  /// The module list of MMIO ranges is specified by the PRM configuration
  /// code as a single array in PRM_MODULE_CONTEXT_BUFFERS.
  ///
  /// The OS is responsible for ensuring the pointer to the array in this
  /// structure is converted to a virtual address during construction of
  /// of the context buffer in the OS.
  ///
  /// This pointer may be NULL if runtime memory ranges are not needed.
  ///
  PRM_RUNTIME_MMIO_RANGES                 *RuntimeMmioRanges;
} PRM_CONTEXT_BUFFER;

//
// A firmware internal data structure used to track context buffer and
// runtime MMIO range usage across a PRM module.
//
typedef struct
{
  ///
  /// The GUID of the PRM module.
  ///
  EFI_GUID                                ModuleGuid;

  ///
  /// The number of PRM context buffers in ContextBuffers[].
  /// This count should equal the number of PRM handlers in the module being configured.
  ///
  UINTN                                   BufferCount;

  ///
  /// A pointer to an array of PRM context buffers
  ///
  PRM_CONTEXT_BUFFER                      *Buffer;

  /// The MMIO ranges are defined in the firmware boot environment.
  /// The addresses within the PRM_RUNTIME_MMIO_RANGES structure will
  /// be converted to virtual addresses by firmware.

  ///
  /// A physical address pointer to an array of PRM_RUNTIME_MMIO_RANGE
  /// structures that describe memory ranges that need to be mapped to
  /// virtual memory addresses for access at OS runtime.
  ///
  /// This is a consolidated array of MMIO ranges accessed by any PRM
  /// handler in the PRM module at OS runtime. The MMIO range physical
  /// addresses registered here will automatically be converted to the
  /// corresponding virtual address in the structure by PRM infrastructure
  /// code. No action is required to convert MMIO range base physical
  /// addresses to virtual addresses by either the PRM configuration code
  /// or the OS.
  ///
  /// This pointer may be NULL if runtime memory ranges are not needed.
  ///
  PRM_RUNTIME_MMIO_RANGES                 *RuntimeMmioRanges;
} PRM_MODULE_CONTEXT_BUFFERS;

#pragma pack(pop)

#endif