diff mbox

[edk2,RFC,0/4] New terminal type for Linux

Message ID CAFECyb-EMMQT1=XNNdY5ZwCK9OovzQ0TJT6bpQA1kofPwfdBZQ@mail.gmail.com
State New
Headers show

Commit Message

Roy Franz May 14, 2015, 8:43 p.m. UTC
On Thu, May 14, 2015 at 12:31 PM, Kinney, Michael D
<michael.d.kinney@intel.com> wrote:
> Jiewen,
>
> I think most of the terminal emulators being discussed here layer on top of a TTY device.
>
> How about TtyTerm instead?
I think this  is a more appropriate name.

Michael - I'll also try to address feedback on the new GUID going in
the wrong place, as the patchset
did grow larger than I expected it to be.  If I understand correctly
the new GUID should just be present
in the TerminalDxe module.


I do want to try to keep the size of this change in check, as fixing backspace
for the problematic cases can be done with the following patch. Fixing delete
is slightly bigger, but if I create a completely separate terminal module it
will be 95+% directly copied from TerminalDxe.  I have no further plans
beyond backspace/delete, so unless others want to extend this new terminal
I don't foresee more being done.

Thanks,
Roy


>
> -----Original Message-----
> From: Yao, Jiewen
> Sent: Wednesday, May 13, 2015 7:13 PM
> To: Kinney, Michael D; edk2-devel@lists.sourceforge.net; linaro-uefi@lists.linaro.org; Tian, Feng
> Subject: RE: [edk2] [RFC 0/4] New terminal type for Linux
>
> Definitely, I fully agree we should add new capability for terminal type to support more OS. It is question of "how", not "if". :-)
>
> Back to naming, I feel a little strange to use "Linux". Does it also work for other *nix system?
> I suggest we had better give a name for terminal type, instead of OS type.
>
> Mike or Andrew
> Do you have better suggestion on naming?
>
> Thank you
> Yao Jiewen
>
> -----Original Message-----
> From: Kinney, Michael D
> Sent: Thursday, May 14, 2015 9:23 AM
> To: Yao, Jiewen; edk2-devel@lists.sourceforge.net; linaro-uefi@lists.linaro.org; Tian, Feng; Kinney, Michael D
> Subject: RE: [edk2] [RFC 0/4] New terminal type for Linux
>
> Jiewen,
>
> Adding more GUIDs is possible if there is no agreement between different terminal emulators.  I recommend we allow the patch to be reviewed and encourage expanding the capabilities of this new terminal type as required to maximize compatibility.
>
> Mike
>
> -----Original Message-----
> From: Yao, Jiewen
> Sent: Wednesday, May 13, 2015 6:16 PM
> To: Kinney, Michael D; edk2-devel@lists.sourceforge.net; linaro-uefi@lists.linaro.org; Tian, Feng
> Subject: RE: [edk2] [RFC 0/4] New terminal type for Linux
>
> OK.  I also have interest to know how to handle below case mentioned by patch submitter :
> "I do not think that all Linux distributions agree on all the details, so my goal is to have a terminal defition that mostly works in many configurations."
>
> If one distribution think it should do A, other distribution think it should do B. Should we just keep adding new GUID type?
>
> Thank you
> Yao Jiewen
>
> -----Original Message-----
> From: Kinney, Michael D
> Sent: Thursday, May 14, 2015 9:12 AM
> To: Yao, Jiewen; edk2-devel@lists.sourceforge.net; linaro-uefi@lists.linaro.org; Tian, Feng; Kinney, Michael D
> Subject: RE: [edk2] [RFC 0/4] New terminal type for Linux
>
> Jiewen,
>
> If there is a size concern, we can add Feature Flag PCDs to enable/disable support for different terminal types in the TerminalDxe driver.
>
> Since this new terminal type is very close to another terminal type that is already supported by TerminalDxe, the size impact of adding this new terminal type should be very small.  Especially since the TerminalDxe driver is usually compressed.
>
> Thanks,
>
> Mike
>
> -----Original Message-----
> From: Yao, Jiewen
> Sent: Wednesday, May 13, 2015 5:59 PM
> To: edk2-devel@lists.sourceforge.net; linaro-uefi@lists.linaro.org; Tian, Feng; Kinney, Michael D
> Subject: RE: [edk2] [RFC 0/4] New terminal type for Linux
>
> Or can we provide a standalone LinuxTerminalDxe driver?
>
> The original TerminalDxe handle the default types defined in UEFI spec.
> The new LinuxTerminalDxe can support the extension like this.
>
> That can also made code size small, if a platform BIOS decides to only support a subset of terminal types.
>
> Thank you
> Yao Jiewen
>
>
> -----Original Message-----
> From: Kinney, Michael D [mailto:michael.d.kinney@intel.com]
> Sent: Thursday, May 14, 2015 8:44 AM
> To: edk2-devel@lists.sourceforge.net; linaro-uefi@lists.linaro.org; Tian, Feng; Kinney, Michael D
> Subject: Re: [edk2] [RFC 0/4] New terminal type for Linux
>
> Roy,
>
> The new GUID for this terminal type should not be defined in the MdePkg.  The MdePkg is intended to only contain content from industry standard specifications.
>
> I recommend you add the GUID for this new terminal type to the MdeModulePkg so it is in the same package that contains the terminal driver that uses it.
>
> I think this means you should not modify PcAnsi.h in BaseTools or the EdkCompatibilityPkg.
>
> It also means that the UEFI Device Path Libs in the MdePkg cannot know about this GUID and will show the VenMedia() node with a GUID value.
>
> Hopefully with these changes, the patch set will be much smaller.
>
> Thanks,
>
> Mike
>
> -----Original Message-----
> From: Roy Franz [mailto:roy.franz@linaro.org]
> Sent: Wednesday, May 13, 2015 4:54 PM
> To: edk2-devel@lists.sourceforge.net; linaro-uefi@lists.linaro.org; Tian, Feng
> Subject: [edk2] [RFC 0/4] New terminal type for Linux
>
> This patchset is a follow on to my previous backspace patchse, and adds a new terminal type "LinuxTerm"
> (for lack of a better name) that better handles the typical Linux terminal (xterm/rxvt/gnome terminal/etc.) These often treat backspace/delete differently than the existing EDK2 terminal types expect, particularly in emulated environments where the emulated serial port is connected to a graphical terminal rather than a serial console.
> For a description of how Debian has dealt with the terminal backspace/delete/^H mess, see the "Keyboard configuration"
> section of:
>
> https://www.debian.org/doc/debian-policy/ch-opersys.html#s9.8">KeyboardConfiguration
>
> I do not think that all Linux distributions agree on all the details, so my goal is to have a terminal defition that mostly works in many configurations.
>
> Backspace being broken in these environments is the primary motivation for this, but this terminal type could be exentend to better support the typical graphical terminal now in use.
> This terminal type may be of use in BSD environments as well, so I'm open to more generic name suggestions.  I deliberately avoided calling it "xterm", as my intention is to try to work with multiple terminal types to the degree possible.
>
>
>
> Roy Franz (4):
>   Add "LinuxTerm" terminal type to TerminalDxe
>   Treat ASCII 0x7F as backspace for LinuxTerm terminal
>   accept [3~ as delete for LinuxTerm terminals
>   Change QEMU terminal type to LinuxTerm
>
>  .../ArmVirtualizationPkg/ArmVirtualizationQemu.dsc |  4 +-
>  BaseTools/Source/C/Include/Guid/PcAnsi.h           |  6 +++
>  .../Foundation/Efi/Guid/PcAnsi/PcAnsi.c            |  2 +
>  .../Foundation/Efi/Guid/PcAnsi/PcAnsi.h            |  6 +++
>  .../Universal/BdsDxe/BootMaint/BootMaint.h         |  2 +-
>  .../Universal/BdsDxe/BootMaint/Data.c              |  5 ++-
>  .../Universal/Console/TerminalDxe/Terminal.c       | 44 ++++++++++++++++----
>  .../Universal/Console/TerminalDxe/Terminal.h       |  2 +
>  .../Universal/Console/TerminalDxe/TerminalConIn.c  | 47 ++++++++++++++++++++--  .../Universal/Console/TerminalDxe/TerminalConOut.c |  2 +  .../Universal/Console/TerminalDxe/TerminalDxe.inf  |  1 +
>  MdePkg/Include/Guid/PcAnsi.h                       |  6 +++
>  MdePkg/Include/Protocol/DevicePath.h               |  1 +
>  .../Library/UefiDevicePathLib/DevicePathFromText.c | 27 +++++++++++++
>  .../Library/UefiDevicePathLib/DevicePathToText.c   |  3 ++
>  .../UefiDevicePathLib/UefiDevicePathLib.inf        |  2 +
>  ...UefiDevicePathLibOptionalDevicePathProtocol.inf |  4 +-
>  MdePkg/MdePkg.dec                                  |  3 ++
>  .../UefiHandleParsingLib/UefiHandleParsingLib.c    |  1 +
>  .../UefiHandleParsingLib/UefiHandleParsingLib.inf  |  1 +
>  20 files changed, 153 insertions(+), 16 deletions(-)
>
> --
> 1.9.1
>
>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y

Comments

Roy Franz June 5, 2015, 4:03 a.m. UTC | #1
On Thu, May 14, 2015 at 1:57 PM, Kinney, Michael D
<michael.d.kinney@intel.com> wrote:
> Roy,
>
> 1) New GUID should be defined in MdeModulePkg/MdeModulePkg.dec
> 2) New include file for new GUID in MdeModulePkg/Include/Guid
> 3) Update TerminalDxe to use this new GUID.
>
> I do not recommend creating a new terminal driver.  Please continue as you have which is adding support for this one new terminal type to MdeModulePkg/Universal/Console/TerminalDxe.
>
> Best regards,
>
> Mike
>
>
OK, I have made the above changes, and have it working with one hack
I'm not sure how to properly resolve.

