coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
endian.h File Reference
#include <arch/byteorder.h>
#include <stdint.h>
#include <swab.h>
Include dependency graph for endian.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ntohll(x)   be64_to_cpu(x)
 
#define htonll(x)   cpu_to_be64(x)
 
#define ntohl(x)   be32_to_cpu(x)
 
#define htonl(x)   cpu_to_be32(x)
 
#define __clrsetbits(endian, bits, addr, clear, set)
 
#define clrbits_le64(addr, clear)   __clrsetbits(le, 64, addr, clear, 0)
 
#define clrbits_be64(addr, clear)   __clrsetbits(be, 64, addr, clear, 0)
 
#define clrbits_le32(addr, clear)   __clrsetbits(le, 32, addr, clear, 0)
 
#define clrbits_be32(addr, clear)   __clrsetbits(be, 32, addr, clear, 0)
 
#define clrbits_le16(addr, clear)   __clrsetbits(le, 16, addr, clear, 0)
 
#define clrbits_be16(addr, clear)   __clrsetbits(be, 16, addr, clear, 0)
 
#define setbits_le64(addr, set)   __clrsetbits(le, 64, addr, 0, set)
 
#define setbits_be64(addr, set)   __clrsetbits(be, 64, addr, 0, set)
 
#define setbits_le32(addr, set)   __clrsetbits(le, 32, addr, 0, set)
 
#define setbits_be32(addr, set)   __clrsetbits(be, 32, addr, 0, set)
 
#define setbits_le16(addr, set)   __clrsetbits(le, 16, addr, 0, set)
 
#define setbits_be16(addr, set)   __clrsetbits(be, 16, addr, 0, set)
 
#define clrsetbits_le64(addr, clear, set)   __clrsetbits(le, 64, addr, clear, set)
 
#define clrsetbits_be64(addr, clear, set)   __clrsetbits(be, 64, addr, clear, set)
 
#define clrsetbits_le32(addr, clear, set)   __clrsetbits(le, 32, addr, clear, set)
 
#define clrsetbits_be32(addr, clear, set)   __clrsetbits(be, 32, addr, clear, set)
 
#define clrsetbits_le16(addr, clear, set)   __clrsetbits(le, 16, addr, clear, set)
 
#define clrsetbits_be16(addr, clear, set)   __clrsetbits(be, 16, addr, clear, set)
 
#define DEFINE_ENDIAN_DEC(endian, width)
 
#define DEFINE_ENDIAN_ENC(endian, width)
 

Functions

static uint16_t htobe16 (uint16_t host_16bits)
 
static uint16_t htole16 (uint16_t host_16bits)
 
static uint16_t be16toh (uint16_t big_endian_16bits)
 
static uint16_t le16toh (uint16_t little_endian_16bits)
 
static uint32_t htobe32 (uint32_t host_32bits)
 
static uint32_t htole32 (uint32_t host_32bits)
 
static uint32_t be32toh (uint32_t big_endian_32bits)
 
static uint32_t le32toh (uint32_t little_endian_32bits)
 
static uint64_t htobe64 (uint64_t host_64bits)
 
static uint64_t htole64 (uint64_t host_64bits)
 
static uint64_t be64toh (uint64_t big_endian_64bits)
 
static uint64_t le64toh (uint64_t little_endian_64bits)
 

Macro Definition Documentation

◆ __clrsetbits

#define __clrsetbits (   endian,
  bits,
  addr,
  clear,
  set 
)
Value:
write##bits(addr, cpu_to_##endian##bits((endian##bits##_to_cpu( \
read##bits(addr)) & ~((uint##bits##_t)(clear))) | (set)))
static u32 addr
Definition: cirrus.c:14
unsigned int uint
Definition: types.h:44

Definition at line 45 of file endian.h.

◆ clrbits_be16

#define clrbits_be16 (   addr,
  clear 
)    __clrsetbits(be, 16, addr, clear, 0)

Definition at line 54 of file endian.h.

◆ clrbits_be32

#define clrbits_be32 (   addr,
  clear 
)    __clrsetbits(be, 32, addr, clear, 0)

Definition at line 52 of file endian.h.

◆ clrbits_be64

#define clrbits_be64 (   addr,
  clear 
)    __clrsetbits(be, 64, addr, clear, 0)

Definition at line 50 of file endian.h.

◆ clrbits_le16

#define clrbits_le16 (   addr,
  clear 
)    __clrsetbits(le, 16, addr, clear, 0)

Definition at line 53 of file endian.h.

◆ clrbits_le32

#define clrbits_le32 (   addr,
  clear 
)    __clrsetbits(le, 32, addr, clear, 0)

Definition at line 51 of file endian.h.

◆ clrbits_le64

#define clrbits_le64 (   addr,
  clear 
)    __clrsetbits(le, 64, addr, clear, 0)

Definition at line 49 of file endian.h.

◆ clrsetbits_be16

#define clrsetbits_be16 (   addr,
  clear,
  set 
)    __clrsetbits(be, 16, addr, clear, set)

Definition at line 68 of file endian.h.

◆ clrsetbits_be32

#define clrsetbits_be32 (   addr,
  clear,
  set 
)    __clrsetbits(be, 32, addr, clear, set)

Definition at line 66 of file endian.h.

◆ clrsetbits_be64

