Page 2 of 2

Re: Enumerate PCI Buses

Posted: Fri Aug 28, 2015 8:22 pm
by SpyderTL
Sorry, I should have just copy/pasted the text.

I would still get clarification from the instructor of the class. There are two possibilities:

A) You are supposed to write part of an Operating System that communicates with the PCI bus via memory or I/O instructions, or
B) You are supposed to write an application that will run in at least one existing Operating System (Linux or Windows), that asks the OS to provide information about the PCI bus.

There is actually a third option, C) you are supposed to write an application that bypasses the OS and talks directly to the PCI bus, but I think this is highly unlikely, unless this is a class on hacking.

But if I were you, I'd ask which of these is the actual assignment, rather than guess and get it wrong. :)

By the way, I'm pretty sure Windows isn't going to let a user application have direct access to either the PCI I/O ports or the corresponding memory addresses that you would need. So I think it's a moot point.

Re: Enumerate PCI Buses

Posted: Sat Aug 29, 2015 6:35 am
by onlyonemac
I gather that it is supposed to be a binary to run on an existing OS but which bypasses the OS. I gather that what they're trying to say is "write the part of the kernel which accesses the PCI bus, but wrap it up in a binary for an existing OS because we haven't got a kernel to put it in". Thus the code written should be designed to execute in kernel space, and really only needs to push the current OS out of the way as such OS is being used as little more than a program loader.

Re: Enumerate PCI Buses

Posted: Tue Sep 01, 2015 11:50 am
by Gigasoft
The assignment seems clear to me. You need to write an user mode program, which bypasses the OS. On linux you can use the iopl or ioperm system calls as root to accomplish this, and on Windows you'll need something like giveio.sys. If you are worried about being preempted in the middle of reading from PCI configuration space, I suggest that you retry at least once and verify that you get the same value both times. Later on, you will port it to kernel space and make it into a proper driver which your user mode layer will invoke.