BOOL cif_drv_unload (void) { DEV_INSTANCE * dev = cif_devices; DBG_PRN("unloading driver\n"); // OS wants to unload driver while (dev) { // deallocate memory, free irq if ( dev->usBoardIrq) { DBG_PRN("free Irq %d for board %d\n", dev->usBoardIrq, dev->usBoard); // Disable physical interrupt on the hardware cif_set_irq_state( HW_INTERRUPT_DISABLE, dev); free_irq( (unsigned int)(dev->usBoardIrq), dev); } DBG_PRN("unmap pDPMBase\n"); if ( ( dev->bActive == TRUE) && ( dev->pDpmBase != NULL) ) { iounmap( dev->ptDpmAddress); iounmap( dev->pbDpmReceiveArea); iounmap( dev->pbDpmSendArea); } dev = (DEV_INSTANCE *)dev->next; } DBG_PRN("Cleanup done!\n"); return (TRUE); // always TRUE if driver is static }
int cif_init_dev_pci (struct pci_dev *pDev, unsigned short index, u32 ulDPMByteSize) { DEV_INSTANCE *dev; DBG_PRN("ulDPMByteSize = %d\n", ulDPMByteSize); if( cif_nr_devs == 0) { DBG_PRN("cif_nr_devs = %d\n", cif_nr_devs); cif_devices = (DEV_INSTANCE *)kmalloc( sizeof (DEV_INSTANCE), GFP_KERNEL); if (!cif_devices) return -ENOMEM; else { memset(cif_devices, 0, sizeof (DEV_INSTANCE)); cif_nr_devs++; dev = (DEV_INSTANCE *)cif_devices; dev->next = NULL; DBG_PRN("nr. %d, dev. %p, dev->next %p\n", cif_nr_devs, dev, dev->next); } } else { DBG_PRN("cif_nr_devs = %d\n", cif_nr_devs); dev = (DEV_INSTANCE *)cif_devices; DBG_PRN("nr. %d, dev. %p, dev->next %p\n", cif_nr_devs, dev, dev->next); while ( dev->next) { DBG_PRN("nr. %d, dev. %p, dev->next %p\n", cif_nr_devs, dev, dev->next); dev = (DEV_INSTANCE *)dev->next; DBG_PRN("nr. %d, dev. %p, dev->next %p\n", cif_nr_devs, dev, dev->next); } DBG_PRN("nr. %d, dev. %p, dev->next %p\n", cif_nr_devs, dev, dev->next); dev->next = (DEV_INSTANCE *)kmalloc(sizeof(DEV_INSTANCE), GFP_KERNEL); if (!dev->next) return -ENOMEM; else { memset(dev->next, 0, sizeof(DEV_INSTANCE)); dev = (DEV_INSTANCE *)dev->next; dev->next = NULL; cif_nr_devs++; } } DBG_PRN("nr. %d, dev. %p, dev->next %p, irq %X\n", cif_nr_devs, dev, dev->next, dev->usBoardIrq); dev->usBoard = index; dev->ucPCIBusNumber = pDev->bus->number; dev->usBoardIrq = pDev->irq; dev->IrqCtrlRegAddr = (unsigned char *)IrqCtrlRegAddr; dev->usBoardIrq_scanned = dev->usBoardIrq; // save it, needed while switching between irq and polling modes dev->ulBoardAddress = ulRegisterSave & PCI_BASE_ADDRESS_IO_MASK; dev->ulDPMByteSize = ulDPMByteSize; dev->ulDPMSize = ulDPMByteSize / 1024; dev->bActive = TRUE; dev->ucBusType = BUS_TYPE_PCI; DBG_PRN("!!!: regsave: %lX, boardAdd: %lX\n", ulRegisterSave, dev->ulBoardAddress); return 0; }
bool TDateTime::SetCurrentDateTime(TDateTime &rhs) { #ifndef WIN32 unsigned int year=0, month=0, day=0, hour=0, min=0, sec=0; rhs.DecodeDate( year, month, day ); rhs.DecodeTime( hour, min, sec ); //更新操作系统时间 struct tm tmSys; time_t tSys; tmSys.tm_year = year - 1900; tmSys.tm_mon = month - 1; tmSys.tm_mday = day; tmSys.tm_sec = sec; tmSys.tm_min = min; tmSys.tm_hour = hour; tmSys.tm_isdst = -1; if ( ( tSys = mktime( &tmSys ) ) == -1 ) { DBG_PRN("info", ("mktime error!!")); return false; } if ( stime( &tSys ) == -1) { DBG_PRN("info", ("stime error!!")); return false; } //更RTC时间 // unsigned char tmp[3]; // int datetime; // datetime = rhs.FormatInt(YYYYMMDD); // int2bin(&tmp[0], (datetime / 10000) % 100, 1); // int2bin(&tmp[1], (datetime / 100) % 100, 1); // int2bin(&tmp[2], datetime % 100, 1); // SetRTCData(tmp); // // datetime = rhs.FormatInt(HHMMSS); // int2bin(&tmp[0], (datetime / 10000) % 100, 1); // int2bin(&tmp[1], (datetime / 100) % 100, 1); // int2bin(&tmp[2], datetime % 100, 1); // SetRTCTime(tmp); #endif return true; }
/* * Scan Compact-PCI-bus / detect CIF80 boards */ int cif_scan_cpci (void) { unsigned short usSubVendor, usSubSystem; #ifdef CONFIG_PCI int i = 0; u32 curr, mask, ulDPMByteSize = 0x0UL; unsigned short index = 0; struct pci_dev *pDev = NULL; DBG_PRN ("scanning for cif80 Boards . . .\n"); while ( (pDev = pci_find_device(VENDOR_ID, CPCI_DEVICE_ID, pDev)) != NULL ) { // PLX-Chip found, look for Hilscher one! pci_read_config_word(pDev, PCI_SUB_VENDOR_ID, &usSubVendor); pci_read_config_word(pDev, PCI_SUB_SYSTEM_ID, &usSubSystem); DBG_PRN("subSystem = %X, subVendor = %X\n", usSubSystem, usSubVendor); if( SUBVENDOR_ID == usSubVendor && CPCI_SUBSYSTEM_ID == usSubSystem && index < 4) { ulDPMByteSize = 0x0UL; DBG_PRN("BAR[]=%x,%x,%x,%x IRQ=%x\n", (unsigned short)pci_resource_start(pDev, 0), (unsigned short)pci_resource_start(pDev, 1), (unsigned short)pci_resource_start(pDev, 2), (unsigned short)pci_resource_start(pDev, 3), pDev->irq); for(i=0; addresses[i]; i++) { pci_read_config_dword(pDev, addresses[i],&curr); DBG_PRN("addresses[%d] = %d, curr = %d\n", i, addresses[i], curr); local_irq_disable(); // cli(); if(i == 2) ulRegisterSave = pci_resource_start (pDev, 2); else if(i == 1) cif_base = (unsigned short)(pci_resource_start (pDev, 1) & 0xFFFFFFFE); else if(i == 0) ulIrqCtrlRegSave = pci_resource_start (pDev, 0); pci_write_config_dword(pDev, addresses[i], ~0); pci_read_config_dword (pDev, addresses[i], &mask); pci_write_config_dword(pDev, addresses[i], curr); local_irq_enable(); // sti(); if(i == 2) ulDPMByteSize = ~(mask & PCI_BASE_ADDRESS_IO_MASK) +1; } DBG_PRN ("PLX-CHIP local Reg. Add. : %x\n", cif_base); if(( IrqCtrlRegAddr = (unsigned char *)ioremap(ulIrqCtrlRegSave, 0x50)) != NULL) { bData = readb( IrqCtrlRegAddr + PCI_INTCTRLSTS_REG); } DBG_PRN ("Interrupt-ctrl-state read: %x\n", bData); bData = (unsigned char)(bData | HW_INTERRUPT_ENABLE);//(bData & ~HW_INTERRUPT_ENABLE); // Desable Interrupt if( cif_init_dev_pci (pDev, index, ulDPMByteSize) != 0) { DBG_PRN ("Cannot alloc memory for Board : %x\n", index); break; // -ENOMEM } else index++; } } if(index == 0) { DBG_PRN ("cif80: no Boards found:\n"); return -ENODEV; } #endif return -ENODEV; }
static int __init cif_init(void) { int res = 0; printk (MODNAME "loaded: {v." VERSION "}\n"); /* scan compact-pci bus for Hilscher boards */ res = cif_scan_cpci(); if( res != -ENODEV) DBG_PRN("%x CIF80-Board(s) detected\n", res); /* scan pci bus for Hilscher boards */ res = cif_scan_pci(); if( res != -ENODEV) DBG_PRN("%x CIF50-Board(s) detected\n", res); // try for Hilscher ISA boards, if there was parameter passed for(res = 0; res < MAX_DEV_BOARDS; res++) { if( cif_nr_devs < MAX_DEV_BOARDS && dpm_add[res] != 0) cif_init_dev_isa( res); else break; } res = 0; if(cif_nr_devs == 0) { return -ENODEV; } else { /* Register major, and accept a dynamic number */ res = register_chrdev(cif_major, "cif", &cif_fops); if (res < 0) { DBG_PRN("can't get major %d\n",cif_major); return res; } if (cif_major == 0) cif_major = res; /* dynamic */ if( cif_drv_load()) return 0; /* succeed */ else { unregister_chrdev(cif_major, "cif"); return -ENOMEM; } } }
void sockopts(int sockfd, int doall) { int option, optlen; /* "doall" is 0 for a server's listening socket (i.e., before accept() has returned.) Some socket options such as SO_KEEPALIVE don't make sense at this point, while others like SO_DEBUG do. */ if (debug) { option = 1; if (setsockopt(sockfd, SOL_SOCKET, SO_DEBUG, (char *) &option, sizeof(option)) < 0) err_sys("SO_DEBUG setsockopt error"); option = 0; optlen = sizeof(option); if (getsockopt(sockfd, SOL_SOCKET, SO_DEBUG, (char *) &option, &optlen) < 0) err_sys("SO_DEBUG getsockopt error"); if (option == 0) err_quit("SO_DEBUG not set (%d)", option); DBG_PRN("SO_DEBUG set\n"); } if (broadcast && doall) { option = 1; if (setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, (char *) &option, sizeof(option)) < 0) err_sys("SO_BROADCAST setsockopt error"); option = 0; optlen = sizeof(option); if (getsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, (char *) &option, &optlen) < 0) err_sys("SO_BROADCAST getsockopt error"); if (option == 0) err_quit("SO_BROADCAST not set (%d)", option); DBG_PRN("SO_BROADCAST set\n"); } }
static void __exit cif_cleanup(void) { DEV_INSTANCE *dev = NULL, *next = NULL; if(cif_nr_devs != 0) { cif_drv_unload(); for ( dev = cif_devices; dev; dev = next) { /* all items of the linked list */ if ( dev) { DBG_PRN("free mem. dev %p, dev->next %p\n", dev, dev->next); next = (DEV_INSTANCE *)dev->next; kfree( dev); dev = NULL; } } } unregister_chrdev(cif_major, "cif"); DBG_PRN("clean up finished!\n\n"); }
// Try ISA boards if there was parameters for them passed while loading driver int cif_init_dev_isa ( int iSa) { DEV_INSTANCE *dev; if ( (dpm_add[iSa] < 0xA0000) || (dpm_add[iSa] > (0xFFFFF - dpm_len[iSa] * 1024)) ) { DBG_PRN("not suitable dpm-address or -length: %d, %d\n", dpm_add[iSa], dpm_len[iSa]); return -1; } else { if( cif_nr_devs == 0) { cif_devices = (DEV_INSTANCE *)kmalloc( sizeof (DEV_INSTANCE), GFP_KERNEL); if (!cif_devices) return -ENOMEM; else { memset(cif_devices, 0, sizeof (DEV_INSTANCE)); cif_nr_devs++; dev = (DEV_INSTANCE *)cif_devices; dev->next = NULL; DBG_PRN("nr.%d, dev.%p, dev->next %p\n", cif_nr_devs, dev, dev->next); } } else { dev = (DEV_INSTANCE *)cif_devices; DBG_PRN("nr. %d, dev. %p, dev->next %p\n", cif_nr_devs, dev, dev->next); while ( dev->next) { DBG_PRN("nr. %d, dev. %p, dev->next %p\n", cif_nr_devs, dev, dev->next); dev = (DEV_INSTANCE *)dev->next; DBG_PRN("nr. %d, dev. %p, dev->next %p\n", cif_nr_devs, dev, dev->next); } DBG_PRN("nr. %d, dev. %p, dev->next %p\n", cif_nr_devs, dev, dev->next); dev->next = (DEV_INSTANCE *)kmalloc(sizeof(DEV_INSTANCE), GFP_KERNEL); if (!dev->next) return -ENOMEM; else { memset(dev->next, 0, sizeof(DEV_INSTANCE)); dev = (DEV_INSTANCE *)dev->next; dev->next = NULL; cif_nr_devs++; } } DBG_PRN("nr. %d, dev. %p, dev->next %p\n", cif_nr_devs, dev, dev->next); dev->usBoard = cif_nr_devs <= 0 ? 0 : cif_nr_devs - 1; dev->usBoardIrq = irq[iSa]; dev->usBoardIrq_scanned = dev->usBoardIrq; // save it, needed while switching between irq and polling modes dev->ulBoardAddress = dpm_add[iSa]; dev->ulDPMByteSize = dpm_len[iSa] * 1024; dev->ulDPMSize = dpm_len[iSa]; dev->bActive = TRUE; dev->ucBusType = BUS_TYPE_ISA; return 0; } }
/* K-2.6 old way MODULE_PARM( pci_irq, "s"); MODULE_PARM_DESC( pci_irq, "Activate Interrupt for PCI Cards"); MODULE_PARM( dpm_add, "1-4i"); MODULE_PARM_DESC( dpm_add, "Up to four DPM-Addresses (integer)"); MODULE_PARM( dpm_len, "1-4i"); MODULE_PARM_DESC( dpm_len, "Up to four DPM-Sizes (integer)"); MODULE_PARM( irq, "1-4h"); MODULE_PARM_DESC( irq, "Up to four irq-numbers (short)"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("David Tsaava"); MODULE_DESCRIPTION("CIF Device Driver for Hilscher Communication Boards, V2.100"); MODULE_SUPPORTED_DEVICE("cif"); */ int cif_open (struct inode *inode, struct file *filp) { //int type = TYPE(inode->i_rdev); int num = NUM(inode->i_rdev); DEV_INSTANCE *dev; /* device information */ DBG_PRN("CIFdevdrv opened!\n\n"); /* type 0, check the device number */ if (num >= cif_nr_devs) return -ENODEV; dev = &cif_devices[num]; /* and use filp->private_data to point to the device data */ filp->private_data = dev; return 0; /* success */ }
int CMachineInfoWin::ProcEvent(int iEvent,unsigned char *pEventData, int iDataLen) { DBG_PRN("info:",("iEvent = %u", iEvent)); //返回上一级菜单 if (RETURN_MAIN_MENU == iEvent) { ChangeWin(BASIC_REPORT_MENU); return SUCCESS; } #if _CONFIG_M2M_MODULE if( FIND_KEY == iEvent ) { GetWmmpIMEINo(); } #endif return CaWindow::ProcEvent(iEvent,pEventData,iDataLen); }
CaProgressBar::CaProgressBar(const char *text,bool withBar):CaWindow() { m_iType = CA_PROGRESSBAR; m_iBoxType = BOX_ALL; if (withBar) { Create(PROGRESSBAR_X,PROGRESSBAR_Y,PROGRESSBAR_W,PROGRESSBAR_H*2); m_pBar = new CaLabelBar(); m_pBar->Create(2,4,PROGRESSBAR_W - 4,GRID_LINE_H / 2); m_pLabel = new CaLabel(false, ALIGN_CENTER); m_pLabel->Create(0, (GRID_LINE_H + 2) * 2, PROGRESSBAR_W, CHAR_H); m_pLabel->SetTitle(text, strlen(text)); } else { int maxwidth = (PROGRESSBAR_W - 1 * WORD_W) / CHAR_W; CStringWrap strwrap(text,maxwidth); strwrap.Wrap(); if (strwrap.Lines() > 1) {//多行的话,就增加高度 int h = PROGRESSBAR_H + (GRID_LINE_H + 1)*(strwrap.Lines() - 1); h = h < SCREEN_H ? h:(SCREEN_H * 5 / 6); Create(PROGRESSBAR_X,PROGRESSBAR_Y / strwrap.Lines(), PROGRESSBAR_W,h); for(int i=0;i<strwrap.Lines();i++) { m_pLabel = new CaLabel(false, ALIGN_CENTER); m_pLabel->Create(0, 4 + (GRID_LINE_H + 1) * i, PROGRESSBAR_W, CHAR_H); DBG_PRN("info",("line[%d]=%s",i,strwrap.Line(i))); m_pLabel->SetTitle(strwrap.Line(i), strlen(strwrap.Line(i))); } } else { Create(PROGRESSBAR_X,PROGRESSBAR_Y,PROGRESSBAR_W,PROGRESSBAR_H); m_pLabel = new CaLabel(false, ALIGN_CENTER); m_pLabel->Create(0, 4, PROGRESSBAR_W, CHAR_H); m_pLabel->SetTitle(text, strlen(text)); } m_pBar = NULL; } End(); }
void CaInput::ReciveRightDirectKey(int iEvent) { DBG_ASSERT_EXIT( (iEvent == INPUT_RIGHT ), ("iEvent =%d is not INPUT_RIGTH")); if(m_iConLen <=0 ) { return; } int oldScrStartIndex=m_iCurConPos-m_iCurScrPos; int newScrStartIndex=oldScrStartIndex; int step=0; //�Ѿ��ڴ���β�� �����ٶ� if( ( m_iCurConPos >= m_iConLen ) )// || m_iCurConPos == m_iConMaxLen-1 ) { if(m_iCurScrPos >= m_iScrMaxLen-1) { m_iCurConPos = m_iConLen; m_iCurConPos = m_iCurConPos >= m_iConMaxLen ? m_iConMaxLen:m_iCurConPos ; m_iCurScrPos = m_iCurConPos-newScrStartIndex; } return; } if (is_gb_ex(m_contentBuf, m_iCurConPos)) { step=2; } else { step=1; } m_iCurConPos +=step; // if (is_gb_ex(m_contentBuf, m_iCurConPos) == 1) //��Ҫ���� if( (m_iCurConPos >= oldScrStartIndex + m_iScrMaxLen ) || ((is_gb_ex(m_contentBuf, m_iCurConPos) == 1) && (m_iCurConPos+1 == oldScrStartIndex+m_iScrMaxLen))) { int scrollLen= m_iScrMaxLen > SCROLL_LEN? SCROLL_LEN:1; int tmp=scrollLen; if((m_iConLen - oldScrStartIndex - m_iScrMaxLen ) < scrollLen ) { tmp=m_iConLen - oldScrStartIndex - m_iScrMaxLen; } if( tmp < scrollLen ) { tmp=m_iConMaxLen - oldScrStartIndex - m_iScrMaxLen; tmp= tmp > scrollLen ? scrollLen :tmp; } newScrStartIndex += tmp; //���� if( HalfHZCount((char *)m_contentBuf,newScrStartIndex)%2 == 1) { DBG_PRN("info",("here")); newScrStartIndex++; } m_iCurScrPos = m_iCurConPos-newScrStartIndex; //������ʾ���ݳ��� if( newScrStartIndex+m_iScrMaxLen >= m_iConLen ) { m_iScrLen=m_iConLen-newScrStartIndex; } else //���ݵ�β�����������������ұ� { m_iScrLen=m_iScrMaxLen; } if (is_gb_ex(m_contentBuf+newScrStartIndex, m_iScrLen-1) == 1) { m_iScrLen--; } memset(m_dispBuf,0,MAX_LINE_LEN); if(m_InputType == aPASSWORD ) { memset(m_dispBuf,PASSWORD_CHAR,m_iScrLen); } else { memcpy(m_dispBuf,m_contentBuf+newScrStartIndex,m_iScrLen); } } else { m_iCurScrPos +=step; } //�Ѿ��ڴ���β�� �����ٶ� if(m_iCurConPos >= m_iConLen /*|| m_iCurConPos == m_iConMaxLen-1 */) { m_iCurConPos = m_iConLen; if(m_iCurScrPos >= m_iScrMaxLen-1) { m_iCurConPos = m_iCurConPos >= m_iConMaxLen ? m_iConMaxLen :m_iCurConPos ; // m_iCurScrPos = m_iCurScrPos >= m_iScrMaxLen ? m_iScrMaxLen-1 :m_iCurScrPos ; } m_iCurScrPos = m_iCurConPos-newScrStartIndex; } }
int CaInput::ProcEvent(int iEvent,unsigned char *pEventData, int iDataLen) { int res=0; //������д���¼� if ((iEvent == 0xFF) && (pEventData != NULL)) { switch(m_InputType) { case aINT: if(ReciveIntChar(0xFF,(char *)pEventData,strlen((char *)pEventData)) == 1 ) { res=1; } break; case aFLOAT: if(ReciveFloatChar(0xFF,(char *)pEventData,strlen((char *)pEventData)) == 1 ) { res= 1; } break; case aPASSWORD: // res= 1; // break; case aCHAR: if(ReciveStrChar(0xFF,(char *)pEventData,strlen((char *)pEventData)) == 1 ) { res= 1; } // memset(m_dispBuf,0,OBJ_TITLE_MAX_LEN); // strncpy(m_dispBuf,(char *)m_contentBuf,m_iTitleLen); break; default: break; } } if (iEvent == CHANGE_INPUT_METHOD_EVENT && !m_bReadOnly && m_InputType!= aINT && m_InputType != aFLOAT && m_InputType!= aPASSWORD) { CPosFrame::OnChangeIME(this,iEvent,pEventData,iDataLen); res = 1; } else { switch(m_InputType) { case aINT: if(!m_bReadOnly && ReciveIntChar(iEvent,(char *)pEventData,iDataLen) == 1 ) { res=1; } break; case aFLOAT: if(!m_bReadOnly &&ReciveFloatChar(iEvent,(char *)pEventData,iDataLen) == 1 ) { res= 1; } break; case aCHAR: case aPASSWORD: if(!m_bReadOnly && ReciveStrChar(iEvent,(char *)pEventData,iDataLen) == 1 ) { res= 1; } break; default: break; } } if(res == 0) { if (iEvent == CLEAR_ALL_EVENT && !m_bReadOnly ) { Clear(); res=1; } else if(iEvent == INPUT_LEFT ) { ReciveLeftDirectKey(iEvent); res= 1; } else if(iEvent == INPUT_RIGHT ) { ReciveRightDirectKey(iEvent); res= 1; } else if(iEvent == CLEAR_ONE_EVENT && !m_bReadOnly) { ReciveEraseKey(iEvent); res=1; } else if(iEvent == ENTER_KEY || (iEvent >= 0x11 && iEvent <= 0x18))//TODO��Ӧ�س����ܼ� { CaObject::ProcEvent(iEvent,pEventData,iDataLen); res = 1; } else { res=0; } } if(res == 1) { ReFresh(); if(IsCurObj()) { SetFocusIn(); } } DBG_PRN("info",("m_contentBuf = %s",m_contentBuf)); return res; }
BOOL cif_drv_load ( void) { int result = 0; BOOL bSuccess = FALSE; // no board available unsigned short usIdx = 0; DEV_INSTANCE * dev = NULL; // Driver is loaded for the very first time DBG_PRN("Boards altogether: %X\n", cif_nr_devs); // get memory for global driver data, delete content if ( cif_nr_devs > 0) { for ( usIdx = 0; usIdx < cif_nr_devs/*CIF_MAX_BOARDS*/; usIdx++) { DBG_PRN("Install instance Number = %d\n", usIdx); dev = cif_dev_get_at( usIdx); DBG_PRN("Board %d, dev: %p\n", usIdx, dev); if ( dev->bActive == TRUE) { DBG_PRN("DPM Adresses AVAILABLE, Board - %X, DPMsize: %lX\n", usIdx, dev->ulDPMByteSize); DBG_PRN("Physical-> DPMBase: %lX, DPMAdd: %lX, SndAdd: %lX, RcvAdd: %lX\n", dev->ulBoardAddress, dev->ulBoardAddress + dev->ulDPMByteSize - 1024, dev->ulBoardAddress, dev->ulBoardAddress + (dev->ulDPMByteSize - 1024)/2); if ( (dev->pDpmBase = (unsigned char *)bus_to_virt(dev->ulBoardAddress)) == NULL) { DBG_PRN("No virtual DPM base address\n"); // no virtual board address is allocated dev->bActive = FALSE; // get handle to message area, last Kbyte of the DPM } else if ( (dev->ptDpmAddress = (DPM_MEMORY *)ioremap(dev->ulBoardAddress + dev->ulDPMByteSize - 1024, 1024)) == NULL) { DBG_PRN("No virtual DPM address for last DPM Kbyte\n"); // no virtual board address is allocated dev->bActive = FALSE; // get handle to send data area (start of DPM) } else if ( (dev->pbDpmSendArea = (unsigned char *)ioremap(dev->ulBoardAddress, (dev->ulDPMByteSize - 1024) / 2)) == NULL) { DBG_PRN("No virtual DPM address for send data area\n"); // no virtual board address is allocated dev->bActive = FALSE; // get handle to receive data area (middle of the DPM) } else if ( (dev->pbDpmReceiveArea = (unsigned char *)ioremap(dev->ulBoardAddress + (dev->ulDPMByteSize - 1024) / 2 , (dev->ulDPMByteSize - 1024) / 2)) == NULL) { DBG_PRN("No virtual DPM address for receive data area\n"); // no virtual board address is allocated dev->bActive = FALSE; // install interrupt while IRQ number not 0 } else { DBG_PRN("DPM Adresses AVAILABLE\n"); DBG_PRN("Remapped-> DPMBase: %lX, DPMAdd: %lX, SndAdd: %lX, RcvAdd: %lX\n", (unsigned long)dev->pDpmBase, (unsigned long)dev->ptDpmAddress, (unsigned long)dev->pbDpmSendArea, (unsigned long)dev->pbDpmReceiveArea); // all parameters successfully read. Initialize instance No. usIdx dev->usRcsError = 0; // RCS-Error during startup dev->sDrvInitError = 0; // DRV-Error during startup // pointers to the DEV dpm cells dev->pbHostFlags = &(dev->ptDpmAddress->HostFlags); dev->pbDevFlags = &(dev->ptDpmAddress->DevFlags); // initialize start states dev->usOpenCounter = 0; dev->bInitMsgFlag = INI_MSG_WAIT; // Init state dev->bReadMsgFlag = HOST_MBX_EMPTY; // Read state dev->bWriteMsgFlag = DEVICE_MBX_EMPTY; // write state dev->bExIOFlag = EXCHGIO_NON; // IO state dev->bStateFlag = STATE_ERR_NON; // State field init_waitqueue_head( &dev->pInitSemaphore); init_waitqueue_head( &dev->pReadSemaphore); init_waitqueue_head( &dev->pWriteSemaphore); init_waitqueue_head( &dev->pExIOSemaphore); spin_lock_init (&dev->mutex); // request IRQ, register interrupt handler and BHs if (dev->usBoardIrq != 0) { //free_irq(dev->usBoardIrq, dev); if( dev->ucBusType == BUS_TYPE_PCI) { if(strncmp(pci_irq, "y", 1) == 0) { DBG_PRN("Board %d, activating irq %d\n", usIdx, dev->usBoardIrq); result = request_irq( (unsigned int)(dev->usBoardIrq), cif_interrupt, SA_SHIRQ, "cif", dev); cif_set_irq_state( HW_INTERRUPT_ENABLE, dev); } else {/* poll */ DBG_PRN("Board %d, disabling irq %d\n", usIdx, dev->usBoardIrq); cif_set_irq_state( HW_INTERRUPT_DISABLE, dev); result = -EBUSY; } } else // ISA bus supports no irq sharing result = request_irq( (unsigned int)(dev->usBoardIrq), cif_interrupt, 0, "cif", dev); if (result) { DBG_PRN("can't get assigned irq %i\n", dev->usBoardIrq); dev->usBoardIrq = 0; } else { DBG_PRN("interrupt handler registration OK. Board = %d, dev = 0x%p, request_irq() = %d\n", usIdx, dev, result); if( dev->ucBusType == BUS_TYPE_PCI) cif_set_irq_state( HW_INTERRUPT_ENABLE, dev); } } // board is configured, test hardware cif_test_hardware( dev); // virtual board address is allocated DBG_PRN("V-IRQ = %p \n", dev->pvVirtualIrq ); DBG_PRN("V-DPM base address = %p \n", dev->pDpmBase ); DBG_PRN("V-DPM send area address = %p \n", dev->pbDpmSendArea); DBG_PRN("V-DPM recive area address = %p \n", dev->pbDpmReceiveArea); DBG_PRN("V-DPM last kByte = %p \n", dev->ptDpmAddress); DBG_PRN("Initialisation OK\n"); // one board is initialized bSuccess = TRUE; } } // end for } } DBG_PRN("Leave %d \n", bSuccess); if( !bSuccess) { iounmap( dev->ptDpmAddress); iounmap( dev->pbDpmReceiveArea); iounmap( dev->pbDpmReceiveArea); } return bSuccess; }
int cif_release (struct inode *inode, struct file *filp) { DBG_PRN("CIFdevdrv closed!\n\n"); return (0); }