I now have gEfiTtyTermGuid declared (extern) in
MdeModulePkg/Include/Guid/TtyTerm.h, and defined in
MdeModulePkg/Universal/Console/TerminalDxe/Tty.c.

I use gEfiTtyTermGuid in DevicePathFromText.c in MdePkg to convert
between a text path to a device path, but
I don't see how to include TtyTerm.h in DevicePathFromText.c.  Right
now I just have added the extern to DevicePathFromText.c
to verify functionality.  This works, but is obviously not the right
solution.   How should I go about properly getting gEfiTtyTermGuid
declared in DevicePathFromText.c?

Thanks,
Roy

------------------------------------------------------------------------------
Ard Biesheuvel June 5, 2015, 9:31 a.m. UTC | #2
On 5 June 2015 at 06:03, Roy Franz <roy.franz@linaro.org> wrote:
> On Thu, May 14, 2015 at 1:57 PM, Kinney, Michael D
> <michael.d.kinney@intel.com> wrote:
>> Roy,
>>
>> 1) New GUID should be defined in MdeModulePkg/MdeModulePkg.dec
>> 2) New include file for new GUID in MdeModulePkg/Include/Guid
>> 3) Update TerminalDxe to use this new GUID.
>>
>> I do not recommend creating a new terminal driver.  Please continue as you have which is adding support for this one new terminal type to MdeModulePkg/Universal/Console/TerminalDxe.
>>
>> Best regards,
>>
>> Mike
>>
>>
> OK, I have made the above changes, and have it working with one hack
> I'm not sure how to properly resolve.
>
> I now have gEfiTtyTermGuid declared (extern) in
> MdeModulePkg/Include/Guid/TtyTerm.h, and defined in
> MdeModulePkg/Universal/Console/TerminalDxe/Tty.c.
>
> I use gEfiTtyTermGuid in DevicePathFromText.c in MdePkg to convert
> between a text path to a device path, but
> I don't see how to include TtyTerm.h in DevicePathFromText.c.  Right
> now I just have added the extern to DevicePathFromText.c
> to verify functionality.  This works, but is obviously not the right
> solution.   How should I go about properly getting gEfiTtyTermGuid
> declared in DevicePathFromText.c?
>

