3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
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.
22 ScriptTableSave module at run time
26 #include "SmmScriptSave.h"
34 IN EFI_SMM_SCRIPT_TABLE
*ScriptTable
,
39 BootScriptPciCfgWrite (
40 IN EFI_SMM_SCRIPT_TABLE
*ScriptTable
,
46 IN UINT8
*Destination
,
52 // Function implementations
56 IN OUT EFI_SMM_SCRIPT_TABLE
*ScriptTable
,
65 if (ScriptTable
== NULL
) {
66 return EFI_INVALID_PARAMETER
;
70 // Build script according to opcode
74 case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE
:
75 VA_START(Marker
, OpCode
);
76 Status
= BootScriptIoWrite (ScriptTable
, Marker
);
80 case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE
:
81 VA_START(Marker
, OpCode
);
82 Status
= BootScriptPciCfgWrite(ScriptTable
, Marker
);
96 SmmBootScriptCreateTable (
97 IN OUT EFI_SMM_SCRIPT_TABLE
*ScriptTable
,
101 BOOT_SCRIPT_POINTERS Script
;
104 if (ScriptTable
== NULL
) {
105 return EFI_INVALID_PARAMETER
;
108 Buffer
= (UINT8
*) ((UINTN
)(*ScriptTable
));
114 Script
.TableInfo
->OpCode
= EFI_BOOT_SCRIPT_TABLE_OPCODE
;
115 Script
.TableInfo
->Length
= sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER
);
116 Script
.TableInfo
->TableLength
= sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER
);
119 // Update current table pointer
121 *ScriptTable
= *ScriptTable
+ sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER
);
127 SmmBootScriptCloseTable (
128 IN EFI_SMM_SCRIPT_TABLE ScriptTableBase
,
129 IN EFI_SMM_SCRIPT_TABLE ScriptTablePtr
,
133 BOOT_SCRIPT_POINTERS Script
;
136 // Add final "termination" node to script table
138 Script
.Raw
= (UINT8
*) ((UINTN
)ScriptTablePtr
);
139 Script
.Terminate
->OpCode
= EFI_BOOT_SCRIPT_TERMINATE_OPCODE
;
140 Script
.Terminate
->Length
= sizeof (EFI_BOOT_SCRIPT_TERMINATE
);
141 ScriptTablePtr
+= sizeof (EFI_BOOT_SCRIPT_TERMINATE
);
145 // Update Table Header
147 Script
.Raw
= (UINT8
*) ((UINTN
)ScriptTableBase
);
148 Script
.TableInfo
->OpCode
= EFI_BOOT_SCRIPT_TABLE_OPCODE
;
149 Script
.TableInfo
->Length
= sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER
);
150 Script
.TableInfo
->TableLength
= (UINT32
)(ScriptTablePtr
- ScriptTableBase
);
158 IN EFI_SMM_SCRIPT_TABLE
*ScriptTable
,
162 BOOT_SCRIPT_POINTERS Script
;
163 EFI_BOOT_SCRIPT_WIDTH Width
;
170 Width
= VA_ARG(Marker
, EFI_BOOT_SCRIPT_WIDTH
);
171 Address
= VA_ARG(Marker
, UINTN
);
172 Count
= VA_ARG(Marker
, UINTN
);
173 Buffer
= VA_ARG(Marker
, UINT8
*);
175 WidthInByte
= (UINT8
)(0x01 << (Width
& 0x03));
176 Script
.Raw
= (UINT8
*) ((UINTN
)(*ScriptTable
));
177 NodeLength
= sizeof (EFI_BOOT_SCRIPT_IO_WRITE
) + (WidthInByte
* Count
);
182 Script
.IoWrite
->OpCode
= EFI_BOOT_SCRIPT_IO_WRITE_OPCODE
;
183 Script
.IoWrite
->Length
= (UINT8
)(NodeLength
);
184 Script
.IoWrite
->Width
= Width
;
185 Script
.IoWrite
->Address
= Address
;
186 Script
.IoWrite
->Count
= (UINT32
)Count
;
188 (UINT8
*)(Script
.Raw
+ sizeof (EFI_BOOT_SCRIPT_IO_WRITE
)),
194 // Update Script table pointer
196 *ScriptTable
= *ScriptTable
+ NodeLength
;
202 BootScriptPciCfgWrite (
203 IN EFI_SMM_SCRIPT_TABLE
*ScriptTable
,
207 BOOT_SCRIPT_POINTERS Script
;
208 EFI_BOOT_SCRIPT_WIDTH Width
;
215 Width
= VA_ARG(Marker
, EFI_BOOT_SCRIPT_WIDTH
);
216 Address
= VA_ARG(Marker
, UINT64
);
217 Count
= VA_ARG(Marker
, UINTN
);
218 Buffer
= VA_ARG(Marker
, UINT8
*);
220 WidthInByte
= (UINT8
)(0x01 << (Width
& 0x03));
221 Script
.Raw
= (UINT8
*) ((UINTN
)(*ScriptTable
));
222 NodeLength
= sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE
) + (WidthInByte
* Count
);
227 Script
.PciWrite
->OpCode
= EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE
;
228 Script
.PciWrite
->Length
= (UINT8
)(NodeLength
);
229 Script
.PciWrite
->Width
= Width
;
230 Script
.PciWrite
->Address
= Address
;
231 Script
.PciWrite
->Count
= (UINT32
)Count
;
233 (UINT8
*)(Script
.Raw
+ sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE
)),
239 // Update Script table pointer
241 *ScriptTable
= *ScriptTable
+ NodeLength
;
247 IN UINT8
*Destination
,
254 for (Index
= 0; Index
< ByteCount
; Index
++, Destination
++, Source
++) {
255 *Destination
= *Source
;