sm91c1.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. /*++
  2. Copyright (c) 2014 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. sm91c1.h
  5. Abstract:
  6. This header contains definitions for the SMSC91C111 LAN Ethernet Controller.
  7. Author:
  8. Chris Stevens 16-Apr-2014
  9. --*/
  10. //
  11. // ------------------------------------------------------------------- Includes
  12. //
  13. //
  14. // ---------------------------------------------------------------- Definitions
  15. //
  16. #define SM91C1_ALLOCATION_TAG 0x31396D53 // '19mS'
  17. //
  18. // Define the flags for the transmit control register.
  19. //
  20. #define SM91C1_TRANSMIT_CONTROL_ENABLE 0x0001
  21. #define SM91C1_TRANSMIT_CONTROL_LOOP 0x0002
  22. #define SM91C1_TRANSMIT_CONTROL_FORCE_COLLISION 0x0004
  23. #define SM91C1_TRANSMIT_CONTROL_PAD_ENABLE 0x0080
  24. #define SM91C1_TRANSMIT_CONTROL_NO_CRC 0x0100
  25. #define SM91C1_TRANSMIT_CONTROL_MONITOR_CARRIER_SENSE 0x0400
  26. #define SM91C1_TRANSMIT_CONTROL_FULL_DUPLEX 0x0800
  27. #define SM91C1_TRANSMIT_CONTROL_STOP_ON_SQET 0x1000
  28. #define SM91C1_TRANSMIT_CONTROL_EPH_LOOP 0x2000
  29. #define SM91C1_TRANSMIT_CONTROL_SWITCHED_FULL_DUPLEX 0x8000
  30. //
  31. // Define the flags for the EPH status register.
  32. //
  33. #define SM91C1_EPH_STATUS_TRANSMIT_SUCCESSFUL 0x0001
  34. #define SM91C1_EPH_STATUS_SINGLE_COLLISION 0x0002
  35. #define SM91C1_EPH_STATUS_MULTIPLE_COLLISIONS 0x0004
  36. #define SM91C1_EPH_STATUS_LAST_TRANSMIT_MULTICAST 0x0008
  37. #define SM91C1_EPH_STATUS_16_COLLISIONS 0x0010
  38. #define SM91C1_EPH_STATUS_SQET 0x0020
  39. #define SM91C1_EPH_STATUS_LAST_TRANSMIT_BROADCAST 0x0040
  40. #define SM91C1_EPH_STATUS_TRANSMIT_DEFERRED 0x0080
  41. #define SM91C1_EPH_STATUS_LATE_COLLISION 0x0200
  42. #define SM91C1_EPH_STATUS_LOST_CARRIER_SENSE 0x0400
  43. #define SM91C1_EPH_STATUS_EXCESSIVE_DEFERRAL 0x0800
  44. #define SM91C1_EPH_STATUS_COUNTER_ROLLOVER 0x1000
  45. #define SM91C1_EPH_STATUS_LINK_OK 0x4000
  46. //
  47. // Define the flags for the receive control register.
  48. //
  49. #define SM91C1_RECEIVE_CONTROL_ABORTED 0x0001
  50. #define SM91C1_RECEIVE_CONTROL_PROMISCUOUS 0x0002
  51. #define SM91C1_RECEIVE_CONTROL_ALL_MULTICAST 0x0004
  52. #define SM91C1_RECEIVE_CONTROL_ENABLE 0x0100
  53. #define SM91C1_RECEIVE_CONTROL_STRIP_CRC 0x0200
  54. #define SM91C1_RECEIVE_CONTROL_ABORT_ENABLE 0x2000
  55. #define SM91C1_RECEIVE_CONTROL_FILTER_CARRIER 0x4000
  56. #define SM91C1_RECEIVE_CONTROL_SOFT_RESET 0x8000
  57. //
  58. // Define the bits for the counter register.
  59. //
  60. #define SM91C1_COUNTER_SINGLE_COLLISION_MASK 0x000F
  61. #define SM91C1_COUNTER_SINGLE_COLLISION_SHIFT 0
  62. #define SM91C1_COUNTER_MULTIPLE_COLLISION_MASK 0x00F0
  63. #define SM91C1_COUNTER_MULTIPLE_COLLISION_SHIFT 4
  64. #define SM91C1_COUNTER_DEFERRED_TRANSMITS_MASK 0x0F00
  65. #define SM91C1_COUNTER_DEFERRED_TRANSMITS_SHIFT 8
  66. #define SM91C1_COUNTER_EXCESSIVE_DEFERRED_TRANSMITS_MASK 0xF000
  67. #define SM91C1_COUNTER_EXCESSIVE_DEFERRED_TRANSMITS_SHIFT 12
  68. //
  69. // Define the bits for the memory register.
  70. //
  71. #define SM91C1_MEMORY_INFORMATION_SIZE_MASK 0x00FF
  72. #define SM91C1_MEMORY_INFORMATION_SIZE_SHIFT 0
  73. #define SM91C1_MEMORY_INFORMATION_FREE_MASK 0xFF00
  74. #define SM91C1_MEMORY_INFORMATION_FREE_SHIFT 8
  75. #define SM91C1_MEMORY_UNIT_SIZE _2KB
  76. //
  77. // Define the bits for the PHY control register.
  78. //
  79. #define SM91C1_PHY_CONTROL_LED_SELECT_0B 0x0004
  80. #define SM91C1_PHY_CONTROL_LED_SELECT_1B 0x0008
  81. #define SM91C1_PHY_CONTROL_LED_SELECT_2B 0x0010
  82. #define SM91C1_PHY_CONTROL_LED_SELECT_0A 0x0020
  83. #define SM91C1_PHY_CONTROL_LED_SELECT_1A 0x0040
  84. #define SM91C1_PHY_CONTROL_LED_SELECT_2A 0x0080
  85. #define SM91C1_PHY_CONTROL_AUTONEGOTIATION 0x0800
  86. #define SM91C1_PHY_CONTROL_FULL_DUPLEX 0x1000
  87. #define SM91C1_PHY_CONTROL_SPEED_100 0x2000
  88. //
  89. // Define the flags for the bank select register.
  90. //
  91. #define SM91C1_BANK_SELECT_BANK_MASK 0x0007
  92. #define SM91C1_BANK_SELECT_BANK_SHIFT 0
  93. //
  94. // Define the flags for the configuration register.
  95. //
  96. #define SM91C1_CONFIGURATION_REGISTER_EXTERNAL_PHY 0x0200
  97. #define SM91C1_CONFIGURATION_REGISTER_GENERAL_PURPOSE_CONTROL 0x0400
  98. #define SM91C1_CONFIGURATION_REGISTER_NO_WAIT 0x1000
  99. #define SM91C1_CONFIGURATION_REGISTER_EPH_POWER_ENABLE 0x8000
  100. //
  101. // Define the bits for the base address register.
  102. //
  103. #define SM91C1_BASE_ADDRESS_BITS_5_TO_9_MASK 0x1F00
  104. #define SM91C1_BASE_ADDRESS_BITS_5_TO_9_SHIFT 8
  105. #define SM91C1_BASE_ADDRESS_BITS_13_TO_15_MASK 0xE000
  106. #define SM91C1_BASE_ADDRESS_BITS_13_TO_15_SHIFT 13
  107. //
  108. // Define the flags for the control register.
  109. //
  110. #define SM91C1_CONTROL_EEPROM_STORE 0x0001
  111. #define SM91C1_CONTROL_EEPROM_RELOAD 0x0002
  112. #define SM91C1_CONTROL_EEPROM_SELECT 0x0004
  113. #define SM91C1_CONTROL_TRANSMIT_ERROR_ENABLE 0x0020
  114. #define SM91C1_CONTROL_COUTER_ROLLOVER_ENABLE 0x0040
  115. #define SM91C1_CONTROL_LINK_ERROR_ENABLE 0x0080
  116. #define SM91C1_CONTROL_AUTO_RELEASE 0x0800
  117. #define SM91C1_CONTROL_RECEIVE_BAD_CRC_PACKETS 0x4000
  118. //
  119. // Define the flags for the MMU command register.
  120. //
  121. #define SM91C1_MMU_COMMAND_BUSY 0x0001
  122. #define SM91C1_MMU_COMMAND_OPERATION_MASK 0x00E0
  123. #define SM91C1_MMU_COMMAND_OPERATION_SHIFT 5
  124. //
  125. // Define the MMU operations.
  126. //
  127. #define SM91C1_MMU_OPERATION_NO_OP 0x0
  128. #define SM91C1_MMU_OPERATION_ALLOCATE_FOR_TRANSMIT 0x1
  129. #define SM91C1_MMU_OPERATION_RESET 0x2
  130. #define SM91C1_MMU_OPERATION_RECEIVE_FIFO_REMOVE 0x3
  131. #define SM91C1_MMU_OPERATION_RECEiVE_FIFO_REMOVE_AND_RELEASE 0x4
  132. #define SM91C1_MMU_OPERATION_RELEASE_PACKET 0x5
  133. #define SM91C1_MMU_OPERATION_QUEUE_PACKET_FOR_TRANSMIT 0x6
  134. #define SM91C1_MMU_OPERATION_TRANSMIT_FIFO_RESET 0x7
  135. //
  136. // Define the flags for the packet number register.
  137. //
  138. #define SM91C1_PACKET_NUMBER_MASK 0x3F
  139. #define SM91C1_PACKET_NUMBER_SHIFT 0
  140. //
  141. // Define the flags for the allocation result register.
  142. //
  143. #define SM91C1_ALLOCATION_RESULT_PACKET_NUMBER_MASK 0x3F
  144. #define SM91C1_ALLOCATION_RESULT_PACKET_NUMBER_SHIFT 0
  145. #define SM91C1_ALLOCATION_RESULT_FAILED 0x80
  146. //
  147. // Define the flags for the transmit FIFO register.
  148. //
  149. #define SM91C1_FIFO_PORTS_TRANSMIT_PACKET_NUMBER_MASK 0x3F
  150. #define SM91C1_FIFO_PORTS_TRANSMIT_PACKET_NUMBER_SHIFT 0
  151. #define SM91C1_FIFO_PORTS_TRANSMIT_EMPTY 0x80
  152. //
  153. // Define the flags for the receive FIFO register.
  154. //
  155. #define SM91C1_FIFO_PORTS_RECEIVE_PACKET_NUMBER_MASK 0x3F
  156. #define SM91C1_FIFO_PORTS_RECEIVE_PACKET_NUMBER_SHIFT 0
  157. #define SM91C1_FIFO_PORTS_RECEIVE_EMPTY 0x80
  158. //
  159. // Define the flags for the pointer register.
  160. //
  161. #define SM91C1_POINTER_MASK 0x07FF
  162. #define SM91C1_POINTER_SHIFT 0
  163. #define SM91C1_POINTER_NOT_EMPTY 0x0800
  164. #define SM91C1_POINTER_READ 0x2000
  165. #define SM91C1_POINTER_WRITE 0x0000
  166. #define SM91C1_POINTER_AUTO_INCREMENT 0x4000
  167. #define SM91C1_POINTER_TRANSMIT 0x0000
  168. #define SM91C1_POINTER_RECEIVE 0x8000
  169. //
  170. // Define the flags for the interrupt register.
  171. //
  172. #define SM91C1_INTERRUPT_RECEIVE 0x01
  173. #define SM91C1_INTERRUPT_TRANSMIT 0x02
  174. #define SM91C1_INTERRUPT_TRANSMIT_EMPTY 0x04
  175. #define SM91C1_INTERRUPT_ALLOCATE 0x08
  176. #define SM91C1_INTERRUPT_RECEIVE_OVERRUN 0x10
  177. #define SM91C1_INTERRUPT_EPH 0x20
  178. #define SM91C1_INTERRUPT_MD 0x80
  179. #define SM91C1_DEFAULT_INTERRUPTS \
  180. (SM91C1_INTERRUPT_MD | \
  181. SM91C1_INTERRUPT_EPH | \
  182. SM91C1_INTERRUPT_TRANSMIT | \
  183. SM91C1_INTERRUPT_RECEIVE_OVERRUN | \
  184. SM91C1_INTERRUPT_RECEIVE)
  185. #define SM91C1_ACKNOWLEDGE_INTERRUPT_MASK \
  186. (SM91C1_INTERRUPT_MD | \
  187. SM91C1_INTERRUPT_RECEIVE_OVERRUN | \
  188. SM91C1_INTERRUPT_TRANSMIT_EMPTY | \
  189. SM91C1_INTERRUPT_TRANSMIT)
  190. //
  191. // Define the flags for the management interface register.
  192. //
  193. #define SM91C1_MANAGEMENT_INTERFACE_MII_MDO 0x0001
  194. #define SM91C1_MANAGEMENT_INTERFACE_MII_MDI 0x0002
  195. #define SM91C1_MANAGEMENT_INTERFACE_MII_CLOCK 0x0004
  196. #define SM91C1_MANAGEMENT_INTERFACE_MII_OUTPUT_ENABLE 0x0008
  197. #define SM91C1_MANAGEMENT_INTERFACE_DISABLE_CRS100 0x4000
  198. //
  199. // Define the flags for the revision register.
  200. //
  201. #define SM91C1_REVISION_ID_MASK 0x000F
  202. #define SM91C1_REVISION_ID_SHIFT 0
  203. #define SM91C1_REVISION_CHIP_ID_MASK 0x00F0
  204. #define SM91C1_REVISION_CHIP_ID_SHIFT 4
  205. //
  206. // Define the flags for the receive register.
  207. //
  208. #define SM91C1_RECEIVE_DISCARD 0x0080
  209. //
  210. // Define the flags used to parse a SM91C1_REGISTER value.
  211. //
  212. #define SM91C1_REGISTER_OFFSET_MASK 0x00F
  213. #define SM91C1_REGISTER_OFFSET_SHIFT 0
  214. #define SM91C1_REGISTER_BYTE_COUNT_MASK 0x0F0
  215. #define SM91C1_REGISTER_BYTE_COUNT_SHIFT 4
  216. #define SM91C1_REGISTER_BANK_MASK 0xF00
  217. #define SM91C1_REGISTER_BANK_SHIFT 8
  218. //
  219. // Define SMSC91c111 Phy MII Basic Control register bits.
  220. //
  221. #define SM91C1_MII_BASIC_CONTROL_COLLISION_TEST 0x0080
  222. #define SM91C1_MII_BASIC_CONTROL_FULL_DUPLEX 0x0100
  223. #define SM91C1_MII_BASIC_CONTROL_RESTART_AUTONEGOTIATION 0x0200
  224. #define SM91C1_MII_BASIC_CONTROL_ISOLATE 0x0400
  225. #define SM91C1_MII_BASIC_CONTROL_POWER_DOWN 0x0800
  226. #define SM91C1_MII_BASIC_CONTROL_ENABLE_AUTONEGOTIATION 0x1000
  227. #define SM91C1_MII_BASIC_CONTROL_SPEED_100 0x2000
  228. #define SM91C1_MII_BASIC_CONTROL_LOOPBACK 0x4000
  229. #define SM91C1_MII_BASIC_CONTROL_RESET 0x8000
  230. //
  231. // Define SMSC91c111 Phy MII Basic Status register bits.
  232. //
  233. #define SM91C1_MII_BASIC_STATUS_EXTENDED_CAPABILITY 0x0001
  234. #define SM91C1_MII_BASIC_STATUS_JABBER_DETECTED 0x0002
  235. #define SM91C1_MII_BASIC_STATUS_LINK_STATUS 0x0004
  236. #define SM91C1_MII_BASIC_STATUS_AUTONEGOTIATE_CAPABLE 0x0008
  237. #define SM91C1_MII_BASIC_STATUS_REMOTE_FAULT 0x0010
  238. #define SM91C1_MII_BASIC_STATUS_AUTONEGOTIATE_COMPLETE 0x0020
  239. #define SM91C1_MII_BASIC_STATUS_PREAMBLE_SUPRESSION_CAPABLE 0x0040
  240. //
  241. // This bit is set if there is extended status in register 0x0F.
  242. //
  243. #define SM91C1_MII_BASIC_STATUS_EXTENDED_STATUS 0x0100
  244. //
  245. // This bit is set if the PHY can do 100BASE-T2 half-duplex.
  246. //
  247. #define SM91C1_MII_BASIC_STATUS_100_HALF2 0x0200
  248. //
  249. // This bit is set if the PHY can do 100BASE-T2 full-duplex.
  250. //
  251. #define SM91C1_MII_BASIC_STATUS_100_FULL2 0x0400
  252. //
  253. // This bit is set if the PHY can do 10 Mbps half-duplex.
  254. //
  255. #define SM91C1_MII_BASIC_STATUS_10_HALF 0x0800
  256. //
  257. // This bit is set if the PHY can do 10 Mbps full-duplex.
  258. //
  259. #define SM91C1_MII_BASIC_STATUS_10_FULL 0x1000
  260. //
  261. // This bit is set if the PHY can do 100 Mbps, half-duplex.
  262. //
  263. #define SM91C1_MII_BASIC_STATUS_100_HALF 0x2000
  264. //
  265. // This bit is set if the PHY can do 100 Mbps, full-duplex.
  266. //
  267. #define SM91C1_MII_BASIC_STATUS_100_FULL 0x4000
  268. //
  269. // This bit is set if the PHY can do 100 Mbps with 4k packets.
  270. //
  271. #define SM91C1_MII_BASIC_STATUS_100_BASE4 0x8000
  272. //
  273. // Define SMSC91c111 Phy MII Advertise register bits.
  274. //
  275. #define SM91C1_MII_ADVERTISE_CSMA 0x0001
  276. #define SM91C1_MII_ADVERTISE_10_HALF 0x0020
  277. #define SM91C1_MII_ADVERTISE_10_FULL 0x0040
  278. #define SM91C1_MII_ADVERTISE_100_HALF 0x0080
  279. #define SM91C1_MII_ADVERTISE_100_FULL 0x0100
  280. #define SM91C1_MII_ADVERTISE_100_BASE4 0x0200
  281. #define SM91C1_MII_ADVERTISE_REMOTE_FAULT 0x2000
  282. #define SM91C1_MII_ADVERTISE_LINK_PARTNER_ACK 0x4000
  283. #define SM91C1_MII_ADVERTISE_NEXT_PAGE 0x8000
  284. #define SM91C1_MII_ADVERTISE_FULL \
  285. (SM91C1_MII_ADVERTISE_100_FULL | \
  286. SM91C1_MII_ADVERTISE_10_FULL | \
  287. SM91C1_MII_ADVERTISE_CSMA)
  288. #define SM91C1_MII_ADVERTISE_ALL \
  289. (SM91C1_MII_ADVERTISE_10_HALF | \
  290. SM91C1_MII_ADVERTISE_10_FULL | \
  291. SM91C1_MII_ADVERTISE_100_HALF | \
  292. SM91C1_MII_ADVERTISE_100_FULL)
  293. //
  294. // Define SMSC91c111 Phy MII Configuraiton 1 register bits.
  295. //
  296. #define SM91C1_MII_CONFIGURATION_1_UTP_CABLE 0x0000
  297. #define SM91C1_MII_CONFIGURATION_1_STP_CABLE 0x0080
  298. #define SM91C1_MII_CONFIGURATION_1_EQUALIZER_DISABLE 0x0100
  299. #define SM91C1_MII_CONFIGURATION_1_UNSCRAMBLED_DISABLE 0x0200
  300. #define SM91C1_MII_CONFIGURATION_1_BYPASS_SCRAMBLER 0x0400
  301. #define SM91C1_MII_CONFIGURATION_1_TRANSMIT_POWER_DOWN 0x2000
  302. #define SM91C1_MII_CONFIGURATION_1_TRANSMIT_DISABLE 0x4000
  303. #define SM91C1_MII_CONFIGURATION_1_LINK_DISABLE 0x8000
  304. //
  305. // Define the SMSC91c111 Phy MII Interrupt Status register bits.
  306. //
  307. #define SM91C1_MII_INTERRUPT_STATUS_DUPLEX 0x0040
  308. #define SM91C1_MII_INTERRUPT_STATUS_SPEED_100 0x0080
  309. #define SM91C1_MII_INTERRUPT_STATUS_JABBER 0x0100
  310. #define SM91C1_MII_INTERRUPT_STATUS_POLARITY 0x0200
  311. #define SM91C1_MII_INTERRUPT_STATUS_END_OF_STREAM_ERROR 0x0400
  312. #define SM91C1_MII_INTERRUPT_STATUS_START_OF_STREAM_ERROR 0x0800
  313. #define SM91C1_MII_INTERRUPT_STATUS_CODEWORD 0x1000
  314. #define SM91C1_MII_INTERRUPT_STATUS_LOST_SYNCHRONIZATION 0x2000
  315. #define SM91C1_MII_INTERRUPT_STATUS_LINK_FAIL 0x4000
  316. #define SM91C1_MII_INTERRUPT_STATUS_INTERRUPT 0x8000
  317. //
  318. // Define the number of 1's that need to be written to the MII interface to
  319. // synchronize it into the IDLE state.
  320. //
  321. #define SM91C1_MII_SYNCHRONIZE_COUNT 32
  322. //
  323. // Define the size of an SM91c111 packet header and footer, in bytes.
  324. //
  325. #define SM91C1_PACKET_HEADER_SIZE 4
  326. #define SM91C1_PACKET_FOOTER_SIZE 2
  327. #define SM91C1_PACKET_CRC_SIZE 4
  328. //
  329. // Define the maximum packet size, including the headers, footers, and CRC.
  330. //
  331. #define SM91C1_MAX_PACKET_SIZE SM91C1_MEMORY_UNIT_SIZE
  332. //
  333. // Define the bits from the Smsc91c111 control byte.
  334. //
  335. #define SM91C1_CONTROL_BYTE_CRC 0x10
  336. #define SM91C1_CONTROL_BYTE_ODD 0x20
  337. //
  338. // ------------------------------------------------------ Data Type Definitions
  339. //
  340. //
  341. // Define the SMS91C1 Phy MII register values.
  342. // TODO: Refactor the generic MII registers and bit definitions to use mii.h.
  343. //
  344. typedef enum _SM91C1_MII_REGISTER {
  345. Sm91c1MiiRegisterBasicControl = 0x00,
  346. Sm91c1MiiRegisterBasicStatus = 0x01,
  347. Sm91c1MiiRegisterPhysicalId1 = 0x02,
  348. Sm91c1MiiRegisterPhysicalId2 = 0x03,
  349. Sm91c1MiiRegisterAdvertise = 0x04,
  350. Sm91c1MiiRegisterRemoteEndCapability = 0x05,
  351. Sm91c1MiiRegisterConfiguration1 = 0x10,
  352. Sm91c1MiiRegisterConfiguration2 = 0x11,
  353. Sm91c1MiiRegisterInterrupt = 0x12,
  354. Sm91c1MiiRegisterInterruptMask = 0x13
  355. } SM91C1_MII_REGISTER, *PSM91C1_MII_REGISTER;
  356. //
  357. // Define the SMSC91C1 register values. See the SM91C1_REGISTER_* mask to
  358. // decode the register.
  359. //
  360. typedef enum _SM91C1_REGISTER {
  361. Sm91c1RegisterTransmitControl = 0x020,
  362. Sm91c1RegisterEphStatus = 0x022,
  363. Sm91c1RegisterReceiveControl = 0x024,
  364. Sm91c1RegisterCounter = 0x026,
  365. Sm91c1RegisterMemoryInformation = 0x028,
  366. Sm91c1RegisterPhyControl = 0x02A,
  367. Sm91c1RegisterBankSelect = 0x02E,
  368. Sm91c1RegisterConfiguration = 0x120,
  369. Sm91c1RegisterBaseAddress = 0x122,
  370. Sm91c1RegisterIndividualAddress0 = 0x114,
  371. Sm91c1RegisterIndividualAddress1 = 0x115,
  372. Sm91c1RegisterIndividualAddress2 = 0x116,
  373. Sm91c1RegisterIndividualAddress3 = 0x117,
  374. Sm91c1RegisterIndividualAddress4 = 0x118,
  375. Sm91c1RegisterIndividualAddress5 = 0x119,
  376. Sm91c1RegisterGeneralPurpose = 0x12A,
  377. Sm91c1RegisterControl = 0x12C,
  378. Sm91c1RegisterMmuCommand = 0x220,
  379. Sm91c1RegisterPacketNumber = 0x212,
  380. Sm91c1RegisterAllocationResult = 0x213,
  381. Sm91c1RegisterTransmitFifo = 0x214,
  382. Sm91c1RegisterReceiveFifo = 0x215,
  383. Sm91c1RegisterPointer = 0x226,
  384. Sm91c1RegisterData = 0x228,
  385. Sm91c1RegisterInterrupt = 0x21C,
  386. Sm91c1RegisterInterruptMask = 0x21D,
  387. Sm91c1RegisterMulticastTable0 = 0x310,
  388. Sm91c1RegisterMulticastTable1 = 0x311,
  389. Sm91c1RegisterMulticastTable2 = 0x312,
  390. Sm91c1RegisterMulticastTable3 = 0x313,
  391. Sm91c1RegisterMulticastTable4 = 0x314,
  392. Sm91c1RegisterMulticastTable5 = 0x315,
  393. Sm91c1RegisterMulticastTable6 = 0x316,
  394. Sm91c1RegisterMulticastTable7 = 0x317,
  395. Sm91c1RegisterManagementInterface = 0x328,
  396. Sm91c1RegisterRevision = 0x32A,
  397. Sm91c1RegisterReceive = 0x32C
  398. } SM91C1_REGISTER, *PSM91C1_REGISTER;
  399. /*++
  400. Structure Description:
  401. This structure defines an SMSC91C1 LAN device.
  402. Members:
  403. OsDevice - Stores a pointer to the OS device object.
  404. ControllerBase - Stores the virtual address of the memory mapping to the
  405. Smsc91c111's registers.
  406. NetworkLink - Stores a pointer to the core networking link.
  407. InterruptLine - Stores the interrupt line that this controller's interrupt
  408. comes in on.
  409. InterruptVector - Stores the interrupt vector that this controller's
  410. interrupt comes in on.
  411. InterruptResourcesFound - Stores a boolean indicating whether or not the
  412. interrupt line and interrupt vector fields are valid.
  413. InterruptHandle - Stores a pointer to the handle received when the
  414. interrupt was connected.
  415. InterruptLock - Stores the spin lock, synchronized at the interrupt
  416. run level, that synchronizes access to the pending status bits, DPC,
  417. and work item.
  418. TransmitPacketList - Stores a list of network packets waiting to be sent.
  419. Lock - Stores a queued lock that protects access to the transmit packet
  420. list and various other values.
  421. ReceiveIoBuffer - Stores a pointer to the I/O buffer used to process a
  422. received packet.
  423. PendingTransmitPacket - Stores the packet number of the transmit packet for
  424. which status in pending.
  425. PendingInterrupts - Stores the bitmask of pending interrupts. See
  426. SM91C1_INTERRUPT_* for definitions.
  427. PendingPhyInterrupts - Stores the bitmask of pending MII interrupts. See
  428. SM91C1_MII_INTERRUPT_STATUS_* for definitions.
  429. AllocateInProgress - Stores a boolean indicating whether or not packet
  430. allocation is in progress. This is protected by the Lock member.
  431. BankLock - Stores a lock that synchronizes access to the Smsc91c111
  432. registers. It must be acquired ad the interrupt run level as the ISR
  433. reads the Smsc91c111 registers as well.
  434. SelectedBank - Stores the currently selected register bank.
  435. MacAddress - Stores the default MAC address of the device.
  436. --*/
  437. typedef struct _SM91C1_DEVICE {
  438. PDEVICE OsDevice;
  439. PVOID ControllerBase;
  440. PNET_LINK NetworkLink;
  441. ULONGLONG InterruptLine;
  442. ULONGLONG InterruptVector;
  443. BOOL InterruptResourcesFound;
  444. HANDLE InterruptHandle;
  445. KSPIN_LOCK InterruptLock;
  446. NET_PACKET_LIST TransmitPacketList;
  447. PQUEUED_LOCK Lock;
  448. PIO_BUFFER ReceiveIoBuffer;
  449. USHORT PendingTransmitPacket;
  450. volatile ULONG PendingInterrupts;
  451. volatile ULONG PendingPhyInterrupts;
  452. BOOL AllocateInProgress;
  453. KSPIN_LOCK BankLock;
  454. BYTE SelectedBank;
  455. BYTE MacAddress[ETHERNET_ADDRESS_SIZE];
  456. } SM91C1_DEVICE, *PSM91C1_DEVICE;
  457. //
  458. // -------------------------------------------------------------------- Globals
  459. //
  460. //
  461. // -------------------------------------------------------- Function Prototypes
  462. //
  463. //
  464. // Hardware functions called by the administrative side.
  465. //
  466. KSTATUS
  467. Sm91c1Send (
  468. PVOID DeviceContext,
  469. PNET_PACKET_LIST PacketList
  470. );
  471. /*++
  472. Routine Description:
  473. This routine sends data through the network.
  474. Arguments:
  475. DeviceContext - Supplies a pointer to the device context associated with
  476. the link down which this data is to be sent.
  477. PacketList - Supplies a pointer to a list of network packets to send. Data
  478. in these packets may be modified by this routine, but must not be used
  479. once this routine returns.
  480. Return Value:
  481. STATUS_SUCCESS if all packets were sent.
  482. STATUS_RESOURCE_IN_USE if some or all of the packets were dropped due to
  483. the hardware being backed up with too many packets to send.
  484. Other failure codes indicate that none of the packets were sent.
  485. --*/
  486. KSTATUS
  487. Sm91c1GetSetInformation (
  488. PVOID DeviceContext,
  489. NET_LINK_INFORMATION_TYPE InformationType,
  490. PVOID Data,
  491. PUINTN DataSize,
  492. BOOL Set
  493. );
  494. /*++
  495. Routine Description:
  496. This routine gets or sets the network device layer's link information.
  497. Arguments:
  498. DeviceContext - Supplies a pointer to the device context associated with
  499. the link for which information is being set or queried.
  500. InformationType - Supplies the type of information being queried or set.
  501. Data - Supplies a pointer to the data buffer where the data is either
  502. returned for a get operation or given for a set operation.
  503. DataSize - Supplies a pointer that on input contains the size of the data
  504. buffer. On output, contains the required size of the data buffer.
  505. Set - Supplies a boolean indicating if this is a get operation (FALSE) or a
  506. set operation (TRUE).
  507. Return Value:
  508. Status code.
  509. --*/
  510. KSTATUS
  511. Sm91c1pInitializeDeviceStructures (
  512. PSM91C1_DEVICE Device
  513. );
  514. /*++
  515. Routine Description:
  516. This routine performs housekeeping preparation for resetting and enabling
  517. an SM91C1 device.
  518. Arguments:
  519. Device - Supplies a pointer to the device.
  520. Return Value:
  521. Status code.
  522. --*/
  523. VOID
  524. Sm91c1pDestroyDeviceStructures (
  525. PSM91C1_DEVICE Device
  526. );
  527. /*++
  528. Routine Description:
  529. This routine performs destroy any device structures allocated for the
  530. SM91C1 device.
  531. Arguments:
  532. Device - Supplies a pointer to the device.
  533. Return Value:
  534. None.
  535. --*/
  536. KSTATUS
  537. Sm91c1pInitialize (
  538. PSM91C1_DEVICE Device
  539. );
  540. /*++
  541. Routine Description:
  542. This routine initializes and enables the SM91C1 device.
  543. Arguments:
  544. Device - Supplies a pointer to the device.
  545. Return Value:
  546. Status code.
  547. --*/
  548. INTERRUPT_STATUS
  549. Sm91c1pInterruptService (
  550. PVOID Context
  551. );
  552. /*++
  553. Routine Description:
  554. This routine implements the SM91C1 interrupt service routine.
  555. Arguments:
  556. Context - Supplies the context pointer given to the system when the
  557. interrupt was connected. In this case, this points to the e100 device
  558. structure.
  559. Return Value:
  560. Interrupt status.
  561. --*/
  562. INTERRUPT_STATUS
  563. Sm91c1pInterruptServiceWorker (
  564. PVOID Context
  565. );
  566. /*++
  567. Routine Description:
  568. This routine implements the SM91C1 low level interrupt service routine.
  569. Arguments:
  570. Context - Supplies the context pointer given to the system when the
  571. interrupt was connected. In this case, this points to the SM91c1 device
  572. structure.
  573. Return Value:
  574. Interrupt status.
  575. --*/
  576. //
  577. // Administrative functions called by the hardware side.
  578. //
  579. KSTATUS
  580. Sm91c1pAddNetworkDevice (
  581. PSM91C1_DEVICE Device
  582. );
  583. /*++
  584. Routine Description:
  585. This routine adds the device to core networking's available links.
  586. Arguments:
  587. Device - Supplies a pointer to the device to add.
  588. Return Value:
  589. Status code.
  590. --*/