diff options
| author | pgoyette <pgoyette@NetBSD.org> | 2021-06-29 21:03:36 +0000 |
|---|---|---|
| committer | pgoyette <pgoyette@NetBSD.org> | 2021-06-29 21:03:36 +0000 |
| commit | 351ab7ad3473ca94806b6456e9104e93ede06e8f (patch) | |
| tree | 808ff44555e3d51d0f9f965725ef9673b61c277d /sys/dev/devlist2h.awk | |
| parent | 8e77388ddd611ba4dd255a5f23c4def3092e60b5 (diff) | |
Rework the xxxVERBOSE option to share the common module-hook-based
verbose mechanism with MIIVERBOSE. This reduces some duplicated code
and allows us to once again permit auto-unload of MIIVERBOSE.
Change details:
* Update dev/devlist2h.awk to accomodate miidevs, including generation
of MII_STR_oui_model definitions and use of oui and model rather than
vendor and product. This also changes the compressed data in the
xxxdevs_data.h files to uint32_t (since mii oui's are up to 6 hex
digits long)
* Update a couple of phy drivers to use new calls to get verbose data
* Regen all of the xxxdevs{,_data}.h files (separate commit, coming
very soon)
* Update mii/mii_verbose.[ch] and mii/mii_physubr.c to use the various
DEV_VERBOSE_xxx macros
* Update the pci, usb, and hdaudio code as needed, to #include the
xxxdevs.h files (in order to get the proper printf format strings)
* Since dev/dev_verbose.c now uses non-literal printf format strings,
(to deal with the vendor/product vs oui/model issue), we need to
make sure it gets compiled with -Wno-error=format-nonliteral, even
in userland's libpci and librumpdev!
* Bump kernel version for the change in module interfaces
Welcome to 9.99.86!
XXX It might be useful in the future to extend the MII_STR_oui_model
XXX definitions to PCI as well (and perhaps USB and HDAUDIO). This
XXX would allow for a single centralized location for the products'
XXX descriptions, rather than being dispersed among individual
XXX drivers' xxx_match tables.
Diffstat (limited to 'sys/dev/devlist2h.awk')
| -rw-r--r-- | sys/dev/devlist2h.awk | 84 |
1 files changed, 70 insertions, 14 deletions
diff --git a/sys/dev/devlist2h.awk b/sys/dev/devlist2h.awk index 5666ab4e0c3..de8a8d250f9 100644 --- a/sys/dev/devlist2h.awk +++ b/sys/dev/devlist2h.awk @@ -1,5 +1,5 @@ #! /usr/bin/awk -f -# $NetBSD: devlist2h.awk,v 1.3 2017/06/27 08:09:14 wiz Exp $ +# $NetBSD: devlist2h.awk,v 1.4 2021/06/29 21:03:36 pgoyette Exp $ # # Copyright (c) 1995, 1996 Christopher G. Demetriou # All rights reserved. @@ -29,6 +29,34 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # + +function collectline(f) { + oparen = 0 + line = "" + while (f <= NF) { + if ($f == "#") { + line = line "(" + oparen = 1 + f++ + continue + } + if (oparen) { + line = line $f + if (f < NF) + line = line " " + f++ + continue + } + line = line $f + if (f < NF) + line = line " " + f++ + } + if (oparen) + line = line ")" + return line +} + NR == 1 { nproducts = nvendors = blanklines = 0 vendormaxlen = productmaxlen = 0 @@ -42,6 +70,22 @@ NR == 1 { gsub("\\$", "", VERSION) gsub(/ $/, "", VERSION) + if ( PREFIX == "MII" ) { + VENDOR="OUI" + PRODUCT="MODEL" + vendor="oui" + product="model" + fmt_vendor="oui %6.6x" + fmt_product="model %4.4x" + } else { + VENDOR="VENDOR" + PRODUCT="PRODUCT" + vendor="vendor" + product="product" + fmt_vendor="vendor %4.4x" + fmt_product="product %4.4x" + } + printf("/*\t$NetBSD" "$\t*/\n\n") > dfile printf("/*\n") > dfile printf(" * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \ @@ -62,13 +106,13 @@ NR == 1 { next } -NF > 0 && $1 == "vendor" { +NF > 0 && $1 == vendor { nvendors++ vendorindex[$2] = nvendors; # record index for this name, for later. vendors[nvendors, 1] = $2; # name vendors[nvendors, 2] = $3; # id - printf("#define\t%s_VENDOR_%s\t%s", PREFIX, vendors[nvendors, 1], + printf("#define\t%s_%s_%s\t%s", PREFIX, VENDOR, vendors[nvendors, 1], vendors[nvendors, 2]) > hfile i = 3; f = 4; @@ -124,14 +168,15 @@ NF > 0 && $1 == "vendor" { next } -NF > 0 && $1 == "product" { +NF > 0 && $1 == product { nproducts++ products[nproducts, 1] = $2; # vendor name products[nproducts, 2] = $3; # product id products[nproducts, 3] = $4; # id - printf("#define\t%s_PRODUCT_%s_%s\t%s", PREFIX, products[nproducts, 1], - products[nproducts, 2], products[nproducts, 3]) > hfile + printf("#define\t%s_%s_%s_%s\t%s", PREFIX, PRODUCT, + products[nproducts, 1], products[nproducts, 2], + products[nproducts, 3]) > hfile i=4; f = 5; @@ -184,6 +229,12 @@ NF > 0 && $1 == "product" { productmaxlen = productlen; } + if (PREFIX == "MII") { + printf("#define\tMII_STR_%s_%s\t\"%s\"\n", + products[nproducts, 1], products[nproducts, 2], + collectline(5)) > hfile + } + next } { @@ -198,9 +249,9 @@ END { printf("\n") > dfile - printf("static const uint16_t %s_vendors[] = {\n", prefix) > dfile + printf("static const uint32_t %s_vendors[] = {\n", prefix) > dfile for (i = 1; i <= nvendors; i++) { - printf("\t %s_VENDOR_%s", PREFIX, vendors[i, 1]) \ + printf("\t %s_%s_%s", PREFIX, VENDOR, vendors[i, 1]) \ > dfile j = 3; @@ -218,11 +269,11 @@ END { printf("\n") > dfile - printf("static const uint16_t %s_products[] = {\n", prefix) > dfile + printf("static const uint32_t %s_products[] = {\n", prefix) > dfile for (i = 1; i <= nproducts; i++) { - printf("\t %s_VENDOR_%s, %s_PRODUCT_%s_%s, \n", - PREFIX, products[i, 1], PREFIX, products[i, 1], - products[i, 2]) > dfile + printf("\t %s_%s_%s, %s_%s_%s_%s, \n", + PREFIX, VENDOR, products[i, 1], PREFIX, PRODUCT, + products[i, 1], products[i, 2]) > dfile printf("\t ") > dfile j = 4 @@ -250,8 +301,13 @@ END { printf("\n") > dfile - printf("Maximum vendor string length: %d\n", vendormaxlen + 1) - printf("Maximum product string length: %d\n", productmaxlen + 1) + printf("\n") > hfile + printf("/* Define format strings for non-existent values */\n") > hfile + printf("#define %s_id1_format\t\"%s\"\n", prefix, fmt_vendor) > hfile + printf("#define %s_id2_format\t\"%s\"\n", prefix, fmt_product) > hfile + + printf("Maximum %s string length: %d\n", vendor, vendormaxlen + 1) + printf("Maximum %s string length: %d\n", product, productmaxlen + 1) printf("\nEnsure that device-specific values are sufficiently large"); printf("\ncheck Makefile.%s for details).\n", FILENAME); |
