xref: /freebsd/sys/dev/acpica/apeivar.h (revision 7fc2c9f688efb12beddd58a01628157e32b632b0)
19313f6b0SJohn Baldwin /*-
29313f6b0SJohn Baldwin  * SPDX-License-Identifier: BSD-2-Clause
39313f6b0SJohn Baldwin  *
49313f6b0SJohn Baldwin  * Copyright (c) 2020 Alexander Motin <mav@FreeBSD.org>
59313f6b0SJohn Baldwin  * Copyright (c) 2025 Netflix, Inc.
69313f6b0SJohn Baldwin  *
79313f6b0SJohn Baldwin  * Redistribution and use in source and binary forms, with or without
89313f6b0SJohn Baldwin  * modification, are permitted provided that the following conditions
99313f6b0SJohn Baldwin  * are met:
109313f6b0SJohn Baldwin  * 1. Redistributions of source code must retain the above copyright
119313f6b0SJohn Baldwin  *    notice, this list of conditions and the following disclaimer.
129313f6b0SJohn Baldwin  * 2. Redistributions in binary form must reproduce the above copyright
139313f6b0SJohn Baldwin  *    notice, this list of conditions and the following disclaimer in the
149313f6b0SJohn Baldwin  *    documentation and/or other materials provided with the distribution.
159313f6b0SJohn Baldwin  *
169313f6b0SJohn Baldwin  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
179313f6b0SJohn Baldwin  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
189313f6b0SJohn Baldwin  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
199313f6b0SJohn Baldwin  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
209313f6b0SJohn Baldwin  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
219313f6b0SJohn Baldwin  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
229313f6b0SJohn Baldwin  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
239313f6b0SJohn Baldwin  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
249313f6b0SJohn Baldwin  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
259313f6b0SJohn Baldwin  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
269313f6b0SJohn Baldwin  * SUCH DAMAGE.
279313f6b0SJohn Baldwin  */
289313f6b0SJohn Baldwin 
299313f6b0SJohn Baldwin #ifndef __APEIVAR_H__
309313f6b0SJohn Baldwin #define	__APEIVAR_H__
319313f6b0SJohn Baldwin 
329313f6b0SJohn Baldwin #include "apei_if.h"
339313f6b0SJohn Baldwin 
349313f6b0SJohn Baldwin struct resource_map *apei_map_register(device_t dev, ACPI_GENERIC_ADDRESS *gas);
359313f6b0SJohn Baldwin struct resource_map *apei_map_memory(device_t dev, rman_res_t start,
369313f6b0SJohn Baldwin     rman_res_t len);
379313f6b0SJohn Baldwin int	apei_unmap_register(device_t dev, struct resource_map *map);
389313f6b0SJohn Baldwin 
399313f6b0SJohn Baldwin #ifdef __i386__
409313f6b0SJohn Baldwin static __inline uint64_t
bus_space_read_8(bus_space_tag_t tag,bus_space_handle_t bsh,bus_size_t offset)41*7fc2c9f6SShengYi Hung bus_space_read_8(bus_space_tag_t tag, bus_space_handle_t bsh, bus_size_t offset)
429313f6b0SJohn Baldwin {
43*7fc2c9f6SShengYi Hung 	return (bus_space_read_4(tag, bsh, offset) |
44*7fc2c9f6SShengYi Hung 	    ((uint64_t)bus_space_read_4(tag, bsh, offset + 4)) << 32);
459313f6b0SJohn Baldwin }
469313f6b0SJohn Baldwin static __inline void
bus_space_write_8(bus_space_tag_t tag,bus_space_handle_t bsh,bus_size_t offset,uint64_t val)47*7fc2c9f6SShengYi Hung bus_space_write_8(bus_space_tag_t tag, bus_space_handle_t bsh,
48*7fc2c9f6SShengYi Hung     bus_size_t offset, uint64_t val)
499313f6b0SJohn Baldwin {
50*7fc2c9f6SShengYi Hung 	bus_space_write_4(tag, bsh, offset, val);
51*7fc2c9f6SShengYi Hung 	bus_space_write_4(tag, bsh, offset + 4, val >> 32);
529313f6b0SJohn Baldwin }
539313f6b0SJohn Baldwin #endif
549313f6b0SJohn Baldwin 
559313f6b0SJohn Baldwin #endif /* !__APEIVAR_H__ */
56