mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-05 07:40:40 +02:00
hwaccess: add endianness converting deserialization functions
Add functions like `uint32_t read_le32(const void *base, size_t offset);` Read a 32 bit unsigned from a base with an offset. Having prototypes and a macro generated implementation makes it easier to read, understand and spot errors in one of them. Change-Id: Idde177acf8bc5f94cd046b6539dc31532c98e452 Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/31016 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:

committed by
Nico Huber

parent
c456944170
commit
82604bd738
13
platform.h
13
platform.h
@ -22,6 +22,7 @@
|
||||
#ifndef __PLATFORM_H__
|
||||
#define __PLATFORM_H__ 1
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* swap bytes */
|
||||
@ -100,4 +101,16 @@ uint16_t be_to_cpu16(uint16_t value);
|
||||
uint32_t be_to_cpu32(uint32_t value);
|
||||
uint64_t be_to_cpu64(uint64_t value);
|
||||
|
||||
/* read value from base at offset in little endian */
|
||||
uint8_t read_le8 (const void *base, size_t offset);
|
||||
uint16_t read_le16(const void *base, size_t offset);
|
||||
uint32_t read_le32(const void *base, size_t offset);
|
||||
uint64_t read_le64(const void *base, size_t offset);
|
||||
|
||||
/* read value from base at offset in big endian */
|
||||
uint8_t read_be8 (const void *base, size_t offset);
|
||||
uint16_t read_be16(const void *base, size_t offset);
|
||||
uint32_t read_be32(const void *base, size_t offset);
|
||||
uint64_t read_be64(const void *base, size_t offset);
|
||||
|
||||
#endif /* !__PLATFORM_H__ */
|
||||
|
Reference in New Issue
Block a user