blob: 5b87fde1161d38a87a6ebca5bd38a67cfe864e07 [file] [log] [blame]
Simon Glassb4a905e2011-10-10 08:22:14 +00001/*
2 * Copyright (c) 2011 The Chromium OS Authors.
3 *
Wolfgang Denkbd8ec7e2013-10-07 13:07:26 +02004 * SPDX-License-Identifier: GPL-2.0+
Simon Glassb4a905e2011-10-10 08:22:14 +00005 */
6
Simon Glass62cf9122013-04-26 02:53:43 +00007#ifndef __SANDBOX_ASM_IO_H
8#define __SANDBOX_ASM_IO_H
9
Simon Glassb4a905e2011-10-10 08:22:14 +000010/*
11 * Given a physical address and a length, return a virtual address
12 * that can be used to access the memory range with the caching
13 * properties specified by "flags".
14 */
15#define MAP_NOCACHE (0)
16#define MAP_WRCOMBINE (0)
17#define MAP_WRBACK (0)
18#define MAP_WRTHROUGH (0)
19
20void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags);
21
22/*
23 * Take down a mapping set up by map_physmem().
24 */
Simon Glass70778bc2015-03-05 12:25:26 -070025void unmap_physmem(const void *vaddr, unsigned long flags);
Simon Glass17dabf02013-02-24 17:33:14 +000026
27/* For sandbox, we want addresses to point into our RAM buffer */
28static inline void *map_sysmem(phys_addr_t paddr, unsigned long len)
29{
30 return map_physmem(paddr, len, MAP_WRBACK);
31}
32
Simon Glass70778bc2015-03-05 12:25:26 -070033/* Remove a previous mapping */
Simon Glass17dabf02013-02-24 17:33:14 +000034static inline void unmap_sysmem(const void *vaddr)
35{
Simon Glass70778bc2015-03-05 12:25:26 -070036 unmap_physmem(vaddr, MAP_WRBACK);
Simon Glass17dabf02013-02-24 17:33:14 +000037}
Simon Glasse23d2932013-04-20 08:42:37 +000038
39/* Map from a pointer to our RAM buffer */
Simon Glass656bfc42013-11-07 09:31:58 -070040phys_addr_t map_to_sysmem(const void *ptr);
Simon Glass62cf9122013-04-26 02:53:43 +000041
Simon Glass125a27b2014-06-11 23:29:43 -060042/* Define nops for sandbox I/O access */
43#define readb(addr) 0
44#define readw(addr) 0
45#define readl(addr) 0
46#define writeb(v, addr)
47#define writew(v, addr)
48#define writel(v, addr)
49
Simon Glass70778bc2015-03-05 12:25:26 -070050/* I/O access functions */
51int inl(unsigned int addr);
52int inw(unsigned int addr);
53int inb(unsigned int addr);
54
55void outl(unsigned int value, unsigned int addr);
56void outw(unsigned int value, unsigned int addr);
57void outb(unsigned int value, unsigned int addr);
58
Simon Glass125a27b2014-06-11 23:29:43 -060059#include <iotrace.h>
60
Simon Glass62cf9122013-04-26 02:53:43 +000061#endif