ER_UINT strncpy_u2k(thread_t *th, void *to, const void *from, const size_t bytes) { PTE *dir = (PTE*)kern_p2v(th->mpu.cr3); void *p = getPageAddress(dir, from); if (p) { UB *w = (UB*)to; UB *r = (UB*)from; size_t left = bytes; size_t offset = getOffset(r); size_t len = PAGE_SIZE - offset; p += offset; do { bool done; len = (left < len)? left:len; done = copy(w, p, &len); left -= len; if (done || !left) return bytes - left; w += len; r += len; len = PAGE_SIZE; } while ((p = getPageAddress(dir, r))); } return E_PAR; }
uint32_t UpdatePageHandle(uint32_t sourceAddress, uint32_t destinationAddress, uint32_t numberOfBytes) { /*! * This function is called when Write was issued and is not complete yet. * Inputs: Source and destination for current page write * and Number of bytes yet to be written * Output: Updates the offset addresses and returns number of bytes scheduled * for current iteration */ currentWrite.currentPageBuffer = sourceAddress; uint32_t pageAddress = getPageAddress(destinationAddress); currentWrite.offsetFreeByteLocation = destinationAddress - pageAddress; if(numberOfBytes > (FLASH_PAGE_SIZE - currentWrite.offsetFreeByteLocation)) { /* We end up here when a portion of the sourceData left to be written goes into current Page*/ currentWrite.numberOfBytesCurrentPage = (FLASH_PAGE_SIZE - currentWrite.offsetFreeByteLocation); } else { /* We reach here when last part of the sourceData can fit into currentPage*/ currentWrite.numberOfBytesCurrentPage = numberOfBytes; } return(numberOfBytes - currentWrite.numberOfBytesCurrentPage); }
bool ProcessInfo::blockInMemory( char * start ) { start = getPageAddress(start); char x = 0; if ( mincore( start , 128 , &x ) ) { log() << "mincore failed: " << errnoWithDescription() << endl; return 1; } return x & 0x1; }