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.
Hello everyone.
I have designed a simple AHCI controller (following the AHCI specification 1.3), without Port Multiplier support. When my OS is getting AHCI configuration from PCI, detects that the ABAR is not placed in a good place, so it has to change it (concretely to the MB 7). But when it try to read the configuration from HBA Mem (supposedly in the MB 7), it gets that no ports are connected, but I know that there is one device connected to port 0, because I'm using VirtualBox and I have checked it.
thepowersgang wrote:May I ask why you are changing the contents of the BARs on VirtualBox? (All PCs have the PCI BIOS which does this for you)
Also, what is the purpose of the '| 0xF0000000'? Surely that would cause the actual programmed base to be not what you expect it to be.
Because the address which is pointed by BAR 5 (ABAR) is already being used by the paging map, I can't move that.
With regard to the "| 0xF0000000":
Before modifying the ABAR content, I read it and, it had the 0xF0500000 value, but the size of the RAM is 32 MB, so it can't be (It fired a PAGE FAULT). I supposed that the ABAR was in 0x500000, and I checked it. I derived that the ABAR content must be "or"ed with that.
You seem to be confused about both the concept of MMIO and Virtual/Physical addressing.
The BARs contain physical addresses, and should never point to present RAM (because the RAM is just another device listening on the address bus). To access the register contents, you'll want to map the area pointed to by the BAR into virtual memory (this can be anywhere you want it to be)
thepowersgang wrote:You seem to be confused about both the concept of MMIO and Virtual/Physical addressing.
The BARs contain physical addresses, and should never point to present RAM (because the RAM is just another device listening on the address bus). To access the register contents, you'll want to map the area pointed to by the BAR into virtual memory (this can be anywhere you want it to be)
First of all, thank you for answering.
My OS works with an Identity Paging, so physical memory is the same as virtual memory.
But, even changing that, I would have the same problem, the paging map, which is the MB 2 and it fills the next 4 MB (until MB 6) and the ABAR points to the MB 5, so they go into conflict.
Moreover, I would want you to answer me a question, could I change the ABAR content?
thepowersgang wrote:You can change the BAR values, but you'd want to be sure that you don't change it to somewhere that is already in use by another device.
Also, how can you be using identity paging, but still have something else occupying the upper area of memory?
Thank for your answer.
I have not understand very well your question(English isn't my mother tongue), but I'm going to try to answer you: No, there still is nothing in the upper memory,but it'll be used for task and other things.
Another question.
I have changed the ABAR content to the MB 7, but when I dump its content, I get that there are nothing, all is zeroed. Then, I used the ABAR which was previously(MB 5) , and I get the same. Could you tell me why? I'm using VirtualBox, and I have 2 devices connected, a SATA harddisk in the port 0 and a SATAPI disk in the port 1, but when I read the PI register I see a 0 value.
The BAR cannot be set to any address in RAM. It must be in an 'unused' area (which is why it was ~0xF0000000 to start with). You should never have to alter the BARs on a PCI device (unless you really know what you're doing, and there's no PCIBIOS to set them for you).
thepowersgang wrote:The BAR cannot be set to any address in RAM. It must be in an 'unused' area (which is why it was ~0xF0000000 to start with). You should never have to alter the BARs on a PCI device (unless you really know what you're doing, and there's no PCIBIOS to set them for you).
Thank you again.
Two question:
1. So, you're telling me that there are no way to change the address where the AHCI will write its data(HBA Mem and Ports descriptors), not?
2. But when I'm using the original ABAR, I also get nothing from there(all is zeroed). I've rewritten the paging module in order not to use the place where the content of ABAR points. It tells me that there are no ports, when I know that there must be, two at least.
Last edited by ateno3 on Sat Jul 27, 2013 4:46 pm, edited 1 time in total.
1. So, you're telling me that there are no way to change the direction where the AHCI will write its data(HBA Mem and Ports descriptors), not?
As far as I got spanish right, "direccion" isn't the proper translation for direction, it's address (as it does in email address).
You really are confusing the direction here. The PCI bar dictates what section of memory addresses the device is supposed to listen to when the CPU wants to do something. If the device needs to read or write to memory of its own, it'll have a different place where that information is stored.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
1. So, you're telling me that there are no way to change the direction where the AHCI will write its data(HBA Mem and Ports descriptors), not?
As far as I got spanish right, "direccion" isn't the proper translation for direction, it's address (as it does in email address).
You really are confusing the direction here. The PCI bar dictates what section of memory addresses the device is supposed to listen to when the CPU wants to do something. If the device needs to read or write to memory of its own, it'll have a different place where that information is stored.
Thank you for helping with my really bad "English".You're right
OK. Then, how can I know where the information is stored?
PD: If you knew the answer to the second question, could you tell it to me?
EDIT: I have mapped the content of ABAR( 0xF0500000 ) into virtual memory. Now the address 0xF0500000 to the MB 7(Physical Memory), but I still have the second problem: I get that there are no attached devices( there are 2, in the port 0 and 1)
thepowersgang wrote:The BAR cannot be set to any address in RAM. It must be in an 'unused' area (which is why it was ~0xF0000000 to start with). You should never have to alter the BARs on a PCI device (unless you really know what you're doing, and there's no PCIBIOS to set them for you).
Hello. I hope not to bother you, but you're the only one who have answered me.
I have done what you said, I mapped the address (contained in ABAR) to some memory which exists(in the 7th MB), but I get that all is zeroed, and the AHCI HBA does not response the MMIO accesses.
I hope you can help... and sorry.
Please note that I find it exceptionally rude when I receive a private message for something that should be in the thread.
I suggest you read up on paging, because it sounds like you are not mapping the IO space correctly (and you were getting virtual and physical memory mixed up).
thepowersgang wrote:The BAR cannot be set to any address in RAM. It must be in an 'unused' area (which is why it was ~0xF0000000 to start with). You should never have to alter the BARs on a PCI device (unless you really know what you're doing, and there's no PCIBIOS to set them for you).
Hello. I hope not to bother you, but you're the only one who have answered me.
I have done what you said, I mapped the address (contained in ABAR) to some memory which exists(in the 7th MB), but I get that all is zeroed, and the AHCI HBA does not response the MMIO accesses.
I hope you can help... and sorry.
Please note that I find it exceptionally rude when I receive a private message for something that should be in the thread.
I suggest you read up on paging, because it sounds like you are not mapping the IO space correctly (and you were getting virtual and physical memory mixed up).
Hello.
I have done what you said to me. I have been reading about the paging.
I think I found the problem: I use the mmap function, to map the content of ABAR to the physical address I want, but when I read the page directory and I look for the page, which the virtual address is, it returns another address. The code is the following:
Since you're hopelessly stuck trying to do advanced stuff while not even knowing the basics, a brief lesson:
PD: If you knew the answer to the second question, could you tell it to me?
Learn to debug?
I mapped the address (contained in ABAR) to some memory which exists(in the 7th MB), but I get that all is zeroed,
Learn to debug?
but when I read the page directory and I look for the page, which the virtual address is, it returns another address.
Learn to debug?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Combuster wrote:Since you're hopelessly stuck trying to do advanced stuff while not even knowing the basics, a brief lesson:
PD: If you knew the answer to the second question, could you tell it to me?
Learn to debug?
I mapped the address (contained in ABAR) to some memory which exists(in the 7th MB), but I get that all is zeroed,
Learn to debug?
but when I read the page directory and I look for the page, which the virtual address is, it returns another address.
Learn to debug?
Thank you, Combuster.
The real code has a lot of DEBUG functions. For example, when I call mmap in my kernel, it prints all parameters in the screen, the intermediate steps, and when it finishes it also gives me the page address, which is in the page table. This is the problem, the result and what I've written are not the same.
PS: I also use GDB.
EDIT: The mmap function works properly, but the AHCI HBA is still sending me no response. By using the VirtualBox Debbuger, I could see that the MMIO space of AHCI is filled with correct information, but I can't get it. Can somebody help me??
EDIT2: Finally, the AHCI response to the MMIO accesses, but the "Identify Device" command doesn't work at all.