/* * print a new line */ static void newline(void) { uint16_t* sp = (uint16_t*)tvPtr->screen; col = 0; if (++row == TV_TEXT_ROWS) { row--; wordmove(sp, &sp[TV_TEXT_COLS], TV_TEXT_LASTROW); // scroll wordfill(&sp[TV_TEXT_LASTROW], blank, TV_TEXT_COLS); // clear new line } }
TInt NThread::Create(SNThreadCreateInfo& anInfo, TBool aInitial) { if (!anInfo.iStackBase || anInfo.iStackSize<0x100) return KErrArgument; TInt r=NThreadBase::Create(anInfo,aInitial); if (r!=KErrNone) return r; if (!aInitial) { TUint32* sp=(TUint32*)(iStackBase+iStackSize-anInfo.iParameterBlockSize); TUint32 esi=(TUint32)anInfo.iParameterBlock; if (anInfo.iParameterBlockSize) { wordmove(sp,anInfo.iParameterBlock,anInfo.iParameterBlockSize); esi=(TUint32)sp; } SThreadStack* stack=((SThreadStack*)sp)-1; stack->iCR0=X86::DefaultCR0 | KX86CR0_TS; stack->iEbx=0; stack->iEsi=esi; // parameter block pointer stack->iEdi=(TUint32)anInfo.iFunction; stack->iEbp=0; stack->iGs=KRing0DS; stack->iFs=0; stack->iReschedFlag=1; stack->iEip=(TUint32)__StartThread; iSavedSP=(TLinAddr)stack; wordmove(&iCoprocessorState, DefaultCoprocessorState, sizeof(iCoprocessorState)); } else { #ifdef MONITOR_THREAD_CPU_TIME iLastStartTime = NKern::FastCounter(); #endif NKern::EnableAllInterrupts(); } #ifdef BTRACE_THREAD_IDENTIFICATION BTrace4(BTrace::EThreadIdentification,BTrace::ENanoThreadCreate,this); #endif return KErrNone; }
TInt RAddressedContainer::Add(TLinAddr aAddress, TAny* aObject) { __NK_ASSERT_DEBUG(aObject); __ASSERT_CRITICAL; __NK_ASSERT_DEBUG(CheckWriteLock()); #ifdef _DEBUG if(K::CheckForSimulatedAllocFail()) { __KTRACE_OPT(KMMU,Kern::Printf("RAddressedContainer::Add returns simulated OOM %d",KErrNoMemory)); return KErrNoMemory; } #endif // find list insertion point... TUint i = FindIndex(aAddress); if(iCount<iMaxCount) { // insert new entry... ReadLock(); // make room by shuffling entries up in the array KMaxEntriesInOneGo at a time... TEntry* entry = iList+i; TEntry* prev = iList+iCount; ++iCount; // must do this before releasing read lock for the first time for(;;) { TEntry* next = prev-KMaxEntriesInOneGo; if(next<=entry) { // move the final remaining entries... wordmove(entry+1,entry,(TUintPtr)prev-(TUintPtr)entry); break; } wordmove(next+1,next,(TUintPtr)prev-(TUintPtr)next); prev = next; // flash the read lock to give readers a chance to look at the list... ReadFlash(); // Note, readers may see a duplicate entry in the list at 'prev' but this // is OK as the Find functions will still work. } // copy in new entry... entry->iAddress = aAddress; entry->iObject = aObject; ReadUnlock(); } else { // list memory needs expanding... TUint newMaxCount = CalculateGrow(); // allocate new memory... TEntry* newList = (TEntry*)Kern::Alloc(sizeof(TEntry)*newMaxCount); if(!newList) return KErrNoMemory; #ifdef _DEBUG if(iList) K::Allocator->DebugFunction(RAllocator::ECopyDebugInfo, iList, newList); #endif iMaxCount = newMaxCount; // copy list to new memory, and insert new entry... wordmove(newList,iList,sizeof(TEntry)*i); TEntry* entry = newList+i; entry->iAddress = aAddress; entry->iObject = aObject; wordmove(entry+1,iList+i,sizeof(TEntry)*(iCount-i)); // start using new list... TEntry* oldList = iList; ReadLock(); iList = newList; ++iCount; ReadUnlock(); // free memory used for old list... Kern::Free(oldList); } return KErrNone; }
TAny* RAddressedContainer::Remove(TLinAddr aAddress) { __ASSERT_CRITICAL; __NK_ASSERT_DEBUG(CheckWriteLock()); // search for it... TUint i = FindIndex(aAddress); TEntry* entry = iList+i-1; if(!i || entry->iAddress!=aAddress) { // not found... return 0; } --i; // make 'i' the index of entry to remove // get object... TAny* result = entry->iObject; __NK_ASSERT_DEBUG(result); TUint newMaxCount = CalculateShrink(iCount-1); if(newMaxCount>=iMaxCount) { remove_without_resize: // remove old entry... ReadLock(); // shuffling entries down in the array KMaxEntriesInOneGo at a time... TEntry* prev = iList+i+1; TEntry* end = iList+iCount; for(;;) { TEntry* next = prev+KMaxEntriesInOneGo; if(next>=end) { // move the final remaining entries... wordmove(prev-1,prev,(TUintPtr)end-(TUintPtr)prev); break; } wordmove(prev-1,prev,(TUintPtr)next-(TUintPtr)prev); prev = next; // flash the read lock to give readers a chance to look at the list... ReadFlash(); // Note, readers may see a duplicate entry at the end of the list but this // is OK as the Find functions will still work. } --iCount; // must do this after moving all the entries ReadUnlock(); } else { // list memory needs shrinking... // allocate new memory... TEntry* newList = 0; if(newMaxCount) { newList = (TEntry*)Kern::Alloc(sizeof(TEntry)*newMaxCount); if(!newList) goto remove_without_resize; // have no memory to shrink array #ifdef _DEBUG if(iList) K::Allocator->DebugFunction(RAllocator::ECopyDebugInfo, iList, newList); #endif } iMaxCount = newMaxCount; // copy list to new memory, deleting removed entry... wordmove(newList,iList,sizeof(TEntry)*i); wordmove(newList+i,iList+i+1,sizeof(TEntry)*(iCount-i-1)); // start using new list... TEntry* oldList = iList; ReadLock(); iList = newList; --iCount; ReadUnlock(); // free memory used for old list... Kern::Free(oldList); } return result; }
// --------------------------------------------------------------------------- // From class MWlanOsa. // --------------------------------------------------------------------------- // void* MWlanOsa::WordCpy( TInt* aDest, const TInt* aSrc, TUint aLengthinBytes ) { return wordmove( aDest, aSrc, aLengthinBytes ); }
TInt DKUCopy::Request(TInt aFunction, TAny* a1, TAny* a2) // // Client requests // { TInt r=KErrNone; switch (aFunction) { case RKUCopy::EControlPut: { SCopyInfo info; kumemget(&info, a1, sizeof(info)); kumemput( (TUint8*)info.iPtr, ((const TUint8*)RandomData)+info.iOffset, info.iLength ); break; } case RKUCopy::EControlGet: { SCopyInfo info; kumemget(&info, a1, sizeof(info)); wordmove(iBuf,RandomData,KBufSize); kumemget( iBuf+info.iOffset, info.iPtr, info.iLength ); break; } case RKUCopy::EControlPut32: { SCopyInfo info; kumemget(&info, a1, sizeof(info)); kumemput32( (TUint8*)info.iPtr, ((const TUint8*)RandomData)+info.iOffset, info.iLength ); break; } case RKUCopy::EControlGet32: { SCopyInfo info; kumemget(&info, a1, sizeof(info)); wordmove(iBuf,RandomData,KBufSize); kumemget32( iBuf+info.iOffset, info.iPtr, info.iLength ); break; } case RKUCopy::EControlSet: { SSetInfo info; kumemget(&info, a1, sizeof(info)); kumemset( info.iPtr, (TUint8)info.iValue, info.iLength ); break; } case RKUCopy::EControlLength: r=KBufSize; break; case RKUCopy::EControlRead: { kumemput(a1,iBuf,KBufSize); break; } case RKUCopy::EControlRandomLength: r=(TInt)sizeof(RandomData); break; case RKUCopy::EControlReadRandom: kumemput(a1,RandomData,sizeof(RandomData)); break; case RKUCopy::EControlDesPut8: { TPtr8 buf(iBuf,0,KBufSize); Kern::KUDesGet(buf,*(const TDesC8*)a2); Kern::KUDesPut(*(TDes8*)a1,buf); break; } case RKUCopy::EControlDesGet8: { TPtr8 buf(iBuf,0,KBufSize); Kern::KUDesGet(buf,*(const TDesC8*)a2); Kern::KUDesPut(*((TDes8*)a1),buf); break; } case RKUCopy::EControlDesInfo8: { SDesInfo info; info.iPtr=(TAny*)Kern::KUDesInfo(*(const TDesC8*)a1,info.iLength,info.iMaxLength); kumemput(a2,&info,sizeof(info)); break; } case RKUCopy::EControlKernBufAddr: r=(TInt)iBuf; break; case RKUCopy::EControlRequestComplete: Kern::RequestComplete(*(TRequestStatus**)&a1, KErrNone); break; case RKUCopy::EControlRequestCompleteLocal: Kern::RequestComplete(*(TRequestStatus**)&a1, KErrNone); break; case RKUCopy::EControlQueueRequestComplete: r = iClientRequest->SetStatus((TRequestStatus*)a1); Kern::QueueRequestComplete(&Kern::CurrentThread(), iClientRequest, KErrNone); break; default: r=KErrNotSupported; break; } return r; }