Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) #ifndef LIBFDT_ENV_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) #define LIBFDT_ENV_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * libfdt - Flat Device Tree manipulation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Copyright (C) 2006 David Gibson, IBM Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * Copyright 2012 Kim Phillips, Freescale Semiconductor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <stdbool.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <stddef.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <stdint.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <stdlib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <limits.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #ifdef __CHECKER__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define FDT_FORCE __attribute__((force))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define FDT_BITWISE __attribute__((bitwise))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define FDT_FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define FDT_BITWISE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) typedef uint16_t FDT_BITWISE fdt16_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) typedef uint32_t FDT_BITWISE fdt32_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) typedef uint64_t FDT_BITWISE fdt64_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define EXTRACT_BYTE(x, n)	((unsigned long long)((uint8_t *)&x)[n])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define CPU_TO_FDT16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define CPU_TO_FDT32(x) ((EXTRACT_BYTE(x, 0) << 24) | (EXTRACT_BYTE(x, 1) << 16) | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 			 (EXTRACT_BYTE(x, 2) << 8) | EXTRACT_BYTE(x, 3))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define CPU_TO_FDT64(x) ((EXTRACT_BYTE(x, 0) << 56) | (EXTRACT_BYTE(x, 1) << 48) | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 			 (EXTRACT_BYTE(x, 2) << 40) | (EXTRACT_BYTE(x, 3) << 32) | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 			 (EXTRACT_BYTE(x, 4) << 24) | (EXTRACT_BYTE(x, 5) << 16) | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 			 (EXTRACT_BYTE(x, 6) << 8) | EXTRACT_BYTE(x, 7))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static inline uint16_t fdt16_to_cpu(fdt16_t x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	return (FDT_FORCE uint16_t)CPU_TO_FDT16(x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) static inline fdt16_t cpu_to_fdt16(uint16_t x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	return (FDT_FORCE fdt16_t)CPU_TO_FDT16(x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) static inline uint32_t fdt32_to_cpu(fdt32_t x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	return (FDT_FORCE uint32_t)CPU_TO_FDT32(x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) static inline fdt32_t cpu_to_fdt32(uint32_t x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	return (FDT_FORCE fdt32_t)CPU_TO_FDT32(x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) static inline uint64_t fdt64_to_cpu(fdt64_t x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	return (FDT_FORCE uint64_t)CPU_TO_FDT64(x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) static inline fdt64_t cpu_to_fdt64(uint64_t x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	return (FDT_FORCE fdt64_t)CPU_TO_FDT64(x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #undef CPU_TO_FDT64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #undef CPU_TO_FDT32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #undef CPU_TO_FDT16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #undef EXTRACT_BYTE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #ifdef __APPLE__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #include <AvailabilityMacros.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) /* strnlen() is not available on Mac OS < 10.7 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) # if !defined(MAC_OS_X_VERSION_10_7) || (MAC_OS_X_VERSION_MAX_ALLOWED < \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)                                          MAC_OS_X_VERSION_10_7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #define strnlen fdt_strnlen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)  * fdt_strnlen: returns the length of a string or max_count - which ever is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)  * smallest.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)  * Input 1 string: the string whose size is to be determined
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)  * Input 2 max_count: the maximum value returned by this function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)  * Output: length of the string or max_count (the smallest of the two)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) static inline size_t fdt_strnlen(const char *string, size_t max_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)     const char *p = memchr(string, 0, max_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)     return p ? p - string : max_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #endif /* !defined(MAC_OS_X_VERSION_10_7) || (MAC_OS_X_VERSION_MAX_ALLOWED <
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)           MAC_OS_X_VERSION_10_7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #endif /* __APPLE__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #endif /* LIBFDT_ENV_H */