本文整理匯總了C++中GLOBAL_LOCK函數的典型用法代碼示例。如果您正苦於以下問題:C++ GLOBAL_LOCK函數的具體用法?C++ GLOBAL_LOCK怎麽用?C++ GLOBAL_LOCK使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GLOBAL_LOCK函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: NATIVE_PROFILE_CLR_HARDWARE
HRESULT CLR_HW_Hardware::TransferAllInterruptsToApplicationQueue()
{
NATIVE_PROFILE_CLR_HARDWARE();
TINYCLR_HEADER();
while(true)
{
HalInterruptRecord* rec;
{
GLOBAL_LOCK(irq1);
rec = m_interruptData.m_HalQueue.Peek();
}
if(rec == NULL) break;
CLR_RT_ApplicationInterrupt* queueRec = (CLR_RT_ApplicationInterrupt*)CLR_RT_Memory::Allocate_And_Erase( sizeof(CLR_RT_ApplicationInterrupt), CLR_RT_HeapBlock::HB_CompactOnFailure ); CHECK_ALLOCATION(queueRec);
queueRec->m_interruptPortInterrupt.m_data1 = rec->m_data1;
queueRec->m_interruptPortInterrupt.m_data2 = rec->m_data2;
queueRec->m_interruptPortInterrupt.m_data3 = rec->m_data3;
queueRec->m_interruptPortInterrupt.m_time = rec->m_time;
queueRec->m_interruptPortInterrupt.m_context = (CLR_RT_HeapBlock_NativeEventDispatcher*)rec->m_context;
m_interruptData.m_applicationQueue.LinkAtBack( queueRec ); ++m_interruptData.m_queuedInterrupts;
{
GLOBAL_LOCK(irq2);
m_interruptData.m_HalQueue.Pop();
}
}
if(m_interruptData.m_queuedInterrupts == 0)
{
TINYCLR_SET_AND_LEAVE(CLR_E_NO_INTERRUPT);
}
TINYCLR_CLEANUP();
if(CLR_E_OUT_OF_MEMORY == hr)
{
// if there is no memory left discard all interrupts to avoid getting into a death spiral of OOM exceptions
{
GLOBAL_LOCK(irq3);
while(!m_interruptData.m_HalQueue.IsEmpty())
{
m_interruptData.m_HalQueue.Pop();
}
}
}
TINYCLR_CLEANUP_END();
}
示例2: NATIVE_PROFILE_PAL_COM
int USART_Driver::Read( int ComPortNum, char* Data, size_t size )
{
NATIVE_PROFILE_PAL_COM();
if((ComPortNum < 0) || (ComPortNum >= TOTAL_USART_PORT)) {ASSERT(FALSE); return -1;}
if(Data == NULL ) return -1;
HAL_USART_STATE& State = Hal_Usart_State[ComPortNum];
if ( IS_POWERSAVE_ENABLED(State) || (!IS_USART_INITIALIZED(State))) return -1;
int CharsRead = 0;
while(CharsRead < size)
{
// keep interrupts off only during pointer movement so we are atomic
GLOBAL_LOCK(irq);
size_t toRead;
UINT8 *Src;
toRead = size - CharsRead;
Src = State.RxQueue.Pop( toRead );
if( NULL == Src )
break;
// Check if FIFO level has just passed or gotten down to the low water mark
if(State.RxQueue.NumberOfElements() <= State.RxBufferLowWaterMark && (State.RxQueue.NumberOfElements() + toRead) > State.RxBufferLowWaterMark)
{
if( USART_FLAG_STATE(State, HAL_USART_STATE::c_RX_SWFLOW_CTRL) )
{
// Clear our XOFF state
SendXON( ComPortNum, XOFF_FLAG_FULL );
}
if( USART_FLAG_STATE(State, HAL_USART_STATE::c_RX_HWFLOW_CTRL) )
{
CPU_USART_RxBufferFullInterruptEnable(ComPortNum, TRUE);
}
}
memcpy(&Data[CharsRead], Src, toRead); // Copy data from queue to Read buffer
CharsRead += toRead;
}
{
GLOBAL_LOCK(irq);
State.fDataEventSet = FALSE;
if(!State.RxQueue.IsEmpty())
{
SetEvent( ComPortNum, USART_EVENT_DATA_CHARS );
}
}
return CharsRead;
}
示例3: NATIVE_PROFILE_PAL_ASYNC_PROC_CALL
void HAL_COMPLETION::DequeueAndExec()
{
NATIVE_PROFILE_PAL_ASYNC_PROC_CALL();
GLOBAL_LOCK(irq);
HAL_COMPLETION* ptr = (HAL_COMPLETION*)g_HAL_Completion_List.FirstNode();
HAL_COMPLETION* ptrNext = (HAL_COMPLETION*)ptr->Next();
// waitforevents does not have an associated completion, therefore we need to verify
// than their is a next completion and that the current one has expired.
if(ptrNext)
{
ASSERT(ptr->EventTimeTicks <= HAL_Time_CurrentTicks());
Events_Set(SYSTEM_EVENT_FLAG_SYSTEM_TIMER);
ptr->Unlink();
//
// In case there's no other request to serve, set the next interrupt to be 356 years since last powerup (@25kHz).
//
HAL_Time_SetCompare( ptrNext->Next() ? ptrNext->EventTimeTicks : HAL_Completion_IdleValue );
#if defined(_DEBUG)
ptr->EventTimeTicks = 0;
#endif // defined(_DEBUG)
// let the ISR turn on interrupts, if it needs to
ptr->Execute();
}
}
示例4: Events_Clear
void Events_Clear( UINT32 Events )
{
NATIVE_PROFILE_PAL_EVENTS();
GLOBAL_LOCK(irq);
SystemEvents &= ~Events;
}
示例5: GLOBAL_LOCK
BOOL USART_Driver::ConnectEventSink( int ComPortNum, int EventType, void* pContext, PFNUsartEvent pfnUsartEvtHandler, void** ppArg )
{
if((ComPortNum < 0) || (ComPortNum >= TOTAL_USART_PORT)) return FALSE;
{
GLOBAL_LOCK(irq);
HAL_USART_STATE& State = Hal_Usart_State[ComPortNum];
State.PortIndex = ComPortNum;
if(ppArg != NULL) *ppArg = (void*)ComPortNum;
if(EventType == USART_EVENT_TYPE_DATA)
{
State.UsartDataEventCallback = pfnUsartEvtHandler;
State.DataContext = pContext;
}
else if(EventType == USART_EVENT_TYPE_ERROR)
{
State.UsartErrorEventCallback = pfnUsartEvtHandler;
State.ErrorContext = pContext;
}
}
return TRUE;
}
示例6: IRQToIRQVector
BOOL MC9328MXL_AITC_Driver::ActivateInterrupt( UINT32 Irq_Index, BOOL Fast, HAL_CALLBACK_FPN ISR, void* ISR_Param, UINT8 Priority )
{
// figure out the interrupt
IRQ_VECTORING* IsrVector = IRQToIRQVector( Irq_Index ); if(!IsrVector) return FALSE;
{
GLOBAL_LOCK(irq);
MC9328MXL_AITC& AITC = MC9328MXL::AITC();
// disable this interrupt while we change it
AITC.INTDISNUM = IsrVector->Index;
// set the correct type
AITC.SetType( IsrVector->Index, Fast );
// set the correct priority
AITC.SetPriority( IsrVector->Index, Priority );
// set the vector
IsrVector->Handler.Initialize( ISR, ISR_Param );
// enable the interrupt if we have a vector
AITC.INTENNUM = IsrVector->Index;
}
return TRUE;
}
示例7: GLOBAL_LOCK
void LPC22XX_USART_Driver::TxBufferEmptyInterruptEnable( int ComPortNum, BOOL Enable )
{
GLOBAL_LOCK(irq);
LPC22XX_USART& USARTC = LPC22XX::UART(ComPortNum);
ASSERT(LPC22XX_USART_Driver::IsValidPortNum(ComPortNum));
if (Enable)
{
USARTC.SEL2.IER.UART_IER |= (LPC22XX_USART::UART_IER_THREIE);
char c;
for (int i=0; i<2; i++)
{
if (USART_RemoveCharFromTxBuffer( ComPortNum, c ))
{
WriteCharToTxBuffer( ComPortNum, c );
Events_Set( SYSTEM_EVENT_FLAG_COM_OUT );
}
else
break;
}
}
else
{
USARTC.SEL2.IER.UART_IER &= ~(LPC22XX_USART::UART_IER_THREIE);
}
}
示例8: GLOBAL_LOCK
BOOL LPC22XX_GPIO_Driver::Uninitialize()
{
GLOBAL_LOCK(irq);
// TODO Implementation
return TRUE;
}
示例9: PinToBit
void AT91_GPIO_Driver::EnableOutputPin( GPIO_PIN pin, BOOL initialState )
{
UINT32 bitmask = 1 << PinToBit( pin );
UINT32 port = PinToPort( pin );
AT91_PIO &pioX = AT91::PIO (port);
GLOBAL_LOCK(irq);
pioX.PIO_PER = bitmask; // Enable PIO function
if(initialState)
pioX.PIO_SODR = bitmask;
else
pioX.PIO_CODR = bitmask;
pioX.PIO_OER = bitmask; // Enable Output
PIN_ISR_DESCRIPTOR& pinIsr = g_AT91_GPIO_Driver.m_PinIsr[ pin ];
pinIsr.m_intEdge = GPIO_INT_NONE;
pinIsr.m_isr = STUB_GPIOISRVector;
pinIsr.m_param = NULL;
}
示例10: IRQToIRQVector
BOOL LPC24XX_VIC_Driver::ActivateInterrupt( UINT32 Irq_Index, BOOL Fast, HAL_CALLBACK_FPN ISR, void* ISR_Param )
{
// figure out the interrupt
IRQ_VECTORING* IsrVector = IRQToIRQVector( Irq_Index ); if(!IsrVector) return FALSE;
{
GLOBAL_LOCK(irq);
LPC24XX_VIC& VIC = LPC24XX::VIC();
// disable this interrupt while we change it
VIC.INTENCLR = 1 << IsrVector->Index;
// set the vector
IsrVector->Handler.Initialize( ISR, ISR_Param );
// Use Vector Address register to identify the source of interrupt
VIC.VECTADDR[Irq_Index] = Irq_Index;
// enable the interrupt if we have a vector
VIC.INTENABLE = 1 << IsrVector->Index;
}
return TRUE;
}
示例11: NATIVE_PROFILE_PAL_COM
void I2C_Driver::Cancel( I2C_HAL_XACTION* xAction, bool signal )
{
NATIVE_PROFILE_PAL_COM();
ASSERT(xAction);
if(xAction == NULL) return;
GLOBAL_LOCK(irq);
switch(xAction->GetState())
{
// only one xAction will efer be in processing for every call to Abort
case I2C_HAL_XACTION::c_Status_Processing:
I2C_Internal_XActionStop();
// fall through...
case I2C_HAL_XACTION::c_Status_Scheduled:
case I2C_HAL_XACTION::c_Status_Completed:
case I2C_HAL_XACTION::c_Status_Aborted:
xAction->Abort();
xAction->SetState(I2C_HAL_XACTION::c_Status_Cancelled);
StartNext();
break;
case I2C_HAL_XACTION::c_Status_Idle: // do nothing since we aren't enqueued yet
break;
}
}
示例12: TTWAIN_SupportsCompressionType
/*---------------------------------------------------------------------------*/
int TTWAIN_SupportsCompressionType(TW_UINT16 comprType)
{
int rc;
TUINT32 size;
int found = FALSE;
TW_ENUMERATION *container = 0;
TW_HANDLE handle = 0;
if (!TTWAIN_IsCapCompressionSupported())
return FALSE;
rc = TTWAIN_GetCap(ICAP_COMPRESSION, TWON_ENUMERATION, (void *)0, &size);
if (!rc || !size)
return FALSE;
handle = GLOBAL_ALLOC(GMEM_FIXED, size);
if (!handle)
return FALSE;
container = (TW_ENUMERATION *)GLOBAL_LOCK(handle);
rc = TTWAIN_GetCap(ICAP_COMPRESSION, TWON_ENUMERATION, (void *)container, 0);
if (!rc)
goto done;
found = TTWAIN_IsItemInList(container->ItemList, &comprType,
container->NumItems, DCItemSize[container->ItemType]);
found = TRUE;
done:
if (handle) {
GLOBAL_UNLOCK(handle);
GLOBAL_FREE(handle);
}
return found;
}
示例13: TTWAIN_SupportsPixelType
/*---------------------------------------------------------------------------*/
int TTWAIN_SupportsPixelType(TTWAIN_PIXTYPE pix_type)
{
TW_HANDLE handle;
TW_ENUMERATION *container;
int rc, found = FALSE;
TUINT32 size4data;
TW_UINT16 twPix;
twPix = PixType[pix_type].type;
rc = TTWAIN_GetCap(ICAP_PIXELTYPE, TWON_ENUMERATION, (void *)0, &size4data);
if (!rc)
return FALSE;
if (!size4data)
return FALSE;
handle = GLOBAL_ALLOC(GMEM_FIXED, size4data);
if (!handle)
return FALSE;
container = (TW_ENUMERATION *)GLOBAL_LOCK(handle);
rc = TTWAIN_GetCap(ICAP_PIXELTYPE, TWON_ENUMERATION, (void *)container, 0);
if (!rc)
goto done;
found = TTWAIN_IsItemInList(container->ItemList, &twPix,
container->NumItems, DCItemSize[container->ItemType]);
done:
GLOBAL_UNLOCK(handle);
GLOBAL_FREE(handle);
return found;
}
示例14: ASSERT
BOOL LPC24XX_TIMER_Driver::Initialize( UINT32 Timer, HAL_CALLBACK_FPN ISR, void* ISR_Param )
{
ASSERT(Timer < c_MaxTimers);
GLOBAL_LOCK(irq);
if(g_LPC24XX_TIMER_Driver.m_configured[Timer] == TRUE) return FALSE;
//--//
if(ISR)
{
if(!CPU_INTC_ActivateInterrupt( LPC24XX_TIMER::getIntNo(Timer) , ISR, ISR_Param )) return FALSE;
}
LPC24XX_TIMER& TIMER = LPC24XX::TIMER( Timer );
TIMER.TCR = LPC24XX_TIMER::TCR_TEN;
//--//
g_LPC24XX_TIMER_Driver.m_configured[Timer] = TRUE;
return TRUE;
}
示例15: Watchdog_LastOccurence
BOOL Watchdog_LastOccurence( INT64& time, INT64& timeout, UINT32& assembly, UINT32& method, BOOL fSet )
{
GLOBAL_LOCK(irq);
Watchdog_Driver::WatchdogEvent last;
if(fSet)
{
last.Time = time;
last.Timeout = timeout;
last.Assembly = assembly;
last.Method = method;
}
BOOL fRes = Watchdog_Driver::LastOccurence( last, fSet );
if(!fSet && fRes)
{
time = last.Time;
timeout = last.Timeout;
assembly = last.Assembly;
method = last.Method;
}
return fRes;
}