AppPkg/Applications/chipsec/conio.h
/** @file conio.h
* A conio implementation for UEFI
*
* Written by:
* cod <cod@hackingteam.com>
*/
#ifndef __CONIO_H_
#define __CONIO_H_
/**
* Colors which you can use in your application.
*/
typedef enum
{
BLACK = EFI_BLACK, /**< black color */
BLUE = EFI_BLUE, /**< blue color */
GREEN = EFI_GREEN, /**< green color */
CYAN = EFI_CYAN, /**< cyan color */
RED = EFI_RED, /**< red color */
MAGENTA = EFI_MAGENTA, /**< magenta color */
BROWN = EFI_BROWN, /**< brown color */
LIGHTGRAY = EFI_LIGHTGRAY, /**< light gray color */
BRIGHT = EFI_BRIGHT,
DARKGRAY = EFI_DARKGRAY, /**< dark gray color */
LIGHTBLUE = EFI_LIGHTBLUE, /**< light blue color */
LIGHTGREEN = EFI_LIGHTGREEN, /**< light green color */
LIGHTCYAN = EFI_LIGHTCYAN, /**< light cyan color */
LIGHTRED = EFI_LIGHTRED, /**< light red color */
LIGHTMAGENTA = EFI_LIGHTMAGENTA, /**< light magenta color */
YELLOW = EFI_YELLOW, /**< yellow color */
WHITE = EFI_WHITE /**< white color */
} COLORS;
/**
* Structure holding information about screen.
* @see gettextinfo
* @see inittextinfo
*/
struct text_info {
unsigned char curx; /**< cursor coordinate x */
unsigned char cury; /**< cursor coordinate y */
unsigned short attribute; /**< current text attribute */
unsigned short normattr; /**< original value of text attribute after
start of the application. If you don't
called the <TT>inittextinfo</TT> on the
beginning of the application, this always
will be black background and light gray
foreground */
unsigned char screenwidth; /**< screen width */
unsigned char screenheight; /**< screen height */
};
/**
* Structure used by gettext/puttext.
* @see _conio_gettext
* @see puttext
*/
struct char_info {
char letter; /**< character value */
unsigned short attr; /**< attribute value */
};
/**
* Returns information of the screen.
* @see text_info
*/
void gettextinfo (struct text_info * info);
/**
* Call this if you need real value of normattr attribute in the text_info
* structure.
* @see text_info
*/
void inittextinfo (void);
/**
* Clears rest of the line from cursor position to the end of line without
* moving the cursor.
*/
void clreol (void);
/**
* Clears whole screen.
*/
void clrscr (void);
/**
* Delete the current line (line on which is cursor) and then moves all lines
* below one line up. Lines below the line are moved one line up.
*/
void delline (void);
/**
* Insert blank line at the cursor position.
* Original content of the line and content of lines below moves one line down.
* The last line is deleted.
*/
void insline (void);
/**
* Gets text from the screen. If you haven't defined <TT>_CONIO_NO_GETTEXT_</TT>
* prior to including <TT>conio2.h</TT> you can use this function also under
* the <TT>gettext</TT> name.
* @see char_info
* @see puttext
* @param left Left coordinate of the rectangle, inclusive, starting from 1.
* @param top Top coordinate of the rectangle, inclusive, starting from 1.
* @param right Right coordinate of the rectangle, inclusive, starting from 1.
* @param bottom Bottom coordinate of the rectangle, inclusive, starting from 1.
* @param buf You have to pass buffer of size
* <TT>(right - left + 1) * (bottom - top + 1) * sizeof(char_info)</TT>.
*/
void conio_gettext (int left, int top, int right, int bottom,
struct char_info * buf);
/**
* Puts text back to the screen.
* @see char_info
* @see _conio_gettext
* @param left Left coordinate of the rectangle, inclusive, starting from 1.
* @param top Top coordinate of the rectangle, inclusive, starting from 1.
* @param right Right coordinate of the rectangle, inclusive, starting from 1.
* @param bottom Bottom coordinate of the rectangle, inclusive, starting from 1.
* @param buf You have to pass buffer of size
* <TT>(right - left + 1) * (bottom - top + 1) * sizeof(char_info)</TT>.
*/
void puttext (int left, int top, int right, int bottom, struct char_info * buf);
/**
* Copies text.
* @param left Left coordinate of the rectangle, inclusive, starting from 1.
* @param top Top coordinate of the rectangle, inclusive, starting from 1.
* @param right Right coordinate of the rectangle, inclusive, starting from 1.
* @param bottom Bottom coordinate of the rectangle, inclusive, starting from 1.
* @param destleft Left coordinate of the destination rectangle.
* @param desttop Top coordinate of the destination rectangle.
*/
void movetext (int left, int top, int right, int bottom, int destleft,
int desttop);
/**
* Moves cursor to the specified position.
* @param x horizontal position
* @param y vertical position
*/
void gotoxy(int x, int y);
/**
* Puts string at the specified position.
* @param x horizontal position
* @param y vertical position
* @param str string
*/
void cputsxy (int x, int y, char * str);
/**
* Puts char at the specified position.
* @param x horizontal position
* @param y vertical position
* @param ch char
*/
void putchxy (int x, int y, char ch);
/**
* Sets the cursor type.
* @see @ref cursortypes
* @param type cursor type, under Win32 it is height of the cursor in percents
*/
void _setcursortype (int type);
/**
* Sets attribute of text.
* @param _attr new text attribute
*/
void textattr (int _attr);
/**
* Sets text attribute back to value it had after program start.
* It uses text_info's normattr value.
* @see text_info
*/
void normvideo (void);
/**
* Sets text background color.
* @see COLORS
* @param color new background color
*/
void textbackground (int color);
/**
* Sets text foreground color.
* @see COLORS
* @param color new foreground color
*/
void textcolor (int color);
/**
* Reads the cursor X position.
* @returns cursor X position
*/
int wherex (void);
/**
* Reads the cursor Y position.
* @returns cursor Y position
*/
int wherey (void);
/**
* Reads password. This function behaves like cgets.
*/
char * getpass (const char * prompt, char * str);
/**
* Makes foreground colors light.
* If the current foreground color is less than <TT>DARKGRAY</TT> adds
* 8 to the its value making dark colors light.
* @see COLORS
* @see lowvideo
*/
void highvideo (void);
/**
* Makes foreground colors dark.
* If the current foreground color is higher than <TT>LIGHTGRAY</TT> substracts
* 8 from its value making light colors dark.
* @see COLORS
* @see highvideo
*/
void lowvideo (void);
/**
* Pauses program execution for a given time.
* @see switchbackground
* @param ms miliseconds
*/
void delay (int ms);
/**
* Replaces background color in the whole window. The text however
* is left intact. Does not modify textbackground().
* @see flashbackground
* @param color background color
*/
void switchbackground (int color);
/**
* Changes background color for a given time and then it restores it back.
* You can use it for visual bell. Does not modify textbackground().
* @see switchbackground
* @see delay
* @param color background color
* @param ms miliseconds
*/
void flashbackground (int color, int ms);
/**
* Clears the keyboard buffer.
* To see it in effect run <TT>conio_test</TT> and try to press a key during
* the 'Flashing...' phase.
*/
void clearkeybuf (void);
#ifdef __cplusplus
}
#endif
#endif