confos.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 EGNITE SOFTWARE GMBH 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 EGNITE
  23. * SOFTWARE GMBH 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: confos.h,v $
  41. * Revision 1.6 2006/05/25 09:18:28 haraldkipp
  42. * API documentation updated and corrected.
  43. *
  44. * Revision 1.5 2006/03/16 15:25:34 haraldkipp
  45. * Changed human readable strings from u_char to char to stop GCC 4 from
  46. * nagging about signedness.
  47. *
  48. * Revision 1.4 2006/01/23 17:34:29 haraldkipp
  49. * Configuration structures must be packed.
  50. *
  51. * Revision 1.3 2005/07/26 16:02:57 haraldkipp
  52. * Avoid redefinition of CONFOS_EE_OFFSET.
  53. *
  54. * Revision 1.2 2004/03/03 17:52:25 drsung
  55. * New field 'hostname' added to structure confos.
  56. *
  57. * Revision 1.1.1.1 2003/05/09 14:41:19 haraldkipp
  58. * Initial using 3.2.1
  59. *
  60. * Revision 1.4 2003/02/04 18:00:52 harald
  61. * Version 3 released
  62. *
  63. * Revision 1.3 2002/06/26 17:29:28 harald
  64. * First pre-release with 2.4 stack
  65. *
  66. * \endverbatim
  67. */
  68. #include <sys/types.h>
  69. #include <cfg/eeprom.h>
  70. /*!
  71. * \addtogroup xgConfOs
  72. */
  73. /*@{*/
  74. /*!
  75. * \brief Non-volatile memory location.
  76. *
  77. * Offset into non-volatile memory, where Nut/OS stores the system
  78. * configuration. The default may be overridden by the Configurator.
  79. */
  80. #ifndef CONFOS_EE_OFFSET
  81. #define CONFOS_EE_OFFSET 0
  82. #endif
  83. #define CONFOS_EE_MAGIC "OS"
  84. /*!
  85. * \brief Operating system configuration type.
  86. */
  87. typedef struct __attribute__ ((packed)) _CONFOS CONFOS;
  88. /*!
  89. * \struct _CONFOS confos.h sys/confos.h
  90. * \brief Operating system configuration structure.
  91. *
  92. * Applications may directly access the global variable \ref confos to
  93. * read or modify the current configuration.
  94. */
  95. struct __attribute__ ((packed)) _CONFOS {
  96. /*! \brief Size of this structure.
  97. *
  98. * Used by Nut/Net to verify, that the structure contents is valid
  99. * after reading it from non-volatile memory.
  100. */
  101. u_char size;
  102. /*! \brief Magic cookie.
  103. *
  104. * Contains CONFOS_EE_MAGIC.
  105. */
  106. u_char magic[2];
  107. /*! \brief Host name of the system.
  108. */
  109. char hostname[16];
  110. };
  111. extern CONFOS confos;
  112. __BEGIN_DECLS
  113. /* Function prototypes */
  114. extern int NutLoadConfig(void);
  115. extern int NutSaveConfig(void);
  116. __END_DECLS
  117. /* End of prototypes */
  118. /*@}*/
  119. #endif