Dear all, Recently I am studying the source code , because I want to try to porting new mainboard later, but it is not easy to realize source code I begin my study from the src/southbridge/amd8111/amd8111.c There are some lines that I can't understand even I have amd8111 datasheet....hope you can tell me
1.devfn = bus_dev->path.u.pci.devfn + (1 << 3); 2.index = ((dev->path.u.pci.devfn & ~7) >> 3) + 8; 3.devfn = (dev->path.u.pci.devfn) & ~7;
Thanks advanced...
HJ Wang
On Mon, 2005-06-20 at 19:20 +0800, Huang-Jen Wang wrote:
Dear all, Recently I am studying the source code , because I want to try to porting new mainboard later, but it is not easy to realize source code I begin my study from the src/southbridge/amd8111/amd8111.c There are some lines that I can't understand even I have amd8111 datasheet....hope you can tell me
1.devfn = bus_dev->path.u.pci.devfn + (1 << 3); 2.index = ((dev->path.u.pci.devfn & ~7) >> 3) + 8; 3.devfn = (dev->path.u.pci.devfn) & ~7;
You choose the worst file in the whole tree to start. You are not supposed understand it unless you are Eric Biederman ;-)
The reason that file is so complicated is because the LPC bridge inside amd8111 controls the enable and disable of devices on both side of the PCI bridge (in amd8111). The function in amd8111.c is call with every devices in the 8111 chip as argument. The function has to figure out which device it is given and how to enable or disable the device. This is done by device_t to devfn magic you see.
Li-Ta Lo ollie@lanl.gov writes:
On Mon, 2005-06-20 at 19:20 +0800, Huang-Jen Wang wrote:
Dear all, Recently I am studying the source code , because I want to try to porting new mainboard later, but it is not easy to realize source code I begin my study from the src/southbridge/amd8111/amd8111.c There are some lines that I can't understand even I have amd8111 datasheet....hope you can tell me
1.devfn = bus_dev->path.u.pci.devfn + (1 << 3); 2.index = ((dev->path.u.pci.devfn & ~7) >> 3) + 8; 3.devfn = (dev->path.u.pci.devfn) & ~7;
You choose the worst file in the whole tree to start. You are not supposed understand it unless you are Eric Biederman ;-)
Hmm. It must need a good comment then :( But I agree that is pretty abstract way to start.
You certainly need to understand how pci encodes bus/device/function information and how LinuxBIOS deals with it to make sense of those lines.
The reason that file is so complicated is because the LPC bridge inside amd8111 controls the enable and disable of devices on both side of the PCI bridge (in amd8111). The function in amd8111.c is call with every devices in the 8111 chip as argument. The function has to figure out which device it is given and how to enable or disable the device. This is done by device_t to devfn magic you see.
Eric
that code is good. Also the AMD numbering device enable bit is good and professional. other SB that enble bit have nothing to do with device id or function...
YH
On 6/20/05, Eric W. Biederman ebiederman@lnxi.com wrote:
Li-Ta Lo ollie@lanl.gov writes:
On Mon, 2005-06-20 at 19:20 +0800, Huang-Jen Wang wrote:
Dear all, Recently I am studying the source code , because I want to try to porting new mainboard later, but it is not easy to realize source code I begin my study from the src/southbridge/amd8111/amd8111.c There are some lines that I can't understand even I have amd8111 datasheet....hope you can tell me
1.devfn = bus_dev->path.u.pci.devfn + (1 << 3); 2.index = ((dev->path.u.pci.devfn & ~7) >> 3) + 8; 3.devfn = (dev->path.u.pci.devfn) & ~7;
You choose the worst file in the whole tree to start. You are not supposed understand it unless you are Eric Biederman ;-)
Hmm. It must need a good comment then :( But I agree that is pretty abstract way to start.
You certainly need to understand how pci encodes bus/device/function information and how LinuxBIOS deals with it to make sense of those lines.
The reason that file is so complicated is because the LPC bridge inside amd8111 controls the enable and disable of devices on both side of the PCI bridge (in amd8111). The function in amd8111.c is call with every devices in the 8111 chip as argument. The function has to figure out which device it is given and how to enable or disable the device. This is done by device_t to devfn magic you see.
Eric
LinuxBIOS mailing list LinuxBIOS@openbios.org http://www.openbios.org/mailman/listinfo/linuxbios
You choose the worst file in the whole tree to start. You are not supposed understand it unless you are Eric Biederman ;-)
I disagree with the above. When I was produceing the base files for the 440bx I looked at a lot of the different files in the tree and IMO the amd source code was some of the cleanist and well designed of all the files I looked at. I found those files easyiest to follow and the most consistent in naming and in methodoloy.
I think they are an excellent place to start. The only thing the user should recognize is that those devices are somewhat complicated and that all the layers are a result of that.
Richard Smith smithbone@gmail.com writes:
You choose the worst file in the whole tree to start. You are not supposed understand it unless you are Eric Biederman ;-)
I disagree with the above. When I was produceing the base files for the 440bx I looked at a lot of the different files in the tree and IMO the amd source code was some of the cleanist and well designed of all the files I looked at. I found those files easyiest to follow and the most consistent in naming and in methodoloy.
I think they are an excellent place to start. The only thing the user should recognize is that those devices are somewhat complicated and that all the layers are a result of that.
amd8111.c in particular is a challenge because it operates at such a high level of abstraction.
The hardest thing about learning the v2 tree is the code is written in a reusable fashion that when you don't know how all of the pieces fit make it a little hard to understand. It isn't a simple a calls b calls c.
Multiple levels of abstraction can be very useful, but until you learn then it is easy to get lost. At least I think that is what was happening with amd8111.c
Eric