make vfs & filesystems use failable copying
[minix3.git] / include / minix / mmio.h
blob60a41c95297be283fdeeee6d2c2e9f9349d797e9
1 #ifndef __MMIO_H__
2 #define __MMIO_H__
4 #define REG16(x)(*((volatile uint16_t *)(x)))
5 #define REG(x)(*((volatile uint32_t *)(x)))
6 #define BIT(x)(0x1 << x)
8 /* Write a uint32_t value to a memory address. */
9 static inline void
10 write32(uint32_t address, uint32_t value)
12 REG(address) = value;
15 /* Read an uint32_t from a memory address */
16 static inline uint32_t
17 read32(uint32_t address)
19 return REG(address);
22 /* Set a 32 bits value depending on a mask */
23 static inline void
24 set32(uint32_t address, uint32_t mask, uint32_t value)
26 uint32_t val;
27 val = read32(address);
28 /* clear the bits */
29 val &= ~(mask);
30 /* apply the value using the mask */
31 val |= (value & mask);
32 write32(address, val);
35 /* Write a uint16_t value to a memory address. */
36 static inline void
37 write16(uint32_t address, uint16_t value)
39 REG16(address) = value;
42 /* Read an uint16_t from a memory address */
43 static inline uint16_t
44 read16(uint32_t address)
46 return REG16(address);
49 /* Set a 16 bits value depending on a mask */
50 static inline void
51 set16(uint32_t address, uint16_t mask, uint16_t value)
53 uint16_t val;
54 val = read16(address);
55 /* clear the bits */
56 val &= ~(mask);
57 /* apply the value using the mask */
58 val |= (value & mask);
59 write16(address, val);
62 #endif /* __MMIO_H__ */