Re: [edk2] SerialIo over PCI-based device

Subject: Re: [edk2] SerialIo over PCI-based device

From: Andrew Fish <afish@apple.com>

To: edk2-devel@lists.sourceforge.net

Date: 2011-10-28 16:53:39

Christian,

The Console devices in the EFI system table are virtual handles produced by the ConSpliter driver.

https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c

If you look at the DriverBinding.Supported() call for the SimpleTextIn you will see that a gEfiConsoleInDeviceGuid protocol is required to be on the handle. 

The ConPlatform driver produces this protocol:
https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c

It is produced for HotPlug devices (USB or PCCARD device paths), or if the "ConIn" or "ConOut" variable has a device path instance that matches. 

If you look in UEFI 2.3.1 section 3.2 Table 10 the global variables are defined. 

So what SimpleTextInput/SimpleTextOutput devices are active as console is controlled by the "ConIn" and "ConOut" variable. 

You may be able to use the platform setup screens to set the active consoles. 

Just for debug you could have your driver append its device path to the "ConIn" and "ConOut" variables.  This is bad practice for a production driver as the design and intent of EFI was to put the policy choices in the platform and remove them from the option ROMs. This is a little more complicated than it sounds as you can see in your examples below that the extra devices paths can get created as children to your handle, like the Uart node and I also think a node may show up to indicate what type of terminal emulation is being used. 

The dmpstore shell command displays the EFI variables. 

Andrew Fish





On Oct 28, 2011, at 7:39 AM, Christian Gmeiner wrote:

