Debian Codegraph @

include/platform.h

raw
1 /*
2 * This file is part of the flashrom project.
3 *
4 * Copyright (C) 2009 Carl-Daniel Hailfinger
5 * Copyright (C) 2022 secunet Security Networks AG
6 * (written by Thomas Heijligen <[email protected])
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17
18 /*
19 * Header file for platform abstraction.
20 */
21
22 #ifndef __PLATFORM_H__
23 #define __PLATFORM_H__ 1
24
25 #include <stddef.h>
26 #include <stdint.h>
27
28 /* convert cpu native endian to little endian */
29 uint8_t cpu_to_le8 (uint8_t value);
30 uint16_t cpu_to_le16(uint16_t value);
31 uint32_t cpu_to_le32(uint32_t value);
32 uint64_t cpu_to_le64(uint64_t value);
33
34 /* convert cpu native endian to big endian */
35 uint8_t cpu_to_be8 (uint8_t value);
36 uint16_t cpu_to_be16(uint16_t value);
37 uint32_t cpu_to_be32(uint32_t value);
38 uint64_t cpu_to_be64(uint64_t value);
39
40 /* convert little endian to cpu native endian */
41 uint8_t le_to_cpu8 (uint8_t value);
42 uint16_t le_to_cpu16(uint16_t value);
43 uint32_t le_to_cpu32(uint32_t value);
44 uint64_t le_to_cpu64(uint64_t value);
45
46 /* convert big endian to cpu native endian */
47 uint8_t be_to_cpu8 (uint8_t value);
48 uint16_t be_to_cpu16(uint16_t value);
49 uint32_t be_to_cpu32(uint32_t value);
50 uint64_t be_to_cpu64(uint64_t value);
51
52 /* read value from base at offset in little endian */
53 uint8_t read_le8 (const void *base, size_t offset);
54 uint16_t read_le16(const void *base, size_t offset);
55 uint32_t read_le32(const void *base, size_t offset);
56 uint64_t read_le64(const void *base, size_t offset);
57
58 /* read value from base at offset in big endian */
59 uint8_t read_be8 (const void *base, size_t offset);
60 uint16_t read_be16(const void *base, size_t offset);
61 uint32_t read_be32(const void *base, size_t offset);
62 uint64_t read_be64(const void *base, size_t offset);
63
64 #endif /* !__PLATFORM_H__ */