libpayload/include/endian.h: Add 64 bit enc/dec

Add 64 bit encode/decode functions to libpayload, since it is required
in the patch that moves device_tree to commonlib.

Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com>
Change-Id: I5dba9a7f41147a511ba1250786e7c51ce623e70a
Reviewed-on: https://review.coreboot.org/c/coreboot/+/83082
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/payloads/libpayload/include/endian.h b/payloads/libpayload/include/endian.h
index 934bb6a..35fe0fd 100644
--- a/payloads/libpayload/include/endian.h
+++ b/payloads/libpayload/include/endian.h
@@ -96,6 +96,16 @@
 		(uint32_t)(p[2] << 8) | p[3]);
 }
 
+static inline uint64_t be64dec(const void *pp)
+{
+	uint8_t const *p = (uint8_t const *)pp;
+
+	return (((uint64_t)p[0] << 56) | ((uint64_t)p[1] << 48) |
+		((uint64_t)p[2] << 40) | ((uint64_t)p[3] << 32) |
+		((uint64_t)p[4] << 24) | ((uint64_t)p[5] << 16) |
+		((uint64_t)p[6] <<  8) | p[7]);
+}
+
 static inline uint16_t le16dec(const void *pp)
 {
 	uint8_t const *p = (uint8_t const *)pp;
@@ -111,6 +121,16 @@
 		(uint32_t)(p[1] << 8) | p[0]);
 }
 
+static inline uint64_t le64dec(const void *pp)
+{
+	uint8_t const *p = (uint8_t const *)pp;
+
+	return (((uint64_t)p[7] << 56) | ((uint64_t)p[6] << 48) |
+		((uint64_t)p[5] << 40) | ((uint64_t)p[4] << 32) |
+		((uint64_t)p[3] << 24) | ((uint64_t)p[2] << 16) |
+		((uint64_t)p[1] <<  8) | p[0]);
+}
+
 static inline void bebitenc(void *pp, uint32_t u, uint8_t b)
 {
 	uint8_t *p = (uint8_t *)pp;
@@ -130,6 +150,11 @@
 	bebitenc(pp, u, 4);
 }
 
+static inline void be64enc(void *pp, uint32_t u)
+{
+	bebitenc(pp, u, 8);
+}
+
 static inline void lebitenc(void *pp, uint32_t u, uint8_t b)
 {
 	uint8_t *p = (uint8_t *)pp;
@@ -149,6 +174,11 @@
 	lebitenc(pp, u, 4);
 }
 
+static inline void le64enc(void *pp, uint32_t u)
+{
+	lebitenc(pp, u, 8);
+}
+
 /* Deprecated names (not in glibc / BSD) */
 #define htobew(in) htobe16(in)
 #define htobel(in) htobe32(in)