📄 sysmotvpdutil.c
字号:
* SEE ALSO: sysVpdPktParse()*/STATUS sysVpdPktGet ( UCHAR vpdType, /* target packet type */ UINT32 vpdInstance, /* instance number of desired packet (0-based) */ VPD_PACKET ** pVpdPtr, /* address of the array of packet pointers */ VPD_PACKET ** pVpdPacket /* address of the return variable */ ) { UCHAR type; /* current packet type */ VPD_PACKET * p; /* pointer to current packet */ /* if the first pointer in the array is NULL, return an error indication. */ if (*pVpdPtr == NULL) return (ERROR); do { /* get the current packet pointer */ p = *pVpdPtr; /* if the packet type matches the caller's requested type */ if ( (type = p->type) == vpdType ) { /* * see if the type is an ethernet address and has a trailing * instance value. if it does, see of the instance number matches * the caller's requested instance. */ if ( (vpdType == VPD_PID_EA) && (p->size == ENET_INSTANCE_SIZE) && (vpdInstance == p->data[ENET_INSTANCE_SIZE-1]) ) { *pVpdPacket = p; return (OK); } else { /* * see if this is the instance the caller requested, if not * decrement the instance count and go around again. */ if (vpdInstance-- == 0) { *pVpdPacket = p; return (OK); } } } /* advance to the next packet. */ pVpdPtr++; /* terminate on reaching the term packet. */ } while ( type != VPD_PID_TERM); return (ERROR); }/******************************************************************************** sysVpdPktRead - read a packet vital product data structure.** This routine searches the vpd in I2C looking for the specified * instance of a specific packet type. The routine takes the number* of data bytes to read in an effort to reduce I2C cycles.** RETURNS: OK, if successful or ERROR if unsuccessful.**/STATUS sysVpdPktRead ( UCHAR devAdrs, /* i2c address of the serial eeprom */ UCHAR devOffset, /* offset to vpd within the serial eeprom */ UCHAR vpdType, /* target packet type */ UINT32 vpdInstance, /* instance number of desired packet (0-based) */ VPD_PACKET *packet, /* pointer to packet to fill out */ UINT32 numBytes /* number of data bytes to read */ ) { UINT32 currentOffset; currentOffset = 0; do { /* Read the next vpd packet. Add the type and size to numBytes. */ if (I2C_BYTE_RANGE_READ (devAdrs, devOffset + sizeof(VPD_HEADER) + currentOffset, numBytes + 2, (UCHAR *)packet) != OK) return (ERROR); /* * Compare the type of this vpd packet. */ if (packet->type == vpdType) return (OK); currentOffset += packet->size + 2; } while ((currentOffset < VPD_EEPROM_SIZE) && (packet->type != VPD_PID_TERM)); return (ERROR); }/******************************************************************************** sysVpdPktInit - initialize a vital product data structure.** This routine reads the vital product data header from a serial eeprom and* validates it. If the header is valid, the remainder of the vpd data* is read from the serial eeprom and parsed into vpd packets for general* purpose use. If the board type is MV2100, the packets are read one* packet at a time rather than the whole 256 bytes.** RETURNS: OK, if successful or ERROR if unsuccessful.** SEE ALSO: sysVpdPktParse(), sysVpdPktGet() */STATUS sysVpdPktInit ( UCHAR devAdrs, /* i2c address of the serial eeprom */ UCHAR devOffset, /* offset to vpd within the serial eeprom */ VPD * pVpd, /* address of vpd structure */ VPD_PACKET ** pVpdPtr, /* address of packet ptr array */ UINT32 PktLimit, /* number of entries in the packet ptr array */ UINT32 parseFlag /* flag indicating to read all bytes or not */ ) {#ifdef MV2100 UINT32 currentOffset; UCHAR * currentPacketOffset; UCHAR size;#endif /* mark vpd packet pointer contents invalid. */ *pVpdPtr = NULL; /* read just the header from serial eeprom. */ if (I2C_BYTE_RANGE_READ (devAdrs, devOffset, sizeof(VPD_HEADER), (UCHAR *)pVpd) != OK) return (ERROR); /* check for a valid header */ if (sysVpdHdrVld (pVpd) != OK) return (ERROR); if (!parseFlag) return (OK); /* read the rest of the vpd from the serial eeprom. */ currentOffset = 0; currentPacketOffset = (UCHAR *)&pVpd->packets[0]; do { /* Read next packet type. */ if (I2C_BYTE_READ (devAdrs, devOffset + sizeof(VPD_HEADER) + currentOffset++, currentPacketOffset) != OK) return (ERROR); if ((*currentPacketOffset == VPD_PID_TERM) || (*currentPacketOffset == VPD_PID_GI)) break; currentPacketOffset++; /* Read the packet size. */ if (I2C_BYTE_READ (devAdrs, devOffset + sizeof(VPD_HEADER) + currentOffset++, &size) != OK) return (ERROR); *currentPacketOffset++ = size; /* Read the next vpd packet. Add the type and size to numBytes. */ if (I2C_BYTE_RANGE_READ (devAdrs, devOffset + sizeof(VPD_HEADER) + currentOffset, size, currentPacketOffset) != OK) return (ERROR); currentOffset += size; /* Add size to pointer */ currentPacketOffset += size; } while (currentOffset < VPD_EEPROM_SIZE); /* parse the raw vpd data into vpd packets. */ return (sysVpdPktParse (pVpd, pVpdPtr, PktLimit) ); }#ifdef DEBUG_VPD/********************************************************************************* debugVpdProgram - debug routine used to program VPD with test values.** This debug routine will program the VPD EEPROM with test values.* These values are probably incorrect and the actual VPD will be* defined and programmed at a later date as a part of manufacturing.* * Motorola Eyecatcher: 4d4f 544f 524f 4c41 * Size of VPD: 01 00 (256 bytes)* * Packets: type len data* -------- ---- --- ----* Product ID (MVME2100): 01 08 4d56 4d45 3234 3030 * Assembly Number (01-W): 02 04 3031 2d57 * Serial Number (9999999): 03 07 3939 3939 3939 39* Config Options: 04 10 c8ca f000 0000 0000 0000 0000 0000 0000* Intrnl Clk Spd (250MHz): 05 04 0ee6 b280* Extrnl Clk Spd (83MHz): 06 04 04f7 90d5* MPU Type (8240): 09 04 3832 3430* CRC: 0a 04 ffff ffff* Flash Type #1: 0b 0a 0089 ffff 1004 0220 2000* Flash Type #2: 0b 0a ffff ffff 0802 0208 0801* L2 Cache Type: 0e 0e ffff ffff 2002 0220 0000 0001 0201 04 * Host PCI-Bus Fq (33MHz): 0d 04 01f7 8a40 * Termination: ff ff ffff*/void debugVpdProgram ( int deviceAddress ) { int defaultVPD[128/4]; defaultVPD[0] = 0x4d4f544f; defaultVPD[1] = 0x524f4c41; defaultVPD[2] = 0x01000108; defaultVPD[3] = 0x4d564d45; defaultVPD[4] = 0x32313030; defaultVPD[5] = 0x02043031; defaultVPD[6] = 0x2d570307; defaultVPD[7] = 0x39393939; defaultVPD[8] = 0x39393904; defaultVPD[9] = 0x10c8caf0; defaultVPD[10] = 0x00000000; defaultVPD[11] = 0x00000000; defaultVPD[12] = 0x00000000; defaultVPD[13] = 0x0005040e; defaultVPD[14] = 0xe6b28006; defaultVPD[15] = 0x0404f790; defaultVPD[16] = 0xd5090438; defaultVPD[17] = 0x3234300a; defaultVPD[18] = 0x04ffffff; defaultVPD[19] = 0xff0b0a00; defaultVPD[20] = 0x89ffff10; defaultVPD[21] = 0x04022020; defaultVPD[22] = 0x000b0aff; defaultVPD[23] = 0xffffff08; defaultVPD[24] = 0x02020808; defaultVPD[25] = 0x010e0eff; defaultVPD[26] = 0xffffff20; defaultVPD[27] = 0x02022000; defaultVPD[28] = 0x00000102; defaultVPD[29] = 0x010d0401; defaultVPD[30] = 0xf78a40ff; defaultVPD[31] = 0xffffffff; I2C_BYTE_RANGE_WRITE(deviceAddress, 0, 31*4, (char *)defaultVPD); }#endif /* DEBUG_VPD */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -