2 * Copyright (c) 2011 The Chromium OS Authors.
4 * SPDX-License-Identifier: GPL-2.0+
7 #ifndef __SANDBOX_ASM_IO_H
8 #define __SANDBOX_ASM_IO_H
10 void *phys_to_virt(phys_addr_t paddr);
11 #define phys_to_virt phys_to_virt
13 phys_addr_t virt_to_phys(void *vaddr);
14 #define virt_to_phys virt_to_phys
16 void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags);
17 #define map_physmem map_physmem
20 * Take down a mapping set up by map_physmem().
22 void unmap_physmem(const void *vaddr, unsigned long flags);
23 #define unmap_physmem unmap_physmem
25 #include <asm-generic/io.h>
27 /* For sandbox, we want addresses to point into our RAM buffer */
28 static inline void *map_sysmem(phys_addr_t paddr, unsigned long len)
30 return map_physmem(paddr, len, MAP_WRBACK);
33 /* Remove a previous mapping */
34 static inline void unmap_sysmem(const void *vaddr)
36 unmap_physmem(vaddr, MAP_WRBACK);
39 /* Map from a pointer to our RAM buffer */
40 phys_addr_t map_to_sysmem(const void *ptr);
42 /* Define nops for sandbox I/O access */
43 #define readb(addr) ((void)addr, 0)
44 #define readw(addr) ((void)addr, 0)
45 #define readl(addr) ((void)addr, 0)
46 #define writeb(v, addr) ((void)addr)
47 #define writew(v, addr) ((void)addr)
48 #define writel(v, addr) ((void)addr)
50 /* I/O access functions */
51 int inl(unsigned int addr);
52 int inw(unsigned int addr);
53 int inb(unsigned int addr);
55 void outl(unsigned int value, unsigned int addr);
56 void outw(unsigned int value, unsigned int addr);
57 void outb(unsigned int value, unsigned int addr);
59 static inline void _insw(volatile u16 *port, void *buf, int ns)
63 static inline void _outsw(volatile u16 *port, const void *buf, int ns)
67 #define insw(port, buf, ns) _insw((u16 *)port, buf, ns)
68 #define outsw(port, buf, ns) _outsw((u16 *)port, buf, ns)
71 #define out16(addr, val)
75 #include <asm/types.h>