On 08/07/14 18:39, Chris Cuthbert wrote: > Hi Andrew, Laszlo, > > The output from the 'devices' shell command is: > > 7B D - - 1 0 0 > PciRoot(0x2)/Pci(0x2,0x0)/Pci(0x0,0x0)/MAC(121212121212,0x1) > > And the output from 'disconnect' and 'reconnect' shell command is: > > Shell> disconnect 7b > Disconnect - (7B,7A9E39E4,7A9E393C) Result Success. > Shell> reconnect 7b > Disconnect - (7B,7A9D3AA8,7AAA5BD0) Result Success. > MnpDriverBindingSupported:0x7F338518 YES > > What this is showing me is that on 'reconnect', the MNP driver does find > a SNP protocol handle implemented by device handle 0x7B. Unfortunately > my system crashes at this point indicating that my driver is not > unloading/loading properly, I will have to work on that. > > I am trying to avoid turning this email chain into a UEFI tutorial but I > did not quiet understand what you are trying to convey. > > My driver is implementing UEFI driver model and at some point in time > "Supported" function is called with a PCIe device handle. Driver figures > out which device it supports and that causes the "Start" function to be > called with that handle. In "Start" function I initialize the PCIe > device and the driver data structures. > > As part of "Start" function driver registers a protocol that it is > producing. Now, how does the UEFI "ConnectController" manage to connect > the MNP driver to my driver ? > The "ConnectController" is for connecting devices to drivers. How are > the service drivers connected to devices providing the services ?
See the recursion in CoreConnectController() [MdeModulePkg/Core/Dxe/Hand/DriverSupport.c]. Your driver consumes (tries to consume) the PciIo protocol on the handles that are passed to it. On suitable handles, your driver is expected to produce a child handle, and to install the SimpleNetworkProtocol on it. - open handle's PciIo -- this is the parent handle - grab handle's DevicePath - create another device path with a MAC node appended - create a pristine, new handle, with the fresh (longer) device path installed on it. This is the child handle. - On the child handle, install SNP - communicate parent-child relationship to the protocol system by opening the parent handle's PciIo instance with the child handle as ControllerHandle, and EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER as Attributes. >From the specification of the OpenProtocol() boot service: BY_CHILD_CONTROLLER Used by bus drivers to show that a protocol interface is being used by one of the child controllers of a bus. This information is used by the boot service ConnectController() to recursively connect all child controllers and by the boot service DisconnectController() to get the list of child controllers that a bus driver created. In turn, the MNP driver consumes SNP instances on the handles that are passed to it, and produces MNP instances. And so on. Again, read through CoreConnectController() in [MdeModulePkg/Core/Dxe/Hand/DriverSupport.c]. It has good comments. Note the filtering for EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. Service binding protocols work a bit differently (the programmer requests creation of child nodes explicitly), but I have no experience with them, so I can only refer you to the spec. You can identify service binding protocols in the "dh" output because they usually have "ServiceBinding" in their names. Laszlo ------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel