-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PCI ATA+AHCI Support #39
Conversation
- clean up all code and add error checks for everything - Adjust some structures - Implement read and write - Add better checking with the AHCI controller for completion and error status
- Interrupt based notification when the read/write is done - Bigger read and write sizes than one block - Perhaps then integrate it into the system with proper syscalls and everything
Wow, this is great! Really appreciate the effort, this is a big one. It works for me, a few things that come to mind:
For what it's worth, I tried booting on my old laptop and got a black screen with the pci/ahci init calls in One thing I would ask before merging would be to fix the warnings (you can compile with I'll keep reading the code for now, let me know when merge time comes, or if there's anything I can do. |
Wow! Thanks for the detailed reply! I'm glad you're happy with what I've added so far! Sorry about the warnings. I had every intention on having them fixed before submitting the pull request, but I got so focused on finishing before my summer Uni courses started that I just saw the build pass and the warnings completely slipped my mind haha. I just wanna confirm some things quickly then about the memory allocation:
I'm hoping I can get a quick commit in with some simple short term changes within the next week or so. Mainly it would be:
Then long term maybe I can add some of the other things discussed like getting it working with ext2 and a block abstraction layer, as well as getting it to work on physical hardware. Lastly, here are some of the resources I used when adding this. Hopefully they can be of help to you as well!
Thanks again! |
You're right on both counts, but I realize now that it's not the best way to do things because of this deallocation+reallocation of the physical frames, which can be avoided (and should, fragmentation is scary). It should be done in a similar way as in SnowflakeOS/kernel/src/devices/fb.c Lines 28 to 35 in 8fc4dce
paging_remap_pages function probably, but it'll do fine for now :)
That's right, and I think it's fair to assume it will stay that way although it's not yet documented (I will so I don't forget). Just to make sure, is this for a one-time (or per-device) allocation ? If at all possible, this is the way to go. Thank you for the resources, these are great and definitely a needed addition to my reading. edit: silly mistake in the code above with the simple division by 0x1000, which you did correctly. There's even a function for that, |
Acknowledge that memcpy doesn't take a volatile pointer, this is ok because memcpy doesn't mess around with the memory
Hey! Firstly, no worries about the late response. Please don't feel rushed at all with this. I'm working on a few other projects, as well as some school stuff, so I'm taking the pace of this a bit slower. I added the spin/loop checks and fixed the warnings like discussed. In regards to expanding the size of a read/write beyond a single 512 byte block, some of the other examples I've been looking at simply have the function caller provide the buffer location, and the read/write function simply sets that as the location for the ahci controller to write to. I think this would probably be a better method, especially considering the case where a caller may want the memory location to actually be a mmio'd address. Additionally, it removes the overhead of memcpying over the data after the read is complete/before the write. Changing it to this method would be super fast for any changes made to the driver, so I'm thinking of just leaving that until I begin trying to implement the driver within the system (which like I said will be a bit more of a long term goal haha). So basically, this is what I have for now, and I may have some bigger, longer term changes coming in the next months if possible. Hope that's alright. Let me know what you think! (oh, and thanks for confirming my questions above regarding the mem allocation!) |
Hi! Just wanted to let you know that I plan to merge this PR in the coming week, I like those changes and from brief testing it looks good. I think your idea of having the caller provide the buffer to write to makes a ton of sense, I think this is the way to go. |
Hey,
I took a shot at adding basic AHCI+SATA support. Still needs a lot of work, it can only read and write one block at a time, and it's only within the kernel space. And only supports ATA requests, not ATAPI.
Let me know if it works for you and what you think. I'd be happy to make adjustments based on your feedback and whatnot. Once I get it aligned with what you're looking for, I'm planning to add some more features as well and make it a bit robust. Maybe after that it can be integrated within the whole system so the root filesystem doesn't have to be baked into the GRUB image anymore.
Also, need some guidance on allocating physical and virtual memory both contiguously that can be mapped to one another. See
ahci.c line 88
andsata.c line 80
. I can elaborate a bit more if you'd like.Let me know what you think.