3 Copyright (c) 2004, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Definitions and macros for building register tables for chipset
21 Components linking this lib must include CpuIo, PciRootBridgeIo, and
22 BootScriptSave protocols in their DPX.
28 #ifndef EFI_REG_TABLE_H
29 #define EFI_REG_TABLE_H
32 #include "EfiScriptLib.h"
33 #include EFI_PROTOCOL_CONSUMER (CpuIo)
34 #include EFI_PROTOCOL_CONSUMER (PciRootBridgeIo)
37 // RegTable OpCodes are encoded as follows:
39 // |31----------------------------16|15---------8|7-------0|
42 // 31:16 defined by Base OpCode---+ \ \
46 #define OPCODE_BASE(OpCode) ((UINT8)((OpCode) & 0xFF))
47 #define OPCODE_FLAGS(OpCode) ((UINT8)(((OpCode) >> 8) & 0xFF))
48 #define OPCODE_EXTRA_DATA(OpCode) ((UINT16)((OpCode) >> 16))
51 // RegTable Base OpCodes
53 #define OP_TERMINATE_TABLE 0
54 #define OP_MEM_WRITE 1
55 #define OP_MEM_READ_MODIFY_WRITE 2
57 #define OP_IO_READ_MODIFY_WRITE 4
58 #define OP_PCI_WRITE 5
59 #define OP_PCI_READ_MODIFY_WRITE 6
63 // RegTable OpCode Flags
65 #define OPCODE_FLAG_S3SAVE 1
68 #define TERMINATE_TABLE { (UINT32) OP_TERMINATE_TABLE, (UINT32) 0, (UINT32) 0 }
72 // REG_TABLE_ENTRY_PCI_WRITE encodes the width in the upper bits of the OpCode
73 // as one of the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH values
79 } EFI_REG_TABLE_PCI_WRITE
;
81 #define PCI_WRITE(Bus, Dev, Fnc, Reg, Width, Data, S3Flag) \
83 (UINT32) (OP_PCI_WRITE | ((S3Flag) << 8) | ((Width) << 16)), \
84 (UINT32) (EFI_PCI_ADDRESS ((Bus), (Dev), (Fnc), (Reg))), \
94 } EFI_REG_TABLE_PCI_READ_MODIFY_WRITE
;
96 #define PCI_READ_MODIFY_WRITE(Bus, Dev, Fnc, Reg, Width, OrMask, AndMask, S3Flag) \
98 (UINT32) (OP_PCI_READ_MODIFY_WRITE | ((S3Flag) << 8) | ((Width) << 16)), \
99 (UINT32) (EFI_PCI_ADDRESS ((Bus), (Dev), (Fnc), (Reg))), \
109 } EFI_REG_TABLE_MEM_READ_MODIFY_WRITE
;
111 #define MEM_READ_MODIFY_WRITE(Address, Width, OrMask, AndMask, S3Flag) \
113 (UINT32) (OP_MEM_READ_MODIFY_WRITE | ((S3Flag) << 8) | ((Width) << 16)), \
114 (UINT32) (Address), \
124 } EFI_REG_TABLE_GENERIC
;
127 EFI_REG_TABLE_GENERIC Generic
;
128 EFI_REG_TABLE_PCI_WRITE PciWrite
;
129 EFI_REG_TABLE_PCI_READ_MODIFY_WRITE PciReadModifyWrite
;
130 EFI_REG_TABLE_MEM_READ_MODIFY_WRITE MemReadModifyWrite
;
135 EFI_REG_TABLE
* RegTableEntry
,
136 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
* PciRootBridgeIo
,
137 EFI_CPU_IO_PROTOCOL
* CpuIo
142 Processes register table assuming which may contain PCI, IO, MEM, and STALL
145 No parameter checking is done so the caller must be careful about omitting
146 values for PciRootBridgeIo or CpuIo parameters. If the regtable does
147 not contain any PCI accesses, it is safe to omit the PciRootBridgeIo (supply
148 NULL). If the regtable does not contain any IO or Mem entries, it is safe to
149 omit the CpuIo (supply NULL).
151 The RegTableEntry parameter is not checked, but is required.
153 gBS is assumed to have been defined and is used when processing stalls.
155 The function processes each entry sequentially until an OP_TERMINATE_TABLE
156 entry is encountered.
159 RegTableEntry - A pointer to the register table to process
161 PciRootBridgeIo - A pointer to the instance of PciRootBridgeIo that is used
162 when processing PCI table entries
164 CpuIo - A pointer to the instance of CpuIo that is used when processing IO and
175 EFI_REG_TABLE
* RegTableEntry
,
176 EFI_CPU_IO_PROTOCOL
* CpuIo
181 Processes register table assuming which may contain IO, MEM, and STALL
182 entries, but must NOT contain any PCI entries. Any PCI entries cause an
183 ASSERT in a DEBUG build and are skipped in a free build.
185 No parameter checking is done. Both RegTableEntry and CpuIo parameters are
188 gBS is assumed to have been defined and is used when processing stalls.
190 The function processes each entry sequentially until an OP_TERMINATE_TABLE
191 entry is encountered.
194 RegTableEntry - A pointer to the register table to process
196 CpuIo - A pointer to the instance of CpuIo that is used when processing IO and