source: ISPProgrammer/ISPprog/CfgMgr.pas

Last change on this file was 363, checked in by chronos, 12 years ago
  • Added: Package ISPProgrammer for in-system programming of various chips. Supports Dallas ISP protocol, Presto, Rabbit RFU and some others Atmel devices.
File size: 11.0 KB
Line 
1unit CfgMgr;
2
3{$MODE Delphi}
4
5interface
6
7uses
8 LCLIntf{$IFDEF Windows}, Windows{$ENDIF};
9
10{$IFDEF Windows}
11const
12// Flags controlling what is included in the device information set built
13// by SetupDiGetClassDevs
14 DIGCF_DEFAULT = $00000001; // only valid with DIGCF_DEVICEINTERFACE
15 DIGCF_PRESENT = $00000002;
16 DIGCF_ALLCLASSES = $00000004;
17 DIGCF_PROFILE = $00000008;
18 DIGCF_DEVICEINTERFACE = $00000010;
19
20// Device registry property codes
21// (Codes marked as read-only (R) may only be used for
22// SetupDiGetDeviceRegistryProperty)
23 SPDRP_DEVICEDESC = $00000000; // DeviceDesc (R/W)
24 SPDRP_HARDWAREID = $00000001; // HardwareID (R/W)
25 SPDRP_COMPATIBLEIDS = $00000002; // CompatibleIDs (R/W)
26 SPDRP_UNUSED0 = $00000003; // unused
27 SPDRP_SERVICE = $00000004; // Service (R/W)
28 SPDRP_UNUSED1 = $00000005; // unused
29 SPDRP_UNUSED2 = $00000006; // unused
30 SPDRP_CLASS = $00000007; // Class (R--tied to ClassGUID)
31 SPDRP_CLASSGUID = $00000008; // ClassGUID (R/W)
32 SPDRP_DRIVER = $00000009; // Driver (R/W)
33 SPDRP_CONFIGFLAGS = $0000000A; // ConfigFlags (R/W)
34 SPDRP_MFG = $0000000B; // Mfg (R/W)
35 SPDRP_FRIENDLYNAME = $0000000C; // FriendlyName (R/W)
36 SPDRP_LOCATION_INFORMATION = $0000000D; // LocationInformation (R/W)
37 SPDRP_PHYSICAL_DEVICE_OBJECT_NAME = $0000000E; // PhysicalDeviceObjectName (R)
38 SPDRP_CAPABILITIES = $0000000F; // Capabilities (R)
39 SPDRP_UI_NUMBER = $00000010; // UiNumber (R)
40 SPDRP_UPPERFILTERS = $00000011; // UpperFilters (R/W)
41 SPDRP_LOWERFILTERS = $00000012; // LowerFilters (R/W)
42 SPDRP_BUSTYPEGUID = $00000013; // BusTypeGUID (R)
43 SPDRP_LEGACYBUSTYPE = $00000014; // LegacyBusType (R)
44 SPDRP_BUSNUMBER = $00000015; // BusNumber (R)
45 SPDRP_ENUMERATOR_NAME = $00000016; // Enumerator Name (R)
46 SPDRP_SECURITY = $00000017; // Security (R/W, binary form)
47 SPDRP_SECURITY_SDS = $00000018; // Security (W, SDS form)
48 SPDRP_DEVTYPE = $00000019; // Device Type (R/W)
49 SPDRP_EXCLUSIVE = $0000001A; // Device is exclusive-access (R/W)
50 SPDRP_CHARACTERISTICS = $0000001B; // Device Characteristics (R/W)
51 SPDRP_ADDRESS = $0000001C; // Device Address (R)
52 SPDRP_UI_NUMBER_DESC_FORMAT = $0000001E; // UiNumberDescFormat (R/W)
53 SPDRP_MAXIMUM_PROPERTY = $0000001F; // Upper bound on ordinals
54
55//
56// Configuration Manager return status codes
57//
58 CR_SUCCESS = $00000000;
59 CR_DEFAULT = $00000001;
60 CR_OUT_OF_MEMORY = $00000002;
61 CR_INVALID_POINTER = $00000003;
62 CR_INVALID_FLAG = $00000004;
63 CR_INVALID_DEVNODE = $00000005;
64 CR_INVALID_DEVINST = CR_INVALID_DEVNODE;
65 CR_INVALID_RES_DES = $00000006;
66 CR_INVALID_LOG_CONF = $00000007;
67 CR_INVALID_ARBITRATOR = $00000008;
68 CR_INVALID_NODELIST = $00000009;
69 CR_DEVNODE_HAS_REQS = $0000000A;
70 CR_DEVINST_HAS_REQS = CR_DEVNODE_HAS_REQS;
71 CR_INVALID_RESOURCEID = $0000000B;
72 CR_DLVXD_NOT_FOUND = $0000000C; // WIN 95 ONLY
73 CR_NO_SUCH_DEVNODE = $0000000D;
74 CR_NO_SUCH_DEVINST = CR_NO_SUCH_DEVNODE;
75 CR_NO_MORE_LOG_CONF = $0000000E;
76 CR_NO_MORE_RES_DES = $0000000F;
77 CR_ALREADY_SUCH_DEVNODE = $00000010;
78 CR_ALREADY_SUCH_DEVINST = CR_ALREADY_SUCH_DEVNODE;
79 CR_INVALID_RANGE_LIST = $00000011;
80 CR_INVALID_RANGE = $00000012;
81 CR_FAILURE = $00000013;
82 CR_NO_SUCH_LOGICAL_DEV = $00000014;
83 CR_CREATE_BLOCKED = $00000015;
84 CR_NOT_SYSTEM_VM = $00000016; // WIN 95 ONLY
85 CR_REMOVE_VETOED = $00000017;
86 CR_APM_VETOED = $00000018;
87 CR_INVALID_LOAD_TYPE = $00000019;
88 CR_BUFFER_SMALL = $0000001A;
89 CR_NO_ARBITRATOR = $0000001B;
90 CR_NO_REGISTRY_HANDLE = $0000001C;
91 CR_REGISTRY_ERROR = $0000001D;
92 CR_INVALID_DEVICE_ID = $0000001E;
93 CR_INVALID_DATA = $0000001F;
94 CR_INVALID_API = $00000020;
95 CR_DEVLOADER_NOT_READY = $00000021;
96 CR_NEED_RESTART = $00000022;
97 CR_NO_MORE_HW_PROFILES = $00000023;
98 CR_DEVICE_NOT_THERE = $00000024;
99 CR_NO_SUCH_VALUE = $00000025;
100 CR_WRONG_TYPE = $00000026;
101 CR_INVALID_PRIORITY = $00000027;
102 CR_NOT_DISABLEABLE = $00000028;
103 CR_FREE_RESOURCES = $00000029;
104 CR_QUERY_VETOED = $0000002A;
105 CR_CANT_SHARE_IRQ = $0000002B;
106 CR_NO_DEPENDENT = $0000002C;
107 CR_SAME_RESOURCES = $0000002D;
108 CR_NO_SUCH_REGISTRY_KEY = $0000002E;
109 CR_INVALID_MACHINENAME = $0000002F; // NT ONLY
110 CR_REMOTE_COMM_FAILURE = $00000030; // NT ONLY
111 CR_MACHINE_UNAVAILABLE = $00000031; // NT ONLY
112 CR_NO_CM_SERVICES = $00000032; // NT ONLY
113 CR_ACCESS_DENIED = $00000033; // NT ONLY
114 CR_CALL_NOT_IMPLEMENTED = $00000034;
115 CR_INVALID_PROPERTY = $00000035;
116 CR_DEVICE_INTERFACE_ACTIVE = $00000036;
117 CR_NO_SUCH_DEVICE_INTERFACE = $00000037;
118 CR_INVALID_REFERENCE_STRING = $00000038;
119 CR_INVALID_CONFLICT_LIST = $00000039;
120 CR_INVALID_INDEX = $0000003A;
121 CR_INVALID_STRUCTURE_SIZE = $0000003B;
122 NUM_CR_RESULTS = $0000003C;
123
124//
125// Logical Config Flags (specified in call to CM_Get_First_Log_Conf
126//
127 BASIC_LOG_CONF = $00000000; // Specifies the req list.
128 FILTERED_LOG_CONF = $00000001; // Specifies the filtered req list.
129 ALLOC_LOG_CONF = $00000002; // Specifies the Alloc Element.
130 BOOT_LOG_CONF = $00000003; // Specifies the RM Alloc Element.
131 FORCED_LOG_CONF = $00000004; // Specifies the Forced Log Conf
132 OVERRIDE_LOG_CONF = $00000005; // Specifies the Override req list.
133 NUM_LOG_CONF = $00000006; // Number of Log Conf type
134 LOG_CONF_BITS = $00000007; // The bits of the log conf type.
135
136//
137// Resource types
138//
139 ResType_All = $00000000; // Return all resource types
140 ResType_None = $00000000; // Arbitration always succeeded
141 ResType_Mem = $00000001; // Physical address resource
142 ResType_IO = $00000002; // Physical I/O address resource
143 ResType_DMA = $00000003; // DMA channels resource
144 ResType_IRQ = $00000004; // IRQ resource
145 ResType_DoNotUse = $00000005; // Used as spacer to sync subsequent ResTypes w/NT
146 ResType_BusNumber = $00000006; // bus number resource
147 ResType_MAX = $00000006; // Maximum known (arbitrated) ResType
148 ResType_Ignored_Bit = $00008000; // Ignore this resource
149 ResType_ClassSpecific = $0000FFFF; // class-specific resource
150 ResType_Reserved = $00008000; // reserved for internal use
151 ResType_DevicePrivate = $00008001; // device private data
152 ResType_PcCardConfig = $00008002; // PC Card configuration data
153 ResType_MfCardConfig = $00008003; // MF Card configuration data
154
155
156type
157 HDEVINFO = DWORD;
158 SP_DEVINFO_DATA = packed record
159 cbSize:DWORD;
160 ClassGuid:TGUID;
161 DevInst:DWORD;
162 Reserved:pointer;
163 end;
164 PSP_DEVINFO_DATA = ^SP_DEVINFO_DATA;
165 DEVINST = DWORD;
166 PDEVINST = ^DEVINST;
167 CONFIGRET = DWORD;
168 LOG_CONF = DWORD;
169 PLOG_CONF = ^LOG_CONF;
170 RES_DES = DWORD;
171 PRES_DES = ^RES_DES;
172 RESOURCEID = ULONG;
173 PRESOURCEID = ^RESOURCEID;
174 IO_DES = packed record
175 IOD_Count:DWORD; // number of IO_RANGE structs in IO_RESOURCE
176 IOD_Type:DWORD; // size (in bytes) of IO_RANGE (IOType_Range)
177 IOD_Alloc_Base:LONGLONG; // base of allocated port range
178 IOD_Alloc_End:LONGLONG; // end of allocated port range
179 IOD_DesFlags:DWORD; // flags relating to allocated port range
180 end;
181 PIO_DES = ^IO_DES;
182 IO_RANGE = packed record
183 IOR_Align:LONGLONG; // mask for base alignment
184 IOR_nPorts:DWORD; // number of ports
185 IOR_Min:LONGLONG; // minimum port address
186 IOR_Max:LONGLONG; // maximum port address
187 IOR_RangeFlags:DWORD; // flags for this port range
188 IOR_Alias:LONGLONG; // multiplier that generates aliases for port(s)
189 end;
190 PIO_RANGE = ^IO_RANGE;
191 IO_RESOURCE = packed record
192 IO_Header:IO_DES; // info about I/O port range list
193 IO_Data:array[0..0] of IO_RANGE; // list of I/O port ranges
194 end;
195 PIO_RESOURCE = ^IO_RESOURCE;
196
197function SetupDiGetClassDevs(
198 ClassGuid:PGUID;
199 Enumerator:PChar;
200 hwndParent:HWND;
201 Flags:DWORD):HDEVINFO; stdcall;
202
203function SetupDiEnumDeviceInfo(
204 DeviceInfoSet:HDEVINFO;
205 MemberIndex:DWORD;
206 DeviceInfoData:PSP_DEVINFO_DATA):BOOL; stdcall;
207
208function SetupDiGetDeviceRegistryProperty(
209 DeviceInfoSet:HDEVINFO;
210 DeviceInfoData:PSP_DEVINFO_DATA;
211 PropertyId:DWORD;
212 PropertyRegDataType:PDWORD;
213 PropertyBuffer:pointer;
214 PropertyBufferSize:DWORD;
215 RequiredSize:PDWORD):BOOL; stdcall;
216
217function SetupDiDestroyDeviceInfoList(
218 DeviceInfoSet:HDEVINFO):BOOL; stdcall;
219
220function CM_Get_DevNode_Status(
221 pulStatus:PULONG;
222 pulProblemNumber:PULONG;
223 dnDevInst:DEVINST;
224 ulFlags:ULONG):CONFIGRET; stdcall;
225
226function CM_Get_First_Log_Conf(
227 plcLogConf:PLOG_CONF;
228 dnDevInst:DEVINST;
229 ulFlags:ULONG):CONFIGRET; stdcall;
230
231function CM_Get_Next_Res_Des(
232 prdResDes:PRES_DES;
233 rdResDes:RES_DES;
234 ForResource:RESOURCEID;
235 pResourceID:PRESOURCEID;
236 ulFlags:ULONG):CONFIGRET; stdcall;
237
238function CM_Get_Res_Des_Data(
239 rdResDes:RES_DES;
240 Buffer:pointer;
241 BufferLen:ULONG;
242 ulFlags:ULONG):CONFIGRET; stdcall;
243
244function CM_Free_Log_Conf_Handle(
245 lcLogConf:LOG_CONF):CONFIGRET; stdcall;
246
247{$ENDIF}
248
249implementation
250
251{$IFDEF Windows}
252
253const
254 setupapi = 'setupapi.dll';
255 cfgmgr32 = 'cfgmgr32.dll';
256
257function SetupDiGetClassDevs; external setupapi name 'SetupDiGetClassDevsA';
258function SetupDiEnumDeviceInfo; external setupapi name 'SetupDiEnumDeviceInfo';
259function SetupDiGetDeviceRegistryProperty; external setupapi name 'SetupDiGetDeviceRegistryPropertyA';
260function SetupDiDestroyDeviceInfoList; external setupapi name 'SetupDiDestroyDeviceInfoList';
261
262function CM_Get_DevNode_Status; external cfgmgr32 name 'CM_Get_DevNode_Status';
263function CM_Get_First_Log_Conf; external cfgmgr32 name 'CM_Get_First_Log_Conf';
264function CM_Get_Next_Res_Des; external cfgmgr32 name 'CM_Get_Next_Res_Des';
265function CM_Get_Res_Des_Data; external cfgmgr32 name 'CM_Get_Res_Des_Data';
266function CM_Free_Log_Conf_Handle; external cfgmgr32 name 'CM_Free_Log_Conf_Handle';
267
268{$ENDIF}
269
270end.
Note: See TracBrowser for help on using the repository browser.