xref: /reactos/drivers/bus/isapnp/isapnphw.h (revision d41dec2e)
1 /*
2  * PROJECT:     ReactOS ISA PnP Bus driver
3  * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE:     Hardware definitions
5  * COPYRIGHT:   Copyright 2010 Cameron Gutman <cameron.gutman@reactos.org>
6  *              Copyright 2020 Hervé Poussineau <hpoussin@reactos.org>
7  *              Copyright 2021 Dmitry Borisov <di.sean@protonmail.com>
8  */
9 
10 #pragma once
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 #if defined(SARCH_PC98)
17 #define ISAPNP_ADDRESS 0x259
18 #define ISAPNP_WRITE_DATA 0xA59
19 #else
20 #define ISAPNP_ADDRESS 0x279
21 #define ISAPNP_WRITE_DATA 0xA79
22 #endif
23 
24 #define ISAPNP_READPORT 0x00
25 #define ISAPNP_SERIALISOLATION 0x01
26 #define ISAPNP_CONFIGCONTROL 0x02
27 #define ISAPNP_WAKE 0x03
28 #define ISAPNP_RESOURCEDATA 0x04
29 #define ISAPNP_STATUS 0x05
30 #define ISAPNP_CARDSELECTNUMBER 0x06
31 #define ISAPNP_LOGICALDEVICENUMBER 0x07
32 
33 #define ISAPNP_ACTIVATE 0x30
34 #define ISAPNP_IORANGECHECK 0x31
35 
36 #define ISAPNP_MEMBASE(n) (0x40 + ((n) * 8))
37 #define ISAPNP_MEMCONTROL(n) (0x42 + ((n) * 8))
38 #define    MEMORY_UPPER_LIMIT 0x01
39 #define    MEMORY_USE_8_BIT_DECODER 0x00
40 #define    MEMORY_USE_16_BIT_DECODER 0x02
41 #define    MEMORY_USE_32_BIT_DECODER 0x06
42 #define ISAPNP_MEMLIMIT(n) (0x43 + ((n) * 8))
43 #define ISAPNP_IOBASE(n) (0x60 + ((n)*2))
44 #define ISAPNP_IRQNO(n) (0x70 + ((n)*2))
45 #define ISAPNP_IRQTYPE(n) (0x71 + ((n) * 2))
46 #define    IRQTYPE_LOW_LEVEL 0x01
47 #define    IRQTYPE_HIGH_EDGE 0x02
48 #define ISAPNP_DMACHANNEL(n) (0x74 + (n))
49 #define ISAPNP_MEMBASE32(n) ((n) == 0 ? 0x76 : (0x70 + (n) * 16))
50 #define ISAPNP_MEMCONTROL32(n) ((n) == 0 ? 0x7A : (0x74 + (n) * 16))
51 #define ISAPNP_MEMLIMIT32(n) ((n) == 0 ? 0x7B : (0x75 + (n) * 16))
52 
53 #define ISAPNP_CONFIG_RESET (1 << 0)
54 #define ISAPNP_CONFIG_WAIT_FOR_KEY (1 << 1)
55 #define ISAPNP_CONFIG_RESET_CSN (1 << 2)
56 
57 #define ISAPNP_LFSR_SEED 0x6A
58 
59 #define ISAPNP_IS_SMALL_TAG(t) (!((t) & 0x80))
60 #define ISAPNP_SMALL_TAG_NAME(t) (((t) >> 3) & 0xF)
61 #define ISAPNP_SMALL_TAG_LEN(t) (((t) & 0x7))
62 #define ISAPNP_TAG_PNPVERNO 0x01
63 #define ISAPNP_TAG_LOGDEVID 0x02
64 #define ISAPNP_TAG_COMPATDEVID 0x03
65 #define ISAPNP_TAG_IRQ 0x04
66 #define ISAPNP_TAG_DMA 0x05
67 #define ISAPNP_TAG_STARTDEP 0x06
68 #define ISAPNP_TAG_ENDDEP 0x07
69 #define ISAPNP_TAG_IOPORT 0x08
70 #define ISAPNP_TAG_FIXEDIO 0x09
71 #define ISAPNP_TAG_END 0x0F
72 
73 #define ISAPNP_IS_LARGE_TAG(t) (((t) & 0x80))
74 #define ISAPNP_LARGE_TAG_NAME(t) (t)
75 #define ISAPNP_TAG_MEMRANGE 0x81
76 #define    MEMRANGE_16_BIT_MEMORY_MASK (0x10 | 0x08)
77 #define       MEMRANGE_32_BIT_MEMORY_ONLY 0x18
78 #define ISAPNP_TAG_ANSISTR 0x82
79 #define ISAPNP_TAG_UNICODESTR 0x83
80 #define ISAPNP_TAG_MEM32RANGE 0x85
81 #define ISAPNP_TAG_FIXEDMEM32RANGE 0x86
82 
83 #define RANGE_LENGTH_TO_LENGTH(RangeLength) ((~(RangeLength) + 1) & 0xFFFFFF)
84 #define LENGTH_TO_RANGE_LENGTH(Length) (~(Length) + 1)
85 
86 #include <pshpack1.h>
87 
88 typedef struct _ISAPNP_IDENTIFIER
89 {
90     USHORT VendorId;
91     USHORT ProdId;
92     ULONG Serial;
93     UCHAR Checksum;
94 } ISAPNP_IDENTIFIER, *PISAPNP_IDENTIFIER;
95 
96 typedef struct _ISAPNP_LOGDEVID
97 {
98     USHORT VendorId;
99     USHORT ProdId;
100     USHORT Flags;
101 } ISAPNP_LOGDEVID, *PISAPNP_LOGDEVID;
102 
103 typedef struct _ISAPNP_COMPATID
104 {
105     USHORT VendorId;
106     USHORT ProdId;
107 } ISAPNP_COMPATID, *PISAPNP_COMPATID;
108 
109 typedef struct _ISAPNP_IO_DESCRIPTION
110 {
111     UCHAR Information;
112     USHORT Minimum;
113     USHORT Maximum;
114     UCHAR Alignment;
115     UCHAR Length;
116 } ISAPNP_IO_DESCRIPTION, *PISAPNP_IO_DESCRIPTION;
117 
118 typedef struct _ISAPNP_FIXED_IO_DESCRIPTION
119 {
120     USHORT IoBase;
121     UCHAR Length;
122 } ISAPNP_FIXED_IO_DESCRIPTION, *PISAPNP_FIXED_IO_DESCRIPTION;
123 
124 typedef struct _ISAPNP_IRQ_DESCRIPTION
125 {
126     USHORT Mask;
127     UCHAR Information;
128 } ISAPNP_IRQ_DESCRIPTION, *PISAPNP_IRQ_DESCRIPTION;
129 
130 typedef struct _ISAPNP_DMA_DESCRIPTION
131 {
132     UCHAR Mask;
133     UCHAR Information;
134 } ISAPNP_DMA_DESCRIPTION, *PISAPNP_DMA_DESCRIPTION;
135 
136 typedef struct _ISAPNP_MEMRANGE_DESCRIPTION
137 {
138     UCHAR Information;
139     USHORT Minimum;
140     USHORT Maximum;
141     USHORT Alignment;
142     USHORT Length;
143 } ISAPNP_MEMRANGE_DESCRIPTION, *PISAPNP_MEMRANGE_DESCRIPTION;
144 
145 typedef struct _ISAPNP_MEMRANGE32_DESCRIPTION
146 {
147     UCHAR Information;
148     ULONG Minimum;
149     ULONG Maximum;
150     ULONG Alignment;
151     ULONG Length;
152 } ISAPNP_MEMRANGE32_DESCRIPTION, *PISAPNP_MEMRANGE32_DESCRIPTION;
153 
154 typedef struct _ISAPNP_FIXEDMEMRANGE_DESCRIPTION
155 {
156     UCHAR Information;
157     ULONG MemoryBase;
158     ULONG Length;
159 } ISAPNP_FIXEDMEMRANGE_DESCRIPTION, *PISAPNP_FIXEDMEMRANGE_DESCRIPTION;
160 
161 #include <poppack.h>
162 
163 #ifdef __cplusplus
164 }
165 #endif
166