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