📄 ls-caps.c
字号:
FLAG(cmd, PCI_HT_SEC_CMD_WR), FLAG(cmd, PCI_HT_SEC_CMD_DE), (cmd & PCI_HT_SEC_CMD_DN) >> 2, FLAG(cmd, PCI_HT_SEC_CMD_CS), FLAG(cmd, PCI_HT_SEC_CMD_HH), FLAG(cmd, PCI_HT_SEC_CMD_AS), FLAG(cmd, PCI_HT_SEC_CMD_HIECE), FLAG(cmd, PCI_HT_SEC_CMD_DUL)); lctr = get_conf_word(d, where + PCI_HT_SEC_LCTR); if (rid >= 0x22) fmt = "\t\tLink Control: CFlE%c CST%c CFE%c <LkFail%c Init%c EOC%c TXO%c <CRCErr=%x IsocEn%c LSEn%c ExtCTL%c 64b%c\n"; else fmt = "\t\tLink Control: CFlE%c CST%c CFE%c <LkFail%c Init%c EOC%c TXO%c <CRCErr=%x\n"; printf(fmt, FLAG(lctr, PCI_HT_LCTR_CFLE), FLAG(lctr, PCI_HT_LCTR_CST), FLAG(lctr, PCI_HT_LCTR_CFE), FLAG(lctr, PCI_HT_LCTR_LKFAIL), FLAG(lctr, PCI_HT_LCTR_INIT), FLAG(lctr, PCI_HT_LCTR_EOC), FLAG(lctr, PCI_HT_LCTR_TXO), (lctr & PCI_HT_LCTR_CRCERR) >> 8, FLAG(lctr, PCI_HT_LCTR_ISOCEN), FLAG(lctr, PCI_HT_LCTR_LSEN), FLAG(lctr, PCI_HT_LCTR_EXTCTL), FLAG(lctr, PCI_HT_LCTR_64B)); lcnf = get_conf_word(d, where + PCI_HT_SEC_LCNF); if (rid >= 0x22) fmt = "\t\tLink Config: MLWI=%1$s DwFcIn%5$c MLWO=%2$s DwFcOut%6$c LWI=%3$s DwFcInEn%7$c LWO=%4$s DwFcOutEn%8$c\n"; else fmt = "\t\tLink Config: MLWI=%s MLWO=%s LWI=%s LWO=%s\n"; printf(fmt, ht_link_width(lcnf & PCI_HT_LCNF_MLWI), ht_link_width((lcnf & PCI_HT_LCNF_MLWO) >> 4), ht_link_width((lcnf & PCI_HT_LCNF_LWI) >> 8), ht_link_width((lcnf & PCI_HT_LCNF_LWO) >> 12), FLAG(lcnf, PCI_HT_LCNF_DFI), FLAG(lcnf, PCI_HT_LCNF_DFO), FLAG(lcnf, PCI_HT_LCNF_DFIE), FLAG(lcnf, PCI_HT_LCNF_DFOE)); printf("\t\tRevision ID: %u.%02u\n", (rid & PCI_HT_RID_MAJ) >> 5, (rid & PCI_HT_RID_MIN)); if (rid < 0x22) return; lfrer = get_conf_byte(d, where + PCI_HT_SEC_LFRER); printf("\t\tLink Frequency: %s\n", ht_link_freq(lfrer & PCI_HT_LFRER_FREQ)); printf("\t\tLink Error: <Prot%c <Ovfl%c <EOC%c CTLTm%c\n", FLAG(lfrer, PCI_HT_LFRER_PROT), FLAG(lfrer, PCI_HT_LFRER_OV), FLAG(lfrer, PCI_HT_LFRER_EOC), FLAG(lfrer, PCI_HT_LFRER_CTLT)); lfcap = get_conf_byte(d, where + PCI_HT_SEC_LFCAP); printf("\t\tLink Frequency Capability: 200MHz%c 300MHz%c 400MHz%c 500MHz%c 600MHz%c 800MHz%c 1.0GHz%c 1.2GHz%c 1.4GHz%c 1.6GHz%c Vend%c\n", FLAG(lfcap, PCI_HT_LFCAP_200), FLAG(lfcap, PCI_HT_LFCAP_300), FLAG(lfcap, PCI_HT_LFCAP_400), FLAG(lfcap, PCI_HT_LFCAP_500), FLAG(lfcap, PCI_HT_LFCAP_600), FLAG(lfcap, PCI_HT_LFCAP_800), FLAG(lfcap, PCI_HT_LFCAP_1000), FLAG(lfcap, PCI_HT_LFCAP_1200), FLAG(lfcap, PCI_HT_LFCAP_1400), FLAG(lfcap, PCI_HT_LFCAP_1600), FLAG(lfcap, PCI_HT_LFCAP_VEND)); ftr = get_conf_word(d, where + PCI_HT_SEC_FTR); printf("\t\tFeature Capability: IsocFC%c LDTSTOP%c CRCTM%c ECTLT%c 64bA%c UIDRD%c ExtRS%c UCnfE%c\n", FLAG(ftr, PCI_HT_FTR_ISOCFC), FLAG(ftr, PCI_HT_FTR_LDTSTOP), FLAG(ftr, PCI_HT_FTR_CRCTM), FLAG(ftr, PCI_HT_FTR_ECTLT), FLAG(ftr, PCI_HT_FTR_64BA), FLAG(ftr, PCI_HT_FTR_UIDRD), FLAG(ftr, PCI_HT_SEC_FTR_EXTRS), FLAG(ftr, PCI_HT_SEC_FTR_UCNFE)); if (ftr & PCI_HT_SEC_FTR_EXTRS) { eh = get_conf_word(d, where + PCI_HT_SEC_EH); printf("\t\tError Handling: PFlE%c OFlE%c PFE%c OFE%c EOCFE%c RFE%c CRCFE%c SERRFE%c CF%c RE%c PNFE%c ONFE%c EOCNFE%c RNFE%c CRCNFE%c SERRNFE%c\n", FLAG(eh, PCI_HT_EH_PFLE), FLAG(eh, PCI_HT_EH_OFLE), FLAG(eh, PCI_HT_EH_PFE), FLAG(eh, PCI_HT_EH_OFE), FLAG(eh, PCI_HT_EH_EOCFE), FLAG(eh, PCI_HT_EH_RFE), FLAG(eh, PCI_HT_EH_CRCFE), FLAG(eh, PCI_HT_EH_SERRFE), FLAG(eh, PCI_HT_EH_CF), FLAG(eh, PCI_HT_EH_RE), FLAG(eh, PCI_HT_EH_PNFE), FLAG(eh, PCI_HT_EH_ONFE), FLAG(eh, PCI_HT_EH_EOCNFE), FLAG(eh, PCI_HT_EH_RNFE), FLAG(eh, PCI_HT_EH_CRCNFE), FLAG(eh, PCI_HT_EH_SERRNFE)); mbu = get_conf_byte(d, where + PCI_HT_SEC_MBU); mlu = get_conf_byte(d, where + PCI_HT_SEC_MLU); printf("\t\tPrefetchable memory behind bridge Upper: %02x-%02x\n", mbu, mlu); }}static voidcap_ht(struct device *d, int where, int cmd){ int type; switch (cmd & PCI_HT_CMD_TYP_HI) { case PCI_HT_CMD_TYP_HI_PRI: cap_ht_pri(d, where, cmd); return; case PCI_HT_CMD_TYP_HI_SEC: cap_ht_sec(d, where, cmd); return; } type = cmd & PCI_HT_CMD_TYP; switch (type) { case PCI_HT_CMD_TYP_SW: printf("HyperTransport: Switch\n"); break; case PCI_HT_CMD_TYP_IDC: printf("HyperTransport: Interrupt Discovery and Configuration\n"); break; case PCI_HT_CMD_TYP_RID: printf("HyperTransport: Revision ID: %u.%02u\n", (cmd & PCI_HT_RID_MAJ) >> 5, (cmd & PCI_HT_RID_MIN)); break; case PCI_HT_CMD_TYP_UIDC: printf("HyperTransport: UnitID Clumping\n"); break; case PCI_HT_CMD_TYP_ECSA: printf("HyperTransport: Extended Configuration Space Access\n"); break; case PCI_HT_CMD_TYP_AM: printf("HyperTransport: Address Mapping\n"); break; case PCI_HT_CMD_TYP_MSIM: printf("HyperTransport: MSI Mapping Enable%c Fixed%c\n", FLAG(cmd, PCI_HT_MSIM_CMD_EN), FLAG(cmd, PCI_HT_MSIM_CMD_FIXD)); if (verbose >= 2 && !(cmd & PCI_HT_MSIM_CMD_FIXD)) { u32 offl, offh; if (!config_fetch(d, where + PCI_HT_MSIM_ADDR_LO, 8)) break; offl = get_conf_long(d, where + PCI_HT_MSIM_ADDR_LO); offh = get_conf_long(d, where + PCI_HT_MSIM_ADDR_HI); printf("\t\tMapping Address Base: %016llx\n", ((unsigned long long)offh << 32) | (offl & ~0xfffff)); } break; case PCI_HT_CMD_TYP_DR: printf("HyperTransport: DirectRoute\n"); break; case PCI_HT_CMD_TYP_VCS: printf("HyperTransport: VCSet\n"); break; case PCI_HT_CMD_TYP_RM: printf("HyperTransport: Retry Mode\n"); break; case PCI_HT_CMD_TYP_X86: printf("HyperTransport: X86 (reserved)\n"); break; default: printf("HyperTransport: #%02x\n", type >> 11); }}static voidcap_msi(struct device *d, int where, int cap){ int is64; u32 t; u16 w; printf("MSI: Mask%c 64bit%c Count=%d/%d Enable%c\n", FLAG(cap, PCI_MSI_FLAGS_MASK_BIT), FLAG(cap, PCI_MSI_FLAGS_64BIT), 1 << ((cap & PCI_MSI_FLAGS_QSIZE) >> 4), 1 << ((cap & PCI_MSI_FLAGS_QMASK) >> 1), FLAG(cap, PCI_MSI_FLAGS_ENABLE)); if (verbose < 2) return; is64 = cap & PCI_MSI_FLAGS_64BIT; if (!config_fetch(d, where + PCI_MSI_ADDRESS_LO, (is64 ? PCI_MSI_DATA_64 : PCI_MSI_DATA_32) + 2 - PCI_MSI_ADDRESS_LO)) return; printf("\t\tAddress: "); if (is64) { t = get_conf_long(d, where + PCI_MSI_ADDRESS_HI); w = get_conf_word(d, where + PCI_MSI_DATA_64); printf("%08x", t); } else w = get_conf_word(d, where + PCI_MSI_DATA_32); t = get_conf_long(d, where + PCI_MSI_ADDRESS_LO); printf("%08x Data: %04x\n", t, w); if (cap & PCI_MSI_FLAGS_MASK_BIT) { u32 mask, pending; if (is64) { if (!config_fetch(d, where + PCI_MSI_MASK_BIT_64, 8)) return; mask = get_conf_long(d, where + PCI_MSI_MASK_BIT_64); pending = get_conf_long(d, where + PCI_MSI_PENDING_64); } else { if (!config_fetch(d, where + PCI_MSI_MASK_BIT_32, 8)) return; mask = get_conf_long(d, where + PCI_MSI_MASK_BIT_32); pending = get_conf_long(d, where + PCI_MSI_PENDING_32); } printf("\t\tMasking: %08x Pending: %08x\n", mask, pending); }}static float power_limit(int value, int scale){ static const float scales[4] = { 1.0, 0.1, 0.01, 0.001 }; return value * scales[scale];}static const char *latency_l0s(int value){ static const char *latencies[] = { "<64ns", "<128ns", "<256ns", "<512ns", "<1us", "<2us", "<4us", "unlimited" }; return latencies[value];}static const char *latency_l1(int value){ static const char *latencies[] = { "<1us", "<2us", "<4us", "<8us", "<16us", "<32us", "<64us", "unlimited" }; return latencies[value];}static void cap_express_dev(struct device *d, int where, int type){ u32 t; u16 w; t = get_conf_long(d, where + PCI_EXP_DEVCAP); printf("\t\tDevCap:\tMaxPayload %d bytes, PhantFunc %d, Latency L0s %s, L1 %s\n", 128 << (t & PCI_EXP_DEVCAP_PAYLOAD), (1 << ((t & PCI_EXP_DEVCAP_PHANTOM) >> 3)) - 1, latency_l0s((t & PCI_EXP_DEVCAP_L0S) >> 6), latency_l1((t & PCI_EXP_DEVCAP_L1) >> 9)); printf("\t\t\tExtTag%c", FLAG(t, PCI_EXP_DEVCAP_EXT_TAG)); if ((type == PCI_EXP_TYPE_ENDPOINT) || (type == PCI_EXP_TYPE_LEG_END) || (type == PCI_EXP_TYPE_UPSTREAM) || (type == PCI_EXP_TYPE_PCI_BRIDGE)) printf(" AttnBtn%c AttnInd%c PwrInd%c", FLAG(t, PCI_EXP_DEVCAP_ATN_BUT), FLAG(t, PCI_EXP_DEVCAP_ATN_IND), FLAG(t, PCI_EXP_DEVCAP_PWR_IND)); printf(" RBE%c FLReset%c", FLAG(t, PCI_EXP_DEVCAP_RBE), FLAG(t, PCI_EXP_DEVCAP_FLRESET)); if (type == PCI_EXP_TYPE_UPSTREAM) printf("SlotPowerLimit %fW", power_limit((t & PCI_EXP_DEVCAP_PWR_VAL) >> 18, (t & PCI_EXP_DEVCAP_PWR_SCL) >> 26)); printf("\n"); w = get_conf_word(d, where + PCI_EXP_DEVCTL); printf("\t\tDevCtl:\tReport errors: Correctable%c Non-Fatal%c Fatal%c Unsupported%c\n", FLAG(w, PCI_EXP_DEVCTL_CERE), FLAG(w, PCI_EXP_DEVCTL_NFERE), FLAG(w, PCI_EXP_DEVCTL_FERE), FLAG(w, PCI_EXP_DEVCTL_URRE)); printf("\t\t\tRlxdOrd%c ExtTag%c PhantFunc%c AuxPwr%c NoSnoop%c", FLAG(w, PCI_EXP_DEVCTL_RELAXED), FLAG(w, PCI_EXP_DEVCTL_EXT_TAG), FLAG(w, PCI_EXP_DEVCTL_PHANTOM), FLAG(w, PCI_EXP_DEVCTL_AUX_PME), FLAG(w, PCI_EXP_DEVCTL_NOSNOOP)); if (type == PCI_EXP_TYPE_PCI_BRIDGE || type == PCI_EXP_TYPE_PCIE_BRIDGE) printf(" BrConfRtry%c", FLAG(w, PCI_EXP_DEVCTL_BCRE)); if (type == PCI_EXP_TYPE_ENDPOINT && (t & PCI_EXP_DEVCAP_FLRESET)) printf(" FLReset%c", FLAG(w, PCI_EXP_DEVCTL_FLRESET)); printf("\n\t\t\tMaxPayload %d bytes, MaxReadReq %d bytes\n", 128 << ((w & PCI_EXP_DEVCTL_PAYLOAD) >> 5), 128 << ((w & PCI_EXP_DEVCTL_READRQ) >> 12)); w = get_conf_word(d, where + PCI_EXP_DEVSTA); printf("\t\tDevSta:\tCorrErr%c UncorrErr%c FatalErr%c UnsuppReq%c AuxPwr%c TransPend%c\n", FLAG(w, PCI_EXP_DEVSTA_CED), FLAG(w, PCI_EXP_DEVSTA_NFED), FLAG(w, PCI_EXP_DEVSTA_FED), FLAG(w, PCI_EXP_DEVSTA_URD), FLAG(w, PCI_EXP_DEVSTA_AUXPD), FLAG(w, PCI_EXP_DEVSTA_TRPND));}static char *link_speed(int speed){ switch (speed) { case 1: return "2.5GT/s"; case 2: return "5GT/s"; default: return "unknown"; }}static char *aspm_support(int code){ switch (code) { case 1: return "L0s"; case 3: return "L0s L1"; default: return "unknown"; }}static const char *aspm_enabled(int code){ static const char *desc[] = { "Disabled", "L0s Enabled", "L1 Enabled", "L0s L1 Enabled" }; return desc[code];}static void cap_express_link(struct device *d, int where, int type){ u32 t; u16 w; t = get_conf_long(d, where + PCI_EXP_LNKCAP); printf("\t\tLnkCap:\tPort #%d, Speed %s, Width x%d, ASPM %s, Latency L0 %s, L1 %s\n", t >> 24, link_speed(t & PCI_EXP_LNKCAP_SPEED), (t & PCI_EXP_LNKCAP_WIDTH) >> 4, aspm_support((t & PCI_EXP_LNKCAP_ASPM) >> 10), latency_l0s((t & PCI_EXP_LNKCAP_L0S) >> 12), latency_l1((t & PCI_EXP_LNKCAP_L1) >> 15)); printf("\t\t\tClockPM%c Surprise%c LLActRep%c BwNot%c\n", FLAG(t, PCI_EXP_LNKCAP_CLOCKPM), FLAG(t, PCI_EXP_LNKCAP_SURPRISE), FLAG(t, PCI_EXP_LNKCAP_DLLA), FLAG(t, PCI_EXP_LNKCAP_LBNC)); w = get_conf_word(d, where + PCI_EXP_LNKCTL); printf("\t\tLnkCtl:\tASPM %s;", aspm_enabled(w & PCI_EXP_LNKCTL_ASPM)); if ((type == PCI_EXP_TYPE_ROOT_PORT) || (type == PCI_EXP_TYPE_ENDPOINT) || (type == PCI_EXP_TYPE_LEG_END)) printf(" RCB %d bytes", w & PCI_EXP_LNKCTL_RCB ? 128 : 64); printf(" Disabled%c Retrain%c CommClk%c\n\t\t\tExtSynch%c ClockPM%c AutWidDis%c BWInt%c AutBWInt%c\n", FLAG(w, PCI_EXP_LNKCTL_DISABLE), FLAG(w, PCI_EXP_LNKCTL_RETRAIN), FLAG(w, PCI_EXP_LNKCTL_CLOCK), FLAG(w, PCI_EXP_LNKCTL_XSYNCH), FLAG(w, PCI_EXP_LNKCTL_CLOCKPM), FLAG(w, PCI_EXP_LNKCTL_HWAUTWD), FLAG(w, PCI_EXP_LNKCTL_BWMIE), FLAG(w, PCI_EXP_LNKCTL_AUTBWIE)); w = get_conf_word(d, where + PCI_EXP_LNKSTA); printf("\t\tLnkSta:\tSpeed %s, Width x%d, TrErr%c Train%c SlotClk%c DLActive%c BWMgmt%c ABWMgmt%c\n", link_speed(w & PCI_EXP_LNKSTA_SPEED), (w & PCI_EXP_LNKSTA_WIDTH) >> 4, FLAG(w, PCI_EXP_LNKSTA_TR_ERR), FLAG(w, PCI_EXP_LNKSTA_TRAIN), FLAG(w, PCI_EXP_LNKSTA_SL_CLK), FLAG(w, PCI_EXP_LNKSTA_DL_ACT), FLAG(w, PCI_EXP_LNKSTA_BWMGMT), FLAG(w, PCI_EXP_LNKSTA_AUTBW));}static const char *indicator(int code){ static const char *names[] = { "Unknown", "On", "Blink", "Off" }; return names[code];}static void cap_express_slot(struct device *d, int where){ u32 t; u16 w; t = get_conf_long(d, where + PCI_EXP_SLTCAP); printf("\t\tSltCap:\tAttnBtn%c PwrCtrl%c MRL%c AttnInd%c PwrInd%c HotPlug%c Surpise%c\n", FLAG(t, PCI_EXP_SLTCAP_ATNB), FLAG(t, PCI_EXP_SLTCAP_PWRC), FLAG(t, PCI_EXP_SLTCAP_MRL), FLAG(t, PCI_EXP_SLTCAP_ATNI), FLAG(t, PCI_EXP_SLTCAP_PWRI), FLAG(t, PCI_EXP_SLTCAP_HPC), FLAG(t, PCI_EXP_SLTCAP_HPS)); printf("\t\t\tSlot #%3x, PowerLimit %f; Interlock%c NoCompl%c\n", t >> 19, power_limit((t & PCI_EXP_SLTCAP_PWR_VAL) >> 7, (t & PCI_EXP_SLTCAP_PWR_SCL) >> 15), FLAG(t, PCI_EXP_SLTCAP_INTERLOCK), FLAG(t, PCI_EXP_SLTCAP_NOCMDCOMP)); w = get_conf_word(d, where + PCI_EXP_SLTCTL); printf("\t\tSltCtl:\tEnable: AttnBtn%c PwrFlt%c MRL%c PresDet%c CmdCplt%c HPIrq%c LinkChg%c\n", FLAG(w, PCI_EXP_SLTCTL_ATNB), FLAG(w, PCI_EXP_SLTCTL_PWRF), FLAG(w, PCI_EXP_SLTCTL_MRLS), FLAG(w, PCI_EXP_SLTCTL_PRSD), FLAG(w, PCI_EXP_SLTCTL_CMDC), FLAG(w, PCI_EXP_SLTCTL_HPIE), FLAG(w, PCI_EXP_SLTCTL_LLCHG)); printf("\t\t\tControl: AttnInd %s, PwrInd %s, Power%c Interlock%c\n", indicator((w & PCI_EXP_SLTCTL_ATNI) >> 6), indicator((w & PCI_EXP_SLTCTL_PWRI) >> 8), FLAG(w, PCI_EXP_SLTCTL_PWRC), FLAG(w, PCI_EXP_SLTCTL_INTERLOCK)); w = get_conf_word(d, where + PCI_EXP_SLTSTA); printf("\t\tSltSta:\tStatus: AttnBtn%c PowerFlt%c MRL%c CmdCplt%c PresDet%c Interlock%c\n", FLAG(w, PCI_EXP_SLTSTA_ATNB), FLAG(w, PCI_EXP_SLTSTA_PWRF), FLAG(w, PCI_EXP_SLTSTA_MRL_ST), FLAG(w, PCI_EXP_SLTSTA_CMDC),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -