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.
Hi all, I wrote an ahci driver for my kernel in assembly (nasm).
when I run qemu, the kernel in the initialization of the ahci driver does not hang but in exit qemu gives me the following error:
Q1: Might be easier to ask it this way - have you implemented a physical memory manager yet?
Q2: As I recall you are writing this all in NASM? Is that still the case?
Q3: Have you at this stage setup any Limine requests? Do you know how to? There is probably quick and dirty way where you have to do a Limine request
I ask this because there is a way you could probably do it by putting the buffer in the .bss section and using the LIMINE_KERNEL_ADDRESS_REQUEST (see: https://github.com/limine-bootloader/li ... ss-feature ) . If you make that request and compute the difference between virtual_base and physical_base (ie kernel_offset = virtual_base-physical_base) you can subtract kernel_offset from any address in the kernel address space (which would include the .bss section) to get the corresponding physical address. That physical address can then be used as the physical address for AHCI (ie: the physical addresses for PxFB and PxFBU registers).
I recently helped someone on Stackoverflow regarding computing a physical address from a virtual kernel address in Limine. The "C" code was here: https://github.com/baponkar/KeblaOS/blo ... nel.c#L105 . kernel_offset is computed and stored as a global variable that can then be subtracted from any kernel virtual address to yield a physical address.
A1: No
A2: Yes
A3: My kernel currently sets up a GDT, IDT and interrupt handling including system calls (int 128).
I know the limine protocol but the manual is very limited on memory management.
I don't have a memory manager yet, neither physical nor virtual, these are things I'm currently studying.
Although you have no VMM, you do have virtual memory mappings provided by Limine. Without a physical memory manager at this point the easiest way is I suggested already. You will have to make a Limine request (LIMINE_KERNEL_ADDRESS_REQUEST) to retrieve the address of the kernel in virtual memory and the physical address (both part of the response). As I pointed out if you compute the difference (call it kernel_phys_virt_offset) between them (virtual_base-physical_base from the Limine response) you can then take any kernel virtual address and subtract that computed offset to obtain the physical address.
If you place the buffers in .bss, that becomes part of the kernel virtual address space. You would just take the virtual address of the buffers in the .bss section and subtract kernel_phys_virt_offset from them. Those will be the physical addresses in memory of the buffers. Those physical addresses can then be used for AHCI for the PxFB and PxFBU registers. This works because Limine has a guarantee that wherever it places the kernel in physical memory it is contiguous physical memory. It then maps that contiguous physical memory into the higher half.
If you had a physical memory manager you would request free physical page(s) and use addresses in those page(s) to use for the AHCI buffers.