From ee725b7a087c3134ed2310ac20daeb8f130cf336 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Sun, 24 Mar 2024 14:09:12 +0100 Subject: [PATCH] Fix 257 page allocation in ahcid. --- storage/ahcid/src/ahci/hba.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/storage/ahcid/src/ahci/hba.rs b/storage/ahcid/src/ahci/hba.rs index a11f2a1425..5ca6af72f7 100644 --- a/storage/ahcid/src/ahci/hba.rs +++ b/storage/ahcid/src/ahci/hba.rs @@ -289,7 +289,7 @@ impl HbaPort { } pub fn ata_start(&mut self, clb: &mut Dma<[HbaCmdHeader; 32]>, ctbas: &mut [Dma; 32], callback: F) -> Option - where F: FnOnce(&mut HbaCmdHeader, &mut FisRegH2D, &mut [HbaPrdtEntry; 65536], &mut [Mmio; 16]) { + where F: FnOnce(&mut HbaCmdHeader, &mut FisRegH2D, &mut [HbaPrdtEntry; PRDT_ENTRIES], &mut [Mmio; 16]) { //TODO: Should probably remove self.is.write(u32::MAX); @@ -414,8 +414,10 @@ pub struct HbaCmdTable { _rsv: [Mmio; 48], // Reserved // 0x80 - prdt_entry: [HbaPrdtEntry; 65536], // Physical region descriptor table entries, 0 ~ 65535 + prdt_entry: [HbaPrdtEntry; PRDT_ENTRIES], // Physical region descriptor table entries, 0 ~ 65535 } +const CMD_TBL_SIZE: usize = 256 * 4096; +const PRDT_ENTRIES: usize = (CMD_TBL_SIZE - 128) / size_of::(); #[repr(packed)] pub struct HbaCmdHeader {