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

Last change on this file since 817 was 495, checked in by alain, 9 years ago

Introduce quad tree for distributed locks and barriers.

File size: 2.6 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// The main service provided by those functions is to force an actual
9// read (volatile attribute) or write (sync operation) to memory.
10///////////////////////////////////////////////////////////////////////////////////
11
12#ifndef IO_H
13#define IO_H
14
15///////////////////////////////////////////////////////////////////////////////////
16// Read an 32 bits memory mapped hardware register
17///////////////////////////////////////////////////////////////////////////////////
18static inline unsigned int ioread32(void * addr)
19{
20        return *(volatile unsigned int *) addr;
21}
22
23///////////////////////////////////////////////////////////////////////////////////
24// Read an 16 bits memory mapped hardware register
25///////////////////////////////////////////////////////////////////////////////////
26static inline unsigned short ioread16(void * addr)
27{
28        return *(volatile unsigned short *) addr;
29}
30
31///////////////////////////////////////////////////////////////////////////////////
32// Read an 8 bits memory mapped hardware register
33///////////////////////////////////////////////////////////////////////////////////
34static inline unsigned char ioread8(void * addr)
35{
36        return *(volatile unsigned char *) addr;
37}
38
39///////////////////////////////////////////////////////////////////////////////////
40// Write an 32 bits memory mapped hardware register
41///////////////////////////////////////////////////////////////////////////////////
42static inline void iowrite32(void * addr, unsigned int value)
43{
44        *(volatile unsigned int *) addr = value;
45        asm volatile("sync" ::: "memory");
46}
47
48///////////////////////////////////////////////////////////////////////////////////
49// Write an 16 bits memory mapped hardware register
50///////////////////////////////////////////////////////////////////////////////////
51static inline void iowrite16(void * addr, unsigned short value)
52{
53        *(volatile unsigned short *) addr = value;
54        asm volatile("sync" ::: "memory");
55}
56
57///////////////////////////////////////////////////////////////////////////////////
58// Write an 8 bits memory mapped hardware register
59///////////////////////////////////////////////////////////////////////////////////
60static inline void iowrite8(void * addr, unsigned char value)
61{
62        *(volatile unsigned char *) addr = value;
63        asm volatile("sync" ::: "memory");
64}
65
66#undef in_reset
67
68#endif
Note: See TracBrowser for help on using the repository browser.