Skip to content

Commit

Permalink
[driver] Add ability to write text to boot splash screen
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
  • Loading branch information
mcb30 committed Feb 26, 2011
1 parent 445de82 commit 63bc225
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 1 deletion.
101 changes: 101 additions & 0 deletions src/driver/boottext.c
@@ -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 changes: 24 additions & 0 deletions src/driver/boottext.h
@@ -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 */
2 changes: 1 addition & 1 deletion src/driver/sources
Expand Up @@ -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

0 comments on commit 63bc225

Please sign in to comment.