mipsnet.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //
  2. // <COPYRIGHT CLASS="1B" YEAR="2005">
  3. // Unpublished work (c) MIPS Technologies, Inc. All rights reserved.
  4. // Unpublished rights reserved under the copyright laws of the U.S.A. and
  5. // other countries.
  6. //
  7. // PROPRIETARY / SECRET CONFIDENTIAL INFORMATION OF MIPS TECHNOLOGIES, INC.
  8. // FOR INTERNAL USE ONLY.
  9. //
  10. // Under no circumstances (contract or otherwise) may this information be
  11. // disclosed to, or copied, modified or used by anyone other than employees
  12. // or contractors of MIPS Technologies having a need to know.
  13. // </COPYRIGHT>
  14. //
  15. //++
  16. // File: MIPS_Net.h
  17. //
  18. // Description:
  19. // The definition of the emulated MIPSNET device's interface.
  20. //
  21. // Notes: This include file needs to work from a Linux device drivers.
  22. //
  23. //--
  24. //
  25. #ifndef __MIPSNET_H
  26. #define __MIPSNET_H
  27. /*
  28. * Id of this Net device, as seen by the core.
  29. */
  30. #define MIPS_NET_DEV_ID ((uint64_t) \
  31. ((uint64_t)'M'<< 0)| \
  32. ((uint64_t)'I'<< 8)| \
  33. ((uint64_t)'P'<<16)| \
  34. ((uint64_t)'S'<<24)| \
  35. ((uint64_t)'N'<<32)| \
  36. ((uint64_t)'E'<<40)| \
  37. ((uint64_t)'T'<<48)| \
  38. ((uint64_t)'0'<<56))
  39. /*
  40. * Net status/control block as seen by sw in the core.
  41. * (Why not use bit fields? can't be bothered with cross-platform struct
  42. * packing.)
  43. */
  44. typedef struct _net_control_block {
  45. /// dev info for probing
  46. /// reads as MIPSNET%d where %d is some form of version
  47. uint64_t devId; /*0x00 */
  48. /*
  49. * read only busy flag.
  50. * Set and cleared by the Net Device to indicate that an rx or a tx
  51. * is in progress.
  52. */
  53. uint32_t busy; /*0x08 */
  54. /*
  55. * Set by the Net Device.
  56. * The device will set it once data has been received.
  57. * The value is the number of bytes that should be read from
  58. * rxDataBuffer. The value will decrease till 0 until all the data
  59. * from rxDataBuffer has been read.
  60. */
  61. uint32_t rxDataCount; /*0x0c */
  62. #define MIPSNET_MAX_RXTX_DATACOUNT (1<<16)
  63. /*
  64. * Settable from the MIPS core, cleared by the Net Device.
  65. * The core should set the number of bytes it wants to send,
  66. * then it should write those bytes of data to txDataBuffer.
  67. * The device will clear txDataCount has been processed (not necessarily sent).
  68. */
  69. uint32_t txDataCount; /*0x10 */
  70. /*
  71. * Interrupt control
  72. *
  73. * Used to clear the interrupted generated by this dev.
  74. * Write a 1 to clear the interrupt. (except bit31).
  75. *
  76. * Bit0 is set if it was a tx-done interrupt.
  77. * Bit1 is set when new rx-data is available.
  78. * Until this bit is cleared there will be no other RXs.
  79. *
  80. * Bit31 is used for testing, it clears after a read.
  81. * Writing 1 to this bit will cause an interrupt to be generated.
  82. * To clear the test interrupt, write 0 to this register.
  83. */
  84. uint32_t interruptControl; /*0x14 */
  85. #define MIPSNET_INTCTL_TXDONE ((uint32_t)(1<< 0))
  86. #define MIPSNET_INTCTL_RXDONE ((uint32_t)(1<< 1))
  87. #define MIPSNET_INTCTL_TESTBIT ((uint32_t)(1<<31))
  88. #define MIPSNET_INTCTL_ALLSOURCES (MIPSNET_INTCTL_TXDONE|MIPSNET_INTCTL_RXDONE|MIPSNET_INTCTL_TESTBIT)
  89. /*
  90. * Readonly core-specific interrupt info for the device to signal the core.
  91. * The meaning of the contents of this field might change.
  92. */
  93. /*###\todo: the whole memIntf interrupt scheme is messy: the device should have
  94. * no control what so ever of what VPE/register set is being used.
  95. * The MemIntf should only expose interrupt lines, and something in the
  96. * config should be responsible for the line<->core/vpe bindings.
  97. */
  98. uint32_t interruptInfo; /*0x18 */
  99. /*
  100. * This is where the received data is read out.
  101. * There is more data to read until rxDataReady is 0.
  102. * Only 1 byte at this regs offset is used.
  103. */
  104. uint32_t rxDataBuffer; /*0x1c */
  105. /*
  106. * This is where the data to transmit is written.
  107. * Data should be written for the amount specified in the txDataCount register.
  108. * Only 1 byte at this regs offset is used.
  109. */
  110. uint32_t txDataBuffer; /*0x20 */
  111. } MIPS_T_NetControl;
  112. #define MIPSNET_IO_EXTENT 0x40 /* being generous */
  113. #define field_offset(field) ((int)&((MIPS_T_NetControl*)(0))->field)
  114. #endif /* __MIPSNET_H */