source: soft/giet_vm/giet_libs/libsrl/srl_endianness.h @ 587

Last change on this file since 587 was 258, checked in by alain, 11 years ago

This is a major release, including a deep restructuration of code.
The main evolutions are

  • use of the Tsar preloader to load the GIET boot-loader from disk
  • introduction of a FAT32 file system library,
  • use of this fat32 library by the boot-loader to load the map.bin data structure, and the various .elf files
  • reorganisation of drivers (one file per peripheral).
  • introduction of drivers for new peripherals: vci_chbuf_dma and vci_multi_ahci.
  • introduction of a new physical memory allocator in the boot code.

This release has been tested on the tsar_generic_iob architecture,
for the two following mappings: 4c_1p_iob_four.xml and 4c_1p_iob_sort.xml

  • Property svn:executable set to *
File size: 2.1 KB
Line 
1#ifndef SRL_ENDIANNESS_H_
2#define SRL_ENDIANNESS_H_
3
4#include "srl_public_types.h"
5
6/** @this reads a big endian 16 bits value */
7#  define endian_le16(x)    (x)
8/** @this reads a big endian 32 bits value */
9#  define endian_le32(x)    (x)
10/** @this reads a big endian 64 bits value */
11//#  define endian_le64(x)    (x)
12/** @this reads a little endian 16 bits value */
13#  define endian_be16(x)    endian_swap16(x)
14/** @this reads a little endian 32 bits value */
15#  define endian_be32(x)    endian_swap32(x)
16/** @this reads a little endian 64 bits value */
17//#  define endian_be64(x)    endian_swap64(x)
18
19/** @internal */
20static inline uint16_t endian_swap16(uint16_t x) {
21    return (x >> 8) | (x << 8);
22}
23
24
25/** @internal */
26static inline uint32_t endian_swap32(uint32_t x) {
27    return (((x >> 24) & 0x000000ff) |
28            ((x >> 8 ) & 0x0000ff00) |
29            ((x << 8 ) & 0x00ff0000) |
30            ((x << 24) & 0xff000000));
31}
32
33
34/** @internal *//*
35                   static inline uint64_t __endian_swap64(uint64_t x)
36                   {
37                   return (((uint64_t)endian_swap32(x      ) << 32) |
38                   ((uint64_t)endian_swap32(x >> 32)      ));
39                   }*/
40
41static inline uint32_t srl_uint32_le_to_machine(uint32_t x) {
42    return endian_le32(x);
43}
44
45
46static inline uint32_t srl_uint32_machine_to_le(uint32_t x) {
47    return endian_le32(x);
48}
49
50
51static inline uint32_t srl_uint32_be_to_machine(uint32_t x) {
52    return endian_be32(x);
53}
54
55
56static inline uint32_t srl_uint32_machine_to_be(uint32_t x) {
57    return endian_be32(x);
58}
59
60
61static inline uint16_t srl_uint16_le_to_machine(uint16_t x) {
62    return endian_le16(x);
63}
64
65
66static inline uint16_t srl_uint16_machine_to_le(uint16_t x) {
67    return endian_le16(x);
68}
69
70
71static inline uint16_t srl_uint16_be_to_machine(uint16_t x) {
72    return endian_be16(x);
73}
74
75
76static inline uint16_t srl_uint16_machine_to_be(uint16_t x) {
77    return endian_be16(x);
78}
79
80
81#endif
82
83
84// Local Variables:
85// tab-width: 4
86// c-basic-offset: 4
87// c-file-offsets:((innamespace . 0)(inline-open . 0))
88// indent-tabs-mode: nil
89// End:
90// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
91
Note: See TracBrowser for help on using the repository browser.