From f82f12fd8b722ffdf8e9f9d584dd8dc5b6f420c7 Mon Sep 17 00:00:00 2001
From: kieron <kieron@6dbc8c32-bb84-406f-8558-d1cf31a0ab0c>
Date: Wed, 4 Apr 2018 21:08:45 +0000
Subject: [PATCH] Added wildcards to driver registration

git-svn-id: https://spexeah.com:8443/svn/Asuro@292 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
---
 src/driver/testdriver.pas | 12 ++++++------
 src/drivermanagement.pas  | 17 ++++++++++-------
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/src/driver/testdriver.pas b/src/driver/testdriver.pas
index f43a3433..5fc22436 100644
--- a/src/driver/testdriver.pas
+++ b/src/driver/testdriver.pas
@@ -19,12 +19,12 @@ var
     devID : TDeviceIdentifier;
 
 begin
-    devID.bus:= biPCI;
-    devID.id0:= $00008086;
-    devID.id1:= $00000006;
-    devID.id2:= $00000000;
-    devID.id3:= $00000000;
-    devID.ex:= nil;
+    devID.bus:= biPCI; { PCI BUS }
+    devID.id0:= idANY; { ANY DEVICE MANUFACTURER }
+    devID.id1:= $00000006; { CLASS }
+    devID.id2:= $00000000; { SUBCLASS }
+    devID.id3:= $00000000; { PROGIF }
+    devID.ex:= nil; { NO EXTENDED INFO }
     drivermanagement.register_driver(@devID, @load);
 end;
 
diff --git a/src/drivermanagement.pas b/src/drivermanagement.pas
index 92bc8f62..fec8b613 100644
--- a/src/drivermanagement.pas
+++ b/src/drivermanagement.pas
@@ -13,6 +13,9 @@ interface
 uses
     console, util, strings, lmemorymanager;
 
+const
+    idANY = $FFFFFFFF;
+
 type
     PDevEx = ^TDevEx;
     TDevEx = record
@@ -20,7 +23,7 @@ type
         ex  : PDevEx;
     end;
 
-    TBusIdentifier = (biUnknown, biPCI, biUSB, bii2c, biPCIe);
+    TBusIdentifier = (biUnknown, biPCI, biUSB, bii2c, biPCIe, biANY);
 
     PDeviceIdentifier = ^TDeviceIdentifier;
     TDeviceIdentifier = record
@@ -57,11 +60,11 @@ var
 
 begin
     identifiers_match:= true;
-    identifiers_match:= identifiers_match and (i1^.Bus = i2^.Bus);
-    identifiers_match:= identifiers_match and (i1^.id0 = i2^.id0);
-    identifiers_match:= identifiers_match and (i1^.id1 = i2^.id1);
-    identifiers_match:= identifiers_match and (i1^.id2 = i2^.id2);
-    identifiers_match:= identifiers_match and (i1^.id3 = i2^.id3);
+    identifiers_match:= identifiers_match and ((i1^.Bus = i2^.Bus) OR (i1^.Bus = biANY) OR (i2^.Bus = biANY));
+    identifiers_match:= identifiers_match and ((i1^.id0 = i2^.id0) OR (i1^.id0 = $FFFFFFFF) OR (i2^.id0 = $FFFFFFFF));
+    identifiers_match:= identifiers_match and ((i1^.id1 = i2^.id1) OR (i1^.id1 = $FFFFFFFF) OR (i2^.id1 = $FFFFFFFF));
+    identifiers_match:= identifiers_match and ((i1^.id2 = i2^.id2) OR (i1^.id2 = $FFFFFFFF) OR (i2^.id2 = $FFFFFFFF));
+    identifiers_match:= identifiers_match and ((i1^.id3 = i2^.id3) OR (i1^.id3 = $FFFFFFFF) OR (i2^.id3 = $FFFFFFFF));
     ll1:= i1^.ex;
     ll2:= i2^.ex;
     while true do begin
@@ -70,7 +73,7 @@ begin
         identifiers_match:= identifiers_match and (b1 = b2);
         if not (b1 and b2) then exit;
         if b1 = b2 then begin
-            identifiers_match:= identifiers_match and (ll1^.idN = ll2^.idN);    
+            identifiers_match:= identifiers_match and ((ll1^.idN = ll2^.idN) OR (ll1^.idN = $FFFFFFFF) OR (ll2^.idN = $FFFFFFFF));    
         end else begin
             identifiers_match:= false;
             exit;