]>
git.ipfire.org Git - people/ummeegge/ipfire-2.x.git/blob - src/hwinfo/src/hd/int.c
5 typedef unsigned long kernel_ulong_t
;
6 #include <linux/types.h>
12 #include <sys/types.h>
19 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
22 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
25 static void int_hotplug(hd_data_t
*hd_data
);
26 static void int_cdrom(hd_data_t
*hd_data
);
27 #if defined(__i386__) || defined (__x86_64__)
28 static int set_bios_id(hd_data_t
*hd_data
, hd_t
*hd_ref
, int bios_id
);
29 static int bios_ctrl_order(hd_data_t
*hd_data
, unsigned *sctrl
, int sctrl_len
);
30 static void int_bios(hd_data_t
*hd_data
);
32 static void int_media_check(hd_data_t
*hd_data
);
33 static int contains_word(char *str
, char *str2
);
34 static int is_zip(hd_t
*hd
);
35 static void int_floppy(hd_data_t
*hd_data
);
36 static void int_fix_usb_scsi(hd_data_t
*hd_data
);
37 static void int_mouse(hd_data_t
*hd_data
);
38 static void new_id(hd_data_t
*hd_data
, hd_t
*hd
);
39 static void int_modem(hd_data_t
*hd_data
);
40 static void int_wlan(hd_data_t
*hd_data
);
41 static void int_udev(hd_data_t
*hd_data
);
42 static void int_devicenames(hd_data_t
*hd_data
);
43 #if defined(__i386__) || defined (__x86_64__)
44 static void int_softraid(hd_data_t
*hd_data
);
46 #if defined(__i386__) || defined (__x86_64__)
47 static void int_system(hd_data_t
*hd_data
);
48 static void int_legacy_geo(hd_data_t
*hd_data
);
51 void hd_scan_int(hd_data_t
*hd_data
)
55 if(!hd_probe_feature(hd_data
, pr_int
)) return;
57 hd_data
->module
= mod_int
;
60 remove_hd_entries(hd_data
);
62 PROGRESS(2, 0, "cdrom");
65 PROGRESS(3, 0, "media");
66 int_media_check(hd_data
);
68 PROGRESS(4, 0, "floppy");
71 #if defined(__i386__) || defined (__x86_64__)
72 PROGRESS(5, 0, "bios");
76 PROGRESS(6, 0, "mouse");
79 #if defined(__i386__) || defined (__x86_64__)
80 PROGRESS(15, 0, "system info");
84 PROGRESS(7, 0, "hdb");
85 hd_data
->flags
.keep_kmods
= 1;
86 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
87 hddb_add_info(hd_data
, hd
);
89 hd_data
->flags
.keep_kmods
= 0;
91 PROGRESS(8, 0, "usbscsi");
92 int_fix_usb_scsi(hd_data
);
94 PROGRESS(9, 0, "hotplug");
97 PROGRESS(10, 0, "modem");
100 PROGRESS(11, 0, "wlan");
103 PROGRESS(12, 0, "udev");
106 PROGRESS(13, 0, "device names");
107 int_devicenames(hd_data
);
109 #if defined(__i386__) || defined (__x86_64__)
110 PROGRESS(14, 0, "soft raid");
111 int_softraid(hd_data
);
113 PROGRESS(15, 0, "geo");
114 int_legacy_geo(hd_data
);
120 * Identify hotpluggable devices.
122 void int_hotplug(hd_data_t
*hd_data
)
126 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
127 if(hd
->bus
.id
== bus_usb
|| hd
->usb_guid
) {
128 hd
->hotplug
= hp_usb
;
134 * Add more info to CDROM entries.
136 void int_cdrom(hd_data_t
*hd_data
)
140 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
142 hd
->base_class
.id
== bc_storage_device
&&
143 hd
->sub_class
.id
== sc_sdev_cdrom
&&
146 if(hd
->device
.name
&& strstr(hd
->device
.name
, "DVD")) {
153 #if defined(__i386__) || defined (__x86_64__)
155 int set_bios_id(hd_data_t
*hd_data
, hd_t
*hd_ref
, int bios_id
)
160 if(!hd_ref
|| !hd_ref
->unix_dev_name
) return 0;
162 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
164 hd
->base_class
.id
== bc_storage_device
&&
165 hd
->sub_class
.id
== sc_sdev_disk
&&
167 !strcmp(hd
->unix_dev_name
, hd_ref
->unix_dev_name
)
169 str_printf(&hd
->rom_id
, 0, "0x%02x", bios_id
);
178 int bios_ctrl_order(hd_data_t
*hd_data
, unsigned *sctrl
, int sctrl_len
)
182 int i
, j
, k
, sctrl2_len
= 0;
183 unsigned pci_slot
, pci_func
;
184 unsigned *sctrl2
= NULL
, *sctrl3
= NULL
;
187 for(bt
= NULL
, hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
189 hd
->base_class
.id
== bc_internal
&&
190 hd
->sub_class
.id
== sc_int_bios
&&
192 hd
->detail
->type
== hd_detail_bios
&&
193 (bt
= hd
->detail
->bios
.data
)
199 if(!bt
|| !bt
->bios32
.ok
|| !bt
->bios32
.compaq
) return 0;
201 sctrl2
= new_mem((sizeof bt
->bios32
.cpq_ctrl
/ sizeof *bt
->bios32
.cpq_ctrl
) * sizeof *sctrl2
);
203 for(i
= 0; (unsigned) i
< sizeof bt
->bios32
.cpq_ctrl
/ sizeof *bt
->bios32
.cpq_ctrl
; i
++) {
205 bt
->bios32
.cpq_ctrl
[i
].id
&&
206 !(bt
->bios32
.cpq_ctrl
[i
].misc
& 0x40) /* bios support ??????? */
208 pci_slot
= PCI_SLOT(bt
->bios32
.cpq_ctrl
[i
].devfn
) + (bt
->bios32
.cpq_ctrl
[i
].bus
<< 8);
209 pci_func
= PCI_FUNC(bt
->bios32
.cpq_ctrl
[i
].devfn
);
210 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
211 if(hd
->bus
.id
== bus_pci
&& hd
->slot
== pci_slot
&& hd
->func
== pci_func
) {
212 sctrl2
[sctrl2_len
++] = hd
->idx
;
219 if(sctrl2_len
) order_info
= 1;
221 for(i
= 0; i
< sctrl2_len
; i
++) {
222 ADD2LOG(" bios ord %d: %d\n", i
, sctrl2
[i
]);
227 sctrl3
= new_mem(sctrl_len
* sizeof *sctrl3
);
230 for(i
= 0; i
< sctrl2_len
; i
++) {
231 for(j
= 0; j
< sctrl_len
; j
++) {
232 if(sctrl
[j
] == sctrl2
[i
]) {
233 sctrl3
[k
++] = sctrl
[j
];
240 for(i
= 0; i
< sctrl_len
; i
++) {
241 if(sctrl
[i
] && k
< sctrl_len
) sctrl3
[k
++] = sctrl
[i
];
244 memcpy(sctrl
, sctrl3
, sctrl_len
* sizeof *sctrl
);
253 void int_bios(hd_data_t
*hd_data
)
256 unsigned *sctrl
, *sctrl2
;
258 int bios_id
, list_sorted
;
260 /* don't do anything if there is useful edd info */
261 if(hd_data
->flags
.edd_used
) return;
263 for(i
= 0, hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
265 hd
->base_class
.id
== bc_storage_device
&&
266 hd
->sub_class
.id
== sc_sdev_disk
274 sctrl
= new_mem(i
* sizeof *sctrl
);
276 /* sctrl: list of storage controllers with disks */
278 for(sctrl_len
= 0, hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
280 hd
->base_class
.id
== bc_storage_device
&&
281 hd
->sub_class
.id
== sc_sdev_disk
283 for(i
= 0; i
< sctrl_len
; i
++) {
284 if(sctrl
[i
] == hd
->attached_to
) break;
286 if(i
== sctrl_len
) sctrl
[sctrl_len
++] = hd
->attached_to
;
290 /* sort list, if possible */
292 list_sorted
= bios_ctrl_order(hd_data
, sctrl
, sctrl_len
);
294 hd_boot
= hd_get_device_by_idx(hd_data
, hd_boot_disk(hd_data
, &i
));
296 /* if we know the boot device, make this controller the first */
298 if(hd_boot
&& hd_boot
->attached_to
&& i
== 1) {
299 for(i
= 0; i
< sctrl_len
; i
++) {
300 if(sctrl
[i
] == hd_boot
->attached_to
) break;
303 sctrl2
= new_mem(sctrl_len
* sizeof *sctrl2
);
304 *sctrl2
= hd_boot
->attached_to
;
305 for(i
= 0, j
= 1; i
< sctrl_len
; i
++) {
306 if(sctrl
[i
] != hd_boot
->attached_to
) sctrl2
[j
++] = sctrl
[i
];
316 if(hd_boot
) ADD2LOG(" bios boot dev: %d\n", hd_boot
->idx
);
317 for(i
= 0; i
< sctrl_len
; i
++) {
318 ADD2LOG(" bios ctrl %d: %d\n", i
, sctrl
[i
]);
321 /* remove existing entries */
323 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
325 hd
->base_class
.id
== bc_storage_device
&&
326 hd
->sub_class
.id
== sc_sdev_disk
328 hd
->rom_id
= free_mem(hd
->rom_id
);
332 if(!list_sorted
&& !hd_boot
&& sctrl_len
> 1) {
333 /* we have no info at all */
336 else if(!list_sorted
&& hd_boot
&& sctrl_len
> 2) {
337 /* we know which controller has the boot device */
346 bios_id
+= set_bios_id(hd_data
, hd_boot
, bios_id
);
349 /* assign all the others */
351 for(i
= 0; i
< sctrl_len
; i
++) {
352 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
354 hd
->base_class
.id
== bc_storage_device
&&
355 hd
->sub_class
.id
== sc_sdev_disk
&&
356 hd
->attached_to
== sctrl
[i
] &&
359 bios_id
+= set_bios_id(hd_data
, hd
, bios_id
);
369 void int_bios(hd_data_t
*hd_data
)
372 int i
, start
, bios
= 0x80;
374 char ide_name
[] = "/dev/hda";
375 char scsi_name
[] = "/dev/sda";
378 hd_boot
= hd_get_device_by_idx(hd_data
, hd_boot_disk(hd_data
, &i
));
381 free_mem(hd_boot
->rom_id
);
382 hd_boot
->rom_id
= new_str("0x80");
385 if(!hd_boot
|| i
!= 1) return;
387 if(strstr(hd_boot
->unix_dev_name
, "/dev/sd") == hd_boot
->unix_dev_name
) {
389 start
= hd_boot
->unix_dev_name
[sizeof "/dev/sd" - 1] - 'a';
391 else if(strstr(hd_boot
->unix_dev_name
, "/dev/hd") == hd_boot
->unix_dev_name
) {
393 start
= hd_boot
->unix_dev_name
[sizeof "/dev/hd" - 1] - 'a';
399 if(start
< 0) return;
401 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
403 hd
->base_class
.id
== bc_storage_device
&&
404 hd
->sub_class
.id
== sc_sdev_disk
406 hd
->rom_id
= free_mem(hd
->rom_id
);
410 s
= ide_1st
? ide_name
: scsi_name
;
412 for(i
= start
; i
< 26; i
++) {
413 s
[strlen(s
) - 1] = 'a' + i
;
414 bios
+= set_bios_id(hd_data
, s
, bios
);
417 for(i
= 0; i
< start
; i
++) {
418 s
[strlen(s
) - 1] = 'a' + i
;
419 bios
+= set_bios_id(hd_data
, s
, bios
);
422 s
= ide_1st
? scsi_name
: ide_name
;
424 for(i
= 0; i
< 26; i
++) {
425 s
[strlen(s
) - 1] = 'a' + i
;
426 bios
+= set_bios_id(hd_data
, s
, bios
);
430 #endif /* defined(__i386__) || defined (__x86_64__) */
433 * Try to read block 0 for block devices.
435 void int_media_check(hd_data_t
*hd_data
)
440 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
441 if(!hd_report_this(hd_data
, hd
)) continue;
443 hd
->base_class
.id
== bc_storage_device
&&
445 /* hd->sub_class.id == sc_sdev_cdrom || */ /* cf. cdrom.c */
446 hd
->sub_class
.id
== sc_sdev_disk
||
447 hd
->sub_class
.id
== sc_sdev_floppy
452 hd
->status
.available
!= status_no
455 PROGRESS(4, ++j
, hd
->unix_dev_name
);
456 hd
->block0
= read_block0(hd_data
, hd
->unix_dev_name
, &i
);
457 hd
->is
.notready
= hd
->block0
? 0 : 1;
464 * Check if str has str2 in it.
466 int contains_word(char *str
, char *str2
)
468 int i
, len
, len2
, found
= 0;
471 if(!str2
|| !*str2
|| !str
|| !*str
) return 0;
478 for(i
= 0; i
< len
; i
++) {
479 if(str
[i
] >= 'a' && str
[i
] <= 'z') str
[i
] -= 'a' - 'A';
482 for(s
= str
; (s
= strstr(s
, str2
)); s
++) {
484 (s
== str
|| s
[-1] < 'A' || s
[-1] > 'Z') &&
485 (s
[len2
] < 'A' || s
[len2
] > 'Z')
499 * Check for zip drive.
504 hd
->base_class
.id
== bc_storage_device
&&
506 hd
->sub_class
.id
== sc_sdev_disk
||
507 hd
->sub_class
.id
== sc_sdev_floppy
512 contains_word(hd
->vendor
.name
, "IOMEGA") ||
513 contains_word(hd
->sub_vendor
.name
, "IOMEGA") ||
514 contains_word(hd
->device
.name
, "IOMEGA") ||
515 contains_word(hd
->sub_device
.name
, "IOMEGA")
517 contains_word(hd
->device
.name
, "ZIP") ||
518 contains_word(hd
->sub_device
.name
, "ZIP")
530 * Turn some drives into floppies.
532 void int_floppy(hd_data_t
*hd_data
)
537 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
538 if(is_zip(hd
)) hd
->is
.zip
= 1;
540 hd
->base_class
.id
== bc_storage_device
&&
541 hd
->sub_class
.id
== sc_sdev_disk
544 hd
->sub_class
.id
= sc_sdev_floppy
;
548 /* make everything a floppy that is 1440k */
549 for(res
= hd
->res
; res
; res
= res
->next
) {
551 res
->any
.type
== res_size
&&
552 res
->size
.unit
== size_unit_sectors
&&
553 res
->size
.val1
== 2880 &&
554 res
->size
.val2
== 512
556 hd
->sub_class
.id
= sc_sdev_floppy
;
567 #define COPY_ENTRY(a) if(hd_scsi->a) { free_mem(hd_usb->a); hd_usb->a = new_str(hd_scsi->a); }
569 * Remove usb entries that are handled by usb-storage.
571 void int_fix_usb_scsi(hd_data_t
*hd_data
)
573 hd_t
*hd_scsi
, *hd_usb
;
575 for(hd_usb
= hd_data
->hd
; hd_usb
; hd_usb
= hd_usb
->next
) {
577 hd_usb
->bus
.id
== bus_usb
&&
579 search_str_list(hd_usb
->drivers
, "usb-storage")
581 for(hd_scsi
= hd_data
->hd
; hd_scsi
; hd_scsi
= hd_scsi
->next
) {
583 hd_scsi
->bus
.id
== bus_scsi
&&
584 hd_scsi
->sysfs_device_link
&&
585 search_str_list(hd_scsi
->drivers
, "usb-storage")
587 if(!strncmp(hd_scsi
->sysfs_device_link
, hd_usb
->sysfs_id
, strlen(hd_usb
->sysfs_id
))) {
588 hd_set_hw_class(hd_scsi
, hw_usb
);
590 free_mem(hd_scsi
->unique_id
);
591 hd_scsi
->unique_id
= hd_usb
->unique_id
;
592 hd_usb
->unique_id
= NULL
;
594 add_res_entry(&hd_scsi
->res
, hd_usb
->res
);
597 new_id(hd_data
, hd_scsi
);
599 hd_usb
->tag
.remove
= 1;
610 for(hd_scsi
= hd_data
->hd
; hd_scsi
; hd_scsi
= hd_scsi
->next
) {
612 hd_scsi
->bus
.id
== bus_scsi
&&
614 search_str_list(hd_scsi
->drivers
, "usb-storage")
616 for(hd_usb
= hd_data
->hd
; hd_usb
; hd_usb
= hd_usb
->next
) {
618 hd_usb
->bus
.id
== bus_usb
&&
620 !hd_usb
->tag
.remove
&&
621 !strcmp(hd_usb
->usb_guid
, hd_scsi
->usb_guid
) &&
623 hd_usb
->detail
->type
== hd_detail_usb
&&
624 (usb
= hd_usb
->detail
->usb
.data
) &&
626 !strcmp(usb
->driver
, "usb-storage")
628 hd_scsi
->tag
.remove
= 1;
630 /* join usb & scsi info */
631 hd_usb
->bus
.id
= hd_scsi
->bus
.id
;
632 COPY_ENTRY(bus
.name
);
633 hd_usb
->base_class
.id
= hd_scsi
->base_class
.id
;
634 COPY_ENTRY(base_class
.name
);
635 hd_usb
->sub_class
.id
= hd_scsi
->sub_class
.id
;
636 COPY_ENTRY(sub_class
.name
);
637 hd_usb
->prog_if
.id
= hd_scsi
->prog_if
.id
;
638 COPY_ENTRY(prog_if
.name
);
639 COPY_ENTRY(unix_dev_name
);
641 // ###### FIXME?: COPY_ENTRY(driver)
643 hd_usb
->vendor
.id
= hd_scsi
->vendor
.id
;
644 COPY_ENTRY(vendor
.name
);
645 hd_usb
->device
.id
= hd_scsi
->device
.id
;
646 COPY_ENTRY(device
.name
);
647 hd_usb
->sub_vendor
.name
= free_mem(hd_usb
->sub_vendor
.name
);
648 COPY_ENTRY(sub_vendor
.name
);
649 hd_usb
->sub_device
.name
= free_mem(hd_usb
->sub_device
.name
);
650 COPY_ENTRY(sub_device
.name
);
651 COPY_ENTRY(revision
.name
);
654 hd_usb
->is
.notready
= hd_scsi
->is
.notready
;
655 if(hd_usb
->block0
) free_mem(hd_usb
->block0
);
656 hd_usb
->block0
= hd_scsi
->block0
;
657 hd_scsi
->block0
= NULL
;
658 add_res_entry(&hd_usb
->res
, hd_scsi
->res
);
661 new_id(hd_data
, hd_usb
);
670 remove_tagged_hd_entries(hd_data
);
676 * Improve mouse info.
678 void int_mouse(hd_data_t
*hd_data
)
681 bios_info_t
*bt
= NULL
;
683 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
686 hd
->detail
->type
== hd_detail_bios
&&
687 (bt
= hd
->detail
->bios
.data
) &&
694 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
696 hd
->base_class
.id
== bc_mouse
&&
697 hd
->sub_class
.id
== sc_mou_ps2
&&
698 hd
->bus
.id
== bt
->mouse
.bus
&&
699 hd
->vendor
.id
== MAKE_ID(TAG_SPECIAL
, 0x0200) &&
700 hd
->device
.id
== MAKE_ID(TAG_SPECIAL
, 0x0002)
702 hd
->vendor
.name
= free_mem(hd
->vendor
.name
);
703 hd
->device
.name
= free_mem(hd
->device
.name
);
704 hd
->vendor
.id
= hd
->device
.id
= 0;
706 hd
->vendor
.id
= bt
->mouse
.compat_vend
;
707 hd
->device
.id
= bt
->mouse
.compat_dev
;
709 hd
->vendor
.name
= new_str(bt
->mouse
.vendor
);
710 hd
->device
.name
= new_str(bt
->mouse
.type
);
711 hd
->compat_vendor
.id
= bt
->mouse
.compat_vend
;
712 hd
->compat_device
.id
= bt
->mouse
.compat_dev
;
720 void new_id(hd_data_t
*hd_data
, hd_t
*hd
)
723 hd
->unique_id
= free_mem(hd
->unique_id
);
724 hd
->unique_id1
= free_mem(hd
->unique_id1
);
725 hd
->old_unique_id
= free_mem(hd
->old_unique_id
);
726 hd_add_id(hd_data
, hd
);
732 * Assign device names to (win-)modems.
734 void int_modem(hd_data_t
*hd_data
)
738 hd_dev_num_t dev_num
= { type
: 'c', range
: 1 };
741 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
743 hd
->base_class
.id
== bc_modem
746 switch(hd
->sub_class
.id
) {
748 s
= new_str("/dev/ham");
753 s
= new_str("/dev/536ep0");
758 s
= new_str("/dev/ttyLT0");
764 str_printf(&s
, 0, "/dev/ttySL%u", cnt4
);
766 dev_num
.minor
= cnt4
++;
771 free_mem(hd
->unix_dev_name
);
772 hd
->unix_dev_name
= s
;
774 hd
->unix_dev_num
= dev_num
;
782 * Look for WLAN cards by checking module info.
784 void int_wlan(hd_data_t
*hd_data
)
790 static char *wlan_mods
[] = {
836 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
837 for(found
= 0, di
= hd
->driver_info
; di
&& !found
; di
= di
->next
) {
838 if(di
->any
.type
== di_module
) {
839 for(sl
= di
->module
.names
; sl
&& !found
; sl
= sl
->next
) {
840 for(u
= 0; u
< sizeof wlan_mods
/ sizeof *wlan_mods
; u
++) {
841 if(!strcmp(sl
->str
, wlan_mods
[u
])) {
851 hd
->base_class
.id
= bc_network
;
852 hd
->sub_class
.id
= 0x82; /* wlan */
853 hddb_add_info(hd_data
, hd
);
862 void int_udev(hd_data_t
*hd_data
)
869 if(!hd_data
->udevinfo
) read_udevinfo(hd_data
);
871 if(!hd_data
->udevinfo
) return;
873 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
874 if(!hd
->sysfs_id
) continue;
876 for(ui
= hd_data
->udevinfo
; ui
; ui
= ui
->next
) {
877 if(ui
->name
&& !strcmp(ui
->sysfs
, hd
->sysfs_id
)) {
878 hd
->unix_dev_names
= free_str_list(hd
->unix_dev_names
);
879 hd
->unix_dev_name
= free_mem(hd
->unix_dev_name
);
880 str_printf(&s
, 0, "%s%s", ui
->type
== 'n' ? "" : "/dev/", ui
->name
);
881 add_str_list(&hd
->unix_dev_names
, s
);
882 for(sl
= ui
->links
; sl
; sl
= sl
->next
) {
883 str_printf(&s
, 0, "%s%s", ui
->type
== 'n' ? "" : "/dev/", sl
->str
);
884 add_str_list(&hd
->unix_dev_names
, s
);
888 sl
= hd
->unix_dev_names
;
890 if(hd_data
->flags
.udev
) {
891 /* use first link as canonical device name */
892 if(ui
->links
) sl
= sl
->next
;
895 hd
->unix_dev_name
= new_str(sl
->str
);
905 * If hd->unix_dev_name is not in hd->unix_dev_names, add it.
907 void int_devicenames(hd_data_t
*hd_data
)
911 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
914 !search_str_list(hd
->unix_dev_names
, hd
->unix_dev_name
)
916 add_str_list(&hd
->unix_dev_names
, hd
->unix_dev_name
);
922 #if defined(__i386__) || defined (__x86_64__)
924 * Tag ide soft raid disks.
926 void int_softraid(hd_data_t
*hd_data
)
929 str_list_t
*raid
, *sl
, *raid_sysfs
= NULL
, *sl1
;
933 if(hd_data
->flags
.fast
) return;
935 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
937 hd
->base_class
.id
== bc_storage_device
&&
938 hd
->status
.available
!= status_no
942 /* no disks -> no check necessary */
945 raid
= read_file("| /sbin/dmraid -rc 2>/dev/null", 0, 0);
947 for(sl
= raid
; sl
; sl
= sl
->next
) {
948 s
= *sl
->str
? strchr(sl
->str
+ 1, '/') : NULL
;
950 sl1
= add_str_list(&raid_sysfs
, NULL
);
951 str_printf(&sl1
->str
, 0, "/block%s", s
);
952 len
= strlen(sl1
->str
);
953 if(len
) sl1
->str
[len
- 1] = 0;
959 ADD2LOG("----- soft raid devices -----\n");
960 for(sl
= raid_sysfs
; sl
; sl
= sl
->next
) {
961 ADD2LOG(" %s\n", sl
->str
);
963 ADD2LOG("----- soft raid devices end -----\n");
965 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
966 if(search_str_list(raid_sysfs
, hd
->sysfs_id
)) {
967 hd
->is
.softraiddisk
= 1;
971 free_str_list(raid_sysfs
);
979 void int_system(hd_data_t
*hd_data
)
985 unsigned acpi_mods
:1; /* *** evil hack *** */
986 enum { v_none
= 0, v_ibm
= 1, v_toshiba
, v_sony
} vendor
;
990 for(hd_sys
= hd_data
->hd
; hd_sys
; hd_sys
= hd_sys
->next
) {
992 hd_sys
->base_class
.id
== bc_internal
&&
993 hd_sys
->sub_class
.id
== sc_int_sys
1000 hd_sys
->vendor
.name
&&
1001 !strncasecmp(hd_sys
->vendor
.name
, "sony", sizeof "sony" - 1)
1007 hd_sys
->device
.name
&&
1008 !strncmp(hd_sys
->device
.name
, "PCG-", sizeof "PCG-" - 1)
1013 for(sm
= hd_data
->smbios
; sm
; sm
= sm
->next
) {
1015 sm
->any
.type
== sm_sysinfo
&&
1016 sm
->sysinfo
.manuf
&&
1017 sm
->sysinfo
.product
&&
1018 !strcasecmp(sm
->sysinfo
.manuf
, "Hewlett-Packard") &&
1019 !strcasecmp(sm
->sysinfo
.product
, "HP Compaq nc6220")
1025 sm
->any
.type
== sm_sysinfo
&&
1026 sm
->sysinfo
.manuf
&&
1027 !strcasecmp(sm
->sysinfo
.manuf
, "ibm")
1033 sm
->any
.type
== sm_sysinfo
&&
1034 sm
->sysinfo
.manuf
&&
1035 !strcasecmp(sm
->sysinfo
.manuf
, "toshiba")
1037 is
.vendor
= v_toshiba
;
1039 if(!hd_sys
->device
.name
&& !hd_sys
->device
.id
&& sm
->sysinfo
.product
) {
1040 hd_sys
->device
.name
= new_str(sm
->sysinfo
.product
);
1042 if(!hd_sys
->vendor
.name
&& !hd_sys
->vendor
.id
) {
1043 hd_sys
->vendor
.name
= new_str("Toshiba");
1048 sm
->any
.type
== sm_sysinfo
&&
1049 sm
->sysinfo
.manuf
&&
1050 !strncasecmp(sm
->sysinfo
.manuf
, "sony", sizeof "sony" - 1)
1054 if(!hd_sys
->device
.name
&& !hd_sys
->device
.id
&& sm
->sysinfo
.product
) {
1055 hd_sys
->device
.name
= new_str(sm
->sysinfo
.product
);
1057 (s
= strchr(hd_sys
->device
.name
, '(')) &&
1058 hd_sys
->device
.name
[strlen(hd_sys
->device
.name
) - 1] == ')'
1063 if(!hd_sys
->vendor
.name
&& !hd_sys
->vendor
.id
) {
1064 hd_sys
->vendor
.name
= new_str("Sony");
1069 sm
->any
.type
== sm_chassis
&&
1071 (sm
->chassis
.ch_type
.id
>= 8 && sm
->chassis
.ch_type
.id
<= 11) ||
1072 sm
->chassis
.ch_type
.id
== 14
1080 " system type:%s%s\n",
1081 is
.vendor
== v_ibm
? " ibm" :
1082 is
.vendor
== v_toshiba
? " toshiba" :
1083 is
.vendor
== v_sony
? " sony" :
1085 is
.notebook
? " notebook" : ""
1088 if(is
.notebook
&& is
.vendor
) {
1089 hd_sys
->compat_vendor
.id
= MAKE_ID(TAG_SPECIAL
, 0xf001);
1090 hd_sys
->compat_device
.id
= MAKE_ID(TAG_SPECIAL
, is
.vendor
);
1092 else if(is
.acpi_mods
) {
1093 hd_sys
->compat_vendor
.id
= MAKE_ID(TAG_SPECIAL
, 0xf001);
1094 hd_sys
->compat_device
.id
= MAKE_ID(TAG_SPECIAL
, 4);
1099 void int_legacy_geo(hd_data_t
*hd_data
)
1107 if(!hd_data
->edd
) return;
1109 for(hd
= hd_data
->hd
; hd
; hd
= hd
->next
) {
1111 hd
->base_class
.id
== bc_storage_device
&&
1112 hd
->sub_class
.id
== sc_sdev_disk
&&
1115 id
= strtol(hd
->rom_id
, &s
, 0) - 0x80;
1116 if(*s
|| id
< 0 || id
>= sizeof hd_data
->edd
/ sizeof *hd_data
->edd
) continue;
1118 ei
= hd_data
->edd
+ id
;
1121 res
= add_res_entry(&hd
->res
, new_mem(sizeof *res
));
1122 res
->disk_geo
.type
= res_disk_geo
;
1123 res
->disk_geo
.cyls
= ei
->edd
.cyls
;
1124 res
->disk_geo
.heads
= ei
->edd
.heads
;
1125 res
->disk_geo
.sectors
= ei
->edd
.sectors
;
1126 res
->disk_geo
.size
= ei
->sectors
;
1127 res
->disk_geo
.geotype
= geo_bios_edd
;
1130 if(ei
->legacy
.cyls
) {
1131 res
= add_res_entry(&hd
->res
, new_mem(sizeof *res
));
1132 res
->disk_geo
.type
= res_disk_geo
;
1133 res
->disk_geo
.cyls
= ei
->legacy
.cyls
;
1134 res
->disk_geo
.heads
= ei
->legacy
.heads
;
1135 res
->disk_geo
.sectors
= ei
->legacy
.sectors
;
1136 res
->disk_geo
.geotype
= geo_bios_legacy
;