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.
 
 
 
 
 
 

116 lines
4.2 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. #include <linker_set.h>
  54. /* from FreeBSD sys/systm.h */
  55. #define CTASSERT(x) _Static_assert(x, "compile-time assertion failed")
  56. #define MAKE_SUBORDER(subsys, order) ((uint32_t)((subsys) << 16) | (order))
  57. #define GET_SUBSYS(x) (((x) >> 16) & 0xffff)
  58. #define GET_ORDER(x) ((x) & 0xffff)
  59. enum sysinit_sub_id {
  60. SI_SUB_DUMMY = 0x0000, /* not executed; for linker*/
  61. SI_SUB_HAL = 0x0010, /* Early HAL init */
  62. SI_SUB_GPIO = 0x0030, /* Early GPIO */
  63. SI_SUB_CONSOLE = 0x0700, /* Setup console/debug prints */
  64. SI_SUB_COPYRIGHT = 0x0800, /* start of when printf works */
  65. SI_SUB_STANDARD = 0x8000, /* standard later initalization */
  66. SI_SUB_LAST = 0xffff /* final initialization */
  67. };
  68. /*
  69. * Some enumerated orders; "ANY" sorts last.
  70. */
  71. enum sysinit_elem_order {
  72. SI_ORDER_FIRST = 0x0000, /* first*/
  73. SI_ORDER_SECOND = 0x0001, /* second*/
  74. SI_ORDER_THIRD = 0x0002, /* third*/
  75. SI_ORDER_FOURTH = 0x0003, /* fourth*/
  76. SI_ORDER_FIFTH = 0x0004, /* fifth*/
  77. SI_ORDER_SIXTH = 0x0005, /* sixth*/
  78. SI_ORDER_SEVENTH = 0x0006, /* seventh*/
  79. SI_ORDER_EIGHTH = 0x0007, /* eighth*/
  80. SI_ORDER_MIDDLE = 0x1000, /* somewhere in the middle */
  81. SI_ORDER_ANY = 0xffff /* last*/
  82. };
  83. typedef void (*sysinit_cfunc_t)(const void *);
  84. struct sysinit {
  85. uint32_t si_subsys_order;
  86. sysinit_cfunc_t si_func;
  87. const void *si_udata;
  88. };
  89. #define SYSINIT(uniquifier, subsystem, order, func, udata) \
  90. CTASSERT((subsystem & 0xffff) == subsystem); \
  91. CTASSERT((order & 0xffff) == order); \
  92. static struct sysinit uniquifier ## _sys_init = { \
  93. .si_subsys_order = MAKE_SUBORDER((subsystem), (order)), \
  94. .si_func = (func), \
  95. .si_udata = (udata), \
  96. }; \
  97. DATA_SET(sysinit_set,uniquifier ## _sys_init)
  98. void sysinit_run(void);
  99. #endif /* _SYSINIT_H_ */