Page MenuHomeFreeBSD

gen_pci_vendors: Add new script
Needs ReviewPublic

Authored by manu on Jan 22 2024, 2:15 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 29, 7:20 AM
Unknown Object (File)
Apr 7 2024, 2:30 AM
Unknown Object (File)
Mar 25 2024, 10:36 PM
Unknown Object (File)
Mar 2 2024, 4:43 PM
Unknown Object (File)
Feb 20 2024, 4:58 PM
Unknown Object (File)
Feb 1 2024, 5:17 AM
Unknown Object (File)
Jan 22 2024, 3:18 PM
Unknown Object (File)
Jan 22 2024, 3:10 PM
Subscribers

Details

Reviewers
bapt
Summary

This script takes a pci_vendor file and generate a C header.

MFC after: 3 days
Sponsored by: Beckhoff Automation GmbH & Co. KG

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 55539
Build 52428: arc lint + arc unit

Event Timeline

manu requested review of this revision.Jan 22 2024, 2:15 PM

Not sure if it's worth parsing the header file and the pci.ids file. If you want to update the header file, you can simply parse the pci.ids file and diff the output or you simply overwrite the header file and use git clean up the diff.

sys/tools/gen_pci_vendors.awk
42

Should we be more strict and check for 4 digits?

46–51

The order makes no sense. In the first step, you're replacing e.g. ( with _. In a later step, you try to replace \(.*\) with "". It should be:

			gsub(/\[.+\]/, "", key)
			gsub(/\(.+\)/, "", key)
			gsub(/[ \.\)\(-\/\+\',#]/, "_", key)
			gsub(/["\?&]/, "", key)
			gsub(/__/, "_", key)
			gsub(/_$/, "", key)

Btw. removing everything between brackets can lead to duplicate keys. E.g.:

1002  Advanced Micro Devices, Inc. [AMD/ATI]
1022  Advanced Micro Devices, Inc. [AMD]
54

Maybe adding a warning for duplicate keys? Therefore, you should parse pci.ids first and then the header file.

57

Nit! Or even "_" toupper(header_file) "_", would avoid the conversion some lines below.

65–69

Parsing the header file and the pci.ids file is currently broken. Both files are using a different key. So, when the header file already contains some values, you're going to add them a second time. So, just use the same key for header and pci.ids file by prepending PCI_VENDOR_ to the pci.ids key.