1*b5b6f09cSrin /* $NetBSD: eficpufunc.c,v 1.1 2023/07/24 01:56:59 rin Exp $ */
2*b5b6f09cSrin
3*b5b6f09cSrin /*-
4*b5b6f09cSrin * Copyright (c) 2023 The NetBSD Foundation, Inc.
5*b5b6f09cSrin * All rights reserved.
6*b5b6f09cSrin *
7*b5b6f09cSrin * Redistribution and use in source and binary forms, with or without
8*b5b6f09cSrin * modification, are permitted provided that the following conditions
9*b5b6f09cSrin * are met:
10*b5b6f09cSrin * 1. Redistributions of source code must retain the above copyright
11*b5b6f09cSrin * notice, this list of conditions and the following disclaimer.
12*b5b6f09cSrin * 2. Redistributions in binary form must reproduce the above copyright
13*b5b6f09cSrin * notice, this list of conditions and the following disclaimer in the
14*b5b6f09cSrin * documentation and/or other materials provided with the distribution.
15*b5b6f09cSrin *
16*b5b6f09cSrin * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17*b5b6f09cSrin * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18*b5b6f09cSrin * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19*b5b6f09cSrin * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20*b5b6f09cSrin * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21*b5b6f09cSrin * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22*b5b6f09cSrin * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23*b5b6f09cSrin * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24*b5b6f09cSrin * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25*b5b6f09cSrin * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26*b5b6f09cSrin * POSSIBILITY OF SUCH DAMAGE.
27*b5b6f09cSrin */
28*b5b6f09cSrin
29*b5b6f09cSrin #include <sys/cdefs.h>
30*b5b6f09cSrin #include <sys/types.h>
31*b5b6f09cSrin
32*b5b6f09cSrin #include "eficpufunc.h"
33*b5b6f09cSrin
34*b5b6f09cSrin uint8_t
inb(uint32_t addr)35*b5b6f09cSrin inb(uint32_t addr)
36*b5b6f09cSrin {
37*b5b6f09cSrin uint8_t c;
38*b5b6f09cSrin
39*b5b6f09cSrin __asm volatile ("inb %%dx, %%al" : "=a"(c) : "d"(addr));
40*b5b6f09cSrin return c;
41*b5b6f09cSrin }
42*b5b6f09cSrin
43*b5b6f09cSrin void
outb(uint32_t addr,uint8_t c)44*b5b6f09cSrin outb(uint32_t addr, uint8_t c)
45*b5b6f09cSrin {
46*b5b6f09cSrin
47*b5b6f09cSrin __asm volatile ("outb %%al, %%dx" : : "a"(c), "d"(addr));
48*b5b6f09cSrin }
49