You should not define the GUID yourself, you should add it to the
appropriate .dec file, If you then depend on that package and guid in
a module's .inf, the definition will be emitted implicitly by the
build tools.
Roy Franz June 5, 2015, 10:36 p.m. UTC | #3
On Fri, Jun 5, 2015 at 2:31 AM, Ard Biesheuvel
<ard.biesheuvel@linaro.org> wrote:
> On 5 June 2015 at 06:03, Roy Franz <roy.franz@linaro.org> wrote:
>> On Thu, May 14, 2015 at 1:57 PM, Kinney, Michael D
>> <michael.d.kinney@intel.com> wrote:
>>> Roy,
>>>
>>> 1) New GUID should be defined in MdeModulePkg/MdeModulePkg.dec
>>> 2) New include file for new GUID in MdeModulePkg/Include/Guid
>>> 3) Update TerminalDxe to use this new GUID.
>>>
>>> I do not recommend creating a new terminal driver.  Please continue as you have which is adding support for this one new terminal type to MdeModulePkg/Universal/Console/TerminalDxe.
>>>
>>> Best regards,
>>>
>>> Mike
>>>
>>>
>> OK, I have made the above changes, and have it working with one hack
>> I'm not sure how to properly resolve.
>>
>> I now have gEfiTtyTermGuid declared (extern) in
>> MdeModulePkg/Include/Guid/TtyTerm.h, and defined in
>> MdeModulePkg/Universal/Console/TerminalDxe/Tty.c.
>>
>> I use gEfiTtyTermGuid in DevicePathFromText.c in MdePkg to convert
>> between a text path to a device path, but
>> I don't see how to include TtyTerm.h in DevicePathFromText.c.  Right
>> now I just have added the extern to DevicePathFromText.c
>> to verify functionality.  This works, but is obviously not the right
>> solution.   How should I go about properly getting gEfiTtyTermGuid
>> declared in DevicePathFromText.c?
>>
>
> You should not define the GUID yourself, you should add it to the
> appropriate .dec file, If you then depend on that package and guid in
> a module's .inf, the definition will be emitted implicitly by the
> build tools.

