CANTxMessageBuffer * CANGetTxMessageBuffer(CAN_MODULE module, CAN_CHANNEL channel) { /* This function returns a pointer * to an available message buffer in * the channel. If the channel is full * the function will return null. */ CAN_REGISTERS * canRegisters = (CAN_REGISTERS *)canModules[module]; if(canRegisters->canFifoRegisters[channel].CxFIFOINTbits.TXNFULLIF == 1) { return((CANTxMessageBuffer *)PA_TO_KVA1(canRegisters->canFifoRegisters[channel].CxFIFOUA)); } else { return(NULL); } }
/**************************************************************************** Function: UINT32 ValidateChecksum(ROM BOOT_REGION* entry) Description: This routine will calculate the check sum for the boot region and check it against the validation code at the beginning of the boot region Precondition: The validation code is saved at the beginning of the region. *entry is word aligned Parameters: BOOT_REGION *entry - The boot region that we are calculating check sum for Returns: None ***************************************************************************/ UINT32 ValidateChecksum(ROM BOOT_REGION* entry) { DWORD check_sum; DWORD validation_code; DWORD address; // Initialize the checksum to 0xFFFFFFFF since first four bytes used for validation code check_sum = 0x00000000;//FFFFFFFF; // Read and save the validation code address = entry->addressStart; validation_code = *((DWORD *)PA_TO_KVA1(address)); // Iterate through the boot region for(address = entry->addressStart + 4; address < entry->addressEnd; address += 4) { // Read the instruction and add it towards the check sum check_sum += *((DWORD *)PA_TO_KVA1(address)); } // Return whether or not the checksum equals the validation code return (check_sum == validation_code); }
/**************************************************************************** * Function: _EthAckPacket * * PreCondition: None * * Input: pPkt - buffer/packet to be acknowledged or NULL * pRemList - list to look for done packets and to remove the packets from * pAddList - list were to add the removed packets * ackFnc - function to be called for each acknowledged buffer in turn * fParam - function argument * * Output: ETH_RES_OK - success * ETH_RES_PACKET_QUEUED - there are packets queued * ETH_RES_NO_PACKET - no packets available in the queue * * Side Effects: None * * Overview: This function acknowledges a packet. * The supplied packet has to have been completed otherwise the call will fail. * When pPkt==NULL, all packets with EOWN==0 will be acknowledged. * * Note: None *****************************************************************************/ eEthRes _EthAckPacket(const void* pPkt, sEthDcptList* pRemList, sEthDcptList* pAddList, pEthBuffAck ackFnc, void* fParam) { sEthDNode *pEDcpt; sEthDNode *prev, *next; int nAcks; int pktFound; int buffIx; prev=next=0; nAcks=pktFound=0; for(pEDcpt=pRemList->head; pEDcpt!=0; pEDcpt=next) { if(pEDcpt->hwDcpt.hdr.SOP && (pPkt==0 || pEDcpt->hwDcpt.pEDBuff==(unsigned char*)KVA_TO_PA(pPkt))) { // found the beg of a packet pktFound=1; if(pEDcpt->hwDcpt.hdr.EOWN) { break; // hw not done with it } next=pEDcpt; buffIx=0; do { pEDcpt=next; next=pEDcpt->next; while(pEDcpt->hwDcpt.hdr.EOWN); // shouldn't happen SlAddTail(pAddList, pEDcpt); // ack this node if(ackFnc) { void* pBuff; pBuff=(pEDcpt->hwDcpt.hdr.kv0?PA_TO_KVA0((int)pEDcpt->hwDcpt.pEDBuff):PA_TO_KVA1((int)pEDcpt->hwDcpt.pEDBuff)); (*ackFnc)(pBuff, buffIx++, fParam); // call user's acknowledge } }while(!pEDcpt->hwDcpt.hdr.EOP); nAcks++; // reconstruct the removed list if(prev) { prev->next=next; // prev->next_ed shouldn't matter here! } else { pRemList->head=next; } if(pPkt) { // done, just one packet ack-ed break; // done } } else { prev=pEDcpt; next=pEDcpt->next; } } return nAcks?ETH_RES_OK:(pktFound?ETH_RES_PACKET_QUEUED:ETH_RES_NO_PACKET); }