blob: 3cde2edae6701f60e09ebb44b253b40f841eb5c1 [file] [log] [blame]
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +00001/*
2 * This file is part of the flashrom project.
3 *
4 * Copyright (C) 2009 Carl-Daniel Hailfinger
Thomas Heijligen5618d5b2022-02-19 21:17:44 +01005 * Copyright (C) 2022 secunet Security Networks AG
6 * (written by Thomas Heijligen <thomas.heijligen@secunet.com)
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +00007 *
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.
Uwe Hermann43959702010-03-13 17:28:29 +000016 */
17
18/*
Thomas Heijligenc92f94b2022-03-17 13:41:17 +010019 * Header file for platform abstraction.
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000020 */
21
Thomas Heijligenc92f94b2022-03-17 13:41:17 +010022#ifndef __PLATFORM_H__
23#define __PLATFORM_H__ 1
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000024
Thomas Heijligen5194d582022-02-19 22:31:32 +010025#include <stddef.h>
Thomas Heijligen5618d5b2022-02-19 21:17:44 +010026#include <stdint.h>
Carl-Daniel Hailfingercceafa22010-05-26 01:45:41 +000027
Thomas Heijligen5618d5b2022-02-19 21:17:44 +010028/* convert cpu native endian to little endian */
29uint8_t cpu_to_le8 (uint8_t value);
30uint16_t cpu_to_le16(uint16_t value);
31uint32_t cpu_to_le32(uint32_t value);
32uint64_t cpu_to_le64(uint64_t value);
33
34/* convert cpu native endian to big endian */
35uint8_t cpu_to_be8 (uint8_t value);
36uint16_t cpu_to_be16(uint16_t value);
37uint32_t cpu_to_be32(uint32_t value);
38uint64_t cpu_to_be64(uint64_t value);
39
40/* convert little endian to cpu native endian */
41uint8_t le_to_cpu8 (uint8_t value);
42uint16_t le_to_cpu16(uint16_t value);
43uint32_t le_to_cpu32(uint32_t value);
44uint64_t le_to_cpu64(uint64_t value);
45
46/* convert big endian to cpu native endian */
47uint8_t be_to_cpu8 (uint8_t value);
48uint16_t be_to_cpu16(uint16_t value);
49uint32_t be_to_cpu32(uint32_t value);
50uint64_t be_to_cpu64(uint64_t value);
Carl-Daniel Hailfingercceafa22010-05-26 01:45:41 +000051
Thomas Heijligen5194d582022-02-19 22:31:32 +010052/* read value from base at offset in little endian */
53uint8_t read_le8 (const void *base, size_t offset);
54uint16_t read_le16(const void *base, size_t offset);
55uint32_t read_le32(const void *base, size_t offset);
56uint64_t read_le64(const void *base, size_t offset);
57
58/* read value from base at offset in big endian */
59uint8_t read_be8 (const void *base, size_t offset);
60uint16_t read_be16(const void *base, size_t offset);
61uint32_t read_be32(const void *base, size_t offset);
62uint64_t read_be64(const void *base, size_t offset);
63
Thomas Heijligenc92f94b2022-03-17 13:41:17 +010064#endif /* !__PLATFORM_H__ */