improved version
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16214 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -54,7 +54,7 @@ actions PCIHeaderGen1
|
|||||||
awk -v HEADERFILE=$(1) -f $(2[2]) $(2[1])
|
awk -v HEADERFILE=$(1) -f $(2[2]) $(2[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
PCIHeaderGen [ FGristFiles pcihdr.h ] : pci.ids : pci-clean.awk ;
|
PCIHeaderGen [ FGristFiles pcihdr.h ] : pci.ids : pci-header.awk ;
|
||||||
|
|
||||||
Preference Devices :
|
Preference Devices :
|
||||||
Devices.cpp
|
Devices.cpp
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Clean PCI header script
|
# PCI Header script
|
||||||
#
|
#
|
||||||
# Copyright 2006, Haiku.
|
# Copyright 2006, Haiku.
|
||||||
# Distributed under the terms of the MIT License.
|
# Distributed under the terms of the MIT License.
|
||||||
@@ -10,34 +10,56 @@
|
|||||||
# run as: awk -v HEADERFILE=pcihdr.h -f pci-header.awk pci.ids
|
# run as: awk -v HEADERFILE=pcihdr.h -f pci-header.awk pci.ids
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
|
|
||||||
|
# field separator, defining because user could have overridden
|
||||||
FS = " "
|
FS = " "
|
||||||
|
|
||||||
|
# Pass this in from outside with -v HEADERFILE=filenametouse
|
||||||
|
# we require pcihdr.h for our system
|
||||||
ofile = HEADERFILE
|
ofile = HEADERFILE
|
||||||
|
|
||||||
|
# possibly use this in the future
|
||||||
|
cleanvalues = "[^A-Za-z0-9{}\"'&@?!*.,:;+<> \\t\\/_\\[\\]=#()-]"
|
||||||
|
# ToDo: currently IDs aren't checked, we dumbly assume the source is clean
|
||||||
|
|
||||||
|
# descriptive output header
|
||||||
print "#if 0" > ofile
|
print "#if 0" > ofile
|
||||||
print "#\tPCIHDR.H: PCI Vendors, Devices, and Class Type information\n#" > ofile
|
print "#\tPCIHDR.H: PCI Vendors, Devices, and Class Type information\n#" > ofile
|
||||||
print "#\tGenerated by pci-clean, sourced from the web at the following URL:\n#\thttp://pciids.sourceforge.net/pci.ids\n#" > ofile
|
print "#\tGenerated by pci-header.awk, source data from the following URI:\n#\thttp://pciids.sourceforge.net/pci.ids\n#" > ofile
|
||||||
print "#\tHeader created on " strftime( "%A, %d %b %Y %H:%M:%S %Z", systime() ) > ofile
|
print "#\tHeader created on " strftime( "%A, %d %b %Y %H:%M:%S %Z", systime() ) > ofile
|
||||||
print "#endif" > ofile
|
print "#endif" > ofile
|
||||||
|
|
||||||
|
# and we start with vendors..
|
||||||
print "\ntypedef struct _PCI_VENTABLE\n{\n\tunsigned short\tVenId ;\n\tchar *\tVenFull ;\n\tchar *\tVenShort ;\n} PCI_VENTABLE, *PPCI_VENTABLE ;\n" > ofile
|
print "\ntypedef struct _PCI_VENTABLE\n{\n\tunsigned short\tVenId ;\n\tchar *\tVenFull ;\n\tchar *\tVenShort ;\n} PCI_VENTABLE, *PPCI_VENTABLE ;\n" > ofile
|
||||||
print "PCI_VENTABLE\tPciVenTable [] =\n{" > ofile
|
print "PCI_VENTABLE\tPciVenTable [] =\n{" > ofile
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# matches vendor - starts with an id as first thing on the line
|
# matches vendor - starts with an id as first thing on the line
|
||||||
|
# because this occurs first in the header file, we output it without worry
|
||||||
/^[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]] / {
|
/^[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]] / {
|
||||||
if ( vendor++ > 0 ) { a = ",\n" } else { a = "" }
|
|
||||||
vend = substr($0, 7); gsub( /\"/, "\\\"", vend )
|
if ( vendorcount++ > 0 ) {
|
||||||
printf a "\t{ 0x" $1 ", \"" vend "\" }" > ofile
|
formatting = ",\n"
|
||||||
|
} else {
|
||||||
|
formatting = ""
|
||||||
|
}
|
||||||
|
|
||||||
# store vendor ID for possible devices afterwards
|
# store vendor ID for possible devices afterwards
|
||||||
currentVendor = $1
|
vendorid = $1
|
||||||
|
vendor = substr($0, 7)
|
||||||
|
gsub( /\"/, "\\\"", vendor )
|
||||||
|
|
||||||
|
printf formatting "\t{ 0x" vendorid ", \"" vendor "\" }" > ofile
|
||||||
}
|
}
|
||||||
|
|
||||||
# matches device
|
# matches device
|
||||||
/^\t[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]] / {
|
/^\t[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]] / {
|
||||||
|
|
||||||
device = substr($0, 8); gsub( /\"/, "\\\"", device )
|
device = substr($0, 8)
|
||||||
|
gsub( /\"/, "\\\"", device )
|
||||||
|
|
||||||
devicecount++
|
devicecount++
|
||||||
devices[devicecount, 1] = currentVendor
|
devices[devicecount, 1] = vendorid
|
||||||
devices[devicecount, 2] = $1
|
devices[devicecount, 2] = $1
|
||||||
devices[devicecount, 3] = device
|
devices[devicecount, 3] = device
|
||||||
}
|
}
|
||||||
@@ -45,7 +67,9 @@ BEGIN {
|
|||||||
# matches subvendor device
|
# matches subvendor device
|
||||||
/^\t\t[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]] / {
|
/^\t\t[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]] / {
|
||||||
|
|
||||||
device = substr($0, 14); gsub( /\"/, "\\\"", device )
|
device = substr($0, 14)
|
||||||
|
gsub( /\"/, "\\\"", device )
|
||||||
|
|
||||||
devicecount++
|
devicecount++
|
||||||
devices[devicecount, 1] = $1
|
devices[devicecount, 1] = $1
|
||||||
devices[devicecount, 2] = $2
|
devices[devicecount, 2] = $2
|
||||||
@@ -54,38 +78,42 @@ BEGIN {
|
|||||||
|
|
||||||
# match device class - store data for later
|
# match device class - store data for later
|
||||||
/^C [[:xdigit:]][[:xdigit:]] / {
|
/^C [[:xdigit:]][[:xdigit:]] / {
|
||||||
|
|
||||||
class = $2
|
class = $2
|
||||||
classdes = substr($0, 7); gsub( /\"/, "\\\"", classdes )
|
classname = substr($0, 7)
|
||||||
|
gsub( /\"/, "\\\"", classname )
|
||||||
}
|
}
|
||||||
|
|
||||||
# match subclass, use device class data captured earlier, and output
|
# match subclass, use device class data captured earlier, and output
|
||||||
/^\t[[:xdigit:]][[:xdigit:]] / {
|
/^\t[[:xdigit:]][[:xdigit:]] / {
|
||||||
# if ( currentclass != class) { classes = classes "\n"; currentclass = class }
|
|
||||||
subclassdes = substr($0, 6); gsub( /\"/, "\\\"", subclassdes )
|
|
||||||
subclass = $1
|
subclass = $1
|
||||||
classcount++;
|
subclassname = substr($0, 6)
|
||||||
|
gsub( /\"/, "\\\"", subclassname )
|
||||||
|
|
||||||
|
classcount++
|
||||||
classes[classcount, 1] = class
|
classes[classcount, 1] = class
|
||||||
classes[classcount, 2] = subclass
|
classes[classcount, 2] = subclass
|
||||||
classes[classcount, 3] = "00"
|
classes[classcount, 3] = "00"
|
||||||
classes[classcount, 4] = classdes
|
classes[classcount, 4] = classname
|
||||||
classes[classcount, 5] = subclassdes
|
classes[classcount, 5] = subclassname
|
||||||
classes[classcount, 6] = ""
|
classes[classcount, 6] = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
# match programming interface
|
# match programming interface
|
||||||
/^\t\t[[:xdigit:]][[:xdigit:]] / {
|
/^\t\t[[:xdigit:]][[:xdigit:]] / {
|
||||||
#if ( $1 != "00" ) {
|
|
||||||
#if ( length(classes) > 0 ) classes = classes ",\n"
|
|
||||||
progif = substr($0, 7); gsub( /\"/, "\\\"", progif )
|
|
||||||
|
|
||||||
classcount++;
|
proginterface = $1
|
||||||
classes[classcount, 1] = class
|
proginterfacename = substr($0, 7)
|
||||||
classes[classcount, 2] = subclass
|
gsub( /\"/, "\\\"", proginterfacename )
|
||||||
classes[classcount, 3] = $1
|
|
||||||
classes[classcount, 4] = classdes
|
classcount++
|
||||||
classes[classcount, 5] = subclassdes
|
classes[classcount, 1] = class
|
||||||
classes[classcount, 6] = progif
|
classes[classcount, 2] = subclass
|
||||||
#}
|
classes[classcount, 3] = proginterface
|
||||||
|
classes[classcount, 4] = classname
|
||||||
|
classes[classcount, 5] = subclassname
|
||||||
|
classes[classcount, 6] = proginterfacename
|
||||||
}
|
}
|
||||||
|
|
||||||
# We've processed the file, now output.
|
# We've processed the file, now output.
|
||||||
@@ -95,30 +123,51 @@ END {
|
|||||||
|
|
||||||
if ( devicecount > 0 ) {
|
if ( devicecount > 0 ) {
|
||||||
|
|
||||||
print "typedef struct _PCI_DEVTABLE\n{\n\tunsigned short VenId ;\n\tunsigned short DevId ;\n\tchar *\tChipDesc ;\n\tchar *\tChip ;\n} PCI_DEVTABLE, *PPCI_DEVTABLE ;\n" > ofile
|
print "typedef struct _PCI_DEVTABLE\n{\n\tunsigned short VenId ;\n\tunsigned short DevId ;\n\tchar *\tChipDesc ;\n\tchar *\tChip;\n} PCI_DEVTABLE, *PPCI_DEVTABLE ;\n" > ofile
|
||||||
print "PCI_DEVTABLE\tPciDevTable [] =\n{" > ofile
|
print "PCI_DEVTABLE\tPciDevTable [] =\n{" > ofile
|
||||||
for (i = 1; i <= devicecount; i++) {
|
for (i = 1; i <= devicecount; i++) {
|
||||||
if (i != 1) { a = ",\n" } else { a = "" }
|
|
||||||
printf a "\t{ 0x" devices[i, 1] ", 0x" devices[i, 2] ", \"" devices[i, 3] "\" }" > ofile
|
if (i != 1) {
|
||||||
|
formatting = ",\n"
|
||||||
|
} else {
|
||||||
|
formatting = ""
|
||||||
|
}
|
||||||
|
printf formatting "\t{ 0x" devices[i, 1] ", 0x" devices[i, 2] ", \"" devices[i, 3] "\" }" > ofile
|
||||||
}
|
}
|
||||||
print "\n} ;\n\n// Use this value for loop control during searching:\n#define PCI_DEVTABLE_LEN (sizeof(PciDevTable)/sizeof(PCI_DEVTABLE))\n" > ofile
|
print "\n} ;\n\n// Use this value for loop control during searching:\n#define PCI_DEVTABLE_LEN (sizeof(PciDevTable)/sizeof(PCI_DEVTABLE))\n" > ofile
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( classcount > 0 ) {
|
if ( classcount > 0 ) {
|
||||||
print "typedef struct _PCI_CLASSCODETABLE\n{\n\tunsigned char BaseClass ;\n\tunsigned char SubClass ;\n\tunsigned char ProgIf ;\n\tchar *\t\tBaseDesc ;\n\tchar *\t\tSubDesc ;\n\tchar *\t\tProgDesc ;\n} PCI_CLASSCODETABLE, *PPCI_CLASSCODETABLE ;\n" > ofile
|
print "typedef struct _PCI_CLASSCODETABLE\n{\n\tunsigned char BaseClass ;\n\tunsigned char SubClass ;\n\tunsigned char ProgIf ;" > ofile
|
||||||
|
print "\tchar *\t\tBaseDesc ;\n\tchar *\t\tSubDesc ;\n\tchar *\t\tProgDesc ;\n} PCI_CLASSCODETABLE, *PPCI_CLASSCODETABLE ;\n" > ofile
|
||||||
print "PCI_CLASSCODETABLE PciClassCodeTable [] =\n{" > ofile
|
print "PCI_CLASSCODETABLE PciClassCodeTable [] =\n{" > ofile
|
||||||
|
currentclass = classes[1, 1]
|
||||||
for (i = 1; i <= classcount; i++) {
|
for (i = 1; i <= classcount; i++) {
|
||||||
if (i != 1) { a = ",\n" } else { a = "" }
|
|
||||||
if ( ( classes[i, 1] == classes[i+1, 1] ) && ( classes[i, 2] == classes[i+1, 2] ) && ( classes[i, 3] == classes[i+1, 3] ) ) {
|
if (i != 1) {
|
||||||
} else {
|
formatting = ",\n"
|
||||||
printf a "\t{ 0x" classes[i, 1] ", 0x" classes[i, 2] ", 0x" classes[i, 3] ", \"" classes[i, 4] "\", \"" classes[i, 5] "\", \"" classes[i, 6] "\" }" > ofile
|
} else {
|
||||||
|
formatting = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
# pretty print separate classes
|
||||||
|
if ( currentclass != classes[i, 1] ) {
|
||||||
|
formatting = formatting "\n"
|
||||||
|
currentclass = classes[i, 1]
|
||||||
|
}
|
||||||
|
|
||||||
|
# if the next item has the same details, we know we're to skip ourselves
|
||||||
|
# this is because the programming interface name needs to be used, and we dont have it ourselves
|
||||||
|
if ( ( classes[i, 1] != classes[i+1, 1] ) || ( classes[i, 2] != classes[i+1, 2] ) || ( classes[i, 3] != classes[i+1, 3] ) ) {
|
||||||
|
printf formatting "\t{ 0x" classes[i, 1] ", 0x" classes[i, 2] ", 0x" classes[i, 3] ", \"" classes[i, 4] "\", \"" classes[i, 5] "\", \"" classes[i, 6] "\" }" > ofile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print "\n} ;\n\n// Use this value for loop control during searching:\n#define PCI_CLASSCODETABLE_LEN (sizeof(PciClassCodeTable)/sizeof(PCI_CLASSCODETABLE))\n" > ofile
|
print "\n} ;\n\n// Use this value for loop control during searching:\n#define PCI_CLASSCODETABLE_LEN (sizeof(PciClassCodeTable)/sizeof(PCI_CLASSCODETABLE))\n" > ofile
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# this is rather ugly, maybe we should include this in a seperate file, and pull it in ?
|
||||||
print "char *\tPciCommandFlags [] =\n{\n\t\"I/O Access\",\n\t\"Memory Access\",\n\t\"Bus Mastering\",\n\t\"Special Cycles\",\n\t\"Memory Write & Invalidate\",\n\t\"Palette Snoop\",\n\t\"Parity Errors\",\n\t\"Wait Cycles\",\n\t\"System Errors\",\n\t\"Fast Back-To-Back\",\n\t\"Reserved 10\",\n\t\"Reserved 11\",\n\t\"Reserved 12\",\n\t\"Reserved 13\",\n\t\"Reserved 14\",\n\t\"Reserved 15\"\n} ;\n" > ofile
|
print "char *\tPciCommandFlags [] =\n{\n\t\"I/O Access\",\n\t\"Memory Access\",\n\t\"Bus Mastering\",\n\t\"Special Cycles\",\n\t\"Memory Write & Invalidate\",\n\t\"Palette Snoop\",\n\t\"Parity Errors\",\n\t\"Wait Cycles\",\n\t\"System Errors\",\n\t\"Fast Back-To-Back\",\n\t\"Reserved 10\",\n\t\"Reserved 11\",\n\t\"Reserved 12\",\n\t\"Reserved 13\",\n\t\"Reserved 14\",\n\t\"Reserved 15\"\n} ;\n" > ofile
|
||||||
print "// Use this value for loop control during searching:\n#define PCI_COMMANDFLAGS_LEN (sizeof(PciCommandFlags)/sizeof(char *))\n" > ofile
|
print "// Use this value for loop control during searching:\n#define PCI_COMMANDFLAGS_LEN (sizeof(PciCommandFlags)/sizeof(char *))\n" > ofile
|
||||||
print "char *\tPciStatusFlags [] =\n{\n\t\"Reserved 0\",\n\t\"Reserved 1\",\n\t\"Reserved 2\",\n\t\"Reserved 3\",\n\t\"Reserved 4\",\n\t\"66 MHz Capable\",\n\t\"User-Defined Features\",\n\t\"Fast Back-To-Back\",\n\t\"Data Parity Reported\",\n\t\"\",\n\t\"\",\n\t\"Signalled Target Abort\",\n\t\"Received Target Abort\",\n\t\"Received Master Abort\",\n\t\"Signalled System Error\",\n\t\"Detected Parity Error\"\n} ;\n" > ofile
|
print "char *\tPciStatusFlags [] =\n{\n\t\"Reserved 0\",\n\t\"Reserved 1\",\n\t\"Reserved 2\",\n\t\"Reserved 3\",\n\t\"Reserved 4\",\n\t\"66 MHz Capable\",\n\t\"User-Defined Features\",\n\t\"Fast Back-To-Back\",\n\t\"Data Parity Reported\",\n\t\"\",\n\t\"\",\n\t\"Signalled Target Abort\",\n\t\"Received Target Abort\",\n\t\"Received Master Abort\",\n\t\"Signalled System Error\",\n\t\"Detected Parity Error\"\n} ;\n" > ofile
|
||||||
@@ -126,6 +175,7 @@ END {
|
|||||||
print "char *\tPciDevSelFlags [] =\n{\n\t\"Fast Devsel Speed\",\n\t\"Medium Devsel Speed\",\n\t\"Slow Devsel Speed\",\n\t\"Reserved 9&10\"\n} ;\n" > ofile
|
print "char *\tPciDevSelFlags [] =\n{\n\t\"Fast Devsel Speed\",\n\t\"Medium Devsel Speed\",\n\t\"Slow Devsel Speed\",\n\t\"Reserved 9&10\"\n} ;\n" > ofile
|
||||||
print "// Use this value for loop control during searching:\n#define PCI_DEVSELFLAGS_LEN (sizeof(PciDevSelFlags)/sizeof(char *))\n\n" > ofile
|
print "// Use this value for loop control during searching:\n#define PCI_DEVSELFLAGS_LEN (sizeof(PciDevSelFlags)/sizeof(char *))\n\n" > ofile
|
||||||
|
|
||||||
|
close(ofile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user