void UrgencyTask (void) { FAST int key; Urgency_JOB_INFO * pInfo = &UrgencyJobInfo; FOREVER { /* wait for somebody to wake us up */ semTake (&pInfo->sem, WAIT_FOREVER); key = intLock (); while (TRUE) { TODO_NODE * pHead; TODO_NODE * pNode; /* Pull all the active nodes off of the queue */ if ( (pHead = pInfo->pHead) == NULL) break; pInfo->pHead = NULL; pInfo->pTail = NULL; intUnlock (key); pNode = pHead; while (TRUE) { pNode->routine (pNode->param1, pNode->param2, pNode->param3, pNode->param4, pNode->param5); if (pNode->pNext == NULL) break; pNode = pNode->pNext; } /* Place all processed nodes on the free queue */ key = intLock (); pNode->pNext = pInfo->pFree; pInfo->pFree = pHead; } intUnlock (key); } }
void sysClkInt ( int timerNum ) { int myLock; myLock = intLock(); /* ack the interrupt */ MIPS3_SD(sysClkBase + R_SCD_TIMER_CFG, M_SCD_TIMER_ENABLE | M_SCD_TIMER_MODE_CONTINUOUS); #if defined(USE_SIBYTE_INTR) SOC_INTR_INVOKE(); #endif /* call system clock service routine */ if (sysClkRoutine != NULL) (* sysClkRoutine) (sysClkArg); intUnlock(myLock); }
void wdbSuspendSystemHere ( void (*callback)(), int arg ) { u_int lockKey; WDB_IU_REGS regSet; lockKey = intLock(); #if CPU==SIMNT sysClkDisable(); #endif if (WDB_CTX_SAVE (®Set) == 0) { _sigCtxRtnValSet (®Set, 1); wdbSuspendSystem (®Set, callback, arg); } #if CPU==SIMNT sysClkEnable(); #endif intUnlock (lockKey); }
void ns16550DevInit ( NS16550_CHAN * pChan /* pointer to channel */ ) { int oldlevel = intLock (); /* initialize the driver function pointers in the SIO_CHAN's */ pChan->pDrvFuncs = &ns16550SioDrvFuncs; /* set the non BSP-specific constants */ pChan->getTxChar = ns16550DummyCallback; pChan->putRcvChar = ns16550DummyCallback; pChan->channelMode = 0; /* undefined */ pChan->options = (CLOCAL | CREAD | CS8); pChan->mcr = MCR_OUT2; /* reset the chip */ ns16550InitChannel (pChan); intUnlock (oldlevel); }
int readSerialMod_9(int *intBuffer) { int lvl; STATUS ret; unsigned char * buffer; unsigned char bufAux[9]; int i, size = 0; buffer = (unsigned char *)(*intBuffer); ret = scMemValidate((void *)buffer, 9, SC_PROT_WRITE); if (ret == OK) { while (size < 9) { lvl = intLock (); /* lock interrupts */ /* invoke the DLL refillBuffer routine */ i = pDllReadSerial(bufAux,(9-size)); intUnlock (lvl); /* unlock interrupts */ if (i > 0) { memcpy (&(buffer[size]),bufAux,i); size = size +i; } } return(size); } else { printf ("reproducir: error en buffer\n"); return(-1); } }
STATUS wdCancel ( WDOG_ID wdId /* ID of watchdog to cancel */ ) { int level = intLock (); /* LOCK INTERRUPTS */ if (OBJ_VERIFY (wdId, wdClassId) != OK) { intUnlock (level); /* UNLOCK INTERRUPTS */ return (ERROR); } #ifdef WV_INSTRUMENTATION /* windview - level 1 event logging */ EVT_OBJ_1 (OBJ, wdId, wdClassId, EVENT_WDCANCEL, wdId); #endif if (kernelState) { intUnlock (level); /* UNLOCK INTERRUPTS */ workQAdd1 ((FUNCPTR)windWdCancel, (int)wdId); } else { kernelState = TRUE; /* KERNEL_ENT */ intUnlock (level); /* UNLOCK INTERRUPTS */ windWdCancel (wdId); /* cancel watchdog */ windExit (); /* KERNEL EXIT */ } return (OK); }
void sysHwInit0(void) { intLock(); #if PLL_EN == 0 /* Not use PLL 不使用PLL */ SysCtlClockSet(CCLK_DIV | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | EXT_CLK); #else /* Use PLL 使用PLL */ SysCtlClockSet(CCLK_DIV | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | EXT_CLK); #endif intLibInit(); //系统IO初始化 bsp_gpio_init(); //系统串口初始化 sysSerialHwInit(); intUnlock(); }
WDOG_ID wdCreate (void) { WDOG_ID wdId; #ifdef WV_INSTRUMENTATION int level; #endif if ((!wdLibInstalled) && (wdLibInit () != OK)) return (NULL); /* package init problem */ wdId = (WDOG_ID) objAlloc (wdClassId); /* initialize allocated watchdog */ if ((wdId != NULL) && (wdInit (wdId) != OK)) { objFree (wdClassId, (char *) wdId); return (NULL); } #ifdef WV_INSTRUMENTATION /* windview - level 1 event logging */ level = intLock (); EVT_OBJ_1 (OBJ, wdId, wdClassId, EVENT_WDCREATE, wdId); intUnlock (level); #endif return (wdId); }
static void i8250InitChannel ( I8250_CHAN *pChan ) { int oldLevel; oldLevel = intLock (); /* 8 data bits, 1 stop bit, no parity */ (*pChan->outByte) (pChan->lcr, 0x03); /* enable the receiver and transmitter */ (*pChan->outByte) (pChan->mdc, 0x0b); (*pChan->inByte) (pChan->data); /* clear the port */ /* enables interrupts */ (*pChan->outByte) (pChan->ier,0x1); intUnlock (oldLevel); }
STATUS semBGive(SEM_ID semId) { /* RAIN_TCB* pOwner; */ int level = intLock(); if(!IS_CLASS(semId, semClassId)) { intUnlock(level); return (ERROR); } /*pOwner = semId->semOwner;*/ if(NULL == (semId->semOwner = (RAIN_TCB*)Q_FIRST(&semId->qHead))) { intUnlock(level); } else { kernelState = TRUE; intUnlock(level); kernelPendQGet(&semId->qHead); kernelExit(); } return (OK); }
void ADSL_DisableIRQ2(void) { register UINT32 temp; if (pF2_IRQ2_ISR == 0) return; temp = intLock(); #ifdef LEVEL_MODE_ADSL DisableInterruptCount++; if (pF2_IRQ2_ISR) SetGPIOIntEnable(GPIOINT_F2_IRQ2, 0); /* Indicate start of critical section for debug */ SetGPIOF2PCS(TRUE); intUnlock(temp); #else /* LEVEL_MODE_ADSL */ oldValue[DisableInterruptCount]=temp; if (DisableInterruptCount == 0) /* Indicate start of critical section for debug */ SetGPIOF2PCS(TRUE); DisableInterruptCount++; #endif /* LEVEL_MODE_ADSL */ }
void bspHwInit(void) { intLock(); intUnlock(); }
void et_drv_mii_rx(int unit, UINT8 *b, int *l) { M_BLK_ID pMblk; int s; int n = 10; *l = 0; while(*l == 0) { pMblk = et_drv_txrx_info[unit].rx_head; if (pMblk != NULL) { s = intLock(); et_drv_txrx_info[unit].rx_head = pMblk->mBlkHdr.mNextPkt; if (et_drv_txrx_info[unit].rx_head == NULL) { et_drv_txrx_info[unit].rx_tail = NULL; } intUnlock(s); *l = pMblk->mBlkPktHdr.len; netMblkToBufCopy(pMblk, (char *)b, NULL); netMblkClChainFree(pMblk); ET_DRV_TXRX_PRINT("DeQueued a packet %08x len = %d\n", (int)pMblk, *l, 3, 4, 5, 6); } else { /* Wait for a packet */ /* semTake(et_drv_txrx_info.rx_sem); */ taskDelay(1); if (!(n--)) break; } } }
BOOLEAN uart_fifo_get_char ( UART_FIFO_T *FifoCtx, BYTE *charbuf // Place to put data retrieved from the fifo ) { // Protect the fifo manipulation operations from interrupts UINT32 oldlevel = intLock(); // Is there data on the fifo? if ( FifoCtx->entry_cnt > 0 ) { // Get data from the fifo context given to us *charbuf = FifoCtx->fifo[ FifoCtx->get_idx++ ]; // Process the get index to account for queue wrapping if( FifoCtx->get_idx >= SIZE_OF_UART_FIFO ) { FifoCtx->get_idx = 0; } // Indicate an entry was removed from the queue FifoCtx->entry_cnt--; // Response successfully dequeued intUnlock(oldlevel); return TRUE; } else { // No response to remove from the queue. intUnlock(oldlevel); return FALSE; } }
void bcm_robo_mii_rx(UINT8 *b, int *l) { M_BLK_ID pMblk; int s; int n = 10; *l = 0; while(*l == 0) { pMblk = robo_txrx_info.rx_head; if (pMblk != NULL) { s = intLock(); robo_txrx_info.rx_head = pMblk->mBlkHdr.mNextPkt; if (robo_txrx_info.rx_head == NULL) { robo_txrx_info.rx_tail = NULL; } intUnlock(s); *l = pMblk->mBlkPktHdr.len; netMblkToBufCopy(pMblk, b, NULL); netMblkClChainFree(pMblk); #ifdef ROBO_TXRX_DEBUG ROBO_TXRX_PRINT("DeQueued a packet %08x len = %d\n", (int)pMblk, *l, 3, 4, 5, 6); #endif } else { /* Wait for a packet */ /* semTake(robo_txrx_info.rx_sem); */ taskDelay(1); if (!(n--)) break; } } }
/*------------------------- set DMAcntl, SampleRate, <8bits unsigned mono> ------------------------*/ int prog_codec(void) { UINT32 format; int lockkey; lockkey = intLock(); /* Program record/playback sampling rate -- 11025 */ /* DAC */ format = DMRn_DMA | DMRn_AUTO |DMRn_TR_READ|DMRn_USIGN|DMRn_SIZE8|DMRn_MONO; writel(format, CS4281_pBA0+BA0_DMR0); writel(0x04, CS4281_pBA0+BA0_DACSR); /* ADC */ format = DMRn_DMA | DMRn_AUTO |DMRn_TR_WRITE/*|DMRn_USIGN*/|DMRn_SIZE8|DMRn_MONO; writel(format, CS4281_pBA0+BA0_DMR1); writel(0x04, CS4281_pBA0+BA0_ADCSR); intUnlock(lockkey); return 0; }
/******************************************************************************* * * spUartDevInit - initialise an SPUART channel * * This routine initialises some CNXT_SIO function pointers and then resets * the chip in a quiescent state. Before this routine is called, the BSP * must already have initialised all the device addresses, etc. in the * CNXT_UART structure. * * RETURNS: N/A *******************************************************************************/ eUARTType spUartDevInit ( CNXT_UART *pUARTChan ) { static eUARTType spUartInitChannel(CNXT_UART *pUARTChan) ; eUARTType eStatus; UINT32 oldlevel = intLock(); HWSTATE.g_pUARTChan = pUARTChan; /* reset the chip */ eStatus = spUartInitChannel(pUARTChan); pUARTChan->xmtr_uart_fifo.get_idx = 0; pUARTChan->xmtr_uart_fifo.put_idx = 0; pUARTChan->xmtr_uart_fifo.entry_cnt = 0; pUARTChan->rcvr_uart_fifo.get_idx = 0; pUARTChan->rcvr_uart_fifo.put_idx = 0; pUARTChan->rcvr_uart_fifo.entry_cnt = 0; intUnlock(oldlevel); return(eStatus); }
LOCAL STATUS ns16550Open ( NS16550_CHAN * pChan /* pointer to channel */ ) { FAST int oldlevel; /* current interrupt level mask */ char mask; mask = ns16550RegRd(REGPTR(MCR, pChan)) & (MCR_RTS | MCR_DTR); if (mask != (MCR_RTS | MCR_DTR)) { /* RTS and DTR not set yet */ oldlevel = intLock (); /* set RTS and DTR TRUE */ pChan->mcr |= (MCR_DTR | MCR_RTS); ns16550RegWr(REGPTR(MCR, pChan) , pChan->mcr); /* clear Tx and receive and enable FIFO */ ns16550RegWr(REGPTR(FCR, pChan) , (RxCLEAR | TxCLEAR | FIFO_ENABLE)); intUnlock (oldlevel); } return (OK); }
LOCAL STATUS ns16550BaudSet ( NS16550_CHAN * pChan, /* pointer to channel */ UINT baud /* requested baud rate */ ) { int oldlevel; int divisor = ((pChan->xtal + (8 * baud)) / (16 * baud)); /* disable interrupts during chip access */ oldlevel = intLock (); /* Enable access to the divisor latches by setting DLAB in LCR. */ ns16550RegWr(REGPTR(LCR, pChan) , LCR_DLAB | pChan->lcr); /* Set divisor latches. */ ns16550RegWr(REGPTR(DLL,pChan) , divisor); ns16550RegWr(REGPTR(DLM,pChan) , (divisor >> 8)); /* Restore line control register */ ns16550RegWr(REGPTR(LCR, pChan) , pChan->lcr); pChan->baudRate = baud; intUnlock (oldlevel); return (OK); }
/***************************************************************************** Prototype : MailBox_SpMsgWrite Description : 专有邮箱写接口封装 Input : ulAddr : 专有邮箱的地址 ulSize : 缓冲区大小(以字节为单位) pData : 缓冲区指针(不包含消息头信息) Return Value : 0: 表示操作成功 其他: 表示操作失败 *****************************************************************************/ u32 MailBox_SpMsgWrite(u32 ulAddr, u32 ulSize, void* pData) { u32 ret = BSP_OK; s32 key; key = intLock(); if(*((u32*)ulAddr)) { /* 设置为无数据 */ *((u32*)ulAddr) = 0; ret = ERR_MAILBOX_COVER; } memcpy(((u8*)ulAddr + 4), pData, ulSize); /* 设置为DSP可以读 */ *((u32*)ulAddr) = 1; intUnlock(key); return ret; }
/***************************************************************************** Prototype : BSP_MailBox_SpMsgRead Description : 专有邮箱(Special Mailbox)的读接口 (由调用者保证调用接口时DSP处于非睡眠状态) Input : ulAddr : 专有邮箱的偏移地址(从消息头开始的地址) ulSize : 初始值的大小(以字节为单位) pData : 数据信息(不包含消息头信息) Return Value : BSP_OK: 读取成功 ERR_MAILBOX_READ_NULL: 无数据 ERR_MAILBOX_NOT_INIT: 邮箱未初始化 ERR_MAILBOX_PARAM_INCORRECT: 参数错误 *****************************************************************************/ u32 BSP_MailBox_SpMsgRead(u32 ulAddr, u32 ulSize, void* pData) { s32 key = 0; u32 ret = 0; if(!(g_stMbxCtrl.bMbxInit)) { g_stMbxMntn.stAbnormal.ulNInitSlic = BSP_GetSliceValue(); return ERR_MAILBOX_NOT_INIT; } if((BSP_NULL == pData) || (0 == ulSize)) { return ERR_MAILBOX_PARAM_INCORRECT; } key = intLock(); ret = MailBox_SpMsgRead(ulAddr, ulSize, pData); intUnlock(key); return ret; }
/***************************************************************************** Prototype : MailBox_SpMsgWrite Description : 专有邮箱读接口封装 Input : ulAddr : 专有邮箱的偏移地址(从消息头开始的地址) ulSize : 初始值的大小(以字节为单位) pData : 数据信息(不包含消息头信息) Return Value : 0: 表示操作成功 其他: 表示操作失败 *****************************************************************************/ u32 MailBox_SpMsgRead(u32 ulAddr, u32 ulSize, void* pData) { s32 key; key = intLock(); /* 如果DSP已睡眠,表示邮箱中无数据 */ /* 如果DSP没睡眠,由锁中断保证不调度低功耗模块对DSP的下电处理 */ if(BSP_TRUE == BSP_MailBox_IsDspSleep()) /*lint !e746*/ { intUnlock(key); return ERR_MAILBOX_READ_NULL; } /* 判断当前消息是否已读走 */ if(0 == *((u32*)ulAddr)) { intUnlock(key); return ERR_MAILBOX_READ_NULL; } memcpy(pData, ((u8*)ulAddr + 4), ulSize); /* 设置可以DSP可以读 */ *((u32*)ulAddr) = 0; intUnlock(key); return BSP_OK; }
STATUS pciIntDisconnect ( VOIDFUNCPTR *vector, /* interrupt vector to attach to */ VOIDFUNCPTR routine /* routine to be called */ ) { int irq = IVEC_TO_INUM ((int)vector) - INT_NUM_IRQ0; PCI_INT_RTN *pRtn; int oldLevel; for (pRtn = (PCI_INT_RTN *)DLL_FIRST (&pciIntList[irq]); pRtn != NULL; pRtn = (PCI_INT_RTN *)DLL_NEXT (&pRtn->node)) { if (pRtn->routine == routine) { oldLevel = intLock (); /* LOCK INTERRUPT */ dllRemove (&pciIntList[irq], &pRtn->node); intUnlock (oldLevel); /* UNLOCK INTERRUPT */ free ((char *)pRtn); return (OK); } } return (ERROR); }
STATUS pciIntConnect (VOIDFUNCPTR *vector, VOIDFUNCPTR routine, int parameter) { static int alreadyConnected=FALSE; int irq = IVEC_TO_INUM ((int)vector) - sysVectorIRQ0; PCI_INT_RTN *pRtn; int oldLevel; pRtn = (PCI_INT_RTN *)malloc (sizeof (PCI_INT_RTN)); if (pRtn == NULL) { return (ERROR); } pRtn->routine = routine; pRtn->parameter = parameter; oldLevel = intLock (); /* LOCK INTERRUPT */ dllAdd (&pciIntList[irq], &pRtn->node); intUnlock (oldLevel); /* UNLOCK INTERRUPT */ if (!alreadyConnected) { if (intConnect(vector, (VOIDFUNCPTR) pciInt, irq) == ERROR) { return -1; } alreadyConnected=TRUE; } return (OK); }
STATUS semDestroy(SEM_ID semId, BOOL dealloc) { int level; level = intLock(); if(!IS_CLASS(semId, semClassId)) { return (ERROR); } objCoreTerminate(&semId->objCore); kernelState = TRUE; intUnlock(level); kernelSemDelete(semId); TASK_SAFE(); kernelExit(); if(dealloc) { objFree(semClassId, (char*)semId); } TASK_UNSAFE(); return (OK); }
int32 VisionApp::GetInt32(const char* settingName) { BAutolock intLock(const_cast<BLocker*>(&fSettingsLock)); if (!intLock.IsLocked()) return B_ERROR; return fVisionSettings->FindInt32(settingName); }
status_t VisionApp::SetInt32(const char* settingName, int32 value) { BAutolock intLock(const_cast<BLocker*>(&fSettingsLock)); if (!intLock.IsLocked()) return B_ERROR; status_t result = fVisionSettings->ReplaceInt32(settingName, value); return result; }
LOCAL UINT8 ns16550RegRd(volatile UINT8 *reg) { int ikey; volatile UINT8 rval; ikey = intLock(); rval = *reg; intUnlock(ikey); return(rval); }
/***************************************************************************** Prototype : BSP_MailBox_SpDLMsgHeadInit Description : 专有(Special Mailbox)下行邮箱的消息头初始化接口 (初始化上行邮箱每条原语的消息头,提供给协议栈,需要调用多次 由调用者保证调用接口时DSP处于非睡眠状态) Input : ulAddr : 专有邮箱的地址 ulSize : 初始值的大小(以字节为单位) ucData : 初始值 Return Value None *****************************************************************************/ void BSP_MailBox_SpDLMsgHeadInit(u32 ulAddr, u32 ulSize, u8 ucData) { s32 key; key = intLock(); memset((u8*)ulAddr, ucData, ulSize); intUnlock(key); }
void wdbExcGetEvent ( void * arg, WDB_EVT_DATA * pEvtData ) { wdbExcInfoNode_t * pNode; wdbExcInfoNode_t * pTmpNode; WDB_EXC_INFO * pExcInfo; int lockKey; /* get a node from the exception queue */ lockKey = intLock(); pNode = (wdbExcInfoNode_t *) dll_head (&wdbExcEvtList); dll_remove (&pNode->node); intUnlock (lockKey); /* give the node info to the host */ pExcInfo = (WDB_EXC_INFO *)&pEvtData->eventInfo; pEvtData->evtType = WDB_EVT_EXC; pExcInfo->numInts = 4; pExcInfo->context = pNode->context; pExcInfo->vec = pNode->excVector; pExcInfo->pEsf = (TGT_ADDR_T) pNode->pESF; /* mark the node invalid and put back in queue (after valid nodes) */ pNode->valid = FALSE; lockKey = intLock(); for (pTmpNode = (wdbExcInfoNode_t *) dll_head (&wdbExcEvtList); pTmpNode != (wdbExcInfoNode_t *) dll_end (&wdbExcEvtList); pTmpNode = (wdbExcInfoNode_t *) dll_next (&pTmpNode->node)) { if (pTmpNode->valid == FALSE) break; } pTmpNode = (wdbExcInfoNode_t *) dll_prev (&pTmpNode->node); dll_insert (&pNode->node, &pTmpNode->node); intUnlock (lockKey); }