本文整理汇总了C++中Memory::access方法的典型用法代码示例。如果您正苦于以下问题:C++ Memory::access方法的具体用法?C++ Memory::access怎么用?C++ Memory::access使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Memory
的用法示例。
在下文中一共展示了Memory::access方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SystemInfoHandler
Error SystemInfoHandler(SystemInformation *info)
{
Memory *memory = Kernel::instance->getMemory();
ProcessManager *procs = Kernel::instance->getProcessManager();
// Verify memory access
if (!memory->access(procs->current(), (Address) info,
sizeof(SystemInformation)))
{
return EFAULT;
}
// Fill in our current information
info->version = VERSIONCODE;
info->memorySize = memory->getTotalMemory();
info->memoryAvail = memory->getAvailableMemory();
// TODO: this interface could be improved using libarch?
info->bootImageAddress = Kernel::instance->getBootImageAddress();
info->bootImageSize = Kernel::instance->getBootImageSize();
// TODO: we dont have the commandline info of kernel yet.
MemoryBlock::copy(info->cmdline, "", 64);
return 0;
}
示例2: ProcessCtlHandler
Error ProcessCtlHandler(ProcessID procID, ProcessOperation action, Address addr)
{
#ifdef __i386__
IntelProcess *proc = ZERO;
Memory *memory = Kernel::instance->getMemory();
ProcessInfo *info = (ProcessInfo *) addr;
ProcessManager *procs = Kernel::instance->getProcessManager();
DEBUG("#" << procs->current()->getID() << " " << action << " -> " << procID << " (" << addr << ")");
/* Verify memory address. */
if (action == InfoPID)
{
if (!memory->access(procs->current(), addr, sizeof(ProcessInfo)))
{
return API::AccessViolation;
}
}
/* Does the target process exist? */
if(action != GetPID && action != Spawn)
{
if (procID == SELF)
proc = (IntelProcess *) procs->current();
else if (!(proc = (IntelProcess *)procs->get(procID)))
return API::NotFound;
}
/* Handle request. */
switch (action)
{
case Spawn:
proc = (IntelProcess *) procs->create(addr);
return proc->getID();
case KillPID:
procs->remove(proc);
break;
case GetPID:
return procs->current()->getID();
case Schedule:
procs->schedule();
break;
case Resume:
proc->setState(Process::Ready);
break;
case AllowIO:
return API::InvalidArgument;
//proc->IOPort(addr, true);
//break;
case WatchIRQ:
Kernel::instance->hookInterrupt(IRQ(addr),
(InterruptHandler *)interruptNotify, (ulong)proc);
Kernel::instance->enableIRQ(addr, true);
break;
case InfoPID:
info->id = proc->getID();
info->state = proc->getState();
info->stack = proc->getStack();
info->pageDirectory = proc->getPageDirectory();
break;
case SetStack:
proc->setStack(addr);
break;
}
#endif
return API::Success;
}
示例3: VMCopyHandler
Error VMCopyHandler(ProcessID procID, API::Operation how, Address ours,
Address theirs, Size sz)
{
ProcessManager *procs = Kernel::instance->getProcessManager();
Memory *memory = Kernel::instance->getMemory();
Process *proc;
Address paddr, tmpAddr;
Size bytes = 0, pageOff, total = 0;
#ifdef __i386__
/* Find the corresponding Process. */
if (!(proc = procs->get(procID)))
{
return API::NotFound;
}
/* Verify memory addresses. */
if (!memory->access(procs->current(), ours, sz) ||
!memory->access(proc, theirs, sz))
{
return API::AccessViolation;
}
/* Keep on going until all memory is processed. */
while (total < sz)
{
/* Update variables. */
paddr = memory->lookup(proc, theirs) & PAGEMASK;
pageOff = theirs & ~PAGEMASK;
bytes = (PAGESIZE - pageOff) < (sz - total) ?
(PAGESIZE - pageOff) : (sz - total);
/* Valid address? */
if (!paddr) break;
/* Map the physical page. */
tmpAddr = memory->map(paddr);
/* Process the action appropriately. */
switch (how)
{
case API::Read:
MemoryBlock::copy((void *)ours, (void *)(tmpAddr + pageOff), bytes);
break;
case API::Write:
MemoryBlock::copy((void *)(tmpAddr + pageOff), (void *)ours, bytes);
break;
default:
;
}
/* Remove mapping. */
memory->map((Address) 0, (Address) tmpAddr, Memory::None);
ours += bytes;
theirs += bytes;
total += bytes;
}
#endif
/* Success. */
return total;
}