#define clrsetbits_be64 (   addr,
  clear,
  set 
)    __clrsetbits(be, 64, addr, clear, set)

Definition at line 64 of file endian.h.

◆ clrsetbits_le16

#define clrsetbits_le16 (   addr,
  clear,
  set 
)    __clrsetbits(le, 16, addr, clear, set)

Definition at line 67 of file endian.h.

◆ clrsetbits_le32

#define clrsetbits_le32 (   addr,
  clear,
  set 
)    __clrsetbits(le, 32, addr, clear, set)

Definition at line 65 of file endian.h.

◆ clrsetbits_le64

#define clrsetbits_le64 (   addr,
  clear,
  set 
)    __clrsetbits(le, 64, addr, clear, set)

Definition at line 63 of file endian.h.

◆ DEFINE_ENDIAN_DEC

#define DEFINE_ENDIAN_DEC (   endian,
  width 
)
Value:
static inline uint##width##_t endian##width##dec(const void *p) \
{ \
return endian##width##_to_cpu(*(uint##width##_t *)p); \
}
static int width
Definition: bochs.c:42

Definition at line 71 of file endian.h.

◆ DEFINE_ENDIAN_ENC

#define DEFINE_ENDIAN_ENC (   endian,
  width 
)
Value:
static inline void endian##width##enc(void *p, uint##width##_t u) \
{ \
*(uint##width##_t *)p = cpu_to_##endian##width(u); \
}

Definition at line 84 of file endian.h.

◆ htonl

#define htonl (   x)    cpu_to_be32(x)

Definition at line 43 of file endian.h.

◆ htonll

#define htonll (   x)    cpu_to_be64(x)

Definition at line 41 of file endian.h.

◆ ntohl

#define ntohl (   x)    be32_to_cpu(x)

Definition at line 42 of file endian.h.

◆ ntohll

#define ntohll (   x)    be64_to_cpu(x)

Definition at line 40 of file endian.h.

◆ setbits_be16

#define setbits_be16 (   addr,
  set 
)    __clrsetbits(be, 16, addr, 0, set)

Definition at line 61 of file endian.h.

◆ setbits_be32

#define setbits_be32 (   addr,
  set 
)    __clrsetbits(be, 32, addr, 0, set)

Definition at line 59 of file endian.h.

◆ setbits_be64

#define setbits_be64 (   addr,
  set 
)    __clrsetbits(be, 64, addr, 0, set)

Definition at line 57 of file endian.h.

◆ setbits_le16

#define setbits_le16 (   addr,
  set 
)    __clrsetbits(le, 16, addr, 0, set)

Definition at line 60 of file endian.h.

◆ setbits_le32

#define setbits_le32 (   addr,
  set 
)    __clrsetbits(le, 32, addr, 0, set)

Definition at line 58 of file endian.h.

◆ setbits_le64

#define setbits_le64 (   addr,
  set 
)    __clrsetbits(le, 64, addr, 0, set)

Definition at line 56 of file endian.h.

Function Documentation

◆ be16toh()

static uint16_t be16toh ( uint16_t  big_endian_16bits)
inlinestatic

Definition at line 110 of file endian.h.

◆ be32toh()

static uint32_t be32toh ( uint32_t  big_endian_32bits)
inlinestatic

◆ be64toh()

static uint64_t be64toh ( uint64_t  big_endian_64bits)
inlinestatic

Definition at line 150 of file endian.h.

Referenced by fdt_unflatten_map_entry().

Here is the caller graph for this function:

◆ htobe16()

static uint16_t htobe16 ( uint16_t  host_16bits)
inlinestatic

Definition at line 100 of file endian.h.

◆ htobe32()

static uint32_t htobe32 ( uint32_t  host_32bits)
inlinestatic

Definition at line 120 of file endian.h.

Referenced by dt_add_u32_prop(), and dt_flatten().

Here is the caller graph for this function:

◆ htobe64()

static uint64_t htobe64 ( uint64_t  host_64bits)
inlinestatic

Definition at line 140 of file endian.h.

Referenced by dt_add_u64_prop(), and dt_flatten_map_entry().

Here is the caller graph for this function:

◆ htole16()

static uint16_t htole16 ( uint16_t  host_16bits)
inlinestatic

Definition at line 105 of file endian.h.

◆ htole32()

static uint32_t htole32 ( uint32_t  host_32bits)
inlinestatic

Definition at line 125 of file endian.h.

◆ htole64()

static uint64_t htole64 ( uint64_t  host_64bits)
inlinestatic

Definition at line 145 of file endian.h.

◆ le16toh()

static uint16_t le16toh ( uint16_t  little_endian_16bits)
inlinestatic

Definition at line 115 of file endian.h.

Referenced by LZ4_readLE16(), and report().

Here is the caller graph for this function:

◆ le32toh()

static uint32_t le32toh ( uint32_t  little_endian_32bits)
inlinestatic

Definition at line 135 of file endian.h.

Referenced by fmap_find_region_name(), fmap_locate_area(), report(), and ulz4fn().

Here is the caller graph for this function:

◆ le64toh()

static uint64_t le64toh ( uint64_t  little_endian_64bits)
inlinestatic

Definition at line 155 of file endian.h.

Referenced by report().

Here is the caller graph for this function: