ahdlc.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #ifndef _DEV_AHDLC_H_
  2. #define _DEV_AHDLC_H_
  3. /*
  4. * Copyright (C) 2001-2003 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. * $Log: ahdlc.h,v $
  36. * Revision 1.1.1.1 2003/05/09 14:41:05 haraldkipp
  37. * Initial using 3.2.1
  38. *
  39. * Revision 1.2 2003/05/06 18:40:28 harald
  40. * Unused items removed
  41. *
  42. * Revision 1.1 2003/03/31 14:53:23 harald
  43. * Prepare release 3.1
  44. *
  45. */
  46. #include <dev/netbuf.h>
  47. #include <net/if_var.h>
  48. /*!
  49. * \file dev/ahdlc.h
  50. * \brief Asynchronous HDLC device definitions.
  51. */
  52. /*
  53. * Significant octet values.
  54. */
  55. #define AHDLC_ALLSTATIONS 0xff /*!< \brief All-Stations broadcast address */
  56. #define AHDLC_UI 0x03 /*!< \brief Unnumbered Information */
  57. #define AHDLC_FLAG 0x7e /*!< \brief Flag Sequence */
  58. #define AHDLC_ESCAPE 0x7d /*!< \brief Asynchronous Control Escape */
  59. #define AHDLC_TRANS 0x20 /*!< \brief Asynchronous transparency modifier */
  60. /*
  61. * Values for FCS calculations.
  62. */
  63. #define AHDLC_INITFCS 0xffff /*!< \brief Initial FCS value */
  64. #define AHDLC_GOODFCS 0xf0b8 /*!< \brief Good final FCS value */
  65. /*!
  66. * \struct _AHDLCDCB ahdlc.h dev/ahdlc.h
  67. * \brief Asynchronous HDLC device information structure.
  68. *
  69. * The start of this structure is equal to the UARTDCB structure.
  70. */
  71. struct _AHDLCDCB {
  72. /*! \brief Mode flags.
  73. */
  74. u_long dcb_modeflags;
  75. /*! \brief Status flags.
  76. */
  77. u_long dcb_statusflags;
  78. /*! \brief Read timeout.
  79. */
  80. u_long dcb_rtimeout;
  81. /*! \brief Write timeout.
  82. */
  83. u_long dcb_wtimeout;
  84. /*! \brief Queue of threads waiting for output buffer empty.
  85. *
  86. * Threads are added to this queue when the output buffer
  87. * is full or when flushing the output buffer.
  88. */
  89. HANDLE dcb_tx_rdy;
  90. /*! \brief Queue of threads waiting for a character in the input buffer.
  91. *
  92. * Threads are added to this queue when the output buffer is
  93. * empty.
  94. */
  95. HANDLE dcb_rx_rdy;
  96. /*! \brief Hardware base address.
  97. *
  98. * This is a copy of the base address in the NUTDEVICE structure
  99. * and required by the interrupt routine.
  100. */
  101. u_char dcb_base;
  102. /*! \brief Input buffer.
  103. *
  104. * This buffer is filled by the the receiver interrupt, so the
  105. * contents of the buffer is volatile.
  106. */
  107. volatile u_char *dcb_rx_buf;
  108. /*! \brief Input buffer index for next incoming byte.
  109. *
  110. * This volatile index is incremented by the receiver interrupt.
  111. */
  112. volatile u_char dcb_rx_idx;
  113. /*! \brief Input buffer index for next byte to read.
  114. */
  115. u_char dcb_rd_idx;
  116. /*! \brief Output buffer.
  117. */
  118. u_char *dcb_tx_buf;
  119. /*! \brief Output buffer index for next outgoing byte.
  120. *
  121. * This volatile index is incremented by the transmit interrupt.
  122. */
  123. volatile u_char dcb_tx_idx;
  124. /*! \brief Output buffer index for next byte to write.
  125. */
  126. u_char dcb_wr_idx;
  127. /*! \brief HDLC mode change event queue.
  128. *
  129. * The frame receiver thread is waiting on this queue until
  130. * the device is switched to HDLC mode.
  131. */
  132. HANDLE dcb_mf_evt;
  133. /*! \brief 32-bit receive ACCM.
  134. */
  135. u_long dcb_rx_accm;
  136. /*! \brief 256-bit transmit ACCM.
  137. */
  138. u_long dcb_tx_accm;
  139. /*! \brief Maximum receive MRU.
  140. */
  141. u_short dcb_rx_mru;
  142. /*! \brief Maximum transmit MRU.
  143. */
  144. u_short dcb_tx_mru;
  145. };
  146. /*!
  147. * \brief Asynchronous HDLC device information type.
  148. */
  149. typedef struct _AHDLCDCB AHDLCDCB;
  150. #endif