]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/linux/libio.h
seccomp: Add filter flag to opt-out of SSB mitigation
[mirror_ubuntu-artful-kernel.git] / include / linux / libio.h
CommitLineData
90a4bbef 1/*
2 * Copyright (C) 2017 Hisilicon Limited, All Rights Reserved.
3 * Author: Zhichang Yuan <yuanzhichang@hisilicon.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __LINUX_LIBIO_H
19#define __LINUX_LIBIO_H
20
21#ifdef __KERNEL__
22
c838920e 23#include <linux/device.h>
90a4bbef 24#include <linux/fwnode.h>
25
26/* This is compatible to PCI MMIO. */
27#define IO_CPU_MMIO 0x01
28/* All hosts where there are no CPU addr */
29#define IO_HOST_INDIRECT 0x02
30
31struct libio_range {
32 struct list_head list;
33 struct fwnode_handle *node;
34 resource_size_t size; /* range size populated */
35 resource_size_t io_start; /* logical pio start. inclusive */
36 resource_size_t hw_start;
37 unsigned long flags;
38 void *devpara; /* private parameter of the host device */
39 struct libio_ops *ops; /* ops operating on this node */
40};
41
42struct libio_ops {
43 u32 (*pfin)(void *devobj, unsigned long ptaddr, size_t dlen);
44 void (*pfout)(void *devobj, unsigned long ptaddr, u32 outval,
45 size_t dlen);
46 u32 (*pfins)(void *devobj, unsigned long ptaddr, void *inbuf,
47 size_t dlen, unsigned int count);
48 void (*pfouts)(void *devobj, unsigned long ptaddr,
49 const void *outbuf, size_t dlen, unsigned int count);
50};
51
52extern u8 libio_inb(unsigned long addr);
53extern void libio_outb(u8 value, unsigned long addr);
54extern void libio_outw(u16 value, unsigned long addr);
55extern void libio_outl(u32 value, unsigned long addr);
56extern u16 libio_inw(unsigned long addr);
57extern u32 libio_inl(unsigned long addr);
58extern void libio_outb(u8 value, unsigned long addr);
59extern void libio_outw(u16 value, unsigned long addr);
60extern void libio_outl(u32 value, unsigned long addr);
61extern void libio_insb(unsigned long addr, void *buffer, unsigned int count);
62extern void libio_insl(unsigned long addr, void *buffer, unsigned int count);
63extern void libio_insw(unsigned long addr, void *buffer, unsigned int count);
64extern void libio_outsb(unsigned long addr, const void *buffer,
65 unsigned int count);
66extern void libio_outsw(unsigned long addr, const void *buffer,
67 unsigned int count);
68extern void libio_outsl(unsigned long addr, const void *buffer,
69 unsigned int count);
70#ifdef CONFIG_LIBIO
71extern struct libio_range
72*find_io_range_from_fwnode(struct fwnode_handle *fwnode);
73extern unsigned long libio_translate_hwaddr(struct fwnode_handle *fwnode,
74 resource_size_t hw_addr);
369b6172 75extern struct libio_range *register_libio_range(struct libio_range *newrange);
76extern resource_size_t libio_to_hwaddr(unsigned long pio);
77
78extern unsigned long libio_translate_cpuaddr(resource_size_t hw_addr);
90a4bbef 79#else
80static inline struct libio_range
81*find_io_range_from_fwnode(struct fwnode_handle *fwnode)
82{
83 return NULL;
84}
85
86static inline unsigned long libio_translate_hwaddr(struct fwnode_handle *fwnode,
87 resource_size_t hw_addr)
88{
89 return -1;
90}
90a4bbef 91
369b6172 92static inline struct libio_range
93*register_libio_range(struct libio_range *newrange)
94{
95 return NULL;
96}
90a4bbef 97
369b6172 98static inline resource_size_t libio_to_hwaddr(unsigned long pio)
99{
100 return -1;
101}
102
103static inline unsigned long libio_translate_cpuaddr(resource_size_t hw_addr)
104{
105 return -1;
106}
107#endif
90a4bbef 108
c838920e 109#ifdef CONFIG_ACPI
110extern int acpi_set_libio_resource(struct device *child,
111 struct device *hostdev);
112#else
113static inline int acpi_set_libio_resource(struct device *child,
114 struct device *hostdev)
115{
116 return -EFAULT;
117}
118#endif /* CONFIG_ACPI */
90a4bbef 119#endif /* __KERNEL__ */
120#endif /* __LINUX_LIBIO_H */