//
// get name
//
CHAR8 CONST* DevTreeGetName(DEVICE_TREE_NODE* theNode)
{
	for(DEVICE_TREE_PROPERTY* theProperty	= theNode->Properties; theProperty; theProperty = theProperty->Next)
	{
		if(!strcmp(theProperty->Name, CHAR8_CONST_STRING("name")))
			return static_cast<CHAR8*>(theProperty->Value);
	}

	return CHAR8_CONST_STRING("(null)");
}
//
// initialize
//
EFI_STATUS DevTreeInitialize()
{
	if(!DevTreeAddChild(nullptr, CHAR8_CONST_STRING("/")))
		return EFI_OUT_OF_RESOURCES;

	return EFI_SUCCESS;
}
Exemplo n.º 3
0
//
// setup thunk code
//
VOID ArchSetupThunkCode0(UINT64 thunkOffset, MACH_O_LOADED_INFO* loadedInfo)
{
	if(loadedInfo)
	{
		ArchpKernelIdlePML4													= MachFindSymbolVirtualAddressByName(loadedInfo, CHAR8_CONST_STRING("_IdlePML4")); //0x8c0ac8 + thunkOffset;
		EfiRuntimeServices->SetVariable(CHAR16_STRING(L"IdlePML4"), &AppleNVRAMVariableGuid, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, sizeof(UINT64), &ArchpKernelIdlePML4);
	}
	else
	{
		UINTN dataSize														= sizeof(UINT64);
		EfiRuntimeServices->GetVariable(CHAR16_STRING(L"IdlePML4"), &AppleNVRAMVariableGuid, nullptr, &dataSize, &ArchpKernelIdlePML4);
	}
}
//
// add child
//
DEVICE_TREE_NODE* DevTreeAddChild(DEVICE_TREE_NODE* parentNode, CHAR8 CONST* childName)
{
	DEVICE_TREE_NODE* theNode												= DevTreepGetNode();
	if(!theNode)
		return nullptr;

	if(parentNode)
	{
		theNode->Next														= parentNode->Children;
		parentNode->Children												= theNode;
	}
	else
	{
		DevTreepRootNode													= theNode;
	}

	EFI_STATUS status														= DevTreeAddProperty(theNode, CHAR8_CONST_STRING("name"), childName, static_cast<UINT32>(strlen(childName) + 1) * sizeof(CHAR8), TRUE);
	if(!EFI_ERROR(status))
		return theNode;

	DevTreepFreeNode(theNode);
	return nullptr;
}