Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6936 serge 1
#ifndef __GENERIC_IO_H
2
#define __GENERIC_IO_H
3
 
4
#include 
5
#include 
6
 
7
/*
8
 * These are the "generic" interfaces for doing new-style
9
 * memory-mapped or PIO accesses. Architectures may do
10
 * their own arch-optimized versions, these just act as
11
 * wrappers around the old-style IO register access functions:
12
 * read[bwl]/write[bwl]/in[bwl]/out[bwl]
13
 *
14
 * Don't include this directly, include it from .
15
 */
16
 
17
/*
18
 * Read/write from/to an (offsettable) iomem cookie. It might be a PIO
19
 * access or a MMIO access, these functions don't care. The info is
20
 * encoded in the hardware mapping set up by the mapping functions
21
 * (or the cookie itself, depending on implementation and hw).
22
 *
23
 * The generic routines just encode the PIO/MMIO as part of the
24
 * cookie, and coldly assume that the MMIO IO mappings are not
25
 * in the low address range. Architectures for which this is not
26
 * true can't use this generic implementation.
27
 */
28
extern unsigned int ioread8(void __iomem *);
29
extern unsigned int ioread16(void __iomem *);
30
extern unsigned int ioread16be(void __iomem *);
31
//extern unsigned int ioread32(void __iomem *);
32
 
33
#ifndef ioread32
34
#define ioread32 ioread32
35
static inline u32 ioread32(const volatile void __iomem *addr)
36
{
37
    return readl(addr);
38
}
39
#endif
40
 
41
extern unsigned int ioread32be(void __iomem *);
42
 
43
extern void iowrite8(u8, void __iomem *);
44
extern void iowrite16(u16, void __iomem *);
45
extern void iowrite16be(u16, void __iomem *);
46
//extern void iowrite32(u32, void __iomem *);
47
#ifndef iowrite32
48
//#define iowrite32 iowrite32
49
static inline void iowrite32(u32 value, volatile void __iomem *addr)
50
{
51
    writel(value, addr);
52
}
53
#endif
54
 
55
extern void iowrite32be(u32, void __iomem *);
56
 
57
/*
58
 * "string" versions of the above. Note that they
59
 * use native byte ordering for the accesses (on
60
 * the assumption that IO and memory agree on a
61
 * byte order, and CPU byteorder is irrelevant).
62
 *
63
 * They do _not_ update the port address. If you
64
 * want MMIO that copies stuff laid out in MMIO
65
 * memory across multiple ports, use "memcpy_toio()"
66
 * and friends.
67
 */
68
extern void ioread8_rep(void __iomem *port, void *buf, unsigned long count);
69
extern void ioread16_rep(void __iomem *port, void *buf, unsigned long count);
70
extern void ioread32_rep(void __iomem *port, void *buf, unsigned long count);
71
 
72
extern void iowrite8_rep(void __iomem *port, const void *buf, unsigned long count);
73
extern void iowrite16_rep(void __iomem *port, const void *buf, unsigned long count);
74
extern void iowrite32_rep(void __iomem *port, const void *buf, unsigned long count);
75
 
76
#ifdef CONFIG_HAS_IOPORT_MAP
77
/* Create a virtual mapping cookie for an IO port range */
78
extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
79
extern void ioport_unmap(void __iomem *);
80
#endif
81
 
82
#ifndef ARCH_HAS_IOREMAP_WC
83
#define ioremap_wc ioremap_nocache
84
#endif
85
 
86
#ifndef ARCH_HAS_IOREMAP_WT
87
#define ioremap_wt ioremap_nocache
88
#endif
89
 
90
#ifdef CONFIG_PCI
91
/* Destroy a virtual mapping cookie for a PCI BAR (memory or IO) */
92
struct pci_dev;
93
extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
94
#elif defined(CONFIG_GENERIC_IOMAP)
95
struct pci_dev;
96
static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
97
{ }
98
#endif
99
 
100
#include 
101
 
102
#endif