]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/hwinfo/src/hd/hdp.c
65dffef7c6dd7b518bdcc0b2c1fc739c07004df8
14 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
15 * This module provides a function that prints a hardware entry.
16 * This is useful for debugging or to provide the user with some fancy info.
18 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
23 #define dump_line(x0, x1...) fprintf(f, "%*s" x0, ind, "", x1)
24 #define dump_line_str(x0...) fprintf(f, "%*s%s", ind, "", x0)
25 #define dump_line0(x0...) fprintf(f, x0)
27 static int ind
= 0; /* output indentation */
29 static void dump_normal(hd_data_t
*, hd_t
*, FILE *);
30 static void dump_cpu(hd_data_t
*, hd_t
*, FILE *);
31 static void dump_bios(hd_data_t
*, hd_t
*, FILE *);
32 static void dump_prom(hd_data_t
*, hd_t
*, FILE *);
33 static void dump_sys(hd_data_t
*, hd_t
*, FILE *);
35 static char *dump_hid(hd_data_t
*hd_data
, hd_id_t
*hid
, int format
, char *buf
, int buf_size
);
36 static char *dump_hid2(hd_data_t
*hd_data
, hd_id_t
*hid1
, hd_id_t
*hid2
, char *buf
, int buf_size
);
37 static char *print_dev_num(hd_dev_num_t
*d
);
40 * Dump a hardware entry to FILE *f.
42 void hd_dump_entry(hd_data_t
*hd_data
, hd_t
*h
, FILE *f
)
44 char *s
, *a0
, *a1
, *a2
, *s1
, *s2
;
45 char buf1
[32], buf2
[32];
53 fprintf(libhd_log
, "; %s\t%p\t%p\n", __FUNCTION__
, CALLED_FROM(hd_dump_entry
, hd_data
), hd_data
);
60 if(h
->is
.agp
) s
= "(AGP)";
61 // pci_flag_pm: dump_line0(", supports PM");
62 if(h
->is
.isapnp
) s
= "(PnP)";
66 a1
= h
->sub_class
.name
?: h
->base_class
.name
;
67 if(a1
&& h
->prog_if
.name
) {
68 str_printf(&a2
, 0, "%s (%s)", a1
, h
->prog_if
.name
);
71 a2
= new_str(a1
?: "?");
74 "%02d: %s%s %02x.%x: %02x%02x %s\n",
75 h
->idx
, a0
? a0
: "?", s
, h
->slot
, h
->func
,
76 h
->base_class
.id
, h
->sub_class
.id
, a2
81 if((hd_data
->debug
& HD_DEB_CREATION
)) {
82 s
= mod_name_by_idx(h
->module
);
83 if(!s
) sprintf(s
= buf1
, "%u", h
->module
);
85 sprintf(buf2
, ".%u", h
->count
);
88 dump_line("[Created at %s.%u%s]\n", s
, h
->line
, buf2
);
91 if(hd_data
->flags
.dformat
== 1) {
92 dump_line("ClassName: \"%s\"\n", a2
);
93 dump_line("Bus: %d\n", h
->slot
>> 8);
94 dump_line("Slot: %d\n", h
->slot
& 0xff);
95 dump_line("Function: %d\n", h
->func
);
100 if((hd_data
->debug
& HD_DEB_CREATION
) && h
->unique_id
) {
101 dump_line("Unique ID: %s\n", h
->unique_id
);
104 if(hd_data
->debug
== -1u && h
->old_unique_id
) {
105 dump_line("Old Unique ID: %s\n", h
->old_unique_id
);
108 if((hd_data
->debug
& HD_DEB_CREATION
) && h
->parent_id
) {
109 dump_line("Parent ID: %s\n", h
->parent_id
);
112 if(hd_data
->debug
== -1u && h
->child_ids
) {
113 s
= hd_join(", ", h
->child_ids
);
114 dump_line("Child IDs: %s\n", s
);
119 dump_line("SysFS ID: %s\n", h
->sysfs_id
);
122 if(h
->sysfs_bus_id
) {
123 dump_line("SysFS BusID: %s\n", h
->sysfs_bus_id
);
126 if(h
->sysfs_device_link
) {
127 dump_line("SysFS Device Link: %s\n", h
->sysfs_device_link
);
130 if(h
->hw_class
&& (s
= hd_hw_item_name(h
->hw_class
))) {
131 dump_line("Hardware Class: %s\n", s
);
134 if(hd_data
->debug
== -1u) {
135 for(i
= j
= 0; i
< (int) hw_all
; i
++) {
136 if(i
!= hw_unknown
&& hd_is_hw_class(h
, i
) && (s
= hd_hw_item_name(i
))) {
138 dump_line("HW Class List: %s", s
);
141 dump_line0(", %s", s
);
146 if(j
) dump_line0("\n");
149 if(h
->base_class
.id
== bc_internal
&& h
->sub_class
.id
== sc_int_cpu
) {
150 dump_cpu(hd_data
, h
, f
);
152 else if(h
->base_class
.id
== bc_internal
&& h
->sub_class
.id
== sc_int_bios
) {
153 dump_bios(hd_data
, h
, f
);
155 else if(h
->base_class
.id
== bc_internal
&& h
->sub_class
.id
== sc_int_prom
) {
156 dump_prom(hd_data
, h
, f
);
159 dump_normal(hd_data
, h
, f
);
164 if(h
->base_class
.id
== bc_storage_device
) {
168 s1
= "not configured";
171 if(h
->is
.softraiddisk
) s2
= "soft raid";
172 if(!s1
) { s1
= s2
; s2
= NULL
; }
175 dump_line("Drive status: %s%s%s\n", s1
, s2
? ", " : "", s2
?: "");
179 dump_line_str("Extra Info: ");
180 for(i
= 0, sl
= h
->extra_info
; sl
; sl
= sl
->next
) {
181 dump_line0("%s%s", i
? ", " : "", sl
->str
);
189 h
->status
.configured
||
190 h
->status
.available
||
197 dump_line_str("Config Status: ");
200 if(h
->status
.invalid
) {
201 dump_line0("invalid");
206 dump_line0("%smanual", i
? ", " : "");
210 if(h
->status
.configured
&& (s
= hd_status_value_name(h
->status
.configured
))) {
211 dump_line0("%scfg=%s", i
? ", " : "", s
);
215 if(h
->status
.available
&& (s
= hd_status_value_name(h
->status
.available
))) {
216 dump_line0("%savail=%s", i
? ", " : "", s
);
220 if(h
->status
.needed
&& (s
= hd_status_value_name(h
->status
.needed
))) {
221 dump_line0("%sneed=%s", i
? ", " : "", s
);
225 if(h
->status
.active
&& (s
= hd_status_value_name(h
->status
.active
))) {
226 dump_line0("%sactive=%s", i
? ", " : "", s
);
233 if(hd_data
->debug
== -1u && h
->config_string
) {
234 dump_line("Configured as: \"%s\"\n", h
->config_string
);
239 (hd_tmp
= hd_get_device_by_idx(hd_data
, h
->attached_to
))
241 s
= hd_tmp
->sub_class
.name
?: hd_tmp
->base_class
.name
;
242 dump_line("Attached to: #%u (%s)\n", h
->attached_to
, s
?: "?");
245 if(h
->detail
&& h
->detail
->ccw
.type
==hd_detail_ccw
)
247 dump_line("LCSS: %x.%x\n",h
->detail
->ccw
.data
->lcss
>> 8, h
->detail
->ccw
.data
->lcss
& 0xf);
248 dump_line("CU Model: 0x%x\n",h
->detail
->ccw
.data
->cu_model
);
249 dump_line("Device Model: 0x%x\n",h
->detail
->ccw
.data
->dev_model
);
252 #if defined(__s390__) || defined(__s390x__)
253 if(h
->detail
&& h
->detail
->scsi
.type
==hd_detail_scsi
)
255 if(h
->detail
->scsi
.data
->wwpn
!= (uint64_t)-1)
256 dump_line("WWPN: 0x%llx\n",(unsigned long long)h
->detail
->scsi
.data
->wwpn
);
257 if(h
->detail
->scsi
.data
->wwpn
!= (uint64_t)-1)
258 dump_line("FCP LUN: 0x%llx\n",(unsigned long long)h
->detail
->scsi
.data
->fcp_lun
);
259 dump_line("SCSI Host CCW ID: %s\n",h
->detail
->scsi
.data
->controller_id
);
264 h
->base_class
.id
== bc_storage_device
&&
265 h
->sub_class
.id
== sc_sdev_cdrom
&&
267 h
->detail
->type
== hd_detail_cdrom
&&
268 h
->detail
->cdrom
.data
270 cdrom_info_t
*ci
= h
->detail
->cdrom
.data
;
273 dump_line("Drive Speed: %u\n", ci
->speed
);
277 if(ci
->iso9660
.volume
) dump_line("Volume ID: \"%s\"\n", ci
->iso9660
.volume
);
278 if(ci
->iso9660
.application
) dump_line("Application: \"%s\"\n", ci
->iso9660
.application
);
279 if(ci
->iso9660
.publisher
) dump_line("Publisher: \"%s\"\n", ci
->iso9660
.publisher
);
280 if(ci
->iso9660
.preparer
) dump_line("Preparer: \"%s\"\n", ci
->iso9660
.preparer
);
281 if(ci
->iso9660
.creation_date
) dump_line("Creation date: \"%s\"\n", ci
->iso9660
.creation_date
);
286 dump_line_str("Drive status: non-ISO9660 cdrom\n");
289 dump_line_str("Drive status: no cdrom found\n");
293 if(ci
->el_torito
.ok
) {
295 "El Torito info: platform %u, %sbootable\n",
296 ci
->el_torito
.platform
,
297 ci
->el_torito
.bootable
? "" : "not "
299 dump_line(" Boot Catalog: at sector 0x%04x\n", ci
->el_torito
.catalog
);
300 if(ci
->el_torito
.id_string
) dump_line(" Id String: \"%s\"\n", ci
->el_torito
.id_string
);
301 if(ci
->el_torito
.label
) dump_line(" Volume Label: \"%s\"\n", ci
->el_torito
.label
);
303 static char *media
[] = {
304 "none", "1.2MB Floppy", "1.44MB Floppy", "2.88MB Floppy", "Hard Disk"
307 " Media: %s starting at sector 0x%04x\n",
308 media
[ci
->el_torito
.media_type
< sizeof media
/ sizeof *media
? ci
->el_torito
.media_type
: 0],
312 if(ci
->el_torito
.geo
.size
) dump_line(
313 " Geometry (CHS): %u/%u/%u (%u blocks)\n",
314 ci
->el_torito
.geo
.c
, ci
->el_torito
.geo
.h
, ci
->el_torito
.geo
.s
, ci
->el_torito
.geo
.size
316 dump_line(" Load: %u bytes", ci
->el_torito
.load_count
* 0x200);
317 if(ci
->el_torito
.load_address
) {
318 dump_line0(" at 0x%04x\n", ci
->el_torito
.load_address
);
328 h
->base_class
.id
== bc_storage_device
&&
329 h
->sub_class
.id
== sc_sdev_floppy
&&
331 h
->detail
->type
== hd_detail_floppy
333 floppy_info_t
*fi
= h
->detail
->floppy
.data
;
336 dump_line_str("Drive status: floppy found\n");
339 dump_line_str("Drive status: no floppy found\n");
346 if(h
->next
) dump_line_str("\n");
351 * print 'normal' hardware entries
353 void dump_normal(hd_data_t
*hd_data
, hd_t
*h
, FILE *f
)
359 char buf
[256], c0
, c1
;
361 str_list_t
*sl
, *sl1
, *sl2
;
363 static char *geo_type_str
[] = { "Physical", "Logical", "BIOS EDD", "BIOS Legacy" };
365 if(h
->model
) dump_line("Model: \"%s\"\n", h
->model
);
384 s
= "IEEE1394 (FireWire)";
389 dump_line("Hotplug: %s\n", s
);
393 (h
->hotplug
== hp_pcmcia
|| h
->hotplug
== hp_cardbus
) &&
396 dump_line("Socket: %u\n", h
->hotplug_slot
- 1);
399 if(h
->vendor
.id
|| h
->vendor
.name
|| h
->device
.id
|| h
->device
.name
) {
400 if(h
->vendor
.id
|| h
->vendor
.name
) {
401 dump_line("Vendor: %s\n", dump_hid(hd_data
, &h
->vendor
, 1, buf
, sizeof buf
));
403 dump_line("Device: %s\n", dump_hid(hd_data
, &h
->device
, 0, buf
, sizeof buf
));
406 if(h
->sub_vendor
.id
|| h
->sub_device
.id
|| h
->sub_device
.name
|| h
->sub_vendor
.name
) {
407 if(h
->sub_vendor
.id
|| h
->sub_vendor
.name
|| h
->sub_device
.id
) {
408 dump_line("SubVendor: %s\n", dump_hid(hd_data
, &h
->sub_vendor
, 1, buf
, sizeof buf
));
410 dump_line("SubDevice: %s\n", dump_hid(hd_data
, &h
->sub_device
, 0, buf
, sizeof buf
));
413 if(h
->revision
.name
) {
414 dump_line("Revision: \"%s\"\n", h
->revision
.name
);
416 else if(h
->revision
.id
) {
417 dump_line("Revision: 0x%02x\n", h
->revision
.id
);
421 dump_line("Serial ID: \"%s\"\n", h
->serial
);
425 dump_line("USB GUID: %s\n", h
->usb_guid
);
428 if(h
->compat_vendor
.id
|| h
->compat_device
.id
) {
430 "Compatible to: %s\n",
431 dump_hid2(hd_data
, &h
->compat_vendor
, &h
->compat_device
, buf
, sizeof buf
)
435 if(h
->base_class
.id
== bc_internal
&& h
->sub_class
.id
== sc_int_sys
) {
436 dump_sys(hd_data
, h
, f
);
440 s
= hd_join("\", \"", h
->drivers
);
441 dump_line("Driver: \"%s\"\n", s
);
446 dump_line_str("Warning: might be broken\n");
449 if(hd_data
->flags
.dformat
== 1) {
450 if(h
->unix_dev_name
) {
451 dump_line("Device File: %s\n", h
->unix_dev_name
);
453 if(h
->unix_dev_name2
) {
454 dump_line("Alternative Device File: %s\n", h
->unix_dev_name2
);
458 s
= h
->unix_dev_name
;
459 if(!s
) s
= h
->unix_dev_name2
;
461 dump_line("Device File: %s", s
);
462 if(h
->unix_dev_name2
) {
463 dump_line0(" (%s)", h
->unix_dev_name2
);
470 /* only if there are more than one */
471 if(h
->unix_dev_names
&& h
->unix_dev_names
->next
) {
472 s
= hd_join(", ", h
->unix_dev_names
);
473 dump_line("Device Files: %s\n", s
);
477 if(h
->unix_dev_num
.type
) {
478 dump_line("Device Number: %s", print_dev_num(&h
->unix_dev_num
));
479 if(h
->unix_dev_num2
.type
) {
480 dump_line0(" (%s)", print_dev_num(&h
->unix_dev_num2
));
486 #if defined(__i386__) || defined (__x86_64__)
487 dump_line("BIOS id: %s\n", h
->rom_id
);
489 #if defined(__PPC__) || defined(__sparc__)
490 dump_line("PROM id: %s\n", h
->rom_id
);
492 #if defined(__s390__) || defined(__s390x__)
493 dump_line("IUCV user: %s\n", h
->rom_id
);
497 if(h
->tag
.ser_skip
) {
498 dump_line_str("Tags: ser_skip\n");
503 h
->is
.cdr
|| h
->is
.cdrw
|| h
->is
.dvd
||
504 h
->is
.dvdr
|| h
->is
.dvdram
|| h
->is
.pppoe
|| h
->is
.wlan
506 dump_line_str("Features:");
508 if(h
->is
.zip
) dump_line0("%s ZIP", i
++ ? "," : "");
509 if(h
->is
.cdr
) dump_line0("%s CD-R", i
++ ? "," : "");
510 if(h
->is
.cdrw
) dump_line0("%s CD-RW", i
++ ? "," : "");
511 if(h
->is
.dvd
) dump_line0("%s DVD", i
++ ? "," : "");
512 if(h
->is
.dvdr
) dump_line0("%s DVD-R", i
++ ? "," : "");
513 if(h
->is
.dvdram
) dump_line0("%s DVDRAM", i
++ ? "," : "");
514 if(h
->is
.pppoe
) dump_line0("%s PPPOE", i
++ ? "," : "");
515 if(h
->is
.wlan
) dump_line0("%s WLAN", i
++ ? "," : "");
519 for(res
= h
->res
; res
; res
= res
->next
) {
520 switch(res
->any
.type
) {
522 u64
= res
->phys_mem
.range
>> 10;
529 dump_line("Memory Size: %"PRId64
" %cB + %"PRId64
" %cB\n", u64
>> 10, c0
, u64
& 0x3ff, c1
);
532 dump_line("Memory Size: %"PRId64
" %cB\n", u64
>> 10, c0
);
538 strcat(buf
, res
->mem
.access
== acc_rw
? "rw" : res
->mem
.access
== acc_ro
? "ro" : "wo");
539 strcat(buf
, res
->mem
.prefetch
== flag_yes
? ",prefetchable" : res
->mem
.prefetch
== flag_no
? ",non-prefetchable" : "");
540 if(!res
->mem
.enabled
) strcat(buf
, ",disabled");
544 "Memory Range: 0x%08"PRIx64
"-0x%08"PRIx64
" (%s)\n",
545 res
->mem
.base
, res
->mem
.base
+ res
->mem
.range
- 1, s
549 dump_line("Memory Range: 0x%08"PRIx64
"-??? (%s)\n", res
->mem
.base
, s
);
555 strcat(buf
, res
->io
.access
== acc_rw
? "rw" : res
->io
.access
== acc_ro
? "ro" : "wo");
556 if(!res
->io
.enabled
) strcat(buf
, ",disabled");
558 if(res
->io
.range
== 0) {
559 dump_line("I/O Ports: 0x%02"PRIx64
"-??? (%s)\n", res
->io
.base
, s
);
561 else if(res
->io
.range
== 1) {
562 dump_line("I/O Port: 0x%02"PRIx64
" (%s)\n", res
->io
.base
, s
);
565 dump_line("I/O Ports: 0x%02"PRIx64
"-0x%02"PRIx64
" (%s)\n", res
->io
.base
, res
->io
.base
+ res
->io
.range
-1, s
);
571 switch(res
->irq
.triggered
) {
573 strcpy(s
, "no events");
577 strcpy(s
, "1 event");
581 sprintf(s
, "%u events", res
->irq
.triggered
);
583 if(!res
->irq
.enabled
) {
584 if(res
->irq
.triggered
)
588 strcat(s
, "disabled");
590 dump_line("IRQ: %u (%s)\n", res
->irq
.base
, s
);
595 if(!res
->dma
.enabled
) strcpy(buf
, " (disabled)");
596 dump_line("DMA: %u%s\n", res
->dma
.base
, s
);
601 "Resolution: %ux%u@%uHz%s\n",
602 res
->monitor
.width
, res
->monitor
.height
, res
->monitor
.vfreq
,
603 res
->monitor
.interlaced
? " (interlaced)" : ""
609 char *s
, b0
[64], b1
[64];
611 switch(res
->size
.unit
) {
612 case size_unit_cinch
:
614 snprintf(b0
, sizeof b0
- 1, "%s", float2str(res
->size
.val1
, 2));
615 snprintf(b1
, sizeof b1
- 1, "%s", float2str(res
->size
.val2
, 2));
619 switch(res
->size
.unit
) {
623 case size_unit_sectors
:
626 case size_unit_kbyte
:
632 snprintf(b0
, sizeof b0
- 1, "%"PRIu64
, res
->size
.val1
);
633 snprintf(b1
, sizeof b1
- 1, "%"PRIu64
, res
->size
.val2
);
636 dump_line("Size: %s %s\n", b0
, s
);
637 else if(res
->size
.unit
== size_unit_sectors
)
638 dump_line("Size: %s %s a %s bytes\n", b0
, s
, b1
);
640 dump_line("Size: %sx%s %s\n", b0
, b1
, s
);
645 s
= res
->disk_geo
.geotype
< sizeof geo_type_str
/ sizeof *geo_type_str
?
646 geo_type_str
[res
->disk_geo
.geotype
] : "";
648 "Geometry (%s): CHS %u/%u/%u\n", s
,
649 res
->disk_geo
.cyls
, res
->disk_geo
.heads
, res
->disk_geo
.sectors
651 if(res
->disk_geo
.size
) {
652 dump_line("Size (%s): %"PRIu64
" sectors\n", s
, res
->disk_geo
.size
);
657 dump_line("Cache: %u kb\n", res
->cache
.size
);
661 if(res
->baud
.speed
== 0 || res
->baud
.speed
% 100) {
662 dump_line("Speed: %u bps\n", res
->baud
.speed
);
664 else if(res
->baud
.speed
% 100000) {
665 dump_line("Speed: %s kbps\n", float2str(res
->baud
.speed
, 3));
668 dump_line("Speed: %s Mbps\n", float2str(res
->baud
.speed
, 6));
670 if(res
->baud
.bits
|| res
->baud
.stopbits
|| res
->baud
.parity
|| res
->baud
.handshake
) {
673 dump_line_str("Config: ");
675 dump_line0("%u bits", res
->baud
.bits
);
678 if(res
->baud
.parity
) {
679 dump_line0("%sparity %c", i
++ ? ", " : "", res
->baud
.parity
);
681 if(res
->baud
.stopbits
) {
682 dump_line0("%s%u stopbits", i
++ ? ", " : "", res
->baud
.stopbits
);
684 if(res
->baud
.handshake
) {
685 dump_line0("%shandshake %c", i
++ ? ", " : "", res
->baud
.handshake
);
691 case res_init_strings
:
692 if(res
->init_strings
.init1
) dump_line("Init1: %s\n", res
->init_strings
.init1
);
693 if(res
->init_strings
.init2
) dump_line("Init2: %s\n", res
->init_strings
.init2
);
696 case res_pppd_option
:
697 dump_line("PPPD Option: %s\n", res
->pppd_option
.option
);
700 case res_framebuffer
:
701 dump_line("Mode 0x%04x: %ux%u (+%u), %u bits\n",
702 res
->framebuffer
.mode
,
703 res
->framebuffer
.width
,
704 res
->framebuffer
.height
,
705 res
->framebuffer
.bytes_p_line
,
706 res
->framebuffer
.colorbits
711 dump_line("HW Address: %s\n", res
->hwaddr
.addr
);
715 dump_line("Link detected: %s\n", res
->link
.state
? "yes" : "no");
719 if(res
->wlan
.channels
) {
720 str_list_t
*ptr
= res
->wlan
.channels
;
721 dump_line("WLAN channels: %s", ptr
->str
);
722 while((ptr
=ptr
->next
)) dump_line0(" %s", ptr
->str
);
725 if(res
->wlan
.frequencies
) {
726 str_list_t
*ptr
= res
->wlan
.frequencies
;
727 dump_line("WLAN frequencies: %s", ptr
->str
);
728 while((ptr
=ptr
->next
)) dump_line0(" %s", ptr
->str
);
731 if(res
->wlan
.bitrates
) {
732 str_list_t
*ptr
= res
->wlan
.bitrates
;
733 dump_line("WLAN bitrates: %s", ptr
->str
);
734 while((ptr
=ptr
->next
)) dump_line0(" %s", ptr
->str
);
737 if(res
->wlan
.enc_modes
) {
738 str_list_t
*ptr
= res
->wlan
.enc_modes
;
739 dump_line("WLAN encryption modes: %s", ptr
->str
);
740 while((ptr
=ptr
->next
)) dump_line0(" %s", ptr
->str
);
743 if(res
->wlan
.auth_modes
) {
744 str_list_t
*ptr
= res
->wlan
.auth_modes
;
745 dump_line("WLAN authentication modes: %s", ptr
->str
);
746 while((ptr
=ptr
->next
)) dump_line0(" %s", ptr
->str
);
753 dump_line("Unknown resource type %d\n", res
->any
.type
);
757 if((sl
= h
->requires
)) {
758 dump_line("Requires: %s", sl
->str
);
759 for(sl
= sl
->next
; sl
; sl
= sl
->next
) {
760 dump_line0(", %s", sl
->str
);
765 for(di
= h
->driver_info
, i
= 0; di
; di
= di
->next
, i
++) {
766 dump_line("Driver Info #%d:\n", i
);
768 switch(di
->any
.type
) {
770 dump_line_str("Driver Info:");
771 for(sl
= di
->any
.hddb0
, j
= 0; sl
; sl
= sl
->next
, j
++) {
772 dump_line0("%c%s", j
? ',' : ' ', sl
->str
);
778 if(di
->display
.width
)
779 dump_line("Max. Resolution: %ux%u\n", di
->display
.width
, di
->display
.height
);
780 if(di
->display
.min_vsync
)
781 dump_line("Vert. Sync Range: %u-%u Hz\n", di
->display
.min_vsync
, di
->display
.max_vsync
);
782 if(di
->display
.min_hsync
)
783 dump_line("Hor. Sync Range: %u-%u kHz\n", di
->display
.min_hsync
, di
->display
.max_hsync
);
784 if(di
->display
.bandwidth
)
785 dump_line("Bandwidth: %u MHz\n", di
->display
.bandwidth
);
789 dump_line_str("Driver Status: ");
790 for(sl1
= di
->module
.names
; sl1
; sl1
= sl1
->next
) {
791 dump_line0("%s%c", sl1
->str
, sl1
->next
? ',' : ' ');
793 dump_line0("%s %sactive\n",
794 di
->module
.names
->next
? "are" : "is",
795 di
->module
.active
? "" : "not "
798 dump_line_str("Driver Activation Cmd: \"");
799 for(sl1
= di
->module
.names
, sl2
= di
->module
.mod_args
; sl1
&& sl2
; sl1
= sl1
->next
, sl2
= sl2
->next
) {
800 dump_line0("%s %s%s%s%s",
801 di
->module
.modprobe
? "modprobe" : "insmod",
804 sl2
->str
? sl2
->str
: "",
805 (sl1
->next
&& sl2
->next
) ? "; " : ""
811 if(di
->module
.conf
) {
812 char *s
= di
->module
.conf
;
814 dump_line_str("Driver \"modules.conf\" Entry: \"");
817 dump_line0("%c", *s
);
821 case '\n': dump_line0("\\n"); break;
822 case '\r': dump_line0("\\r"); break;
823 case '\t': dump_line0("\t"); break; /* *no* typo! */
824 default: dump_line0("\\%03o", *s
);
833 if(di
->mouse
.buttons
>= 0) dump_line("Buttons: %d\n", di
->mouse
.buttons
);
834 if(di
->mouse
.wheels
>= 0) dump_line("Wheels: %d\n", di
->mouse
.wheels
);
835 if(di
->mouse
.xf86
) dump_line("XFree86 Protocol: %s\n", di
->mouse
.xf86
);
836 if(di
->mouse
.gpm
) dump_line("GPM Protocol: %s\n", di
->mouse
.gpm
);
842 "XFree86 v%s Server%s: %s\n",
843 di
->x11
.xf86_ver
, strcmp(di
->x11
.xf86_ver
, "4") ? "" : " Module", di
->x11
.server
846 if(di
->x11
.x3d
) dump_line_str("3D Support: yes\n");
847 if(di
->x11
.script
) dump_line("3D Script: %s\n", di
->x11
.script
);
848 if(di
->x11
.colors
.all
) {
849 dump_line_str("Color Depths: ");
851 if(di
->x11
.colors
.c8
) { dump_line0("8"); j
++; }
852 if(di
->x11
.colors
.c15
) { if(j
) dump_line0(", "); dump_line0("15"); j
++; }
853 if(di
->x11
.colors
.c16
) { if(j
) dump_line0(", "); dump_line0("16"); j
++; }
854 if(di
->x11
.colors
.c24
) { if(j
) dump_line0(", "); dump_line0("24"); j
++; }
855 if(di
->x11
.colors
.c32
) { if(j
) dump_line0(", "); dump_line0("32"); j
++; }
858 if(di
->x11
.dacspeed
) dump_line("Max. DAC Clock: %u MHz\n", di
->x11
.dacspeed
);
859 if(di
->x11
.extensions
) {
860 dump_line("Extensions: %s", di
->x11
.extensions
->str
);
861 for(sl
= di
->x11
.extensions
->next
; sl
; sl
= sl
->next
) {
862 dump_line0(", %s", sl
->str
);
866 if(di
->x11
.options
) {
867 dump_line("Options: %s", di
->x11
.options
->str
);
868 for(sl
= di
->x11
.options
->next
; sl
; sl
= sl
->next
) {
869 dump_line0(", %s", sl
->str
);
874 dump_line("XF86Config Entry: %s", di
->x11
.raw
->str
);
875 for(sl
= di
->x11
.raw
->next
; sl
; sl
= sl
->next
) {
876 dump_line0("\\n%s", sl
->str
);
884 "I4L Type: %d/%d [%s]\n",
885 di
->isdn
.i4l_type
, di
->isdn
.i4l_subtype
, di
->isdn
.i4l_name
887 if((ip
= di
->isdn
.params
)) {
890 dump_line_str("Parameter:\n");
891 for(k
= 0; ip
; ip
= ip
->next
, k
++) {
893 " %d%s: (0x%x/%02x): %s = 0x%"PRIx64
,
894 k
, ip
->conflict
? "(conflict)" : ip
->valid
? "" : "(invalid)",
895 ip
->type
, ip
->flags
>> 8, ip
->name
, ip
->value
898 for(l
= 0; l
< ip
->alt_values
; l
++) {
900 "%s%s0x%x", l
? "," : " [",
901 ip
->alt_value
[l
] == ip
->def_value
? "*" : "",
924 if(di
->kbd
.XkbRules
) dump_line("XkbRules: %s\n", di
->kbd
.XkbRules
);
925 if(di
->kbd
.XkbModel
) dump_line("XkbModel: %s\n", di
->kbd
.XkbModel
);
926 if(di
->kbd
.XkbLayout
) dump_line("XkbLayout: %s\n", di
->kbd
.XkbLayout
);
927 if(di
->kbd
.keymap
) dump_line("keymap: %s\n", di
->kbd
.keymap
);
931 dump_line_str("Driver Status: unknown driver info format\n");
934 if((hd_data
->debug
& HD_DEB_DRIVER_INFO
)) {
935 for(sl
= di
->any
.hddb0
, j
= 0; sl
; sl
= sl
->next
, j
++) {
937 dump_line0("|%s", sl
->str
);
940 dump_line("Driver DB0: %d, %s", di
->any
.type
, sl
->str
);
943 if(di
->any
.hddb0
) dump_line0("\n");
945 for(sl
= di
->any
.hddb1
, j
= 0; sl
; sl
= sl
->next
, j
++) {
946 if(!j
) dump_line_str("Driver DB1: \"");
947 dump_line0("%s\\n", sl
->str
);
949 if(di
->any
.hddb1
) dump_line0("\"\n");
959 void dump_cpu(hd_data_t
*hd_data
, hd_t
*hd
, FILE *f
)
964 if(!hd
->detail
|| hd
->detail
->type
!= hd_detail_cpu
) return;
965 if(!(ct
= hd
->detail
->cpu
.data
)) return;
967 dump_line0 (" Arch: ");
968 switch (ct
->architecture
) {
970 dump_line0 ("Intel\n");
973 dump_line0 ("Alpha\n");
976 dump_line0 ("Sparc (32)\n");
979 dump_line0 ("UltraSparc (64)\n");
982 dump_line0 ("PowerPC\n");
985 dump_line0 ("PowerPC (64)\n");
988 dump_line0 ("68k\n");
991 dump_line0 ("IA-64\n");
994 dump_line0 ("S390\n");
997 dump_line0 ("S390x\n");
1000 dump_line0 ("ARM\n");
1003 dump_line0 ("MIPS\n");
1006 dump_line0 ("X86-64\n");
1009 dump_line0 ("**UNKNWON**\n");
1013 if(ct
->vend_name
) dump_line("Vendor: \"%s\"\n", ct
->vend_name
);
1017 "Model: %u.%u.%u \"%s\"\n",
1018 ct
->family
, ct
->model
, ct
->stepping
, ct
->model_name
1021 if(ct
->platform
) dump_line("Platform: \"%s\"\n", ct
->platform
);
1024 dump_line("Features: %s", ct
->features
->str
);
1025 for(sl
= ct
->features
->next
; sl
; sl
= sl
->next
) {
1026 dump_line0(",%s", sl
->str
);
1031 if(ct
->clock
) dump_line("Clock: %u MHz\n", ct
->clock
);
1033 if(ct
->cache
) dump_line("Cache: %u kb\n", ct
->cache
);
1034 if(ct
->units
) dump_line("Units/Processor: %u\n", ct
->units
);
1039 * print BIOS entries
1041 void dump_bios(hd_data_t
*hd_data
, hd_t
*hd
, FILE *f
)
1045 if(!hd
->detail
|| hd
->detail
->type
!= hd_detail_bios
) return;
1046 if(!(bt
= hd
->detail
->bios
.data
)) return;
1049 dump_line("VESA BIOS Version: %u.%u\n", bt
->vbe_ver
>> 8, bt
->vbe_ver
& 0xff);
1052 if(bt
->vbe_video_mem
) {
1053 dump_line("Video Memory: %u kb\n", bt
->vbe_video_mem
>> 10);
1056 if(bt
->vbe
.ok
&& bt
->vbe
.current_mode
) {
1057 dump_line("Current VESA Mode: 0x%04x\n", bt
->vbe
.current_mode
);
1060 if(bt
->apm_supported
) {
1061 dump_line("APM Version: %u.%u\n", bt
->apm_ver
, bt
->apm_subver
);
1062 dump_line("APM Status: %s\n", bt
->apm_enabled
? "on" : "off");
1063 dump_line("APM BIOS Flags: 0x%x\n", bt
->apm_bios_flags
);
1067 dump_line_str("BIOS Keyboard LED Status:\n");
1068 dump_line(" Scroll Lock: %s\n", bt
->led
.scroll_lock
? "on" : "off");
1069 dump_line(" Num Lock: %s\n", bt
->led
.num_lock
? "on" : "off");
1070 dump_line(" Caps Lock: %s\n", bt
->led
.caps_lock
? "on" : "off");
1073 if(bt
->ser_port0
) dump_line("Serial Port 0: 0x%x\n", bt
->ser_port0
);
1074 if(bt
->ser_port1
) dump_line("Serial Port 1: 0x%x\n", bt
->ser_port1
);
1075 if(bt
->ser_port2
) dump_line("Serial Port 2: 0x%x\n", bt
->ser_port2
);
1076 if(bt
->ser_port3
) dump_line("Serial Port 3: 0x%x\n", bt
->ser_port3
);
1078 if(bt
->par_port0
) dump_line("Parallel Port 0: 0x%x\n", bt
->par_port0
);
1079 if(bt
->par_port1
) dump_line("Parallel Port 1: 0x%x\n", bt
->par_port1
);
1080 if(bt
->par_port2
) dump_line("Parallel Port 2: 0x%x\n", bt
->par_port2
);
1082 if(bt
->low_mem_size
) dump_line("Base Memory: %u kB\n", bt
->low_mem_size
>> 10);
1084 if(bt
->is_pnp_bios
) {
1085 char *s
= isa_id2str(bt
->pnp_id
);
1086 dump_line("PnP BIOS: %s\n", s
);
1090 if(bt
->lba_support
) {
1091 dump_line_str("BIOS: extended read supported\n");
1095 dump_line("MP spec rev 1.%u info:\n", bt
->smp
.rev
);
1096 dump_line(" OEM id: \"%s\"\n", bt
->smp
.oem_id
);
1097 dump_line(" Product id: \"%s\"\n", bt
->smp
.prod_id
);
1098 dump_line(" %u CPUs (%u disabled)\n", bt
->smp
.cpus
, bt
->smp
.cpus
- bt
->smp
.cpus_en
);
1102 dump_line("BIOS32 Service Directory Entry: 0x%05x\n", bt
->bios32
.entry
);
1105 if(bt
->smbios_ver
) {
1106 dump_line("SMBIOS Version: %u.%u\n", bt
->smbios_ver
>> 8, bt
->smbios_ver
& 0xff);
1109 smbios_dump(hd_data
, f
);
1114 * print PROM entries
1116 void dump_prom(hd_data_t
*hd_data
, hd_t
*hd
, FILE *f
)
1121 if(!hd
->detail
|| hd
->detail
->type
!= hd_detail_prom
) return;
1122 if(!(pt
= hd
->detail
->prom
.data
)) return;
1125 // ###########################
1126 // s = hd_device_name(hd_data, MAKE_ID(TAG_SPECIAL, 0x0300), MAKE_ID(TAG_SPECIAL, pt->color));
1129 dump_line("Color: %s (0x%02x)\n", s
, pt
->color
);
1131 dump_line("Color: 0x%02x\n", pt
->color
);
1137 * print System entries
1139 void dump_sys(hd_data_t
*hd_data
, hd_t
*hd
, FILE *f
)
1143 if(!hd
->detail
|| hd
->detail
->type
!= hd_detail_sys
) return;
1144 if(!(st
= hd
->detail
->sys
.data
)) return;
1146 if(st
->system_type
) {
1147 dump_line("SystemType: \"%s\"\n", st
->system_type
);
1149 if(st
->generation
) {
1150 dump_line("Generation: \"%s\"\n", st
->generation
);
1154 dump_line("Language: \"%s\"\n", st
->lang
);
1159 char *dump_hid(hd_data_t
*hd_data
, hd_id_t
*hid
, int format
, char *buf
, int buf_size
)
1168 t
= ID_TAG(hid
->id
);
1169 id
= ID_VALUE(hid
->id
);
1171 if(format
&& t
== TAG_EISA
) {
1172 snprintf(buf
, buf_size
- 1, "%s", eisa_vendor_str(id
));
1175 snprintf(buf
, buf_size
- 1, "%s0x%04x", hid_tag_name2(t
), id
);
1187 if(!buf_size
) return buf
;
1190 snprintf(s
, buf_size
- 1, "\"%s\"", hid
->name
);
1196 char *dump_hid2(hd_data_t
*hd_data
, hd_id_t
*hid1
, hd_id_t
*hid2
, char *buf
, int buf_size
)
1200 unsigned t
, id1
, id2
;
1205 if(hid1
->id
) t
= ID_TAG(hid1
->id
);
1206 if(hid2
->id
) t
= ID_TAG(hid2
->id
);
1208 id1
= ID_VALUE(hid1
->id
);
1209 id2
= ID_VALUE(hid2
->id
);
1211 if(hid1
->id
|| hid2
->id
) {
1213 snprintf(buf
, buf_size
- 1, "%s 0x%04x", eisa_vendor_str(id1
), id2
);
1216 snprintf(buf
, buf_size
- 1, "%s0x%04x 0x%04x", hid_tag_name2(t
), id1
, id2
);
1224 if(!buf_size
) return buf
;
1227 snprintf(s
, buf_size
- 1, " \"%s\"", hid2
->name
);
1234 char *print_dev_num(hd_dev_num_t
*d
)
1236 static char *buf
= NULL
;
1239 str_printf(&buf
, 0, "%s %u:%u",
1240 d
->type
== 'b' ? "block" : "char",
1244 str_printf(&buf
, -1, "-%u:%u",
1245 d
->major
, d
->minor
+ d
->range
- 1
1250 str_printf(&buf
, 0, "%s", "");
1257 #else /* ifndef LIBHD_TINY */
1259 void hd_dump_entry(hd_data_t
*hd_data
, hd_t
*h
, FILE *f
) { }
1261 #endif /* ifndef LIBHD_TINY */