> Hi
> 
> 2011/10/28 Christian Gmeiner :
>> Hi
>> 
>>> 1. Make sure your serial IO device handle can be managed by the Terminal DXE driver.
>> 
>> How can I check this? At the moment I am looking into the source of
>> Terminal DXE driver to find out
>> some more details.
> 
> So I got one step closer to a working console - devtree output (only
> important bits)
> 
> Ctrl[97] PciRoot(0x0)/Pci(0x1A,0x0)
> Ctrl[98] PciRoot(0x0)/Pci(0x1A,0x0)/Pci(0x0,0x0)
>   Ctrl[A2] PciRoot(0x0)/Pci(0x1A,0x0)/Pci(0x0,0x0)/Uart(115200,8,N,1)
>     Ctrl[A3] PC-ANSI Serial Console
> Ctrl[99] PciRoot(0x0)/Pci(0x1B,0x0)
> Ctrl[9A] PciRoot(0x0)/Pci(0x1F,0x0)
>   Ctrl[9C] PciRoot(0x0)/Pci(0x1F,0x0)/Serial(0x0)
>     Ctrl[9F] PciRoot(0x0)/Pci(0x1F,0x0)/Serial(0x0)/Uart(115200,8,N,1)
>       Ctrl[A0] PC-ANSI Serial Console
>         Ctrl[6D] Primary Console Input Device
>         Ctrl[6E] Primary Console Output Device
>   Ctrl[9D] PciRoot(0x0)/Pci(0x1F,0x0)/Acpi(PNP0303,0x0)
>   Ctrl[9E] PciRoot(0x0)/Pci(0x1F,0x0)/Acpi(PNP0F03,0x0)
> Ctrl[9B] IEGD Graphics Controller Display Device #0
>   Ctrl[6E] Primary Console Output Device
> Ctrl[9C] PciRoot(0x0)/Pci(0x1F,0x0)/Serial(0x0)
>   Ctrl[9F] PciRoot(0x0)/Pci(0x1F,0x0)/Serial(0x0)/Uart(115200,8,N,1)
>     Ctrl[A0] PC-ANSI Serial Console
>       Ctrl[6D] Primary Console Input Device
>       Ctrl[6E] Primary Console Output Device
> Ctrl[9D] PciRoot(0x0)/Pci(0x1F,0x0)/Acpi(PNP0303,0x0)
> Ctrl[9E] PciRoot(0x0)/Pci(0x1F,0x0)/Acpi(PNP0F03,0x0)
> Ctrl[9F] PciRoot(0x0)/Pci(0x1F,0x0)/Serial(0x0)/Uart(115200,8,N,1)
>   Ctrl[A0] PC-ANSI Serial Console
>     Ctrl[6D] Primary Console Input Device
>     Ctrl[6E] Primary Console Output Device
> Ctrl[A0] PC-ANSI Serial Console
>   Ctrl[6D] Primary Console Input Device
>   Ctrl[6E] Primary Console Output Device
> Ctrl[A2] PciRoot(0x0)/Pci(0x1A,0x0)/Pci(0x0,0x0)/Uart(115200,8,N,1)
> <---- my device
>   Ctrl[A3] PC-ANSI Serial Console
> Ctrl[A3] PC-ANSI Serial Console
> 
> What I am missing some nodes now:
>   Primary Console Input Device
>   Primary Console Output Device
> 
> 
> Also this looks much better now:
> 
> 65: 3E8ACB90
> ComponentName2
> ComponentName
> DriverBinding
> ImageDevicePath
> LoadedImage
>     Child[65]        : PCI Serial Driver
>   Driver Image Name  : FvFile(7E28461B-709A-48C4-9081-7071FC4454D9)
>   Driver Version     : 00000001
>   Driver Type        : Bus
>   Configuration      : NO
>   Diagnostics        : NO
>   Child Controllers  :
>     Ctrl[98]         : PciRoot(0x0)/Pci(0x1A,0x0)/Pci(0x0,0x0)
>     Child[A2]        :
> PciRoot(0x0)/Pci(0x1A,0x0)/Pci(0x0,0x0)/Uart(115200,8,N,1)
> 
> But I was not able to find the requirements to get this working :/
> Where can I find them?
> 
>> 
>>> 2. Specify the PCI serial device as a default console in the platform BDS library. Refer to the gPlatformConsole[] in the PlatformData.c of Nt32Pkg\Library\Nt32BdsLib.
>> 
>> Should not my PCI serial driver be used, if no other serial driver
>> (producer of SerialIO) can be found?
>> 
> 
> thanks
> --
> Christian Gmeiner, MSc
> 
>> thanks
>> --
>> Christian Gmeiner, MSc
>> 
>> 
>> 
>> 2011/10/28 Sun, Rui :
>>> Hi,
>>> 
>>> 1. Make sure your serial IO device handle can be managed by the Terminal DXE driver.
>>> 2. Specify the PCI serial device as a default console in the platform BDS library. Refer to the gPlatformConsole[] in the PlatformData.c of Nt32Pkg\Library\Nt32BdsLib.
>>> 
>>> -----Original Message-----
>>> From: Christian Gmeiner [mailto:christian.gmeiner@gmail.com]
>>> Sent: Friday, October 28, 2011 5:17 PM
>>> To: edk2-devel@lists.sourceforge.net
>>> Subject: Re: [edk2] SerialIo over PCI-based device
>>> 
>>> Hi all,
>>> 
>>> here is a short update of my progress. I have written a driver that
>>> consumes the PCI IO protocol and produces
>>> the Serial IO interface. My driver gets loaded and I can write some
>>> test string over my PCI serial device.
>>> 
>>>        UINTN len = 7;
>>>        gSerialDev.SerialIo.Write(&gSerialDev.SerialIo, &len, "test 1\n");
>>> 
>>> But my serial console device is not used by the shell. What are the
>>> requirements that my PCI serial device gets
>>> used by the shell?
>>> 
>>> 2.0 Shell> dh -d 6e
>>> 6E: 3EBBCC90
>>> ComponentName2
>>> ComponentName
>>> DriverBinding
>>> ImageDevicePath
>>> LoadedImage
>>>     Child[6E]        : PCI Serial Driver
>>>   Driver Image Name  : FvFile(7E28461B-709A-48C4-9081-7071FC4454D9)
>>>   Driver Version     : 00000001
>>>   Driver Type        : Device
>>>   Configuration      : NO
>>>   Diagnostics        : NO
>>>   Child Controllers  :
>>>     Ctrl[93]         : PciRoot(0x0)/Pci(0x1A,0x0)/Pci(0x0,0x0)
>>> 
>>> thanks
>>> --
>>> Christian Gmeiner, MSc
>>> 
>>> 
>>> 
>>> 2011/9/7 Sun, Rui :
>>>> Hi,
>>>> 
>>>> For your case, you need to write a UEFI Driver Model driver. In EFI Driver Binding Protocol.Supported(), it checks if the pass-in device handle is the PCI serial device. In EFI Driver Binding Protocol.Start(), it consumes the PCI IO Protocol installed on the device handle, and produces Serial IO Protocol. The Terminal DXE driver (MdeModulePkg\Universal\Console\TerminalDxe) consumes the Serial IO Protocol and provides serial console functionality.
>>>> 
>>>> As defined in the UEFI spec, the Serial IO Protocol is in DXE phase and can be used for serial console. The serial port library is designed in the EDKII. It is a low level library class and its appropriate instance can be linked with modules in any phase, SEC/PEI/DXE.... It is mainly intended for debug purpose, while it can be used by the driver producing serial IO Protocol as well.
>>>> 
>>>> You could implement a serial port library instance for your PCI serial device. However, you need to take care how to deal with PCI stuff, (PCI resource assignment, PCI bus number...).
>>>> 
>>>> -----Original Message-----
>>>> From: Christian Gmeiner [mailto:christian.gmeiner@gmail.com]
>>>> Sent: Wednesday, September 07, 2011 3:10 PM
>>>> To: edk2-devel@lists.sourceforge.net
>>>> Subject: Re: [edk2] SerialIo over PCI-based device
>>>> 
>>>> Hi
>>>> 
>>>>> For protocol implementation,  EmbeddedPkg/SerialDxe/SerialIo will be a
>>>>> good reference
>>>>> For Serial port library , MdeModulePkg/Library/BaseserialportLib16550
>>>>> will be a good starting point
>>>>> 
>>>> 
>>>> Fine... I have looked into the EFI docs, but I could not find the
>>>> difference between
>>>> a Serial port library and the protocol implementation.
>>>> 
>>>> I think that for an PCI driver I need to implement the protocol, as
>>>> the Serial port
>>>> library is used for legacy serial ports. I am correct?
>>>> 
>>>> thanks,
>>>> Christian Gmeiner, MSc
>>>> 
>>>> ------------------------------------------------------------------------------
>>>> Using storage to extend the benefits of virtualization and iSCSI
>>>> Virtualization increases hardware utilization and delivers a new level of
>>>> agility. Learn what those decisions are and how to modernize your storage
>>>> and backup environments for virtualization.
>>>> http://www.accelacomm.com/jaw/sfnl/114/51434361/
>>>> _______________________________________________
>>>> edk2-devel mailing list
>>>> edk2-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>>>> ------------------------------------------------------------------------------
>>>> Using storage to extend the benefits of virtualization and iSCSI
>>>> Virtualization increases hardware utilization and delivers a new level of
>>>> agility. Learn what those decisions are and how to modernize your storage
>>>> and backup environments for virtualization.
>>>> http://www.accelacomm.com/jaw/sfnl/114/51434361/
>>>> _______________________________________________
>>>> edk2-devel mailing list
>>>> edk2-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>>>> 
>>> 
>>> ------------------------------------------------------------------------------
>>> The demand for IT networking professionals continues to grow, and the
>>> demand for specialized networking skills is growing even more rapidly.
>>> Take a complimentary Learning@Cisco Self-Assessment and learn
>>> about Cisco certifications, training, and career opportunities.
>>> http://p.sf.net/sfu/cisco-dev2dev
>>> _______________________________________________
>>> edk2-devel mailing list
>>> edk2-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>>> ------------------------------------------------------------------------------
>>> The demand for IT networking professionals continues to grow, and the
>>> demand for specialized networking skills is growing even more rapidly.
>>> Take a complimentary Learning@Cisco Self-Assessment and learn
>>> about Cisco certifications, training, and career opportunities.
>>> http://p.sf.net/sfu/cisco-dev2dev
>>> _______________________________________________
>>> edk2-devel mailing list
>>> edk2-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>>> 
>> 
> 
> ------------------------------------------------------------------------------
> The demand for IT networking professionals continues to grow, and the
> demand for specialized networking skills is growing even more rapidly.
> Take a complimentary Learning@Cisco Self-Assessment and learn 
> about Cisco certifications, training, and career opportunities. 
> http://p.sf.net/sfu/cisco-dev2dev
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel


------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel