[driver] Add ability to write text to boot splash screen

Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
This commit is contained in:
Michael Brown 2011-02-26 11:31:13 +00:00
parent 445de827bc
commit 63bc225266
3 changed files with 126 additions and 1 deletions

101
src/driver/boottext.c Normal file
View File

@ -0,0 +1,101 @@
/*
* Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
*
* 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 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.
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <ntddk.h>
#include <ntstrsafe.h>
#include <stdarg.h>
#include "sanbootconf.h"
#include "boottext.h"
/* Maximum length of string to print */
#define BOOT_TEXT_MAX_LEN 128
/* Boot text colour */
#define BOOT_TEXT_COLOUR 15 /* White */
/* Boot text area left-hand edge */
#define BOOT_TEXT_AREA_LEFT 8
/* Boot text area right-hand edge */
#define BOOT_TEXT_AREA_RIGHT 631
/* Boot text area top edge */
#define BOOT_TEXT_AREA_TOP 14
/* Boot text area bottom edge */
#define BOOT_TEXT_AREA_BOTTOM 111
/* Definitions taken from ReactOS' inbvfuncs.h */
typedef BOOLEAN ( NTAPI * INBV_RESET_DISPLAY_PARAMETERS ) ( ULONG Cols,
ULONG Rows );
typedef VOID ( NTAPI * INBV_DISPLAY_STRING_FILTER ) ( PCHAR *Str );
VOID NTAPI InbvAcquireDisplayOwnership ( VOID );
BOOLEAN NTAPI InbvCheckDisplayOwnership ( VOID );
VOID NTAPI InbvNotifyDisplayOwnershipLost ( IN INBV_RESET_DISPLAY_PARAMETERS
Callback );
VOID NTAPI InbvEnableBootDriver ( IN BOOLEAN Enable );
VOID NTAPI InbvInstallDisplayStringFilter ( IN INBV_DISPLAY_STRING_FILTER
DisplayFilter );
BOOLEAN NTAPI InbvIsBootDriverInstalled ( VOID );
BOOLEAN NTAPI InbvDisplayString ( IN PCHAR String );
BOOLEAN NTAPI InbvEnableDisplayString ( IN BOOLEAN Enable );
BOOLEAN NTAPI InbvResetDisplay ( VOID );
VOID NTAPI InbvSetScrollRegion ( IN ULONG Left, IN ULONG Top, IN ULONG Width,
IN ULONG Height );
VOID NTAPI InbvSetTextColor ( IN ULONG Color );
VOID NTAPI InbvSolidColorFill ( IN ULONG Left, IN ULONG Top, IN ULONG Width,
IN ULONG Height, IN ULONG Color );
VOID NTAPI InbvSetProgressBarSubset ( IN ULONG Floor, IN ULONG Ceiling );
/**
* Print text to boot screen
*
* @v fmt Format string
* @v ... Arguments
*/
VOID BootPrint ( const char *fmt, ... ) {
static BOOLEAN initialised = FALSE;
char buf[BOOT_TEXT_MAX_LEN];
va_list args;
/* Generate string to print */
va_start ( args, fmt );
RtlStringCbVPrintfA ( buf, sizeof ( buf ), fmt, args );
va_end ( args );
/* Log to debugger, if attached */
DbgPrint ( "%s", buf );
/* Configure display */
if ( ! InbvCheckDisplayOwnership() )
InbvAcquireDisplayOwnership();
if ( ! initialised ) {
InbvSetScrollRegion ( BOOT_TEXT_AREA_LEFT,
BOOT_TEXT_AREA_TOP,
BOOT_TEXT_AREA_RIGHT,
BOOT_TEXT_AREA_BOTTOM );
initialised = TRUE;
}
InbvSetTextColor ( BOOT_TEXT_COLOUR );
InbvEnableDisplayString ( TRUE );
/* Avoid switching to the "chkdsk" screen */
InbvInstallDisplayStringFilter ( NULL );
/* Print the string */
InbvDisplayString ( buf );
}

24
src/driver/boottext.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef _BOOTTEXT_H
#define _BOOTTEXT_H
/*
* Copyright (C) 2011 Michael Brown <mbrown@fensystems.co.uk>.
*
* 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 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.
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
extern VOID BootPrint ( const char *fmt, ... );
#endif /* _BOOTTEXT_H */

View File

@ -8,4 +8,4 @@ TARGETLIBS = $(DDK_LIB_PATH)\ndis.lib $(DDK_LIB_PATH)\ntstrsafe.lib $(DDK_LIB_PA
MSC_WARNING_LEVEL = /W4 /Wp64 /WX
SOURCES = sanbootconf.c registry.c acpi.c nic.c ibft.c abft.c sbft.c
SOURCES = sanbootconf.c registry.c acpi.c nic.c ibft.c abft.c sbft.c boottext.c