本文整理汇总了C++中Handle::IsOkayResult方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle::IsOkayResult方法的具体用法?C++ Handle::IsOkayResult怎么用?C++ Handle::IsOkayResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Handle
的用法示例。
在下文中一共展示了Handle::IsOkayResult方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AllocateNew
Handle ExtendedStates::AllocateNew(void * & state)
{
Handle res = ExtendedStatesAllocator.AllocateObject(state);
if (!res.IsOkayResult())
return res;
if (templateState != nullptr)
::memcpy(state, templateState, ExtendedStatesAllocator.ObjectSize);
return HandleResult::Okay;
}
示例2: AllocateTemplate
Handle ExtendedStates::AllocateTemplate(void * & state)
{
if (templateState != nullptr || !ExtendedStates::Initialized)
return HandleResult::UnsupportedOperation;
Handle res = ExtendedStatesAllocator.AllocateObject(state);
if (!res.IsOkayResult())
return res;
templateState = state;
::memset(state, 0, ExtendedStatesAllocator.ObjectSize);
// Clear all the bits, for the cheap (f)xsave implementations that just
// leave the reserved bits/bytes/whatever unchanged.
return HandleResult::Okay;
}
示例3: TestCmdo
void TestCmdo()
{
CMDO(1, "a", "alpha", String);
CMDO(2, "b", "beta", String);
CMDO(3, "c", "gamma", String);
CMDO(4, "s", "sierra", BooleanByPresence);
CMDO(5, "x", "xenulol", BooleanByPresence);
CMDO(6, "y", "york", BooleanByPresence);
Handle res;
res = parser.StartParsing(OptionsString1);
ASSERT(res.IsOkayResult()
, "Failed to start parsing command-line options: %H"
, res);
// for (size_t i = 0; i < parser.Length; ++i)
// if (parser.InputString[i] == '\0')
// parser.InputString[i] = '_';
// msg("Length of \"%S\" is: %us.%n", parser.Length, parser.InputString, parser.Length);
ASSERT(parser.TokenCount == 7
, "Parser should have identified %us tokens, not %us."
, (size_t)7, parser.TokenCount);
PARSE_OPT(1);
PARSE_OPT(2);
PARSE_OPT(3);
PARSE_OPT(4);
PARSE_OPT(5);
PARSE_OPT(6);
CHECK_STR(1, "test a");
CHECK_STR(2, "yada yada");
CHECK_STR(3, "rada");
CHECK_BOL(4, true);
CHECK_BOL(5, true);
CHECK_BOL(6, false);
// AND NOW ROUND 2!
new (&parser) CommandLineOptionParser();
res = parser.StartParsing(OptionsString2);
ASSERT(res.IsOkayResult()
, "Failed to start parsing command-line options: %H"
, res);
// for (size_t i = 0; i < parser.Length; ++i)
// if (parser.InputString[i] == '\0')
// parser.InputString[i] = '_';
// msg("Length of \"%S\" is: %us.%n", parser.Length, parser.InputString, parser.Length);
ASSERT(parser.TokenCount == 6
, "Parser should have identified %us tokens, not %us."
, (size_t)6, parser.TokenCount);
PARSE_OPT(1);
PARSE_OPT(2);
PARSE_OPT(3);
PARSE_OPT(4);
PARSE_OPT(5);
PARSE_OPT(6);
CHECK_STR(1, "test a");
CHECK_STR(2, "yada yada");
CHECK_STR(3, "rada");
CHECK_BOL(4, true);
CHECK_BOL(5, true);
CHECK_BOL(6, false);
// AND NOW ROUND 3!
CMDO(a, "1", "one", SignedInteger);
CMDO(b, "2", "two", SignedInteger);
CMDO(c, "3", "three", SignedInteger);
CMDO(d, "4", "four", SignedInteger);
CMDO(e, "BT", "BT", BooleanExplicit);
CMDO(f, "BF", "BF", BooleanExplicit);
new (&parser) CommandLineOptionParser();
res = parser.StartParsing(OptionsString3);
ASSERT(res.IsOkayResult()
, "Failed to start parsing command-line options: %H"
, res);
// for (size_t i = 0; i < parser.Length; ++i)
// if (parser.InputString[i] == '\0')
// parser.InputString[i] = '_';
// msg("Length of \"%S\" is: %us.%n", parser.Length, parser.InputString, parser.Length);
ASSERT(parser.TokenCount == 11
//.........这里部分代码省略.........
示例4: TestApplication
void TestApplication()
{
// First get the loadtest app's location.
ASSERT(InitRd::Loaded);
Handle file = InitRd::FindItem("/apps/loadtest.exe");
ASSERT(file.IsType(HandleType::InitRdFile)
, "Failed to find loadtest app in InitRD: %H.", file);
FileBoundaries bnd = InitRd::GetFileBoundaries(file);
ASSERT(bnd.Start != 0 && bnd.Size != 0);
// Then attempt parsing it.
Handle res = HandleLoadtest(bnd.Start, bnd.Size);
ASSERT(res.IsOkayResult(), "Error in handling loadtest app: %H.", res);
// Then prepare the necessary processes and threads.
TestRegionLock.Reset();
TestRegionLock.Acquire();
new (&testProcess) Process();
Vmm::Initialize(&testProcess);
new (&testThread) Thread(&testProcess);
new (&testWatcher) Thread(&testProcess);
// DEBUG_TERM_ << "Created app test process and threads." << Terminals::EndLine;
// Then the test thread.
uintptr_t stackVaddr = nullvaddr;
res = Vmm::AllocatePages(nullptr, 3 * PageSize
, MemoryAllocationOptions::Commit | MemoryAllocationOptions::VirtualKernelHeap
| MemoryAllocationOptions::GuardLow | MemoryAllocationOptions::GuardHigh
, MemoryFlags::Global | MemoryFlags::Writable
, MemoryContent::ThreadStack
, stackVaddr);
ASSERT(res.IsOkayResult()
, "Failed to allocate stack for test userland thread: %H."
, res);
testThread.KernelStackTop = stackVaddr + 3 * PageSize;
testThread.KernelStackBottom = stackVaddr;
testThread.EntryPoint = &JumpToRing3;
InitializeThreadState(&testThread);
// This sets up the thread so it goes directly to the entry point when switched to.
withInterrupts (false)
BootstrapThread.IntroduceNext(&testThread);
// DEBUG_TERM_ << "Initialized app test main thread." << Terminals::EndLine;
// Then the watcher thread.
stackVaddr = nullvaddr;
res = Vmm::AllocatePages(nullptr, 3 * PageSize
, MemoryAllocationOptions::Commit | MemoryAllocationOptions::VirtualKernelHeap
| MemoryAllocationOptions::GuardLow | MemoryAllocationOptions::GuardHigh
, MemoryFlags::Global | MemoryFlags::Writable
, MemoryContent::ThreadStack
, stackVaddr);
ASSERT(res.IsOkayResult()
, "Failed to allocate stack for test watcher thread: %H."
, res);
testWatcher.KernelStackTop = stackVaddr + 3 * PageSize;
testWatcher.KernelStackBottom = stackVaddr;
testWatcher.EntryPoint = &WatchTestThread;
InitializeThreadState(&testWatcher);
// This sets up the thread so it goes directly to the entry point when switched to.
withInterrupts (false)
testThread.IntroduceNext(&testWatcher);
// DEBUG_TERM_ << "Initialized app test watcher thread." << Terminals::EndLine;
// That's all, folks. The other threads finish the work.
}
示例5: ASSERT
void * JumpToRing3(void * arg)
{
(void)arg;
Handle res;
// First, the userland stack page.
uintptr_t userStackBottom = nullvaddr;
res = Vmm::AllocatePages(&testProcess
, userStackPageCount * PageSize
, MemoryAllocationOptions::AllocateOnDemand | MemoryAllocationOptions::VirtualUser
| MemoryAllocationOptions::GuardLow | MemoryAllocationOptions::GuardHigh
, MemoryFlags::Userland | MemoryFlags::Writable
, MemoryContent::ThreadStack
, userStackBottom);
ASSERT(res.IsOkayResult()
, "Failed to allocate userland stack for app test thread: %H."
, res);
uintptr_t userStackTop = userStackBottom + userStackPageCount * PageSize;
// DEBUG_TERM_ << "Initialized userland stack for app test main thread." << Terminals::EndLine;
// Then, deploy the runtime.
StartupData * stdat = nullptr;
res = Runtime64::Deploy(rtlib_base, stdat);
ASSERT(res.IsOkayResult()
, "Failed to deploy runtime64 library into test app process: %H."
, res);
ASSERT(stdat != nullptr);
// Then pass on the app image.
res = Vmm::AllocatePages(nullptr
, RoundUp(loadtestEnd - loadtestStart, PageSize)
, MemoryAllocationOptions::Commit | MemoryAllocationOptions::VirtualUser
, MemoryFlags::Userland | MemoryFlags::Writable
, MemoryContent::Generic
, appVaddr);
ASSERT(res.IsOkayResult()
, "Failed to allocate pages for test app image: %H."
, res);
memmove(reinterpret_cast<void *>(appVaddr)
, reinterpret_cast<void const *>(loadtestStart)
, loadtestEnd - loadtestStart);
stdat->MemoryImageStart = appVaddr;
stdat->MemoryImageEnd = loadtestEnd - loadtestStart + appVaddr;
// DEBUG_TERM_ << "Deployed 64-bit runtime for app test process." << Terminals::EndLine;
// Finally, a region for test incrementation.
vaddr_t testRegVaddr = 0x300000000000;
res = Vmm::AllocatePages(&testProcess
, 0x30000
, MemoryAllocationOptions::AllocateOnDemand | MemoryAllocationOptions::VirtualUser
, MemoryFlags::Userland | MemoryFlags::Writable
, MemoryContent::Generic
, testRegVaddr);
ASSERT(res.IsOkayResult()
, "Failed to allocate app test region in userland: %H.%n"
"Stack is between %Xp and %Xp."
, res, userStackBottom, userStackTop);
// DEBUG_TERM_ << "Created test region for app test process." << Terminals::EndLine;
TestRegionLock.Release();
// And finish by going to ring 3.
// DEBUG_TERM_ << "About to go to ring 3!" << EndLine;
CpuInstructions::InvalidateTlb(reinterpret_cast<void const *>(rtlib_base + Runtime64::Template.GetEntryPoint()));
GoToRing3_64(rtlib_base + Runtime64::Template.GetEntryPoint(), userStackTop);
}