mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2025-04-18 05:38:36 +01:00
Improve AHCI performance by removing checks for blkdev max_reads and max_writes limits.
Fix AHCI port and command waits hanging entire OS by using Yield. Fix DVD boot hardcoded AHCI port number, correctly search ports for ATAPI drive. Fix compiler unused variable warnings in Mount2.
This commit is contained in:
parent
0f9d6b43f8
commit
fad8608b87
7 changed files with 22 additions and 19 deletions
Binary file not shown.
|
@ -1,7 +1,7 @@
|
|||
//Make Your own Distro by #include-ing this file.
|
||||
|
||||
//#define STD_DISTRO_DVD_CONFIG "TB\nScale2Mem(2048,0x40000)\nT \n\n1024\n768\n\n\n"
|
||||
#define STD_DISTRO_DVD_CONFIG "TB\nScale2Mem(2048,0x40000)\nT0\n\n5\n\n\n"
|
||||
#define STD_DISTRO_DVD_CONFIG "TB\nScale2Mem(2048,0x40000)\nT\n\n5\n\n\n"
|
||||
|
||||
U0 MakeMyISO(U8 *_out_iso_filename)
|
||||
{//Does everything with current drive.
|
||||
|
|
|
@ -50,6 +50,7 @@ Bool AHCIPortWait(I64 port_num, F64 timeout, Bool throwing=TRUE)
|
|||
{
|
||||
if (!(port->task_file_data & (ATAS_DRQ | ATAS_BSY)))
|
||||
return TRUE;
|
||||
Yield; // don't hang OS
|
||||
}
|
||||
while (timeout > tS);
|
||||
if (throwing)
|
||||
|
@ -96,6 +97,7 @@ error:
|
|||
ZenithErr("AHCI: Port %d: Command failed!\n", port_num);
|
||||
throw('AHCI');
|
||||
}
|
||||
Yield; // don't hang OS
|
||||
}
|
||||
if (Bt(&port->interrupt_status, AHCI_PxIf_TFE)) //Second safety check
|
||||
goto error;
|
||||
|
@ -204,7 +206,7 @@ U8 *AHCIBufferAlign(CBlkDev *bd, U8 *user_buf, I64 buf_size, Bool write)
|
|||
//In the case of an inadequate buffer address being passed in, we will use a MAlloced internal buffer.
|
||||
if(user_buf + buf_size > U32_MAX || user_buf & 1)
|
||||
{//if the buffer is not within 32-bit address space or not U16-aligned
|
||||
"Aligning buffer under 32-bit range\n";
|
||||
// "Aligning buffer under 32-bit range\n";
|
||||
Free(bd->prd_buf);
|
||||
bd->prd_buf = MAlloc(buf_size, Fs->code_heap);
|
||||
Bts(&bd->flags, BDf_INTERNAL_BUF);
|
||||
|
@ -590,8 +592,8 @@ Bool AHCIAtapiRBlks(CDrive *drive, U8 *buf, I64 blk, I64 count)
|
|||
while (count > 0)
|
||||
{
|
||||
nn = count;
|
||||
if (nn > bd->max_reads)
|
||||
nn = bd->max_reads;
|
||||
// if (nn > bd->max_reads)
|
||||
// nn = bd->max_reads;
|
||||
|
||||
if (bd->type == BDT_ATAPI)
|
||||
{
|
||||
|
@ -612,7 +614,7 @@ Bool AHCIAtapiRBlks(CDrive *drive, U8 *buf, I64 blk, I64 count)
|
|||
|
||||
n = (l2 + spc - 1) / spc;
|
||||
|
||||
"AHCIAtapiBlksRead(bd, dvd_buf, %d, %d);", blk2 / spc, n;
|
||||
// "AHCIAtapiBlksRead(bd, dvd_buf, %d, %d);", blk2 / spc, n;
|
||||
AHCIAtapiBlksRead(bd, dvd_buf, blk2 / spc, n);
|
||||
|
||||
if (bd->flags & BDF_READ_CACHE)
|
||||
|
@ -642,8 +644,8 @@ Bool AHCIAtaRBlks(CDrive *drive, U8 *buf, I64 blk, I64 count)
|
|||
while (count > 0)
|
||||
{
|
||||
n = count;
|
||||
if (n > bd->max_reads)
|
||||
n = bd->max_reads;
|
||||
// if (n > bd->max_reads)
|
||||
// n = bd->max_reads;
|
||||
|
||||
if (bd->type == BDT_ATA)
|
||||
AHCIAtaBlksRead(bd, buf, blk, n);
|
||||
|
@ -666,8 +668,8 @@ Bool AHCIAtaWBlks(CDrive *drive, U8 *buf, I64 blk, I64 count)
|
|||
while (count > 0)
|
||||
{
|
||||
n = count;
|
||||
if (n > bd->max_writes)
|
||||
n = bd->max_writes;
|
||||
// if (n > bd->max_writes)
|
||||
// n = bd->max_writes;
|
||||
AHCIAtaBlksWrite(bd, buf, blk, n);
|
||||
|
||||
buf += n << BLK_SIZE_BITS;
|
||||
|
|
|
@ -70,7 +70,7 @@ Bool BlkRead(CDrive *drive, U8 *buf, I64 blk, I64 count)
|
|||
break;
|
||||
case BDT_ATAPI: // ahci
|
||||
res = AHCIAtapiRBlks(drive, buf, blk, count);
|
||||
D(buf, count);
|
||||
// D(buf, count);
|
||||
break;
|
||||
}
|
||||
bd->last_time = tS;
|
||||
|
|
|
@ -16,9 +16,9 @@ Bool ISOInit(CDrive *drive, I64 blk)
|
|||
while (TRUE)
|
||||
{
|
||||
drive->size = MaxI64(drive->size, (i + 1) * spc);
|
||||
"BlkRead(drive, iso, %d, %d);", i * spc, spc;
|
||||
// "BlkRead(drive, iso, %d, %d);", i * spc, spc;
|
||||
BlkRead(drive, iso, i * spc, spc);
|
||||
D(iso);
|
||||
// D(iso);
|
||||
// Sleep(3000);
|
||||
buf[0](U32) = iso->id[0](U32);
|
||||
buf[4](U16) = iso->id[4](U8);
|
||||
|
|
|
@ -2,7 +2,8 @@ U0 InstallDrive(U8 drv_let)
|
|||
{
|
||||
U8 *st;
|
||||
|
||||
Sleep(3000);
|
||||
while (!DriveCheck(blkdev.let_to_drive[drv_let - 'A'], FALSE))
|
||||
Sleep(100);
|
||||
|
||||
ExePrint("CopyTree(\"::/\",\"%C:/\");", drv_let);
|
||||
ExePrint("DirMake(\"%C:/Tmp\");", drv_let);
|
||||
|
|
|
@ -6,8 +6,8 @@ I64 SATARep()
|
|||
|
||||
"\nAHCI version %X.%1X%1X\n",
|
||||
blkdev.ahci_hba->version >> 16, (blkdev.ahci_hba->version & 0xFF00) >> 8, blkdev.ahci_hba->version & 0xFF;
|
||||
/*
|
||||
if (dev.pci_head)
|
||||
|
||||
/* if (dev.pci_head)
|
||||
{
|
||||
pci = PCIDevFind(PCIC_STORAGE, PCISC_AHCI);
|
||||
// ClassRep(pci);
|
||||
|
@ -55,9 +55,9 @@ I64 SATARep()
|
|||
U8 Mount2(U8 boot_drive_let, CDoc *_doc, Bool _caller_is_prtdisk)
|
||||
{//If _doc, called by $LK,"::/Kernel/KConfig.CC"$ else called by $LK,"Mount",A="MN:Mount"$().
|
||||
I64 count, total = 0, num_hints, drv_let, type, unit, prt_num, port = -1; // ahci
|
||||
U8 blks_buf[STR_LEN], addr_buf[STR_LEN], base0_buf[STR_LEN], base1_buf[STR_LEN],
|
||||
U8 blks_buf[STR_LEN], addr_buf[STR_LEN], base0_buf[STR_LEN],// base1_buf[STR_LEN],
|
||||
*filename = NULL, *filename2 = NULL, res = 0;
|
||||
CATARep *head = NULL, *tmpha;
|
||||
// CATARep *head = NULL, *tmpha;
|
||||
Bool whole_drive, make_free;
|
||||
CDoc *doc;
|
||||
|
||||
|
@ -161,7 +161,7 @@ U8 Mount2(U8 boot_drive_let, CDoc *_doc, Bool _caller_is_prtdisk)
|
|||
}
|
||||
DocPrint(doc, "\"bd = BlkDevNextFreeSlot('%C', %d); bd->unit = %d;\n\";\n", drv_let, type, unit);
|
||||
DocPrint(doc, "bd = BlkDevNextFreeSlot(\'%C\', %d); bd->unit = %d;\n", drv_let, type, unit);
|
||||
if (port != -1) // ahci
|
||||
if (port != -1 && *base0_buf) // ahci
|
||||
{
|
||||
DocPrint(doc, "\"AHCIPortInit(bd, &blkdev.ahci_hba->ports[%d], %d);\n\";\n", port, port);
|
||||
DocPrint(doc, "AHCIPortInit(bd, &blkdev.ahci_hba->ports[%d], %d);\n", port, port);
|
||||
|
@ -187,7 +187,7 @@ U8 Mount2(U8 boot_drive_let, CDoc *_doc, Bool _caller_is_prtdisk)
|
|||
|
||||
case BDT_ATA:
|
||||
case BDT_ATAPI:
|
||||
if (type == BDT_ATAPI && !*base0_buf)
|
||||
if (type == BDT_ATAPI && !*base0_buf && _doc)
|
||||
{
|
||||
// DocPrint(doc, "\"GetBaseUnit(bd);\n\";\n");
|
||||
// DocPrint(doc, "GetBaseUnit(bd);\n"); //Only $LK,"::/Kernel/KConfig.CC"$
|
||||
|
|
Loading…
Reference in a new issue