1 | /* |
---|
2 | * Copyright (c) 1992-1998 Michael A. Cooper. |
---|
3 | * This software may be freely used and distributed provided it is not |
---|
4 | * sold for profit or used in part or in whole for commercial gain |
---|
5 | * without prior written agreement, and the author is credited |
---|
6 | * appropriately. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * $Revision: 1.1.1.3 $ |
---|
11 | */ |
---|
12 | |
---|
13 | #ifndef __sysinfo_defs__ |
---|
14 | #define __sysinfo_defs__ |
---|
15 | |
---|
16 | #include "mconfig.h" |
---|
17 | #include "version.h" |
---|
18 | #include "mcl.h" |
---|
19 | |
---|
20 | #if defined(HAVE_UNAME) |
---|
21 | # include <sys/utsname.h> |
---|
22 | #endif /* HAVE_UNAME */ |
---|
23 | #if defined(HAVE_SYSINFO) |
---|
24 | # include <sys/systeminfo.h> |
---|
25 | #endif /* HAVE_SYSINFO */ |
---|
26 | |
---|
27 | /* |
---|
28 | * nlist information |
---|
29 | */ |
---|
30 | #if defined(HAVE_NLIST) |
---|
31 | # include <fcntl.h> |
---|
32 | # include <nlist.h> |
---|
33 | #if defined(NLIST_TYPE) |
---|
34 | typedef NLIST_TYPE nlist_t; |
---|
35 | #else |
---|
36 | typedef struct nlist nlist_t; |
---|
37 | #endif |
---|
38 | #if !defined(NLIST_FUNC) |
---|
39 | # define NLIST_FUNC nlist |
---|
40 | #endif |
---|
41 | #endif /* HAVE_NLIST */ |
---|
42 | |
---|
43 | /* |
---|
44 | * KVM Address type for KVMget(). |
---|
45 | * Should always match 2nd argument type for kvm_read(3) |
---|
46 | */ |
---|
47 | #if defined(KVMADDR_T) |
---|
48 | typedef KVMADDR_T KVMaddr_t; |
---|
49 | #else |
---|
50 | typedef u_long KVMaddr_t; |
---|
51 | #endif |
---|
52 | |
---|
53 | /* |
---|
54 | * Internal type for large values |
---|
55 | */ |
---|
56 | #if !defined(SYSINFO_LARGE_T) |
---|
57 | # define SYSINFO_LARGE_T u_long |
---|
58 | #endif |
---|
59 | typedef SYSINFO_LARGE_T Large_t; |
---|
60 | |
---|
61 | #if defined(NEED_KVM) |
---|
62 | # include "kvm.h" |
---|
63 | #else |
---|
64 | #if defined(HAVE_KVM) |
---|
65 | # include <kvm.h> |
---|
66 | #endif /* HAVE_KVM */ |
---|
67 | #endif /* NEED_KVM */ |
---|
68 | |
---|
69 | /* |
---|
70 | * File containing our CPU model name. Overrides all other methods |
---|
71 | * for determing model name. |
---|
72 | */ |
---|
73 | #if !defined(MODELFILE) |
---|
74 | # define MODELFILE "/etc/sysmodel" |
---|
75 | #endif |
---|
76 | |
---|
77 | /* |
---|
78 | * System call failure value |
---|
79 | */ |
---|
80 | #if !defined(SYSFAIL) |
---|
81 | # define SYSFAIL -1 |
---|
82 | #endif |
---|
83 | |
---|
84 | /* |
---|
85 | * SysInfo Message types |
---|
86 | */ |
---|
87 | #define SIM_INFO 0x01 /* Normal INFOmation */ |
---|
88 | #define SIM_WARN 0x02 /* Warnings */ |
---|
89 | #define SIM_GERR 0x04 /* General errors */ |
---|
90 | #define SIM_CERR 0x10 /* Critical errors */ |
---|
91 | #define SIM_DBG 0x20 /* Debugging */ |
---|
92 | #define SIM_UNKN 0x40 /* Things that are unknown 2 SysInfo */ |
---|
93 | #define SIM_DEFAULT (SIM_INFO|SIM_WARN|SIM_CERR) |
---|
94 | /* Default SIM output */ |
---|
95 | #define SIM_ALL (SIM_INFO|SIM_WARN|SIM_GERR|SIM_CERR|SIM_UNKN) |
---|
96 | /* Everything, but DBG */ |
---|
97 | /* |
---|
98 | * SysInfo Message flags |
---|
99 | * Must not conflict with SIM_* defines above! |
---|
100 | */ |
---|
101 | #define SIM_NONL 0x1000 /* Don't add newline to output */ |
---|
102 | #define SIM_NOLBL 0x2000 /* Don't print "sysinfo: *ERROR:" */ |
---|
103 | |
---|
104 | #if !defined(MAXHOSTNAMLEN) |
---|
105 | # define MAXHOSTNAMLEN 256 |
---|
106 | #endif |
---|
107 | |
---|
108 | #define MHERTZ 1000000 /* MegaHertz */ |
---|
109 | #define BYTES ((Large_t)1) /* Bytes */ |
---|
110 | #define KBYTES ((Large_t)1024) /* Kilobytes */ |
---|
111 | #define MBYTES ((Large_t)1048576) /* Megabytes */ |
---|
112 | #define GBYTES ((Large_t)1073741824) /* Gigabytes */ |
---|
113 | |
---|
114 | /* |
---|
115 | * Misc macros |
---|
116 | */ |
---|
117 | #define EQ(a,b) (a && b && strcasecmp(a,b)==0) |
---|
118 | #define EQN(a,b,n) (a && b && strncasecmp(a,b,n)==0) |
---|
119 | #define ARG(s) ((s) ? s : "<null>") |
---|
120 | #define PRTS(s) ( ( s && *s ) ? s : "" ) |
---|
121 | |
---|
122 | /* |
---|
123 | * CheckNlist() breaks in a variety of ways on |
---|
124 | * various OS's. |
---|
125 | */ |
---|
126 | #if !defined(BROKEN_NLIST_CHECK) |
---|
127 | # define CheckNlist(p) _CheckNlist(p) |
---|
128 | #else |
---|
129 | # define CheckNlist(p) 0 |
---|
130 | #endif |
---|
131 | |
---|
132 | /* |
---|
133 | * Get nlist n_name |
---|
134 | */ |
---|
135 | #if defined(__MACH__) |
---|
136 | # define GetNlName(N) ((N).n_un.n_name) |
---|
137 | # define GetNlNamePtr(N) ((N)->n_un.n_name) |
---|
138 | #else |
---|
139 | # define GetNlName(N) ((N).n_name) |
---|
140 | # define GetNlNamePtr(N) ((N)->n_name) |
---|
141 | #endif /* __MACH__ */ |
---|
142 | |
---|
143 | /* |
---|
144 | * Conversion macros |
---|
145 | */ |
---|
146 | #define bytes_to_gbytes(N) ( (float) N / (float) GBYTES ) |
---|
147 | #define bytes_to_mbytes(N) ( (float) N / (float) MBYTES ) |
---|
148 | #define bytes_to_kbytes(N) ( (float) (N / (float) KBYTES) ) |
---|
149 | #define mbytes_to_bytes(N) ( (float) ( (float) N * (float) MBYTES ) ) |
---|
150 | #define kbytes_to_mbytes(N) ( (float) ( (float) N / (float) KBYTES ) ) |
---|
151 | #define kbytes_to_gbytes(N) ( (float) ( (float) N / (float) MBYTES ) ) |
---|
152 | #define mbytes_to_gbytes(N) ( (float) ( (float) N / (float) KBYTES ) ) |
---|
153 | #define nsect_to_bytes(N,S) ( S ? ( (( (float) N) / (float) \ |
---|
154 | (1024 / S)) * (float) KBYTES) : 0 ) |
---|
155 | #define nsect_to_mbytes(N,S) ( S ? ( (( (float) N) / (float) \ |
---|
156 | (1024 / S)) / (float) KBYTES) : 0 ) |
---|
157 | |
---|
158 | /* |
---|
159 | * Are flags f set in b? |
---|
160 | */ |
---|
161 | #define FLAGS_ON(b,f) ((b != 0) && (b & f)) |
---|
162 | #define FLAGS_OFF(b,f) ((b == 0) || ((b != 0) && !(b & f))) |
---|
163 | |
---|
164 | /* |
---|
165 | * KVM Data Type |
---|
166 | */ |
---|
167 | #define KDT_DATA 0 /* Data buffer */ |
---|
168 | #define KDT_STRING 1 /* NULL terminated string */ |
---|
169 | |
---|
170 | /* |
---|
171 | * Format Types |
---|
172 | */ |
---|
173 | #define FT_PRETTY 1 /* Normal pretty output */ |
---|
174 | #define FT_REPORT 2 /* Report output */ |
---|
175 | #define FormatType_t int |
---|
176 | |
---|
177 | /* |
---|
178 | * Message Levels |
---|
179 | */ |
---|
180 | #define L_GENERAL 0x0001 /* General verbosity */ |
---|
181 | #define L_BRIEF 0x0002 /* Brief */ |
---|
182 | #define L_TERSE 0x0004 /* Briefest */ |
---|
183 | #define L_DESC 0x0010 /* Description info */ |
---|
184 | #define L_CONFIG 0x0020 /* Configuratin info */ |
---|
185 | #define L_ALL (L_GENERAL|L_DESC|L_CONFIG) |
---|
186 | /* |
---|
187 | * Verbosity macros |
---|
188 | */ |
---|
189 | #define VL_BRIEF (MsgLevel & L_BRIEF) |
---|
190 | #define VL_TERSE (MsgLevel & L_TERSE) |
---|
191 | #define VL_GENERAL (MsgLevel & L_GENERAL) |
---|
192 | #define VL_DESC (MsgLevel & L_DESC) |
---|
193 | #define VL_CONFIG (MsgLevel & L_CONFIG) |
---|
194 | #define VL_ALL (MsgLevel == L_ALL) |
---|
195 | |
---|
196 | /* |
---|
197 | * Debug macro |
---|
198 | */ |
---|
199 | #define Debug FLAGS_ON(MsgClassFlags, SIM_DBG) |
---|
200 | |
---|
201 | /* |
---|
202 | * Definetion Options |
---|
203 | */ |
---|
204 | #define DO_REGEX 0x0001 /* Perform regex match */ |
---|
205 | |
---|
206 | /* |
---|
207 | * Definetion List names |
---|
208 | */ |
---|
209 | #define DL_SYSMODEL "SysModel" /* System Models */ |
---|
210 | #define DL_SUBSYSMODEL "SubSysModel" /* Sub System Models */ |
---|
211 | #define DL_SYSCONF "SysConf" /* System Configuration */ |
---|
212 | #define DL_KARCH "KArch" /* Kernel Architectures */ |
---|
213 | #define DL_CPU "CPU" /* CPU types */ |
---|
214 | #define DL_OBP "OBP" /* Open Boot Prom info */ |
---|
215 | #define DL_VPD "VPD" /* Vital Product Data */ |
---|
216 | #define DL_NETTYPE "NetType" /* Network Types */ |
---|
217 | #define DL_CATEGORY "Category" /* Categorys */ |
---|
218 | #define DL_PART "Part" /* Part info */ |
---|
219 | #define DL_TAPEINFO "TapeInfo" /* Tape info */ |
---|
220 | #define DL_KERNEL "Kernel" /* Kernel Variable */ |
---|
221 | #define DL_SCSI_DTYPE "SCSIdtype" /* SCSI Device Types */ |
---|
222 | #define DL_SCSI_FLAGS "SCSIflags" /* SCSI Flags */ |
---|
223 | #define DL_CDSPEED "CDspeed" /* CD Speeds */ |
---|
224 | #define DL_DOSPARTTYPES "DosPartTypes" /* DOS Partition Types */ |
---|
225 | |
---|
226 | /* |
---|
227 | * Report names |
---|
228 | */ |
---|
229 | #define R_NAME "name" /* Name description */ |
---|
230 | #define R_DESC "desc" /* Description info */ |
---|
231 | #define R_PART "part" /* Partition info */ |
---|
232 | #define R_TOTALDISK "totaldisk" /* Total disk capacity */ |
---|
233 | |
---|
234 | /* |
---|
235 | * Class Names |
---|
236 | */ |
---|
237 | #define CN_GENERAL "General" |
---|
238 | #define CN_KERNEL "Kernel" |
---|
239 | #define CN_SYSCONF "SysConf" |
---|
240 | #define CN_DEVICE "Device" |
---|
241 | |
---|
242 | /* |
---|
243 | * Types |
---|
244 | */ |
---|
245 | typedef void * Opaque_t; /* Hide type */ |
---|
246 | typedef int OBPnodeid_t; /* OBP node ID type */ |
---|
247 | |
---|
248 | /* |
---|
249 | * Name list |
---|
250 | */ |
---|
251 | struct _namelist { |
---|
252 | char *nl_name; |
---|
253 | struct _namelist *nl_next; |
---|
254 | }; |
---|
255 | typedef struct _namelist namelist_t; |
---|
256 | |
---|
257 | /* |
---|
258 | * Platform Specific Interface |
---|
259 | */ |
---|
260 | typedef struct { |
---|
261 | char *(*Get)(); |
---|
262 | } PSI_t; |
---|
263 | |
---|
264 | /* |
---|
265 | * List Info type |
---|
266 | */ |
---|
267 | struct _ListInfo { |
---|
268 | int IntKey; /* Int key */ |
---|
269 | char *Name; /* Keyword name */ |
---|
270 | char *Desc; /* Description */ |
---|
271 | void (*List)(); /* List function */ |
---|
272 | }; |
---|
273 | typedef struct _ListInfo ListInfo_t; |
---|
274 | |
---|
275 | /* |
---|
276 | * Class Information |
---|
277 | */ |
---|
278 | typedef struct { |
---|
279 | char *Name; /* Class name */ |
---|
280 | void (*Show)(); /* Show function */ |
---|
281 | void (*List)(); /* List arguments function */ |
---|
282 | char *Label; /* It's label/description */ |
---|
283 | char *Banner; /* Banner */ |
---|
284 | int Enabled; /* Is enabled or not */ |
---|
285 | } ClassInfo_t; |
---|
286 | |
---|
287 | /* |
---|
288 | * Show Information |
---|
289 | */ |
---|
290 | typedef struct { |
---|
291 | char *Name; /* Name */ |
---|
292 | char *Label; /* Label/description */ |
---|
293 | char *(*Get)(); /* Get value function */ |
---|
294 | int Enabled; /* Show this item? */ |
---|
295 | } ShowInfo_t; |
---|
296 | |
---|
297 | /* |
---|
298 | * Device description |
---|
299 | */ |
---|
300 | struct _DevDesc { |
---|
301 | char *Label; /* Label of description */ |
---|
302 | char *Desc; /* Description */ |
---|
303 | int Flags; /* Is primary description */ |
---|
304 | struct _DevDesc *Next; /* Pointer to next entry */ |
---|
305 | }; |
---|
306 | typedef struct _DevDesc DevDesc_t; |
---|
307 | /* |
---|
308 | * Description Action |
---|
309 | */ |
---|
310 | #define DA_APPEND 0x01 /* Append entry */ |
---|
311 | #define DA_INSERT 0x02 /* Insert entry */ |
---|
312 | #define DA_PRIME 0x10 /* Indicate primary */ |
---|
313 | |
---|
314 | /* |
---|
315 | * Main Device information |
---|
316 | * |
---|
317 | * Used after device info has been obtained |
---|
318 | */ |
---|
319 | struct _DevInfo { |
---|
320 | char *Name; /* Name (e.g. cgtwo0) */ |
---|
321 | char *Driver; /* Driver Name (e.g. cgtwo) */ |
---|
322 | char **Aliases; /* Alias Names */ |
---|
323 | char *AltName; /* Alt name */ |
---|
324 | char **Files; /* Device files */ |
---|
325 | int Type; /* Device type (eg DT_TAPE) */ |
---|
326 | int ClassType; /* Class type (eg SCSI,IPI) */ |
---|
327 | char *Vendor; /* Hardware Vendor */ |
---|
328 | char *Model; /* Model */ |
---|
329 | char *ModelDesc; /* eg SCSI, 4.0GB, etc. */ |
---|
330 | char *Serial; /* Serial Number */ |
---|
331 | char *Revision; /* Revision Info */ |
---|
332 | DevDesc_t *DescList; /* Device Description */ |
---|
333 | int Unit; /* Unit number */ |
---|
334 | int Addr; /* Address */ |
---|
335 | int Prio; /* Priority */ |
---|
336 | int Vec; /* Vector */ |
---|
337 | int NodeID; /* ID of this node */ |
---|
338 | char *MasterName; /* Name of master */ |
---|
339 | void *DevSpec; /* Device specific info */ |
---|
340 | void *OSdata; /* Data from OS */ |
---|
341 | struct _DevInfo *Master; /* Device controller */ |
---|
342 | struct _DevInfo *Slaves; /* Devices on this device */ |
---|
343 | struct _DevInfo *Next; /* Pointer to next device */ |
---|
344 | }; |
---|
345 | typedef struct _DevInfo DevInfo_t; |
---|
346 | |
---|
347 | /* |
---|
348 | * Device types (DevInfo_t.Type) |
---|
349 | */ |
---|
350 | #define DT_NONE 1 /* Sort of ignore */ |
---|
351 | #define DTN_NONE "none" |
---|
352 | #define DT_PSEUDO 2 /* Pseudo Device */ |
---|
353 | #define DTN_PSEUDO "pseudo" |
---|
354 | #define DT_DRIVER 3 /* Device Driver */ |
---|
355 | #define DTN_DRIVER "driver" |
---|
356 | #define DT_GENERIC 4 /* Generic Device */ |
---|
357 | #define DTN_GENERIC "generic" |
---|
358 | #define DT_DEVICE 5 /* Real Device */ |
---|
359 | #define DTN_DEVICE "device" |
---|
360 | #define DT_DISKDRIVE 6 /* Disk Drive */ |
---|
361 | #define DTN_DISKDRIVE "diskdrive" |
---|
362 | #define DT_DISKCTLR 7 /* Disk Controller */ |
---|
363 | #define DTN_DISKCTLR "diskctlr" |
---|
364 | #define DTN_MSD "msd" |
---|
365 | #define DT_TAPEDRIVE 8 /* Tape Drive */ |
---|
366 | #define DTN_TAPEDRIVE "tapedrive" |
---|
367 | #define DT_TAPECTLR 9 /* Tape Controller */ |
---|
368 | #define DTN_TAPECTLR "tapectlr" |
---|
369 | #define DT_FRAMEBUFFER 10 /* Frame Buffer */ |
---|
370 | #define DTN_FRAMEBUFFER "framebuffer" |
---|
371 | #define DTN_FB "fb" |
---|
372 | #define DTN_VID "vid" |
---|
373 | #define DT_GFXACCEL 11 /* Graphics Accelerator */ |
---|
374 | #define DTN_GFXACCEL "gfxaccel" /* Not the same as DT_FRAME* */ |
---|
375 | #define DT_NETIF 12 /* Network Interface */ |
---|
376 | #define DTN_NETIF "netif" |
---|
377 | #define DTN_NET "net" |
---|
378 | #define DT_BUS 13 /* System Bus */ |
---|
379 | #define DTN_BUS "bus" |
---|
380 | #define DT_BRIDGE 14 /* System Bus Bridge */ |
---|
381 | #define DTN_BRIDGE "bridge" |
---|
382 | #define DT_CONTROLLER 15 /* Generic Controller */ |
---|
383 | #define DTN_CONTROLLER "ctlr" |
---|
384 | #define DT_CPU 16 /* CPU */ |
---|
385 | #define DTN_CPU "cpu" |
---|
386 | #define DT_MEMORY 17 /* Memory */ |
---|
387 | #define DTN_MEMORY "memory" |
---|
388 | #define DTN_MEM "mem" |
---|
389 | #define DT_KEYBOARD 18 /* Keyboard */ |
---|
390 | #define DTN_KEYBOARD "keyboard" |
---|
391 | #define DTN_KEY "key" |
---|
392 | #define DT_CDROM 19 /* CD-ROM */ |
---|
393 | #define DTN_CDROM "cdrom" |
---|
394 | #define DT_SERIAL 20 /* Serial */ |
---|
395 | #define DTN_SERIAL "serial" |
---|
396 | #define DTN_COM "com" |
---|
397 | #define DT_PARALLEL 21 /* Parallel */ |
---|
398 | #define DTN_PARALLEL "parallel" |
---|
399 | #define DTN_PRT "prt" |
---|
400 | #define DT_CARD 22 /* Generic Card */ |
---|
401 | #define DTN_CARD "card" |
---|
402 | #define DT_AUDIO 23 /* Audio */ |
---|
403 | #define DTN_AUDIO "audio" |
---|
404 | #define DT_MFC 24 /* Multi Function Card */ |
---|
405 | #define DTN_MFC "mfc" |
---|
406 | #define DT_POINTER 25 /* Pointer (mouse, etc) */ |
---|
407 | #define DTN_POINTER "pointer" |
---|
408 | #define DTN_PTR "ptr" |
---|
409 | #define DTN_MOUSE "mouse" |
---|
410 | #define DT_MONITOR 26 /* Video Monitor */ |
---|
411 | #define DTN_MONITOR "monitor" |
---|
412 | #define DT_FLOPPY 27 /* Floppy Disk Drive */ |
---|
413 | #define DTN_FLOPPY "floppy" |
---|
414 | #define DT_FLOPPYCTLR 28 /* Floppy Disk Controller */ |
---|
415 | #define DTN_FLOPPYCTLR "floppyctlr" |
---|
416 | #define DT_PRINTER 29 /* Printer */ |
---|
417 | #define DTN_PRINTER "printer" |
---|
418 | #define DT_WORM 30 /* WORM */ |
---|
419 | #define DTN_WORM "WORM" |
---|
420 | #define DT_SCANNER 31 /* Scanner */ |
---|
421 | #define DTN_SCANNER "scanner" |
---|
422 | #define DT_CONSOLE 32 /* Console */ |
---|
423 | #define DTN_CONSOLE "console" |
---|
424 | |
---|
425 | /* |
---|
426 | * Class Type - Classify devices into sub types according to their DevType. |
---|
427 | * For DT_DISK there is CT_SCSI, CT_IDE, etc. |
---|
428 | * For DT_NETIF there MIGHT be CT_ETHER, CT_FDDI, etc. |
---|
429 | */ |
---|
430 | #define MAX_CLASS_DEVTYPES 10 /* Max number of DevTypes list |
---|
431 | in ClassType->DevTypes */ |
---|
432 | typedef struct { |
---|
433 | int DevTypes[MAX_CLASS_DEVTYPES];/* DevType List */ |
---|
434 | int Type; /* ClassType */ |
---|
435 | char *Name; /* Type Name */ |
---|
436 | char *Desc; /* Description */ |
---|
437 | int (*Probe)(); /* Probe function */ |
---|
438 | } ClassType_t; |
---|
439 | |
---|
440 | /* |
---|
441 | * Class Types (DevInfo_t.ClassType) |
---|
442 | * Numeric value must be unique to each class |
---|
443 | */ |
---|
444 | /* ClassTypes for DT_DISKDRIVE and DT_DISKCTLR */ |
---|
445 | #define CT_SCSI 1 |
---|
446 | #define CT_SCSI_S "SCSI" |
---|
447 | #define CT_IPI 2 |
---|
448 | #define CT_IPI_S "IPI" |
---|
449 | #define CT_SMD 3 |
---|
450 | #define CT_SMD_S "SMD" |
---|
451 | #define CT_ATA 4 |
---|
452 | #define CT_ATA_S "ATA" |
---|
453 | #define CT_IDE_S "IDE" |
---|
454 | /* ClassTypes for DT_BUS */ |
---|
455 | #define CT_PCI 20 |
---|
456 | #define CT_PCI_S "PCI" |
---|
457 | #define CT_ISA 21 |
---|
458 | #define CT_ISA_S "ISA" |
---|
459 | #define CT_PNPISA 22 |
---|
460 | #define CT_PNPISA_S "PNPISA" |
---|
461 | #define CT_EISA 23 |
---|
462 | #define CT_EISA_S "EISA" |
---|
463 | #define CT_SBUS 24 |
---|
464 | #define CT_SBUS_S "SBus" |
---|
465 | #define CT_MCA 25 |
---|
466 | #define CT_MCA_S "MCA" |
---|
467 | /* ClassTypes for DT_NETIF */ |
---|
468 | #define CT_ETHER10M 40 |
---|
469 | #define CT_ETHER10M_S "ether" |
---|
470 | #define CT_ETHER100M 41 |
---|
471 | #define CT_ETHER100M_S "ether100m" |
---|
472 | #define CT_ETHER1G 42 |
---|
473 | #define CT_ETHER1G_S "ether1g" |
---|
474 | #define CT_FDDI 43 |
---|
475 | #define CT_FDDI_S "FDDI" |
---|
476 | #define CT_ATM 44 |
---|
477 | #define CT_ATM_S "ATM" |
---|
478 | #define CT_TOKEN 45 |
---|
479 | #define CT_TOKEN_S "token" |
---|
480 | #define CT_HIPPI 46 |
---|
481 | #define CT_HIPPI_S "HIPPI" |
---|
482 | #define CT_ISDN 47 |
---|
483 | #define CT_ISDN_S "ISDN" |
---|
484 | /* ClassTypes for DT_MONITOR */ |
---|
485 | #define CT_RGBCOLOR 60 |
---|
486 | #define CT_RGBCOLOR_S "RGB" |
---|
487 | #define CT_NONRGBCOLOR 61 |
---|
488 | #define CT_NONRGBCOLOR_S "NONRGB" |
---|
489 | #define CT_MONO 62 |
---|
490 | #define CT_MONO_S "Mono" |
---|
491 | |
---|
492 | /* |
---|
493 | * Disk type |
---|
494 | */ |
---|
495 | #define DKT_GENERIC 1 /* Generic disk */ |
---|
496 | #define DKT_CDROM 2 /* CD-ROM */ |
---|
497 | |
---|
498 | /* |
---|
499 | * Disk Partition information. |
---|
500 | */ |
---|
501 | struct _DiskPart { |
---|
502 | char *Title; /* Title of what this Part is */ |
---|
503 | char *Name; /* Partition name */ |
---|
504 | char *Type; /* Type of partition */ |
---|
505 | int NumType; /* Numeric val for type */ |
---|
506 | char *Usage; /* Usage information */ |
---|
507 | Large_t StartSect; /* Starting sector */ |
---|
508 | Large_t NumSect; /* Number of sectors */ |
---|
509 | struct _DiskPart *Next; /* Pointer to next DiskPart_t */ |
---|
510 | }; |
---|
511 | typedef struct _DiskPart DiskPart_t; |
---|
512 | |
---|
513 | /* |
---|
514 | * Values for DiskDrive_t->DataType |
---|
515 | */ |
---|
516 | #define DK_DTYPE_HW "HW" /* Hardware */ |
---|
517 | #define DK_DTYPE_OS "OS" /* OS */ |
---|
518 | |
---|
519 | /* |
---|
520 | * Disk Drive specific data |
---|
521 | */ |
---|
522 | struct _DiskDrive { |
---|
523 | char *DataType; /* HW, OS */ |
---|
524 | char *Label; /* Disk label */ |
---|
525 | int Unit; /* Unit number */ |
---|
526 | int Slave; /* Slave number */ |
---|
527 | /* Cylinders */ |
---|
528 | u_long DataCyl; /* # (usable) data cylinders */ |
---|
529 | u_long PhyCyl; /* # physical cylinders */ |
---|
530 | u_long AltCyl; /* # alternate cylinders */ |
---|
531 | u_long CylSkew; /* Cylinder Skew */ |
---|
532 | u_long APC; /* Alternates / Cyl (SCSI) */ |
---|
533 | /* Tracks (Heads) */ |
---|
534 | u_long Tracks; /* # Tracks */ |
---|
535 | u_long AltTracksPerZone;/* # Alt Tracks / zone */ |
---|
536 | u_long AltTracksPerVol;/* # alternate Tracks / volume */ |
---|
537 | u_long TrackSkew; /* Track Skew */ |
---|
538 | /* Sectors */ |
---|
539 | u_long Sect; /* # usable sectors / Track */ |
---|
540 | u_long SecSize; /* Size of Sector (bytes) */ |
---|
541 | u_long PhySect; /* # physical sectors / Track */ |
---|
542 | u_long AltSectPerZone;/* # Alternate Sectors / Zone */ |
---|
543 | u_long SectGap; /* Gap length between sectors */ |
---|
544 | /* Floppy Related */ |
---|
545 | u_long StepsPerTrack; /* Steps per track */ |
---|
546 | /* General Misc */ |
---|
547 | u_long RPM; /* Revolutions Per Minute */ |
---|
548 | u_long IntrLv; /* Interleave factor */ |
---|
549 | u_long PROMRev; /* PROM Revision */ |
---|
550 | /* SysInfo Misc */ |
---|
551 | float Size; /* Size of disk (MB) */ |
---|
552 | int Flags; /* Info flags */ |
---|
553 | DevInfo_t *Ctlr; /* Controller disk is on */ |
---|
554 | struct _DiskPart *DiskPart; /* Partition information */ |
---|
555 | }; |
---|
556 | typedef struct _DiskDrive DiskDrive_t; |
---|
557 | |
---|
558 | /* |
---|
559 | * DiskDriveData_t contains multiple DiskDrive_t's because the actual |
---|
560 | * hardware data may differ from what the OS uses. For instance in |
---|
561 | * x86 UNIX land, the OS may be installed inside of a DOS partition. |
---|
562 | * In this case, the OS may think the disk is "600MB" when in fact it's |
---|
563 | * actually installed in a 600MB partition on a 4GB disk. |
---|
564 | */ |
---|
565 | typedef struct { |
---|
566 | DiskDrive_t *HWdata; /* The actual hardware Drive data */ |
---|
567 | DiskDrive_t *OSdata; /* The OS's view of the Drive */ |
---|
568 | } DiskDriveData_t; |
---|
569 | |
---|
570 | /* |
---|
571 | * Disk Flags (DiskDrive_t.Flags) |
---|
572 | */ |
---|
573 | #define DF_HEXUNIT 0x01 /* Unit is prt 3 hex digits */ |
---|
574 | |
---|
575 | /* |
---|
576 | * Generic Name/Value table |
---|
577 | */ |
---|
578 | typedef struct { |
---|
579 | int value; /* Value field */ |
---|
580 | char *name; /* Corresponding name */ |
---|
581 | char *valuestr; /* Value string field */ |
---|
582 | } NameTab_t; |
---|
583 | |
---|
584 | /* |
---|
585 | * Conditions for matching criteria |
---|
586 | */ |
---|
587 | struct _Condition { |
---|
588 | char *Key; /* Key word */ |
---|
589 | char *StrVal; /* String Value */ |
---|
590 | int IntVal; /* Int Value */ |
---|
591 | int Matches; /* Matches? */ |
---|
592 | int Flags; /* Flags */ |
---|
593 | struct _Condition *Next; /* Next */ |
---|
594 | }; |
---|
595 | typedef struct _Condition Condition_t; |
---|
596 | |
---|
597 | #define CONFL_SETONLY 0x01 /* Entry only used for set vars */ |
---|
598 | |
---|
599 | /* |
---|
600 | * Definetion information |
---|
601 | */ |
---|
602 | struct _Define { |
---|
603 | char *KeyStr; /* Key string */ |
---|
604 | long KeyNum; /* Key numeric */ |
---|
605 | char *ValStr1; /* Value string 1 */ |
---|
606 | char *ValStr2; /* Value string 2 */ |
---|
607 | char *ValStr3; /* Value string 3 */ |
---|
608 | char *ValStr4; /* Value string 4 */ |
---|
609 | char *ValStr5; /* Value string 5 */ |
---|
610 | Condition_t *Conditions; /* Matching conditions */ |
---|
611 | struct _Define *Next; /* Next member */ |
---|
612 | }; |
---|
613 | typedef struct _Define Define_t; |
---|
614 | |
---|
615 | /* |
---|
616 | * Definetion List |
---|
617 | */ |
---|
618 | struct _DefineList { |
---|
619 | char *Name; /* Name of list */ |
---|
620 | Define_t *Defines; /* Definetion list */ |
---|
621 | struct _DefineList *Next; /* Next member */ |
---|
622 | }; |
---|
623 | typedef struct _DefineList DefineList_t; |
---|
624 | |
---|
625 | /* |
---|
626 | * Generic Key/Value table |
---|
627 | */ |
---|
628 | typedef struct { |
---|
629 | char *Key; /* Corresponding name */ |
---|
630 | long Lvalue; /* Long value field */ |
---|
631 | char *Svalue; /* Value string field */ |
---|
632 | } KeyTab_t; |
---|
633 | |
---|
634 | /* |
---|
635 | * FrameBuffer specific data |
---|
636 | */ |
---|
637 | typedef struct { |
---|
638 | int Height; /* Height (in pixels) */ |
---|
639 | int Width; /* Width (in pixels) */ |
---|
640 | int Depth; /* Depth (bits/pixel) */ |
---|
641 | u_long Size; /* Total size (in bytes) */ |
---|
642 | u_long VMSize; /* Video memory (in bytes) */ |
---|
643 | int CMSize; /* Color Map Size (#entries) */ |
---|
644 | } FrameBuffer_t; |
---|
645 | |
---|
646 | /* |
---|
647 | * Monitor specific data (DT_MONITOR) |
---|
648 | */ |
---|
649 | typedef struct { |
---|
650 | int MaxHorSize; /* Max Horizontal (cm) */ |
---|
651 | int MaxVerSize; /* Max Vertical (cm) */ |
---|
652 | char **Resolutions; /* Supported Resolutions */ |
---|
653 | } Monitor_t; |
---|
654 | |
---|
655 | /* |
---|
656 | * Network Interface specific data |
---|
657 | */ |
---|
658 | struct _netif { |
---|
659 | char *TypeName; /* Name of address type */ |
---|
660 | char *HostAddr; /* Host address */ |
---|
661 | char *HostName; /* Host name */ |
---|
662 | char *MACaddr; /* Current MAC address */ |
---|
663 | char *MACname; /* Current MAC name */ |
---|
664 | char *FacMACaddr; /* Factory MAC address */ |
---|
665 | char *FacMACname; /* Factory MAC name */ |
---|
666 | char *NetAddr; /* Network address */ |
---|
667 | char *NetName; /* Network name */ |
---|
668 | struct _netif *Next; /* Pointer to next element */ |
---|
669 | }; |
---|
670 | typedef struct _netif NetIF_t; |
---|
671 | |
---|
672 | /* |
---|
673 | * Address family table |
---|
674 | */ |
---|
675 | typedef struct { |
---|
676 | int Type; /* Type value */ |
---|
677 | char *Name; /* Name value */ |
---|
678 | NetIF_t *(*GetNetIF)(); /* Function to get netif */ |
---|
679 | } AddrFamily_t; |
---|
680 | |
---|
681 | /* |
---|
682 | * Basic device data |
---|
683 | * |
---|
684 | * Used when searching for initial list of devices |
---|
685 | */ |
---|
686 | typedef struct { |
---|
687 | char *DevName; /* Name of device (no unit) */ |
---|
688 | char **DevAliases; /* Dev aliases */ |
---|
689 | int DevUnit; /* Device specific unit # */ |
---|
690 | int DevType; /* If we know the DevType_t */ |
---|
691 | int Slave; /* Slave number */ |
---|
692 | dev_t DevNum; /* Device number */ |
---|
693 | char *CtlrName; /* Name of Controller */ |
---|
694 | int CtlrUnit; /* Controller # */ |
---|
695 | DevInfo_t *CtlrDevInfo; /* Ctlr's DevInfo ptr */ |
---|
696 | int Flags; /* DevData Device flags */ |
---|
697 | int OSflags; /* Flags passed from OS */ |
---|
698 | int NodeID; /* ID of this node */ |
---|
699 | DevInfo_t *OSDevInfo; /* OS provided DevInfo */ |
---|
700 | } DevData_t; |
---|
701 | |
---|
702 | /* |
---|
703 | * Flags for DevData_t.Flags |
---|
704 | */ |
---|
705 | #define DD_MAYBE_ALIVE 0x01 /* Device may be alive */ |
---|
706 | #define DD_IS_ALIVE 0x02 /* Device is alive */ |
---|
707 | #define DD_IS_ROOT 0x04 /* Is root dev node */ |
---|
708 | |
---|
709 | /* |
---|
710 | * Device Type information |
---|
711 | */ |
---|
712 | typedef struct { |
---|
713 | int Type; /* Device type */ |
---|
714 | char *Name; /* Type Name */ |
---|
715 | char *Desc; /* Description */ |
---|
716 | void (*Print)(); /* Print function */ |
---|
717 | DevInfo_t *(*Probe)(); /* Probe function */ |
---|
718 | int Enabled; /* Enable this entry */ |
---|
719 | } DevType_t; |
---|
720 | |
---|
721 | /* |
---|
722 | * Device definetion structure |
---|
723 | */ |
---|
724 | struct _DevDefine { |
---|
725 | char *Name; /* Name of device */ |
---|
726 | char **Aliases; /* List of name aliases */ |
---|
727 | int Ident; /* Device identifier */ |
---|
728 | int Type; /* Device type */ |
---|
729 | int ClassType; /* ClassType */ |
---|
730 | DevInfo_t *(*Probe)(); /* Probe device function */ |
---|
731 | char *Vendor; /* Hardware Vendor */ |
---|
732 | char *Model; /* Model */ |
---|
733 | char *Desc; /* Description */ |
---|
734 | char *File; /* Device file name */ |
---|
735 | int Flags; /* Flags */ |
---|
736 | long DevFlags; /* Device specific flags */ |
---|
737 | struct _DevDefine *Next; /* Next member */ |
---|
738 | }; |
---|
739 | typedef struct _DevDefine DevDefine_t; |
---|
740 | |
---|
741 | /* |
---|
742 | * Flags for DevDefine_t.Flags |
---|
743 | */ |
---|
744 | #define DDT_LENCMP 0x0001 /* Compare by length */ |
---|
745 | #define DDT_NOUNIT 0x0002 /* No unit number */ |
---|
746 | #define DDT_UNITNUM 0x0004 /* Force unit number */ |
---|
747 | #define DDT_ASSUNIT 0x0010 /* Assign unit number */ |
---|
748 | #define DDT_ZOMBIE 0x0020 /* Doesn't have to be ALIVE */ |
---|
749 | #define DDT_DEFINFO 0x0040 /* Use default definetions */ |
---|
750 | #define DDT_ISALIAS 0x0100 /* We're mk'ing an alias */ |
---|
751 | |
---|
752 | /* |
---|
753 | * Data needed for Probe routines |
---|
754 | */ |
---|
755 | struct _ProbeData { |
---|
756 | /* For argument passing */ |
---|
757 | char *DevName; /* Device's Name (vx0) */ |
---|
758 | char **AliasNames; /* Aliases for DevName */ |
---|
759 | char *DevFile; /* Name of device file */ |
---|
760 | int FileDesc; /* File Descriptor */ |
---|
761 | DevData_t *DevData; /* Device Data */ |
---|
762 | DevDefine_t *DevDefine; /* Device Definetions */ |
---|
763 | void *Opaque; /* Opaque data */ |
---|
764 | DevInfo_t *CtlrDevInfo; /* Ctlr's DevInfo if we know */ |
---|
765 | DevInfo_t *UseDevInfo; /* DevInfo we can use */ |
---|
766 | /* Returned/set data */ |
---|
767 | DevInfo_t *RetDevInfo; /* Returned Data */ |
---|
768 | }; |
---|
769 | typedef struct _ProbeData ProbeData_t; |
---|
770 | |
---|
771 | /* |
---|
772 | * DevFind query |
---|
773 | */ |
---|
774 | typedef struct { |
---|
775 | /* These are the conditions to search for */ |
---|
776 | char *NodeName; /* Name of node to find */ |
---|
777 | OBPnodeid_t NodeID; /* Node ID to find */ |
---|
778 | char *Serial; /* Serial # to find */ |
---|
779 | int DevType; /* DevType */ |
---|
780 | int ClassType; /* ClassType */ |
---|
781 | int Unit; /* Unit # */ |
---|
782 | /* We operate on these */ |
---|
783 | DevInfo_t *Tree; /* Device Tree */ |
---|
784 | int Expr; /* DFE_* Expression Flags */ |
---|
785 | char Reason[128]; /* List of what matched */ |
---|
786 | } DevFind_t; |
---|
787 | |
---|
788 | /* |
---|
789 | * DevFind Expression commands (DevFind_t.Expr) |
---|
790 | */ |
---|
791 | #define DFE_OR 0 /* OR all checks */ |
---|
792 | #define DFE_AND 1 /* AND all checks */ |
---|
793 | |
---|
794 | /* |
---|
795 | * Now include the declarations |
---|
796 | */ |
---|
797 | #include "declare.h" |
---|
798 | #include "probe.h" |
---|
799 | |
---|
800 | #endif /* __sysinfo_defs__ */ |
---|