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

Last change on this file since 347 was 345, checked in by cfuguet, 10 years ago

giet_vm optimizations:

  • Several modifications in GIET_VM in order to support compilation with GCC optimizations (-O2) activated.
  • Adding missing volatile in some global variables.
  • Using ioread and iowrite utility functions in peripheral drivers which prevent GCC to remove writes or reads in hardware memory mapped registers.
  • Code refactoring of stdio printf functions. Now, shr_printf and tty_printf function reuse the same function body. The only difference is that shr_printf wraps printf function call with TTY get lock and release lock.
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///////////////////////////////////////////////////////////////////////////////////
[283]9#ifndef IO_H
10#define IO_H
11
[289]12///////////////////////////////////////////////////////////////////////////////////
13// Read an 32 bits memory mapped hardware register
14///////////////////////////////////////////////////////////////////////////////////
[283]15static inline unsigned int ioread32(void * addr)
16{
17        return *(volatile unsigned int *) addr;
18}
19
[289]20///////////////////////////////////////////////////////////////////////////////////
21// Read an 16 bits memory mapped hardware register
22///////////////////////////////////////////////////////////////////////////////////
[283]23static inline unsigned short ioread16(void * addr)
24{
25        return *(volatile unsigned short *) addr;
26}
27
[289]28///////////////////////////////////////////////////////////////////////////////////
29// Read an 8 bits memory mapped hardware register
30///////////////////////////////////////////////////////////////////////////////////
[283]31static inline unsigned char ioread8(void * addr)
32{
33        return *(volatile unsigned char *) addr;
34}
35
[289]36///////////////////////////////////////////////////////////////////////////////////
37// Write an 32 bits memory mapped hardware register
38///////////////////////////////////////////////////////////////////////////////////
[283]39static inline void iowrite32(void * addr, unsigned int value)
40{
41        *(volatile unsigned int *) addr = value;
[345]42        asm volatile("sync" ::: "memory");
[283]43}
44
[289]45///////////////////////////////////////////////////////////////////////////////////
46// Write an 16 bits memory mapped hardware register
47///////////////////////////////////////////////////////////////////////////////////
[283]48static inline void iowrite16(void * addr, unsigned short value)
49{
50        *(volatile unsigned short *) addr = value;
[345]51        asm volatile("sync" ::: "memory");
[283]52}
53
[289]54///////////////////////////////////////////////////////////////////////////////////
55// Write an 8 bits memory mapped hardware register
56///////////////////////////////////////////////////////////////////////////////////
[283]57static inline void iowrite8(void * addr, unsigned char value)
58{
59        *(volatile unsigned char *) addr = value;
[345]60        asm volatile("sync" ::: "memory");
[283]61}
62
63#undef in_reset
64
65#endif
Note: See TracBrowser for help on using the repository browser.