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.
 
 
 
 
 
 

120 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. /* 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_CONSOLE = 0x0700, /* Setup console/debug prints */
  67. SI_SUB_COPYRIGHT = 0x0800, /* start of when printf works */
  68. SI_SUB_STANDARD = 0x8000, /* standard later initalization */
  69. SI_SUB_LAST = 0xffff /* final initialization */
  70. };
  71. /*
  72. * Some enumerated orders; "ANY" sorts last.
  73. */
  74. enum sysinit_elem_order {
  75. SI_ORDER_FIRST = 0x0000, /* first*/
  76. SI_ORDER_SECOND = 0x0001, /* second*/
  77. SI_ORDER_THIRD = 0x0002, /* third*/
  78. SI_ORDER_FOURTH = 0x0003, /* fourth*/
  79. SI_ORDER_FIFTH = 0x0004, /* fifth*/
  80. SI_ORDER_SIXTH = 0x0005, /* sixth*/
  81. SI_ORDER_SEVENTH = 0x0006, /* seventh*/
  82. SI_ORDER_EIGHTH = 0x0007, /* eighth*/
  83. SI_ORDER_MIDDLE = 0x1000, /* somewhere in the middle */
  84. SI_ORDER_ANY = 0xffff /* last*/
  85. };
  86. typedef void (*sysinit_cfunc_t)(const void *);
  87. struct sysinit {
  88. uint32_t si_subsys_order;
  89. sysinit_cfunc_t si_func;
  90. const void *si_udata;
  91. };
  92. #define SYSINIT(uniquifier, subsystem, order, func, udata) \
  93. CTASSERT((subsystem & 0xffff) == subsystem); \
  94. CTASSERT((order & 0xffff) == order); \
  95. static const struct sysinit uniquifier ## _sys_init = { \
  96. .si_subsys_order = MAKE_SUBORDER((subsystem), (order)), \
  97. .si_func = (func), \
  98. .si_udata = (udata), \
  99. }; \
  100. DATA_SET(sysinit_set,uniquifier ## _sys_init)
  101. void sysinit_run(void);
  102. #endif /* _SYSINIT_H_ */