source: rtems/cpukit/libfs/src/rfs/rtems-rfs-data.h @ 1d539c0

4.104.11
Last change on this file since 1d539c0 was 1d539c0, checked in by Chris Johns <chrisj@…>, on Apr 12, 2010 at 5:29:25 AM

2010-04-12 Chris Johns <chrisj@…>

libfs/src/rfs/rtems-rfs-buffer-bdbuf.c,
libfs/src/rfs/rtems-rfs-buffer.c, libfs/src/rfs/rtems-rfs-data.h,
libfs/src/rfs/rtems-rfs-dir.c,
libfs/src/rfs/rtems-rfs-file-system.c,
libfs/src/rfs/rtems-rfs-format.c, libfs/src/rfs/rtems-rfs-inode.h,
libfs/src/rfs/rtems-rfs-rtems.c, libfs/src/rfs/rtems-rfs-rtems.h,
libfs/src/rfs/rtems-rfs-shell.c: Fix for PR1502. Clean up problems
on 16bit targets.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2 *  COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
3 *
4 *  The license and distribution terms for this file may be
5 *  found in the file LICENSE in this distribution or at
6 *  http://www.rtems.com/license/LICENSE.
7 *
8 *  $Id$
9 */
10/**
11 * @file
12 *
13 * @ingroup rtems-rfs
14 *
15 * RTEMS File System Data.
16 *
17 * Access data in the correct byte order for the specific target we are running
18 * on.
19 *
20 * @todo Make direct access on matching byte ordered targets.
21 */
22
23#if !defined (_RTEMS_RFS_DATA_H_)
24#define _RTEMS_RFS_DATA_H_
25
26#include <stdint.h>
27
28/**
29 * Helper function to make sure we have a byte pointer.
30 */
31#define rtems_rfs_data_ptr(_d) ((uint8_t*)(_d))
32
33/**
34 * Helper function to get the data shifted in the correctly sized type.
35 */
36#define rtems_rfs_data_get(_d, _t, _o, _s) \
37  (((_t)(rtems_rfs_data_ptr (_d)[_o])) << (_s))
38
39/**
40 * RFS Read Unsigned 8bit Integer
41 */
42#define rtems_rfs_read_u8(_d) \
43  (*rtems_rfs_data_ptr (_d))
44
45/**
46 * RFS Read Unsigned 16bit Integer
47 */
48#define rtems_rfs_read_u16(_d) \
49  (rtems_rfs_data_get (_d, uint16_t, 0, 8) | \
50   rtems_rfs_data_get (_d, uint16_t, 1, 0))
51
52/**
53 * RFS Read Unsigned 32bit Integer
54 */
55#define rtems_rfs_read_u32(_d) \
56  (rtems_rfs_data_get (_d, uint32_t, 0, 24) | \
57   rtems_rfs_data_get (_d, uint32_t, 1, 16) | \
58   rtems_rfs_data_get (_d, uint32_t, 2, 8) | \
59   rtems_rfs_data_get (_d, uint32_t, 3, 0))
60
61/**
62 * RFS Write Unsigned 8bit Integer
63 */
64#define rtems_rfs_write_u8(_d, _v) \
65  (*rtems_rfs_data_ptr (_d) = (uint8_t)(_v))
66
67/**
68 * RFS Write Unsigned 16bit Integer
69 */
70#define rtems_rfs_write_u16(_d, _v) \
71  do { \
72    rtems_rfs_data_ptr (_d)[0] = (uint8_t)(((uint16_t)(_v)) >> 8); \
73    rtems_rfs_data_ptr (_d)[1] = (uint8_t)((_v)); \
74  } while (0)
75
76/**
77 * RFS Write Unsigned 32bit Integer
78 */
79#define rtems_rfs_write_u32(_d, _v) \
80  do { \
81    rtems_rfs_data_ptr (_d)[0] = (uint8_t)(((uint32_t)(_v)) >> 24); \
82    rtems_rfs_data_ptr (_d)[1] = (uint8_t)(((uint32_t)(_v)) >> 16); \
83    rtems_rfs_data_ptr (_d)[2] = (uint8_t)(((uint32_t)(_v)) >> 8);  \
84    rtems_rfs_data_ptr (_d)[3] = (uint8_t)((uint32_t)(_v)); \
85  } while (0)
86
87#endif
Note: See TracBrowser for help on using the repository browser.