mirror of
https://github.com/ipxe/ipxe
synced 2026-05-08 15:02:55 +03:00
[build] Allow PCI_ROM() and ISA_ROM() to span multiple lines
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -470,15 +470,18 @@ static void intelx_remove ( struct pci_device *pci ) {
|
||||
/** PCI device IDs */
|
||||
static struct pci_device_id intelx_nics[] = {
|
||||
PCI_ROM ( 0x8086, 0x10f7, "82599-kx4", "82599 (KX/KX4)", 0 ),
|
||||
PCI_ROM ( 0x8086, 0x10f8, "82599-combo-backplane", "82599 (combined backplane; KR/KX4/KX)", 0 ),
|
||||
PCI_ROM ( 0x8086, 0x10f8, "82599-combo-backplane",
|
||||
"82599 (combined backplane; KR/KX4/KX)", 0 ),
|
||||
PCI_ROM ( 0x8086, 0x10f9, "82599-cx4", "82599 (CX4)", 0 ),
|
||||
PCI_ROM ( 0x8086, 0x10fb, "82599-sfp", "82599 (SFI/SFP+)", 0 ),
|
||||
PCI_ROM ( 0x8086, 0x10fc, "82599-xaui", "82599 (XAUI/BX4)", 0 ),
|
||||
PCI_ROM ( 0x8086, 0x151c, "82599-tn", "82599 (TN)", 0 ),
|
||||
PCI_ROM ( 0x8086, 0x1528, "x540t", "X540-AT2/X540-BT2", 0 ),
|
||||
PCI_ROM ( 0x8086, 0x154d, "82599-sfp-sf2", "82599 (SFI/SFP+)", 0 ),
|
||||
PCI_ROM ( 0x8086, 0x1557, "82599en-sfp", "82599 (Single Port SFI Only)", 0 ),
|
||||
PCI_ROM ( 0x8086, 0x1560, "x540t1", "X540-AT2/X540-BT2 (with single port NVM)", 0 ),
|
||||
PCI_ROM ( 0x8086, 0x1557, "82599en-sfp",
|
||||
"82599 (Single Port SFI Only)", 0 ),
|
||||
PCI_ROM ( 0x8086, 0x1560, "x540t1",
|
||||
"X540-AT2/X540-BT2 (with single port NVM)", 0 ),
|
||||
PCI_ROM ( 0x8086, 0x1563, "x550t2", "X550-T2", 0 ),
|
||||
PCI_ROM ( 0x8086, 0x15ab, "x552", "X552", 0 ),
|
||||
PCI_ROM ( 0x8086, 0x15c8, "x553t", "X553/X557-AT", 0 ),
|
||||
|
||||
+10
-7
@@ -254,23 +254,27 @@ sub build_ipxe_nic_list {
|
||||
my $hex_id = qr/0 x [[:xdigit:]]{4} /x;
|
||||
my $quote = qr/ ['"] /x;
|
||||
my $non_space = qr/ [^\s] /x;
|
||||
my $rom_decl = qr/^ \s* ( (PCI|ISA)_ROM \s*
|
||||
\( \s* .*? \s* \) \s* ) [,;]/msx;
|
||||
my $rom_line_counter = 0;
|
||||
foreach my $c_path ( sort @c_files ) {
|
||||
my $legacy = 0;
|
||||
open( my $fh, "<", $c_path );
|
||||
my $content = do { local $/ = undef; <$fh> };
|
||||
close($fh);
|
||||
my $c_file = $c_path;
|
||||
$c_file =~ s{^\Q$dir\E/?}{} if -d $dir; # Strip directory from reported filename
|
||||
my $ipxe_driver = basename($c_file, '.c');
|
||||
while(<$fh>) {
|
||||
# Most likely EtherBoot legacy API
|
||||
$legacy = 1 if m/struct \s* nic \s*/x;
|
||||
$legacy = 1 if $content =~ m/struct \s* nic \s*/x;
|
||||
while( $content =~ m/$rom_decl/g ) {
|
||||
local $_ = $1;
|
||||
|
||||
# parse ISA|PCI_ROM lines into hashref and append to $ipxe_nic_list
|
||||
next unless m/^ \s* (?:ISA|PCI)_ROM /x;
|
||||
next unless m/^ \s* (?:ISA|PCI)_ROM /sx;
|
||||
$rom_line_counter++;
|
||||
chomp;
|
||||
#say; # for debugging regexp
|
||||
if ( m/^ \s* ISA_ROM \s* \( \s* $quote ( .*? ) $quote \s* , \s* $quote ( .*? ) $quote \s* \) /x ) {
|
||||
if ( m/^ \s* ISA_ROM \s* \( \s* $quote ( .*? ) $quote \s* , \s* $quote ( .*? ) $quote \s* \) /sx ) {
|
||||
my $image = $1;
|
||||
my $name = $2;
|
||||
push @$ipxe_nic_list, {
|
||||
@@ -283,7 +287,7 @@ sub build_ipxe_nic_list {
|
||||
};
|
||||
next;
|
||||
}
|
||||
if ( m/^ \s* PCI_ROM \s* \( \s* ($hex_id) \s* , \s* ($hex_id) \s* , \s* $quote (.*?) $quote \s* , \s* $quote (.*?) $quote /x ) {
|
||||
if ( m/^ \s* PCI_ROM \s* \( \s* ($hex_id) \s* , \s* ($hex_id) \s* , \s* $quote (.*?) $quote \s* , \s* $quote (.*?) $quote /sx ) {
|
||||
my $vendor_id = lc $1;
|
||||
my $device_id = lc $2;
|
||||
my $name = $3;
|
||||
@@ -301,7 +305,6 @@ sub build_ipxe_nic_list {
|
||||
next;
|
||||
}
|
||||
}
|
||||
close($fh);
|
||||
}
|
||||
|
||||
# Verify all ROM lines where parsed properly
|
||||
|
||||
@@ -36,9 +36,10 @@ if ( $debug ) {
|
||||
my %RE = (
|
||||
'parse_driver_class' => qr{ drivers/ (\w+?) / }x,
|
||||
'parse_family' => qr{^ (?:\./)? (.*) \..+? $}x,
|
||||
'find_rom_line' => qr/^ \s* ( (PCI|ISA)_ROM \s* \( \s* (.*?) ) $/x,
|
||||
'extract_pci_id' => qr/^ \s* 0x([0-9A-Fa-f]{4}) \s* ,? \s* (.*) $/x,
|
||||
'extract_quoted_string' => qr/^ \s* \" ([^\"]*?) \" \s* ,? \s* (.*) $/x,
|
||||
'find_rom_line' => qr/^ \s* ( (PCI|ISA)_ROM \s*
|
||||
\( \s* (.*?) \s* \) \s* ) [,;]/msx,
|
||||
'extract_pci_id' => qr/^ \s* 0x([0-9A-Fa-f]{4}) \s* ,? \s* (.*) $/sx,
|
||||
'extract_quoted_string' => qr/^ \s* \" ([^\"]*?) \" \s* ,? \s* (.*) $/sx,
|
||||
);
|
||||
|
||||
# Show help if required arguments are missing or help was requested
|
||||
@@ -95,10 +96,11 @@ sub process_source_file {
|
||||
# and # output Makefile rules
|
||||
open( my $fh, "<", $state->{'source_file'} )
|
||||
or die "Couldn't open $state->{source_file}: $!\n";
|
||||
while (<$fh>) {
|
||||
process_rom_decl($state, $1, $2, $3) if m/$RE{find_rom_line}/;
|
||||
}
|
||||
my $content = do { local $/ = undef; <$fh> };
|
||||
close($fh) or die "Couldn't close $source_file: $!\n";
|
||||
while ( $content =~ m/$RE{find_rom_line}/g ) {
|
||||
process_rom_decl($state, $1, $2, $3);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user