summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenny L. Ku <kenny.k.ku@intel.com>2019-11-23 01:27:01 +0300
committerKu, Kenny K <kenny.k.ku@intel.com>2019-11-26 03:27:15 +0300
commite1a147f6fddf3ef7fd35278fd187a1575c79a75f (patch)
treebf2c56ed97bdeafc2646bafd3dc53166d85bb9c8
parenta980a67c483738ca63aab52dcb0fb8c3044d9e52 (diff)
downloadprovingground-e1a147f6fddf3ef7fd35278fd187a1575c79a75f.tar.xz
Add peci_WrEndPointConfig_seq for sequential write
Tested: Verified with peci_cmds. Signed-off-by: Kenny K. Ku <kenny.k.ku@intel.com> Change-Id: I72ff9de2a765b5f98ec287783764f71a226cb9cf
-rw-r--r--libpeci/peci.c53
-rw-r--r--libpeci/peci.h8
2 files changed, 41 insertions, 20 deletions
diff --git a/libpeci/peci.c b/libpeci/peci.c
index 90d68b0..58079bc 100644
--- a/libpeci/peci.c
+++ b/libpeci/peci.c
@@ -897,16 +897,16 @@ EPECIStatus peci_RdEndPointConfigMmio_seq(
}
/*-------------------------------------------------------------------------
- * This internal function is the common interface for WdEndPointConfig to PCI
+ * This function allows sequential peci_WrEndPointConfig to PCI EndPoint with
+ *the provided peci file descriptor.
*------------------------------------------------------------------------*/
-static EPECIStatus peci_WrEndPointConfigCommon(uint8_t target,
- uint8_t u8MsgType, uint8_t u8Seg,
- uint8_t u8Bus, uint8_t u8Device,
- uint8_t u8Fcn, uint16_t u16Reg,
- uint8_t DataLen,
- uint32_t DataVal, uint8_t* cc)
+EPECIStatus peci_WrEndPointConfig_seq(uint8_t target, uint8_t u8MsgType,
+ uint8_t u8Seg, uint8_t u8Bus,
+ uint8_t u8Device, uint8_t u8Fcn,
+ uint16_t u16Reg, uint8_t DataLen,
+ uint32_t DataVal, int peci_fd,
+ uint8_t* cc)
{
- int peci_fd = -1;
struct peci_wr_end_pt_cfg_msg cmd;
EPECIStatus ret;
@@ -921,11 +921,6 @@ static EPECIStatus peci_WrEndPointConfigCommon(uint8_t target,
return PECI_CC_INVALID_REQ;
}
- if (peci_Open(&peci_fd) != PECI_CC_SUCCESS)
- {
- return PECI_CC_DRIVER_ERR;
- }
-
cmd.addr = target;
cmd.msg_type = u8MsgType;
cmd.params.pci_cfg.seg = u8Seg;
@@ -939,7 +934,6 @@ static EPECIStatus peci_WrEndPointConfigCommon(uint8_t target,
ret = HW_peci_issue_cmd(PECI_IOC_WR_END_PT_CFG, (char*)&cmd, peci_fd);
*cc = cmd.cc;
- peci_Close(peci_fd);
return ret;
}
@@ -952,9 +946,19 @@ EPECIStatus peci_WrEndPointPCIConfigLocal(uint8_t target, uint8_t u8Seg,
uint8_t DataLen, uint32_t DataVal,
uint8_t* cc)
{
- return peci_WrEndPointConfigCommon(target, PECI_ENDPTCFG_TYPE_LOCAL_PCI,
- u8Seg, u8Bus, u8Device, u8Fcn, u16Reg,
- DataLen, DataVal, cc);
+ int peci_fd = -1;
+ EPECIStatus ret;
+
+ if (peci_Open(&peci_fd) != PECI_CC_SUCCESS)
+ {
+ return PECI_CC_DRIVER_ERR;
+ }
+
+ ret = peci_WrEndPointConfig_seq(target, PECI_ENDPTCFG_TYPE_LOCAL_PCI, u8Seg,
+ u8Bus, u8Device, u8Fcn, u16Reg, DataLen,
+ DataVal, peci_fd, cc);
+ peci_Close(peci_fd);
+ return ret;
}
/*-------------------------------------------------------------------------
@@ -966,9 +970,18 @@ EPECIStatus peci_WrEndPointPCIConfig(uint8_t target, uint8_t u8Seg,
uint8_t DataLen, uint32_t DataVal,
uint8_t* cc)
{
- return peci_WrEndPointConfigCommon(target, PECI_ENDPTCFG_TYPE_PCI, u8Seg,
- u8Bus, u8Device, u8Fcn, u16Reg, DataLen,
- DataVal, cc);
+ int peci_fd = -1;
+ EPECIStatus ret;
+
+ if (peci_Open(&peci_fd) != PECI_CC_SUCCESS)
+ {
+ return PECI_CC_DRIVER_ERR;
+ }
+ ret = peci_WrEndPointConfig_seq(target, PECI_ENDPTCFG_TYPE_PCI, u8Seg,
+ u8Bus, u8Device, u8Fcn, u16Reg, DataLen,
+ DataVal, peci_fd, cc);
+ peci_Close(peci_fd);
+ return ret;
}
/*-------------------------------------------------------------------------
diff --git a/libpeci/peci.h b/libpeci/peci.h
index 81fba95..33b664d 100644
--- a/libpeci/peci.h
+++ b/libpeci/peci.h
@@ -209,6 +209,14 @@ EPECIStatus peci_WrEndPointPCIConfig(uint8_t target, uint8_t u8Seg,
uint8_t DataLen, uint32_t DataVal,
uint8_t* cc);
+// Allows sequential write access to the EP PCI Configuration space
+EPECIStatus peci_WrEndPointConfig_seq(uint8_t target, uint8_t u8MsgType,
+ uint8_t u8Seg, uint8_t u8Bus,
+ uint8_t u8Device, uint8_t u8Fcn,
+ uint16_t u16Reg, uint8_t DataLen,
+ uint32_t DataVal, int peci_fd,
+ uint8_t* cc);
+
// Provides access to the Crashdump Discovery API
EPECIStatus peci_CrashDump_Discovery(uint8_t target, uint8_t subopcode,
uint8_t param0, uint16_t param1,