]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c
Added some functions header.
[mirror_edk2.git] / MdeModulePkg / Universal / Console / TerminalDxe / Ansi.c
1 /** @file
2 Implementation of translation upon PC ANSI.
3
4 Copyright (c) 2006 - 2008, Intel Corporation. <BR>
5 All rights reserved. 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 FIFI into unicode, and insert
20 them into Unicode FIFO.
21
22 @param TerminalDevice The terminal device.
23
24 @return None.
25
26 **/
27 VOID
28 AnsiRawDataToUnicode (
29 IN TERMINAL_DEV *TerminalDevice
30 )
31 {
32 UINT8 RawData;
33
34 //
35 // pop the raw data out from the raw fifo,
36 // and translate it into unicode, then push
37 // the unicode into unicode fifo, until the raw fifo is empty.
38 //
39 while (!IsRawFiFoEmpty (TerminalDevice)) {
40
41 RawFiFoRemoveOneKey (TerminalDevice, &RawData);
42
43 UnicodeFiFoInsertOneKey (TerminalDevice, (UINT16) RawData);
44 }
45 }
46
47 /**
48 Check if input string is valid Ascii string, valid EFI control characters
49 or valid text graphics.
50
51 @param TerminalDevice The terminal device.
52 @param WString The input string.
53
54 @retval EFI_UNSUPPORTED If not all input characters are valid.
55 @retval EFI_SUCCESS If all input characters are valid.
56
57 **/
58 EFI_STATUS
59 AnsiTestString (
60 IN TERMINAL_DEV *TerminalDevice,
61 IN CHAR16 *WString
62 )
63 {
64 CHAR8 GraphicChar;
65
66 //
67 // support three kind of character:
68 // valid ascii, valid efi control char, valid text graphics.
69 //
70 for (; *WString != CHAR_NULL; WString++) {
71
72 if ( !(TerminalIsValidAscii (*WString) ||
73 TerminalIsValidEfiCntlChar (*WString) ||
74 TerminalIsValidTextGraphics (*WString, &GraphicChar, NULL) )) {
75
76 return EFI_UNSUPPORTED;
77 }
78 }
79
80 return EFI_SUCCESS;
81 }