|
|
1.1 root 1: /*++
2:
3: Copyright (c) 1990-1992 Microsoft Corporation
4:
5: Module Name:
6:
7: sonichrd.h
8:
9: Abstract:
10:
11: This file contains the hardware-related definitions for
12: the SONIC driver.
13:
14: The overall structure is taken from the Lance driver
15: by Tony Ercolano.
16:
17: Author:
18:
19: Anthony V. Ercolano (tonye) creation-date 19-Jun-1990
20: Adam Barr (adamba) 16-Nov-1990
21:
22: Environment:
23:
24: This driver is expected to work in DOS, OS2 and NT at the equivalent
25: of kernel mode.
26:
27: Architecturally, there is an assumption in this driver that we are
28: on a little endian machine.
29:
30: Revision History:
31:
32:
33: --*/
34:
35: #ifndef _SONICHARDWARE_
36: #define _SONICHARDWARE_
37:
38:
39: //
40: // Include processor-specific definitions needed by the sonic.
41: // This defines the SONIC_READ_PORT and SONIC_WRITE_PORT macros,
42: // as well as whether SONIC_EISA and SONIC_INTERNAL are defined.
43: //
44:
45: #include <sonicdet.h>
46:
47:
48: //
49: // Offsets from the base of the Sonic registers.
50: //
51: // All registers are 16 bits.
52: //
53:
54: #define SONIC_COMMAND 0x00
55: #define SONIC_DATA_CONFIGURATION 0x01
56: #define SONIC_RECEIVE_CONTROL 0x02
57: #define SONIC_TRANSMIT_CONTROL 0x03
58: #define SONIC_INTERRUPT_MASK 0x04
59: #define SONIC_INTERRUPT_STATUS 0x05
60:
61: #define SONIC_UPPER_TRANSMIT_DESCRIPTOR 0x06
62: #define SONIC_CURR_TRANSMIT_DESCRIPTOR 0x07
63:
64: #define SONIC_UPPER_RECEIVE_DESCRIPTOR 0x0d
65: #define SONIC_CURR_RECEIVE_DESCRIPTOR 0x0e
66: #define SONIC_END_OF_BUFFER_WORD_COUNT 0x13
67: #define SONIC_UPPER_RECEIVE_RESOURCE 0x14
68: #define SONIC_RESOURCE_START 0x15
69: #define SONIC_RESOURCE_END 0x16
70: #define SONIC_RESOURCE_READ 0x17
71: #define SONIC_RESOURCE_WRITE 0x18
72: #define SONIC_RECEIVE_SEQUENCE 0x2b
73:
74: #define SONIC_CAM_ENTRY_POINTER 0x21
75: #define SONIC_CAM_ADDRESS_PORT_2 0x22
76: #define SONIC_CAM_ADDRESS_PORT_1 0x23
77: #define SONIC_CAM_ADDRESS_PORT_0 0x24
78: #define SONIC_CAM_ENABLE 0x25
79: #define SONIC_CAM_DESCRIPTOR 0x26
80: #define SONIC_CAM_DESCRIPTOR_COUNT 0x27
81:
82: #define SONIC_CRC_ERROR 0x2c
83: #define SONIC_FRAME_ALIGNMENT_ERROR 0x2d
84: #define SONIC_MISSED_PACKET 0x2e
85:
86: #define SONIC_WATCHDOG_TIMER_0 0x29
87: #define SONIC_WATCHDOG_TIMER_1 0x2a
88:
89: #define SONIC_SILICON_REVISION 0x28
90:
91:
92: //
93: // Constants for the SONIC_COMMAND register.
94: //
95:
96: #define SONIC_CR_LOAD_CAM ((USHORT)(0x0200))
97: #define SONIC_CR_READ_RRA ((USHORT)(0x0100))
98: #define SONIC_CR_SOFTWARE_RESET ((USHORT)(0x0080))
99: #define SONIC_CR_START_TIMER ((USHORT)(0x0020))
100: #define SONIC_CR_STOP_TIMER ((USHORT)(0x0010))
101: #define SONIC_CR_RECEIVER_ENABLE ((USHORT)(0x0008))
102: #define SONIC_CR_RECEIVER_DISABLE ((USHORT)(0x0004))
103: #define SONIC_CR_TRANSMIT_PACKETS ((USHORT)(0x0002))
104: #define SONIC_CR_HALT_TRANSMISSION ((USHORT)(0x0001))
105:
106:
107: //
108: // Constants for the SONIC_DATA_CONFIGURATION register.
109: //
110:
111: #define SONIC_DCR_LATCHED_BUS_RETRY ((USHORT)(0x2000))
112: #define SONIC_DCR_PROGRAMMABLE_OUTPUT_1 ((USHORT)(0x1000))
113: #define SONIC_DCR_PROGRAMMABLE_OUTPUT_0 ((USHORT)(0x0800))
114: #define SONIC_DCR_SYNCH_TERMINATION ((USHORT)(0x0400))
115: #define SONIC_DCR_USER_DEFINABLE_1 ((USHORT)(0x0200))
116: #define SONIC_DCR_USER_DEFINABLE_0 ((USHORT)(0x0100))
117: #define SONIC_DCR_0_WAIT_STATE ((USHORT)(0x0000))
118: #define SONIC_DCR_1_WAIT_STATE ((USHORT)(0x0040))
119: #define SONIC_DCR_2_WAIT_STATE ((USHORT)(0x0080))
120: #define SONIC_DCR_3_WAIT_STATE ((USHORT)(0x00c0))
121: #define SONIC_DCR_32_BIT_DATA_WIDTH ((USHORT)(0x0020))
122: #define SONIC_DCR_16_BIT_DATA_WIDTH ((USHORT)(0x0000))
123: #define SONIC_DCR_BLOCK_MODE_DMA ((USHORT)(0x0010))
124: #define SONIC_DCR_EMPTY_FILL_DMA ((USHORT)(0x0000))
125: #define SONIC_DCR_FIFO_MASK ((USHORT)(0xfff0))
126: #define SONIC_DCR_12_WORD_RECEIVE_FIFO ((USHORT)(0x000c))
127: #define SONIC_DCR_8_WORD_RECEIVE_FIFO ((USHORT)(0x0008))
128: #define SONIC_DCR_4_WORD_RECEIVE_FIFO ((USHORT)(0x0004))
129: #define SONIC_DCR_2_WORD_RECEIVE_FIFO ((USHORT)(0x0000))
130: #define SONIC_DCR_14_WORD_TRANSMIT_FIFO ((USHORT)(0x0003))
131: #define SONIC_DCR_12_WORD_TRANSMIT_FIFO ((USHORT)(0x0002))
132: #define SONIC_DCR_8_WORD_TRANSMIT_FIFO ((USHORT)(0x0001))
133: #define SONIC_DCR_4_WORD_TRANSMIT_FIFO ((USHORT)(0x0000))
134:
135:
136: //
137: // Constants for the SONIC_RECEIVE_CONTROL register.
138: //
139:
140: #define SONIC_RCR_ACCEPT_CRC_ERRORS ((USHORT)(0x8000))
141: #define SONIC_RCR_ACCEPT_RUNT_PACKETS ((USHORT)(0x4000))
142: #define SONIC_RCR_ACCEPT_BROADCAST ((USHORT)(0x2000))
143: #define SONIC_RCR_PROMISCUOUS_PHYSICAL ((USHORT)(0x1000))
144: #define SONIC_RCR_ACCEPT_ALL_MULTICAST ((USHORT)(0x0800))
145: #define SONIC_RCR_TRANSCEIVER_LOOPBACK ((USHORT)(0x0600))
146: #define SONIC_RCR_ENDEC_LOOPBACK ((USHORT)(0x0400))
147: #define SONIC_RCR_MAC_LOOPBACK ((USHORT)(0x0200))
148: #define SONIC_RCR_NO_LOOPBACK ((USHORT)(0x0000))
149:
150: #define SONIC_RCR_MULTICAST_RECEIVED ((USHORT)(0x0100))
151: #define SONIC_RCR_BROADCAST_RECEIVED ((USHORT)(0x0080))
152: #define SONIC_RCR_LAST_PACKET_IN_RBA ((USHORT)(0x0040))
153: #define SONIC_RCR_CARRIER_SENSE ((USHORT)(0x0020))
154: #define SONIC_RCR_COLLISION ((USHORT)(0x0010))
155: #define SONIC_RCR_CRC_ERROR ((USHORT)(0x0008))
156: #define SONIC_RCR_FRAME_ALIGNMENT ((USHORT)(0x0004))
157: #define SONIC_RCR_LOOPBACK_RECEIVED ((USHORT)(0x0002))
158: #define SONIC_RCR_PACKET_RECEIVED_OK ((USHORT)(0x0001))
159:
160:
161: //
162: // This is needed due to a problem with the SONIC while attempting
163: // to ignore these packets.
164: //
165:
166: #define SONIC_RCR_DEFAULT_VALUE ((USHORT) \
167: (SONIC_RCR_ACCEPT_CRC_ERRORS | \
168: SONIC_RCR_ACCEPT_RUNT_PACKETS))
169:
170:
171: //
172: // Constants for the SONIC_TRANSMIT_CONTROL register.
173: //
174:
175: #define SONIC_TCR_PROG_INTERRUPT ((USHORT)(0x8000))
176: #define SONIC_TCR_CRC_INHIBIT ((USHORT)(0x2000))
177: #define SONIC_TCR_EXCESSIVE_DEFERRAL ((USHORT)(0x0400))
178: #define SONIC_TCR_DEFERRED_TRANSMISSION ((USHORT)(0x0200))
179: #define SONIC_TCR_NO_CARRIER_SENSE ((USHORT)(0x0100))
180: #define SONIC_TCR_CARRIER_LOST ((USHORT)(0x0080))
181: #define SONIC_TCR_EXCESSIVE_COLLISIONS ((USHORT)(0x0040))
182: #define SONIC_TCR_OUT_OF_WINDOW ((USHORT)(0x0020))
183: #define SONIC_TCR_FIFO_UNDERRUN ((USHORT)(0x0004))
184: #define SONIC_TCR_BYTE_COUNT_MISMATCH ((USHORT)(0x0002))
185: #define SONIC_TCR_PACKET_TRANSMITTED_OK ((USHORT)(0x0001))
186:
187: #define SONIC_TCR_STATUS_MASK ((USHORT)(0x07ff))
188: #define SONIC_TCR_COLLISIONS_MASK ((USHORT)(0xf800))
189: #define SONIC_TCR_COLLISIONS_SHIFT 11
190:
191:
192: //
193: // Constants for the SONIC_INTERRUPT_MASK and
194: // SONIC_INTERRUPT_STATUS registers.
195: //
196:
197: #define SONIC_INT_BUS_RETRY ((USHORT)(0x4000))
198: #define SONIC_INT_HEARTBEAT_LOST ((USHORT)(0x2000))
199: #define SONIC_INT_LOAD_CAM_DONE ((USHORT)(0x1000))
200: #define SONIC_INT_PROG_INTERRUPT ((USHORT)(0x0800))
201: #define SONIC_INT_PACKET_RECEIVED ((USHORT)(0x0400))
202: #define SONIC_INT_PACKET_TRANSMITTED ((USHORT)(0x0200))
203: #define SONIC_INT_TRANSMIT_ERROR ((USHORT)(0x0100))
204: #define SONIC_INT_TIMER_COMPLETE ((USHORT)(0x0080))
205: #define SONIC_INT_RECEIVE_DESCRIPTORS ((USHORT)(0x0040))
206: #define SONIC_INT_RECEIVE_BUFFERS ((USHORT)(0x0020))
207: #define SONIC_INT_RECEIVE_OVERFLOW ((USHORT)(0x0010))
208: #define SONIC_INT_CRC_TALLY_ROLLOVER ((USHORT)(0x0008))
209: #define SONIC_INT_FAE_TALLY_ROLLOVER ((USHORT)(0x0004))
210: #define SONIC_INT_MP_TALLY_ROLLOVER ((USHORT)(0x0002))
211:
212: //
213: // By default, the interrupts we unmask.
214: //
215:
216: #define SONIC_INT_DEFAULT_VALUE ((USHORT) \
217: (SONIC_INT_BUS_RETRY | \
218: SONIC_INT_LOAD_CAM_DONE | \
219: SONIC_INT_PROG_INTERRUPT | \
220: SONIC_INT_PACKET_RECEIVED | \
221: SONIC_INT_PACKET_TRANSMITTED | \
222: SONIC_INT_TRANSMIT_ERROR | \
223: SONIC_INT_RECEIVE_DESCRIPTORS | \
224: SONIC_INT_RECEIVE_BUFFERS | \
225: SONIC_INT_RECEIVE_OVERFLOW | \
226: SONIC_INT_CRC_TALLY_ROLLOVER | \
227: SONIC_INT_FAE_TALLY_ROLLOVER | \
228: SONIC_INT_MP_TALLY_ROLLOVER))
229:
230: //
231: // The interrupts we acknowledge immediately.
232: //
233:
234: #define SONIC_INT_IMMEDIATE_ACK ((USHORT) \
235: (SONIC_INT_DEFAULT_VALUE & \
236: ~(SONIC_INT_RECEIVE_DESCRIPTORS | \
237: SONIC_INT_RECEIVE_BUFFERS)))
238:
239:
240:
241: //
242: // The maximum number of fragments that a transmit descriptor
243: // can hold. If a packet has more than this, we have to merge
244: // it into a single buffer before we transmit it. Increasing
245: // this will prevent us from merging packets with more fragments
246: // (which are rare) but use more memory in our transmit descriptors
247: // (which are permanently allocated). For every one that we
248: // increase this, memory usage goes up by 12 bytes in each
249: // descriptor.
250: //
251:
252: #define SONIC_MAX_FRAGMENTS 4
253:
254:
255: //
256: // The smallest size that a fragment can be. This is due to
257: // their potentially being underrun problems if a fragment
258: // shorted than this is transmitted. If a packet has a fragment
259: // that is too short, we merge it into a single buffer before
260: // we transmit it. This should not change unless the hardware
261: // changes in some way.
262: //
263:
264: #define SONIC_MIN_FRAGMENT_SIZE 12
265:
266:
267: //
268: // The smallest Ethernet packet size. Packets smaller than this
269: // have blanks appended to pad them out to this length.
270: //
271:
272: #define SONIC_MIN_PACKET_SIZE 60
273:
274:
275: //
276: // The number of entries in the CAM. The CAM (Content Addressable
277: // Memory) holds the directed and multicast addresses that we
278: // monitor. We reserve one of these spots for our directed address,
279: // allowing us SONIC_CAM_ENTRIES - 1 multicast addresses. Changing
280: // this allows us to handle more multicast addresses without
281: // forcing the protocol into "all multicast" mode, but allocates
282: // more memory in the CAM (16 bytes per entry).
283: //
284:
285: #define SONIC_CAM_ENTRIES 16
286:
287:
288: //
289: // The number of transmit descriptors in the ring we allocate,
290: // each of which can hold SONIC_MAX_FRAGMENTS fragments.
291: // The size of a transmit descriptor is ~100 bytes, varying
292: // based on SONIC_MAX_FRAGMENTS.
293: //
294:
295: #define SONIC_NUMBER_OF_TRANSMIT_DESCRIPTORS 5
296:
297:
298: //
299: // The number and size of the receive buffers we allocate,
300: // which hold the actual data received off the network. Increasing
301: // this allows us to receive more large packets, but the
302: // number of receive descriptors also needs to be increased.
303: //
304:
305: #define SONIC_NUMBER_OF_RECEIVE_BUFFERS 10
306: #define SONIC_SIZE_OF_RECEIVE_BUFFERS 4000
307:
308:
309: //
310: // This seems to have to be a multiple of four
311: // (not just two). When there is less than this
312: // amount left in a Receive Buffer after packet
313: // reception, the sonic will use the next
314: // ReceiveBuffer for the next packet. We define it
315: // larger than the maximum Ethernet packet size,
316: // so we never get a buffer overflow.
317: //
318:
319: #define SONIC_END_OF_BUFFER_COUNT 1520
320:
321:
322: //
323: // The number of receive descriptors we allocate, which hold
324: // pointers to packets received in the receive buffers. This
325: // is now kept at twice the number of receive buffers since
326: // two full-size packets can be received into each receive
327: // buffer.
328: //
329:
330: #define SONIC_NUMBER_OF_RECEIVE_DESCRIPTORS 20
331:
332:
333: //
334: // The small, medium and large buffers are used for merging
335: // packets that violate our constraints (two many fragments,
336: // fragments too small). The packet is merged into the smallest
337: // buffer that can hold it. These should not be increased unless
338: // there is a problem with many packets being merged; in that
339: // case it might be better to increase SONIC_MAX_FRAGMENTS
340: // first (if the problem is too many fragments).
341: //
342:
343: #define SONIC_SMALL_BUFFER_SIZE ((UINT)64)
344: #define SONIC_MEDIUM_BUFFER_SIZE ((UINT)256)
345: #define SONIC_LARGE_BUFFER_SIZE ((UINT)1514)
346:
347: #define SONIC_NUMBER_OF_SMALL_BUFFERS ((UINT)10)
348: #define SONIC_NUMBER_OF_MEDIUM_BUFFERS ((UINT)10)
349: #define SONIC_NUMBER_OF_LARGE_BUFFERS ((UINT)3)
350:
351:
352: //
353: // This bit in a link field signifies "end of list" to the
354: // sonic.
355: //
356:
357: #define SONIC_END_OF_LIST 0x01
358:
359:
360: //
361: // These are used in the InUse field of Receive Descriptors.
362: //
363:
364: #define SONIC_OWNED_BY_SYSTEM 0x00
365: #define SONIC_OWNED_BY_SONIC 0x01
366:
367:
368: //
369: // This type defines the physical addresses used by the Sonic
370: // chip itself. This should always be four bytes.
371: //
372:
373: typedef ULONG SONIC_PHYSICAL_ADDRESS, *PSONIC_PHYSICAL_ADDRESS;
374:
375:
376:
377: //
378: // Describes a Receive Buffer Area; the Receive Resource
379: // Area is an array of these structures. In 32-bit mode the
380: // upper 16 bits of all the elements are not used.
381: //
382:
383: typedef struct _SONIC_RECEIVE_RESOURCE {
384:
385: //
386: // Pointer to the receive buffer. It must be
387: // longword (4 bytes) aligned.
388: //
389:
390: SONIC_PHYSICAL_ADDRESS LowBufferAddress;
391: SONIC_PHYSICAL_ADDRESS HighBufferAddress;
392:
393: //
394: // The number of WORDS in the receive buffer.
395: //
396:
397: UINT LowBufferWordCount;
398: UINT HighBufferWordCount;
399:
400: } SONIC_RECEIVE_RESOURCE, * PSONIC_RECEIVE_RESOURCE;
401:
402:
403: //
404: // A receive descriptor; the Receive Descriptor Area is a
405: // linked list of these structures.
406: //
407:
408: typedef struct _SONIC_RECEIVE_DESCRIPTOR {
409:
410: //
411: // After reception this field will contain the contents
412: // of the SONIC_RECEIVE_CONTROL register. Bits 8-0 are
413: // status bits.
414: //
415:
416: UINT ReceiveStatus;
417:
418: //
419: // The length of the packet (including the CRC field).
420: //
421:
422: UINT ByteCount;
423:
424: //
425: // A pointer to the location in the RBA where the packet
426: // resides. A packet is always received into a contiguous
427: // piece of memory.
428: //
429:
430: SONIC_PHYSICAL_ADDRESS LowPacketAddress;
431: SONIC_PHYSICAL_ADDRESS HighPacketAddress;
432:
433: //
434: // Contains the RBA and packet sequence number.
435: //
436:
437: UINT SequenceNumber;
438:
439: //
440: // A link to the next receive descriptor. This is set up
441: // at initialization and is not modified by the SONIC.
442: // The low bit is the EOL bit, indicating the end of
443: // the linked list of receive descriptors.
444: //
445:
446: SONIC_PHYSICAL_ADDRESS Link;
447:
448: //
449: // Denotes the ownership of this receive descriptor.
450: // 0 = driver, non-zero = SONIC.
451: //
452:
453: UINT InUse;
454:
455: } SONIC_RECEIVE_DESCRIPTOR, * PSONIC_RECEIVE_DESCRIPTOR;
456:
457:
458:
459: //
460: // Describes a fragment of a packet.
461: //
462:
463: typedef struct _SONIC_TRANSMIT_FRAGMENT {
464:
465: //
466: // A pointer to the fragment. May be aligned on any
467: // byte boundary.
468: //
469:
470: SONIC_PHYSICAL_ADDRESS LowFragmentAddress;
471: SONIC_PHYSICAL_ADDRESS HighFragmentAddress;
472:
473: //
474: // The size of the fragment.
475: //
476:
477: UINT FragmentByteCount;
478:
479: } SONIC_TRANSMIT_FRAGMENT, * PSONIC_TRANSMIT_FRAGMENT;
480:
481:
482: //
483: // A transmit descriptor for a packet (containing up to
484: // SONIC_MAX_PACKET_FRAGMENTS pieces); the Transmit
485: // Descriptor Area is a linked list of these structures.
486: // If there are fewer than SONIC_MAX_PACKET_FRAGMENTS
487: // pieces, then the Link field will not be used and
488: // the link value will instead be put in
489: // PacketFragments[FragmentCount].FragmentPointerLsb;
490: // however at initialization the value will be put in
491: // Link and that is the value that must be used.
492: //
493:
494: typedef struct _SONIC_TRANSMIT_DESCRIPTOR {
495:
496: //
497: // Contains the status after transmission. The status
498: // is bits 10-0 of the SONIC_TRANSMIT_CONTROL register.
499: //
500:
501: UINT TransmitStatus;
502:
503: //
504: // Before transmission, bits 15-12 of this field are
505: // copied into the SONIC_TRANSMIT_CONTROL register.
506: //
507:
508: UINT TransmitConfiguration;
509:
510: //
511: // The size of the packet to be transmitted, in bytes.
512: //
513:
514: UINT PacketSize;
515:
516: //
517: // The number of fragments in the packet.
518: //
519:
520: UINT FragmentCount;
521:
522: //
523: // Location and size of each fragment.
524: //
525:
526: SONIC_TRANSMIT_FRAGMENT Fragments[SONIC_MAX_FRAGMENTS];
527:
528: //
529: // A pointer to the next Transmit Descriptor. This will
530: // be set at initialization time and will not change.
531: // However, its value will be copied into the beginning
532: // of the first unused Fragments[] structure if FragmentCount
533: // is less than SONIC_MAX_FRAGMENTS (since the Link field
534: // must follow the last fragment descriptor).
535: //
536:
537: SONIC_PHYSICAL_ADDRESS Link;
538:
539: } SONIC_TRANSMIT_DESCRIPTOR, * PSONIC_TRANSMIT_DESCRIPTOR;
540:
541:
542:
543: //
544: // Describes an entry in the CAM Descriptor Area.
545: //
546:
547: typedef struct _SONIC_CAM_FRAGMENT {
548:
549: //
550: // The index (0-15) of the CAM entry
551: //
552:
553: UINT CamEntryPointer;
554:
555: //
556: // The Ethernet address, divided into three pieces in
557: // order from most significant to least significant.
558: // In each piece only the low-order 16 bits are
559: // used. I.e., for an Ethernet address 01-02-03-04-05-06,
560: // CamAddressPort0 would be 0x0102, CamAddressPort1
561: // would be 0x0304, and CamAddressPort2 would be 0x0506.
562: //
563:
564: UINT CamAddressPort0;
565: UINT CamAddressPort1;
566: UINT CamAddressPort2;
567:
568: } SONIC_CAM_FRAGMENT, * PSONIC_CAM_FRAGMENT;
569:
570:
571:
572: //
573: // The entire CAM Descriptor Area. In general, the CamEnable
574: // field is not needed; the value will be stored in the
575: // CamEntryPointer of the SONIC_CAM_FRAGMENT after the last
576: // one used. However, the current value will also be
577: // maintained in CamEnable.
578: //
579:
580: typedef struct _SONIC_CAM_DESCRIPTOR_AREA {
581:
582: //
583: // Holds the index and value of each of the entries.
584: //
585:
586: SONIC_CAM_FRAGMENT CamFragments[SONIC_CAM_ENTRIES];
587:
588: //
589: // A bit mask indicating which of the entries are enabled
590: // (only the low 16 bits are used).
591: //
592:
593: UINT CamEnable;
594:
595: } SONIC_CAM_DESCRIPTOR_AREA, * PSONIC_CAM_DESCRIPTOR_AREA;
596:
597:
598:
599: //
600: // Identifies the AdapterType values that the driver supports.
601: //
602:
603: #define SONIC_ADAPTER_TYPE_EISA 1
604: #define SONIC_ADAPTER_TYPE_INTERNAL 2
605:
606:
607: //
608: // Macros to get MSB and LSB of an address.
609: //
610:
611: #define SONIC_GET_LOW_PART_ADDRESS(Adr) ((USHORT)((Adr) & 0xffff))
612: #define SONIC_GET_HIGH_PART_ADDRESS(Adr) ((UCHAR)(((Adr) & 0xffff0000) >> 16))
613:
614:
615: //
616: // Set up a SONIC_CAM_FRAGMENT given the entry pointer and
617: // Ethernet address.
618: //
619: // Cfp is a pointer to a CAM Fragment.
620: //
621: // Ep is the entry pointer.
622: //
623: // Addr is the Ethernet address.
624: //
625:
626: #define SONIC_LOAD_CAM_FRAGMENT(Cfp, Ep, Addr) \
627: { \
628: PSONIC_CAM_FRAGMENT _Cfp = (Cfp); \
629: UINT _Ep = (Ep); \
630: PVOID _Addr = (Addr); \
631: _Cfp->CamEntryPointer = _Ep; \
632: NdisWriteRegisterUlong((PULONG)(&_Cfp->CamAddressPort0), (ULONG)(((PUSHORT)Addr)[0])); \
633: NdisWriteRegisterUlong((PULONG)(&_Cfp->CamAddressPort1), (ULONG)(((PUSHORT)Addr)[1])); \
634: NdisWriteRegisterUlong((PULONG)(&_Cfp->CamAddressPort2), (ULONG)(((PUSHORT)Addr)[2])); \
635: }
636:
637:
638: //
639: // Set up a SONIC_CAM_FRAGMENT to hold the CamEnable value
640: // in it.
641: //
642: // Cfp is a pointer to the CAM Fragment.
643: //
644: // Ce is the value for CAM Enable.
645: //
646:
647: #define SONIC_LOAD_CAM_ENABLE(_Cfp, _Ce) \
648: NdisWriteRegisterUlong((PULONG)(&(_Cfp)->CamEntryPointer), (ULONG)(_Ce))
649:
650:
651: //
652: // Set a link field to be the end of a list.
653: //
654: // Plink is a pointer to a link field.
655: //
656:
657: #define SONIC_SET_END_OF_LIST(Plink) \
658: { \
659: ULONG _Data; \
660: NdisReadRegisterUlong((PULONG)(Plink), (PULONG)(&_Data)); \
661: NdisWriteRegisterUlong((PULONG)(Plink),(ULONG)(_Data | SONIC_END_OF_LIST)); \
662: }
663:
664: //
665: // Set a link field to not be the end of a list.
666: //
667: // Plink is a pointer to a link field.
668: //
669:
670: #define SONIC_REMOVE_END_OF_LIST(Plink) \
671: { \
672: ULONG _Data; \
673: NdisReadRegisterUlong((PULONG)(Plink), (PULONG)(&_Data)); \
674: NdisWriteRegisterUlong((PULONG)(Plink), (ULONG)(_Data & ~SONIC_END_OF_LIST)); \
675: }
676:
677: //
678: // Used to set the address of a transmit descriptor fragment.
679: //
680: // Tdf is a pointer to a transmit descriptor fragment.
681: //
682: // Adr is a *physical* address.
683: //
684:
685: #define SONIC_SET_TRANSMIT_FRAGMENT_ADDRESS(Tdf,Adr) \
686: { \
687: SONIC_PHYSICAL_ADDRESS _Adr = (Adr); \
688: PSONIC_TRANSMIT_FRAGMENT _Tdf = (Tdf); \
689: _Tdf->LowFragmentAddress = (SONIC_PHYSICAL_ADDRESS)_Adr; \
690: _Tdf->HighFragmentAddress = (SONIC_PHYSICAL_ADDRESS)(SONIC_GET_HIGH_PART_ADDRESS(_Adr)); \
691: }
692:
693:
694: //
695: // Used to retrieve the address of a transmit descriptor fragment.
696: // It takes advantage of the fact that we store the entire address
697: // at LowFragmentAddress, not just the low bits.
698: //
699: // Tdf is a pointer to a transmit descriptor fragment.
700: //
701: #define SONIC_GET_TRANSMIT_FRAGMENT_ADDRESS(Tdf) \
702: (Tdf)->LowFragmentAddress
703:
704:
705: //
706: // Used to set the length of the transmit descriptor fragment.
707: //
708: // Tdf is a pointer to a transmit descriptor fragment.
709: //
710: // Len is the unsigned short length of the buffer.
711: //
712: #define SONIC_SET_TRANSMIT_FRAGMENT_LENGTH(Tdf,Len) \
713: (Tdf)->FragmentByteCount = (UINT)(Len)
714:
715:
716: //
717: // Used to put the link field on top of a transmit descriptor
718: // fragment.
719: //
720: // Tdf is a pointer to a transmit descriptor fragment.
721: //
722: // Link is the link field to copy.
723: //
724: #define SONIC_SET_TRANSMIT_LINK(Tdf,Link) \
725: NdisWriteRegisterUlong((PULONG)(&(Tdf)->LowFragmentAddress), (ULONG)((Link) | SONIC_END_OF_LIST))
726:
727:
728:
729: //
730: // Used to set the address of a receive resource.
731: //
732: // Rrp is a pointer to a receive resource.
733: //
734: // Adr is a *physical* address.
735: //
736: #define SONIC_SET_RECEIVE_RESOURCE_ADDRESS(Rrp,Adr) \
737: { \
738: SONIC_PHYSICAL_ADDRESS _Adr = (Adr); \
739: PSONIC_RECEIVE_RESOURCE _Rrp = (Rrp); \
740: NdisWriteRegisterUlong((PULONG)(&_Rrp->LowBufferAddress), (ULONG)(_Adr)); \
741: NdisWriteRegisterUlong((PULONG)(&_Rrp->HighBufferAddress), (ULONG)(SONIC_GET_HIGH_PART_ADDRESS(_Adr))); \
742: }
743:
744:
745: //
746: // Used to retrieve the address of a receive resource.
747: // It takes advantage of the fact that we store the entire address
748: // at LowBufferAddress, not just the low bits.
749: //
750: // Rrp is a pointer to a receive resource.
751: //
752: #define SONIC_GET_RECEIVE_RESOURCE_ADDRESS(Rrp) \
753: (Rrp)->LowBufferAddress
754:
755:
756: //
757: // Used to set the length of a receive resource.
758: //
759: // Rrp is a pointer to a receive resource.
760: //
761: // Len is the length of the buffer.
762: //
763: #define SONIC_SET_RECEIVE_RESOURCE_LENGTH(Rrp,Len) \
764: { \
765: ULONG _Len = (Len); \
766: PSONIC_RECEIVE_RESOURCE _Rrp = (Rrp); \
767: NdisWriteRegisterUlong((PULONG)(&_Rrp->LowBufferWordCount), (ULONG)(((_Len) & 0x1ffff) >> 1)); \
768: NdisWriteRegisterUlong((PULONG)(&_Rrp->HighBufferWordCount), (ULONG)((_Len) >> 17)); \
769: }
770:
771:
772: #endif // _SONICHARDWARE_
773:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.