Skip to content

Commit 4e69c18

Browse files
Eathonhsuyhsu3apop5
authored
Supports KCS command register declare (#286)
## Description KCS data and command registers may be decoded as "discontinuous," so a new PCD is added to manage the command register. For example: IO 62h/66h as KCS data and command registers. For details on how to complete these options and their meaning refer to [CONTRIBUTING.md](https://github.com/microsoft/mu/blob/HEAD/CONTRIBUTING.md). - [ ] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? ## How This Was Tested This modification does not affect the original operation. If the system declares CA2h/CA3h, make sure the IPMI KCS works as expected. ## Integration Instructions If your system KCS data and command registers may be decoded as "discontinuous," please refer this: Example: IO 62h/66h as KCS data and command registers. ```ini gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiIoBaseAddress|0x62|UINT16|0xF0000009 gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiIoCmdRegister|0x66|UINT16|0xF000000A ``` The IPMI device: Original ![IPMC_ORI](https://github.com/user-attachments/assets/b60b7701-744c-4a52-a419-e1124cb957ea) Modification ![IPMC_MOD](https://github.com/user-attachments/assets/5f099f2a-335a-4cdf-b11b-83bda4cb79f5) --------- Co-authored-by: yhsu3 <yhsu3@lenovo.com> Co-authored-by: Aaron <aaronpop@microsoft.com>
1 parent 0db2533 commit 4e69c18

6 files changed

Lines changed: 34 additions & 47 deletions

File tree

IpmiFeaturePkg/BmcAcpi/BmcAcpi.c

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ UpdateDeviceSsdtTable (
116116
{
117117
EFI_ACPI_DESCRIPTION_HEADER *TableHeader = NULL;
118118
UINT64 TempOemTableId;
119-
UINT8 *DataPtr;
120-
EFI_ACPI_IO_PORT_DESCRIPTOR *IoRsc;
121119

122120
TableHeader = (EFI_ACPI_DESCRIPTION_HEADER *)Table;
123121

@@ -130,33 +128,6 @@ UpdateDeviceSsdtTable (
130128
TableHeader->CreatorId = EFI_ACPI_CREATOR_ID;
131129
TableHeader->CreatorRevision = EFI_ACPI_CREATOR_REVISION;
132130

133-
//
134-
// Update IO(Decode16, 0xCA2, 0xCA2, 0, 2)
135-
//
136-
DEBUG ((DEBUG_INFO, "UpdateDeviceSsdtTable - IPMI\n"));
137-
for (DataPtr = (UINT8 *)(Table + 1);
138-
DataPtr < (UINT8 *)((UINT8 *)Table + Table->Length - 4);
139-
DataPtr++)
140-
{
141-
if (CompareMem (DataPtr, "_CRS", 4) == 0) {
142-
DataPtr += 4; // Skip _CRS
143-
ASSERT (*DataPtr == AML_BUFFER_OP);
144-
DataPtr++; // Skip AML_BUFFER_OP
145-
ASSERT ((*DataPtr & (BIT7|BIT6)) == 0);
146-
DataPtr++; // Skip PkgLength - 0xD
147-
ASSERT ((*DataPtr) == AML_BYTE_PREFIX);
148-
DataPtr++; // Skip BufferSize OpCode
149-
DataPtr++; // Skip BufferSize - 0xA
150-
IoRsc = (VOID *)DataPtr;
151-
ASSERT (IoRsc->Header.Bits.Type == ACPI_SMALL_ITEM_FLAG);
152-
ASSERT (IoRsc->Header.Bits.Name == ACPI_SMALL_IO_PORT_DESCRIPTOR_NAME);
153-
ASSERT (IoRsc->Header.Bits.Length == sizeof (EFI_ACPI_IO_PORT_DESCRIPTOR) - sizeof (ACPI_SMALL_RESOURCE_HEADER));
154-
DEBUG ((DEBUG_INFO, "IPMI IO Base in ASL update - 0x%04x <= 0x%04x\n", IoRsc->BaseAddressMin, PcdGet16 (PcdIpmiIoBaseAddress)));
155-
IoRsc->BaseAddressMin = PcdGet16 (PcdIpmiIoBaseAddress);
156-
IoRsc->BaseAddressMax = PcdGet16 (PcdIpmiIoBaseAddress);
157-
}
158-
}
159-
160131
return EFI_SUCCESS;
161132
}
162133

IpmiFeaturePkg/BmcAcpi/BmcAcpi.inf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
[Pcd]
3939
gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiIoBaseAddress
40+
gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiIoCmdRegister
4041
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId
4142
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId
4243

IpmiFeaturePkg/BmcAcpi/BmcSsdt/IpmiOprRegions.asi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ Device(IPMC)
4343
Name(_CRS, ResourceTemplate()
4444
{
4545
// Uses 8-bit ports 0xCA2-0xCA5
46-
IO(Decode16, 0xCA2, 0xCA2, 0, 2)
46+
IO(Decode16, FixedPcdGet8 (PcdIpmiIoBaseAddress), FixedPcdGet8 (PcdIpmiIoBaseAddress), 0, 1)
47+
IO(Decode16, FixedPcdGet8 (PcdIpmiIoCmdRegister), FixedPcdGet8 (PcdIpmiIoCmdRegister), 0, 1)
48+
4749
})
4850

4951
Name(_HID, "IPI0001") // IPMI device

IpmiFeaturePkg/IpmiFeaturePkg.dec

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@
6060
gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiCommandMaxReties|3|UINT8|0xF0000004
6161
gIpmiFeaturePkgTokenSpaceGuid.PcdBmcTimeoutSeconds|30|UINT8|0xF0000005
6262
gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiSelOemManufacturerId|{0, 0, 0}|VOID*|0xF0000007
63-
gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiIoBaseAddress|0xCA2|UINT16|0xF000000A
63+
#
64+
# KCS Status Register I/O Address (Normally CA2)
65+
#
66+
gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiIoBaseAddress|0xCA2|UINT16|0xF0000009
67+
#
68+
# KCS Command Register I/O Address (Normally CA3)
69+
#
70+
gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiIoCmdRegister|0xCA3|UINT16|0xF000000A
6471
#
6572
# IPMI Interface Type
6673
#

IpmiFeaturePkg/Library/IpmiTransportLibKcs/KcsBmc.c

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,19 @@ Routine Description:
7272
UINT8 KcsData;
7373
KCS_STATUS KcsStatus;
7474
UINT16 KcsPort;
75+
UINT16 KcsCmdReg;
7576
UINT8 RetryCount;
7677
UINT64 TimeOut;
7778

7879
KcsPort = PcdGet16 (PcdIpmiIoBaseAddress);
80+
KcsCmdReg = PcdGet16 (PcdIpmiIoCmdRegister);
7981
TimeOut = 0;
8082
RetryCount = 0;
8183
while (RetryCount < KCS_ABORT_RETRY_COUNT) {
8284
TimeOut = 0;
8385
do {
8486
MicroSecondDelay (IPMI_DELAY_UNIT);
85-
KcsStatus.RawData = IoRead8 (KcsPort + 1);
87+
KcsStatus.RawData = IoRead8 (KcsCmdReg);
8688
if ((KcsStatus.RawData == 0xFF) || (TimeOut >= IpmiTimeoutPeriod)) {
8789
RetryCount = KCS_ABORT_RETRY_COUNT;
8890
break;
@@ -96,12 +98,12 @@ Routine Description:
9698
}
9799

98100
KcsData = KCS_ABORT;
99-
IoWrite8 ((KcsPort + 1), KcsData);
101+
IoWrite8 ((KcsCmdReg), KcsData);
100102

101103
TimeOut = 0;
102104
do {
103105
MicroSecondDelay (IPMI_DELAY_UNIT);
104-
KcsStatus.RawData = IoRead8 (KcsPort + 1);
106+
KcsStatus.RawData = IoRead8 (KcsCmdReg);
105107
if ((KcsStatus.RawData == 0xFF) || (TimeOut >= IpmiTimeoutPeriod)) {
106108
Status = EFI_DEVICE_ERROR;
107109
goto LabelError;
@@ -118,7 +120,7 @@ Routine Description:
118120
TimeOut = 0;
119121
do {
120122
MicroSecondDelay (IPMI_DELAY_UNIT);
121-
KcsStatus.RawData = IoRead8 (KcsPort + 1);
123+
KcsStatus.RawData = IoRead8 (KcsCmdReg);
122124
if ((KcsStatus.RawData == 0xFF) || (TimeOut >= IpmiTimeoutPeriod)) {
123125
Status = EFI_DEVICE_ERROR;
124126
goto LabelError;
@@ -131,7 +133,7 @@ Routine Description:
131133
TimeOut = 0;
132134
do {
133135
MicroSecondDelay (IPMI_DELAY_UNIT);
134-
KcsStatus.RawData = IoRead8 (KcsPort + 1);
136+
KcsStatus.RawData = IoRead8 (KcsCmdReg);
135137
if ((KcsStatus.RawData == 0xFF) || (TimeOut >= IpmiTimeoutPeriod)) {
136138
Status = EFI_DEVICE_ERROR;
137139
goto LabelError;
@@ -149,7 +151,7 @@ Routine Description:
149151
TimeOut = 0;
150152
do {
151153
MicroSecondDelay (IPMI_DELAY_UNIT);
152-
KcsStatus.RawData = IoRead8 (KcsPort + 1);
154+
KcsStatus.RawData = IoRead8 (KcsCmdReg);
153155
if ((KcsStatus.RawData == 0xFF) || (TimeOut >= IpmiTimeoutPeriod)) {
154156
Status = EFI_DEVICE_ERROR;
155157
goto LabelError;
@@ -162,7 +164,7 @@ Routine Description:
162164
TimeOut = 0;
163165
do {
164166
MicroSecondDelay (IPMI_DELAY_UNIT);
165-
KcsStatus.RawData = IoRead8 (KcsPort + 1);
167+
KcsStatus.RawData = IoRead8 (KcsCmdReg);
166168
if ((KcsStatus.RawData == 0xFF) || (TimeOut >= IpmiTimeoutPeriod)) {
167169
Status = EFI_DEVICE_ERROR;
168170
goto LabelError;
@@ -222,6 +224,7 @@ Routine Description:
222224
EFI_STATUS Status;
223225
KCS_STATUS KcsStatus;
224226
UINT16 KcsPort;
227+
UINT16 KcsCmdReg;
225228
UINT64 TimeOut;
226229

227230
if (Idle == NULL) {
@@ -230,11 +233,12 @@ Routine Description:
230233

231234
*Idle = FALSE;
232235

233-
TimeOut = 0;
234-
KcsPort = PcdGet16 (PcdIpmiIoBaseAddress);
236+
TimeOut = 0;
237+
KcsPort = PcdGet16 (PcdIpmiIoBaseAddress);
238+
KcsCmdReg = PcdGet16 (PcdIpmiIoCmdRegister);
235239
do {
236240
MicroSecondDelay (IPMI_DELAY_UNIT);
237-
KcsStatus.RawData = IoRead8 (KcsPort + 1);
241+
KcsStatus.RawData = IoRead8 (KcsCmdReg);
238242
if ((KcsStatus.RawData == 0xFF) || (TimeOut >= IpmiTimeoutPeriod)) {
239243
Status = EFI_DEVICE_ERROR;
240244
goto LabelError;
@@ -261,7 +265,7 @@ Routine Description:
261265
TimeOut = 0;
262266
do {
263267
MicroSecondDelay (IPMI_DELAY_UNIT);
264-
KcsStatus.RawData = IoRead8 (KcsPort + 1);
268+
KcsStatus.RawData = IoRead8 (KcsCmdReg);
265269
if ((KcsStatus.RawData == 0xFF) || (TimeOut >= IpmiTimeoutPeriod)) {
266270
Status = EFI_DEVICE_ERROR;
267271
goto LabelError;
@@ -310,18 +314,19 @@ Routine Description:
310314
KCS_STATUS KcsStatus;
311315
UINT8 KcsData;
312316
UINT16 KcsIoBase;
317+
UINT16 KcsCmdReg;
313318
EFI_STATUS Status;
314319
UINT8 i;
315320
BOOLEAN Idle;
316321
UINT64 TimeOut;
317322

318323
KcsIoBase = PcdGet16 (PcdIpmiIoBaseAddress);
319-
320-
TimeOut = 0;
324+
KcsCmdReg = PcdGet16 (PcdIpmiIoCmdRegister);
325+
TimeOut = 0;
321326

322327
do {
323328
MicroSecondDelay (IPMI_DELAY_UNIT);
324-
KcsStatus.RawData = IoRead8 (KcsIoBase + 1);
329+
KcsStatus.RawData = IoRead8 (KcsCmdReg);
325330
if ((KcsStatus.RawData == 0xFF) || (TimeOut >= IpmiTimeoutPeriod)) {
326331
if ((Status = KcsErrorExit (IpmiTimeoutPeriod)) != EFI_SUCCESS) {
327332
return Status;
@@ -332,7 +337,7 @@ Routine Description:
332337
} while (KcsStatus.Status.Ibf);
333338

334339
KcsData = KCS_WRITE_START;
335-
IoWrite8 ((KcsIoBase + 1), KcsData);
340+
IoWrite8 ((KcsCmdReg), KcsData);
336341
if ((Status = KcsCheckStatus (IpmiTimeoutPeriod, KcsWriteState, &Idle)) != EFI_SUCCESS) {
337342
return Status;
338343
}
@@ -344,7 +349,7 @@ Routine Description:
344349
}
345350

346351
KcsData = KCS_WRITE_END;
347-
IoWrite8 ((KcsIoBase + 1), KcsData);
352+
IoWrite8 ((KcsCmdReg), KcsData);
348353
}
349354

350355
Status = KcsCheckStatus (IpmiTimeoutPeriod, KcsWriteState, &Idle);

IpmiFeaturePkg/Library/IpmiTransportLibKcs/KcsIpmiTransportLib.inf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@
3030

3131
[Pcd]
3232
gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiIoBaseAddress
33+
gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiIoCmdRegister

0 commit comments

Comments
 (0)