Przeglądaj źródła

[ehci] Add extra debugging information

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 lat temu
rodzic
commit
17a200257a
1 zmienionych plików z 73 dodań i 2 usunięć
  1. 73
    2
      src/drivers/usb/ehci.c

+ 73
- 2
src/drivers/usb/ehci.c Wyświetl plik

@@ -173,6 +173,61 @@ static int ehci_ctrl_reachable ( struct ehci_device *ehci, void *ptr ) {
173 173
 	return -ENOTSUP;
174 174
 }
175 175
 
176
+/******************************************************************************
177
+ *
178
+ * Diagnostics
179
+ *
180
+ ******************************************************************************
181
+ */
182
+
183
+/**
184
+ * Dump host controller registers
185
+ *
186
+ * @v ehci		EHCI device
187
+ */
188
+static __unused void ehci_dump ( struct ehci_device *ehci ) {
189
+	uint8_t caplength;
190
+	uint16_t hciversion;
191
+	uint32_t hcsparams;
192
+	uint32_t hccparams;
193
+	uint32_t usbcmd;
194
+	uint32_t usbsts;
195
+	uint32_t usbintr;
196
+	uint32_t frindex;
197
+	uint32_t ctrldssegment;
198
+	uint32_t periodiclistbase;
199
+	uint32_t asynclistaddr;
200
+	uint32_t configflag;
201
+
202
+	/* Do nothing unless debugging is enabled */
203
+	if ( ! DBG_LOG )
204
+		return;
205
+
206
+	/* Dump capability registers */
207
+	caplength = readb ( ehci->cap + EHCI_CAP_CAPLENGTH );
208
+	hciversion = readw ( ehci->cap + EHCI_CAP_HCIVERSION );
209
+	hcsparams = readl ( ehci->cap + EHCI_CAP_HCSPARAMS );
210
+	hccparams = readl ( ehci->cap + EHCI_CAP_HCCPARAMS );
211
+	DBGC ( ehci, "EHCI %s caplen %02x hciversion %04x hcsparams %08x "
212
+	       "hccparams %08x\n", ehci->name, caplength, hciversion,
213
+	       hcsparams,  hccparams );
214
+
215
+	/* Dump operational registers */
216
+	usbcmd = readl ( ehci->op + EHCI_OP_USBCMD );
217
+	usbsts = readl ( ehci->op + EHCI_OP_USBSTS );
218
+	usbintr = readl ( ehci->op + EHCI_OP_USBINTR );
219
+	frindex = readl ( ehci->op + EHCI_OP_FRINDEX );
220
+	ctrldssegment = readl ( ehci->op + EHCI_OP_CTRLDSSEGMENT );
221
+	periodiclistbase = readl ( ehci->op + EHCI_OP_PERIODICLISTBASE );
222
+	asynclistaddr = readl ( ehci->op + EHCI_OP_ASYNCLISTADDR );
223
+	configflag = readl ( ehci->op + EHCI_OP_CONFIGFLAG );
224
+	DBGC ( ehci, "EHCI %s usbcmd %08x usbsts %08x usbint %08x frindx "
225
+	       "%08x\n", ehci->name, usbcmd, usbsts, usbintr, frindex );
226
+	DBGC ( ehci, "EHCI %s ctrlds %08x period %08x asyncl %08x cfgflg "
227
+	       "%08x\n", ehci->name, ctrldssegment, periodiclistbase,
228
+	       asynclistaddr, configflag );
229
+}
230
+
176 231
 /******************************************************************************
177 232
  *
178 233
  * USB legacy support
@@ -233,6 +288,14 @@ static void ehci_legacy_claim ( struct ehci_device *ehci,
233 288
 	if ( ! legacy )
234 289
 		return;
235 290
 
291
+	/* Dump original SMI usage */
292
+	pci_read_config_dword ( pci, ( legacy + EHCI_USBLEGSUP_CTLSTS ),
293
+				&ctlsts );
294
+	if ( ctlsts ) {
295
+		DBGC ( ehci, "EHCI %s BIOS using SMIs: %08x\n",
296
+		       ehci->name, ctlsts );
297
+	}
298
+
236 299
 	/* Claim ownership */
237 300
 	pci_write_config_byte ( pci, ( legacy + EHCI_USBLEGSUP_OS ),
238 301
 				EHCI_USBLEGSUP_OS_OWNED );
@@ -276,9 +339,11 @@ static void ehci_legacy_claim ( struct ehci_device *ehci,
276 339
  */
277 340
 static void ehci_legacy_release ( struct ehci_device *ehci,
278 341
 				  struct pci_device *pci ) {
342
+	unsigned int legacy = ehci->legacy;
343
+	uint32_t ctlsts;
279 344
 
280 345
 	/* Do nothing unless legacy support capability is present */
281
-	if ( ! ehci->legacy )
346
+	if ( ! legacy )
282 347
 		return;
283 348
 
284 349
 	/* Do nothing if releasing ownership is prevented */
@@ -289,8 +354,14 @@ static void ehci_legacy_release ( struct ehci_device *ehci,
289 354
 	}
290 355
 
291 356
 	/* Release ownership */
292
-	pci_write_config_byte ( pci, ( ehci->legacy + EHCI_USBLEGSUP_OS ), 0 );
357
+	pci_write_config_byte ( pci, ( legacy + EHCI_USBLEGSUP_OS ), 0 );
293 358
 	DBGC ( ehci, "EHCI %s released ownership to BIOS\n", ehci->name );
359
+
360
+	/* Dump restored SMI usage */
361
+	pci_read_config_dword ( pci, ( legacy + EHCI_USBLEGSUP_CTLSTS ),
362
+				&ctlsts );
363
+	DBGC ( ehci, "EHCI %s BIOS reclaimed SMIs: %08x\n",
364
+	       ehci->name, ctlsts );
294 365
 }
295 366
 
296 367
 /******************************************************************************

Ładowanie…
Anuluj
Zapisz