changelog tags changeset manifest revisions annotate raw

hardware_load.rb

changeset 25: 19405d7dd94b
parent:d4b2f4b664a5
author: frsyuki@vcore
date: Fri Mar 23 20:59:50 2007 +0900 (14 years ago)
permissions: -rw-r--r--
1require "log"
2
3
4class HardwareDetect
5 MODULE_SCSI_STORAGE = ["sd_mod", "sr_mod"]
6 MODULE_IDE_STORAGE = ["ide-disk", "ide-cd"]
7 MODULE_SATA_STORAGE = MODULE_SCSI_STORAGE + ["libata"] + ["ahci"]
8 MODULE_PCCARD_BRIDGE = [] + ["yenta_socket"]
9 MODULE_FIREWIRE_BUS = MODULE_SCSI_STORAGE + ["sbp2"] + ["ohci1394", "pcilynx"]
10 MODULE_USB_BUS = MODULE_SCSI_STORAGE + ["usb-storage"] + ["uhci-hcd", "ohci-hcd", "ehci-hcd"]
11 # usb-storageはUSB自動検出でも検出可能だが、
12 # ホットプラグを考慮してここでロードする
13
14
15 def getModulePCI(dev)
16 mod = dev.modules
17
18 case dev.pclass[0,2] # Base class
19 #dev.pclass[2,2] # Sub class
20
21 when "01" # Mass storage controller
22 case dev.pclass[2,2]
23 when "00", "07" # SCSI storage, Serial Attached SCSI controller
24 mod.concat(MODULE_SCSI_STORAGE)
25 when "01", "05" # IDE interface, ATA controller
26 mod.concat(MODULE_IDE_STORAGE)
27 when "06", "04" # SATA controller, RAID bus controller
28 mod.concat(MODULE_SATA_STORAGE)
29 end
30
31 when "06" # Bridge
32 case dev.pclass[2,2]
33 when "05", "07" # PCMCIA bridge, CardBus bridge
34 mod.concat(MODULE_PCCARD_BRIDGE)
35 end
36
37 when "0c" # Serial bus controller
38 case dev.pclass[2,2]
39 when "00" # FieWire (IEEE 1394)
40 mod.concat(MODULE_FIREWIRE_BUS)
41 when "03" # USB Controller
42 mod.concat(MODULE_USB_BUS)
43 end
44
45 end
46
47 return mod
48 end
49
50 def getModuleUSB(dev)
51 # XXX: getModuleUSB: modules.usbmapだけでロード可能?
52 return dev.modules
53 end
54
55 private :getModulePCI, :getModuleUSB
56
57
58 def loadDetectedPCI
59 load_modules = Array.new
60
61 @detected_pci.each {|dev|
62 load_modules.concat( getModulePCI(dev) )
63 }
64
65 load_modules.uniq!
66 load_modules.each {|m|
67 @kmodule.load(m)
68 }
69 end
70
71
72 def loadDetectedUSB
73 load_modules = Array.new
74 @detected_usb.each {|dev|
75 load_modules.concat( dev.modules )
76 }
77 load_modules.uniq!
78 load_modules.each {|m|
79 @kmodule.load(m)
80 }
81 end
82
83 private :loadDetectedPCI, :loadDetectedUSB
84
85end
86
87
88$log.debug "#{File.basename(__FILE__, ".*")} loaded"
89