Thanks Ard.

OK,  got rid of the bogus Tty.c.  I already  had the GUID (also)
defined in the MdeModulePkg.dec, and the gEfiTtyTermGuid
in the [Guid] section of the UefiDevicePathLib.inf.
What I am missing is the declaring the dependency of UefiDevicePathLib
on the MdeModulePackage, and I don't know how to add that.
TerminalDxe isn't under the Library directory, and doesn't have
a "LIBRARY_CLASS" in its .inf file, and all the examples of dependencies
that I have found seem to rely on that.
My somewhat vague understanding of the ED2 build system has hit its limit.

Thanks,
Roy







>
> --
> Ard.

------------------------------------------------------------------------------
Roy Franz June 5, 2015, 11:57 p.m. UTC | #4
On Fri, Jun 5, 2015 at 4:39 PM, Laszlo Ersek <lersek@redhat.com> wrote:
> On 06/06/15 00:36, Roy Franz wrote:
>> On Fri, Jun 5, 2015 at 2:31 AM, Ard Biesheuvel
>> <ard.biesheuvel@linaro.org> wrote:
>>> On 5 June 2015 at 06:03, Roy Franz <roy.franz@linaro.org> wrote:
>>>> On Thu, May 14, 2015 at 1:57 PM, Kinney, Michael D
>>>> <michael.d.kinney@intel.com> wrote:
>>>>> Roy,
>>>>>
>>>>> 1) New GUID should be defined in MdeModulePkg/MdeModulePkg.dec
>>>>> 2) New include file for new GUID in MdeModulePkg/Include/Guid
>>>>> 3) Update TerminalDxe to use this new GUID.
>>>>>
>>>>> I do not recommend creating a new terminal driver.  Please continue as you have which is adding support for this one new terminal type to MdeModulePkg/Universal/Console/TerminalDxe.
>>>>>
>>>>> Best regards,
>>>>>
>>>>> Mike
>>>>>
>>>>>
>>>> OK, I have made the above changes, and have it working with one hack
>>>> I'm not sure how to properly resolve.
>>>>
>>>> I now have gEfiTtyTermGuid declared (extern) in
>>>> MdeModulePkg/Include/Guid/TtyTerm.h, and defined in
>>>> MdeModulePkg/Universal/Console/TerminalDxe/Tty.c.
>>>>
>>>> I use gEfiTtyTermGuid in DevicePathFromText.c in MdePkg to convert
>>>> between a text path to a device path, but
>>>> I don't see how to include TtyTerm.h in DevicePathFromText.c.  Right
>>>> now I just have added the extern to DevicePathFromText.c
>>>> to verify functionality.  This works, but is obviously not the right
>>>> solution.   How should I go about properly getting gEfiTtyTermGuid
>>>> declared in DevicePathFromText.c?
>>>>
>>>
>>> You should not define the GUID yourself, you should add it to the
>>> appropriate .dec file, If you then depend on that package and guid in
>>> a module's .inf, the definition will be emitted implicitly by the
>>> build tools.
>>
>> Thanks Ard.
>>
>> OK,  got rid of the bogus Tty.c.  I already  had the GUID (also)
>> defined in the MdeModulePkg.dec, and the gEfiTtyTermGuid
>> in the [Guid] section of the UefiDevicePathLib.inf.
>> What I am missing is the declaring the dependency of UefiDevicePathLib
>> on the MdeModulePackage, and I don't know how to add that.
>> TerminalDxe isn't under the Library directory, and doesn't have
>> a "LIBRARY_CLASS" in its .inf file, and all the examples of dependencies
>> that I have found seem to rely on that.
>> My somewhat vague understanding of the ED2 build system has hit its limit.
>
> In the INF file of any module (library instance, driver module,
> application, etc), you have a
>
> [Packages]
>
> section, under which you can list *.dec files, with pathnames relative
> to the root of the edk2 clone. Once you add a dec file there, you can
> reference guids, PCDs, and library classes (headers) declared in that
> DEC file.
>
> Protocol GUIDs and other GUIDs will become available for compilation by
> including the appropriate include files (from under Library/, Protocol/,
> and Guid/, usually); these relative include file pathnames are then
> searched against all modules that you listed under [Packages].
>
> For *linking*, you'll also have to list the protocol guids under
> [Protocols] and the other guids under [Guids] in the INF file. This will
> cause the build system to include *definitions* for these GUIDs in the
> auto-generated C files. This way linking too will succeed.
>
> The [LibraryClasses] section is also there for linking, but it has an
> extra level of indirection. (For compilation, see Library/ above.) A
> library class ultimately corresponds to a header file only, and it can
> have several implementations. [LibraryClasses] therefore lists only the
> sets of APIs you'd like to link against, but the actual library
> implementation is resolved in the DSC file that you are building.
>
> The DSC file can resolve a library class to a library instance
> - globally, for all modules,
> - for types of modules (eg. DXE_DRIVER vs. PEIM vs. UEFI_APPLICATION),
> - for individual modules (identified by their INF files).
>
> (The INF file spec describes this in much more detail, and no doubt much
> more correctly; just google it.)
>
> In addition, library instances (= implementations) can restrict
> themselves to some module types. The most common example is that
> libraries that write to static variables cannot be generally linked into
> PEIMs, because writeable memory becomes available only at some point
> during PEI; some PEIMs execute in place from flash. (There's only static
> linking; dynamic linking is covered with PPIs (PEIM-to-PEIM interfaces)
> and protocols.)
>
> So a library wanting to write to a static variable would in general
> restrict itself to post-PEI module types. Alternatively, its INF file
> could list a dependency expression (a depex) on the
> "gEfiPeiMemoryDiscoveredPpiGuid" PPI, which gets installed when DRAM
> becomes available during PEI. Such a depex would be inherited by any
> PEIM that linked against this particular library instance, with the
> effect that the PEIM would be first dispatched only after DRAM were
> initialized. (Hence allowing the library built into the module to write
> to its static variables.)
>
> Anyway, in the current case, the technical solution would be to add
> MdeModulePkg/MdeModulePkg.dec under the [Packages] section in
> "MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf".
>
> However, that's no good, because MdePkg contains definitions, libraries
> etc. for industry standards. For example, the DevicePathLib library
> instance in question ("UefiDevicePathLib") knows about GUIDs that are
> listed in the UEFI specification. So you'd either have to introduce a
> cross-package dependency to MdeModulePkg (which is technically feasible,
> but purity-wise it would be frowned upon I think, because MdeModulePkg
> is reference implementation for a standard, not standard per se), *or*
> you'd have to add gEfiTtyTermGuid to MdePkg's dec file, and the
> appropriate MdePkg/Include/Guid/... header file). However, the latter
> would not be accepted until gEfiTtyTermGuid were actually *standard*.
>
> So what can you do, if neither the cross-pkg dependency nor the direct
> MdePkg modification is appropriate? Two options:
> - Try to standardize the GUID with the USWG. Good luck! :)
> - Fork the UefiDevicePathLib library instance to some other (less
>   central) package, and modify it there. This sucks because any updates
>   to the standard location would have to be cross-ported, going forward.
>
> The edk2 build system is actually very flexible, it's just that the
> terminal stuff has always proven untouchable (to me at least). Note
> though that forking a library instance (or a module for that matter) is
> the *norm* for proprietary vendors, which is what edk2 (and the UEFI
> spec itself) are optimized for. (Eg. the protocols are ABIs, not APIs.)
>
> To summarize: you're facing this problem because the devpath-to-text
> conversion library instance under MdePkg is tightly coupled with an
> industry standard (the UEFI spec), whereas the driver modules under
> MdeModulePkg are just "independent implementations" (that Intel cares
> about very much though). If you want to add non-standard extensions to
> the devpath-to-text conversion library, you might have to fork it (or
> standardize the extension).
>
> Sorry if I misunderstood the situation; hopefully others can correct me
> then (or anyway).

