diff options
author | Michael Brown <mcb30@ipxe.org> | 2024-10-18 13:13:28 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2024-10-18 13:13:51 +0100 |
commit | c69f9589cc7543baba08dbabdb5c30104fadaa34 (patch) | |
tree | 15cb64369c6f7e50a399c5b43e7b1a3b917ee028 /src/drivers/net | |
parent | c219b5d8a9536cc87e9c53e8389e59c706ba3f8e (diff) | |
download | ipxe-c69f9589cc7543baba08dbabdb5c30104fadaa34.tar.gz |
[usb] Expose USB device descriptor and strings via settings
Allow scripts to read basic information from USB device descriptors
via the settings mechanism. For example:
echo USB vendor ID: ${usb/${busloc}.8.2}
echo USB device ID: ${usb/${busloc}.10.2}
echo USB manufacturer name: ${usb/${busloc}.14.0}
The general syntax is
usb/<bus:dev>.<offset>.<length>
where bus:dev is the USB bus:device address (as obtained via the
"usbscan" command, or from e.g. ${net0/busloc} for a USB network
device), and <offset> and <length> select the required portion of the
USB device descriptor.
Following the usage of SMBIOS settings tags, a <length> of zero may be
used to indicate that the byte at <offset> contains a USB string
descriptor index, and an <offset> of zero may be used to indicate that
the <length> contains a literal USB string descriptor index.
Since the byte at offset zero can never contain a string index, and a
literal string index can never be zero, the combination of both
<length> and <offset> being zero may be used to indicate that the
entire device descriptor is to be read as a raw hex dump.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/drivers/net')
-rw-r--r-- | src/drivers/net/ecm.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/drivers/net/ecm.c b/src/drivers/net/ecm.c index ab1f98370..7b3e92b9b 100644 --- a/src/drivers/net/ecm.c +++ b/src/drivers/net/ecm.c @@ -97,8 +97,9 @@ int ecm_fetch_mac ( struct usb_function *func, int rc; /* Fetch MAC address string */ + buf[ sizeof ( buf ) - 1 ] = '\0'; len = usb_get_string_descriptor ( usb, desc->mac, 0, buf, - sizeof ( buf ) ); + ( sizeof ( buf ) - 1 ) ); if ( len < 0 ) { rc = len; return rc; |