bankmem.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #ifndef _SYS_BANKMEM_H_
  2. #define _SYS_BANKMEM_H_
  3. /*
  4. * <MFS> Modified for Streamit
  5. * Changed MACRO to select bank
  6. * added void NutBufRemovePage(void) to the interface
  7. *
  8. * Copyright (C) 2003-2005 by egnite Software GmbH. All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. *
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions and the following disclaimer.
  16. * 2. Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the distribution.
  19. * 3. Neither the name of the copyright holders nor the names of
  20. * contributors may be used to endorse or promote products derived
  21. * from this software without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
  24. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  25. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  26. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
  27. * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  28. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  29. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  30. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  31. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  33. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  34. * SUCH DAMAGE.
  35. *
  36. * For additional information see http://www.ethernut.de/
  37. *
  38. */
  39. /*!
  40. * $Log: bankmem.h,v $
  41. * Revision 1.7 2007/04/12 09:08:57 haraldkipp
  42. * Segmented buffer routines ported to ARM.
  43. *
  44. * Revision 1.6 2005/09/07 16:22:11 christianwelzel
  45. * Added banking support for MMnet02
  46. *
  47. * Revision 1.5 2005/05/16 08:35:32 haraldkipp
  48. * Added banking support for Arthernet.
  49. *
  50. * Revision 1.4 2004/09/01 14:19:41 haraldkipp
  51. * Avoiding too many ifdefs
  52. *
  53. * Revision 1.3 2004/08/18 18:51:41 haraldkipp
  54. * Made banked memory configurable.
  55. *
  56. * Revision 1.2 2003/12/15 19:27:53 haraldkipp
  57. * Ethernut 2 support added
  58. *
  59. * Revision 1.1 2003/07/21 18:21:34 haraldkipp
  60. * First check in
  61. *
  62. */
  63. #include <sys/types.h>
  64. #include <cfg/bankmem.h>
  65. /*!
  66. * \file sys/bankmem.h
  67. * \brief Banked memory management definitions.
  68. */
  69. #ifndef NUTBANK_COUNT
  70. /*
  71. * Arrrgh! I hate this. OK, on one hand the code is not
  72. * spoiled by ifdefs, but this one is sooouuu ugly.
  73. */
  74. #define NUTBANK_COUNT 0
  75. #endif
  76. #if NUTBANK_COUNT
  77. #ifdef ARTHERNET1
  78. /* Arthernet uses a different banking. */
  79. #define NutSegBufEnable(bank) *(volatile u_char *)(NUTBANK_SR) = (((u_char)bank+1)<<4)
  80. #elif MMNET02
  81. /* MMnet02 uses a different banking. */
  82. #define NutSegBufEnable(bank) *((char *)(NUTBANK_SR)) = (bank)
  83. #else
  84. /* This is the Ethernut way. */
  85. //#define NutSegBufEnable(bank) *((char *)(NUTBANK_SR) + (bank)) = (bank)
  86. /* This is the Lukas way. */
  87. //#define NutSegBufEnable(bank) *(char *)(NUTBANK_SR) = ((u_char)(bank) + NUTBANK_OFFSET)
  88. /* This is the correct Lukas way. */
  89. #define NutSegBufEnable(bank) *(volatile u_char *)(NUTBANK_SR) = ((u_char)(bank) + NUTBANK_OFFSET)
  90. #endif
  91. #else
  92. /* No banked memory. */
  93. #define NutSegBufEnable(bank)
  94. #endif
  95. __BEGIN_DECLS
  96. /* Prototypes */
  97. extern char *NutSegBufReset(void);
  98. extern char *NutSegBufInit(size_t size);
  99. extern char *NutSegBufWriteRequest(size_t * bcp);
  100. extern char *NutSegBufReadRequest(size_t * bcp);
  101. extern char *NutSegBufWriteCommit(size_t bc);
  102. extern char *NutSegBufReadCommit(size_t bc);
  103. extern void NutSegBufWriteLast(size_t bc);
  104. extern void NutSegBufReadLast(size_t bc);
  105. extern u_long NutSegBufAvailable(void);
  106. extern u_long NutSegBufUsed(void);
  107. /* Added by Streamit */
  108. extern void NutBufRemovePage(void);
  109. /* */
  110. __END_DECLS
  111. #endif