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:

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.

Actually, the names of the locators are indeed available in the kernel!

The attached patch revises the device-properties dictionary to include this information as well.

I would still like feedback (positive or negative), as well as some indication of whether you think this should be committed.



-------------------------------------------------------------------------
| 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     16 Jan 2012 01:57:08 -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, j;
+       const struct cfiattrdata *ci;
+       prop_dictionary_t attr_dict;
+       prop_array_t attr_array, loc_array;
 
        cd = config_cfdriver_lookup(cf->cf_name);
        if (cd == NULL)
@@ -1390,6 +1394,55 @@ 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 and add it
+        * to the device's dv_properties dictionary.
+        *
+        * <key>interface-attributes</key>
+        * <array>
+        *    <dict>
+        *       <key>attribute-name</key>
+        *       <string>foo</string>
+        *       <key>locators</key>
+        *       <array>
+        *          <string>foo-loc1</string>
+        *          <string>foo-loc2</string>
+        *          ...
+        *       </array>
+        *    </dict>
+        *    ...
+        * </array>
+        */
+       if (dev->dv_cfdriver->cd_attrs == NULL)
+               return dev;
+
+       if ((attr_array = prop_array_create()) != NULL) {
+               for (i = 0; ; i++) {
+                       if ((ci = dev->dv_cfdriver->cd_attrs[i]) == NULL)
+                               break;
+                       if ((attr_dict = prop_dictionary_create()) == NULL)
+                               break;
+                       prop_dictionary_set_cstring_nocopy(attr_dict,
+                           "attribute-name", ci->ci_name);
+                       if (ci->ci_loclen == 0)
+                               continue;
+                       if ((loc_array = prop_array_create()) == NULL)
+                               continue;
+                       for (j = 0; j < ci->ci_loclen; j++)
+                               prop_array_set_cstring_nocopy(loc_array, j,
+                                   ci->ci_locdesc[j].cld_name);
+                       prop_dictionary_set_and_rel(attr_dict, "locators",
+                           loc_array);
+                       prop_array_add(attr_array, attr_dict);
+                       prop_object_release(attr_dict);
+               }
+               if (i == 0)
+                       prop_object_release(attr_array);
+               else
+                       prop_dictionary_set_and_rel(dev->dv_properties,
+                           "interface-attributes", attr_array);
+       }
+
        return dev;
 }
 
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>
                <dict>
                        <key>attribute-name</key>
                        <string>ioapicbus</string>
                        <key>locators</key>
                        <array>
                                <string>apid</string>
                        </array>
                </dict>
                <dict>
                        <key>attribute-name</key>
                        <string>cpubus</string>
                        <key>locators</key>
                        <array>
                                <string>apid</string>
                        </array>
                </dict>
                <dict>
                        <key>attribute-name</key>
                        <string>pcibus</string>
                        <key>locators</key>
                        <array>
                                <string>bus</string>
                        </array>
                </dict>
        </array>
</dict>
</plist>
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>
                <dict>
                        <key>attribute-name</key>
                        <string>ata_hl</string>
                        <key>locators</key>
                        <array>
                                <string>drive</string>
                        </array>
                </dict>
        </array>
</dict>
</plist>
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