iseries_vpdinfo.c

来自「是关于linux2.5.1的完全源码」· C语言 代码 · 共 340 行 · 第 1/2 页

C
340
字号
/************************************************************************//* File iSeries_vpdInfo.c created by Allan Trautman on Fri Feb  2 2001. *//************************************************************************//* This code gets the card location of the hardware                     *//* Copyright (C) 20yy  <Allan H Trautman> <IBM Corp>                    *//*                                                                      *//* This program is free software; you can redistribute it and/or modify *//* it under the terms of the GNU General Public License as published by *//* the Free Software Foundation; either version 2 of the License, or    *//* (at your option) any later version.                                  *//*                                                                      *//* This program is distributed in the hope that it will be useful,      */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of       *//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *//* GNU General Public License for more details.                         *//*                                                                      *//* You should have received a copy of the GNU General Public License    */ /* along with this program; if not, write to the:                       *//* Free Software Foundation, Inc.,                                      */ /* 59 Temple Place, Suite 330,                                          */ /* Boston, MA  02111-1307  USA                                          *//************************************************************************//* Change Activity:                                                     *//*   Created, Feb 2, 2001                                               *//* End Change Activity                                                  *//************************************************************************/#include <linux/config.h>#include <linux/init.h>#include <linux/pci.h>#include <asm/types.h>#include <asm/resource.h>#include <asm/iSeries/HvCallPci.h>#include <asm/iSeries/HvTypes.h>#include <asm/iSeries/mf.h>#include <asm/iSeries/LparData.h>#include <asm/iSeries/HvCallPci.h>#include <asm/iSeries/iSeries_VpdInfo.h>#include "iSeries_pci.h"/************************************************//* Size of Bus VPD data                         *//************************************************/#define BUS_VPDSIZE      1024/************************************************//* Bus Vpd Tags                                 *//************************************************/#define  VpdEndOfDataTag   0x78#define  VpdEndOfAreaTag   0x79#define  VpdIdStringTag    0x82#define  VpdVendorAreaTag  0x84/************************************************//* Mfg Area Tags                                *//************************************************/#define  VpdAsmPartNumber 0x504E     // "PN"#define  VpdFruFlag       0x4647     // "FG"#define  VpdFruLocation   0x464C     // "FL"#define  VpdFruFrameId    0x4649     // "FI"#define  VpdFruPartNumber 0x464E     // "FN"#define  VpdFruPowerData  0x5052     // "PR"#define  VpdFruSerial     0x534E     // "SN"#define  VpdFruType       0x4343     // "CC"#define  VpdFruCcinExt    0x4345     // "CE"#define  VpdFruRevision   0x5256     // "RV"#define  VpdSlotMapFormat 0x4D46     // "MF"#define  VpdSlotMap       0x534D     // "SM"/************************************************//* Structures of the areas                      *//************************************************/struct BusVpdAreaStruct {    u8  Tag;    u8  LowLength;    u8  HighLength;};typedef struct BusVpdAreaStruct BusVpdArea;#define BUS_ENTRY_SIZE   3struct MfgVpdAreaStruct {    u16 Tag;    u8  TagLength;};typedef struct MfgVpdAreaStruct MfgVpdArea;#define MFG_ENTRY_SIZE   3struct SlotMapFormatStruct {    u16 Tag;    u8  TagLength;    u16 Format;};struct FrameIdMapStruct{    u16 Tag;    u8  TagLength;    u8  FrameId;};typedef struct FrameIdMapStruct FrameIdMap;struct SlotMapStruct {    u8   AgentId;    u8   SecondaryAgentId;    u8   PhbId;    char CardLocation[3];    char Parms[8];    char Reserved[2];};typedef struct SlotMapStruct SlotMap;#define SLOT_ENTRY_SIZE   16/****************************************************************//* Prototypes                                                   *//****************************************************************/static void  iSeries_Parse_Vpd(BusVpdArea*,    int, LocationData*);static void  iSeries_Parse_MfgArea(MfgVpdArea*,int, LocationData*);static void  iSeries_Parse_SlotArea(SlotMap*,  int, LocationData*);static void  iSeries_Parse_PhbId(BusVpdArea*,  int, LocationData*);/****************************************************************//*                                                              *//*                                                              *//*                                                              *//****************************************************************/LocationData* iSeries_GetLocationData(struct pci_dev* PciDev) {    LocationData* LocationPtr = 0;    BusVpdArea*   BusVpdPtr   = 0;    int           BusVpdLen   = 0;    BusVpdPtr  = (BusVpdArea*)kmalloc(BUS_VPDSIZE, GFP_KERNEL);    BusVpdLen  = HvCallPci_getBusVpd(ISERIES_GET_LPAR_BUS(PciDev->bus->number),REALADDR(BusVpdPtr),BUS_VPDSIZE);    /* printk("PCI: VpdBuffer 0x%08X \n",(int)BusVpdPtr);          */    /***************************************************************/    /* Need to set Agent Id, Bus in location info before the call  */    /***************************************************************/    LocationPtr = (LocationData*)kmalloc(LOCATION_DATA_SIZE, GFP_KERNEL);    LocationPtr->Bus              = ISERIES_GET_LPAR_BUS(PciDev->bus->number);    LocationPtr->Board            = 0;    LocationPtr->FrameId          = 0;    iSeries_Parse_PhbId(BusVpdPtr,BusVpdLen,LocationPtr);    LocationPtr->Card             = PCI_SLOT(PciDev->devfn);    strcpy(LocationPtr->CardLocation,"Cxx");    LocationPtr->AgentId          = ISERIES_DECODE_DEVICE(PciDev->devfn);    LocationPtr->SecondaryAgentId = 0x10;    /* And for Reference only.                        */    LocationPtr->LinuxBus         = PciDev->bus->number;    LocationPtr->LinuxDevFn       = PciDev->devfn;    /***************************************************************/    /* Any data to process?                                        */    /***************************************************************/    if(BusVpdLen > 0) {	iSeries_Parse_Vpd(BusVpdPtr, BUS_VPDSIZE, LocationPtr);    }    else {	ISERIES_PCI_FR("No VPD Data....");    }    kfree(BusVpdPtr);    return LocationPtr;}/****************************************************************//*                                                              *//****************************************************************/void  iSeries_Parse_Vpd(BusVpdArea* VpdData,int VpdLen, LocationData* LocationPtr) {    MfgVpdArea* MfgVpdPtr = 0;    int         BusTagLen = 0;    BusVpdArea* BusVpdPtr = VpdData;    int         BusVpdLen = VpdLen;    /*************************************************************/    /* Make sure this is what I think it is                      */    /*************************************************************/    if(BusVpdPtr->Tag != VpdIdStringTag) {            /*0x82     */	ISERIES_PCI_FR("Not 0x82 start.");

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?