Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

124 lines
4.5 KiB

  1. /*-
  2. * SPDX-License-Identifier: BSD-4-Clause
  3. *
  4. * Copyright (c) 1995 Terrence R. Lambert
  5. * Copyright 2022 John-Mark Gurney
  6. * All rights reserved.
  7. *
  8. * Copyright (c) 1990, 1993
  9. * The Regents of the University of California. All rights reserved.
  10. * (c) UNIX System Laboratories, Inc.
  11. * All or some portions of this file are derived from material licensed
  12. * to the University of California by American Telephone and Telegraph
  13. * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  14. * the permission of UNIX System Laboratories, Inc.
  15. *
  16. * Redistribution and use in source and binary forms, with or without
  17. * modification, are permitted provided that the following conditions
  18. * are met:
  19. * 1. Redistributions of source code must retain the above copyright
  20. * notice, this list of conditions and the following disclaimer.
  21. * 2. Redistributions in binary form must reproduce the above copyright
  22. * notice, this list of conditions and the following disclaimer in the
  23. * documentation and/or other materials provided with the distribution.
  24. * 3. All advertising materials mentioning features or use of this software
  25. * must display the following acknowledgement:
  26. * This product includes software developed by the University of
  27. * California, Berkeley and its contributors.
  28. * 4. Neither the name of the University nor the names of its contributors
  29. * may be used to endorse or promote products derived from this software
  30. * without specific prior written permission.
  31. *
  32. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  33. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  34. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  35. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  36. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  37. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  38. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  39. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  40. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  41. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  42. * SUCH DAMAGE.
  43. *
  44. * @(#)kernel.h 8.3 (Berkeley) 1/21/94
  45. * $FreeBSD$
  46. */
  47. /*
  48. * This system is similar to FreeBSD's SYSINIT(9), but w/ minor
  49. * modifications.
  50. */
  51. #ifndef _SYSINIT_H_
  52. #define _SYSINIT_H_ 1
  53. /* for __WEAK */
  54. #include <cmsis_compiler.h>
  55. #include <stdint.h>
  56. #include <linker_set.h>
  57. /* from FreeBSD sys/systm.h */
  58. #define CTASSERT(x) _Static_assert(x, "compile-time assertion failed")
  59. #define MAKE_SUBORDER(subsys, order) ((uint32_t)((subsys) << 16) | (order))
  60. #define GET_SUBSYS(x) (((x) >> 16) & 0xffff)
  61. #define GET_ORDER(x) ((x) & 0xffff)
  62. enum sysinit_sub_id {
  63. SI_SUB_DUMMY = 0x0000, /* not executed; for linker*/
  64. SI_SUB_HAL = 0x0010, /* Early HAL init */
  65. SI_SUB_GPIO = 0x0030, /* Early GPIO */
  66. SI_SUB_USB = 0x0300, /* USB */
  67. SI_SUB_CONSOLE = 0x0700, /* Setup console/debug prints */
  68. SI_SUB_COPYRIGHT = 0x0800, /* start of when printf works */
  69. SI_SUB_STANDARD = 0x8000, /* standard later initalization */
  70. SI_SUB_LAST = 0xffff /* final initialization */
  71. };
  72. /*
  73. * Some enumerated orders; "ANY" sorts last.
  74. */
  75. enum sysinit_elem_order {
  76. SI_ORDER_FIRST = 0x0000, /* first*/
  77. SI_ORDER_SECOND = 0x0001, /* second*/
  78. SI_ORDER_THIRD = 0x0002, /* third*/
  79. SI_ORDER_FOURTH = 0x0003, /* fourth*/
  80. SI_ORDER_FIFTH = 0x0004, /* fifth*/
  81. SI_ORDER_SIXTH = 0x0005, /* sixth*/
  82. SI_ORDER_SEVENTH = 0x0006, /* seventh*/
  83. SI_ORDER_EIGHTH = 0x0007, /* eighth*/
  84. SI_ORDER_MIDDLE = 0x1000, /* somewhere in the middle */
  85. SI_ORDER_ANY = 0xfffe, /* second to last */
  86. SI_ORDER_LAST = 0xffff /* last*/
  87. };
  88. typedef void (*sysinit_cfunc_t)(const void *);
  89. struct sysinit {
  90. uint32_t si_subsys_order;
  91. sysinit_cfunc_t si_func;
  92. const void *si_udata;
  93. };
  94. #define SYSINIT(uniquifier, subsystem, order, func, udata) \
  95. CTASSERT(((subsystem) & 0xffff) == (subsystem)); \
  96. CTASSERT(((order) & 0xffff) == (order)); \
  97. static const struct sysinit uniquifier ## _sys_init = { \
  98. .si_subsys_order = MAKE_SUBORDER((subsystem), (order)), \
  99. .si_func = (func), \
  100. .si_udata = (udata), \
  101. }; \
  102. DATA_SET(sysinit_set,uniquifier ## _sys_init)
  103. #define SYSINIT_VF(uniquifier, subsystem, order, func) \
  104. SYSINIT(uniquifier, (subsystem), (order), (void (*)(const void *))(func), NULL)
  105. void sysinit_run(void);
  106. #endif /* _SYSINIT_H_ */