|
|
1.1 root 1: /*++
2:
3: Copyright (c005189-92 Microsoft Corporation
4:
5: Module Name:
6:
7: miniport.h
8:
9: Abstract:
10:
11: Type definitions for miniport drivers.
12:
13: Author:
14:
15: Mike Glass 27-April-1992
16:
17: Revision History:
18:
19: --*/
20:
21: #ifndef _MINIPORT_
22: #define _MINIPORT_
23:
24: #include "stddef.h"
25:
26: #define ASSERT( exp )
27:
28: #ifndef IN
29: #define IN
30: #endif
31:
32: #ifndef OUT
33: #define OUT
34: #endif
35:
36: #ifndef OPTIONAL
37: #define OPTIONAL
38: #endif
39:
40: #ifndef NOTHING
41: #define NOTHING
42: #endif
43:
44: #ifndef CRITICAL
45: #define CRITICAL
46: #endif
47:
48: #ifndef ANYSIZE_ARRAY
49: #define ANYSIZE_ARRAY 1 // winnt
50: #endif
51:
52: #if defined(_MIPS_) || defined(_ALPHA_) // winnt
53: #define UNALIGNED __unaligned // winnt
54: #else // winnt
55: #define UNALIGNED // winnt
56: #endif // winnt
57:
58: #ifndef CONST
59: #define CONST const
60: #endif
61:
62: //
63: // Void
64: //
65:
66: typedef void *PVOID; // winnt
67:
68:
69: //
70: // Basics
71: //
72:
73: #ifndef VOID
74: #define VOID void
75: typedef char CHAR;
76: typedef short SHORT;
77: typedef long LONG;
78: #endif
79:
80: //
81: // UNICODE (Wide Character) types
82: //
83:
84: typedef wchar_t WCHAR; // wc, 16-bit UNICODE character
85:
86: typedef WCHAR *PWCHAR;
87: typedef WCHAR *LPWCH, *PWCH;
88: typedef CONST WCHAR *LPCWCH, *PCWCH;
89: typedef WCHAR *NWPSTR;
90: typedef WCHAR *LPWSTR, *PWSTR;
91:
92: typedef CONST WCHAR *LPCWSTR, *PCWSTR;
93:
94: //
95: // ANSI (Multi-byte Character) types
96: //
97: typedef CHAR *PCHAR;
98: typedef CHAR *LPCH, *PCH;
99:
100: typedef CONST CHAR *LPCCH, *PCCH;
101: typedef CHAR *NPSTR;
102: typedef CHAR *LPSTR, *PSTR;
103: typedef CONST CHAR *LPCSTR, *PCSTR;
104:
105: //
106: // Neutral ANSI/UNICODE types and macros
107: //
108: #ifdef UNICODE
109:
110: #ifndef _TCHAR_DEFINED
111: typedef WCHAR TCHAR, *PTCHAR;
112: typedef WCHAR TUCHAR, *PTUCHAR;
113: #define _TCHAR_DEFINED
114: #endif /* !_TCHAR_DEFINED */
115:
116: typedef LPWSTR LPTCH, PTCH;
117: typedef LPWSTR PTSTR, LPTSTR;
118: typedef LPCWSTR LPCTSTR;
119: typedef LPWSTR LP;
120: #define __TEXT(quote) L##quote
121:
122: #else /* UNICODE */
123:
124: #ifndef _TCHAR_DEFINED
125: typedef char TCHAR, *PTCHAR;
126: typedef unsigned char TUCHAR, *PTUCHAR;
127: #define _TCHAR_DEFINED
128: #endif /* !_TCHAR_DEFINED */
129:
130: typedef LPSTR LPTCH, PTCH;
131: typedef LPSTR PTSTR, LPTSTR;
132: typedef LPCSTR LPCTSTR;
133: #define __TEXT(quote) quote
134:
135: #endif /* UNICODE */
136: #define TEXT(quote) __TEXT(quote)
137:
138:
139: // end_winnt
140:
141: typedef double DOUBLE;
142:
143: typedef struct _QUAD { // QUAD is for those times we want
144: double DoNotUseThisField; // an 8 byte aligned 8 byte long structure
145: } QUAD; // which is NOT really a floating point
146: // number. Use DOUBLE if you want an FP
147: // number.
148:
149: //
150: // Pointer to Basics
151: //
152:
153: typedef SHORT *PSHORT; // winnt
154: typedef LONG *PLONG; // winnt
155: typedef QUAD *PQUAD;
156:
157: //
158: // Unsigned Basics
159: //
160:
161: // Tell windef.h that some types are already defined.
162: #define BASETYPES
163:
164: typedef unsigned char UCHAR;
165: typedef unsigned short USHORT;
166: typedef unsigned long ULONG;
167: typedef QUAD UQUAD;
168:
169: //
170: // Pointer to Unsigned Basics
171: //
172:
173: typedef UCHAR *PUCHAR;
174: typedef USHORT *PUSHORT;
175: typedef ULONG *PULONG;
176: typedef UQUAD *PUQUAD;
177:
178: //
179: // Signed characters
180: //
181:
182: typedef signed char SCHAR;
183: typedef SCHAR *PSCHAR;
184:
185: #ifndef NO_STRICT
186: #define STRICT 1
187: #endif
188:
189: //
190: // Handle to an Object
191: //
192:
193: // begin_winnt
194:
195: #ifdef STRICT
196: typedef void *HANDLE;
197: #define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
198: #else
199: typedef PVOID HANDLE;
200: #define DECLARE_HANDLE(name) typedef HANDLE name
201: #endif
202: typedef HANDLE *PHANDLE;
203:
204: // end_winnt
205:
206: //
207: // Low order two bits of a handle are ignored by the system and available
208: // for use by application code as tag bits. The remaining bits are opaque
209: // and used to store a serial number and table index.
210: //
211:
212: #define OBJ_HANDLE_TAGBITS 0x00000003L
213:
214: //
215: // Cardinal Data Types [0 - 2**N-2)
216: //
217:
218: typedef char CCHAR; // winnt
219: typedef short CSHORT;
220: typedef ULONG CLONG;
221:
222: typedef CCHAR *PCCHAR;
223: typedef CSHORT *PCSHORT;
224: typedef CLONG *PCLONG;
225:
226:
227: #if defined(MIDL_PASS) || defined(_CFRONT_PASS_)
228: typedef double LONGLONG;
229: typedef double ULONGLONG;
230: #else
231: #if defined(_M_IX86)
232: typedef double LONGLONG;
233: typedef double ULONGLONG;
234: #elif defined(_M_MRX000)
235: typedef double LONGLONG;
236: typedef double ULONGLONG;
237: #elif defined(_ALPHA_)
238: typedef __int64 LONGLONG;
239: typedef unsigned __int64 ULONGLONG;
240: #else
241: typedef double LONGLONG;
242: typedef double ULONGLONG;
243: #endif
244: #endif
245:
246: typedef LONGLONG *PLONGLONG;
247: typedef ULONGLONG *PULONGLONG;
248:
249: #if defined(MIDL_PASS)
250: typedef struct _LARGE_INTEGER {
251: #else // MIDL_PASS
252: typedef union _LARGE_INTEGER {
253: #if defined(_CFRONT_PASS_)
254: struct {
255: ULONG LowPart;
256: LONG HighPart;
257: } u;
258: #else
259: struct {
260: ULONG LowPart;
261: LONG HighPart;
262: };
263: #endif
264: #endif //MIDL_PASS
265: LONGLONG QuadPart;
266: } LARGE_INTEGER, *PLARGE_INTEGER;
267:
268:
269: #if defined(MIDL_PASS)
270: typedef struct _ULARGE_INTEGER {
271: #else // MIDL_PASS
272: typedef union _ULARGE_INTEGER {
273: #if defined(_CFRONT_PASS_)
274: struct {
275: ULONG LowPart;
276: ULONG HighPart;
277: } u;
278: #else
279: struct {
280: ULONG LowPart;
281: ULONG HighPart;
282: };
283: #endif
284: #endif //MIDL_PASS
285: ULONGLONG QuadPart;
286: } ULARGE_INTEGER, *PULARGE_INTEGER;
287:
288:
289: //
290: // Physical address.
291: //
292:
293: typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS; // windbgkd
294:
295:
296: //
297: // Boolean
298: //
299:
300: typedef UCHAR BOOLEAN; // winnt
301: typedef BOOLEAN *PBOOLEAN; // winnt
302:
303:
304: //
305: // Constants
306: //
307:
308: #define FALSE 0
309: #define TRUE 1
310:
311: #ifndef NULL
312: #ifdef __cplusplus
313: #define NULL 0
314: #else
315: #define NULL ((void *)0)
316: #endif
317: #endif // NULL
318:
319: //
320: // Calculate the byte offset of a field in a structure of type type.
321: //
322:
323: #define FIELD_OFFSET(type, field) ((LONG)&(((type *)0)->field))
324:
325:
326: //
327: // Calculate the address of the base of the structure given its type, and an
328: // address of a field within the structure.
329: //
330:
331: #define CONTAINING_RECORD(address, type, field) ((type *)( \
332: (PCHAR)(address) - \
333: (PCHAR)(&((type *)0)->field)))
334:
335: //
336: // Interrupt Request Level (IRQL)
337: //
338:
339: typedef UCHAR KIRQL;
340:
341: typedef KIRQL *PKIRQL;
342:
343:
344: //
345: // Macros used to eliminate compiler warning generated when formal
346: // parameters or local variables are not declared.
347: //
348: // Use DBG_UNREFERENCED_PARAMETER() when a parameter is not yet
349: // referenced but will be once the module is completely developed.
350: //
351: // Use DBG_UNREFERENCED_LOCAL_VARIABLE() when a local variable is not yet
352: // referenced but will be once the module is completely developed.
353: //
354: // Use UNREFERENCED_PARAMETER() if a parameter will never be referenced.
355: //
356: // DBG_UNREFERENCED_PARAMETER and DBG_UNREFERENCED_LOCAL_VARIABLE will
357: // eventually be made into a null macro to help determine whether there
358: // is unfinished work.
359: //
360:
361: #if ! (defined(lint) || defined(_lint))
362: #define UNREFERENCED_PARAMETER(P) (P)
363: #define DBG_UNREFERENCED_PARAMETER(P) (P)
364: #define DBG_UNREFERENCED_LOCAL_VARIABLE(V) (V)
365:
366: #else // lint or _lint
367:
368: // Note: lint -e530 says don't complain about uninitialized variables for
369: // this. line +e530 turns that checking back on. Error 527 has to do with
370: // unreachable code.
371:
372: #define UNREFERENCED_PARAMETER(P) \
373: /*lint -e527 -e530 */ \
374: { \
375: (P) = (P); \
376: } \
377: /*lint +e527 +e530 */
378: #define DBG_UNREFERENCED_PARAMETER(P) \
379: /*lint -e527 -e530 */ \
380: { \
381: (P) = (P); \
382: } \
383: /*lint +e527 +e530 */
384: #define DBG_UNREFERENCED_LOCAL_VARIABLE(V) \
385: /*lint -e527 -e530 */ \
386: { \
387: (V) = (V); \
388: } \
389: /*lint +e527 +e530 */
390:
391: #endif // lint or _lint
392:
393:
394:
395: #ifdef _X86_
396:
397: //
398: // Disable these two pramas that evaluate to "sti" "cli" on x86 so that driver
399: // writers to not leave them inadvertantly in their code.
400: //
401:
402: #if !defined(MIDL_PASS)
403: #if !defined(_CFRONT_PASS_)
404: #if !defined(RC_INVOKED)
405:
406: #pragma warning(disable:4164) // disable C4164 warning so that apps that
407: // build with /Od don't get weird errors !
408: #pragma function(_enable)
409: #pragma function(_disable)
410:
411: #pragma warning(default:4164) // reenable C4164 warning
412:
413: #endif
414: #endif
415: #endif
416:
417:
418: #endif //_X86_
419:
420: //
421: // Define the I/O bus interface types.
422: //
423:
424: typedef enum _INTERFACE_TYPE {
425: Internal,
426: Isa,
427: Eisa,
428: MicroChannel,
429: TurboChannel,
430: PCIBus,
431: VMEBus,
432: NuBus,
433: PCMCIABus,
434: CBus,
435: MPIBus,
436: MPSABus,
437: MaximumInterfaceType
438: }INTERFACE_TYPE, *PINTERFACE_TYPE;
439:
440: //
441: // Define the DMA transfer widths.
442: //
443:
444: typedef enum _DMA_WIDTH {
445: Width8Bits,
446: Width16Bits,
447: Width32Bits,
448: MaximumDmaWidth
449: }DMA_WIDTH, *PDMA_WIDTH;
450:
451: //
452: // Define DMA transfer speeds.
453: //
454:
455: typedef enum _DMA_SPEED {
456: Compatible,
457: TypeA,
458: TypeB,
459: TypeC,
460: MaximumDmaSpeed
461: }DMA_SPEED, *PDMA_SPEED;
462:
463:
464: //
465: // Interrupt modes.
466: //
467:
468: typedef enum _KINTERRUPT_MODE {
469: LevelSensitive,
470: Latched
471: } KINTERRUPT_MODE;
472:
473: //
474: // Define types of bus information.
475: //
476:
477: typedef enum _BUS_DATA_TYPE {
478: Cmos,
479: EisaConfiguration,
480: Pos,
481: CbusConfiguration,
482: PCIConfiguration,
483: VMEConfiguration,
484: NuBusConfiguration,
485: PCMCIAConfiguration,
486: MPIConfiguration,
487: MPSAConfiguration,
488: MaximumBusDataType
489: } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
490:
491:
492: //
493: // Structures used by the kernel drivers to describe which ports must be
494: // hooked out directly from the V86 emulator to the driver.
495: //
496:
497: typedef enum _EMULATOR_PORT_ACCESS_TYPE {
498: Uchar,
499: Ushort,
500: Ulong
501: } EMULATOR_PORT_ACCESS_TYPE, *PEMULATOR_PORT_ACCESS_TYPE;
502:
503: //
504: // Access Modes
505: //
506:
507: #define EMULATOR_READ_ACCESS 0x01
508: #define EMULATOR_WRITE_ACCESS 0x02
509:
510: typedef struct _EMULATOR_ACCESS_ENTRY {
511: ULONG BasePort;
512: ULONG NumConsecutivePorts;
513: EMULATOR_PORT_ACCESS_TYPE AccessType;
514: UCHAR AccessMode;
515: UCHAR StringSupport;
516: PVOID Routine;
517: } EMULATOR_ACCESS_ENTRY, *PEMULATOR_ACCESS_ENTRY;
518:
519:
520: #pragma pack(1)
521:
522:
523: //
524: // Define Mca POS data block for slot
525: //
526:
527: typedef struct _CM_MCA_POS_DATA {
528: USHORT AdapterId;
529: UCHAR PosData1;
530: UCHAR PosData2;
531: UCHAR PosData3;
532: UCHAR PosData4;
533: } CM_MCA_POS_DATA, *PCM_MCA_POS_DATA;
534:
535: //
536: // Memory configuration of eisa data block structure
537: //
538:
539: typedef struct _EISA_MEMORY_TYPE {
540: UCHAR ReadWrite: 1;
541: UCHAR Cached : 1;
542: UCHAR Reserved0 :1;
543: UCHAR Type:2;
544: UCHAR Shared:1;
545: UCHAR Reserved1 :1;
546: UCHAR MoreEntries : 1;
547: } EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE;
548:
549: typedef struct _EISA_MEMORY_CONFIGURATION {
550: EISA_MEMORY_TYPE ConfigurationByte;
551: UCHAR DataSize;
552: USHORT AddressLowWord;
553: UCHAR AddressHighByte;
554: USHORT MemorySize;
555: } EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION;
556:
557:
558: //
559: // Interrupt configurationn of eisa data block structure
560: //
561:
562: typedef struct _EISA_IRQ_DESCRIPTOR {
563: UCHAR Interrupt : 4;
564: UCHAR Reserved :1;
565: UCHAR LevelTriggered :1;
566: UCHAR Shared : 1;
567: UCHAR MoreEntries : 1;
568: } EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR;
569:
570: typedef struct _EISA_IRQ_CONFIGURATION {
571: EISA_IRQ_DESCRIPTOR ConfigurationByte;
572: UCHAR Reserved;
573: } EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION;
574:
575:
576: //
577: // DMA description of eisa data block structure
578: //
579:
580: typedef struct _DMA_CONFIGURATION_BYTE0 {
581: UCHAR Channel : 3;
582: UCHAR Reserved : 3;
583: UCHAR Shared :1;
584: UCHAR MoreEntries :1;
585: } DMA_CONFIGURATION_BYTE0;
586:
587: typedef struct _DMA_CONFIGURATION_BYTE1 {
588: UCHAR Reserved0 : 2;
589: UCHAR TransferSize : 2;
590: UCHAR Timing : 2;
591: UCHAR Reserved1 : 2;
592: } DMA_CONFIGURATION_BYTE1;
593:
594: typedef struct _EISA_DMA_CONFIGURATION {
595: DMA_CONFIGURATION_BYTE0 ConfigurationByte0;
596: DMA_CONFIGURATION_BYTE1 ConfigurationByte1;
597: } EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION;
598:
599:
600: //
601: // Port description of eisa data block structure
602: //
603:
604: typedef struct _EISA_PORT_DESCRIPTOR {
605: UCHAR NumberPorts : 5;
606: UCHAR Reserved :1;
607: UCHAR Shared :1;
608: UCHAR MoreEntries : 1;
609: } EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR;
610:
611: typedef struct _EISA_PORT_CONFIGURATION {
612: EISA_PORT_DESCRIPTOR Configuration;
613: USHORT PortAddress;
614: } EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION;
615:
616:
617: //
618: // Eisa slot information definition
619: // N.B. This structure is different from the one defined
620: // in ARC eisa addendum.
621: //
622:
623: typedef struct _CM_EISA_SLOT_INFORMATION {
624: UCHAR ReturnCode;
625: UCHAR ReturnFlags;
626: UCHAR MajorRevision;
627: UCHAR MinorRevision;
628: USHORT Checksum;
629: UCHAR NumberFunctions;
630: UCHAR FunctionInformation;
631: ULONG CompressedId;
632: } CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION;
633:
634:
635: //
636: // Eisa function information definition
637: //
638:
639: typedef struct _CM_EISA_FUNCTION_INFORMATION {
640: ULONG CompressedId;
641: UCHAR IdSlotFlags1;
642: UCHAR IdSlotFlags2;
643: UCHAR MinorRevision;
644: UCHAR MajorRevision;
645: UCHAR Selections[26];
646: UCHAR FunctionFlags;
647: UCHAR TypeString[80];
648: EISA_MEMORY_CONFIGURATION EisaMemory[9];
649: EISA_IRQ_CONFIGURATION EisaIrq[7];
650: EISA_DMA_CONFIGURATION EisaDma[4];
651: EISA_PORT_CONFIGURATION EisaPort[20];
652: UCHAR InitializationData[60];
653: } CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION;
654:
655: #pragma pack()
656:
657: //
658: // Masks for EISA function information
659: //
660:
661: #define EISA_FUNCTION_ENABLED 0x80
662: #define EISA_FREE_FORM_DATA 0x40
663: #define EISA_HAS_PORT_INIT_ENTRY 0x20
664: #define EISA_HAS_PORT_RANGE 0x10
665: #define EISA_HAS_DMA_ENTRY 0x08
666: #define EISA_HAS_IRQ_ENTRY 0x04
667: #define EISA_HAS_MEMORY_ENTRY 0x02
668: #define EISA_HAS_TYPE_ENTRY 0x01
669: #define EISA_HAS_INFORMATION EISA_HAS_PORT_RANGE + \
670: EISA_HAS_DMA_ENTRY + \
671: EISA_HAS_IRQ_ENTRY + \
672: EISA_HAS_MEMORY_ENTRY + \
673: EISA_HAS_TYPE_ENTRY
674:
675: //
676: // Masks for EISA memory configuration
677: //
678:
679: #define EISA_MORE_ENTRIES 0x80
680: #define EISA_SYSTEM_MEMORY 0x00
681: #define EISA_MEMORY_TYPE_RAM 0x01
682:
683: //
684: // Returned error code for EISA bios call
685: //
686:
687: #define EISA_INVALID_SLOT 0x80
688: #define EISA_INVALID_FUNCTION 0x81
689: #define EISA_INVALID_CONFIGURATION 0x82
690: #define EISA_EMPTY_SLOT 0x83
691: #define EISA_INVALID_BIOS_CALL 0x86
692:
693:
694: #endif /* _MINIPORT_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.