瀏覽代碼

Improved debug messages.

Prevented find_pci_device() from being an endless loop.
tags/v0.9.3
Michael Brown 19 年之前
父節點
當前提交
211a607147
共有 1 個檔案被更改,包括 13 行新增13 行删除
  1. 13
    13
      src/drivers/bus/pci.c

+ 13
- 13
src/drivers/bus/pci.c 查看文件

@@ -73,7 +73,7 @@ static int fill_pci_device ( struct pci_device *pci ) {
73 73
 		pci_read_config_byte ( pci, PCI_INTERRUPT_LINE, &pci->irq );
74 74
 	}
75 75
 
76
-	DBG ( "PCI found %hhx:%hhx.%d Class %hx: %hx:%hx (rev %hhx)\n",
76
+	DBG ( "PCI found device %hhx:%hhx.%d Class %hx: %hx:%hx (rev %hhx)\n",
77 77
 	      PCI_BUS ( pci->busdevfn ), PCI_DEV ( pci->busdevfn ),
78 78
 	      PCI_FUNC ( pci->busdevfn ), pci->class, pci->vendor, pci->dev_id,
79 79
 	      pci->revision );
@@ -92,7 +92,7 @@ void adjust_pci_device ( struct pci_device *pci ) {
92 92
 	pci_read_config_word ( pci, PCI_COMMAND, &pci_command );
93 93
 	new_command = pci_command | PCI_COMMAND_MASTER | PCI_COMMAND_IO;
94 94
 	if ( pci_command != new_command ) {
95
-		DBG ( "%hhx:%hhx.%d : PCI BIOS has not enabled this device! "
95
+		DBG ( "PCI BIOS has not enabled device %hhx:%hhx.%d! "
96 96
 		      "Updating PCI command %hX->%hX\n",
97 97
 		      PCI_BUS ( pci->busdevfn ), PCI_DEV ( pci->busdevfn ),
98 98
 		      PCI_FUNC ( pci->busdevfn ), pci_command, new_command );
@@ -100,8 +100,8 @@ void adjust_pci_device ( struct pci_device *pci ) {
100 100
 	}
101 101
 	pci_read_config_byte ( pci, PCI_LATENCY_TIMER, &pci_latency);
102 102
 	if ( pci_latency < 32 ) {
103
-		DBG ( "%hhx:%hhx.%d : PCI latency timer (CFLT) "
104
-		      "is unreasonably low at %d. Setting to 32.\n",
103
+		DBG ( "PCI device %hhx:%hhx.%d latency timer is "
104
+		      "unreasonably low at %d. Setting to 32.\n",
105 105
 		      PCI_BUS ( pci->busdevfn ), PCI_DEV ( pci->busdevfn ),
106 106
 		      PCI_FUNC ( pci->busdevfn ), pci_latency );
107 107
 		pci_write_config_byte ( pci, PCI_LATENCY_TIMER, 32);
@@ -139,7 +139,8 @@ int find_pci_device ( struct pci_device *pci,
139 139
 	/* Iterate through all possible PCI bus:dev.fn combinations,
140 140
 	 * starting where we left off.
141 141
 	 */
142
-	for ( ; pci->busdevfn <= 0xffff ; pci->busdevfn++ ) {
142
+	DBG ( "PCI searching for device matching driver %s\n", driver->name );
143
+	do {
143 144
 		/* If we've already used this device, skip it */
144 145
 		if ( pci->already_tried ) {
145 146
 			pci->already_tried = 0;
@@ -157,8 +158,8 @@ int find_pci_device ( struct pci_device *pci,
157 158
 		/* If driver has a class, and class matches, use it */
158 159
 		if ( driver->class && 
159 160
 		     ( driver->class == pci->class ) ) {
160
-			DBG ( "Driver %s matches class %hx\n",
161
-			      driver->name, driver->class );
161
+			DBG ( "PCI found class %hx matching driver %s\n",
162
+			      driver->class, driver->name );
162 163
 			pci->name = driver->name;
163 164
 			pci->already_tried = 1;
164 165
 			return 1;
@@ -170,17 +171,16 @@ int find_pci_device ( struct pci_device *pci,
170 171
 			
171 172
 			if ( ( pci->vendor == id->vendor ) &&
172 173
 			     ( pci->dev_id == id->dev_id ) ) {
173
-				DBG ( "Device %s (driver %s) matches "
174
-				      "ID %hx:%hx\n", id->name, driver->name,
175
-				      id->vendor, id->dev_id );
174
+				DBG ( "PCI found ID %hx:%hx (device %s) "
175
+				      "matching driver %s\n", id->vendor,
176
+				      id->dev_id, id->name, driver->name );
176 177
 				pci->name = id->name;
177 178
 				pci->already_tried = 1;
178 179
 				return 1;
179 180
 			}
180 181
 		}
181
-
182
-		DBG ( "No match in driver %s\n", driver->name );
183
-	}
182
+	} while ( ++pci->busdevfn );
183
+	DBG ( "PCI failed to find device matching driver %s\n", driver->name );
184 184
 
185 185
 	/* No device found */
186 186
 	return 0;

Loading…
取消
儲存