Update contrib.
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\drivers\usbcc\queue.cpp
15 // Platform independent layer (PIL) of the USB Device controller driver:
16 // Simple singly linked list + its iterator.
25 #include <drivers/usbc.h>
28 void TSglQueLink::Enque(TSglQueLink* aLink)
30 // Enque this after aLink.
38 TSglQueBase::TSglQueBase(TInt aOffset)
42 : iHead(NULL), iLast((TSglQueLink*) &iHead), iOffset(aOffset), iElements(0)
44 // ESQueOffsetNotAligned
45 __ASSERT_ALWAYS((iOffset % 4 == 0), Kern::Fault(KUsbPILPanicCat, __LINE__));
49 void TSglQueBase::DoAddLast(TAny* aPtr)
51 // Add the object at the end of the queue.
54 TSglQueLink* pL = PtrAdd((TSglQueLink*) aPtr, iOffset);
58 __ASSERT_DEBUG((iElements > 0), Kern::Fault(KUsbPILPanicCat, __LINE__));
62 void TSglQueBase::DoRemove(TAny* aPtr)
64 // Remove the object from the queue.
67 TSglQueLink* pP = (TSglQueLink*) (&iHead);
68 TSglQueLink* pL = PtrAdd((TSglQueLink*) aPtr, iOffset);
69 TSglQueLink* pN = pP->iNext;
74 pP->iNext = pN->iNext;
79 iLast = (TSglQueLink*) (&iHead);
82 __ASSERT_DEBUG((iElements >= 0), Kern::Fault(KUsbPILPanicCat, __LINE__));
88 // This doesn't have to indicate an error (but might):
89 __KTRACE_OPT(KPANIC, Kern::Printf("TSglQueBase::DoRemove: ESQueLinkNotQueued"));
93 TSglQueIterBase::TSglQueIterBase(TSglQueBase& aQue)
97 : iOffset(aQue.iOffset), iHead(aQue.iHead), iNext(aQue.iHead)
102 void TSglQueIterBase::SetToFirst()
104 // Start from the beginning of the que.
107 iNext = iHead->iNext;
111 TAny* TSglQueIterBase::DoPostInc()
113 // Return the current pointer and increment.
119 iNext = iNext->iNext;
120 return PtrSub(pN, iOffset);