All about the OSDev Wiki. Discussions about the organization and general structure of articles and how to use the wiki. Request changes here if you don't know how to use the wiki.
In the "Enumerating PCI Buses" section, the code for checking all the functions of a multi-function device starts at function 0 and breaks as soon as a function isn't detected. This requires all the functions of a multi-function device to be numbered consecutively, which I don't think is always true (Bochs for one doesn't appear to).
That's what I'm thinking. That line is there to cut down on the number of I/O accesses by exiting the function checking loop at the first function that isn't detected. Problem is I don't believe the functions are always consecutive, so bailing out at the first missing function could cause you to miss some of them.
I would discuss this on the articles talk page, but I did some searching on here and this seems to be a common algorithm. Even the venerable Brendan posted some code a while back that quit the multi-function loop in the same fashion . Hence why I'm a bit hesitant to call this an error on the PCI page when it could just as easily be Bochs or me.
Wouldn't changing the break into continue be smarter than just dropping the condition in this case?
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
metallevel wrote:I would discuss this on the articles talk page, but I did some searching on here and this seems to be a common algorithm. Even the venerable Brendan posted some code a while back that quit the multi-function loop in the same fashion . Hence why I'm a bit hesitant to call this an error on the PCI page when it could just as easily be Bochs or me.
A while ago someone was asking questions about PCI device enumeration. I was just going to tell them "here's the relevant part of the wiki page!" but the information wasn't in the wiki, so I couldn't. It's possible that I posted the pseudo-code as a reply, then slapped myself, then added the same pseudo-code to the wiki.
In general, you should never assume anyone is correct, including me. I also think you're right (and that my pseudo-code was wrong).
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.