RTEMS  5.1
rtems-rfs-data.h
Go to the documentation of this file.
1 
16 /*
17  * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
18  *
19  * The license and distribution terms for this file may be
20  * found in the file LICENSE in this distribution or at
21  * http://www.rtems.org/license/LICENSE.
22  */
23 
24 
25 #if !defined (_RTEMS_RFS_DATA_H_)
26 #define _RTEMS_RFS_DATA_H_
27 
28 #include <stdint.h>
29 
33 #define rtems_rfs_data_ptr(_d) ((uint8_t*)(_d))
34 
38 #define rtems_rfs_data_get(_d, _t, _o, _s) \
39  (((_t)(rtems_rfs_data_ptr (_d)[_o])) << (_s))
40 
44 #define rtems_rfs_read_u8(_d) \
45  (*rtems_rfs_data_ptr (_d))
46 
50 #define rtems_rfs_read_u16(_d) \
51  (rtems_rfs_data_get (_d, uint16_t, 0, 8) | \
52  rtems_rfs_data_get (_d, uint16_t, 1, 0))
53 
57 #define rtems_rfs_read_u32(_d) \
58  (rtems_rfs_data_get (_d, uint32_t, 0, 24) | \
59  rtems_rfs_data_get (_d, uint32_t, 1, 16) | \
60  rtems_rfs_data_get (_d, uint32_t, 2, 8) | \
61  rtems_rfs_data_get (_d, uint32_t, 3, 0))
62 
66 #define rtems_rfs_write_u8(_d, _v) \
67  (*rtems_rfs_data_ptr (_d) = (uint8_t)(_v))
68 
72 #define rtems_rfs_write_u16(_d, _v) \
73  do { \
74  rtems_rfs_data_ptr (_d)[0] = (uint8_t)(((uint16_t)(_v)) >> 8); \
75  rtems_rfs_data_ptr (_d)[1] = (uint8_t)((_v)); \
76  } while (0)
77 
81 #define rtems_rfs_write_u32(_d, _v) \
82  do { \
83  rtems_rfs_data_ptr (_d)[0] = (uint8_t)(((uint32_t)(_v)) >> 24); \
84  rtems_rfs_data_ptr (_d)[1] = (uint8_t)(((uint32_t)(_v)) >> 16); \
85  rtems_rfs_data_ptr (_d)[2] = (uint8_t)(((uint32_t)(_v)) >> 8); \
86  rtems_rfs_data_ptr (_d)[3] = (uint8_t)((uint32_t)(_v)); \
87  } while (0)
88 
89 #endif