equal
deleted
inserted
replaced
24 |
24 |
25 const TInt KTimerQDfcPriority=6; |
25 const TInt KTimerQDfcPriority=6; |
26 |
26 |
27 GLDEF_D NTimerQ TheTimerQ; |
27 GLDEF_D NTimerQ TheTimerQ; |
28 |
28 |
29 extern "C" void send_irq_ipi(TSubScheduler*, TInt); |
29 extern "C" void send_irq_ipi(TSubScheduler*); |
30 |
30 |
31 #ifndef __MSTIM_MACHINE_CODED__ |
31 #ifndef __MSTIM_MACHINE_CODED__ |
32 #ifdef _DEBUG |
32 #ifdef _DEBUG |
33 #define __DEBUG_CALLBACK(n) {if (iDebugFn) (*iDebugFn)(iDebugPtr,n);} |
33 #define __DEBUG_CALLBACK(n) {if (iDebugFn) (*iDebugFn)(iDebugPtr,n);} |
34 #else |
34 #else |
343 EXPORT_C TInt NTimer::Again(TInt aTime) |
343 EXPORT_C TInt NTimer::Again(TInt aTime) |
344 // |
344 // |
345 // Wait aTime from last trigger time - used for periodic timers |
345 // Wait aTime from last trigger time - used for periodic timers |
346 // |
346 // |
347 { |
347 { |
|
348 __NK_ASSERT_DEBUG(aTime>0); |
348 TInt irq = TheTimerQ.iTimerSpinLock.LockIrqSave(); |
349 TInt irq = TheTimerQ.iTimerSpinLock.LockIrqSave(); |
349 if (!IsValid()) |
350 if (!IsValid()) |
350 { |
351 { |
351 TheTimerQ.iTimerSpinLock.UnlockIrqRestore(irq); |
352 TheTimerQ.iTimerSpinLock.UnlockIrqRestore(irq); |
352 return KErrDied; |
353 return KErrDied; |
583 |
584 |
584 void NTimerQ::Init3(TDfcQue* aDfcQ) |
585 void NTimerQ::Init3(TDfcQue* aDfcQ) |
585 { |
586 { |
586 __KTRACE_OPT(KBOOT,DEBUGPRINT("NTimerQ::Init3 DFCQ at %08x",aDfcQ)); |
587 __KTRACE_OPT(KBOOT,DEBUGPRINT("NTimerQ::Init3 DFCQ at %08x",aDfcQ)); |
587 TheTimerQ.iDfc.SetDfcQ(aDfcQ); |
588 TheTimerQ.iDfc.SetDfcQ(aDfcQ); |
588 NThreadBase* t = aDfcQ->iThread; |
|
589 t->iRebalanceAttr = 1; |
|
590 } |
589 } |
591 |
590 |
592 #ifndef __MSTIM_MACHINE_CODED__ |
591 #ifndef __MSTIM_MACHINE_CODED__ |
593 void NTimerQ::Add(NTimer* aTimer) |
592 void NTimerQ::Add(NTimer* aTimer) |
594 // |
593 // |
741 @see NTimerQ::TimerAddress() |
740 @see NTimerQ::TimerAddress() |
742 */ |
741 */ |
743 EXPORT_C void NTimerQ::Tick() |
742 EXPORT_C void NTimerQ::Tick() |
744 { |
743 { |
745 TInt irq = iTimerSpinLock.LockIrqSave(); |
744 TInt irq = iTimerSpinLock.LockIrqSave(); |
746 TInt i = TInt(__e32_atomic_add_rlx64(&iMsCount64, 1)) & ETimerQMask; |
745 TInt i=iMsCount & ETimerQMask; |
|
746 iMsCount++; |
747 STimerQ* pQ=iTickQ+i; |
747 STimerQ* pQ=iTickQ+i; |
748 iPresent &= ~(1<<i); |
748 iPresent &= ~(1<<i); |
749 TBool doDfc=FALSE; |
749 TBool doDfc=FALSE; |
750 if (!pQ->iDfcQ.IsEmpty()) |
750 if (!pQ->iDfcQ.IsEmpty()) |
751 { |
751 { |
800 TInt cpu = tied->BeginTiedEvent(); |
800 TInt cpu = tied->BeginTiedEvent(); |
801 if (cpu != NKern::CurrentCpu()) |
801 if (cpu != NKern::CurrentCpu()) |
802 { |
802 { |
803 pC->i_NTimer_iState = TUint8(NTimer::EEventQ + cpu); |
803 pC->i_NTimer_iState = TUint8(NTimer::EEventQ + cpu); |
804 TSubScheduler* ss = TheSubSchedulers + cpu; |
804 TSubScheduler* ss = TheSubSchedulers + cpu; |
805 TInt kick = ss->QueueEvent(pC); |
805 TBool kick = ss->QueueEvent(pC); |
806 iTimerSpinLock.UnlockIrqRestore(irq); |
806 iTimerSpinLock.UnlockIrqRestore(irq); |
807 if (kick) |
807 if (kick) |
808 send_irq_ipi(ss, kick); |
808 send_irq_ipi(ss); |
809 continue; |
809 continue; |
810 } |
810 } |
811 } |
811 } |
812 pC->i_NTimer_iState=NTimer::EIdle; |
812 pC->i_NTimer_iState=NTimer::EIdle; |
813 TAny* p = pC->iPtr; |
813 TAny* p = pC->iPtr; |
919 |
919 |
920 @post Interrupts are disabled. |
920 @post Interrupts are disabled. |
921 */ |
921 */ |
922 EXPORT_C void NTimerQ::Advance(TInt aTicks) |
922 EXPORT_C void NTimerQ::Advance(TInt aTicks) |
923 { |
923 { |
924 CHECK_PRECONDITIONS(MASK_INTERRUPTS_DISABLED,"NTimerQ::Advance"); |
924 CHECK_PRECONDITIONS(MASK_INTERRUPTS_DISABLED,"NTimerQ::Advance"); |
925 __e32_atomic_add_rlx64(&TheTimerQ.iMsCount64, TUint64(TUint32(aTicks))); |
925 TheTimerQ.iMsCount+=(TUint32)aTicks; |
926 } |
926 } |
927 |
927 |
928 |
928 |
929 /** Returns the period of the nanokernel timer. |
929 /** Returns the period of the nanokernel timer. |
930 @return Period in microseconds |
930 @return Period in microseconds |