source: trunk/softs/tsar_boot/include/io.h @ 653

Last change on this file since 653 was 653, checked in by cfuguet, 11 years ago

Introducing a RAMDISK driver in the preloader.

When using RAMDISK, execute the make command with the flags
SOCLIB=1 and RAMDISK=1. The RDK_PADDR_BASE variable must
also be set on the conf/<platform>/defs_platform.h

These modifications are backward compatibles. Therefore,
when no using RAMDISK, none modifications applied on the
platform configuration file.

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