Getting strange readings from AHCI device

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Ethin
Member
Member
Posts: 625
Joined: Sun Jun 23, 2019 5:36 pm
Location: North Dakota, United States

Getting strange readings from AHCI device

Post by Ethin »

I'm trying to debug my kernel; I implemented AHCI yesterday and got it (sort-of) working today. The problem is that I get weird values, and therefore can't read anything because my kernel thinks that the device has no ports.
This is the strange output I'm getting:
Normal output:
AHCI: found AHCI-capable device with vendor 8086 and device 2922
AHCI: detected base address for AHCI driver: FEBF5000
AHCI: Inserting device at position 0
Abnormal output:
AHCI: Device scan: dbg: HbaMem {cap: 80000000C0141F05, ghc: 3F00000000, is: 10000, pi: 0, vs: 0, ccc_ctl: 0, ccc_pts: 0, em_loc: 0, em_ctl: 0, cap2: 0, bohc: 0}
I'm running qemu with the following command line:
qemu-system-x86_64 -drive format=raw,file=target\x86_64-kernel-none\debug\bootimage-kernel.bin -serial stdio -soundhw all -drive format=raw,id=disk,file=disk.img,if=none -device ich9-ahci,id=ahci -device ide-drive,drive=disk,bus=ahci.0 -no-reboot -cpu max
Am I running QEMU wrong, or is my code wrong? The code is at https://github.com/ethindp/kernel/blob/ ... ge/ahci.rs (lines 988-1,044). (Yes, I know, the file is ridiculously long; most of that is because I used bindgen to figure out how to do bitfields in Rust since it doesn't support those natively yet. It definitely could use some cleanup, I admit. Sorry about that.)
Ethin
Member
Member
Posts: 625
Joined: Sun Jun 23, 2019 5:36 pm
Location: North Dakota, United States

Re: Getting strange readings from AHCI device

Post by Ethin »

Update: fixed the problem. Yay!
Post Reply