Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

174 líneas
6.3 KiB

  1. /*-
  2. * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  3. *
  4. * Copyright (c) 1999 John D. Polstra
  5. * Copyright (c) 1999,2001 Peter Wemm <peter@FreeBSD.org>
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  18. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  21. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27. * SUCH DAMAGE.
  28. *
  29. * $FreeBSD$
  30. */
  31. #ifndef _SYS_LINKER_SET_H_
  32. #define _SYS_LINKER_SET_H_
  33. #include <sys/cdefs.h>
  34. /* START cdefs.h direct import from FreeBSD */
  35. /* This section has the follwing copyright */
  36. /*-
  37. * SPDX-License-Identifier: BSD-3-Clause
  38. *
  39. * Copyright (c) 1991, 1993
  40. * The Regents of the University of California. All rights reserved.
  41. *
  42. * This code is derived from software contributed to Berkeley by
  43. * Berkeley Software Design, Inc.
  44. *
  45. * Redistribution and use in source and binary forms, with or without
  46. * modification, are permitted provided that the following conditions
  47. * are met:
  48. * 1. Redistributions of source code must retain the above copyright
  49. * notice, this list of conditions and the following disclaimer.
  50. * 2. Redistributions in binary form must reproduce the above copyright
  51. * notice, this list of conditions and the following disclaimer in the
  52. * documentation and/or other materials provided with the distribution.
  53. * 3. Neither the name of the University nor the names of its contributors
  54. * may be used to endorse or promote products derived from this software
  55. * without specific prior written permission.
  56. *
  57. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  58. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  59. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  60. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  61. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  62. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  63. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  64. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  65. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  66. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  67. * SUCH DAMAGE.
  68. *
  69. * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
  70. * $FreeBSD$
  71. */
  72. #define __CONCAT1(x,y) x ## y
  73. #define __CONCAT(x,y) __CONCAT1(x,y)
  74. #define __STRING(x) #x /* stringify without expanding x */
  75. #define __XSTRING(x) __STRING(x) /* expand x, then stringify */
  76. #define __nosanitizeaddress
  77. #define __nosanitizememory
  78. #define __used __attribute__((__used__))
  79. #define __weak_symbol __attribute__((__weak__))
  80. /* END cdefs.h direct import */
  81. /*
  82. * The following macros are used to declare global sets of objects, which
  83. * are collected by the linker into a `linker_set' as defined below.
  84. * For ELF, this is done by constructing a separate segment for each set.
  85. */
  86. #if defined(__powerpc64__) && (!defined(_CALL_ELF) || _CALL_ELF == 1)
  87. /*
  88. * ELFv1 pointers to functions are actaully pointers to function
  89. * descriptors.
  90. *
  91. * Move the symbol pointer from ".text" to ".data" segment, to make
  92. * the GCC compiler happy:
  93. */
  94. #define __MAKE_SET_CONST
  95. #else
  96. #define __MAKE_SET_CONST const
  97. #endif
  98. /*
  99. * Private macros, not to be used outside this header file.
  100. */
  101. #ifdef __GNUCLIKE___SECTION
  102. /*
  103. * The userspace address sanitizer inserts redzones around global variables,
  104. * violating the assumption that linker set elements are packed.
  105. */
  106. #ifdef _KERNEL
  107. #define __NOASAN
  108. #else
  109. #define __NOASAN __nosanitizeaddress
  110. #endif
  111. #define __MAKE_SET_QV(set, sym, qv) \
  112. void *__WEAK(__CONCAT(__start_set_,set)); \
  113. void *__WEAK(__CONCAT(__stop_set_,set)); \
  114. static void const * qv \
  115. __NOASAN \
  116. __set_##set##_sym_##sym __section("set_" #set) \
  117. __used = &(sym)
  118. #define __MAKE_SET(set, sym) __MAKE_SET_QV(set, sym, __MAKE_SET_CONST)
  119. #else /* !__GNUCLIKE___SECTION */
  120. #error this file needs to be ported to your compiler
  121. #endif /* __GNUCLIKE___SECTION */
  122. /*
  123. * Public macros.
  124. */
  125. #define TEXT_SET(set, sym) __MAKE_SET(set, sym)
  126. #define DATA_SET(set, sym) __MAKE_SET(set, sym)
  127. #define DATA_WSET(set, sym) __MAKE_SET_QV(set, sym, )
  128. #define BSS_SET(set, sym) __MAKE_SET(set, sym)
  129. #define ABS_SET(set, sym) __MAKE_SET(set, sym)
  130. #define SET_ENTRY(set, sym) __MAKE_SET(set, sym)
  131. /*
  132. * Initialize before referring to a given linker set.
  133. */
  134. #define SET_DECLARE(set, ptype) \
  135. extern ptype __weak_symbol __section("set_" #set)*__CONCAT(__start_set_,set); \
  136. extern ptype __weak_symbol *__CONCAT(__stop_set_,set) __section("set_" #set)
  137. #define SET_BEGIN(set) \
  138. (&__CONCAT(__start_set_,set))
  139. #define SET_LIMIT(set) \
  140. (&__CONCAT(__stop_set_,set))
  141. /*
  142. * Iterate over all the elements of a set.
  143. *
  144. * Sets always contain addresses of things, and "pvar" points to words
  145. * containing those addresses. Thus is must be declared as "type **pvar",
  146. * and the address of each set item is obtained inside the loop by "*pvar".
  147. */
  148. #define SET_FOREACH(pvar, set) \
  149. for (pvar = SET_BEGIN(set); pvar < SET_LIMIT(set); pvar++)
  150. #define SET_ITEM(set, i) \
  151. ((SET_BEGIN(set))[i])
  152. /*
  153. * Provide a count of the items in a set.
  154. */
  155. #define SET_COUNT(set) \
  156. (SET_LIMIT(set) - SET_BEGIN(set))
  157. #endif /* _SYS_LINKER_SET_H_ */