1 /** @file
2   Implementation of translation upon PC ANSI.
3 
4 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution.  The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9 
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 
13 **/
14 
15 
16 #include "Terminal.h"
17 
18 /**
19   Translate all raw data in the Raw FIFO into unicode, and insert
20   them into Unicode FIFO.
21 
22   @param TerminalDevice          The terminal device.
23 
24 **/
25 VOID
AnsiRawDataToUnicode(IN TERMINAL_DEV * TerminalDevice)26 AnsiRawDataToUnicode (
27   IN  TERMINAL_DEV    *TerminalDevice
28   )
29 {
30   UINT8 RawData;
31 
32   //
33   // pop the raw data out from the raw fifo,
34   // and translate it into unicode, then push
35   // the unicode into unicode fifo, until the raw fifo is empty.
36   //
37   while (!IsRawFiFoEmpty (TerminalDevice) && !IsUnicodeFiFoFull (TerminalDevice)) {
38 
39     RawFiFoRemoveOneKey (TerminalDevice, &RawData);
40 
41     UnicodeFiFoInsertOneKey (TerminalDevice, (UINT16) RawData);
42   }
43 }
44 
45 /**
46   Check if input string is valid Ascii string, valid EFI control characters
47   or valid text graphics.
48 
49   @param  TerminalDevice          The terminal device.
50   @param  WString                 The input string.
51 
52   @retval EFI_UNSUPPORTED         If not all input characters are valid.
53   @retval EFI_SUCCESS             If all input characters are valid.
54 
55 **/
56 EFI_STATUS
AnsiTestString(IN TERMINAL_DEV * TerminalDevice,IN CHAR16 * WString)57 AnsiTestString (
58   IN  TERMINAL_DEV    *TerminalDevice,
59   IN  CHAR16          *WString
60   )
61 {
62   CHAR8 GraphicChar;
63 
64   //
65   // support three kind of character:
66   // valid ascii, valid efi control char, valid text graphics.
67   //
68   for (; *WString != CHAR_NULL; WString++) {
69 
70     if ( !(TerminalIsValidAscii (*WString) ||
71         TerminalIsValidEfiCntlChar (*WString) ||
72         TerminalIsValidTextGraphics (*WString, &GraphicChar, NULL) )) {
73 
74       return EFI_UNSUPPORTED;
75     }
76   }
77 
78   return EFI_SUCCESS;
79 }
80