Add debug variable report and timeout count to AHCI methods that doodguy's computer is hanging at.

This commit is contained in:
TomAwezome 2022-09-14 18:17:36 -04:00
parent 8c132e2536
commit 0561a21eaa

View file

@ -222,6 +222,10 @@ U0 AHCIPortCmdWait(I64 port_num, I64 cmd_slot)
CAHCIPort *port = &blkdev.ahci_hba->ports[port_num]; CAHCIPort *port = &blkdev.ahci_hba->ports[port_num];
U8 str[STR_LEN]; U8 str[STR_LEN];
U64 debug_timeout = 0;
U64 debug_retries = 16;
"DEBUG: AHCI: AHCIPortCmdWait";
while (TRUE) while (TRUE)
{ {
if (!Bt(&port->cmd_issue, cmd_slot)) //When command has been processed if (!Bt(&port->cmd_issue, cmd_slot)) //When command has been processed
@ -230,6 +234,11 @@ U0 AHCIPortCmdWait(I64 port_num, I64 cmd_slot)
if (Bt(&port->interrupt_status, AHCI_PxIf_TFE)) //Task File Error ($LK,"ATAS_ERR",A="MN:ATAS_ERR"$) if (Bt(&port->interrupt_status, AHCI_PxIf_TFE)) //Task File Error ($LK,"ATAS_ERR",A="MN:ATAS_ERR"$)
{ {
error: error:
"\nDEBUG: AHCI: AHCIPortCmdWait Task File Error!\n";
AHCIDebug(port_num);
"\nPausing for 10 seconds...\n";
Busy(10 * 1000 * 1000);
if (AHCI_DEBUG) if (AHCI_DEBUG)
{ {
StrPrint(str, "Run AHCIDebug(%d);", port_num); StrPrint(str, "Run AHCIDebug(%d);", port_num);
@ -240,10 +249,24 @@ error:
throw('AHCI'); throw('AHCI');
} }
if (++debug_timeout > U16_MAX * 6)
{
debug_timeout = 0;
".";
if (!--debug_retries)
{
"\nDEBUG: AHCI: AHCIPortCmdWait stuck !\n";
AHCIDebug(port_num);
"\nDEBUG: AHCI: Halting.\n";
while (TRUE) {asm{HLT};};
}
}
Yield; // don't hang OS Yield; // don't hang OS
} }
"\n";
if (Bt(&port->interrupt_status, AHCI_PxIf_TFE)) //Second safety check  if (Bt(&port->interrupt_status, AHCI_PxIf_TFE)) //Second safety check
goto error; goto error;
} }
@ -579,6 +602,23 @@ U0 AHCIPortIdentify(CBlkDev *bd)
AHCIPortWait(bd->port_num, tS + 2); AHCIPortWait(bd->port_num, tS + 2);
Bts(&port->cmd_issue, cmd_slot); //Issue the command. Bts(&port->cmd_issue, cmd_slot); //Issue the command.
if (sys_boot_src.u16[0] == BOOT_SRC_DVD)
{
"AHCI: DEBUG: AHCIPortIdentify variable check\n";
"___________\n";
"bd : 0x%016X\n", bd;
"cmd_table: 0x%016X\n", cmd_table;
"cmd_fis: 0x%016X\n", cmd_fis;
"port: 0x%016X\n", port;
"cmd_slot: %d\n", cmd_slot;
"cmd_header: 0x%016X\n", cmd_header;
"dev_id_record: 0x%016X\n", dev_id_record;
"port->signature: 0x%016X\n", port->signature;
"cmd_fis->command: 0x%016X\n", cmd_fis->command;
"port->cmd_issue: 0x%016X\n", port->cmd_issue;
"___________\n";
}
AHCIPortCmdWait(bd->port_num, cmd_slot); AHCIPortCmdWait(bd->port_num, cmd_slot);
Free(bd->dev_id_record); Free(bd->dev_id_record);
@ -995,19 +1035,6 @@ U0 AHCIPortInit(CBlkDev *bd, CAHCIPort *port, I64 port_num)
cmd_header_base = port->cmd_list_base; cmd_header_base = port->cmd_list_base;
if (sys_boot_src.u16[0] == BOOT_SRC_DVD)
{
"AHCI: DEBUG: AHCIPortInit variable check\n";
"___________\n";
"port (addr): 0x%016X\n", port;
"port->fis_base: 0x%016X\n", port->fis_base;
"&port->fis_base: 0x%016X\n", &port->fis_base;
"port->cmd_list_base: 0x%016X\n", port->cmd_list_base;
"&port->cmd_list_base: 0x%016X\n", &port->cmd_list_base;
"cmd_header_base: 0x%016X\n", cmd_header_base;
"&cmd_header_base[0]: 0x%016X\n", &cmd_header_base[0];
"___________\n";
}
for (i = 0; i < blkdev.cmd_slot_count; i++) for (i = 0; i < blkdev.cmd_slot_count; i++)
{ {
cmd_header = &cmd_header_base[i]; cmd_header = &cmd_header_base[i];