bool IMBuffer::TestFrame() { bool io= ((RX_buffer.len>=sizeof(IMFrameHeader)) && (RX_buffer.len<=sizeof(IMFrame))); if (io) { io=(rSize==sizeof(IMFrame)+3); } else { DBGERR("!Size"); } if (io) { // io=crcCheck(); return io; } else { DBGERR("!LEN"); DBGERR(rSize); return io; } if (!io){ // io =( (RX_buffer.packet.Header.ReceiverId==myId) || (RX_buffer.packet.Header.ReceiverId==0)); // } else { DBGERR("!CRC"); return io; }; return io; }
bool Transceiver::Onward(IMFrame & frame) { if ((frame.Header.DestinationId==myId) || (myId==0)) { return false; //this frame is for me } else { if (!Connected()) { DBGERR("&NOTCNT"); return true; } if (frame.Header.ReceiverId==myId) { if (frame.Forward()) Forward(frame); else { Backward(frame); } } else { DBGERR("&NOTMY"); } return true; } }
/* ************************************************************************* * ReturnPacketHandler ************************************************************************* * * When NdisMIndicateReceivePacket returns asynchronously, * the protocol returns ownership of the packet to the miniport via this function. * */ VOID ReturnPacketHandler(NDIS_HANDLE MiniportAdapterContext, PNDIS_PACKET Packet) { IrDevice *thisDev = CONTEXT_TO_DEV(MiniportAdapterContext); UINT rcvBufIndex; DBGOUT(("ReturnPacketHandler(0x%x)", (UINT)MiniportAdapterContext)); /* * The rcv buffer index is cached in the MiniportReserved field of the packet. */ rcvBufIndex = *(UINT *)Packet->MiniportReserved; if (rcvBufIndex < NUM_RCV_BUFS){ if (thisDev->rcvBufs[rcvBufIndex].state == STATE_PENDING){ PNDIS_BUFFER ndisBuf; DBGPKT(("Reclaimed rcv packet 0x%x.", (UINT)Packet)); NdisUnchainBufferAtFront(Packet, &ndisBuf); if (ndisBuf){ NdisFreeBuffer(ndisBuf); } thisDev->rcvBufs[rcvBufIndex].state = STATE_FREE; } else { DBGERR(("Packet in ReturnPacketHandler was not PENDING.")); } } else { DBGERR(("Bad rcvBufIndex (from corrupted MiniportReserved) in ReturnPacketHandler.")); } }
/************************************************************************ * Function Name : hc_parse_trans * * This function checks the status of the transmitted or received packet * and copy the data from the SL811HS register into a buffer. * * 1) Check the status of the packet * 2) If successful, and IN packet then copy the data from the SL811HS register * into a buffer * * Input: hci = data structure for the host controller * actbytes = pointer to actual number of bytes * data = data buffer * cc = packet status * length = the urb transmit length * pid = packet ID * urb_state = the current stage of USB transaction * * Return: 0 ***********************************************************************/ static inline int hc_parse_trans (hci_t * hci, int *actbytes, __u8 * data, int *cc, int *toggle, int length, int pid, int urb_state) { __u8 addr; __u8 len; DBGFUNC ("enter hc_parse_trans\n"); /* get packet status; convert ack rcvd to ack-not-rcvd */ *cc = (int) SL811Read (hci, SL11H_PKTSTATREG); if (*cc & (SL11H_STATMASK_ERROR | SL11H_STATMASK_TMOUT | SL11H_STATMASK_OVF | SL11H_STATMASK_NAK | SL11H_STATMASK_STALL)) { if (*cc & SL11H_STATMASK_OVF) DBGERR ("parse trans: error recv ack, cc = 0x%x, TX_BASE_Len = " "0x%x, TX_count=0x%x\n", *cc, SL811Read (hci, SL11H_BUFLNTHREG), SL811Read (hci, SL11H_XFERCNTREG)); } else { DBGVERBOSE ("parse trans: recv ack, cc = 0x%x, len = 0x%x, \n", *cc, length); /* Successful data */ if ((pid == PID_IN) && (urb_state != US_CTRL_SETUP)) { /* Find the base address */ addr = SL811Read (hci, SL11H_BUFADDRREG); /* Find the Transmit Length */ len = SL811Read (hci, SL11H_BUFLNTHREG); /* The actual data length = xmit length reg - xfer count reg */ *actbytes = len - SL811Read (hci, SL11H_XFERCNTREG); if ((data != NULL) && (*actbytes > 0)) { SL811BufRead (hci, addr, data, *actbytes); } else if ((data == NULL) && (*actbytes <= 0)) { DBGERR ("hc_parse_trans: data = NULL or actbyte = 0x%x\n", *actbytes); return 0; } } else if (pid == PID_OUT) { *actbytes = length; } else { // printk ("ERR:parse_trans, pid != IN or OUT, pid = 0x%x\n", pid); } *toggle = !*toggle; } return 0; }
bool CmdResult::validateR6Response() { if(error!=Ok) return validateError(); if((response & 0xe008)==0) return true; DBGERR("CMD%d: R6 response error(s):\n",cmd); if(response & (1<<15)) DBGERR("command CRC failed\n"); if(response & (1<<14)) DBGERR("illegal command\n"); if(response & (1<<13)) DBGERR("unknown error\n"); if(response & (1<<3)) DBGERR("AKE_SEQ error\n"); return false; }
int cmmbmemo_valueinit(struct file *file) { struct cmmb_memory *cmmbmemo = file->private_data; int ret = 0; DBG("[CMMB HW]:[memory]: enter cmmb memo open\n"); cmmbmemo->video_buf = NULL; cmmbmemo->audio_buf = NULL; cmmbmemo->data_buf = NULL; cmmbmemo->video_buf = kzalloc(CMMB_VIDEO_BUFFER_SIZE+1, GFP_KERNEL); if (cmmbmemo->video_buf == NULL){ ret = - ENOMEM; DBGERR("[CMMB HW]:[memory]:[err]: cmmb video buffer malloc fail!!!\n"); goto kmalloc_fail; } cmmbmemo->audio_buf = kzalloc(CMMB_AUDIO_BUFFER_SIZE+1, GFP_KERNEL); if (cmmbmemo->audio_buf == NULL){ ret = - ENOMEM; DBGERR("[CMMB HW]:[memory]:[err]: cmmb audio buffer malloc fail!!!\n"); goto kmalloc_fail; } cmmbmemo->data_buf = kzalloc(1, GFP_KERNEL); if (cmmbmemo->data_buf == NULL){ ret = - ENOMEM; DBGERR("[CMMB HW]:[memory]:[err]: cmmb data buffer malloc fail!!!\n"); goto kmalloc_fail; } //hzb@20100415,init av ring buffers,cmmb need three ring buffers to store the demuxed data cmmb_ringbuffer_init(&cmmbmemo->buffer_Video, cmmbmemo->video_buf, CMMB_VIDEO_BUFFER_SIZE); //init video ring buffer cmmb_ringbuffer_init(&cmmbmemo->buffer_Audio, cmmbmemo->audio_buf, CMMB_AUDIO_BUFFER_SIZE); //init audio ring buffer cmmb_ringbuffer_init(&cmmbmemo->buffer_Data, cmmbmemo->data_buf, 1); //init data ring buffer cmmbmemo->w_datatype = CMMB_NULL_TYPE; cmmbmemo->r_datatype = CMMB_NULL_TYPE; return ret; kmalloc_fail: kfree(cmmbmemo->video_buf); kfree(cmmbmemo->audio_buf); kfree(cmmbmemo->data_buf); return ret; }
/** * \internal * Used for debugging, print 8 bit error code from SD card */ static void print_error_code(unsigned char value) { switch(value) { case 0x40: DBGERR("Parameter error\n"); break; case 0x20: DBGERR("Address error\n"); break; case 0x10: DBGERR("Erase sequence error\n"); break; case 0x08: DBGERR("CRC error\n"); break; case 0x04: DBGERR("Illegal command\n"); break; case 0x02: DBGERR("Erase reset\n"); break; case 0x01: DBGERR("Card is initializing\n"); break; default: DBGERR("Unknown error 0x%x\n",value); break; } }
/** * \internal * Return 1 if card is OK, otherwise print 16 bit error code from SD card */ static char sd_status() { short value=send_cmd(CMD13,0); value<<=8; value|=spi_1_send(0xff); switch(value) { case 0x0000: return 1; case 0x0001: DBGERR("Card is Locked\n"); /*//Try to fix the problem by erasing all the SD card. char e=send_cmd(CMD16,1); if(e!=0) print_error_code(e); e=send_cmd(CMD42,0); if(e!=0) print_error_code(e); spi_1_send(0xfe); // Start block spi_1_send(1<<3); //Erase all disk command spi_1_send(0xff); // Checksum part 1 spi_1_send(0xff); // Checksum part 2 e=spi_1_send(0xff); iprintf("Reached here 0x%x\n",e);//Should return 0xe5 while(spi_1_send(0xff)!=0xff);*/ break; case 0x0002: DBGERR("WP erase skip or lock/unlock cmd failed\n"); break; case 0x0004: DBGERR("General error\n"); break; case 0x0008: DBGERR("Internal card controller error\n"); break; case 0x0010: DBGERR("Card ECC failed\n"); break; case 0x0020: DBGERR("Write protect violation\n"); break; case 0x0040: DBGERR("Invalid selection for erase\n"); break; case 0x0080: DBGERR("Out of range or CSD overwrite\n"); break; default: if(value>0x00FF) print_error_code((unsigned char)(value>>8)); else DBGERR("Unknown error 0x%x\n",value); break; }
bool Disk::write(const unsigned char *buffer, unsigned int lba, unsigned char nSectors) { DBG("Disk::write(): nSectors=%d\n",nSectors); if(!BufferConverter::isWordAligned(buffer)) DBG("Buffer misaligned\n"); for(int i=0;i<ClockController::getRetryCount();i++) { //Select card CardSelector selector; if(selector.succeded()==false) continue; if(nSectors==1) { if(singleBlockWrite(buffer,lba)==false) continue; } else { // Multiple block write // Currently implemented with N calls to single block write const unsigned char *tempBuffer=buffer; unsigned int tempLba=lba; for(unsigned int i=0;i<nSectors;i++) { if(singleBlockWrite(tempBuffer,tempLba)==false) continue; tempBuffer+=512; tempLba++; } } if(i>0) DBGERR("Write: required %d retries\n",i); return true; } return false; }
/*************************************************************************** * Function Name : regTest * * This routine test the Read/Write functionality of SL811HS registers * * 1) Store original register value into a buffer * 2) Write to registers with a RAMP pattern. (10, 11, 12, ..., 255) * 3) Read from register * 4) Compare the written value with the read value and make sure they are * equivalent * 5) Restore the original register value * * Input: hci = data structure for the host controller * * * Return: TRUE = passed; FALSE = failed **************************************************************************/ int regTest (hci_t * hci) { int i, data, result = TRUE; char buf[256]; DBGFUNC ("Enter regTest\n"); for (i = 0x10; i < 256; i++) { /* save the original buffer */ buf[i] = (char) SL811Read (hci, i); /* Write the new data to the buffer */ SL811Write (hci, i, i); } /* compare the written data */ for (i = 0x10; i < 256; i++) { data = SL811Read (hci, i); if (data != i) { DBGERR ("Pattern test failed!! value = 0x%x, s/b 0x%x\n", data, i); result = FALSE; } } /* restore the data */ for (i = 0x10; i < 256; i++) { SL811Write (hci, i, buf[i]); } return (result); }
// BUGBUG: Arguments are reversed from as documented in April '96 MSDN! NDIS_STATUS MiniportReset(PBOOLEAN AddressingReset, NDIS_HANDLE MiniportAdapterContext) { IrDevice *dev, *thisDev = CONTEXT_TO_DEV(MiniportAdapterContext); NDIS_STATUS result = NDIS_STATUS_SUCCESS; DBGOUT(("MiniportReset(0x%x)", (UINT)MiniportAdapterContext)); /* BUGBUG: fixed; REMOVE ??? * Verify that the context is not bogus. * I've seen bad contexts getting passed in when the system gets corrupted. */ for (dev = firstIrDevice; dev && (dev != thisDev); dev = dev->next){ } if (!dev){ DBGERR(("Bad context in MiniportReset")); return NDIS_STATUS_FAILURE; } DoClose(thisDev); CloseDevice(thisDev); OpenDevice(thisDev); DoOpen(thisDev); *AddressingReset = TRUE; DBGOUT(("MiniportReset done.")); return result; }
/* ************************************************************************* * AllocateCompleteHandler ************************************************************************* * * Indicate completion of an NdisMAllocateSharedMemoryAsync call. * We never call that function, so we should never get entered here. * */ VOID AllocateCompleteHandler( NDIS_HANDLE MiniportAdapterContext, PVOID VirtualAddress, PNDIS_PHYSICAL_ADDRESS PhysicalAddress, ULONG Length, PVOID Context) { DBGERR(("AllocateCompleteHandler - should not get called")); }
int cmmb_register_device(struct cmmb_adapter *adap, struct cmmb_device **pcmmbdev, struct file_operations *fops, void *priv, int type,char* name) { struct cmmb_device *cmmbdev; struct file_operations *cmmbdevfops; struct device *clsdev; DBG("[CMMB HW]:[class]:cmmb_register_device\n"); *pcmmbdev = cmmbdev = kmalloc(sizeof(struct cmmb_device), GFP_KERNEL); if(!pcmmbdev) { DBGERR("[CMMB HW]:[class]:[err]: cmmb register device cmmbdev malloc fail!!!\n"); return -ENOMEM; } cmmbdevfops = kzalloc(sizeof(struct file_operations), GFP_KERNEL); if (!cmmbdevfops){ DBGERR("[CMMB HW]:[class]:[err]: cmmb register device cmmbdevfops malloc fail!!!\n"); kfree (cmmbdev); return -ENOMEM; } cmmbdev->type = type; cmmbdev->adapter = adap; cmmbdev->priv = priv; cmmbdev->fops = cmmbdevfops; init_waitqueue_head (&cmmbdev->wait_queue); memcpy(cmmbdev->fops, fops, sizeof(struct file_operations)); cmmbdev->fops->owner = THIS_MODULE; list_add_tail (&cmmbdev->list_head, &adap->device_list); clsdev = device_create(cmmb_class, adap->device,MKDEV(CMMB_MAJOR, type),NULL,name); if (IS_ERR(clsdev)) { DBGERR("[CMMB HW]:[class]:[err]: creat dev fail!!!\n"); return PTR_ERR(clsdev); } return 0; }
NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) { NTSTATUS result = STATUS_SUCCESS, stat; NDIS_HANDLE wrapperHandle; NDIS40_MINIPORT_CHARACTERISTICS info; DBGOUT(("==> IRMINI_Entry()")); NdisMInitializeWrapper( (PNDIS_HANDLE)&wrapperHandle, DriverObject, RegistryPath, NULL ); DBGOUT(("Wrapper handle is %xh", (UINT)wrapperHandle)); info.MajorNdisVersion = (UCHAR)NDIS_MAJOR_VERSION; info.MinorNdisVersion = (UCHAR)NDIS_MINOR_VERSION; // info.Flags = 0; info.CheckForHangHandler = MiniportCheckForHang; info.HaltHandler = MiniportHalt; info.InitializeHandler = MiniportInitialize; info.QueryInformationHandler = MiniportQueryInformation; info.ReconfigureHandler = MiniportReconfigure; info.ResetHandler = MiniportReset; info.SendHandler = MiniportSend; info.SetInformationHandler = MiniportSetInformation; info.TransferDataHandler = MiniportTransferData; info.HandleInterruptHandler = MiniportHandleInterrupt; info.ISRHandler = MiniportISR; info.DisableInterruptHandler = MiniportDisableInterrupt; info.EnableInterruptHandler = MiniportEnableInterrupt; /* * New NDIS 4.0 fields */ info.ReturnPacketHandler = ReturnPacketHandler; info.SendPacketsHandler = SendPacketsHandler; info.AllocateCompleteHandler = AllocateCompleteHandler; stat = NdisMRegisterMiniport( wrapperHandle, (PNDIS_MINIPORT_CHARACTERISTICS)&info, sizeof(NDIS_MINIPORT_CHARACTERISTICS)); if (stat != NDIS_STATUS_SUCCESS){ DBGERR(("NdisMRegisterMiniport failed in DriverEntry")); result = STATUS_UNSUCCESSFUL; goto _entryDone; } _entryDone: DBGOUT(("<== IRMINI_Entry %s", (PUCHAR)((result == NDIS_STATUS_SUCCESS) ? "succeeded" : "failed"))); return result; }
LOCAL void ICACHE_FLASH_ATTR buttonTask(void *pvParameters) { static uint32_t messageId = 0; uint8_t loopIndex; uint8_t currentValue; uint8_t remoteRequest[50] = {0}; uint32_t remoteRequestLength; DBGINF(("Button task initiated")); vTaskDelay(100); DBGINF(("Button task running")); for (loopIndex = 0; loopIndex < CTNC_MAX_NUMBER_OF_RESOURCE; loopIndex++) { if (CTNC_RES_TYPE_BINARY_INPUT == fResource[loopIndex].type) { PIN_FUNC_SELECT(fResource[loopIndex].gpioName, fResource[loopIndex].gpioFunc); PIN_PULLUP_EN(fResource[loopIndex].gpioName); //GPIO_DIS_OUTPUT(GPIO_ID_PIN(fResource[loopIndex].gpioNumber)); gpio_output_set(0, BIT(GPIO_ID_PIN(fResource[loopIndex].gpioNumber)), 0,0); } } DBGINF(("All resource output set to current values.")); while (1) { for (loopIndex = 0; loopIndex < CTNC_MAX_NUMBER_OF_RESOURCE; loopIndex++) { fResource[loopIndex].lacheValue++; currentValue = GPIO_READ(fResource[loopIndex].gpioNumber); if ( (currentValue != fResource[loopIndex].value) || (fResource[loopIndex].lacheValue >= 5000) ) { fResource[loopIndex].value = currentValue; fResource[loopIndex].lacheValue = 0; messageId++; remoteRequestLength = snprintf( &remoteRequest[0], 50, "/%d/%s/%s/uresval/%d/%d", messageId, MESH_getNodeID(), MESH_getNodeID(), fResource[loopIndex].id, fResource[loopIndex].value); for (loopIndex = 0; loopIndex < 4; loopIndex++) { sendUDPData(remoteRequest, remoteRequestLength); vTaskDelay(50); } break; } } vTaskDelay(CTNC_BTN_TASK_SLEEP); } DBGERR(("QUITING BUTTON TASK, This is never expected")); vTaskDelete(NULL); }
bool Transceiver::GetFrame(IMFrame& frame) { // if (GetData()) { frame=buffer->RX_buffer.packet; bool io =( (frame.Header.ReceiverId==myId) || (frame.Header.ReceiverId==0)); if (!io) { DBGERR("Address"); DBGERR(frame.Header.ReceiverId); }; // if (io){ io= frame.checkCRC(); // } if (!io) { DBGERR("!!CRC "); DBGERR(frame.CRC()); }; DBGINFO(" RSSI: "); DBGINFO(Rssi()); DBGINFO("dBm "); return io; }
bool CmdResult::validateError() { switch(error) { case Ok: return true; case Timeout: DBGERR("CMD%d: Timeout\n",cmd); break; case CRCFail: DBGERR("CMD%d: CRC Fail\n",cmd); break; case RespNotMatch: DBGERR("CMD%d: Response does not match\n",cmd); break; case ACMDFail: DBGERR("CMD%d: ACMD Fail\n",cmd); break; } return false; }
VOID NTAPI ClassFreeOrReuseSrb(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PSCSI_REQUEST_BLOCK Srb) /*++ Routine Description: This routine will attempt to reuse the provided SRB to start a blocked read/write request. If there is no need to reuse the request it will be returned to the SRB lookaside list. Arguments: Fdo - the device extension Srb - the SRB which is to be reused or freed. Return Value: none. --*/ { PCOMMON_DEVICE_EXTENSION commonExt = &FdoExtension->CommonExtension; //KIRQL oldIrql; //PIRP blockedIrp; // This function is obsolete, but still called by DISK.SYS . // DBGWARN(("ClassFreeOrReuseSrb is OBSOLETE !")); // // safety net. this should never occur. if it does, it's a potential // memory leak. // ASSERT(!TEST_FLAG(Srb->SrbFlags, SRB_FLAGS_FREE_SENSE_BUFFER)); if (commonExt->IsSrbLookasideListInitialized){ /* * Put the SRB back in our lookaside list. * * BUGBUG - Some class drivers use ClassIoComplete * to complete SRBs that they themselves allocated. * So we may be putting a "foreign" SRB * (e.g. with a different pool tag) into our lookaside list. */ ClasspFreeSrb(FdoExtension, Srb); } else { DBGERR(("ClassFreeOrReuseSrb: someone is trying to use an uninitialized SrbLookasideList !!!")); ExFreePool(Srb); } }
/***************************************************************** * * Function Name: hc_found_hci * * This function request IO memory regions, request IRQ, and * allocate all other resources. * * Input: addr = first IO address * addr2 = second IO address * irq = interrupt number * * Return: 0 = success or error condition * *****************************************************************/ static int __devinit hc_found_hci (int addr, int addr2, int irq) { hci_t *hci; hcipriv_t *hp; DBGFUNC ("Enter hc_found_hci\n"); hci = hc_alloc_hci (); if (!hci) { return -ENOMEM; } init_irq (); hp = &hci->hp; if (!request_region (addr, 256, "SL811 USB HOST")) { DBGERR ("request address %d failed", addr); hc_release_hci (hci); return -EBUSY; } hp->hcport = addr; if (!hp->hcport) { DBGERR ("Error mapping SL811 Memory 0x%x", hp->hcport); } if (!request_region (addr2, 256, "SL811 USB HOST")) { DBGERR ("request address %d failed", addr2); hc_release_hci (hci); return -EBUSY; } hp->hcport2 = addr2; if (!hp->hcport2) { DBGERR ("Error mapping SL811 Memory 0x%x", hp->hcport2); } if (hc_alloc_trans_buffer (hci)) { hc_release_hci (hci); return -ENOMEM; } usb_register_bus (hci->bus); if (request_irq (irq, hc_interrupt, 0, "SL811", hci) != 0) { DBGERR ("request interrupt %d failed", irq); hc_release_hci (hci); return -EBUSY; } hp->irq = irq; printk (KERN_INFO __FILE__ ": USB SL811 at %x, addr2 = %x, IRQ %d\n", addr, addr2, irq); hc_reset (hci); if (hc_start (hci) < 0) { DBGERR ("can't start usb-%x", addr); hc_release_hci (hci); return -EBUSY; } return 0; }
bool IMBuffer::Send() { while (ruptures[TransceiverRead]){ DBGERR("?? READ ??"); } state=TransceiverWrite; TX_buffer.len=sizeof(TX_buffer.packet); if (cc1101.SendData((uint8_t*)&(TX_buffer.packet),TX_buffer.len)) { // while (state==TransceiverWrite) // Wait for GDO0 to be cleared -> end of packet // DBGINFO("?"); // DBGINFO(state); return true; } else { DBGERR("! SEND"); DBGERR(cc1101.errState); state=TransceiverIdle; // cc1101.Reinit(); return false; } }
/** * \internal * Wait until the card is ready for data transfer. * Can be called independently of the card being selected. * \return true on success, false on failure */ bool waitForCardReady() { for(int i=0;i<300;i++) //Timeout 1.5 second { CmdResult cr=Command::send(Command::CMD13,Command::getRca()<<16); if(cr.validateR1Response()==false) return false; //Bit 8 in R1 response means ready for data. if(cr.getResponse() & (1<<8)) return true; Thread::sleep(5); } DBGERR("Timeout waiting card ready\n"); return false; }
bool DataResult::validateError() { switch(error) { case Ok: return true; case Timeout: DBGERR("Data Timeout\n"); break; case CRCFail: DBGERR("Data CRC Fail\n"); break; case RXOverrun: DBGERR("Data overrun\n"); break; case TXUnderrun: DBGERR("Data underrun\n"); break; case StartBitFail: DBGERR("Data start bit Fail\n"); break; } return false; }
static void tca6424_gpio_set_value(struct gpio_chip *gc, unsigned pin_num, int val) { struct tca6424_chip *chip; uint8_t gpioPortNum; uint8_t gpioPortPinNum; uint8_t reg_val; uint8_t Regaddr; int ret=-1; chip = container_of(gc, struct tca6424_chip, gpio_chip); gpioPortNum = pin_num/8; gpioPortPinNum= pin_num%8; if((gpioPortNum>=TCA6424_PortNum)||(gpioPortPinNum>=portnum[gpioPortNum])) return; Regaddr = TCA6424_OutputLevel_Reg+gpioPortNum; if(tca6424getbit(chip->gtca6424_struct.reg_direction[gpioPortNum],gpioPortPinNum)) // input state { return; } #ifdef TCA6424_OUTREGLOCK if (!mutex_trylock(&chip->outreglock)) { DBGERR("**%s[%d] Did not get the outreglock**\n",__FUNCTION__,__LINE__); return; } #endif if(((chip->gtca6424_struct.reg_output[gpioPortNum]>>gpioPortPinNum)& 0x01) != val) { if(val) reg_val = tca6424setbit(chip->gtca6424_struct.reg_output[gpioPortNum], gpioPortPinNum); else reg_val = tca6424clearbit(chip->gtca6424_struct.reg_output[gpioPortNum], gpioPortPinNum); ret = tca6424_write_reg(chip->client, Regaddr, reg_val); if (ret<0) goto err; chip->gtca6424_struct.reg_output[gpioPortNum] = reg_val; //DBG("**%s[%d],set output address[0x%2x]=%2x,ret=%d**\n",__FUNCTION__,__LINE__,Regaddr,reg_val,ret); } err: #ifdef TCA6424_OUTREGLOCK mutex_unlock(&chip->outreglock); #endif return; }
/* * ClassSplitRequest * * This is a legacy exported function. * It is called by storage miniport driver that have their own * StartIo routine when the transfer size is too large for the hardware. * We map it to our new read/write handler. */ VOID NTAPI ClassSplitRequest(IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN ULONG MaximumBytes) { PFUNCTIONAL_DEVICE_EXTENSION fdoExt = Fdo->DeviceExtension; PCLASS_PRIVATE_FDO_DATA fdoData = fdoExt->PrivateFdoData; if (MaximumBytes > fdoData->HwMaxXferLen) { DBGERR(("ClassSplitRequest - driver requesting split to size that " "hardware is unable to handle!\n")); } if (MaximumBytes < fdoData->HwMaxXferLen){ DBGWARN(("ClassSplitRequest - driver requesting smaller HwMaxXferLen " "than required")); fdoData->HwMaxXferLen = MAX(MaximumBytes, PAGE_SIZE); } ServiceTransferRequest(Fdo, Irp); }
/* ************************************************************************* * MiniportHalt ************************************************************************* * * Halts the network interface card. * */ VOID MiniportHalt(IN NDIS_HANDLE MiniportAdapterContext) { IrDevice *thisDev = CONTEXT_TO_DEV(MiniportAdapterContext); DBGOUT(("MiniportHalt(0x%x)", (UINT)MiniportAdapterContext)); /* * Remove this device from our global list */ if (thisDev == firstIrDevice){ firstIrDevice = firstIrDevice->next; } else { IrDevice *dev; for (dev = firstIrDevice; dev && (dev->next != thisDev); dev = dev->next){ } if (dev){ dev->next = dev->next->next; } else { /* * Don't omit this error check. I've seen NDIS call MiniportHalt with * a bogus context when the system gets corrupted. */ DBGERR(("Bad context in MiniportHalt")); return; } } /* * Now destroy the device object. */ DoClose(thisDev); NdisMDeregisterIoPortRange( thisDev->ndisAdapterHandle, thisDev->portInfo.ioBase, 8, (PVOID)thisDev->mappedPortRange); FreeDevice(thisDev); }
bool Transceiver::ForwardHello(IMFrame & frame) { IMFrameSetup setup_recv; frame.Get(&setup_recv); IMAddress a=frame.Header.SenderId; if (frame.Onward()) // first hop { frame.Header.DestinationId=serverId; frame.Header.SourceId=myId; // server should know where send welcome a=0; // register MAC with no addres (no bypass) frame.Setup()->rssi=buffer->rssiH; // send RSSI to server } if (!router.addMAC(setup_recv.MAC,a)){ DBGERR("ERRADDMAC"); Deconnect(); buffer->Reboot(); ; } return Forward(frame); }
/* ************************************************************************* * MiniportTransferData ************************************************************************* * * * Copies the contents of the received packet to a specified packet buffer. * * * */ NDIS_STATUS MiniportTransferData ( OUT PNDIS_PACKET Packet, OUT PUINT BytesTransferred, IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_HANDLE MiniportReceiveContext, IN UINT ByteOffset, IN UINT BytesToTransfer ) { DBGERR(("MiniportTransferData - should not get called.")); /* * We always pass the entire packet up in the indicate-receive call, * so we will never get this callback. * (We can't do anything but return failure anyway, * since NdisMIndicateReceivePacket does not pass up a packet context). */ *BytesTransferred = 0; return NDIS_STATUS_FAILURE; }
static int tca6424_gpio_direction_input(struct gpio_chip *gc, unsigned pin_num) { struct tca6424_chip *chip; uint8_t gpioPortNum; uint8_t gpioPortPinNum; uint8_t reg_val; uint8_t Regaddr; int ret = -1; chip = container_of(gc, struct tca6424_chip, gpio_chip); gpioPortNum = pin_num/8; gpioPortPinNum= pin_num%8; if((gpioPortNum>=TCA6424_PortNum)||(gpioPortPinNum>=portnum[gpioPortNum])) return ret; Regaddr = TCA6424_Config_Reg+gpioPortNum; #ifdef TCA6424_CONFIGREGLOCK if (!mutex_trylock(&chip->configreglock)) { DBGERR("**%s[%d]Did not get the configreglock**\n",__FUNCTION__,__LINE__); return -1; } #endif if(((chip->gtca6424_struct.reg_direction[gpioPortNum]>>gpioPortPinNum)& 0x01)==EXTGPIO_OUTPUT) { reg_val = tca6424setbit(chip->gtca6424_struct.reg_direction[gpioPortNum], gpioPortPinNum); ret = tca6424_write_reg(chip->client, Regaddr, reg_val); if(ret<0) goto err; chip->gtca6424_struct.reg_direction[gpioPortNum] = reg_val; //DBG("**%s[%d],set config address[0x%2x]=%2x,ret=%d**\n",__FUNCTION__,__LINE__,Regaddr,reg_val,ret); } err: #ifdef TCA6424_CONFIGREGLOCK mutex_unlock(&chip->configreglock); #endif return (ret<0)?-1:0; }
static int tca6424_gpio_get_value(struct gpio_chip *gc, unsigned pin_num) { struct tca6424_chip *chip; uint8_t gpioPortNum; uint8_t gpioPortPinNum; uint8_t Regaddr; int ret; chip = container_of(gc, struct tca6424_chip, gpio_chip); #ifdef CONFIG_EXPAND_GPIO_SOFT_INTERRUPT ret = wait_untill_input_reg_flash( ); if(ret<0) { return -1; DBGERR("**********tca6424 get value error***************\n"); } #endif gpioPortNum = pin_num/8; gpioPortPinNum= pin_num%8; Regaddr = TCA6424_OutputLevel_Reg+gpioPortNum; if((gpioPortNum>=TCA6424_PortNum)||(gpioPortPinNum>=portnum[gpioPortNum])) return -1; #ifndef CONFIG_EXPAND_GPIO_SOFT_INTERRUPT uint8_t reg_val; ret = tca6424_read_reg(chip->client, Regaddr, ®_val); if (ret < 0) return -1; chip->gtca6424_struct.reg_input[gpioPortNum] = reg_val; #endif //DBG("**%s[%d] read input address[0x%2x]=%2x**\n",__FUNCTION__,__LINE__,Regaddr,chip->reg_input[gpioPortNum]); return ((chip->gtca6424_struct.reg_input[gpioPortNum] >> gpioPortPinNum) & 0x01); }
static int tca6424_remove(struct i2c_client *client) { struct tca6424_platform_data *pdata = client->dev.platform_data; struct tca6424_chip *chip = i2c_get_clientdata(client); int ret = 0; if (pdata->teardown) { ret = pdata->teardown(client, chip->gpio_chip.base, chip->gpio_chip.ngpio, pdata->context); if (ret < 0) { DBGERR(" %s failed, %d\n",__FUNCTION__,ret); return ret; } } ret = gpiochip_remove(&chip->gpio_chip); if (ret) { dev_err(&client->dev, "%s failed, %d\n", "gpiochip_remove()", ret); return ret; } kfree(chip); return 0; }