184447Sdfr/*-
284447Sdfr * Copyright (c) 2000,2001 Michael Smith
384447Sdfr * Copyright (c) 2000 BSDi
484447Sdfr * All rights reserved.
584447Sdfr *
684447Sdfr * Redistribution and use in source and binary forms, with or without
784447Sdfr * modification, are permitted provided that the following conditions
884447Sdfr * are met:
984447Sdfr * 1. Redistributions of source code must retain the above copyright
1084447Sdfr *    notice, this list of conditions and the following disclaimer.
1184447Sdfr * 2. Redistributions in binary form must reproduce the above copyright
1284447Sdfr *    notice, this list of conditions and the following disclaimer in the
1384447Sdfr *    documentation and/or other materials provided with the distribution.
1484447Sdfr *
1584447Sdfr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1684447Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1784447Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1884447Sdfr * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1984447Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2084447Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2184447Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2284447Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2384447Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2484447Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2584447Sdfr * SUCH DAMAGE.
2684447Sdfr */
2784447Sdfr
28135453Smarcel#include <sys/cdefs.h>
29135453Smarcel__FBSDID("$FreeBSD$");
30135453Smarcel
31108026Smarcel#include <sys/types.h>
32108026Smarcel#include <sys/sysctl.h>
33135453Smarcel#include <machine/efi.h>
3484447Sdfr
35193530Sjkim#include <contrib/dev/acpica/include/acpi.h>
3684447Sdfr
37135453Smarcelstatic u_long acpi_root_phys;
38108026Smarcel
39135453SmarcelSYSCTL_ULONG(_machdep, OID_AUTO, acpi_root, CTLFLAG_RD, &acpi_root_phys, 0,
40135453Smarcel    "The physical address of the RSDP");
41108026Smarcel
4284447SdfrACPI_STATUS
4384447SdfrAcpiOsInitialize(void)
4484447Sdfr{
45135453Smarcel
46215023Sjkim	return (AE_OK);
4784447Sdfr}
4884447Sdfr
4984447SdfrACPI_STATUS
5084447SdfrAcpiOsTerminate(void)
5184447Sdfr{
52135453Smarcel
53215023Sjkim	return (AE_OK);
5484447Sdfr}
5584447Sdfr
56215023Sjkimstatic u_long
57215023Sjkimacpi_get_root_from_efi(void)
58215023Sjkim{
59215023Sjkim	static struct uuid acpi_root_uuid = EFI_TABLE_ACPI20;
60215023Sjkim	void *acpi_root;
61215023Sjkim
62215023Sjkim	acpi_root = efi_get_table(&acpi_root_uuid);
63215023Sjkim	if (acpi_root != NULL)
64215023Sjkim		return (IA64_RR_MASK((uintptr_t)acpi_root));
65215023Sjkim
66215023Sjkim	return (0);
67215023Sjkim}
68215023Sjkim
69167814SjkimACPI_PHYSICAL_ADDRESS
70167814SjkimAcpiOsGetRootPointer(void)
7184447Sdfr{
72135453Smarcel
73215023Sjkim	if (acpi_root_phys == 0)
74215023Sjkim		acpi_root_phys = acpi_get_root_from_efi();
7584447Sdfr
76167814Sjkim	return (acpi_root_phys);
7784447Sdfr}
78