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