Reviewed-by: Ruiyu Ni <[email protected]> I also checked it in.
> -----Original Message----- > From: Roy Franz [mailto:[email protected]] > Sent: Friday, July 10, 2015 3:29 AM > To: Ni, Ruiyu > Cc: [email protected]; [email protected] > Subject: Re: edk2[17897] Accept VT220 DEL and function keys for TTY > terminal type > > On Thu, Jul 9, 2015 at 2:21 AM, Ni, Ruiyu <[email protected]> wrote: > > Roy, > > TerminalConIn.c cannot pass VS2013 build. Error in line 1583, 1590, 1594 > complains about the conversion from UINTN to UINT16. > > > > Thanks, > > Ray > > OK, the problem is in this code: > > UINTN EscCode; > > TerminalDevice->TtyEscapeStr[TerminalDevice->TtyEscapeIndex] > = 0; /* Terminate string */ > EscCode = StrDecimalToUintn(TerminalDevice->TtyEscapeStr); > switch (EscCode) { > case 3: > Key.ScanCode = SCAN_DELETE; > break; > case 11: > case 12: > case 13: > case 14: > case 15: > Key.ScanCode = SCAN_F1 + EscCode - 11; > break; > > Key.ScanCode is UINT16, and EscCode is UINTN, and there are 3 instances > of this assignment. There is no StrDecimalToUint16, so we need a cast. > > How about (copy/pasted in gmail, so may not apply) > > diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c > b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c > index fbaf33b..5c67bf1 100644 > --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c > +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c > @@ -1568,9 +1568,9 @@ UnicodeToEfiKey ( > if (TerminalDevice->TerminalType == TTYTERMTYPE) { > > if (UnicodeChar == '~' && TerminalDevice->TtyEscapeIndex <= 2) { > - UINTN EscCode; > + UINT16 EscCode;^M > > TerminalDevice->TtyEscapeStr[TerminalDevice->TtyEscapeIndex] > = 0; /* Terminate string */ > - EscCode = StrDecimalToUintn(TerminalDevice->TtyEscapeStr); > + EscCode = > (UINT16)StrDecimalToUintn(TerminalDevice->TtyEscapeStr);^M > switch (EscCode) { > case 3: > Key.ScanCode = SCAN_DELETE; > > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Roy Franz <[email protected]> > > > > Ray - can you confirm that this change fixes the build error? > > Thanks, > Roy > > > > > > >> -----Original Message----- > >> From: [email protected] > [mailto:[email protected]] > >> Sent: Thursday, July 9, 2015 2:24 PM > >> To: [email protected] > >> Subject: edk2[17897] Accept VT220 DEL and function keys for TTY > terminal > >> type > >> > >> Revision: 17897 > >> http://sourceforge.net/p/edk2/code/17897 > >> Author: lersek > >> Date: 2015-07-09 06:24:20 +0000 (Thu, 09 Jul 2015) > >> Log Message: > >> ----------- > >> Accept VT220 DEL and function keys for TTY terminal type > >> > >> Accept the VT220 escape code [3~ as backspace for TtyTerm terminals. > >> This is > >> sent by many Linux terminals by default. Also accept VT220 function > keys > >> F1-F12, and VT100 F1-F4 keys as these are commonly sent by Linux > >> terminals. > >> The VT220 escape codes are longer, and variable length so a new state is > >> added > >> to the state machine along with a variable to construct the multibyte > escape > >> sequence. > >> There are currently no ambiguous escape sequence prefixes accepted, so > the > >> TTY > >> terminal accepts escape sequences for a variety of terminals. The goal > is > >> to > >> 'just work' with as many terminals as possible, rather than properly > >> emulating > >> any specific terminal. Backspace, Del, and F10 have been tested on > xterm, > >> rxvt, tmux, and screen. > >> Note: The existing vt100 function key handling does not match the vt100 > >> documentation that I found, so I added the TTY terminal handling > >> of VT100 F1-F4 (really PF1-PF4 on vt100) separately. The vt100 > >> has no F5-F10 keys, so I don't know what the current vt100 code > >> is based on. > >> > >> Contributed-under: TianoCore Contribution Agreement 1.0 > >> Signed-off-by: Roy Franz <[email protected]> > >> Reviewed-by: Feng Tian <[email protected]> > >> > >> Modified Paths: > >> -------------- > >> > trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c > >> > trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h > >> > >> > trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn. > >> c > >> > >> Modified: > >> trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c > >> > ============================================================== > >> ===== > >> --- > trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c > >> 2015-07-09 06:24:15 UTC (rev 17896) > >> +++ > trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c > >> 2015-07-09 06:24:20 UTC (rev 17897) > >> @@ -81,6 +81,12 @@ > >> NULL, // TwoSecondTimeOut > >> INPUT_STATE_DEFAULT, > >> RESET_STATE_DEFAULT, > >> + { > >> + 0, > >> + 0, > >> + 0 > >> + }, > >> + 0, > >> FALSE, > >> { // SimpleTextInputEx > >> TerminalConInResetEx, > >> > >> Modified: > >> trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h > >> > ============================================================== > >> ===== > >> --- > trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h > >> 2015-07-09 06:24:15 UTC (rev 17896) > >> +++ > trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h > >> 2015-07-09 06:24:20 UTC (rev 17897) > >> @@ -99,6 +99,8 @@ > >> EFI_EVENT TwoSecondTimeOut; > >> UINT32 InputState; > >> UINT32 ResetState; > >> + UINT16 TtyEscapeStr[3]; > >> + INTN TtyEscapeIndex; > >> > >> // > >> // Esc could not be output to the screen by user, > >> @@ -118,6 +120,7 @@ > >> #define INPUT_STATE_LEFTOPENBRACKET 0x04 > >> #define INPUT_STATE_O 0x08 > >> #define INPUT_STATE_2 0x10 > >> +#define INPUT_STATE_LEFTOPENBRACKET_2 0x20 > >> > >> #define RESET_STATE_DEFAULT 0x00 > >> #define RESET_STATE_ESC_R 0x01 > >> > >> Modified: > >> > trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn. > >> c > >> > ============================================================== > >> ===== > >> --- > >> > trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn. > >> c 2015-07-09 06:24:15 UTC (rev 17896) > >> +++ > >> > trunk/edk2/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn. > >> c 2015-07-09 06:24:20 UTC (rev 17897) > >> @@ -1223,7 +1223,8 @@ > >> continue; > >> } > >> > >> - if (UnicodeChar == 'O' && TerminalDevice->TerminalType == > >> VT100TYPE) { > >> + if (UnicodeChar == 'O' && (TerminalDevice->TerminalType == > >> VT100TYPE || > >> + TerminalDevice->TerminalType > == > >> TTYTERMTYPE)) { > >> TerminalDevice->InputState |= INPUT_STATE_O; > >> TerminalDevice->ResetState = RESET_STATE_DEFAULT; > >> continue; > >> @@ -1371,6 +1372,22 @@ > >> default : > >> break; > >> } > >> + } else if (TerminalDevice->TerminalType == TTYTERMTYPE) { > >> + /* Also accept VT100 escape codes for F1-F4 for TTY term */ > >> + switch (UnicodeChar) { > >> + case 'P': > >> + Key.ScanCode = SCAN_F1; > >> + break; > >> + case 'Q': > >> + Key.ScanCode = SCAN_F2; > >> + break; > >> + case 'R': > >> + Key.ScanCode = SCAN_F3; > >> + break; > >> + case 'S': > >> + Key.ScanCode = SCAN_F4; > >> + break; > >> + } > >> } > >> > >> if (Key.ScanCode != SCAN_NULL) { > >> @@ -1514,6 +1531,21 @@ > >> } > >> } > >> > >> + /* > >> + * The VT220 escape codes that the TTY terminal accepts all > have > >> + * numeric codes, and there are no ambiguous prefixes shared > with > >> + * other terminal types. > >> + */ > >> + if (TerminalDevice->TerminalType == TTYTERMTYPE && > >> + Key.ScanCode == SCAN_NULL && > >> + UnicodeChar >= '0' && > >> + UnicodeChar <= '9') { > >> + TerminalDevice->TtyEscapeStr[0] = UnicodeChar; > >> + TerminalDevice->TtyEscapeIndex = 1; > >> + TerminalDevice->InputState |= > >> INPUT_STATE_LEFTOPENBRACKET_2; > >> + continue; > >> + } > >> + > >> if (Key.ScanCode != SCAN_NULL) { > >> Key.UnicodeChar = 0; > >> EfiKeyFiFoInsertOneKey (TerminalDevice, &Key); > >> @@ -1527,6 +1559,65 @@ > >> break; > >> > >> > >> + case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | > >> INPUT_STATE_LEFTOPENBRACKET_2: > >> + /* > >> + * Here we handle the VT220 escape codes that we accept. > This > >> + * state is only used by the TTY terminal type. > >> + */ > >> + Key.ScanCode = SCAN_NULL; > >> + if (TerminalDevice->TerminalType == TTYTERMTYPE) { > >> + > >> + if (UnicodeChar == '~' && TerminalDevice->TtyEscapeIndex <= > 2) { > >> + UINTN EscCode; > >> + > >> TerminalDevice->TtyEscapeStr[TerminalDevice->TtyEscapeIndex] = 0; /* > >> Terminate string */ > >> + EscCode = > StrDecimalToUintn(TerminalDevice->TtyEscapeStr); > >> + switch (EscCode) { > >> + case 3: > >> + Key.ScanCode = SCAN_DELETE; > >> + break; > >> + case 11: > >> + case 12: > >> + case 13: > >> + case 14: > >> + case 15: > >> + Key.ScanCode = SCAN_F1 + EscCode - 11; > >> + break; > >> + case 17: > >> + case 18: > >> + case 19: > >> + case 20: > >> + case 21: > >> + Key.ScanCode = SCAN_F6 + EscCode - 17; > >> + break; > >> + case 23: > >> + case 24: > >> + Key.ScanCode = SCAN_F11 + EscCode - 23; > >> + break; > >> + default: > >> + break; > >> + } > >> + } else if (TerminalDevice->TtyEscapeIndex == 1){ > >> + /* 2 character escape code */ > >> + > >> TerminalDevice->TtyEscapeStr[TerminalDevice->TtyEscapeIndex++] = > >> UnicodeChar; > >> + continue; > >> + } > >> + else { > >> + DEBUG ((EFI_D_ERROR, "Unexpected state in escape2\n")); > >> + } > >> + } > >> + TerminalDevice->ResetState = RESET_STATE_DEFAULT; > >> + > >> + if (Key.ScanCode != SCAN_NULL) { > >> + Key.UnicodeChar = 0; > >> + EfiKeyFiFoInsertOneKey (TerminalDevice, &Key); > >> + TerminalDevice->InputState = INPUT_STATE_DEFAULT; > >> + UnicodeToEfiKeyFlushState (TerminalDevice); > >> + continue; > >> + } > >> + > >> + UnicodeToEfiKeyFlushState (TerminalDevice); > >> + break; > >> + > >> default: > >> // > >> // Invalid state. This should never happen. > >> > >> > >> ------------------------------------------------------------------------------ > >> Don't Limit Your Business. Reach for the Cloud. > >> GigeNET's Cloud Solutions provide you with the tools and support that > >> you need to offload your IT needs and focus on growing your business. > >> Configured For All Businesses. Start Your Cloud Today. > >> https://www.gigenetcloud.com/ > >> _______________________________________________ > >> edk2-commits mailing list > >> [email protected] > >> https://lists.sourceforge.net/lists/listinfo/edk2-commits ------------------------------------------------------------------------------ Don't Limit Your Business. Reach for the Cloud. GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today. https://www.gigenetcloud.com/ _______________________________________________ edk2-commits mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/edk2-commits
