]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/hwinfo/src/hd/hd.h
Kleiner netter neuer Versuch.
[people/teissler/ipfire-2.x.git] / src / hwinfo / src / hd / hd.h
1 #ifndef _HD_H
2 #define _HD_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8
9 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
10 *
11 * libhd data structures
12 *
13 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
14 */
15
16 #define HD_VERSION 10
17
18 /*
19 * debug flags
20 */
21 #define HD_DEB_SHOW_LOG (1 << 0)
22 #define HD_DEB_PROGRESS (1 << 1)
23 #define HD_DEB_CREATION (1 << 2)
24 #define HD_DEB_DRIVER_INFO (1 << 3)
25 #define HD_DEB_PCI (1 << 4)
26 #define HD_DEB_ISAPNP (1 << 5)
27 #define HD_DEB_CDROM (1 << 6)
28 #define HD_DEB_NET (1 << 7)
29 #define HD_DEB_FLOPPY (1 << 8)
30 #define HD_DEB_MISC (1 << 9)
31 #define HD_DEB_SERIAL (1 << 10)
32 #define HD_DEB_MONITOR (1 << 11)
33 #define HD_DEB_CPU (1 << 12)
34 #define HD_DEB_BIOS (1 << 13)
35 #define HD_DEB_MOUSE (1 << 14)
36 #define HD_DEB_IDE (1 << 15)
37 #define HD_DEB_SCSI (1 << 16)
38 #define HD_DEB_USB (1 << 17)
39 #define HD_DEB_ADB (1 << 18)
40 #define HD_DEB_MODEM (1 << 19)
41 #define HD_DEB_PARALLEL (1 << 20)
42 #define HD_DEB_ISA (1 << 21)
43 #define HD_DEB_BOOT (1 << 22)
44 #define HD_DEB_HDDB (1 << 23)
45
46 #include <stdio.h>
47 #include <inttypes.h>
48 #include <termios.h>
49 #include <sys/types.h>
50
51 /*
52 * libhd's directory
53 */
54 #define HARDWARE_DIR "/var/lib/hardware"
55 #define HARDWARE_UNIQUE_KEYS HARDWARE_DIR "/unique-keys"
56
57 /**
58 * \defgroup idmacros Id macros
59 * Macros to handle device and vendor ids.
60 *
61 * Example: to check if an id is a pci id and get its value,
62 * do something like this:
63 * \code
64 * if(ID_TAG(hd->dev) == TAG_PCI) {
65 * pci_id = ID_VALUE(hd->dev)
66 * }
67 * \endcode
68 *@{
69 */
70
71 #define TAG_PCI 1 /**< PCI ids. */
72 #define TAG_EISA 2 /**< EISA ids (monitors, ISA-PnP, modems, mice etc). */
73 #define TAG_USB 3 /**< USB ids. */
74 #define TAG_SPECIAL 4 /**< Internally used ids. */
75 #define TAG_PCMCIA 5 /**< PCMCIA ids. */
76
77 /**
78 * Get the real id value.
79 */
80 #define ID_VALUE(id) ((id) & 0xffff)
81
82 /**
83 * Get the tag value.
84 */
85 #define ID_TAG(id) (((id) >> 16) & 0xf)
86
87 /**
88 * Combine tag and id value.
89 */
90 #define MAKE_ID(tag, id_val) ((tag << 16) | (id_val))
91
92 /*@}*/
93
94 /*
95 * flags to control the probing.
96 */
97 typedef enum probe_feature {
98 pr_memory = 1, pr_pci, pr_isapnp, pr_net, pr_floppy, pr_misc,
99 pr_misc_serial, pr_misc_par, pr_misc_floppy, pr_serial, pr_cpu, pr_bios,
100 pr_monitor, pr_mouse, pr_scsi, pr_usb, pr_usb_mods, pr_adb, pr_modem,
101 pr_modem_usb, pr_parallel, pr_parallel_lp, pr_parallel_zip, pr_isa,
102 pr_isa_isdn, pr_isdn, pr_kbd, pr_prom, pr_sbus, pr_int, pr_braille,
103 pr_braille_alva, pr_braille_fhp, pr_braille_ht, pr_ignx11, pr_sys,
104 pr_bios_vbe, pr_isapnp_old, pr_isapnp_new, pr_isapnp_mod, pr_braille_baum,
105 pr_manual, pr_fb, pr_veth, pr_pppoe, pr_scan, pr_pcmcia, pr_fork,
106 pr_parallel_imm, pr_s390, pr_cpuemu, pr_sysfs, pr_s390disks, pr_udev,
107 pr_block, pr_block_cdrom, pr_block_part, pr_edd, pr_edd_mod, pr_bios_ddc,
108 pr_bios_fb, pr_bios_mode, pr_input, pr_block_mods, pr_bios_vesa,
109 pr_cpuemu_debug, pr_scsi_noserial, pr_wlan,
110 pr_max, pr_lxrc, pr_dsl, pr_default, pr_all /* pr_all must be last */
111 } hd_probe_feature_t;
112
113 /*
114 * list types for hd_list()
115 *
116 * if you want to modify this: cf. manual.c::hw_items[]
117 *
118 * Note: hw_tv _must_ be < hw_display!
119 */
120 typedef enum hw_item {
121 hw_sys = 1, hw_cpu, hw_keyboard, hw_braille, hw_mouse, hw_joystick,
122 hw_printer, hw_scanner, hw_chipcard, hw_monitor, hw_tv, hw_display,
123 hw_framebuffer, hw_camera, hw_sound, hw_storage_ctrl, hw_network_ctrl,
124 hw_isdn, hw_modem, hw_network, hw_disk, hw_partition, hw_cdrom, hw_floppy,
125 hw_manual, hw_usb_ctrl, hw_usb, hw_bios, hw_pci, hw_isapnp, hw_bridge,
126 hw_hub, hw_scsi, hw_ide, hw_memory, hw_dvb, hw_pcmcia, hw_pcmcia_ctrl,
127 hw_ieee1394, hw_ieee1394_ctrl, hw_hotplug, hw_hotplug_ctrl, hw_zip, hw_pppoe,
128 hw_wlan, hw_redasd, hw_dsl, hw_block, hw_tape, hw_vbe, hw_bluetooth,
129 /* append new entries here */
130 hw_unknown, hw_all /* hw_all must be last */
131 } hd_hw_item_t;
132
133 /*
134 * device base classes and bus types
135 *
136 */
137
138 /* base class values (superset of PCI classes) */
139 typedef enum base_classes {
140 /* these *must* match standard PCI class numbers */
141 bc_none, bc_storage, bc_network, bc_display, bc_multimedia,
142 bc_memory, bc_bridge, bc_comm, bc_system, bc_input, bc_docking,
143 bc_processor, bc_serial, bc_wireless, bc_i2o, bc_other = 0xff,
144
145 // add our own classes here (starting at 0x100 as PCI values are 8 bit)
146 bc_monitor = 0x100, bc_internal, bc_modem, bc_isdn, bc_ps2, bc_mouse,
147 bc_storage_device, bc_network_interface, bc_keyboard, bc_printer,
148 bc_hub, bc_braille, bc_scanner, bc_joystick, bc_chipcard, bc_camera,
149 bc_framebuffer, bc_dvb, bc_tv, bc_partition, bc_dsl, bc_bluetooth
150 } hd_base_classes_t;
151
152 /* subclass values of bc_monitor */
153 typedef enum sc_monitor {
154 sc_mon_other, sc_mon_crt, sc_mon_lcd
155 } hd_sc_monitor_t;
156
157 /* subclass values of bc_storage */
158 typedef enum sc_storage {
159 sc_sto_scsi, sc_sto_ide, sc_sto_floppy, sc_sto_ipi, sc_sto_raid,
160 sc_sto_other = 0x80
161 } hd_sc_storage_t;
162
163 /* subclass values of bc_display */
164 typedef enum sc_display {
165 sc_dis_vga, sc_dis_xga, sc_dis_other = 0x80
166 } hd_sc_display_t;
167
168 /* subclass values of bc_framebuffer */
169 typedef enum sc_framebuffer {
170 sc_fb_vesa = 1
171 } hd_sc_framebuffer_t;
172
173 /* subclass values of bc_bridge */
174 typedef enum sc_bridge {
175 sc_bridge_host, sc_bridge_isa, sc_bridge_eisa, sc_bridge_mc,
176 sc_bridge_pci, sc_bridge_pcmcia, sc_bridge_nubus, sc_bridge_cardbus,
177 sc_bridge_other = 0x80
178 } hd_sc_bridge_t;
179
180 /* subclass values of bc_comm */
181 typedef enum sc_comm {
182 sc_com_ser, sc_com_par, sc_com_multi, sc_com_modem, sc_com_other = 0x80
183 } hd_sc_comm_t;
184
185 /* subclass values of bc_system */
186 typedef enum sc_system {
187 sc_sys_pic, sc_sys_dma, sc_sys_timer, sc_sys_rtc, sc_sys_other = 0x80
188 } hd_sc_system_t;
189
190 /* subclass values of bc_input */
191 typedef enum sc_input {
192 sc_inp_keyb, sc_inp_digit, sc_inp_mouse, sc_inp_other = 0x80
193 } hd_sc_input_t;
194
195 /* subclass values of bc_serial */
196 typedef enum sc_serial {
197 sc_ser_fire, sc_ser_access, sc_ser_ssa, sc_ser_usb, sc_ser_fiber,
198 sc_ser_smbus, sc_ser_other = 0x80
199 } hd_sc_serial_t;
200
201 /* internal sub class values (bc_internal) */
202 typedef enum sc_internal {
203 sc_int_none, sc_int_isapnp_if, sc_int_main_mem, sc_int_cpu, sc_int_fpu,
204 sc_int_bios, sc_int_prom, sc_int_sys
205 } hd_sc_internal_t;
206
207 /* subclass values of bc_mouse */
208 typedef enum sc_mouse {
209 sc_mou_ps2, sc_mou_ser, sc_mou_bus, sc_mou_usb, sc_mou_sun,
210 sc_mou_other = 0x80
211 } hd_sc_mouse_t;
212
213 /* subclass values of bc_storage_device */
214 typedef enum sc_std {
215 sc_sdev_disk, sc_sdev_tape, sc_sdev_cdrom, sc_sdev_floppy, sc_sdev_scanner,
216 sc_sdev_other = 0x80
217 } hd_sc_std_t;
218
219 /* subclass values of bc_network_interface */
220 typedef enum sc_net_if {
221 sc_nif_loopback, sc_nif_ethernet, sc_nif_tokenring, sc_nif_fddi,
222 sc_nif_ctc, sc_nif_iucv, sc_nif_hsi, sc_nif_qeth,
223 sc_nif_escon, sc_nif_myrinet, sc_nif_wlan, sc_nif_xp,
224 sc_nif_usb, sc_nif_other = 0x80, sc_nif_sit
225 } hd_sc_net_if_t;
226
227 /* subclass values of bc_multimedia */
228 typedef enum sc_multimedia {
229 sc_multi_video, sc_multi_audio, sc_multi_other
230 } hd_sc_multimedia_t;
231
232 /* subclass values of bc_keyboard */
233 typedef enum sc_keyboard {
234 sc_keyboard_kbd, sc_keyboard_console
235 } hd_sc_keyboard_t;
236
237 /* subclass values of bc_hub */
238 typedef enum sc_hub {
239 sc_hub_other, sc_hub_usb
240 } hd_sc_hub_t;
241
242 /* subclass values of bc_camera */
243 typedef enum sc_camera {
244 sc_camera_webcam, sc_camera_digital
245 } hd_sc_camera_t;
246
247 /* subclass values of bc_modem */
248 typedef enum sc_modem {
249 sc_mod_at, sc_mod_win1, sc_mod_win2, sc_mod_win3, sc_mod_win4
250 } hd_sc_modem_t;
251
252 /* subclass values of bc_dsl */
253 typedef enum sc_dsl {
254 sc_dsl_unknown, sc_dsl_pppoe, sc_dsl_capi, sc_dsl_capiisdn
255 } hd_sc_dsl_t;
256
257 /* prog_if's of sc_ser_usb */
258 typedef enum pif_usb_e {
259 pif_usb_uhci = 0, pif_usb_ohci = 0x10, pif_usb_ehci = 0x20,
260 pif_usb_other = 0x80, pif_usb_device = 0xfe
261 } hd_pif_usb_t;
262
263 /* CD-ROM prog_if values */
264 typedef enum pif_cdrom {
265 pif_cdrom, pif_cdr, pif_cdrw, pif_dvd, pif_dvdr, pif_dvdram
266 } hd_pif_cdrom_t ;
267
268 /* S/390 disk prog_if values */
269 typedef enum pif_s390disk {
270 pif_scsi, pif_dasd, pif_dasd_fba
271 } hd_pif_s390disk_t;
272
273 /* bus type values similar to PCI bridge subclasses */
274 typedef enum bus_types {
275 bus_none, bus_isa, bus_eisa, bus_mc, bus_pci, bus_pcmcia, bus_nubus,
276 bus_cardbus, bus_other,
277
278 /* outside the range of the PCI values */
279 bus_ps2 = 0x80, bus_serial, bus_parallel, bus_floppy, bus_scsi, bus_ide, bus_usb,
280 bus_adb, bus_raid, bus_sbus, bus_i2o, bus_vio, bus_ccw, bus_iucv
281 } hd_bus_types_t;
282
283 /**
284 * Hardware status.
285 * The status is stored in /var/lib/hardware/unique-keys/ and used
286 * to detect if the hardware is new and has to be configured by some
287 * hardware %config tool.
288 */
289 typedef struct {
290 /**
291 * Status fields are invalid.
292 */
293 unsigned invalid:1;
294 /**
295 * Hardware should be reconfigured.
296 * Either \ref hd_status_t::status_yes or \ref hd_status_t::status_no.
297 * A hardware must be reconfigured if it is in state
298 * \ref hd_status_t::available == \ref hd_status_t::status_no and
299 * \ref hd_status_t::needed == \ref hd_status_t::status_yes.
300 * In other words, if a hardware that was
301 * needed to run the system is gone.
302 */
303 unsigned reconfig:3;
304
305 /**
306 * Hardware %config status.
307 * Set to \ref hd_status_t::status_yes if the hardware has been configured, otherwise
308 * \ref hd_status_t::status_no.
309 */
310 unsigned configured:3;
311
312 /**
313 * Hardware availability.
314 * Set to \ref hd_status_t::status_yes if the hardware has been detected or
315 * \ref hd_status_t::status_no if the hardware has not been found. You can set
316 * it to \ref hd_status_t::status_unknown to indicate that this hardware cannot
317 * be automatically detected (say, ISA cards).
318 * \note You can simulate all kinds of hardware on your system by
319 * creating entries in /var/lib/hardware/unique-keys/ that have
320 * \ref hd_status_t::available set to \ref hd_status_t::status_unknown.
321 */
322 unsigned available:3;
323
324 /**
325 * Hardware is needed.
326 * Set to \ref hd_status_t::status_yes if this hardware is really necessary to run
327 * your computer. The effect will be that some hardware %config dialog
328 * is run if the hardware item is not found.
329 * Typical examples are graphics cards and mice.
330 */
331 unsigned needed:3;
332
333 /**
334 * (Internal) original value of \ref available;
335 * This is used to keep track of the original value of the \ref hd_status_t::available
336 * state as it was stored in /var/lib/hardware/unique-keys/. (\ref hd_status_t::available
337 * is automatically updated during the detection process.)
338 */
339 unsigned available_orig:3;
340
341 /**
342 * Hardware is active.
343 */
344 unsigned active:3;
345 } hd_status_t;
346
347 /* hardware config status values */
348 typedef enum {
349 status_no = 1, status_yes, status_unknown, status_new
350 } hd_status_value_t;
351
352 /**
353 * Various types of hotplug devices.
354 */
355 typedef enum {
356 hp_none, /**< Not a hotpluggable %device. */
357 hp_pcmcia, /**< PCMCIA %device. */
358 hp_cardbus, /**< Cardbus %device. */
359 hp_pci, /**< PCI hotplug %device. */
360 hp_usb, /**< USB %device. */
361 hp_ieee1394 /**< IEEE 1394 (FireWire) %device */
362 } hd_hotplug_t;
363
364
365 /**
366 * Holds id/name pairs.
367 * Used for bus, class, vendor, %device and such.
368 */
369 typedef struct {
370 unsigned id; /**< Numeric id. */
371 char *name; /**< Name (if any) that corresponds to \ref hd_id_t::id. */
372 } hd_id_t;
373
374 /**
375 * String list type.
376 * Used whenever we create a list of strings (e.g. file read).
377 */
378 typedef struct s_str_list_t {
379 struct s_str_list_t *next; /**< Link to next member. */
380 char *str; /**< Some string data. */
381 } str_list_t;
382
383
384 typedef struct {
385 unsigned char bitmap[16]; /* large enough for all uses */
386 unsigned bits; /* real bitmap length in bits */
387 unsigned not_empty:1; /* at least 1 bit is set */
388 str_list_t *str; /* interpreted bitmask */
389 } hd_bitmap_t;
390
391
392 /*
393 * for memory areas
394 */
395 typedef struct {
396 unsigned start, size; /* base address & size */
397 unsigned char *data; /* actual data */
398 } memory_range_t;
399
400
401 /*
402 * smp info according to Intel smp spec (ia32)
403 */
404 typedef struct {
405 unsigned ok:1; /* data are valid */
406 unsigned rev; /* MP spec revision */
407 unsigned mpfp; /* MP Floating Pointer struct */
408 unsigned mpconfig_ok:1; /* MP config table valid */
409 unsigned mpconfig; /* MP config table */
410 unsigned mpconfig_size; /* dto, size */
411 unsigned char feature[5]; /* MP feature info */
412 char oem_id[9]; /* oem id */
413 char prod_id[13]; /* product id */
414 unsigned cpus, cpus_en; /* number of cpus & ennabled cpus */
415 } smp_info_t;
416
417
418 /*
419 * vesa bios extensions info
420 */
421 typedef struct vbe_mode_info_s {
422 unsigned number; /* mode number */
423 unsigned attributes; /* mode attributes */
424 unsigned width, height; /* mode size */
425 unsigned bytes_p_line; /* line length */
426 unsigned pixel_size; /* bits per pixel */
427 unsigned fb_start; /* frame buffer start address (if any) */
428 unsigned win_A_start; /* window A start address */
429 unsigned win_A_attr; /* window A attributes */
430 unsigned win_B_start; /* window B start address */
431 unsigned win_B_attr; /* window B attributes */
432 unsigned win_size; /* window size in bytes */
433 unsigned win_gran; /* window granularity in bytes */
434 unsigned pixel_clock; /* maximum pixel clock */
435 } vbe_mode_info_t;
436
437
438 typedef struct {
439 unsigned ok:1; /* data are valid */
440 unsigned version; /* vbe version */
441 unsigned oem_version; /* oem version info */
442 unsigned memory; /* in bytes */
443 unsigned fb_start; /* != 0 if framebuffer is supported */
444 char *oem_name; /* oem name */
445 char *vendor_name; /* vendor name */
446 char *product_name; /* product name */
447 char *product_revision; /* product revision */
448 unsigned modes; /* number of supported video modes */
449 vbe_mode_info_t *mode; /* video mode list */
450 unsigned current_mode; /* current video mode */
451 unsigned char ddc[0x80]; /* ddc monitor info */
452 } vbe_info_t;
453
454
455 /*
456 * Compaq Controller Order EV (CQHORD) definition
457 */
458 typedef struct {
459 unsigned id;
460 unsigned char slot;
461 unsigned char bus;
462 unsigned char devfn;
463 unsigned char misc;
464 } cpq_ctlorder_t;
465
466
467 typedef struct {
468 unsigned ok:1; /* data are valid */
469 unsigned entry; /* entry point */
470 unsigned compaq:1; /* is compaq system */
471 cpq_ctlorder_t cpq_ctrl[32]; /* 32 == MAX_CONTROLLERS */
472 } bios32_info_t;
473
474
475 /*
476 * smbios entries
477 */
478 typedef enum {
479 sm_biosinfo, sm_sysinfo, sm_boardinfo, sm_chassis,
480 sm_processor, sm_memctrl, sm_memmodule, sm_cache,
481 sm_connect, sm_slot, sm_onboard, sm_oem,
482 sm_config, sm_lang, sm_group, sm_eventlog,
483 sm_memarray, sm_memdevice, sm_memerror, sm_memarraymap,
484 sm_memdevicemap, sm_mouse, sm_battery, sm_reset,
485 sm_secure, sm_power, sm_voltage, sm_cool,
486 sm_temperature, sm_current, sm_outofband, sm_bis,
487 sm_boot, sm_mem64error, sm_mandev, sm_mandevcomp,
488 sm_mdtd, sm_inactive = 126, sm_end = 127
489 } hd_smbios_type_t;
490
491
492 /* common part of all smbios_* types */
493 typedef struct {
494 union u_hd_smbios_t *next; /* link to next entry */
495 hd_smbios_type_t type; /* BIOS info type */
496 int data_len; /* formatted section length */
497 unsigned char *data; /* formatted section */
498 str_list_t *strings; /* strings taken from the unformed section */
499 int handle; /* handle, unique 16 bit number */
500 } smbios_any_t;
501
502
503 /* BIOS related information */
504 typedef struct {
505 union u_hd_smbios_t *next;
506 hd_smbios_type_t type;
507 int data_len;
508 unsigned char *data;
509 str_list_t *strings;
510 int handle;
511 char *vendor; /* vendor name */
512 char *version; /* version (free form) */
513 char *date; /* date mm/dd/yyyy (old: yy) */
514 hd_bitmap_t feature; /* BIOS characteristics */
515 unsigned start; /* start address */
516 unsigned rom_size; /* ROM size (in bytes) */
517 } smbios_biosinfo_t;
518
519
520 /* overall system related information */
521 typedef struct {
522 union u_hd_smbios_t *next;
523 hd_smbios_type_t type;
524 int data_len;
525 unsigned char *data;
526 str_list_t *strings;
527 int handle;
528 char *manuf; /* manufacturer */
529 char *product; /* product name */
530 char *version; /* version */
531 char *serial; /* serial number */
532 unsigned char uuid[16]; /* universal unique id; all 0x00: undef, all 0xff: undef but settable */
533 hd_id_t wake_up; /* wake-up type */
534 } smbios_sysinfo_t;
535
536
537 /* motherboard related information */
538 typedef struct {
539 union u_hd_smbios_t *next;
540 hd_smbios_type_t type;
541 int data_len;
542 unsigned char *data;
543 str_list_t *strings;
544 int handle;
545 char *manuf; /* manufacturer */
546 char *product; /* product name */
547 char *version; /* version */
548 char *serial; /* serial number */
549 char *asset; /* asset tag */
550 hd_id_t board_type; /* board type */
551 hd_bitmap_t feature; /* board features */
552 char *location; /* location in chassis */
553 int chassis; /* handle of chassis */
554 int objects_len; /* number of contained objects */
555 int *objects; /* array of object handles */
556 } smbios_boardinfo_t;
557
558
559 /* chassis information */
560 typedef struct {
561 union u_hd_smbios_t *next;
562 hd_smbios_type_t type;
563 int data_len;
564 unsigned char *data;
565 str_list_t *strings;
566 int handle;
567 char *manuf; /* manufacturer */
568 char *version; /* version */
569 char *serial; /* serial number */
570 char *asset; /* asset tag */
571 hd_id_t ch_type; /* chassis type */
572 unsigned lock; /* 1: lock present, 0: not present or unknown */
573 hd_id_t bootup; /* bootup state */
574 hd_id_t power; /* power supply state (at last boot) */
575 hd_id_t thermal; /* thermal state (at last boot) */
576 hd_id_t security; /* security state (at last boot) */
577 unsigned oem; /* OEM-specific information */
578 } smbios_chassis_t;
579
580
581 /* processor information */
582 typedef struct {
583 union u_hd_smbios_t *next;
584 hd_smbios_type_t type;
585 int data_len;
586 unsigned char *data;
587 str_list_t *strings;
588 int handle;
589 char *socket; /* socket */
590 hd_id_t upgrade; /* socket type */
591 char *manuf; /* manufacturer */
592 char *version; /* version */
593 char *serial; /* serial number */
594 char *asset; /* asset tag */
595 char *part; /* part number */
596 hd_id_t pr_type; /* processor type */
597 hd_id_t family; /* processor family */
598 uint64_t cpu_id; /* processor id */
599 unsigned voltage; /* in 0.1 V */
600 unsigned ext_clock; /* MHz */
601 unsigned max_speed; /* MHz */
602 unsigned current_speed; /* MHz */
603 unsigned sock_status; /* socket status (1: populated, 0: empty */
604 hd_id_t cpu_status; /* cpu status */
605 int l1_cache; /* handle of L1 cache */
606 int l2_cache; /* handle of L2 cache */
607 int l3_cache; /* handle of L3 cache */
608 } smbios_processor_t;
609
610
611 /* cache information */
612 typedef struct {
613 union u_hd_smbios_t *next;
614 hd_smbios_type_t type;
615 int data_len;
616 unsigned char *data;
617 str_list_t *strings;
618 int handle;
619 char *socket; /* socket designation */
620 unsigned max_size; /* max cache size in kbytes */
621 unsigned current_size; /* current size in kbytes */
622 unsigned speed; /* cache speed in nanoseconds */
623 hd_id_t mode; /* operational mode */
624 unsigned state; /* 0/1: disabled/enabled */
625 hd_id_t location; /* cache location */
626 unsigned socketed; /* 0/1: not socketed/socketed */
627 unsigned level; /* cache level (0 = L1, 1 = L2, ...) */
628 hd_id_t ecc; /* error correction type */
629 hd_id_t cache_type; /* logical cache type */
630 hd_id_t assoc; /* cache associativity */
631 hd_bitmap_t supp_sram; /* supported SRAM types */
632 hd_bitmap_t sram; /* current SRAM type */
633 } smbios_cache_t;
634
635
636 /* port connector information */
637 typedef struct {
638 union u_hd_smbios_t *next;
639 hd_smbios_type_t type;
640 int data_len;
641 unsigned char *data;
642 str_list_t *strings;
643 int handle;
644 hd_id_t port_type; /* port type */
645 char *i_des; /* internal reference designator */
646 hd_id_t i_type; /* internal connector type */
647 char *x_des; /* external reference designator */
648 hd_id_t x_type; /* external connector type */
649 } smbios_connect_t;
650
651
652 /* system slot information */
653 typedef struct {
654 union u_hd_smbios_t *next;
655 hd_smbios_type_t type;
656 int data_len;
657 unsigned char *data;
658 str_list_t *strings;
659 int handle;
660 char *desig; /* slot designation */
661 hd_id_t slot_type; /* slot type */
662 hd_id_t bus_width; /* data bus width */
663 hd_id_t usage; /* current usage */
664 hd_id_t length; /* slot length */
665 unsigned id; /* slot id */
666 hd_bitmap_t feature; /* slot characteristics */
667 } smbios_slot_t;
668
669
670 /* on board devices information */
671 typedef struct {
672 union u_hd_smbios_t *next;
673 hd_smbios_type_t type;
674 int data_len;
675 unsigned char *data;
676 str_list_t *strings;
677 int handle;
678 unsigned dev_len; /* device list length */
679 struct {
680 char *name; /* device name */
681 hd_id_t type; /* device type */
682 unsigned status; /* 0: disabled, 1: enabled */
683 } *dev; /* device list */
684 } smbios_onboard_t;
685
686
687 /* OEM information */
688 typedef struct {
689 union u_hd_smbios_t *next;
690 hd_smbios_type_t type;
691 int data_len;
692 unsigned char *data;
693 str_list_t *strings;
694 int handle;
695 str_list_t *oem_strings; /* OEM strings */
696 } smbios_oem_t;
697
698
699 /* system config options */
700 typedef struct {
701 union u_hd_smbios_t *next;
702 hd_smbios_type_t type;
703 int data_len;
704 unsigned char *data;
705 str_list_t *strings;
706 int handle;
707 str_list_t *options; /* system config options */
708 } smbios_config_t;
709
710
711 /* language information */
712 typedef struct {
713 union u_hd_smbios_t *next;
714 hd_smbios_type_t type;
715 int data_len;
716 unsigned char *data;
717 str_list_t *strings; /* list of languages */
718 int handle;
719 char *current; /* current language */
720 } smbios_lang_t;
721
722
723 /* group associations */
724 typedef struct {
725 union u_hd_smbios_t *next;
726 hd_smbios_type_t type;
727 int data_len;
728 unsigned char *data;
729 str_list_t *strings;
730 int handle;
731 char *name; /* group name */
732 int items_len; /* number of items in this group */
733 int *item_handles; /* array of item handles */
734 } smbios_group_t;
735
736
737 /* physical memory array (consists of several memory devices) */
738 typedef struct {
739 union u_hd_smbios_t *next;
740 hd_smbios_type_t type;
741 int data_len;
742 unsigned char *data;
743 str_list_t *strings;
744 int handle;
745 hd_id_t location; /* memory device location */
746 hd_id_t use; /* memory usage */
747 hd_id_t ecc; /* ECC types */
748 unsigned max_size; /* maximum memory size in kB */
749 int error_handle; /* points to error info record; 0xfffe: not supported, 0xffff: no error */
750 unsigned slots; /* slots or sockets for this device */
751 } smbios_memarray_t;
752
753
754 /* memory device */
755 typedef struct {
756 union u_hd_smbios_t *next;
757 hd_smbios_type_t type;
758 int data_len;
759 unsigned char *data;
760 str_list_t *strings;
761 int handle;
762 char *location; /* device location */
763 char *bank; /* bank location */
764 char *manuf; /* manufacturer */
765 char *serial; /* serial number */
766 char *asset; /* asset tag */
767 char *part; /* part number */
768 int array_handle; /* memory array this device belongs to */
769 int error_handle; /* points to error info record; 0xfffe: not supported, 0xffff: no error */
770 unsigned width; /* data width in bits */
771 unsigned eccbits; /* ecc bits */
772 unsigned size; /* kB */
773 hd_id_t form; /* form factor */
774 unsigned set; /* 0: does not belong to a set; 1-0xfe: set number; 0xff: unknown */
775 hd_id_t mem_type; /* memory type */
776 hd_bitmap_t type_detail; /* memory type details */
777 unsigned speed; /* in MHz */
778 } smbios_memdevice_t;
779
780
781 /* 32-bit memory error information */
782 typedef struct {
783 union u_hd_smbios_t *next;
784 hd_smbios_type_t type;
785 int data_len;
786 unsigned char *data;
787 str_list_t *strings;
788 int handle;
789 hd_id_t err_type; /* error type memory */
790 hd_id_t granularity; /* memory array or memory partition */
791 hd_id_t operation; /* mem operation causing the error */
792 unsigned syndrome; /* vendor-specific ECC syndrome; 0: unknown */
793 unsigned array_addr; /* fault address rel. to mem array; 0x80000000: unknown */
794 unsigned device_addr; /* fault address rel to mem device; 0x80000000: unknown */
795 unsigned range; /* range, within which the error can be determined; 0x80000000: unknown */
796 } smbios_memerror_t;
797
798
799 /* memory array mapped address */
800 typedef struct {
801 union u_hd_smbios_t *next;
802 hd_smbios_type_t type;
803 int data_len;
804 unsigned char *data;
805 str_list_t *strings;
806 int handle;
807 int array_handle; /* memory array this mapping belongs to */
808 uint64_t start_addr; /* memory range start address */
809 uint64_t end_addr; /* end address */
810 unsigned part_width; /* number of memory devices */
811 } smbios_memarraymap_t;
812
813
814 /* memory device mapped address */
815 typedef struct {
816 union u_hd_smbios_t *next;
817 hd_smbios_type_t type;
818 int data_len;
819 unsigned char *data;
820 str_list_t *strings;
821 int handle;
822 int memdevice_handle; /* memory device handle */
823 int arraymap_handle; /* memory array mapping handle */
824 uint64_t start_addr; /* memory range start address */
825 uint64_t end_addr; /* end address */
826 unsigned row_pos; /* position of the referenced memory device in a row of the address partition */
827 unsigned interleave_pos; /* dto, in an interleave */
828 unsigned interleave_depth; /* number of consecutive rows */
829 } smbios_memdevicemap_t;
830
831
832 /* pointing device (aka 'mouse') information */
833 typedef struct {
834 union u_hd_smbios_t *next;
835 hd_smbios_type_t type;
836 int data_len;
837 unsigned char *data;
838 str_list_t *strings;
839 int handle;
840 hd_id_t mtype; /* mouse type */
841 hd_id_t interface; /* interface type */
842 unsigned buttons; /* number of buttons */
843 } smbios_mouse_t;
844
845
846 /* hardware security */
847 typedef struct {
848 union u_hd_smbios_t *next;
849 hd_smbios_type_t type;
850 int data_len;
851 unsigned char *data;
852 str_list_t *strings;
853 int handle;
854 hd_id_t power; /* power-on password status */
855 hd_id_t keyboard; /* keyboard password status */
856 hd_id_t admin; /* admin password status */
857 hd_id_t reset; /* front panel reset status */
858 } smbios_secure_t;
859
860
861 /* system power controls */
862 typedef struct {
863 union u_hd_smbios_t *next;
864 hd_smbios_type_t type;
865 int data_len;
866 unsigned char *data;
867 str_list_t *strings;
868 int handle;
869 unsigned month; /* next scheduled power-on month */
870 unsigned day; /* dto, day */
871 unsigned hour; /* dto, hour */
872 unsigned minute; /* dto, minute */
873 unsigned second; /* dto, second */
874 } smbios_power_t;
875
876
877 /* 64-bit memory error information */
878 typedef struct {
879 union u_hd_smbios_t *next;
880 hd_smbios_type_t type;
881 int data_len;
882 unsigned char *data;
883 str_list_t *strings;
884 int handle;
885 hd_id_t err_type; /* error type memory */
886 hd_id_t granularity; /* memory array or memory partition */
887 hd_id_t operation; /* mem operation causing the error */
888 unsigned syndrome; /* vendor-specific ECC syndrome; 0: unknown */
889 uint64_t array_addr; /* fault address rel. to mem array; 0x80000000: unknown */
890 uint64_t device_addr; /* fault address rel to mem device; 0x80000000: unknown */
891 unsigned range; /* range, within which the error can be determined; 0x80000000: unknown */
892 } smbios_mem64error_t;
893
894
895 typedef union u_hd_smbios_t {
896 union u_hd_smbios_t *next;
897 smbios_any_t any;
898 smbios_biosinfo_t biosinfo;
899 smbios_sysinfo_t sysinfo;
900 smbios_boardinfo_t boardinfo;
901 smbios_chassis_t chassis;
902 smbios_processor_t processor;
903 smbios_cache_t cache;
904 smbios_connect_t connect;
905 smbios_slot_t slot;
906 smbios_onboard_t onboard;
907 smbios_oem_t oem;
908 smbios_config_t config;
909 smbios_lang_t lang;
910 smbios_group_t group;
911 smbios_memarray_t memarray;
912 smbios_memdevice_t memdevice;
913 smbios_memerror_t memerror;
914 smbios_memarraymap_t memarraymap;
915 smbios_memdevicemap_t memdevicemap;
916 smbios_mouse_t mouse;
917 smbios_secure_t secure;
918 smbios_power_t power;
919 smbios_mem64error_t mem64error;
920 } hd_smbios_t;
921
922
923 /*
924 * udev database info
925 */
926 typedef struct s_udevinfo_t {
927 struct s_udevinfo_t *next;
928 char *sysfs;
929 char *name;
930 str_list_t *links;
931 int type;
932 } hd_udevinfo_t;
933
934
935 /*
936 * sysfs driver info
937 */
938 typedef struct s_sysfsdrv_t {
939 struct s_sysfsdrv_t *next;
940 char *driver;
941 char *device;
942 } hd_sysfsdrv_t;
943
944
945 /*
946 * device number; type is either 0 or 'b' or 'c'.
947 *
948 * range: number of nodes
949 */
950 typedef struct {
951 int type;
952 unsigned major, minor, range;
953 } hd_dev_num_t;
954
955
956 /*
957 * structure holding the (raw) PCI data
958 */
959 typedef struct s_pci_t {
960 struct s_pci_t *next; /* linked list */
961 unsigned data_len; /* the actual length of the data field */
962 unsigned data_ext_len; /* max. accessed config byte; see code */
963 unsigned char data[256]; /* the PCI data */
964 char *log; /* log messages */
965 unsigned flags, /* various info, see enum pci_flags */
966 cmd, /* PCI_COMMAND */
967 hdr_type, /* PCI_HEADER_TYPE */
968 secondary_bus; /* > 0 for PCI & CB bridges */
969 unsigned bus, /* PCI bus #, *nothing* to do with hw_t.bus */
970 slot, func; /* slot & function */
971 unsigned base_class, sub_class, prog_if; /* PCI device classes */
972 unsigned dev, vend, sub_dev, sub_vend, rev; /* vendor & device ids */
973 unsigned irq; /* used irq, if any */
974 uint64_t base_addr[7]; /* I/O or memory base */
975 uint64_t base_len[7]; /* I/O or memory ranges */
976 unsigned addr_flags[7]; /* I/O or memory address flags */
977 uint64_t rom_base_addr; /* memory base for card ROM */
978 uint64_t rom_base_len; /* memory range for card ROM */
979 char *sysfs_id; /* sysfs path */
980 char *sysfs_bus_id; /* sysfs bus id */
981 } pci_t;
982
983 /*
984 * pci related flags cf. (pci_t).flags
985 */
986 typedef enum pci_flags {
987 pci_flag_ok, pci_flag_pm, pci_flag_agp
988 } hd_pci_flags_t;
989
990
991 /*
992 * raw USB data
993 */
994 typedef struct usb_s {
995 struct usb_s *next;
996 unsigned hd_idx;
997 unsigned hd_base_idx;
998 /* see Linux USB docs */
999 str_list_t *c, *d, *e, *i, *p, *s, *t;
1000 struct usb_s *cloned;
1001 int bus, dev_nr, lev, parent, port, count, conns, used_conns, ifdescr;
1002 unsigned speed;
1003 unsigned vendor, device, rev;
1004 char *manufact, *product, *serial;
1005 char *driver;
1006 memory_range_t raw_descr;
1007 int d_cls, d_sub, d_prot;
1008 int i_alt, i_cls, i_sub, i_prot;
1009 unsigned country;
1010 } usb_t;
1011
1012 /*
1013 *structures to hold the (raw) ISA-PnP data
1014 */
1015 typedef struct {
1016 int len;
1017 int type;
1018 unsigned char *data;
1019 } isapnp_res_t;
1020
1021 typedef struct {
1022 int csn;
1023 int log_devs;
1024 unsigned char *serial;
1025 unsigned char *card_regs;
1026 unsigned char (*ldev_regs)[0xd0];
1027 int res_len;
1028 unsigned broken:1; /* mark a broken card */
1029 isapnp_res_t *res;
1030 } isapnp_card_t;
1031
1032 typedef struct {
1033 int read_port;
1034 int cards;
1035 isapnp_card_t *card;
1036 } isapnp_t;
1037
1038 typedef struct {
1039 isapnp_card_t *card;
1040 int dev;
1041 unsigned flags; /* cf. enum isapnp_flags */
1042 unsigned ref:1; /* internally used flag */
1043 } isapnp_dev_t;
1044
1045 /*
1046 * ISA-PnP related flags; cf. (isapnp_dev_t).flags
1047 */
1048 typedef enum isapnp_flags {
1049 isapnp_flag_act
1050 } hd_isapnp_flags_t;
1051
1052
1053 /*
1054 * raw SCSI data
1055 */
1056 typedef struct scsi_s {
1057 struct scsi_s *next;
1058 unsigned deleted:1;
1059 unsigned generic:1;
1060 unsigned fake:1;
1061 char *dev_name;
1062 char *guessed_dev_name;
1063 int generic_dev;
1064 unsigned host, channel, id, lun;
1065 char *vendor, *model, *rev, *type_str, *serial;
1066 int type;
1067 unsigned inode_low;
1068 char *proc_dir, *driver;
1069 unsigned unique;
1070 char *info;
1071 unsigned lgeo_c, lgeo_h, lgeo_s;
1072 unsigned pgeo_c, pgeo_h, pgeo_s;
1073 uint64_t size;
1074 unsigned sec_size;
1075 unsigned cache;
1076 str_list_t *host_info;
1077 char *usb_guid;
1078 unsigned pci_info;
1079 unsigned pci_bus;
1080 unsigned pci_slot;
1081 unsigned pci_func;
1082 uint64_t wwpn;
1083 uint64_t fcp_lun;
1084 char *controller_id;
1085 } scsi_t;
1086
1087
1088 /*
1089 * PROM tree on PPC
1090 */
1091 typedef struct devtree_s {
1092 struct devtree_s *next;
1093 struct devtree_s *parent;
1094 unsigned idx;
1095 char *path, *filename;
1096 unsigned pci:1;
1097 char *name, *model, *device_type, *compatible;
1098 int class_code; /* class : sub_class : prog-if */
1099 int vendor_id, device_id, subvendor_id, subdevice_id;
1100 int revision_id, interrupt;
1101 unsigned char *edid; /* 128 bytes */
1102 } devtree_t;
1103
1104 /*
1105 * Device/CU model numbers for S/390
1106 */
1107 typedef struct ccw_s {
1108 unsigned char lcss;
1109 unsigned char cu_model;
1110 unsigned char dev_model;
1111 } ccw_t;
1112
1113 /*
1114 * special CDROM entry
1115 */
1116 typedef struct cdrom_info_s {
1117 struct cdrom_info_s *next;
1118 char *name;
1119 unsigned speed;
1120 unsigned cdr:1, cdrw:1, dvd:1, dvdr:1, dvdram:1;
1121 unsigned cdrom:1; /* cdrom in drive */
1122 struct {
1123 unsigned ok:1;
1124 char *volume, *publisher, *preparer, *application, *creation_date;
1125 } iso9660;
1126 struct {
1127 unsigned ok:1;
1128 unsigned platform;
1129 char *id_string;
1130 unsigned bootable:1;
1131 unsigned media_type; /* boot emulation type */
1132 unsigned load_address;
1133 unsigned load_count; /* sectors to load */
1134 unsigned start; /* start sector */
1135 unsigned catalog; /* boot catalog start */
1136 struct {
1137 unsigned c, h, s;
1138 unsigned size;
1139 } geo;
1140 char *label;
1141 } el_torito;
1142
1143 } cdrom_info_t;
1144
1145 // note: obsolete, will be removed
1146 typedef struct {
1147 unsigned char block0[512];
1148 } floppy_info_t;
1149
1150 /*
1151 * bios data (ix86)
1152 */
1153 typedef struct {
1154 unsigned apm_supported:1;
1155 unsigned apm_enabled:1;
1156 unsigned apm_ver, apm_subver;
1157 unsigned apm_bios_flags;
1158
1159 unsigned vbe_ver;
1160 unsigned vbe_video_mem;
1161
1162 unsigned ser_port0, ser_port1, ser_port2, ser_port3;
1163 unsigned par_port0, par_port1, par_port2;
1164
1165 /* The id is still in big endian format! */
1166 unsigned is_pnp_bios:1;
1167 unsigned pnp_id;
1168 unsigned lba_support:1;
1169
1170 unsigned low_mem_size;
1171 smp_info_t smp;
1172 vbe_info_t vbe;
1173
1174 unsigned smbios_ver;
1175
1176 struct {
1177 unsigned width;
1178 unsigned height;
1179 char *vendor;
1180 char *name;
1181 } lcd;
1182
1183 struct {
1184 char *vendor;
1185 char *type;
1186 unsigned bus;
1187 unsigned compat_vend;
1188 unsigned compat_dev;
1189 } mouse;
1190
1191 struct {
1192 unsigned ok:1;
1193 unsigned scroll_lock:1;
1194 unsigned num_lock:1;
1195 unsigned caps_lock:1;
1196 } led;
1197
1198 bios32_info_t bios32;
1199
1200 } bios_info_t;
1201
1202
1203 /*
1204 * prom data (ppc, sparc)
1205 */
1206 typedef struct {
1207 unsigned has_color:1;
1208 unsigned color;
1209 } prom_info_t;
1210
1211
1212 /*
1213 * general system data
1214 */
1215 typedef struct {
1216 char *system_type;
1217 char *generation;
1218 char *vendor;
1219 char *model;
1220 char *serial;
1221 char *lang;
1222 } sys_info_t;
1223
1224
1225 /*
1226 * monitor (DDC) data
1227 */
1228 typedef struct {
1229 unsigned manu_year;
1230 unsigned min_vsync, max_vsync; /* vsync range */
1231 unsigned min_hsync, max_hsync; /* hsync range */
1232 char *vendor;
1233 char *name;
1234 char *serial;
1235 } monitor_info_t;
1236
1237
1238 typedef enum cpu_arch {
1239 arch_unknown = 0,
1240 arch_intel,
1241 arch_alpha,
1242 arch_sparc, arch_sparc64,
1243 arch_ppc, arch_ppc64,
1244 arch_68k,
1245 arch_ia64,
1246 arch_s390, arch_s390x,
1247 arch_arm,
1248 arch_mips,
1249 arch_x86_64
1250 } hd_cpu_arch_t;
1251
1252 // ###### drop boot_arch at all?
1253 typedef enum boot_arch {
1254 boot_unknown = 0,
1255 boot_lilo, boot_milo, boot_aboot, boot_silo, boot_ppc, boot_elilo, boot_s390,
1256 boot_mips, boot_grub
1257 } hd_boot_arch_t;
1258
1259 /* special cpu entry */
1260 typedef struct {
1261 enum cpu_arch architecture;
1262 unsigned family; /* axp: cpu variation */
1263 unsigned model; /* axp: cpu revision */
1264 unsigned stepping;
1265 unsigned cache;
1266 unsigned clock;
1267 unsigned units; /* >1 "hyperthreading" */
1268 char *vend_name; /* axp: system type */
1269 char *model_name; /* axp: cpu model */
1270 char *platform; /* x86: NULL */
1271 str_list_t *features; /* x86: flags */
1272 } cpu_info_t;
1273
1274
1275 /*
1276 * enhanced disk data (cf. edd.c)
1277 */
1278 typedef struct {
1279 uint64_t sectors;
1280 struct {
1281 unsigned cyls, heads, sectors;
1282 } edd;
1283 struct {
1284 unsigned cyls, heads, sectors;
1285 } legacy;
1286 unsigned ext_fixed_disk:1;
1287 unsigned ext_lock_eject:1;
1288 unsigned ext_edd:1;
1289 unsigned ext_64bit:1;
1290 unsigned assigned:1;
1291 char *sysfs_id;
1292 unsigned hd_idx;
1293 } edd_info_t;
1294
1295
1296 /*
1297 * database info
1298 */
1299 typedef struct {
1300 unsigned data_len, data_max;
1301 unsigned *data;
1302 unsigned names_len, names_max;
1303 char *names;
1304 } hddb_data_t;
1305
1306 typedef uint32_t hddb_entry_mask_t;
1307
1308 typedef struct hddb_list_s {
1309 hddb_entry_mask_t key_mask;
1310 hddb_entry_mask_t value_mask;
1311 unsigned key;
1312 unsigned value;
1313 } hddb_list_t;
1314
1315 typedef struct {
1316 unsigned list_len, list_max;
1317 hddb_list_t *list;
1318 unsigned ids_len, ids_max;
1319 unsigned *ids;
1320 unsigned strings_len, strings_max;
1321 char *strings;
1322 } hddb2_data_t;
1323
1324 /*
1325 * pci module info
1326 */
1327 typedef struct {
1328 char *module;
1329 unsigned vendor;
1330 unsigned device;
1331 unsigned subvendor;
1332 unsigned subdevice;
1333 unsigned pciclass;
1334 unsigned classmask;
1335 } hddb_pci_t;
1336
1337
1338 /*
1339 * resource types
1340 */
1341 typedef enum resource_types {
1342 res_any, res_phys_mem, res_mem, res_io, res_irq, res_dma, res_monitor,
1343 res_size, res_disk_geo, res_cache, res_baud, res_init_strings, res_pppd_option,
1344 res_framebuffer, res_hwaddr, res_link, res_wlan
1345 } hd_resource_types_t;
1346
1347
1348 /*
1349 * size units (cf. (res_size_t).unit)
1350 */
1351 typedef enum size_units {
1352 size_unit_cm, size_unit_cinch, size_unit_byte, size_unit_sectors,
1353 size_unit_kbyte, size_unit_mbyte, size_unit_gbyte
1354 } hd_size_units_t;
1355
1356 /*
1357 * access types for I/O and memory resources
1358 */
1359 typedef enum access_flags {
1360 acc_unknown, acc_ro, acc_wo, acc_rw /* unknown, read only, write only, read/write */
1361 } hd_access_flags_t;
1362
1363
1364 typedef enum yes_no_flag {
1365 flag_unknown, flag_no, flag_yes /* unknown, no, yes */
1366 } hd_yes_no_flag_t;
1367
1368
1369 typedef enum geo_types {
1370 geo_physical = 0, geo_logical, geo_bios_edd, geo_bios_legacy
1371 } hd_geo_types_t;
1372
1373
1374 /*
1375 * definitions for the various resource types
1376 */
1377 typedef struct {
1378 union u_hd_res_t *next;
1379 enum resource_types type;
1380 } res_any_t;
1381
1382 typedef struct {
1383 union u_hd_res_t *next;
1384 enum resource_types type;
1385 uint64_t base, range;
1386 unsigned
1387 enabled:1, /* 0: disabled, 1 enabled */
1388 access:2, /* enum access_flags */
1389 prefetch:2; /* enum yes_no_flag */
1390 } res_mem_t;
1391
1392 typedef struct {
1393 union u_hd_res_t *next;
1394 enum resource_types type;
1395 uint64_t range;
1396 } res_phys_mem_t;
1397
1398 typedef struct {
1399 union u_hd_res_t *next;
1400 enum resource_types type;
1401 uint64_t base, range;
1402 unsigned
1403 enabled:1, /* 0: disabled, 1 enabled */
1404 access:2; /* enum access_flags */
1405 } res_io_t;
1406
1407 typedef struct {
1408 union u_hd_res_t *next;
1409 enum resource_types type;
1410 unsigned base;
1411 unsigned triggered; /* # of interrupts */
1412 unsigned enabled:1; /* 0: disabled, 1 enabled */
1413 } res_irq_t;
1414
1415 typedef struct {
1416 union u_hd_res_t *next;
1417 enum resource_types type;
1418 unsigned base;
1419 unsigned enabled:1; /* 0: disabled, 1 enabled */
1420 } res_dma_t;
1421
1422 typedef struct {
1423 union u_hd_res_t *next;
1424 enum resource_types type;
1425 enum size_units unit;
1426 uint64_t val1, val2; /* to allow for 2D values */
1427 } res_size_t;
1428
1429 typedef struct {
1430 union u_hd_res_t *next;
1431 enum resource_types type;
1432 unsigned speed;
1433 unsigned bits, stopbits;
1434 char parity; /* n, e, o, s, m */
1435 char handshake; /* -, h, s */
1436 } res_baud_t;
1437
1438 typedef struct {
1439 union u_hd_res_t *next;
1440 enum resource_types type;
1441 unsigned size; /* in kbyte */
1442 } res_cache_t;
1443
1444 typedef struct {
1445 union u_hd_res_t *next;
1446 enum resource_types type;
1447 unsigned cyls, heads, sectors;
1448 uint64_t size;
1449 enum geo_types geotype; /* 0-3: physical/logical/bios edd/bios legacy */
1450 } res_disk_geo_t;
1451
1452 typedef struct {
1453 union u_hd_res_t *next;
1454 enum resource_types type;
1455 unsigned width, height; /* in pixel */
1456 unsigned vfreq; /* in Hz */
1457 unsigned interlaced:1; /* 0/1 */
1458 } res_monitor_t;
1459
1460 typedef struct {
1461 union u_hd_res_t *next;
1462 enum resource_types type;
1463 char *init1;
1464 char *init2;
1465 } res_init_strings_t;
1466
1467 typedef struct {
1468 union u_hd_res_t *next;
1469 enum resource_types type;
1470 char *option;
1471 } res_pppd_option_t;
1472
1473 typedef struct {
1474 union u_hd_res_t *next;
1475 enum resource_types type;
1476 unsigned width, height; /* in pixel */
1477 unsigned bytes_p_line; /* line length in bytes (do not confuse with 'width') */
1478 unsigned colorbits; /* 4, 8, 15, 16, 24, 32 */
1479 unsigned mode; /* mode number for kernel */
1480 } res_framebuffer_t;
1481
1482 typedef struct {
1483 union u_hd_res_t *next;
1484 enum resource_types type;
1485 char *addr;
1486 } res_hwaddr_t;
1487
1488 typedef struct {
1489 union u_hd_res_t *next;
1490 enum resource_types type;
1491 unsigned state:1; /* network link state: 0 - not connected, 1 - connected */
1492 } res_link_t;
1493
1494 /* wlan capabilities */
1495 typedef struct {
1496 union u_hd_res_t *next;
1497 enum resource_types type;
1498 str_list_t *channels;
1499 str_list_t *frequencies; /* in GHz units */
1500 str_list_t *bitrates; /* in Mbps units */
1501 str_list_t *auth_modes; /* open, sharedkey, wpa-psk, wpa-eap, wpa-leap */
1502 str_list_t *enc_modes; /* WEP40, WEP104, WEP128, WEP232, TKIP, CCMP */
1503 } res_wlan_t;
1504
1505 typedef union u_hd_res_t {
1506 union u_hd_res_t *next;
1507 res_any_t any;
1508 res_io_t io;
1509 res_mem_t mem;
1510 res_phys_mem_t phys_mem;
1511 res_irq_t irq;
1512 res_dma_t dma;
1513 res_size_t size;
1514 res_cache_t cache;
1515 res_baud_t baud;
1516 res_disk_geo_t disk_geo;
1517 res_monitor_t monitor;
1518 res_init_strings_t init_strings;
1519 res_pppd_option_t pppd_option;
1520 res_framebuffer_t framebuffer;
1521 res_hwaddr_t hwaddr;
1522 res_link_t link;
1523 res_wlan_t wlan;
1524 } hd_res_t;
1525
1526
1527 /*
1528 * data gathered by the misc module; basically resources from /proc
1529 */
1530 typedef struct {
1531 uint64_t addr, size;
1532 char *dev;
1533 unsigned tag;
1534 } misc_io_t;
1535
1536 typedef struct {
1537 unsigned channel;
1538 char *dev;
1539 unsigned tag;
1540 } misc_dma_t;
1541
1542 typedef struct {
1543 unsigned irq, events;
1544 int devs;
1545 char **dev;
1546 unsigned tag;
1547 } misc_irq_t;
1548
1549 typedef struct {
1550 unsigned io_len, dma_len, irq_len;
1551 misc_io_t *io;
1552 misc_dma_t *dma;
1553 misc_irq_t *irq;
1554 str_list_t *proc_io, *proc_dma, *proc_irq;
1555 } misc_t;
1556
1557 typedef struct s_serial_t {
1558 struct s_serial_t *next;
1559 char *name;
1560 char *device;
1561 unsigned line, port, irq, baud;
1562 } serial_t;
1563
1564 typedef struct s_ser_device_t {
1565 struct s_ser_device_t *next;
1566 unsigned hd_idx;
1567 char *dev_name;
1568 str_list_t *at_resp;
1569 int fd;
1570 struct termios tio;
1571 unsigned max_baud, cur_baud;
1572 unsigned is_mouse:1;
1573 unsigned is_modem:1;
1574 unsigned do_io:1;
1575 unsigned char buf[0x1000];
1576 int buf_len;
1577 int garbage, non_pnp, pnp;
1578 unsigned char pnp_id[8];
1579 char *serial, *class_name, *dev_id, *user_name, *vend, *init_string1, *init_string2, *pppd_option;
1580 unsigned pnp_rev;
1581 unsigned bits;
1582 } ser_device_t;
1583
1584 /*
1585 * Notes on isdn_parm_t:
1586 * - def_value is only relevant of alt_values != 0
1587 * - def_value should be a value out of alt_value[]
1588 * - see libihw docu for the meaning of name,type,flags,def_value
1589 */
1590 typedef struct isdn_parm_s {
1591 struct isdn_parm_s *next;
1592 char *name; /* parameter name */
1593 unsigned valid:1; /* 1: entry is valid, 0: some inconsistencies */
1594 unsigned conflict:1; /* 1: ressource conflict (eg. no free irq) */
1595 uint64_t value; /* value of the parameter */
1596 unsigned type; /* CDBISDN type (P_...) */
1597 unsigned flags; /* CDBISDN flags (P_...) */
1598 unsigned def_value; /* default value */
1599 int alt_values; /* length of alt_value[] */
1600 unsigned *alt_value; /* possible values */
1601 } isdn_parm_t;
1602
1603 /* device driver info types */
1604 typedef enum driver_info_type {
1605 di_any, di_display, di_module, di_mouse, di_x11, di_isdn, di_kbd, di_dsl
1606 } hd_driver_info_t;
1607
1608 /* unspecific info */
1609 typedef struct {
1610 union driver_info_u *next;
1611 enum driver_info_type type; /* driver info type */
1612 str_list_t *hddb0, *hddb1; /* the actual driver database entries */
1613 } driver_info_any_t;
1614
1615 /* display (monitor) info */
1616 typedef struct {
1617 union driver_info_u *next;
1618 enum driver_info_type type; /* driver info type */
1619 str_list_t *hddb0, *hddb1; /* the actual driver database entries */
1620 unsigned width, height; /* max. useful display geometry */
1621 unsigned min_vsync, max_vsync; /* vsync range */
1622 unsigned min_hsync, max_hsync; /* hsync range */
1623 unsigned bandwidth; /* max. pixel clock */
1624 } driver_info_display_t;
1625
1626 /* module info */
1627 typedef struct {
1628 union driver_info_u *next;
1629 enum driver_info_type type; /* driver info type */
1630 str_list_t *hddb0, *hddb1; /* the actual driver database entries */
1631 unsigned active:1; /* if module is currently active */
1632 unsigned modprobe:1; /* modprobe or insmod */
1633 str_list_t *names; /* (ordered) list of module names */
1634 str_list_t *mod_args; /* list of module args (corresponds to the module name list) */
1635 char *conf; /* conf.modules entry, if any (e.g. for sb.o) */
1636 } driver_info_module_t;
1637
1638 /* mouse protocol info */
1639 typedef struct {
1640 union driver_info_u *next;
1641 enum driver_info_type type; /* driver info type */
1642 str_list_t *hddb0, *hddb1; /* the actual driver database entries */
1643 char *xf86; /* the XF86 protocol name */
1644 char *gpm; /* dto, gpm */
1645 int buttons; /* number of buttons, -1 --> unknown */
1646 int wheels; /* dto, wheels */
1647 } driver_info_mouse_t;
1648
1649 /* X11 server info */
1650 typedef struct {
1651 union driver_info_u *next;
1652 enum driver_info_type type; /* driver info type */
1653 str_list_t *hddb0, *hddb1; /* the actual driver database entries */
1654 char *server; /* the server/module name */
1655 char *xf86_ver; /* XFree86 version (3 or 4) */
1656 unsigned x3d:1; /* has 3D support */
1657 struct {
1658 unsigned all:5; /* the next 5 entries combined */
1659 unsigned c8:1, c15:1, c16:1, c24:1, c32:1;
1660 } colors; /* supported color depths */
1661 unsigned dacspeed; /* max. ramdac clock */
1662 str_list_t *extensions; /* additional X extensions to load ('Module' section) */
1663 str_list_t *options; /* special server options */
1664 str_list_t *raw; /* extra info to add to XF86Config */
1665 char *script; /* 3d script to run */
1666 } driver_info_x11_t;
1667
1668 /* isdn info */
1669 typedef struct {
1670 union driver_info_u *next;
1671 enum driver_info_type type; /* driver info type */
1672 str_list_t *hddb0, *hddb1; /* the actual driver database entries */
1673 int i4l_type, i4l_subtype; /* I4L types */
1674 char *i4l_name; /* I4L card name */
1675 isdn_parm_t *params; /* isdn parameters */
1676 } driver_info_isdn_t;
1677
1678 /* dsl info */
1679 typedef struct {
1680 union driver_info_u *next;
1681 enum driver_info_type type; /* driver info type */
1682 str_list_t *hddb0, *hddb1; /* the actual driver database entries */
1683 char *mode; /* DSL driver types */
1684 char *name; /* DSL driver name */
1685 } driver_info_dsl_t;
1686
1687 /* keyboard info */
1688 typedef struct {
1689 union driver_info_u *next;
1690 enum driver_info_type type; /* driver info type */
1691 str_list_t *hddb0, *hddb1; /* the actual driver database entries */
1692 char *XkbRules; /* XF86Config entries */
1693 char *XkbModel;
1694 char *XkbLayout;
1695 char *keymap; /* console keymap */
1696 } driver_info_kbd_t;
1697
1698 /*
1699 * holds device driver info
1700 */
1701 typedef union driver_info_u {
1702 union driver_info_u *next;
1703 driver_info_any_t any;
1704 driver_info_module_t module;
1705 driver_info_mouse_t mouse;
1706 driver_info_x11_t x11;
1707 driver_info_display_t display;
1708 driver_info_isdn_t isdn;
1709 driver_info_dsl_t dsl;
1710 driver_info_kbd_t kbd;
1711 } driver_info_t;
1712
1713
1714 /*
1715 * Some hardware doesn't fit into the hd_t scheme or there is info we
1716 * gathered during the scan process but that no-one really cares about. Such
1717 * stuff is stored in hd_detail_t.
1718 */
1719 typedef enum hd_detail_type {
1720 hd_detail_pci, hd_detail_usb, hd_detail_isapnp, hd_detail_cdrom,
1721 hd_detail_floppy, hd_detail_bios, hd_detail_cpu, hd_detail_prom,
1722 hd_detail_monitor, hd_detail_sys, hd_detail_scsi, hd_detail_devtree,
1723 hd_detail_ccw
1724 } hd_detail_type_t;
1725
1726 typedef struct {
1727 enum hd_detail_type type;
1728 pci_t *data;
1729 } hd_detail_pci_t;
1730
1731 typedef struct {
1732 enum hd_detail_type type;
1733 usb_t *data;
1734 } hd_detail_usb_t;
1735
1736 typedef struct {
1737 enum hd_detail_type type;
1738 isapnp_dev_t *data;
1739 } hd_detail_isapnp_t;
1740
1741 typedef struct {
1742 enum hd_detail_type type;
1743 cdrom_info_t *data;
1744 } hd_detail_cdrom_t;
1745
1746 typedef struct {
1747 enum hd_detail_type type;
1748 floppy_info_t *data;
1749 } hd_detail_floppy_t;
1750
1751 typedef struct {
1752 enum hd_detail_type type;
1753 bios_info_t *data;
1754 } hd_detail_bios_t;
1755
1756 typedef struct {
1757 enum hd_detail_type type;
1758 cpu_info_t *data;
1759 } hd_detail_cpu_t;
1760
1761 typedef struct {
1762 enum hd_detail_type type;
1763 prom_info_t *data;
1764 } hd_detail_prom_t;
1765
1766 typedef struct {
1767 enum hd_detail_type type;
1768 monitor_info_t *data;
1769 } hd_detail_monitor_t;
1770
1771 typedef struct {
1772 enum hd_detail_type type;
1773 sys_info_t *data;
1774 } hd_detail_sys_t;
1775
1776 typedef struct {
1777 enum hd_detail_type type;
1778 scsi_t *data;
1779 } hd_detail_scsi_t;
1780
1781 typedef struct {
1782 enum hd_detail_type type;
1783 devtree_t *data;
1784 } hd_detail_devtree_t;
1785
1786 typedef struct {
1787 enum hd_detail_type type;
1788 ccw_t *data;
1789 } hd_detail_ccw_t;
1790
1791 typedef union {
1792 enum hd_detail_type type;
1793 hd_detail_pci_t pci;
1794 hd_detail_usb_t usb;
1795 hd_detail_isapnp_t isapnp;
1796 hd_detail_cdrom_t cdrom;
1797 hd_detail_floppy_t floppy;
1798 hd_detail_bios_t bios;
1799 hd_detail_cpu_t cpu;
1800 hd_detail_prom_t prom;
1801 hd_detail_monitor_t monitor;
1802 hd_detail_sys_t sys;
1803 hd_detail_scsi_t scsi;
1804 hd_detail_devtree_t devtree;
1805 hd_detail_ccw_t ccw;
1806 } hd_detail_t;
1807
1808
1809 /* info about manually configured hardware (in /var/lib/hardware/) */
1810 typedef struct hd_manual_s {
1811 struct hd_manual_s *next;
1812
1813 char *unique_id;
1814 char *parent_id;
1815 char *child_ids;
1816 unsigned hw_class;
1817 char *model;
1818
1819 hd_status_t status;
1820 char *config_string;
1821
1822 /* More or less free-form key, value pairs.
1823 * key should not contain '=', however.
1824 */
1825 str_list_t *key;
1826 str_list_t *value;
1827 } hd_manual_t;
1828
1829
1830 /**
1831 * Individual hardware item.
1832 * Every hardware component gets an \ref hd_t entry. A list of all hardware
1833 * items is in \ref hd_data_t::hd.
1834 */
1835 typedef struct s_hd_t {
1836 struct s_hd_t *next; /**< Link to next hardware item. */
1837 /**
1838 * Unique index, starting at 1.
1839 * Use \ref hd_get_device_by_idx() to look up an hardware entry by index. And don't
1840 * free the result!
1841 */
1842 unsigned idx;
1843
1844 /**
1845 * Hardware appears to be broken in some way.
1846 * This was used to indicate broken framebuffer support of some graphics cards.
1847 * Currently unused.
1848 */
1849 unsigned broken:1;
1850
1851 /**
1852 * Bus type (id and name).
1853 */
1854 hd_id_t bus;
1855
1856 /**
1857 * Slot and bus number.
1858 * Bits 0-7: slot number, 8-31 bus number.
1859 */
1860 unsigned slot;
1861
1862 /**
1863 * (PCI) function.
1864 */
1865 unsigned func;
1866
1867 /**
1868 * Base class (id and name).
1869 */
1870 hd_id_t base_class;
1871
1872 /**
1873 * Sub class (id and name).
1874 */
1875 hd_id_t sub_class;
1876
1877 /**
1878 * (PCI) programming interface (id and name).
1879 */
1880 hd_id_t prog_if;
1881
1882 /**
1883 * Vendor id and name.
1884 * Id is actually a combination of some tag to differentiate the
1885 * various id types and the real id. Use the \ref ID_VALUE macro to
1886 * get e.g. the real PCI id value for a PCI %device.
1887 */
1888 hd_id_t vendor;
1889
1890 /**
1891 * Device id and name.
1892 * Id is actually a combination of some tag to differentiate the
1893 * various id types and the real id. Use the \ref ID_VALUE macro to
1894 * get e.g. the real PCI id value for a PCI %device.
1895 * \note If you're looking or something printable, you might want to use \ref hd_t::model
1896 * instead.
1897 */
1898 hd_id_t device;
1899
1900 /**
1901 * Subvendor id and name.
1902 * Id is actually a combination of some tag to differentiate the
1903 * various id types and the real id. Use the \ref ID_VALUE macro to
1904 * get e.g. the real PCI id value for a PCI %device.
1905 */
1906 hd_id_t sub_vendor;
1907
1908 /**
1909 * Subdevice id and name.
1910 * Id is actually a combination of some tag to differentiate the
1911 * various id types and the real id. Use the \ref ID_VALUE macro to
1912 * get e.g. the real PCI id value for a PCI %device.
1913 */
1914 hd_id_t sub_device;
1915
1916 /**
1917 * Revision id or string.
1918 * If revision is numerical (e.g. PCI) \ref hd_id_t::id is used.
1919 * If revision is some char data (e.g. disk drives) it is stored in \ref hd_id_t::name.
1920 */
1921 hd_id_t revision;
1922
1923 /**
1924 * Serial id.
1925 */
1926 char *serial;
1927
1928 /**
1929 * Vendor id and name of some compatible hardware.
1930 * Used mainly for ISA-PnP devices.
1931 */
1932 hd_id_t compat_vendor;
1933
1934 /**
1935 * Device id and name of some compatible hardware.
1936 * Used mainly for ISA-PnP devices.
1937 */
1938 hd_id_t compat_device;
1939
1940 /**
1941 * Hardware class.
1942 * Not to confuse with \ref base_class!
1943 */
1944 hd_hw_item_t hw_class;
1945
1946 /**
1947 * Hardware class list.
1948 * A device may belong to more than one hardware class.
1949 */
1950 unsigned char hw_class_list[(hw_all + 7) / 8]; /**< (Internal) bitmask of hw classes. */
1951
1952 /**
1953 * Model name.
1954 * This is a combination of vendor and %device names. Some heuristics is used
1955 * to make it more presentable. Use this instead of \ref hd_t::vendor and
1956 * \ref hd_t::device.
1957 */
1958 char *model;
1959
1960 /**
1961 * Device this hardware is attached to.
1962 * Link to some 'parent' %device. Use \ref hd_get_device_by_idx() to get
1963 * the corresponding hardware entry.
1964 */
1965 unsigned attached_to;
1966
1967 /**
1968 * sysfs entry for this hardware, if any.
1969 */
1970 char *sysfs_id;
1971
1972 /**
1973 * sysfs bus id for this hardware, if any.
1974 */
1975 char *sysfs_bus_id;
1976
1977 /**
1978 * sysfs device link.
1979 */
1980 char *sysfs_device_link;
1981
1982 /**
1983 * Special %device file.
1984 * Device file name to access this hardware. Normally something below /dev.
1985 * For network interfaces this is the interface name.
1986 */
1987 char *unix_dev_name;
1988
1989 /**
1990 * Device type & number according to sysfs.
1991 */
1992 hd_dev_num_t unix_dev_num;
1993
1994 /**
1995 * List of %device names.
1996 * Device file names to access this hardware. Normally something below /dev.
1997 * They should be all equivalent. The preferred name however is
1998 * \ref hd_t::unix_dev_name.
1999 */
2000 str_list_t *unix_dev_names;
2001
2002 /**
2003 * Special %device file.
2004 * Device file name to access this hardware. Most hardware only has one
2005 * %device name stored in \ref hd_t::unix_dev_name. But in some cases
2006 * there's an alternative name.
2007 */
2008 char *unix_dev_name2;
2009
2010 /**
2011 * Device type & number according to sysfs.
2012 */
2013 hd_dev_num_t unix_dev_num2;
2014
2015 /**
2016 * BIOS/PROM id.
2017 * Where appropriate, this is a special BIOS/PROM id (e.g. "0x80" for
2018 * the first harddisk on Intel-PCs).
2019 * CHPID for s390.
2020 */
2021 char *rom_id;
2022
2023 /**
2024 * Unique id for this hardware.
2025 * A unique string identifying this hardware. The string consists
2026 * of two parts separated by a dot ("."). The part before the dot
2027 * describes the location (where the hardware is attached in the system).
2028 * The part after the dot identifies the hardware itself. The string
2029 * must not contain slashes ("/") because we're going to create files
2030 * with this id as name. Apart from this there are no restrictions on
2031 * the form of this string.
2032 */
2033 char *unique_id;
2034
2035 /* List of ids. */
2036 str_list_t *unique_ids;
2037
2038 /**
2039 * (Internal) Probing module that created this entry.
2040 */
2041 unsigned module;
2042
2043 /**
2044 * (Internal) Source code line where this entry was created.
2045 */
2046 unsigned line;
2047
2048 /**
2049 * (Internal) Counter, used in combination with \ref hd_t::module and \ref hd_t::line.
2050 */
2051 unsigned count;
2052
2053 /**
2054 * Device resources.
2055 */
2056 hd_res_t *res;
2057
2058 /**
2059 * Special info associated with this hardware.
2060 * \note This is going to change!
2061 */
2062 hd_detail_t *detail;
2063
2064 /**
2065 * (Internal) Unspecific text info.
2066 * It is used to track IDE interfaces and assign them to the correct
2067 * IDE controllers.
2068 */
2069 str_list_t *extra_info;
2070
2071 /**
2072 * Hardware status (if available).
2073 * The status is stored in files below /var/lib/hardware/unique-keys/. Every
2074 * hardware item gets a file there with its unique id as file name.
2075 */
2076 hd_status_t status;
2077
2078 /**
2079 * Some %config info.
2080 * Every hardware item may get some string assigned. This string is stored
2081 * in files below /var/lib/hardware/unique-keys/. There is no meaning
2082 * associated with this string.
2083 */
2084 char *config_string;
2085
2086 /**
2087 * Hotplug controller for this %device.
2088 * It indicates what kind of hotplug %device (if any) this is.
2089 */
2090 hd_hotplug_t hotplug;
2091
2092 /**
2093 * Slot the hotplug device is connected to (e.g. PCMCIA socket).
2094 * \note \ref hotplug_slot counts 1-based (0: no information available).
2095 */
2096 unsigned hotplug_slot;
2097
2098 struct is_s {
2099 unsigned agp:1; /* AGP device */
2100 unsigned isapnp:1; /* ISA-PnP device */
2101 unsigned notready:1; /* block devices: no medium, other: device not configured */
2102 unsigned manual:1; /* undetectable, manually configured hardware */
2103 unsigned softraiddisk:1; /* disk belongs to some soft raid array */
2104 unsigned zip:1; /* zip floppy */
2105 unsigned cdr:1; /* CD-R */
2106 unsigned cdrw:1; /* CD-RW */
2107 unsigned dvd:1; /* DVD */
2108 unsigned dvdr:1; /* DVD-R */
2109 unsigned dvdram:1; /* DVD-RAM */
2110 unsigned pppoe:1; /* PPPOE modem connected */
2111 unsigned wlan:1; /* WLAN card */
2112 } is;
2113
2114 struct tag_s { /* this struct is for internal purposes only */
2115 unsigned remove:1; /* schedule for removal */
2116 unsigned freeit:1; /* for internal memory management */
2117 unsigned fixed:1; /* fixed, do no longer modify this entry */
2118 unsigned ser_skip:1; /* if serial line, don't scan for devices */
2119 unsigned ser_device:2; /* if != 0: info about attached serial device; see serial.c */
2120 } tag;
2121
2122 /**
2123 * (Internal) First 512 bytes of block devices.
2124 * To check accessibility of block devices we read the first block. The data
2125 * is used to identify the boot %device.
2126 */
2127 unsigned char *block0;
2128
2129 /**
2130 * Currently active driver.
2131 */
2132 char *driver;
2133
2134 /**
2135 * List of currently active drivers.
2136 */
2137 str_list_t *drivers;
2138
2139 /**
2140 * Old \ref unique_id for compatibility.
2141 * The calculation of unique ids has changed in libhd v3.17. Basically
2142 * we no longer use the vendor/%device names if there are vendor/%device
2143 * ids. (Otherwise a simple %device name database update would change the id,
2144 * which is really not what you want.)
2145 */
2146 char *old_unique_id;
2147
2148 /**
2149 * \ref unique_id of parent (\ref attached_to).
2150 * \note Please do not use it for now.
2151 *
2152 */
2153 char *parent_id;
2154
2155 /**
2156 * \ref unique_ids of children (\ref parent_id).
2157 * \note Please do not use it for now.
2158 *
2159 */
2160 str_list_t *child_ids;
2161
2162 /**
2163 * (Internal) location independent \ref unique_id part.
2164 * The speed up some internal searches, we store it here separately.
2165 */
2166 char *unique_id1;
2167
2168 /**
2169 * USB Global Unique Identifier.
2170 * Available for USB devices. This may even be set if \ref hd_t::bus is not
2171 * \ref bus_usb (e.g. USB storage devices will have \ref hd_t::bus set to
2172 * \ref bus_scsi due to SCSI emulation).
2173 */
2174 char *usb_guid;
2175
2176 driver_info_t *driver_info; /* device driver info */
2177
2178 str_list_t *requires; /* packages/programs required for this hardware */
2179
2180 /*
2181 * These are used internally for memory management.
2182 * Do not even _think_ of modifying these!
2183 */
2184 unsigned ref_cnt; /**< (Internal) memory reference count. */
2185 struct s_hd_t *ref; /**< (Internal) if set, this is only a reference. */
2186 } hd_t;
2187
2188
2189 /**
2190 * Holds all data accumulated during hardware probing.
2191 */
2192 typedef struct {
2193 /**
2194 * Current hardware list.
2195 * The list of all currently probed hardware. This is not identical with
2196 * the result of \ref hd_list(). (But a superset of it.)
2197 */
2198 hd_t *hd;
2199
2200 /**
2201 * A progress indicator.
2202 * If this callback function is not NULL, it is called at various points and can
2203 * be used to give some user feedback what we are actually doing.
2204 * If the debug flag HD_DEB_PROGRESS is set, progress messages are logged.
2205 * \param pos Indicates where we are.
2206 * \param msg Indicates what we are going to do.
2207 */
2208 void (*progress)(char *pos, char *msg);
2209
2210 /** Log messages.
2211 * All messages logged during hardware probing accumulate here.
2212 */
2213 char *log;
2214
2215 /** Debug flags.
2216 * Although there exist some debug flag defines this scheme is currently
2217 * not followed consistently. It is guaranteed however that -1 will give
2218 * the most log messages and 0 the least.
2219 */
2220 unsigned debug;
2221
2222 /**
2223 * Special flags.
2224 * Influence hardware probing in some strange ways with these. You normally
2225 * do not want to use them.
2226 */
2227 struct flag_struct {
2228 unsigned internal:1; /**< \ref hd_scan() has been called internally. */
2229 unsigned dformat:2; /**< Alternative output format. */
2230 unsigned no_parport:1; /**< Don't do parport probing: parport modules (used to) crash pmacs. */
2231 unsigned iseries:1; /**< Set if we are on an iSeries machine. */
2232 unsigned list_all:1; /**< Return even devices with status 'not available'. */
2233 unsigned fast:1; /**< Don't check tricky hardware. */
2234 unsigned list_md:1; /**< Report md & lvm devices from /proc/partitions */
2235 unsigned nofork:1; /**< don't run potentially hanging code in a subprocess */
2236 unsigned nosysfs:1; /**< don't ask sysfs */
2237 unsigned forked:1; /**< we're running in a subprocess */
2238 unsigned cpuemu:1; /**< use CPU emulation to run BIOS code (i386 only) */
2239 unsigned udev:1; /**< return first udev symlink as device name */
2240 unsigned edd_used:1; /**< internal: edd info has been used */
2241 unsigned keep_kmods:2; /**< internal: don't reread kmods */
2242 } flags;
2243
2244
2245 /** Concentrate on these devices.
2246 * List of sysfs ids for devices to look for.
2247 */
2248 str_list_t *only;
2249
2250 /*
2251 * The following entries should *not* be accessed outside of libhd!
2252 */
2253 unsigned char probe[(pr_all + 7) / 8]; /**< (Internal) bitmask of probing features. */
2254 unsigned char probe_set[(pr_all + 7) / 8]; /**< (Iternal) bitmask of probing features that will always be set. */
2255 unsigned char probe_clr[(pr_all + 7) / 8]; /**< (Internal) bitmask of probing features that will always be reset. */
2256 unsigned last_idx; /**< (Internal) index of the last hd entry generated */
2257 unsigned module; /**< (Internal) the current probing module we are in */
2258 enum boot_arch boot; /**< (Internal) boot method */
2259 hd_t *old_hd; /**< (Internal) old (outdated) entries (if you scan more than once) */
2260 pci_t *pci; /**< (Internal) raw PCI data */
2261 isapnp_t *isapnp; /**< (Internal) raw ISA-PnP data */
2262 cdrom_info_t *cdrom; /**< (Internal) CDROM devs from PROC_CDROM_INFO */
2263 str_list_t *net; /**< (Internal) list of network interfaces */
2264 str_list_t *floppy; /**< (Internal) contents of PROC_NVRAM, used by the floppy module */
2265 misc_t *misc; /**< (Internal) data gathered in the misc module */
2266 serial_t *serial; /**< (Internal) /proc's serial info */
2267 scsi_t *scsi; /**< (Internal) raw SCSI data */
2268 ser_device_t *ser_mouse; /**< (Internal) info about serial mice */
2269 ser_device_t *ser_modem; /**< (Internal) info about serial modems */
2270 str_list_t *cpu; /**< (Internal) /proc/cpuinfo */
2271 str_list_t *klog; /**< (Internal) kernel log */
2272 str_list_t *proc_usb; /**< (Internal) /proc/bus/usb info */
2273 usb_t *usb; /**< (Internal) usb info */
2274 hddb_pci_t *hddb_pci_hm; /**< (Internal) pci module info */
2275 hddb_pci_t *hddb_pci; /**< (Internal) pci module info */
2276 hddb2_data_t *hddb2[2]; /**< (Internal) hardware database */
2277 str_list_t *kmods; /**< (Internal) list of active kernel modules */
2278 uint64_t used_irqs; /**< (Internal) irq usage */
2279 uint64_t assigned_irqs; /**< (Internal) irqs automatically assigned by libhd (for driver info) */
2280 memory_range_t bios_rom; /**< (Internal) BIOS 0xc0000 - 0xfffff */
2281 memory_range_t bios_ram; /**< (Internal) BIOS 0x00400 - 0x004ff */
2282 memory_range_t bios_ebda; /**< (Internal) EBDA */
2283 unsigned display; /**< (Internal) hd_idx of the active (vga) display */
2284 unsigned color_code; /**< (Internal) color, if any */
2285 char *cmd_line; /**< (Internal) kernel command line */
2286 str_list_t *xtra_hd; /**< (Internal) fake hd entries (for testing) */
2287 devtree_t *devtree; /**< (Internal) prom device tree on ppc */
2288 unsigned kernel_version; /**< (Internal) kernel version */
2289 int in_vmware; /**< (Internal) running in vmware */
2290 hd_manual_t *manual; /**< (Internal) hardware config info */
2291 str_list_t *disks; /**< (Internal) disks according to /proc/partitions */
2292 str_list_t *partitions; /**< (Internal) dto, partitions */
2293 str_list_t *cdroms; /**< (Internal) cdroms according to PROC_CDROM_INFO */
2294 hd_smbios_t *smbios; /**< (Internal) smbios data */
2295 struct {
2296 unsigned ok:1;
2297 unsigned size;
2298 unsigned used;
2299 void *data;
2300 int id;
2301 int updated;
2302 } shm; /**< (Internal) our shm segment */
2303 unsigned pci_config_type; /**< (Internal) PCI config type (1 or 2), 0: unknown */
2304 hd_udevinfo_t *udevinfo; /**< (Internal) udev info */
2305 hd_sysfsdrv_t *sysfsdrv; /**< (Internal) sysfs driver info */
2306 uint64_t sysfsdrv_id; /**< (Internal) sysfs driver info id */
2307 str_list_t *scanner_db; /**< (Internal) list of scanner modules */
2308 edd_info_t edd[0x80]; /**< (Internal) enhanced disk drive data */
2309 } hd_data_t;
2310
2311
2312 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2313 *
2314 * libhd interface functions
2315 *
2316 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2317 */
2318
2319 /* implemented in hd.c */
2320
2321 /* the actual hardware scan */
2322 void hd_scan(hd_data_t *hd_data);
2323
2324 //! Free all data.
2325 hd_data_t *hd_free_hd_data(hd_data_t *hd_data);
2326
2327 //! Free hardware items returned by e.g. \ref hd_list().
2328 hd_t *hd_free_hd_list(hd_t *hd);
2329
2330 void hd_set_probe_feature(hd_data_t *hd_data, enum probe_feature feature);
2331 void hd_clear_probe_feature(hd_data_t *hd_data, enum probe_feature feature);
2332 int hd_probe_feature(hd_data_t *hd_data, enum probe_feature feature);
2333 void hd_set_probe_feature_hw(hd_data_t *hd_data, hd_hw_item_t item);
2334
2335 enum probe_feature hd_probe_feature_by_name(char *name);
2336 char *hd_probe_feature_by_value(enum probe_feature feature);
2337
2338 int hd_module_is_active(hd_data_t *hd_data, char *mod);
2339
2340 hd_t *hd_base_class_list(hd_data_t *hd_data, unsigned base_class);
2341 hd_t *hd_sub_class_list(hd_data_t *hd_data, unsigned base_class, unsigned sub_class);
2342 hd_t *hd_bus_list(hd_data_t *hd_data, unsigned bus);
2343 const char* hd_busid_to_hwcfg(int busid);
2344 hd_t *hd_list(hd_data_t *hd_data, hd_hw_item_t item, int rescan, hd_t *hd_old);
2345 hd_t *hd_list_with_status(hd_data_t *hd_data, hd_hw_item_t item, hd_status_t status);
2346 hd_t *hd_list2(hd_data_t *hd_data, hd_hw_item_t *items, int rescan);
2347 hd_t *hd_list_with_status2(hd_data_t *hd_data, hd_hw_item_t *items, hd_status_t status);
2348
2349 int hd_has_pcmcia(hd_data_t *hd_data);
2350 // will be gone soon
2351 // int hd_apm_enabled(hd_data_t *hd_data);
2352 int hd_usb_support(hd_data_t *hd_data);
2353 int hd_smp_support(hd_data_t *hd_data);
2354 int hd_mac_color(hd_data_t *hd_data);
2355 int hd_color(hd_data_t *hd_data);
2356 int hd_is_uml(hd_data_t *hd_data);
2357 unsigned hd_display_adapter(hd_data_t *hd_data);
2358 unsigned hd_boot_disk(hd_data_t *hd_data, int *matches);
2359 enum cpu_arch hd_cpu_arch(hd_data_t *hd_data);
2360 enum boot_arch hd_boot_arch(hd_data_t *hd_data);
2361
2362 hd_t *hd_get_device_by_idx(hd_data_t *hd_data, unsigned idx);
2363
2364 void hd_set_hw_class(hd_t *hd, hd_hw_item_t hw_class);
2365 int hd_is_hw_class(hd_t *hd, hd_hw_item_t hw_class);
2366
2367 int hd_is_sgi_altix(hd_data_t *hd_data);
2368
2369 char *hd_version(void);
2370
2371 /* implemented in hddb.c */
2372
2373 str_list_t *get_hddb_packages(hd_data_t *hd_data);
2374 void hddb_add_info(hd_data_t *hd_data, hd_t *hd);
2375
2376 void hddb_dump_raw(hddb2_data_t *hddb, FILE *f);
2377 void hddb_dump(hddb2_data_t *hddb, FILE *f);
2378
2379 /* implemented in hdp.c */
2380
2381 void hd_dump_entry(hd_data_t *hd_data, hd_t *hd, FILE *f);
2382
2383
2384 /* implemented in cdrom.c */
2385
2386 cdrom_info_t *hd_read_cdrom_info(hd_data_t *hd_data, hd_t *hd);
2387
2388 /* implemented in manual.c */
2389 hd_manual_t *hd_manual_read_entry(hd_data_t *hd_data, const char *id);
2390 int hd_manual_write_entry(hd_data_t *hd_data, hd_manual_t *entry);
2391 hd_manual_t *hd_free_manual(hd_manual_t *manual);
2392 hd_t *hd_read_config(hd_data_t *hd_data, const char *id);
2393 int hd_write_config(hd_data_t *hd_data, hd_t *hd);
2394 char *hd_hw_item_name(hd_hw_item_t item);
2395 char *hd_status_value_name(hd_status_value_t status);
2396 int hd_change_status(const char *id, hd_status_t status, const char *config_string);
2397 int hd_read_mmap(hd_data_t *hd_data, char *name, unsigned char *buf, off_t start, unsigned size);
2398
2399
2400 /*
2401 * - - - - - CDB ISDN interface - - - - -
2402 */
2403
2404
2405 /* (C) 2003 kkeil@suse.de */
2406
2407 #define CDBISDN_VERSION 0x0101
2408
2409 #ifndef PCI_ANY_ID
2410 #define PCI_ANY_ID 0xffff
2411 #endif
2412
2413 #define CDBISDN_P_NONE 0x0
2414 #define CDBISDN_P_IRQ 0x1
2415 #define CDBISDN_P_MEM 0x2
2416 #define CDBISDN_P_IO 0x3
2417
2418 /* vendor info */
2419 typedef struct {
2420 char *name;
2421 char *shortname;
2422 int vnr;
2423 int refcnt;
2424 } cdb_isdn_vendor;
2425
2426 typedef struct {
2427 int handle; /* internal identifier idx in database */
2428 int vhandle; /* internal identifier to vendor database */
2429 char *name; /* cardname */
2430 char *lname; /* vendor short name + cardname */
2431 char *Class; /* CLASS of the card */
2432 char *bus; /* bus type */
2433 int revision; /* revision used with USB */
2434 int vendor; /* Vendor ID for ISAPNP and PCI cards */
2435 int device; /* Device ID for ISAPNP and PCI cards */
2436 int subvendor; /* Subvendor ID for PCI cards */
2437 /* A value of 0xffff is ANY_ID */
2438 int subdevice; /* Subdevice ID for PCI cards */
2439 /* A value of 0xffff is ANY_ID */
2440 unsigned int features; /* feature flags */
2441 int line_cnt; /* count of ISDN ports */
2442 int vario_cnt; /* count of driver varios */
2443 int vario; /* referenz to driver vario record */
2444 } cdb_isdn_card;
2445
2446 typedef struct {
2447 int handle; /* idx in database */
2448 int next_vario; /* link to alternate vario */
2449 int drvid; /* unique id of the driver vario */
2450 int typ; /* Type to identify the driver */
2451 int subtyp; /* Subtype of the driver type */
2452 int smp; /* SMP supported ? */
2453 char *mod_name; /* name of the driver module */
2454 char *para_str; /* optional parameter string */
2455 char *mod_preload; /* optional modules to preload */
2456 char *cfg_prog; /* optional cfg prog */
2457 char *firmware; /* optional firmware to load */
2458 char *description; /* optional description */
2459 char *need_pkg; /* list of packages needed for function */
2460 char *info; /* optional additional info */
2461 char *protocol; /* supported D-channel protocols */
2462 char *interface; /* supported API interfaces */
2463 char *io; /* possible IO ports with legacy ISA cards */
2464 char *irq; /* possible interrupts with legacy ISA cards */
2465 char *membase; /* possible membase with legacy ISA cards */
2466 char *features; /* optional features*/
2467 int card_ref; /* reference to a card */
2468 char *name; /* driver name */
2469 } cdb_isdn_vario;
2470
2471
2472 extern cdb_isdn_vendor *hd_cdbisdn_get_vendor(int);
2473 extern cdb_isdn_card *hd_cdbisdn_get_card(int);
2474 extern cdb_isdn_vario *hd_cdbisdn_get_vario_from_type(int, int);
2475 extern cdb_isdn_card *hd_cdbisdn_get_card_from_type(int, int);
2476 extern cdb_isdn_card *hd_cdbisdn_get_card_from_id(int, int, int, int);
2477 extern cdb_isdn_vario *hd_cdbisdn_get_vario(int);
2478 extern int hd_cdbisdn_get_version(void);
2479 extern int hd_cdbisdn_get_db_version(void);
2480 extern char *hd_cdbisdn_get_db_date(void);
2481
2482 /* CDB ISDN interface end */
2483
2484 #ifdef __cplusplus
2485 }
2486 #endif
2487
2488 #endif /* _HD_H */