Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Rescan for ahcisata ?
On Sun, 15 Jan 2012, Paul Goyette wrote:
It would be nice to be able to list attributes. Locators, too.
I'm working on including the attribute list as an array within the device's
property dictionary. The info would then be available via "drvctl -p" so
would not require any changes in drvctl(8) itself.
Attached is a rather simple patch that adds to the device dictionary an
array containing the interface-attributes of each device. Also there is
an attachment of sample output, including output from a device that has
no attributes (ioapic0).
Does anyone have any objections to commiting this?
As for the locators associated with each interface-attribute, that's a
rather different animal, since the names of the locators are not stored
anywhere inside the kernel.
-------------------------------------------------------------------------
| Paul Goyette | PGP Key fingerprint: | E-mail addresses: |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer | | pgoyette at netbsd.org |
-------------------------------------------------------------------------
Index: subr_autoconf.c
===================================================================
RCS file: /cvsroot/src/sys/kern/subr_autoconf.c,v
retrieving revision 1.220
diff -u -p -r1.220 subr_autoconf.c
--- subr_autoconf.c 31 Aug 2011 18:31:02 -0000 1.220
+++ subr_autoconf.c 15 Jan 2012 21:30:07 -0000
@@ -1303,6 +1303,10 @@ config_devalloc(const device_t parent, c
void *dev_private;
const struct cfiattrdata *ia;
device_lock_t dvl;
+ int i;
+ const char *attr;
+ prop_array_t attr_array;
+ prop_string_t attr_string;
cd = config_cfdriver_lookup(cf->cf_name);
if (cd == NULL)
@@ -1390,6 +1394,30 @@ config_devalloc(const device_t parent, c
prop_dictionary_set_uint16(dev->dv_properties,
"device-unit", dev->dv_unit);
+ /*
+ * Create an array of device attach attributes
+ */
+ if (dev->dv_cfdriver->cd_attrs == NULL)
+ return dev;
+
+ if ((attr_array = prop_array_create()) != NULL) {
+ for (i = 0; ; i++) {
+ if (dev->dv_cfdriver->cd_attrs[i] == NULL)
+ break;
+ attr = dev->dv_cfdriver->cd_attrs[i]->ci_name;
+ attr_string = prop_string_create_cstring_nocopy(attr);
+ if (attr_string != NULL) {
+ prop_array_add(attr_array, attr_string);
+ prop_object_release(attr_string);
+ }
+ }
+ if (i == 0)
+ prop_object_release(attr_array);
+ else
+ prop_dictionary_set_and_rel(dev->dv_properties,
+ "interface-attributes", attr_array);
+ }
+
return dev;
}
# drvctl -p mainbus0
Properties for device `mainbus0':
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>device-driver</key>
<string>mainbus</string>
<key>device-unit</key>
<integer>0x0</integer>
<key>interface-attributes</key>
<array>
<string>ipmibus</string>
<string>ioapicbus</string>
<string>cpubus</string>
<string>acpibus</string>
<string>pcibus</string>
<string>isabus</string>
</array>
</dict>
</plist>
# drvctl -p atabus0
Properties for device `atabus0':
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>device-driver</key>
<string>atabus</string>
<key>device-unit</key>
<integer>0x0</integer>
<key>interface-attributes</key>
<array>
<string>ata_hl</string>
<string>atapi</string>
</array>
</dict>
</plist>
# drvctl -p ioapic0
Properties for device `ioapic0':
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>device-driver</key>
<string>ioapic</string>
<key>device-unit</key>
<integer>0x0</integer>
</dict>
</plist>
Home |
Main Index |
Thread Index |
Old Index