本文整理汇总了C++中MemoryContext::lookup方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryContext::lookup方法的具体用法?C++ MemoryContext::lookup怎么用?C++ MemoryContext::lookup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryContext
的用法示例。
在下文中一共展示了MemoryContext::lookup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VMCopyHandler
Error VMCopyHandler(ProcessID procID, API::Operation how, Address ours,
Address theirs, Size sz)
{
ProcessManager *procs = Kernel::instance->getProcessManager();
Process *proc;
Address paddr, vaddr;
Size bytes = 0, pageOff, total = 0;
// Find the corresponding Process
if (procID == SELF)
proc = procs->current();
else if (!(proc = procs->get(procID)))
return API::NotFound;
// TODO: Verify memory addresses
MemoryContext *local = procs->current()->getMemoryContext();
MemoryContext *remote = proc->getMemoryContext();
// Keep on going until all memory is processed
while (total < sz)
{
/* Update variables. */
if (how == API::ReadPhys)
paddr = theirs & PAGEMASK;
else if (remote->lookup(theirs, &paddr) != MemoryContext::Success)
return API::AccessViolation;
pageOff = theirs & ~PAGEMASK;
bytes = (PAGESIZE - pageOff) < (sz - total) ?
(PAGESIZE - pageOff) : (sz - total);
/* Valid address? */
if (!paddr) break;
// Map their address into our local address space
if (local->findFree(PAGESIZE, MemoryMap::KernelPrivate, &vaddr) != MemoryContext::Success)
return API::RangeError;
local->map(vaddr, paddr, Memory::Readable | Memory::Writable);
/* Process the action appropriately. */
switch (how)
{
case API::Read:
case API::ReadPhys:
MemoryBlock::copy((void *)ours, (void *)(vaddr + pageOff), bytes);
break;
case API::Write:
MemoryBlock::copy((void *)(vaddr + pageOff), (void *)ours, bytes);
break;
default:
;
}
// Unmap
local->unmap(vaddr);
// Update counters
ours += bytes;
theirs += bytes;
total += bytes;
}
return total;
}