confos.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #ifndef _SYS_CONFOS_H_
  2. #define _SYS_CONFOS_H_
  3. /*
  4. * Copyright (C) 2001-2006 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  23. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. */
  34. /*!
  35. * \file sys/confos.h
  36. * \brief Header file for global system configuration.
  37. *
  38. * \verbatim
  39. *
  40. * $Log$
  41. * Revision 1.9 2009/01/16 17:03:02 haraldkipp
  42. * Configurable host name length. The *nix conditional is
  43. * no longer required as this will be handled in the nvmem
  44. * routines. NutLoadConfig will now set the virgin host
  45. * name, if no valid configuration is available. Cookie
  46. * and virgin host name are configurable too, but disabled
  47. * in the Configurator until we fixed the string value
  48. * problem. You may use UserConf.mk instead.
  49. *
  50. * Revision 1.8 2008/10/05 16:47:04 haraldkipp
  51. * Removed attribute 'packed' from typedef.
  52. *
  53. * Revision 1.7 2008/08/11 07:00:25 haraldkipp
  54. * BSD types replaced by stdint types (feature request #1282721).
  55. *
  56. * Revision 1.6 2006/05/25 09:18:28 haraldkipp
  57. * API documentation updated and corrected.
  58. *
  59. * Revision 1.5 2006/03/16 15:25:34 haraldkipp
  60. * Changed human readable strings from u_char to char to stop GCC 4 from
  61. * nagging about signedness.
  62. *
  63. * Revision 1.4 2006/01/23 17:34:29 haraldkipp
  64. * Configuration structures must be packed.
  65. *
  66. * Revision 1.3 2005/07/26 16:02:57 haraldkipp
  67. * Avoid redefinition of CONFOS_EE_OFFSET.
  68. *
  69. * Revision 1.2 2004/03/03 17:52:25 drsung
  70. * New field 'hostname' added to structure confos.
  71. *
  72. * Revision 1.1.1.1 2003/05/09 14:41:19 haraldkipp
  73. * Initial using 3.2.1
  74. *
  75. * Revision 1.4 2003/02/04 18:00:52 harald
  76. * Version 3 released
  77. *
  78. * Revision 1.3 2002/06/26 17:29:28 harald
  79. * First pre-release with 2.4 stack
  80. *
  81. * \endverbatim
  82. */
  83. #include <sys/types.h>
  84. #include <cfg/eeprom.h>
  85. #include <stdint.h>
  86. /*!
  87. * \addtogroup xgConfOs
  88. */
  89. /*@{*/
  90. /*!
  91. * \brief Non-volatile memory location.
  92. *
  93. * Offset into non-volatile memory, where Nut/OS stores the system
  94. * configuration. The default may be overridden by the Configurator.
  95. */
  96. #ifndef CONFOS_EE_OFFSET
  97. #define CONFOS_EE_OFFSET 0
  98. #endif
  99. #ifndef CONFOS_EE_MAGIC
  100. #define CONFOS_EE_MAGIC "OS"
  101. #endif
  102. /*!
  103. * \brief Maximum number of characters allowed for hostname.
  104. *
  105. * Intentionally not MAXHOSTNAMELEN to avoid conflicts with existing
  106. * C libraries.
  107. */
  108. #ifndef MAX_HOSTNAME_LEN
  109. #define MAX_HOSTNAME_LEN 15
  110. #endif
  111. /*!
  112. * \brief Default hostname.
  113. *
  114. * Used on virgin systems without any valid configuration.
  115. */
  116. #ifndef CONFOS_VIRGIN_HOSTNAME
  117. #define CONFOS_VIRGIN_HOSTNAME "ethernut"
  118. #endif
  119. /*!
  120. * \brief Operating system configuration type.
  121. */
  122. typedef struct _CONFOS CONFOS;
  123. /*!
  124. * \struct _CONFOS confos.h sys/confos.h
  125. * \brief Operating system configuration structure.
  126. *
  127. * Applications may directly access the global variable \ref confos to
  128. * read or modify the current configuration.
  129. */
  130. struct NUT_PACKED_TYPE _CONFOS {
  131. /*! \brief Size of this structure.
  132. *
  133. * Used by Nut/Net to verify, that the structure contents is valid
  134. * after reading it from non-volatile memory.
  135. */
  136. uint8_t size;
  137. /*! \brief Magic cookie.
  138. *
  139. * Contains CONFOS_EE_MAGIC.
  140. */
  141. uint8_t magic[sizeof(CONFOS_EE_MAGIC) - 1];
  142. /*! \brief Host name of the system.
  143. */
  144. char hostname[MAX_HOSTNAME_LEN + 1];
  145. };
  146. extern CONFOS confos;
  147. extern int NutLoadConfig(void);
  148. extern int NutSaveConfig(void);
  149. /*@}*/
  150. #endif