2001-05-15 03:50:25 +00:00
/*
* FreeLoader
2003-01-19 01:04:01 +00:00
* Copyright ( C ) 1998 - 2003 Brian Palmer < brianp @ sginet . com >
2001-05-15 03:50:25 +00:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
2009-10-27 10:34:16 +00:00
* You should have received a copy of the GNU General Public License along
* with this program ; if not , write to the Free Software Foundation , Inc . ,
* 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA .
2001-05-15 03:50:25 +00:00
*/
2010-02-26 11:43:19 +00:00
# pragma once
2001-05-15 03:50:25 +00:00
2013-05-24 12:20:13 +00:00
extern ULONG UiScreenWidth ; // Screen Width
extern ULONG UiScreenHeight ; // Screen Height
extern UCHAR UiStatusBarFgColor ; // Status bar foreground color
extern UCHAR UiStatusBarBgColor ; // Status bar background color
extern UCHAR UiBackdropFgColor ; // Backdrop foreground color
extern UCHAR UiBackdropBgColor ; // Backdrop background color
extern UCHAR UiBackdropFillStyle ; // Backdrop fill style
extern UCHAR UiTitleBoxFgColor ; // Title box foreground color
extern UCHAR UiTitleBoxBgColor ; // Title box background color
extern UCHAR UiMessageBoxFgColor ; // Message box foreground color
extern UCHAR UiMessageBoxBgColor ; // Message box background color
extern UCHAR UiMenuFgColor ; // Menu foreground color
extern UCHAR UiMenuBgColor ; // Menu background color
extern UCHAR UiTextColor ; // Normal text color
extern UCHAR UiSelectedTextColor ; // Selected text color
extern UCHAR UiSelectedTextBgColor ; // Selected text background color
extern UCHAR UiEditBoxTextColor ; // Edit box text color
extern UCHAR UiEditBoxBgColor ; // Edit box text background color
extern CHAR UiTitleBoxTitleText [ 260 ] ; // Title box's title text
extern BOOLEAN UiUseSpecialEffects ; // Tells us if we should use fade effects
extern BOOLEAN UiCenterMenu ;
extern BOOLEAN UiMenuBox ;
extern CHAR UiTimeText [ ] ;
extern BOOLEAN UiDrawTime ;
extern const CHAR UiMonthNames [ 12 ] [ 15 ] ;
2001-05-15 03:50:25 +00:00
2002-06-06 05:58:37 +00:00
///////////////////////////////////////////////////////////////////////////////////////
//
// User Interface Functions
//
///////////////////////////////////////////////////////////////////////////////////////
2013-05-24 12:20:13 +00:00
BOOLEAN UiInitialize ( BOOLEAN ShowGui ) ; // Initialize User-Interface
VOID UiUnInitialize ( PCSTR BootText ) ; // Un-initialize User-Interface
VOID UiDrawBackdrop ( VOID ) ; // Fills the entire screen with a backdrop
VOID UiFillArea ( ULONG Left , ULONG Top , ULONG Right , ULONG Bottom , CHAR FillChar , UCHAR Attr /* Color Attributes */ ) ; // Fills the area specified with FillChar and Attr
VOID UiDrawShadow ( ULONG Left , ULONG Top , ULONG Right , ULONG Bottom ) ; // Draws a shadow on the bottom and right sides of the area specified
VOID UiDrawBox ( ULONG Left , ULONG Top , ULONG Right , ULONG Bottom , UCHAR VertStyle , UCHAR HorzStyle , BOOLEAN Fill , BOOLEAN Shadow , UCHAR Attr ) ; // Draws a box around the area specified
VOID UiDrawText ( ULONG X , ULONG Y , PCSTR Text , UCHAR Attr ) ; // Draws text at coordinates specified
VOID UiDrawText2 ( ULONG X , ULONG Y , ULONG MaxNumChars , PCSTR Text , UCHAR Attr ) ; // Draws text at coordinates specified
VOID UiDrawCenteredText ( ULONG Left , ULONG Top , ULONG Right , ULONG Bottom , PCSTR TextString , UCHAR Attr ) ; // Draws centered text at the coordinates specified and clips the edges
VOID UiDrawStatusText ( PCSTR StatusText ) ; // Draws text at the very bottom line on the screen
VOID UiUpdateDateTime ( VOID ) ; // Updates the date and time
VOID UiInfoBox ( PCSTR MessageText ) ; // Displays a info box on the screen
2014-01-14 20:12:07 +00:00
VOID UiMessageBox ( PCSTR Format , . . . ) ; // Displays a message box on the screen with an ok button
2013-05-24 12:20:13 +00:00
VOID UiMessageBoxCritical ( PCSTR MessageText ) ; // Displays a message box on the screen with an ok button using no system resources
VOID UiDrawProgressBarCenter ( ULONG Position , ULONG Range , PCHAR ProgressText ) ; // Draws the progress bar showing nPos percent filled
VOID UiDrawProgressBar ( ULONG Left , ULONG Top , ULONG Right , ULONG Bottom , ULONG Position , ULONG Range , PCHAR ProgressText ) ; // Draws the progress bar showing nPos percent filled
[FREELDR] Some ARC-spec compatibility refactoring + simplifications & fixes.
CORE-9023
- During loading and initialization of the list of operating systems
available in freeldr.ini, convert any legacy operating system entry
encountered -- they are like those in NTLDR's boot.ini file, i.e.:
ArcOsLoadPartition="LoadIdentifier" /List /of /Options
into a new operating system INI entry, like those used by default in
FreeLoader. This allows us to avoid treating this corner-case later in
different parts of the code. Also, the "BootType" value is now
determined there, only once.
- Convert the OS loaders entry-points to ARC-compatible ones, following
the "Advanced RISC Computing Specification, Version 1.2" specification
https://www.netbsd.org/docs/Hardware/Machines/ARC/riscspec.pdf
- Introduce helpers for retrieving options values from the argument vector
in a simple way.
- Simplify LoadOperatingSystem(), since now the "BootType" value has
been determined once while loading the list of OSes (see above) and
is well-defined there. Use the BuildArgvForOsLoader() helper to build
the ARC-compatible argument vector from the corresponding INI settings
for the selected operating system entry, and use it when calling the
corresponding OS loader.
- In the OS loaders, since we can now directly read the settings from
the argument vector (instead of using INI settings), we can avoid
using a bunch of fixed-size string buffers, and avoid potentially
failing IniOpenSection() calls as well.
- Simplify code in the Linux loader (and the RemoveQuotes() function).
- Add UiShowMessageBoxesInArgv() that acts on the "MessageBox=" settings
passed through the argument vector (equivalent to
UiShowMessageBoxesInSection() ).
- Use string-safe functions where needed (copy/concatenation/printf on
fixed-size buffers).
2019-08-06 20:30:54 +00:00
2013-05-24 12:20:13 +00:00
VOID UiShowMessageBoxesInSection ( PCSTR SectionName ) ; // Displays all the message boxes in a given section
[FREELDR] Some ARC-spec compatibility refactoring + simplifications & fixes.
CORE-9023
- During loading and initialization of the list of operating systems
available in freeldr.ini, convert any legacy operating system entry
encountered -- they are like those in NTLDR's boot.ini file, i.e.:
ArcOsLoadPartition="LoadIdentifier" /List /of /Options
into a new operating system INI entry, like those used by default in
FreeLoader. This allows us to avoid treating this corner-case later in
different parts of the code. Also, the "BootType" value is now
determined there, only once.
- Convert the OS loaders entry-points to ARC-compatible ones, following
the "Advanced RISC Computing Specification, Version 1.2" specification
https://www.netbsd.org/docs/Hardware/Machines/ARC/riscspec.pdf
- Introduce helpers for retrieving options values from the argument vector
in a simple way.
- Simplify LoadOperatingSystem(), since now the "BootType" value has
been determined once while loading the list of OSes (see above) and
is well-defined there. Use the BuildArgvForOsLoader() helper to build
the ARC-compatible argument vector from the corresponding INI settings
for the selected operating system entry, and use it when calling the
corresponding OS loader.
- In the OS loaders, since we can now directly read the settings from
the argument vector (instead of using INI settings), we can avoid
using a bunch of fixed-size string buffers, and avoid potentially
failing IniOpenSection() calls as well.
- Simplify code in the Linux loader (and the RemoveQuotes() function).
- Add UiShowMessageBoxesInArgv() that acts on the "MessageBox=" settings
passed through the argument vector (equivalent to
UiShowMessageBoxesInSection() ).
- Use string-safe functions where needed (copy/concatenation/printf on
fixed-size buffers).
2019-08-06 20:30:54 +00:00
VOID
UiShowMessageBoxesInArgv (
IN ULONG Argc ,
IN PCHAR Argv [ ] ) ;
2013-05-24 12:20:13 +00:00
VOID UiEscapeString ( PCHAR String ) ; // Processes a string and changes all occurrences of "\n" to '\n'
BOOLEAN UiEditBox ( PCSTR MessageText , PCHAR EditTextBuffer , ULONG Length ) ;
UCHAR UiTextToColor ( PCSTR ColorText ) ; // Converts the text color into it's equivalent color value
UCHAR UiTextToFillStyle ( PCSTR FillStyleText ) ; // Converts the text fill into it's equivalent fill value
VOID UiTruncateStringEllipsis ( PCHAR StringText , ULONG MaxChars ) ; // Truncates a string to MaxChars by adding an ellipsis on the end '...'
VOID UiFadeInBackdrop ( VOID ) ; // Draws the backdrop and fades the screen in
VOID UiFadeOut ( VOID ) ; // Fades the screen out
2002-11-24 19:10:06 +00:00
2001-11-28 10:26:53 +00:00
///////////////////////////////////////////////////////////////////////////////////////
//
// Menu Functions
//
///////////////////////////////////////////////////////////////////////////////////////
2007-10-29 11:00:31 +00:00
2012-12-24 23:03:11 +00:00
typedef struct tagUI_MENU_INFO
{
2019-08-02 19:35:23 +00:00
PCSTR MenuHeader ;
PCSTR MenuFooter ;
BOOLEAN ShowBootOptions ;
PCSTR * MenuItemList ;
ULONG MenuItemCount ;
LONG MenuTimeRemaining ;
ULONG SelectedMenuItem ;
PVOID Context ;
ULONG Left ;
ULONG Top ;
ULONG Right ;
ULONG Bottom ;
2012-12-24 23:03:11 +00:00
} UI_MENU_INFO , * PUI_MENU_INFO ;
2007-10-29 11:00:31 +00:00
2019-08-02 19:35:23 +00:00
typedef
BOOLEAN
( * UiMenuKeyPressFilterCallback ) (
IN ULONG KeyPress ,
IN ULONG SelectedMenuItem ,
IN PVOID Context OPTIONAL ) ;
BOOLEAN
UiDisplayMenu (
IN PCSTR MenuHeader ,
IN PCSTR MenuFooter OPTIONAL ,
IN BOOLEAN ShowBootOptions ,
IN PCSTR MenuItemList [ ] ,
IN ULONG MenuItemCount ,
IN ULONG DefaultMenuItem ,
IN LONG MenuTimeOut ,
OUT PULONG SelectedMenuItem ,
IN BOOLEAN CanEscape ,
IN UiMenuKeyPressFilterCallback KeyPressFilter OPTIONAL ,
IN PVOID Context OPTIONAL ) ;
2002-06-06 05:58:37 +00:00
2007-10-29 11:00:31 +00:00
///////////////////////////////////////////////////////////////////////////////////////
//
// UI virtual table
//
///////////////////////////////////////////////////////////////////////////////////////
typedef struct tagUIVTBL
{
2013-05-24 12:20:13 +00:00
BOOLEAN ( * Initialize ) ( VOID ) ;
VOID ( * UnInitialize ) ( VOID ) ;
VOID ( * DrawBackdrop ) ( VOID ) ;
VOID ( * FillArea ) ( ULONG Left , ULONG Top , ULONG Right , ULONG Bottom , CHAR FillChar , UCHAR Attr ) ;
VOID ( * DrawShadow ) ( ULONG Left , ULONG Top , ULONG Right , ULONG Bottom ) ;
VOID ( * DrawBox ) ( ULONG Left , ULONG Top , ULONG Right , ULONG Bottom , UCHAR VertStyle , UCHAR HorzStyle , BOOLEAN Fill , BOOLEAN Shadow , UCHAR Attr ) ;
VOID ( * DrawText ) ( ULONG X , ULONG Y , PCSTR Text , UCHAR Attr ) ;
VOID ( * DrawText2 ) ( ULONG X , ULONG Y , ULONG MaxNumChars , PCSTR Text , UCHAR Attr ) ;
VOID ( * DrawCenteredText ) ( ULONG Left , ULONG Top , ULONG Right , ULONG Bottom , PCSTR TextString , UCHAR Attr ) ;
VOID ( * DrawStatusText ) ( PCSTR StatusText ) ;
VOID ( * UpdateDateTime ) ( VOID ) ;
VOID ( * MessageBox ) ( PCSTR MessageText ) ;
VOID ( * MessageBoxCritical ) ( PCSTR MessageText ) ;
VOID ( * DrawProgressBarCenter ) ( ULONG Position , ULONG Range , PCHAR ProgressText ) ;
VOID ( * DrawProgressBar ) ( ULONG Left , ULONG Top , ULONG Right , ULONG Bottom , ULONG Position , ULONG Range , PCHAR ProgressText ) ;
BOOLEAN ( * EditBox ) ( PCSTR MessageText , PCHAR EditTextBuffer , ULONG Length ) ;
UCHAR ( * TextToColor ) ( PCSTR ColorText ) ;
UCHAR ( * TextToFillStyle ) ( PCSTR FillStyleText ) ;
VOID ( * FadeInBackdrop ) ( VOID ) ;
VOID ( * FadeOut ) ( VOID ) ;
2019-08-02 19:35:23 +00:00
BOOLEAN ( * DisplayMenu ) (
IN PCSTR MenuHeader ,
IN PCSTR MenuFooter OPTIONAL ,
IN BOOLEAN ShowBootOptions ,
IN PCSTR MenuItemList [ ] ,
IN ULONG MenuItemCount ,
IN ULONG DefaultMenuItem ,
IN LONG MenuTimeOut ,
OUT PULONG SelectedMenuItem ,
IN BOOLEAN CanEscape ,
IN UiMenuKeyPressFilterCallback KeyPressFilter OPTIONAL ,
IN PVOID Context OPTIONAL ) ;
2013-05-24 12:20:13 +00:00
VOID ( * DrawMenu ) ( PUI_MENU_INFO MenuInfo ) ;
2007-10-29 11:00:31 +00:00
} UIVTBL , * PUIVTBL ;
VOID UiInit ( const char * CmdLine ) ;
extern UIVTBL UiVtbl ;
/*
* Combines the foreground and background colors into a single attribute byte
*/
2013-05-24 12:20:13 +00:00
# define ATTR(cFore, cBack) ((cBack << 4)|cFore)
2007-10-29 11:00:31 +00:00
/*
* Fill styles for DrawBackdrop ( )
*/
2013-05-24 12:20:13 +00:00
# define LIGHT_FILL 0xB0
# define MEDIUM_FILL 0xB1
# define DARK_FILL 0xB2
2001-11-28 10:26:53 +00:00
2007-10-29 11:00:31 +00:00
/*
* Screen colors
*/
2013-05-24 12:20:13 +00:00
# define COLOR_BLACK 0
# define COLOR_BLUE 1
# define COLOR_GREEN 2
# define COLOR_CYAN 3
# define COLOR_RED 4
# define COLOR_MAGENTA 5
# define COLOR_BROWN 6
# define COLOR_GRAY 7
# define COLOR_DARKGRAY 8
# define COLOR_LIGHTBLUE 9
# define COLOR_LIGHTGREEN 10
# define COLOR_LIGHTCYAN 11
# define COLOR_LIGHTRED 12
# define COLOR_LIGHTMAGENTA 13
# define COLOR_YELLOW 14
# define COLOR_WHITE 15
2007-10-29 11:00:31 +00:00
/* Add COLOR_BLINK to a background to cause blinking */
2013-05-24 12:20:13 +00:00
//#define COLOR_BLINK 8
2007-10-29 11:00:31 +00:00
/*
* Defines for IBM box drawing characters
*/
2013-05-24 12:20:13 +00:00
# define HORZ (0xc4) /* Single horizontal line */
# define D_HORZ (0xcd) /* Double horizontal line.*/
2007-10-29 11:00:31 +00:00
# define VERT (0xb3) /* Single vertical line */
# define D_VERT (0xba) /* Double vertical line. */