source: soft/giet_vm/giet_common/io.h @ 408

Last change on this file since 408 was 408, checked in by alain, 10 years ago

Introducing a physical memory allocator (pmem.c & pmem.h files).

File size: 2.5 KB
Line 
1///////////////////////////////////////////////////////////////////////////////////
2// File     : io.h
3// Date     : 05/09/2012
4// Author   : cesar fuguet
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7// Utility functions to write or read memory mapped hardware registers
8///////////////////////////////////////////////////////////////////////////////////
9
10#ifndef IO_H
11#define IO_H
12
13///////////////////////////////////////////////////////////////////////////////////
14// Read an 32 bits memory mapped hardware register
15///////////////////////////////////////////////////////////////////////////////////
16static inline unsigned int ioread32(void * addr)
17{
18        return *(volatile unsigned int *) addr;
19}
20
21///////////////////////////////////////////////////////////////////////////////////
22// Read an 16 bits memory mapped hardware register
23///////////////////////////////////////////////////////////////////////////////////
24static inline unsigned short ioread16(void * addr)
25{
26        return *(volatile unsigned short *) addr;
27}
28
29///////////////////////////////////////////////////////////////////////////////////
30// Read an 8 bits memory mapped hardware register
31///////////////////////////////////////////////////////////////////////////////////
32static inline unsigned char ioread8(void * addr)
33{
34        return *(volatile unsigned char *) addr;
35}
36
37///////////////////////////////////////////////////////////////////////////////////
38// Write an 32 bits memory mapped hardware register
39///////////////////////////////////////////////////////////////////////////////////
40static inline void iowrite32(void * addr, unsigned int value)
41{
42        *(volatile unsigned int *) addr = value;
43        asm volatile("sync" ::: "memory");
44}
45
46///////////////////////////////////////////////////////////////////////////////////
47// Write an 16 bits memory mapped hardware register
48///////////////////////////////////////////////////////////////////////////////////
49static inline void iowrite16(void * addr, unsigned short value)
50{
51        *(volatile unsigned short *) addr = value;
52        asm volatile("sync" ::: "memory");
53}
54
55///////////////////////////////////////////////////////////////////////////////////
56// Write an 8 bits memory mapped hardware register
57///////////////////////////////////////////////////////////////////////////////////
58static inline void iowrite8(void * addr, unsigned char value)
59{
60        *(volatile unsigned char *) addr = value;
61        asm volatile("sync" ::: "memory");
62}
63
64#undef in_reset
65
66#endif
Note: See TracBrowser for help on using the repository browser.