Thank you - that was very helpful, and I think you do understand the situation.
I had some inklings of some of problems you highlighted above, but not
the full ramifications.

So, the link problem I am having is in the device path conversion code
(DevicePathTo/FromText.c),
so is there a way to avoid this by just not supporting nice text
device paths?  From my (again limited)
understanding of device paths, I could do something like:
VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)
instead of VenTtyTerm(), which would directly encode the GUID, and
hence avoid the dependency problems
I'm having.  It will make for a more ugly .dsc file, but that's what
comments are for :)
Would this work?

Thanks,
Roy



>
> Thanks
> Laszlo

------------------------------------------------------------------------------
diff mbox

Patch

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
index 51492f3..70ec370 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
@@ -1561,8 +1561,14 @@  UnicodeToEfiKey (
     }

     if (UnicodeChar == DEL) {
-      Key.ScanCode    = SCAN_DELETE;
-      Key.UnicodeChar = 0;
+      if (PcgGetBool(TerminalTreatAsciiDelAsBackspace) {^M
+        Key.ScanCode    = SCAN_NULL;^M
+        Key.UnicodeChar = CHAR_BACKSPACE;^M
+      }^M
+      else {^M
+        Key.ScanCode    = SCAN_DELETE;^M
+        Key.UnicodeChar = 0;^M
+      }^M

>
> Mike