/* * Return the physical address of the requested table or zero if one * is not found. */ vm_paddr_t acpi_find_table(const char *sig) { ACPI_PHYSICAL_ADDRESS rsdp_ptr; ACPI_TABLE_RSDP *rsdp; ACPI_TABLE_XSDT *xsdt; ACPI_TABLE_HEADER *table; vm_paddr_t addr; int i, count; if (resource_disabled("acpi", 0)) return (0); /* * Map in the RSDP. Since ACPI uses AcpiOsMapMemory() which in turn * calls pmap_mapbios() to find the RSDP, we assume that we can use * pmap_mapbios() to map the RSDP. */ if ((rsdp_ptr = AcpiOsGetRootPointer()) == 0) return (0); rsdp = pmap_mapbios(rsdp_ptr, sizeof(ACPI_TABLE_RSDP)); if (rsdp == NULL) { if (bootverbose) printf("ACPI: Failed to map RSDP\n"); return (0); } addr = 0; if (rsdp->Revision >= 2 && rsdp->XsdtPhysicalAddress != 0) { /* * AcpiOsGetRootPointer only verifies the checksum for * the version 1.0 portion of the RSDP. Version 2.0 has * an additional checksum that we verify first. */ if (AcpiTbChecksum((UINT8 *)rsdp, ACPI_RSDP_XCHECKSUM_LENGTH)) { if (bootverbose) printf("ACPI: RSDP failed extended checksum\n"); return (0); } xsdt = map_table(rsdp->XsdtPhysicalAddress, 2, ACPI_SIG_XSDT); if (xsdt == NULL) { if (bootverbose) printf("ACPI: Failed to map XSDT\n"); pmap_unmapbios((vm_offset_t)rsdp, sizeof(ACPI_TABLE_RSDP)); return (0); } count = (xsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) / sizeof(UINT64); for (i = 0; i < count; i++) if (probe_table(xsdt->TableOffsetEntry[i], sig)) { addr = xsdt->TableOffsetEntry[i]; break; } acpi_unmap_table(xsdt); } pmap_unmapbios((vm_offset_t)rsdp, sizeof(ACPI_TABLE_RSDP)); if (addr == 0) { if (bootverbose) printf("ACPI: No %s table found\n", sig); return (0); } if (bootverbose) printf("%s: Found table at 0x%jx\n", sig, (uintmax_t)addr); /* * Verify that we can map the full table and that its checksum is * correct, etc. */ table = map_table(addr, 0, sig); if (table == NULL) return (0); acpi_unmap_table(table); return (addr); }
bool MapMode::_Load() { // Map data // Clear out all old map data if existing. ScriptManager->DropGlobalTable("map_data"); // Open map script file and read in the basic map properties and tile definitions if(!_map_script.OpenFile(_map_data_filename)) { PRINT_ERROR << "Couldn't open map data file: " << _map_data_filename << std::endl; return false; } if(!_map_script.OpenTable("map_data")) { PRINT_ERROR << "Couldn't open table 'map_data' in: " << _map_data_filename << std::endl; _map_script.CloseFile(); return false; } // Loads the collision grid if(!_object_supervisor->Load(_map_script)) { PRINT_ERROR << "Failed to load the collision grid from: " << _map_data_filename << std::endl; _map_script.CloseFile(); return false; } // Instruct the supervisor classes to perform their portion of the load operation if(!_tile_supervisor->Load(_map_script)) { PRINT_ERROR << "Failed to load the tile data from: " << _map_data_filename << std::endl; _map_script.CloseFile(); return false; } _map_script.CloseAllTables(); _map_script.CloseFile(); // Free the map data file once everyhting is loaded // Map script _map_script_tablespace = ScriptEngine::GetTableSpace(_map_script_filename); if(_map_script_tablespace.empty()) { PRINT_ERROR << "Invalid map script namespace in: " << _map_script_filename << std::endl; return false; } // Clear out all old map data if existing. ScriptManager->DropGlobalTable(_map_script_tablespace); // Open map script file and read in the basic map properties and tile definitions if(!_map_script.OpenFile(_map_script_filename)) { PRINT_ERROR << "Couldn't open map script file: " << _map_script_filename << std::endl; return false; } if(_map_script.OpenTablespace().empty()) { PRINT_ERROR << "Couldn't open map script namespace in: " << _map_script_filename << std::endl; _map_script.CloseFile(); return false; } // Loads the map image and translated location names. // Test for empty strings to never trigger the default gettext msg string // which contains translation info. std::string map_hud_name = _map_script.ReadString("map_name"); _map_hud_name.SetText(map_hud_name.empty() ? ustring() : UTranslate(map_hud_name), TextStyle("map_title")); std::string map_hud_subname = _map_script.ReadString("map_subname"); _map_hud_subname.SetText(map_hud_subname.empty() ? ustring() : UTranslate(map_hud_subname), TextStyle("title24")); std::string map_image_filename = _map_script.ReadString("map_image_filename"); if(!map_image_filename.empty() && !_map_image.Load(map_image_filename)) PRINT_ERROR << "Failed to load location graphic image: " << map_image_filename << std::endl; // Load map default music // NOTE: Other audio handling will be handled through scripting _music_filename = _map_script.ReadString("music_filename"); if(!_music_filename.empty() && !AudioManager->LoadMusic(_music_filename, this)) PRINT_WARNING << "Failed to load map music: " << _music_filename << std::endl; else if (!_music_filename.empty()) _audio_state = AUDIO_STATE_PLAYING; // Set the default music state to "playing". // Call the map script's custom load function and get a reference to all other script function pointers ScriptObject map_table(luabind::from_stack(_map_script.GetLuaState(), vt_script::private_script::STACK_TOP)); ScriptObject function = map_table["Load"]; bool loading_succeeded = true; if(function.is_valid()) { try { ScriptCallFunction<void>(function, this); } catch(const luabind::error &e) { ScriptManager->HandleLuaError(e); loading_succeeded = false; } catch(const luabind::cast_failed &e) { ScriptManager->HandleCastError(e); loading_succeeded = false; } } else { loading_succeeded = false; } if(!loading_succeeded) { PRINT_ERROR << "Invalid map Load() function in " << _map_script_filename << ". The function wasn't called." << std::endl; _map_script.CloseAllTables(); _map_script.CloseFile(); return false; } _update_function = _map_script.ReadFunctionPointer("Update"); _map_script.CloseAllTables(); _map_script.CloseFile(); // Free the map script file once everything is loaded return true; } // bool MapMode::_Load()
/* * Try to map a table at a given physical address previously returned * by acpi_find_table(). */ void * acpi_map_table(vm_paddr_t pa, const char *sig) { return (map_table(pa, 0, sig)); }