Re: how is a device detected

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



How the kernel scan the pci devices:

In /arch/x86/pci/legacy.c, 
pci_legacy_init() invoke
    - pcibios_scan_root(0) to scan pci devices from the root bus, 
          if the bus is already scanned then just return;
          else the
        - pci_scan_bus_parented() will be invoked, in this function the 
            - pci_create_bus() will create pci_bus for the 
                  corresponding bus and add it to the pci_root_buses
            - pci_scan_child_bus() is invoked to enumerate all the
                  devices of that bus. for each device number(each bus host
                  up to 32 devices, see Page 303, LDD3) invoke
                  - pci_scan_slot() to scan its 8 function number, here the
                      - pci_scan_single_device() be invoked, that means 
                            for each device the
                          - pci_scan_device() will be invoked, if the device
                              exist, the
                          - pci_device_add() will add the device to the devices list
                              of the bus it belongs to.

Oh, A lot of code to read, I think you will be interest in
the pci_scan_device() function, this function gets 
configuration registers of the pci device(Page 308, LDD3)

eh, I must go to class now...

On Tue, Nov 30, 2010 at 4:56 AM, Bond <jamesbond.2k.g@xxxxxxxxx> wrote:
On Tue, Nov 23, 2010 at 3:07 AM, Yuchen Liao <lycdragon@xxxxxxxxx> wrote:
> AFAIK, in the device_add() function (in driver/base/core.c), kernel will
> invoke "device_create_file()" function to create the "uevent" file;
> (The kobj is also added in this device_add() function by invoke
> kobject_add() function)
> In user space, the udevd is listening the NETLINK_KOBJECT_EVENT to get the
> "uevent" event. Then it will find a match udev rule under the
> /etc/udev/rules.d/. It will make changes according to the rule(Like create
> the device file under /dev).
> Every device when it is register, it will create a uevent file(by this way,
> can trigger a hotplug event), can write a "add" or "remove" command to add
> or remove a device.
> When starting computer, kernel will register a lot of devices, but the
> udev(in user space) is not start. After it start, it will scan the sysfs, to
> get all the uevent file, and write "add" into it. In this way, the event
> been triggered.
> ----
> I'm not so sure that I'm right. Please correct me if there is anything
> wrong. Thank you~
Hi thanks your explanation was very good.
 I have been doing some research on this aspect and replying you after
so many days it is helpful.
What I came across was some thing known as pci-core for PCI devices
and USB core for USB devices.
So that is one thing I surely want to understand.
My objective by this exercise is to be able to write a kernel which is
working on bare metal.(I just want a small set of code which can work)
So I want to understand it more.If some one has more thoughts here
then share it please.



--
from Yuchen Liao via Gmail
yyloves.me


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux