Changes in v1.8 (1/18/2003) (brianp)

- Added F8 options menu
- Added custom Boot functionality
- Moved all OS= settings from [FreeLoader] section to [Operating Systems] section.
- Removed MessageLine= setting. MessageBox= now accepts "\n" as an escape character for newlines.
- Added descriptions for disk error codes returned by the BIOS.
- Device names like "fd0" and "hd0" and "hd1" as well as BIOS drive numbers can now be used as BootDrive= settings.

svn path=/trunk/; revision=4038
This commit is contained in:
Brian Palmer 2003-01-19 01:04:01 +00:00
parent a26dfde014
commit 59f1842f56
79 changed files with 971 additions and 645 deletions

View file

@ -44,3 +44,19 @@ EXTERN(_ChainLoadBiosBootSectorCode)
movw $0x7C00,%sp
ljmpl $0x0000,$0x7C00
EXTERN(_SoftReboot)
.code32
call switch_to_real
.code16
movw $0x40,%ax
movw %ax,%ds
movw $0x72,%si
// Set the word at location 40:72 to 1234h
movw $0x1234,(%si)
// and jump to location FFFF:0 in ROM
ljmpl $0xFFFF,$0x0000

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -22,7 +22,7 @@
#include <rtl.h>
#include <arch.h>
#include <debug.h>
#include <comm.h>
#include <portio.h>
typedef struct

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -22,7 +22,7 @@
#include <mm.h>
#include <debug.h>
#include <rtl.h>
#include <comm.h>
#include <portio.h>
U32 GetExtendedMemorySize(VOID)

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -19,7 +19,8 @@
#include <freeldr.h>
#include <arch.h>
#include <rtl.h>
#include <portio.h>
void putchar(int ch)
{
@ -326,3 +327,70 @@ int getsecond(void)
return (Digit1 + Digit2);
}
void beep(void)
{
sound(700);
delay(200);
sound(0);
}
void delay(unsigned msec)
{
REGS Regs;
unsigned usec;
unsigned msec_this;
// Int 15h AH=86h
// BIOS - WAIT (AT,PS)
//
// AH = 86h
// CX:DX = interval in microseconds
// Return:
// CF clear if successful (wait interval elapsed)
// CF set on error or AH=83h wait already in progress
// AH = status (see #00496)
// Note: The resolution of the wait period is 977 microseconds on
// many systems because many BIOSes use the 1/1024 second fast
// interrupt from the AT real-time clock chip which is available on INT 70;
// because newer BIOSes may have much more precise timers available, it is
// not possible to use this function accurately for very short delays unless
// the precise behavior of the BIOS is known (or found through testing)
while (msec)
{
msec_this = msec;
if (msec_this > 4000)
{
msec_this = 4000;
}
usec = msec_this * 1000;
Regs.b.ah = 0x86;
Regs.w.cx = usec >> 16;
Regs.w.dx = usec & 0xffff;
Int386(0x15, &Regs, &Regs);
msec -= msec_this;
}
}
void sound(int freq)
{
int scale;
if (freq == 0)
{
WRITE_PORT_UCHAR((PUCHAR)0x61, READ_PORT_UCHAR((PUCHAR)0x61) & ~3);
return;
}
scale = 1193046 / freq;
WRITE_PORT_UCHAR((PUCHAR)0x43, 0xb6);
WRITE_PORT_UCHAR((PUCHAR)0x42, scale & 0xff);
WRITE_PORT_UCHAR((PUCHAR)0x42, scale >> 8);
WRITE_PORT_UCHAR((PUCHAR)0x61, READ_PORT_UCHAR((PUCHAR)0x61) | 3);
}

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
* Portions from Linux video.S - Display adapter & video mode setup, version 2.13 (14-May-99)
* Copyright (C) 1995 -- 1999 Martin Mares <mj@ucw.cz>
* Based on the original setup.S code (C) Linus Torvalds and Mats Anderson
@ -24,7 +24,7 @@
#include <freeldr.h>
#include <arch.h>
#include <video.h>
#include <comm.h>
#include <portio.h>
#include <rtl.h>
#include <debug.h>
@ -427,7 +427,7 @@ VOID VideoSetTextCursorPosition(U32 X, U32 Y)
// DL = column (00h is left)
// Return:
// Nothing
Regs.b.ah = 0x01;
Regs.b.ah = 0x02;
Regs.b.bh = 0x00;
Regs.b.dh = Y;
Regs.b.dl = X;

View file

@ -1,4 +1,4 @@
/* $Id: portio.c,v 1.3 2002/08/07 05:13:15 bpalmer Exp $
/* $Id: portio.c,v 1.1 2003/01/19 01:03:58 bpalmer Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -21,6 +21,7 @@
#include <freeldr.h>
#include <comm.h>
#include <portio.h>
/* MACROS *******************************************************************/

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -34,15 +34,50 @@
VOID DiskError(PUCHAR ErrorString, U32 ErrorCode)
{
UCHAR ErrorCodeString[80];
UCHAR ErrorCodeString[200];
sprintf(ErrorCodeString, "%s\n\nError Code: 0x%x", ErrorString, ErrorCode);
sprintf(ErrorCodeString, "%s\n\nError Code: 0x%x\nError: %s", ErrorString, ErrorCode, DiskGetErrorCodeString(ErrorCode));
DbgPrint((DPRINT_DISK, "%s\n", ErrorCodeString));
UiMessageBox(ErrorCodeString);
}
PUCHAR DiskGetErrorCodeString(U32 ErrorCode)
{
switch (ErrorCode)
{
case 0x00: return "no error";
case 0x01: return "bad command passed to driver";
case 0x02: return "address mark not found or bad sector";
case 0x03: return "diskette write protect error";
case 0x04: return "sector not found";
case 0x05: return "fixed disk reset failed";
case 0x06: return "diskette changed or removed";
case 0x07: return "bad fixed disk parameter table";
case 0x08: return "DMA overrun";
case 0x09: return "DMA access across 64k boundary";
case 0x0A: return "bad fixed disk sector flag";
case 0x0B: return "bad fixed disk cylinder";
case 0x0C: return "unsupported track/invalid media";
case 0x0D: return "invalid number of sectors on fixed disk format";
case 0x0E: return "fixed disk controlled data address mark detected";
case 0x0F: return "fixed disk DMA arbitration level out of range";
case 0x10: return "ECC/CRC error on disk read";
case 0x11: return "recoverable fixed disk data error, data fixed by ECC";
case 0x20: return "controller error (NEC for floppies)";
case 0x40: return "seek failure";
case 0x80: return "time out, drive not ready";
case 0xAA: return "fixed disk drive not ready";
case 0xBB: return "fixed disk undefined error";
case 0xCC: return "fixed disk write fault on selected drive";
case 0xE0: return "fixed disk status error/Error reg = 0";
case 0xFF: return "sense operation failed";
default: return "unknown error code";
}
}
// This function is in arch/i386/i386disk.c
//BOOL DiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer)

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -17,8 +17,6 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
//20030118 RJJ added comment to test CVS
#include <freeldr.h>
#include <rtl.h>
#include <arch.h>

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -160,6 +160,9 @@ int Int386(int ivec, REGS* in, REGS* out);
void EnableA20(void);
VOID ChainLoadBiosBootSectorCode(VOID); // Implemented in boot.S
VOID SoftReboot(VOID); // Implemented in boot.S
#endif /* ! ASM */

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -23,6 +23,7 @@
U32 GetDefaultOperatingSystem(PUCHAR OperatingSystemList[], U32 OperatingSystemCount);
S32 GetTimeOut(VOID);
BOOL MainBootMenuKeyPressFilter(U32 KeyPress);
#endif // #defined __BOOTMGR_H

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -29,57 +29,4 @@ VOID Rs232PortPutByte(UCHAR ByteToSend);
/*
* Port I/O functions
*/
VOID
/*STDCALL*/
READ_PORT_BUFFER_UCHAR (PUCHAR Port, PUCHAR Value, U32 Count);
VOID
/*STDCALL*/
READ_PORT_BUFFER_ULONG (U32* Port, U32* Value, U32 Count);
VOID
/*STDCALL*/
READ_PORT_BUFFER_USHORT (U16* Port, U16* Value, U32 Count);
UCHAR
/*STDCALL*/
READ_PORT_UCHAR (PUCHAR Port);
U32
/*STDCALL*/
READ_PORT_ULONG (U32* Port);
U16
/*STDCALL*/
READ_PORT_USHORT (U16* Port);
VOID
/*STDCALL*/
WRITE_PORT_BUFFER_UCHAR (PUCHAR Port, PUCHAR Value, U32 Count);
VOID
/*STDCALL*/
WRITE_PORT_BUFFER_ULONG (U32* Port, U32* Value, U32 Count);
VOID
/*STDCALL*/
WRITE_PORT_BUFFER_USHORT (U16* Port, U16* Value, U32 Count);
VOID
/*STDCALL*/
WRITE_PORT_UCHAR (PUCHAR Port, UCHAR Value);
VOID
/*STDCALL*/
WRITE_PORT_ULONG (U32* Port, U32 Value);
VOID
/*STDCALL*/
WRITE_PORT_USHORT (U16* Port, U16 Value);
#endif // defined __RS232_H

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -105,6 +105,7 @@ BOOL DiskGetDriveParameters(U32 DriveNumber, PGEOMETRY Geometry);
//
///////////////////////////////////////////////////////////////////////////////////////
VOID DiskError(PUCHAR ErrorString, U32 ErrorCode);
PUCHAR DiskGetErrorCodeString(U32 ErrorCode);
BOOL DiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY DriveGeometry);
BOOL DiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer); // Implemented in i386disk.c
BOOL DiskIsDriveRemovable(U32 DriveNumber);

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -24,8 +24,12 @@ BOOL IniFileInitialize(VOID);
BOOL IniOpenSection(PUCHAR SectionName, U32* SectionId);
U32 IniGetNumSectionItems(U32 SectionId);
U32 IniGetSectionSettingNameSize(U32 SectionId, U32 SettingIndex);
U32 IniGetSectionSettingValueSize(U32 SectionId, U32 SettingIndex);
BOOL IniReadSettingByNumber(U32 SectionId, U32 SettingNumber, PUCHAR SettingName, U32 NameSize, PUCHAR SettingValue, U32 ValueSize);
BOOL IniReadSettingByName(U32 SectionId, PUCHAR SettingName, PUCHAR Buffer, U32 BufferSize);
BOOL IniAddSection(PUCHAR SectionName, U32* SectionId);
BOOL IniAddSettingValueToSection(U32 SectionId, PUCHAR SettingName, PUCHAR SettingValue);
#endif // defined __PARSEINI_H

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -24,6 +24,7 @@
// Key codes
#define KEY_EXTENDED 0x00
#define KEY_ENTER 0x0D
#define KEY_BACKSPACE 0x08
#define KEY_SPACE 0x20
#define KEY_UP 0x48
#define KEY_DOWN 0x50

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -17,6 +17,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <fs.h>
#ifndef __LINUX_H
#define __LINUX_H
@ -120,7 +122,7 @@ typedef struct
VOID BootNewLinuxKernel(VOID); // Implemented in linux.S
VOID BootOldLinuxKernel(U32 KernelSize); // Implemented in linux.S
VOID LoadAndBootLinux(PUCHAR OperatingSystemName);
VOID LoadAndBootLinux(PUCHAR OperatingSystemName, PUCHAR Description);
BOOL LinuxParseIniSection(PUCHAR OperatingSystemName);
BOOL LinuxReadBootSector(PFILE LinuxKernelFile);

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -20,8 +20,6 @@
#ifndef __BOOT_H
#define __BOOT_H
VOID ChainLoadBiosBootSectorCode(VOID); // Implemented in boot.S
VOID LoadAndBootBootSector(PUCHAR OperatingSystemName);
VOID LoadAndBootPartition(PUCHAR OperatingSystemName);
VOID LoadAndBootDrive(PUCHAR OperatingSystemName);

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -20,12 +20,15 @@
#ifndef __OPTIONS_H
#define __OPTIONS_H
void DoOptionsMenu(void);
void DoDiskOptionsMenu(void);
void DoBootOptionsMenu(int BootDriveNum, char *BootDriveText);
void DoBootPartitionOptionsMenu(int BootDriveNum);
int RunOptionsMenu(char OptionsMenuItems[][80], int OptionsMenuItemCount, int nOptionSelected, char *OptionsMenuTitle);
void InitOptionsMenu(int *nOptionsMenuBoxLeft, int *nOptionsMenuBoxTop, int *nOptionsMenuBoxRight, int *nOptionsMenuBoxBottom, int OptionsMenuItemCount);
void DrawOptionsMenu(char OptionsMenuItems[][80], int OptionsMenuItemCount, int nOptionSelected, char *OptionsMenuTitle, int nOptionsMenuBoxLeft, int nOptionsMenuBoxTop, int nOptionsMenuBoxRight, int nOptionsMenuBoxBottom);
VOID DoOptionsMenu(VOID);
VOID OptionMenuReboot(VOID);
VOID OptionMenuCustomBoot(VOID);
VOID OptionMenuCustomBootDisk(VOID);
VOID OptionMenuCustomBootPartition(VOID);
VOID OptionMenuCustomBootBootSectorFile(VOID);
VOID OptionMenuCustomBootReactOS(VOID);
VOID OptionMenuCustomBootLinux(VOID);
#endif // #defined __OPTIONS_H

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -0,0 +1,78 @@
/*
* FreeLoader
* Copyright (C) 2001 Brian Palmer <brianp@sginet.com>
* Copyright (C) 2001 Eric Kohl
* Copyright (C) 2001 Emanuele Aliberti
*
* 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.
*
* 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.
*/
#ifndef __PORTIO_H
#define __PORTIO_H
/*
* Port I/O functions
*/
VOID
/*STDCALL*/
READ_PORT_BUFFER_UCHAR (PUCHAR Port, PUCHAR Value, U32 Count);
VOID
/*STDCALL*/
READ_PORT_BUFFER_ULONG (U32* Port, U32* Value, U32 Count);
VOID
/*STDCALL*/
READ_PORT_BUFFER_USHORT (U16* Port, U16* Value, U32 Count);
UCHAR
/*STDCALL*/
READ_PORT_UCHAR (PUCHAR Port);
U32
/*STDCALL*/
READ_PORT_ULONG (U32* Port);
U16
/*STDCALL*/
READ_PORT_USHORT (U16* Port);
VOID
/*STDCALL*/
WRITE_PORT_BUFFER_UCHAR (PUCHAR Port, PUCHAR Value, U32 Count);
VOID
/*STDCALL*/
WRITE_PORT_BUFFER_ULONG (U32* Port, U32* Value, U32 Count);
VOID
/*STDCALL*/
WRITE_PORT_BUFFER_USHORT (U16* Port, U16* Value, U32 Count);
VOID
/*STDCALL*/
WRITE_PORT_UCHAR (PUCHAR Port, UCHAR Value);
VOID
/*STDCALL*/
WRITE_PORT_ULONG (U32* Port, U32 Value);
VOID
/*STDCALL*/
WRITE_PORT_USHORT (U16* Port, U16 Value);
#endif // defined __PORTIO_H

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -41,8 +41,8 @@ VOID ReactOSRunSetupLoader(VOID);
//
///////////////////////////////////////////////////////////////////////////////////////
BOOL DissectArcPath(char *ArcPath, char *BootPath, U32* BootDrive, U32* BootPartition);
//BOOL ConvertBiosDriveToArcName(PUCHAR ArcName, U32 BiosDriveNumber);
//U32 ConvertArcNameToBiosDrive(PUCHAR ArcName);
void ConstructArcPath(PUCHAR ArcPath, PUCHAR SystemFolder, U32 Disk, U32 Partition);
U32 ConvertArcNameToBiosDriveNumber(PUCHAR ArcPath);
#endif // defined __REACTOS_H

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -79,6 +79,10 @@ int gethour(void); // Implemented in asmcode.S
int getminute(void); // Implemented in asmcode.S
int getsecond(void); // Implemented in asmcode.S
void beep(void);
void delay(unsigned msec);
void sound(int freq);
#ifndef max
#define max(a, b) (((a) > (b)) ? (a) : (b))
#endif

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -38,9 +38,10 @@ 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 UiTitleBoxTitleText[260]; // Title box's title text
extern UCHAR UiEditBoxTextColor; // Edit box text color
extern UCHAR UiEditBoxBgColor; // Edit box text background color
extern PUCHAR UiMessageBoxLineText;
extern UCHAR UiTitleBoxTitleText[260]; // Title box's title text
extern BOOL UserInterfaceUp; // Tells us if the user interface is displayed
@ -66,10 +67,11 @@ VOID UiUpdateDateTime(VOID); // Updates the date and time
VOID UiInfoBox(PUCHAR MessageText); // Displays a info box on the screen
VOID UiMessageBox(PUCHAR MessageText); // Displays a message box on the screen with an ok button
VOID UiMessageBoxCritical(PUCHAR MessageText); // Displays a message box on the screen with an ok button using no system resources
VOID UiMessageLine(PUCHAR MessageText); // Adds a line of text to the message box buffer
VOID UiDrawProgressBarCenter(U32 Position, U32 Range, PUCHAR ProgressText); // Draws the progress bar showing nPos percent filled
VOID UiDrawProgressBar(U32 Left, U32 Top, U32 Right, U32 Bottom, U32 Position, U32 Range, PUCHAR ProgressText); // Draws the progress bar showing nPos percent filled
VOID UiShowMessageBoxesInSection(PUCHAR SectionName); // Displays all the message boxes in a given section
VOID UiEscapeString(PUCHAR String); // Processes a string and changes all occurances of "\n" to '\n'
BOOL UiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, U32 Length);
UCHAR UiTextToColor(PUCHAR ColorText); // Converts the text color into it's equivalent color value
UCHAR UiTextToFillStyle(PUCHAR FillStyleText); // Converts the text fill into it's equivalent fill value
@ -84,7 +86,9 @@ VOID UiFadeOut(VOID); // Fades the screen out
// Menu Functions
//
///////////////////////////////////////////////////////////////////////////////////////
BOOL UiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem, S32 MenuTimeOut, U32* SelectedMenuItem);
typedef BOOL (*UiMenuKeyPressFilterCallback)(U32 KeyPress);
BOOL UiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem, S32 MenuTimeOut, U32* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter);

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -22,8 +22,8 @@
/* just some stuff */
#define VERSION "FreeLoader v1.7.12"
#define COPYRIGHT "Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>"
#define VERSION "FreeLoader v1.8"
#define COPYRIGHT "Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>"
#define AUTHOR_EMAIL "<brianp@sginet.com>"
#define BY_AUTHOR "by Brian Palmer"
@ -35,8 +35,8 @@
// If you add major functionality then you increment the major version and zero the minor & patch versions
//
#define FREELOADER_MAJOR_VERSION 1
#define FREELOADER_MINOR_VERSION 7
#define FREELOADER_PATCH_VERSION 12
#define FREELOADER_MINOR_VERSION 8
#define FREELOADER_PATCH_VERSION 0
PUCHAR GetFreeLoaderVersionString(VOID);

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -54,7 +54,8 @@ typedef struct
} INI_SECTION, *PINI_SECTION;
extern PINI_SECTION IniFileSectionListHead;
extern U32 IniFileSectionListCount;
extern U32 IniFileSectionCount;
extern U32 IniFileSettingCount;
PFILE IniOpenIniFile(U8 BootDriveNumber, U8 BootPartitionNumber);

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -22,6 +22,7 @@
#include <ui.h>
#include <rtl.h>
#include <debug.h>
#include <mm.h>
BOOL IniOpenSection(PUCHAR SectionName, U32* SectionId)
{
@ -61,6 +62,22 @@ U32 IniGetNumSectionItems(U32 SectionId)
return Section->SectionItemCount;
}
U32 IniGetSectionSettingNameSize(U32 SectionId, U32 SettingIndex)
{
PINI_SECTION Section = (PINI_SECTION)SectionId;
// Return the size of the string plus 1 for the null-terminator
return (strlen(Section->SectionItemList[SettingIndex].ItemName) + 1);
}
U32 IniGetSectionSettingValueSize(U32 SectionId, U32 SettingIndex)
{
PINI_SECTION Section = (PINI_SECTION)SectionId;
// Return the size of the string plus 1 for the null-terminator
return (strlen(Section->SectionItemList[SettingIndex].ItemValue) + 1);
}
BOOL IniReadSettingByNumber(U32 SectionId, U32 SettingNumber, PUCHAR SettingName, U32 NameSize, PUCHAR SettingValue, U32 ValueSize)
{
PINI_SECTION Section = (PINI_SECTION)SectionId;
@ -68,13 +85,16 @@ BOOL IniReadSettingByNumber(U32 SectionId, U32 SettingNumber, PUCHAR SettingName
#ifdef DEBUG
U32 RealSettingNumber = SettingNumber;
#endif
DbgPrint((DPRINT_INIFILE, ".001 NameSize = %d ValueSize = %d\n", NameSize, ValueSize));
DbgPrint((DPRINT_INIFILE, "IniReadSettingByNumber() SectionId = 0x%x\n", SectionId));
// Loop through each section item and find the one they want
DbgPrint((DPRINT_INIFILE, ".01 NameSize = %d ValueSize = %d\n", NameSize, ValueSize));
SectionItem = (PINI_SECTION_ITEM)RtlListGetHead((PLIST_ITEM)Section->SectionItemList);
while (SectionItem != NULL)
{
DbgPrint((DPRINT_INIFILE, ".1 NameSize = %d ValueSize = %d\n", NameSize, ValueSize));
// Check to see if this is the setting they want
if (SettingNumber == 0)
{
@ -82,8 +102,16 @@ BOOL IniReadSettingByNumber(U32 SectionId, U32 SettingNumber, PUCHAR SettingName
DbgPrint((DPRINT_INIFILE, "IniReadSettingByNumber() Setting name = %s\n", SectionItem->ItemName));
DbgPrint((DPRINT_INIFILE, "IniReadSettingByNumber() Setting value = %s\n", SectionItem->ItemValue));
DbgPrint((DPRINT_INIFILE, "1 NameSize = %d ValueSize = %d\n", NameSize, ValueSize));
RtlZeroMemory(SettingName, NameSize);
RtlZeroMemory(SettingValue, ValueSize);
DbgPrint((DPRINT_INIFILE, "2 NameSize = %d ValueSize = %d\n", NameSize, ValueSize));
strncpy(SettingName, SectionItem->ItemName, NameSize);
DbgPrint((DPRINT_INIFILE, "3 NameSize = %d ValueSize = %d\n", NameSize, ValueSize));
strncpy(SettingValue, SectionItem->ItemValue, ValueSize);
DbgPrint((DPRINT_INIFILE, "4 NameSize = %d ValueSize = %d\n", NameSize, ValueSize));
DbgDumpBuffer(DPRINT_INIFILE, SettingName, NameSize);
DbgDumpBuffer(DPRINT_INIFILE, SettingValue, ValueSize);
return TRUE;
}
@ -117,6 +145,7 @@ BOOL IniReadSettingByName(U32 SectionId, PUCHAR SettingName, PUCHAR Buffer, U32
DbgPrint((DPRINT_INIFILE, "IniReadSettingByName() Setting \'%s\' found.\n", SettingName));
DbgPrint((DPRINT_INIFILE, "IniReadSettingByName() Setting value = %s\n", SectionItem->ItemValue));
RtlZeroMemory(Buffer, BufferSize);
strncpy(Buffer, SectionItem->ItemValue, BufferSize);
return TRUE;
@ -130,3 +159,91 @@ BOOL IniReadSettingByName(U32 SectionId, PUCHAR SettingName, PUCHAR Buffer, U32
return FALSE;
}
BOOL IniAddSection(PUCHAR SectionName, U32* SectionId)
{
PINI_SECTION Section;
// Allocate a new section structure
Section = MmAllocateMemory(sizeof(INI_SECTION));
if (!Section)
{
return FALSE;
}
RtlZeroMemory(Section, sizeof(INI_SECTION));
// Allocate the section name buffer
Section->SectionName = MmAllocateMemory(strlen(SectionName));
if (!Section->SectionName)
{
MmFreeMemory(Section);
return FALSE;
}
// Get the section name
strcpy(Section->SectionName, SectionName);
// Add it to the section list head
IniFileSectionCount++;
if (IniFileSectionListHead == NULL)
{
IniFileSectionListHead = Section;
}
else
{
RtlListInsertTail((PLIST_ITEM)IniFileSectionListHead, (PLIST_ITEM)Section);
}
*SectionId = (U32)Section;
return TRUE;
}
BOOL IniAddSettingValueToSection(U32 SectionId, PUCHAR SettingName, PUCHAR SettingValue)
{
PINI_SECTION Section = (PINI_SECTION)SectionId;
PINI_SECTION_ITEM SectionItem;
// Allocate a new item structure
SectionItem = MmAllocateMemory(sizeof(INI_SECTION_ITEM));
if (!SectionItem)
{
return FALSE;
}
RtlZeroMemory(SectionItem, sizeof(INI_SECTION_ITEM));
// Allocate the setting name buffer
SectionItem->ItemName = MmAllocateMemory(strlen(SettingName));
if (!SectionItem->ItemName)
{
MmFreeMemory(SectionItem);
return FALSE;
}
// Allocate the setting value buffer
SectionItem->ItemValue = MmAllocateMemory(strlen(SettingValue));
if (!SectionItem->ItemValue)
{
MmFreeMemory(SectionItem->ItemName);
MmFreeMemory(SectionItem);
return FALSE;
}
strcpy(SectionItem->ItemName, SettingName);
strcpy(SectionItem->ItemValue, SettingValue);
// Add it to the current section
Section->SectionItemCount++;
if (Section->SectionItemList == NULL)
{
Section->SectionItemList = SectionItem;
}
else
{
RtlListInsertTail((PLIST_ITEM)Section->SectionItemList, (PLIST_ITEM)SectionItem);
}
return TRUE;
}

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -124,6 +124,8 @@ BOOL IniParseFile(PUCHAR IniFileData, U32 IniFileSize)
if (CurrentSection == NULL)
{
printf("Error: freeldr.ini:%ld: Setting '%s' found outside of a [section].\n", CurrentLineNumber, IniFileLine);
printf("Press any key to continue...\n");
getch();
CurrentLineNumber++;
continue;
}
@ -151,6 +153,7 @@ BOOL IniParseFile(PUCHAR IniFileData, U32 IniFileSize)
CurrentItem->ItemValue = MmAllocateMemory(IniGetSettingValueSize(IniFileLine, LineLength));
if (!CurrentItem->ItemValue)
{
MmFreeMemory(CurrentItem->ItemName);
MmFreeMemory(CurrentItem);
MmFreeMemory(IniFileLine);
return FALSE;

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -31,6 +31,7 @@
#include <inifile.h>
#include <oslist.h> // For RemoveQuotes()
#include <video.h>
#include <drivemap.h>
@ -52,7 +53,7 @@ PVOID LinuxKernelLoadAddress = NULL;
PVOID LinuxInitrdLoadAddress = NULL;
UCHAR LinuxBootDescription[80];
VOID LoadAndBootLinux(PUCHAR OperatingSystemName)
VOID LoadAndBootLinux(PUCHAR OperatingSystemName, PUCHAR Description)
{
PFILE LinuxKernel = NULL;
PFILE LinuxInitrdFile = NULL;
@ -60,15 +61,24 @@ VOID LoadAndBootLinux(PUCHAR OperatingSystemName)
UiDrawBackdrop();
if (Description)
{
sprintf(LinuxBootDescription, "Loading %s...", Description);
}
else
{
strcpy(LinuxBootDescription, "Loading Linux...");
}
UiDrawStatusText(LinuxBootDescription);
UiDrawProgressBarCenter(0, 100, LinuxBootDescription);
// Parse the .ini file section
if (!LinuxParseIniSection(OperatingSystemName))
{
goto LinuxBootFailed;
}
UiDrawStatusText(LinuxBootDescription);
UiDrawProgressBarCenter(0, 100, LinuxBootDescription);
// Open the boot volume
if (!FsOpenVolume(BootDrive, BootPartition))
{
@ -148,13 +158,11 @@ VOID LoadAndBootLinux(PUCHAR OperatingSystemName)
LinuxSetupSector->LoadFlags = 0;
}
getch();
RtlCopyMemory((PVOID)0x90000, LinuxBootSector, 512);
RtlCopyMemory((PVOID)0x90200, LinuxSetupSector, SetupSectorSize);
RtlCopyMemory((PVOID)0x99000, LinuxCommandLine, LinuxCommandLineSize);
UiUnInitialize("Booting Linux...");
getch();
DiskStopFloppyMotor();
@ -231,17 +239,7 @@ BOOL LinuxParseIniSection(PUCHAR OperatingSystemName)
return FALSE;
}
if (IniReadSettingByName(SectionId, "Name", SettingValue, 260))
{
RemoveQuotes(SettingValue);
sprintf(LinuxBootDescription, "Loading %s...");
}
else
{
strcpy(LinuxBootDescription, "Loading Linux...");
}
BootDrive = atoi(SettingValue);
BootDrive = DriveMapGetBiosDriveNumber(SettingValue);
BootPartition = 0;
if (IniReadSettingByName(SectionId, "BootPartition", SettingValue, 260))

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -26,6 +26,7 @@
#include <ui.h>
#include <inifile.h>
#include <disk.h>
#include <drivemap.h>
VOID LoadAndBootBootSector(PUCHAR OperatingSystemName)
{
@ -53,7 +54,7 @@ VOID LoadAndBootBootSector(PUCHAR OperatingSystemName)
return;
}
BootDrive = atoi(SettingValue);
BootDrive = DriveMapGetBiosDriveNumber(SettingValue);
BootPartition = 0;
if (IniReadSettingByName(SectionId, "BootPartition", SettingValue, 80))
@ -132,7 +133,7 @@ VOID LoadAndBootPartition(PUCHAR OperatingSystemName)
return;
}
BootDrive = atoi(SettingValue);
BootDrive = DriveMapGetBiosDriveNumber(SettingValue);
// Read the boot partition
if (!IniReadSettingByName(SectionId, "BootPartition", SettingValue, 80))
@ -199,7 +200,7 @@ VOID LoadAndBootDrive(PUCHAR OperatingSystemName)
return;
}
BootDrive = atoi(SettingValue);
BootDrive = DriveMapGetBiosDriveNumber(SettingValue);
// Now try to read the boot sector (or mbr)
// If this fails then abort

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -53,16 +53,16 @@ PUCHAR MmGetSystemMemoryMapTypeString(U32 Type);
#endif
U32 MmGetPageNumberFromAddress(PVOID Address); // Returns the page number that contains a linear address
PVOID MmGetEndAddressOfAnyMemory(BIOS_MEMORY_MAP BiosMemoryMap[32], U32 MapCount); // Returns the last address of memory from the memory map
U32 MmGetAddressablePageCountIncludingHoles(BIOS_MEMORY_MAP BiosMemoryMap[32], U32 MapCount); // Returns the count of addressable pages from address zero including any memory holes and reserved memory regions
PVOID MmFindLocationForPageLookupTable(BIOS_MEMORY_MAP BiosMemoryMap[32], U32 MapCount); // Returns the address for a memory chunk big enough to hold the page lookup table (starts search from end of memory)
VOID MmSortBiosMemoryMap(BIOS_MEMORY_MAP BiosMemoryMap[32], U32 MapCount); // Sorts the BIOS_MEMORY_MAP array so the first element corresponds to the first address in memory
VOID MmInitPageLookupTable(PVOID PageLookupTable, U32 TotalPageCount, BIOS_MEMORY_MAP BiosMemoryMap[32], U32 MapCount); // Inits the page lookup table according to the memory types in the memory map
PVOID MmGetEndAddressOfAnyMemory(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount); // Returns the last address of memory from the memory map
U32 MmGetAddressablePageCountIncludingHoles(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount); // Returns the count of addressable pages from address zero including any memory holes and reserved memory regions
PVOID MmFindLocationForPageLookupTable(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount); // Returns the address for a memory chunk big enough to hold the page lookup table (starts search from end of memory)
VOID MmSortBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount); // Sorts the BIOS_MEMORY_MAP array so the first element corresponds to the first address in memory
VOID MmInitPageLookupTable(PVOID PageLookupTable, U32 TotalPageCount, PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount); // Inits the page lookup table according to the memory types in the memory map
VOID MmMarkPagesInLookupTable(PVOID PageLookupTable, U32 StartPage, U32 PageCount, U32 PageAllocated); // Marks the specified pages as allocated or free in the lookup table
VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, U32 StartPage, U32 PageCount); // Allocates the specified pages in the lookup table
U32 MmCountFreePagesInLookupTable(PVOID PageLookupTable, U32 TotalPageCount); // Returns the number of free pages in the lookup table
U32 MmFindAvailablePagesFromEnd(PVOID PageLookupTable, U32 TotalPageCount, U32 PagesNeeded); // Returns the page number of the first available page range from the end of memory
VOID MmFixupSystemMemoryMap(BIOS_MEMORY_MAP BiosMemoryMap[32], U32* MapCount); // Removes entries in the memory map that describe memory above 4G
VOID MmFixupSystemMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32* MapCount); // Removes entries in the memory map that describe memory above 4G
VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, U32 TotalPageCount); // Sets the LastFreePageHint to the last usable page of memory
BOOL MmAreMemoryPagesAvailable(PVOID PageLookupTable, U32 TotalPageCount, PVOID PageAddress, U32 PageCount); // Returns TRUE if the specified pages of memory are available, otherwise FALSE

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -149,7 +149,7 @@ U32 MmGetPageNumberFromAddress(PVOID Address)
return ((U32)Address) / MM_PAGE_SIZE;
}
PVOID MmGetEndAddressOfAnyMemory(BIOS_MEMORY_MAP BiosMemoryMap[32], U32 MapCount)
PVOID MmGetEndAddressOfAnyMemory(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount)
{
U64 MaxStartAddressSoFar;
U64 EndAddressOfMemory;
@ -175,7 +175,7 @@ PVOID MmGetEndAddressOfAnyMemory(BIOS_MEMORY_MAP BiosMemoryMap[32], U32 MapCount
return (PVOID)(U32)EndAddressOfMemory;
}
U32 MmGetAddressablePageCountIncludingHoles(BIOS_MEMORY_MAP BiosMemoryMap[32], U32 MapCount)
U32 MmGetAddressablePageCountIncludingHoles(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount)
{
U32 PageCount;
U64 EndAddress;
@ -201,17 +201,17 @@ U32 MmGetAddressablePageCountIncludingHoles(BIOS_MEMORY_MAP BiosMemoryMap[32], U
return PageCount;
}
PVOID MmFindLocationForPageLookupTable(BIOS_MEMORY_MAP BiosMemoryMap[32], U32 MapCount)
PVOID MmFindLocationForPageLookupTable(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount)
{
U32 TotalPageCount;
U32 PageLookupTableSize;
PVOID PageLookupTableAddress;
PVOID PageLookupTableMemAddress;
int Index;
BIOS_MEMORY_MAP TempBiosMemoryMap[32];
TotalPageCount = MmGetAddressablePageCountIncludingHoles(BiosMemoryMap, MapCount);
PageLookupTableSize = TotalPageCount * sizeof(PAGE_LOOKUP_TABLE_ITEM);
PageLookupTableAddress = 0;
PageLookupTableMemAddress = 0;
RtlCopyMemory(TempBiosMemoryMap, BiosMemoryMap, sizeof(BIOS_MEMORY_MAP) * 32);
MmSortBiosMemoryMap(TempBiosMemoryMap, MapCount);
@ -222,17 +222,17 @@ PVOID MmFindLocationForPageLookupTable(BIOS_MEMORY_MAP BiosMemoryMap[32], U32 Ma
// then we'll put our page lookup table here
if (TempBiosMemoryMap[Index].Type == MEMTYPE_USABLE && TempBiosMemoryMap[Index].Length >= PageLookupTableSize)
{
PageLookupTableAddress = (PVOID)(U32)(TempBiosMemoryMap[Index].BaseAddress + (TempBiosMemoryMap[Index].Length - PageLookupTableSize));
PageLookupTableMemAddress = (PVOID)(U32)(TempBiosMemoryMap[Index].BaseAddress + (TempBiosMemoryMap[Index].Length - PageLookupTableSize));
break;
}
}
DbgPrint((DPRINT_MEMORY, "MmFindLocationForPageLookupTable() returning 0x%x\n", PageLookupTableAddress));
DbgPrint((DPRINT_MEMORY, "MmFindLocationForPageLookupTable() returning 0x%x\n", PageLookupTableMemAddress));
return PageLookupTableAddress;
return PageLookupTableMemAddress;
}
VOID MmSortBiosMemoryMap(BIOS_MEMORY_MAP BiosMemoryMap[32], U32 MapCount)
VOID MmSortBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount)
{
U32 Index;
U32 LoopCount;
@ -254,7 +254,7 @@ VOID MmSortBiosMemoryMap(BIOS_MEMORY_MAP BiosMemoryMap[32], U32 MapCount)
}
}
VOID MmInitPageLookupTable(PVOID PageLookupTable, U32 TotalPageCount, BIOS_MEMORY_MAP BiosMemoryMap[32], U32 MapCount)
VOID MmInitPageLookupTable(PVOID PageLookupTable, U32 TotalPageCount, PBIOS_MEMORY_MAP BiosMemoryMap, U32 MapCount)
{
U32 MemoryMapStartPage;
U32 MemoryMapEndPage;
@ -353,7 +353,7 @@ U32 MmFindAvailablePagesFromEnd(PVOID PageLookupTable, U32 TotalPageCount, U32 P
AvailablePageStart = 0;
AvailablePagesSoFar = 0;
for (Index=LastFreePageHint-1; Index>=0; Index--)
for (Index=LastFreePageHint-1; Index>0; Index--)
{
if (RealPageLookupTable[Index].PageAllocated != 0)
{
@ -374,7 +374,7 @@ U32 MmFindAvailablePagesFromEnd(PVOID PageLookupTable, U32 TotalPageCount, U32 P
return 0;
}
VOID MmFixupSystemMemoryMap(BIOS_MEMORY_MAP BiosMemoryMap[32], U32* MapCount)
VOID MmFixupSystemMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32* MapCount)
{
int Index;
int Index2;
@ -403,7 +403,7 @@ VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, U32 TotalPageCount)
PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable;
U32 Index;
for (Index=TotalPageCount-1; Index>=0; Index--)
for (Index=TotalPageCount-1; Index>0; Index--)
{
if (RealPageLookupTable[Index].PageAllocated == 0)
{

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -22,375 +22,105 @@
#include <ui.h>
#include <options.h>
#include <miscboot.h>
#include <debug.h>
#include <disk.h>
#include <arch.h>
#if 0
void DoOptionsMenu(void)
PUCHAR OptionsMenuList[] =
{
int OptionsMenuItemCount = 1; // Count is 1 because we don't show the "Set ReactOS Boot Flags" menu item yet
char OptionsMenuItems[2][80] = { "Boot Wizard", "Set ReactOS Boot Flags" /* i.e. Safe Mode, Last Known Good Configuration */ };
int OptionsMenuItemSelected = 0;
"Safe Mode",
"Safe Mode with Networking",
"Safe Mode with Command Prompt",
while (OptionsMenuItemSelected != -1)
"SEPARATOR",
"Enable Boot Logging",
"Enable VGA Mode",
"Last Known Good Configuration",
"Directory Services Restore Mode",
"Debugging Mode",
"SEPARATOR",
"Custom Boot",
"Reboot",
};
enum OptionMenuItems
{
OptionsMenuItemSelected = RunOptionsMenu(OptionsMenuItems, OptionsMenuItemCount, OptionsMenuItemSelected, "[Advanced Options]");
SAFE_MODE = 0,
SAFE_MODE_WITH_NETWORKING = 1,
SAFE_MODE_WITH_COMMAND_PROMPT = 2,
switch (OptionsMenuItemSelected)
SEPARATOR1 = 3,
ENABLE_BOOT_LOGGING = 4,
ENABLE_VGA_MODE = 5,
LAST_KNOWN_GOOD_CONFIGURATION = 6,
DIRECTORY_SERVICES_RESTORE_MODE = 7,
DEBUGGING_MODE = 8,
SEPARATOR2 = 9,
CUSTOM_BOOT = 10,
REBOOT = 11,
};
U32 OptionsMenuItemCount = sizeof(OptionsMenuList) / sizeof(OptionsMenuList[0]);
VOID DoOptionsMenu(VOID)
{
case 0:
DoDiskOptionsMenu();
break;
}
}
}
U32 SelectedMenuItem;
void DoDiskOptionsMenu(void)
if (!UiDisplayMenu(OptionsMenuList, OptionsMenuItemCount, 0, -1, &SelectedMenuItem, TRUE, NULL))
{
char DiskMenuItems[25][80];
int DiskMenuItemCount = 0;
int FloppyDiskMenuItemCount = 0;
int HardDiskMenuItemCount = 0;
int DiskMenuItemSelected = 0;
char temp[255];
int i;
FloppyDiskMenuItemCount = (int)*((char *)((0x40 * 16) + 0x10)); // Get number of floppy disks from bios data area 40:10
if (FloppyDiskMenuItemCount & 1)
FloppyDiskMenuItemCount = (FloppyDiskMenuItemCount >> 6) + 1;
else
FloppyDiskMenuItemCount = 0;
HardDiskMenuItemCount = (int)*((char *)((0x40 * 16) + 0x75)); // Get number of hard disks from bios data area 40:75
DiskMenuItemCount = FloppyDiskMenuItemCount + HardDiskMenuItemCount;
for (i=0; i<FloppyDiskMenuItemCount; i++)
{
strcpy(DiskMenuItems[i], "Floppy Disk ");
itoa(i + 1, temp, 10);
strcat(DiskMenuItems[i], temp);
}
for (i=0; i<HardDiskMenuItemCount; i++)
{
strcpy(DiskMenuItems[i + FloppyDiskMenuItemCount], "Hard Disk ");
itoa(i + 1, temp, 10);
strcat(DiskMenuItems[i + FloppyDiskMenuItemCount], temp);
strcat(DiskMenuItems[i + FloppyDiskMenuItemCount], " (");
itoa((get_heads(i+0x80) * get_cylinders(i+0x80) * get_sectors(i+0x80)) / 2048, temp, 10);
strcat(DiskMenuItems[i + FloppyDiskMenuItemCount], temp);
strcat(DiskMenuItems[i + FloppyDiskMenuItemCount], " MB)");
}
DiskMenuItemSelected = 0;
while (DiskMenuItemSelected != -1)
{
DiskMenuItemSelected = RunOptionsMenu(DiskMenuItems, DiskMenuItemCount, DiskMenuItemSelected, "[Boot Wizard]");
if (DiskMenuItemSelected != -1)
{
if (DiskMenuItemSelected < FloppyDiskMenuItemCount)
DoBootOptionsMenu(DiskMenuItemSelected, DiskMenuItems[DiskMenuItemSelected]);
else
DoBootOptionsMenu((DiskMenuItemSelected - FloppyDiskMenuItemCount) + 0x80, DiskMenuItems[DiskMenuItemSelected]);
}
}
}
void DoBootOptionsMenu(int BootDriveNum, char *BootDriveText)
{
int BootOptionsMenuItemCount = 2;
char BootOptionsMenuItems[2][80] = { "Boot To ", "Pick A Boot Partition" };
int BootOptionsMenuItemSelected = 0;
/*strcat(BootOptionsMenuItems[0], BootDriveText);
while (BootOptionsMenuItemSelected != -1)
{
BootOptionsMenuItemSelected = RunOptionsMenu(BootOptionsMenuItems, BootOptionsMenuItemCount, BootOptionsMenuItemSelected, "[Boot Options]");
switch (BootOptionsMenuItemSelected)
{
case 0:
BootDrive = BootDriveNum;
if (!biosdisk(_DISK_READ, BootDrive, 0, 0, 1, 1, (void*)0x7c00))
{
MessageBox("Disk Read Error");
// The user pressed ESC
return;
}
// Check for validity
if (*((U16*)(0x7c00 + 0x1fe)) != 0xaa55)
// Clear the backdrop
UiDrawBackdrop();
switch (SelectedMenuItem)
{
MessageBox("Invalid boot sector magic (0xaa55)");
return;
}
RestoreScreen(ScreenBuffer);
VideoShowTextCursor();
gotoxy(CursorXPos, CursorYPos);
StopFloppyMotor();
JumpToBootCode();
case SAFE_MODE:
break;
case 1:
if (BootDriveNum < 0x80)
{
MessageBox("This option is not available for a floppy disk.");
continue;
}
else
DoBootPartitionOptionsMenu(BootDriveNum);
case SAFE_MODE_WITH_NETWORKING:
break;
}
}*/
}
void DoBootPartitionOptionsMenu(int BootDriveNum)
{
struct
{
int partition_num;
int partition_type;
int head, sector, cylinder;
} BootPartitions[8];
int BootOptionsMenuItemCount = 0;
char BootOptionsMenuItems[8][80];
int BootOptionsMenuItemSelected = 0;
int head, sector, cylinder;
int offset;
int i;
char temp[25];
/*BootDrive = BootDriveNum;
if (!biosdisk(_DISK_READ, BootDrive, 0, 0, 1, 1, SectorBuffer))
{
MessageBox("Disk Read Error");
return;
}
// Check for validity
if (*((U16*)(SectorBuffer + 0x1fe)) != 0xaa55)
{
MessageBox("Invalid partition table magic (0xaa55)");
return;
}
offset = 0x1BE;
for (i=0; i<4; i++)
{
// Check for valid partition
if (SectorBuffer[offset + 4] != 0)
{
BootPartitions[BootOptionsMenuItemCount].partition_num = i;
BootPartitions[BootOptionsMenuItemCount].partition_type = SectorBuffer[offset + 4];
BootPartitions[BootOptionsMenuItemCount].head = SectorBuffer[offset + 1];
BootPartitions[BootOptionsMenuItemCount].sector = (SectorBuffer[offset + 2] & 0x3F);
BootPartitions[BootOptionsMenuItemCount].cylinder = SectorBuffer[offset + 3];
if (SectorBuffer[offset + 2] & 0x80)
BootPartitions[BootOptionsMenuItemCount].cylinder += 0x200;
if (SectorBuffer[offset + 2] & 0x40)
BootPartitions[BootOptionsMenuItemCount].cylinder += 0x100;
strcpy(BootOptionsMenuItems[BootOptionsMenuItemCount], "Boot To Partition ");
itoa(i+1, temp, 10);
strcat(BootOptionsMenuItems[BootOptionsMenuItemCount], temp);
strcat(BootOptionsMenuItems[BootOptionsMenuItemCount], " (Type: 0x");
itoa(BootPartitions[BootOptionsMenuItemCount].partition_type, temp, 16);
if (strlen(temp) < 2)
strcat(BootOptionsMenuItems[BootOptionsMenuItemCount], "0");
strcat(BootOptionsMenuItems[BootOptionsMenuItemCount], temp);
strcat(BootOptionsMenuItems[BootOptionsMenuItemCount], ")");
BootOptionsMenuItemCount++;
}
offset += 0x10;
}
while (BootOptionsMenuItemSelected != -1)
{
BootOptionsMenuItemSelected = RunOptionsMenu(BootOptionsMenuItems, BootOptionsMenuItemCount, BootOptionsMenuItemSelected, "[Boot Partition Options]");
if (BootOptionsMenuItemSelected != -1)
{
head = BootPartitions[BootOptionsMenuItemCount].head;
sector = BootPartitions[BootOptionsMenuItemCount].sector;
cylinder = BootPartitions[BootOptionsMenuItemCount].cylinder;
// Read partition boot sector
if (!biosdisk(_DISK_READ, BootDrive, head, cylinder, sector, 1, (void*)0x7c00))
{
MessageBox("Disk Read Error");
return;
}
// Check for validity
if (*((U16*)(0x7c00 + 0x1fe)) != 0xaa55)
{
MessageBox("Invalid boot sector magic (0xaa55)");
return;
}
RestoreScreen(ScreenBuffer);
VideoShowTextCursor();
gotoxy(CursorXPos, CursorYPos);
StopFloppyMotor();
JumpToBootCode();
}
}*/
}
int RunOptionsMenu(char OptionsMenuItems[][80], int OptionsMenuItemCount, int nOptionSelected, char *OptionsMenuTitle)
{
int key;
int second;
BOOL bDone = FALSE;
int nOptionsMenuBoxLeft;
int nOptionsMenuBoxRight;
int nOptionsMenuBoxTop;
int nOptionsMenuBoxBottom;
// Initialise the menu
InitOptionsMenu(&nOptionsMenuBoxLeft, &nOptionsMenuBoxTop, &nOptionsMenuBoxRight, &nOptionsMenuBoxBottom, OptionsMenuItemCount);
DrawBackdrop();
// Update the menu
DrawOptionsMenu(OptionsMenuItems, OptionsMenuItemCount, nOptionSelected, OptionsMenuTitle, nOptionsMenuBoxLeft, nOptionsMenuBoxTop, nOptionsMenuBoxRight, nOptionsMenuBoxBottom);
second = getsecond();
// Loop
do
{
// Check for a keypress
if (kbhit())
{
// Cancel the timeout
if (nTimeOut != -1)
{
nTimeOut = -1;
DrawOptionsMenu(OptionsMenuItems, OptionsMenuItemCount, nOptionSelected, OptionsMenuTitle, nOptionsMenuBoxLeft, nOptionsMenuBoxTop, nOptionsMenuBoxRight, nOptionsMenuBoxBottom);
}
// Get the key
key = getch();
// Is it extended?
if (key == 0)
key = getch(); // Yes - so get the extended key
// Process the key
switch (key)
{
case KEY_UP:
if (nOptionSelected)
{
nOptionSelected--;
// Update the menu
DrawOptionsMenu(OptionsMenuItems, OptionsMenuItemCount, nOptionSelected, OptionsMenuTitle, nOptionsMenuBoxLeft, nOptionsMenuBoxTop, nOptionsMenuBoxRight, nOptionsMenuBoxBottom);
}
case SAFE_MODE_WITH_COMMAND_PROMPT:
break;
case KEY_DOWN:
if (nOptionSelected < (OptionsMenuItemCount - 1))
{
nOptionSelected++;
// Update the menu
DrawOptionsMenu(OptionsMenuItems, OptionsMenuItemCount, nOptionSelected, OptionsMenuTitle, nOptionsMenuBoxLeft, nOptionsMenuBoxTop, nOptionsMenuBoxRight, nOptionsMenuBoxBottom);
}
//case SEPARATOR1:
// break;
case ENABLE_BOOT_LOGGING:
break;
case KEY_ENTER:
//MessageBox("The Advanced Options are still being implemented.");
bDone = TRUE;
case ENABLE_VGA_MODE:
break;
case KEY_ESC:
nOptionSelected = -1;
bDone = TRUE;
case LAST_KNOWN_GOOD_CONFIGURATION:
break;
case DIRECTORY_SERVICES_RESTORE_MODE:
break;
case DEBUGGING_MODE:
break;
//case SEPARATOR2:
// break;
case CUSTOM_BOOT:
OptionMenuCustomBoot();
break;
case REBOOT:
OptionMenuReboot();
break;
}
}
// Update the date & time
UpdateDateTime();
if (nTimeOut > 0)
VOID OptionMenuReboot(VOID)
{
if (getsecond() != second)
{
second = getsecond();
nTimeOut--;
UiMessageBox("The system will now reboot.");
// Update the menu
DrawOptionsMenu(OptionsMenuItems, OptionsMenuItemCount, nOptionSelected, OptionsMenuTitle, nOptionsMenuBoxLeft, nOptionsMenuBoxTop, nOptionsMenuBoxRight, nOptionsMenuBoxBottom);
}
}
if (nTimeOut == 0)
bDone = TRUE;
}
while (!bDone);
return nOptionSelected;
}
void InitOptionsMenu(int *nOptionsMenuBoxLeft, int *nOptionsMenuBoxTop, int *nOptionsMenuBoxRight, int *nOptionsMenuBoxBottom, int OptionsMenuItemCount)
{
/*int height = OptionsMenuItemCount;
int width = 20;
height += 1; // Allow room for top & bottom borders
width += 18; // Allow room for left & right borders, plus 8 spaces on each side
// Calculate the OS list box area
*nOptionsMenuBoxLeft = (nScreenWidth - width) / 2;
*nOptionsMenuBoxRight = *nOptionsMenuBoxLeft + width;
*nOptionsMenuBoxTop = (nScreenHeight - height) / 2 + 1;
*nOptionsMenuBoxBottom = *nOptionsMenuBoxTop + height;*/
}
void DrawOptionsMenu(char OptionsMenuItems[][80], int OptionsMenuItemCount, int nOptionSelected, char *OptionsMenuTitle, int nOptionsMenuBoxLeft, int nOptionsMenuBoxTop, int nOptionsMenuBoxRight, int nOptionsMenuBoxBottom)
{
int i, j;
char text[260];
int space, space_left, space_right;
// Update the status bar
/*DrawStatusText("Use \x18\x19 to select, then press ENTER. Press ESC to go back.");
DrawBox(nOptionsMenuBoxLeft, nOptionsMenuBoxTop, nOptionsMenuBoxRight, nOptionsMenuBoxBottom, D_VERT, D_HORZ, TRUE, TRUE, ATTR(cMenuFgColor, cMenuBgColor));
DrawText(nOptionsMenuBoxLeft + (((nOptionsMenuBoxRight - nOptionsMenuBoxLeft) - strlen(OptionsMenuTitle)) / 2) + 1, nOptionsMenuBoxTop, OptionsMenuTitle, ATTR(cMenuFgColor, cMenuBgColor));
for(i=0; i<OptionsMenuItemCount; i++)
{
space = (nOptionsMenuBoxRight - nOptionsMenuBoxLeft - 2) - strlen(OptionsMenuItems[i]);
space_left = (space / 2) + 1;
space_right = (space - space_left) + 1;
text[0] = '\0';
for(j=0; j<space_left; j++)
strcat(text, " ");
strcat(text, OptionsMenuItems[i]);
for(j=0; j<space_right; j++)
strcat(text, " ");
if(i == nOptionSelected)
{
DrawText(nOptionsMenuBoxLeft+1, nOptionsMenuBoxTop+1+i, text, ATTR(cSelectedTextColor, cSelectedTextBgColor));
}
else
{
DrawText(nOptionsMenuBoxLeft+1, nOptionsMenuBoxTop+1+i, text, ATTR(cTextColor, cMenuBgColor));
}
}*/
}
#ifdef __i386__
DiskStopFloppyMotor();
SoftReboot();
#else
UNIMPLEMENTED();
#endif
}

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -40,9 +40,9 @@ BOOL InitOperatingSystemList(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNames
//
// Open the [FreeLoader] section
//
if (!IniOpenSection("FreeLoader", &SectionId))
if (!IniOpenSection("Operating Systems", &SectionId))
{
UiMessageBox("Section [FreeLoader] not found in freeldr.ini.");
UiMessageBox("Section [Operating Systems] not found in freeldr.ini.");
return FALSE;
}
@ -58,45 +58,26 @@ BOOL InitOperatingSystemList(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNames
}
//
// Now loop through and read the operating system section names
// Now loop through and read the operating system section and display names
//
CurrentOperatingSystemIndex = 0;
for (Idx=0; Idx<SectionSettingCount; Idx++)
{
IniReadSettingByNumber(SectionId, Idx, SettingName, 260, SettingValue, 260);
if (stricmp(SettingName, "OS") == 0 && IniOpenSection(SettingValue, &OperatingSystemSectionId))
if (IniOpenSection(SettingName, &OperatingSystemSectionId))
{
strcpy(OperatingSystemSectionNames[CurrentOperatingSystemIndex], SettingValue);
// Copy the section name
strcpy(OperatingSystemSectionNames[CurrentOperatingSystemIndex], SettingName);
// Copy the display name
RemoveQuotes(SettingValue);
strcpy(OperatingSystemDisplayNames[CurrentOperatingSystemIndex], SettingValue);
CurrentOperatingSystemIndex++;
}
}
//
// Now loop through and read the operating system display names
//
for (Idx=0; Idx<OperatingSystemCount; Idx++)
{
if (IniOpenSection(OperatingSystemSectionNames[Idx], &OperatingSystemSectionId))
{
if (IniReadSettingByName(OperatingSystemSectionId, "Name", SettingValue, 260))
{
//
// Remove any quotes around the string
//
RemoveQuotes(SettingValue);
strcpy(OperatingSystemDisplayNames[Idx], SettingValue);
}
else
{
sprintf(SettingName, "Operating System '%s' has no\nName= line in it's [section].", OperatingSystemSectionNames[Idx]);
UiMessageBox(SettingName);
strcpy(OperatingSystemDisplayNames[Idx], "");
}
}
}
*OperatingSystemCountPointer = OperatingSystemCount;
*SectionNamesPointer = OperatingSystemSectionNames;
*DisplayNamesPointer = OperatingSystemDisplayNames;
@ -120,9 +101,7 @@ U32 CountOperatingSystems(U32 SectionId)
{
IniReadSettingByNumber(SectionId, Idx, SettingName, 260, SettingValue, 260);
if (stricmp(SettingName, "OS") == 0)
{
if (IniOpenSection(SettingValue, NULL))
if (IniOpenSection(SettingName, NULL))
{
OperatingSystemCount++;
}
@ -132,7 +111,6 @@ U32 CountOperatingSystems(U32 SectionId)
UiMessageBox(SettingName);
}
}
}
return OperatingSystemCount;
}

View file

@ -72,3 +72,70 @@ BOOL DissectArcPath(char *ArcPath, char *BootPath, U32* BootDrive, U32* BootPart
return TRUE;
}
void ConstructArcPath(PUCHAR ArcPath, PUCHAR SystemFolder, U32 Disk, U32 Partition)
{
char tmp[50];
strcpy(ArcPath, "multi(0)disk(0)");
if (Disk < 0x80)
{
/*
* floppy disk path:
* multi(0)disk(0)fdisk(x)\path
*/
sprintf(tmp, "fdisk(%d)", Disk);
strcat(ArcPath, tmp);
}
else
{
/*
* hard disk path:
* multi(0)disk(0)rdisk(x)partition(y)\path
*/
sprintf(tmp, "rdisk(%d)partition(%d)", (Disk - 0x80), Partition);
strcat(ArcPath, tmp);
}
if (SystemFolder[0] == '\\' || SystemFolder[0] == '/')
{
strcat(ArcPath, SystemFolder);
}
else
{
strcat(ArcPath, "\\");
strcat(ArcPath, SystemFolder);
}
}
U32 ConvertArcNameToBiosDriveNumber(PUCHAR ArcPath)
{
char * p;
U32 DriveNumber = 0;
if (strnicmp(ArcPath, "multi(0)disk(0)", 15) != 0)
return 0;
p = ArcPath + 15;
if (strnicmp(p, "fdisk(", 6) == 0)
{
/*
* floppy disk path:
* multi(0)disk(0)fdisk(x)\path
*/
p = p + 6;
DriveNumber = atoi(p);
}
else if (strnicmp(p, "rdisk(", 6) == 0)
{
/*
* hard disk path:
* multi(0)disk(0)rdisk(x)partition(y)\path
*/
p = p + 6;
DriveNumber = atoi(p) + 0x80;
}
return DriveNumber;
}

View file

@ -1,7 +1,7 @@
/*
* FreeLoader
*
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,7 +1,7 @@
/*
* FreeLoader
*
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,7 +1,7 @@
/*
* FreeLoader
*
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -45,6 +45,8 @@ char *strncpy(char *dest, char *src, size_t count)
while((*src) && (count--))
*dest++ = *src++;
if (count)
*dest = 0;
return ret;

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -111,7 +111,7 @@ VOID TuiDrawBackdrop(VOID)
//
// Draw help text
//
//TuiDrawText(UiScreenWidth - 16, 3, /*"F1 for Help"*/"F8 for Options", ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor));
TuiDrawText(UiScreenWidth - 16, 3, /*"F1 for Help"*/"F8 for Options", ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor));
//
// Draw title text
@ -477,8 +477,6 @@ VOID TuiUpdateDateTime(VOID)
// Draw the time
TuiDrawText(UiScreenWidth-strlen(TimeString)-2, 2, TimeString, ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor));
VideoCopyOffScreenBufferToVRAM();
}
VOID TuiSaveScreen(PUCHAR Buffer)
@ -769,3 +767,167 @@ VOID TuiFadeOut(VOID)
}
}
BOOL TuiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, U32 Length)
{
int width = 8;
int height = 1;
int curline = 0;
int i , j, k;
int x1, x2, y1, y2;
char temp[260];
char key;
int EditBoxLine;
int EditBoxStartX, EditBoxEndX;
int EditBoxCursorX;
int EditBoxTextCount;
int EditBoxTextDisplayIndex;
BOOL ReturnCode;
PVOID ScreenBuffer;
// Save the screen contents
ScreenBuffer = MmAllocateMemory(UiScreenWidth * UiScreenHeight * 2);
TuiSaveScreen(ScreenBuffer);
// Find the height
for (i=0; i<strlen(MessageText); i++)
{
if (MessageText[i] == '\n')
height++;
}
// Find the width
for (i=0,j=0,k=0; i<height; i++)
{
while ((MessageText[j] != '\n') && (MessageText[j] != 0))
{
j++;
k++;
}
if (k > width)
width = k;
k = 0;
j++;
}
// Calculate box area
x1 = (UiScreenWidth - (width+2))/2;
x2 = x1 + width + 3;
y1 = ((UiScreenHeight - height - 2)/2) + 1;
y2 = y1 + height + 4;
// Draw the box
TuiDrawBox(x1, y1, x2, y2, D_VERT, D_HORZ, TRUE, TRUE, ATTR(UiMessageBoxFgColor, UiMessageBoxBgColor));
// Draw the text
for (i=0,j=0; i<strlen(MessageText)+1; i++)
{
if ((MessageText[i] == '\n') || (MessageText[i] == 0))
{
temp[j] = 0;
j = 0;
UiDrawText(x1+2, y1+1+curline, temp, ATTR(UiMessageBoxFgColor, UiMessageBoxBgColor));
curline++;
}
else
temp[j++] = MessageText[i];
}
EditBoxTextCount = 0;
EditBoxLine = y2 - 2;
EditBoxStartX = x1 + 3;
EditBoxEndX = x2 - 3;
UiFillArea(EditBoxStartX, EditBoxLine, EditBoxEndX, EditBoxLine, ' ', ATTR(UiEditBoxTextColor, UiEditBoxBgColor));
// Show the cursor
EditBoxCursorX = EditBoxStartX;
VideoSetTextCursorPosition(EditBoxCursorX, EditBoxLine);
VideoShowTextCursor();
// Draw status text
UiDrawStatusText("Press ENTER to continue, or ESC to cancel");
VideoCopyOffScreenBufferToVRAM();
for (;;)
{
if (kbhit())
{
key = getch();
if(key == KEY_EXTENDED)
{
key = getch();
}
if(key == KEY_ENTER)
{
ReturnCode = TRUE;
break;
}
else if(key == KEY_ESC)
{
ReturnCode = FALSE;
break;
}
else if (key == KEY_BACKSPACE) // Remove a character
{
if (EditBoxTextCount)
{
EditBoxTextCount--;
EditTextBuffer[EditBoxTextCount] = 0;
}
else
{
beep();
}
}
else // Add this key to the buffer
{
if (EditBoxTextCount < Length - 1)
{
EditTextBuffer[EditBoxTextCount] = key;
EditBoxTextCount++;
EditTextBuffer[EditBoxTextCount] = 0;
}
else
{
beep();
}
}
}
// Draw the edit box background
UiFillArea(EditBoxStartX, EditBoxLine, EditBoxEndX, EditBoxLine, ' ', ATTR(UiEditBoxTextColor, UiEditBoxBgColor));
// Fill the text in
if (EditBoxTextCount > (EditBoxEndX - EditBoxStartX))
{
EditBoxTextDisplayIndex = EditBoxTextCount - (EditBoxEndX - EditBoxStartX);
EditBoxCursorX = EditBoxEndX;
}
else
{
EditBoxTextDisplayIndex = 0;
EditBoxCursorX = EditBoxStartX + EditBoxTextCount;
}
UiDrawText(EditBoxStartX, EditBoxLine, &EditTextBuffer[EditBoxTextDisplayIndex], ATTR(UiEditBoxTextColor, UiEditBoxBgColor));
// Move the cursor
VideoSetTextCursorPosition(EditBoxCursorX, EditBoxLine);
TuiUpdateDateTime();
VideoCopyOffScreenBufferToVRAM();
}
// Hide the cursor again
VideoHideTextCursor();
// Restore the screen contents
TuiRestoreScreen(ScreenBuffer);
MmFreeMemory(ScreenBuffer);
return ReturnCode;
}

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -45,6 +45,7 @@ VOID TuiMessageBox(PUCHAR MessageText); // Displays a message box on the sc
VOID TuiMessageBoxCritical(PUCHAR MessageText); // Displays a message box on the screen with an ok button using no system resources
VOID TuiDrawProgressBarCenter(U32 Position, U32 Range, PUCHAR ProgressText); // Draws the progress bar showing nPos percent filled
VOID TuiDrawProgressBar(U32 Left, U32 Top, U32 Right, U32 Bottom, U32 Position, U32 Range, PUCHAR ProgressText); // Draws the progress bar showing nPos percent filled
BOOL TuiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, U32 Length);
UCHAR TuiTextToColor(PUCHAR ColorText); // Converts the text color into it's equivalent color value
UCHAR TuiTextToFillStyle(PUCHAR FillStyleText); // Converts the text fill into it's equivalent fill value
@ -76,8 +77,8 @@ VOID TuiCalcMenuBoxSize(PTUI_MENU_INFO MenuInfo);
VOID TuiDrawMenu(PTUI_MENU_INFO MenuInfo);
VOID TuiDrawMenuBox(PTUI_MENU_INFO MenuInfo);
VOID TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo, U32 MenuItemNumber);
U32 TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo);
BOOL TuiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem, S32 MenuTimeOut, U32* SelectedMenuItem);
U32 TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo, UiMenuKeyPressFilterCallback KeyPressFilter);
BOOL TuiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem, S32 MenuTimeOut, U32* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter);
/*

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -27,10 +27,11 @@
#include <video.h>
BOOL TuiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem, S32 MenuTimeOut, U32* SelectedMenuItem)
BOOL TuiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem, S32 MenuTimeOut, U32* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter)
{
TUI_MENU_INFO MenuInformation;
U32 CurrentClockSecond;
U32 KeyPress;
//
// The first thing we need to check is the timeout
@ -78,13 +79,21 @@ BOOL TuiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuIte
//
// Process key presses
//
if (TuiProcessMenuKeyboardEvent(&MenuInformation) == KEY_ENTER)
KeyPress = TuiProcessMenuKeyboardEvent(&MenuInformation, KeyPressFilter);
if (KeyPress == KEY_ENTER)
{
//
// If they pressed enter then exit this loop
//
break;
}
else if (CanEscape && KeyPress == KEY_ESC)
{
//
// They pressed escape, so just return FALSE
//
return FALSE;
}
//
// Update the date & time
@ -168,7 +177,7 @@ VOID TuiCalcMenuBoxSize(PTUI_MENU_INFO MenuInfo)
//
MenuInfo->Left = (UiScreenWidth - Width) / 2;
MenuInfo->Right = (MenuInfo->Left) + Width;
MenuInfo->Top = (( (UiScreenHeight - TUI_TITLE_BOX_CHAR_HEIGHT) - Height) / 2 + 1) + (TUI_TITLE_BOX_CHAR_HEIGHT / 2);
MenuInfo->Top = (((UiScreenHeight - TUI_TITLE_BOX_CHAR_HEIGHT) - Height) / 2) + TUI_TITLE_BOX_CHAR_HEIGHT;
MenuInfo->Bottom = (MenuInfo->Top) + Height;
}
@ -176,6 +185,16 @@ VOID TuiDrawMenu(PTUI_MENU_INFO MenuInfo)
{
U32 Idx;
//
// Draw the backdrop
//
UiDrawBackdrop();
//
// Update the status bar
//
UiDrawStatusText("Use \x18\x19 to select, then press ENTER.");
//
// Draw the menu box
//
@ -196,11 +215,7 @@ VOID TuiDrawMenuBox(PTUI_MENU_INFO MenuInfo)
{
UCHAR MenuLineText[80];
UCHAR TempString[80];
//
// Update the status bar
//
UiDrawStatusText("Use \x18\x19 to select, ENTER to boot.");
U32 Idx;
//
// Draw the menu box
@ -230,6 +245,18 @@ VOID TuiDrawMenuBox(PTUI_MENU_INFO MenuInfo)
MenuLineText,
ATTR(UiMenuFgColor, UiMenuBgColor));
}
//
// Now draw the separators
//
for (Idx=0; Idx<MenuInfo->MenuItemCount; Idx++)
{
if (stricmp(MenuInfo->MenuItemList[Idx], "SEPARATOR") == 0)
{
UiDrawText(MenuInfo->Left, MenuInfo->Top + Idx + 1, "\xC7", ATTR(UiMenuFgColor, UiMenuBgColor));
UiDrawText(MenuInfo->Right, MenuInfo->Top + Idx + 1, "\xB6", ATTR(UiMenuFgColor, UiMenuBgColor));
}
}
}
VOID TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo, U32 MenuItemNumber)
@ -239,6 +266,7 @@ VOID TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo, U32 MenuItemNumber)
U32 SpaceTotal;
U32 SpaceLeft;
U32 SpaceRight;
UCHAR Attribute;
//
// We will want the string centered so calculate
@ -270,6 +298,20 @@ VOID TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo, U32 MenuItemNumber)
strcat(MenuLineText, " ");
}
//
// If it is a separator then adjust the text accordingly
//
if (stricmp(MenuInfo->MenuItemList[MenuItemNumber], "SEPARATOR") == 0)
{
memset(MenuLineText, 0, 80);
memset(MenuLineText, 0xC4, (MenuInfo->Right - MenuInfo->Left - 1));
Attribute = ATTR(UiMenuFgColor, UiMenuBgColor);
}
else
{
Attribute = ATTR(UiTextColor, UiMenuBgColor);
}
//
// If this is the selected menu item then draw it as selected
// otherwise just draw it using the normal colors
@ -286,11 +328,11 @@ VOID TuiDrawMenuItem(PTUI_MENU_INFO MenuInfo, U32 MenuItemNumber)
UiDrawText(MenuInfo->Left + 1,
MenuInfo->Top + 1 + MenuItemNumber,
MenuLineText,
ATTR(UiTextColor, UiMenuBgColor));
Attribute);
}
}
U32 TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo)
U32 TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo, UiMenuKeyPressFilterCallback KeyPressFilter)
{
U32 KeyEvent = 0;
@ -319,6 +361,21 @@ U32 TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo)
if (KeyEvent == 0)
KeyEvent = getch(); // Yes - so get the extended key
//
// Call the supplied key filter callback function to see
// if it is going to handle this keypress.
//
if (KeyPressFilter != NULL)
{
if (KeyPressFilter(KeyEvent))
{
// It processed the key character
TuiDrawMenu(MenuInfo);
return 0;
}
}
//
// Process the key
//
@ -334,6 +391,13 @@ U32 TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo)
// Update the menu
//
TuiDrawMenuItem(MenuInfo, MenuInfo->SelectedMenuItem + 1); // Deselect previous item
// Skip past any separators
if (MenuInfo->SelectedMenuItem > 0 && stricmp(MenuInfo->MenuItemList[MenuInfo->SelectedMenuItem], "SEPARATOR") == 0)
{
MenuInfo->SelectedMenuItem--;
}
TuiDrawMenuItem(MenuInfo, MenuInfo->SelectedMenuItem); // Select new item
}
@ -349,6 +413,13 @@ U32 TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo)
// Update the menu
//
TuiDrawMenuItem(MenuInfo, MenuInfo->SelectedMenuItem - 1); // Deselect previous item
// Skip past any separators
if (MenuInfo->SelectedMenuItem < (MenuInfo->MenuItemCount - 1) && stricmp(MenuInfo->MenuItemList[MenuInfo->SelectedMenuItem], "SEPARATOR") == 0)
{
MenuInfo->SelectedMenuItem++;
}
TuiDrawMenuItem(MenuInfo, MenuInfo->SelectedMenuItem); // Select new item
}

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -48,10 +48,10 @@ UCHAR UiMenuBgColor = COLOR_BLUE; // Menu background color
UCHAR UiTextColor = COLOR_YELLOW; // Normal text color
UCHAR UiSelectedTextColor = COLOR_BLACK; // Selected text color
UCHAR UiSelectedTextBgColor = COLOR_GRAY; // Selected text background color
UCHAR UiTitleBoxTitleText[260] = "Boot Menu"; // Title box's title text
UCHAR UiEditBoxTextColor = COLOR_WHITE; // Edit box text color
UCHAR UiEditBoxBgColor = COLOR_BLACK; // Edit box text background color
PUCHAR UiMessageBoxLineText = NULL;
#define UIMESSAGEBOXLINETEXTSIZE 4096
UCHAR UiTitleBoxTitleText[260] = "Boot Menu"; // Title box's title text
BOOL UserInterfaceUp = FALSE; // Tells us if the user interface is displayed
@ -70,15 +70,6 @@ BOOL UiInitialize(VOID)
DbgPrint((DPRINT_UI, "Initializing User Interface.\n"));
UiMessageBoxLineText = MmAllocateMemory(UIMESSAGEBOXLINETEXTSIZE);
if (UiMessageBoxLineText == NULL)
{
return FALSE;
}
RtlZeroMemory(UiMessageBoxLineText, UIMESSAGEBOXLINETEXTSIZE);
DbgPrint((DPRINT_UI, "Reading in UI settings from [Display] section.\n"));
if (IniOpenSection("Display", &SectionId))
@ -192,6 +183,14 @@ BOOL UiInitialize(VOID)
{
UiSelectedTextBgColor = UiTextToColor(SettingText);
}
if (IniReadSettingByName(SectionId, "EditBoxTextColor", SettingText, 260))
{
UiEditBoxTextColor = UiTextToColor(SettingText);
}
if (IniReadSettingByName(SectionId, "EditBoxColor", SettingText, 260))
{
UiEditBoxBgColor = UiTextToColor(SettingText);
}
if (IniReadSettingByName(SectionId, "SpecialEffects", SettingText, 260))
{
if (stricmp(SettingText, "Yes") == 0 && strlen(SettingText) == 3)
@ -429,19 +428,15 @@ VOID UiMessageBox(PUCHAR MessageText)
return;
}
strcat(UiMessageBoxLineText, MessageText);
if (UiDisplayMode == DISPLAYMODE_TEXT)
{
TuiMessageBox(UiMessageBoxLineText);
TuiMessageBox(MessageText);
}
else
{
UNIMPLEMENTED();
//GuiMessageBox(UiMessageBoxLineText);
//GuiMessageBox(MessageText);
}
RtlZeroMemory(UiMessageBoxLineText, UIMESSAGEBOXLINETEXTSIZE);
}
VOID UiMessageBoxCritical(PUCHAR MessageText)
@ -469,12 +464,6 @@ VOID UiMessageBoxCritical(PUCHAR MessageText)
}
}
VOID UiMessageLine(PUCHAR MessageText)
{
strcat(UiMessageBoxLineText, MessageText);
strcat(UiMessageBoxLineText, "\n");
}
UCHAR UiTextToColor(PUCHAR ColorText)
{
if (UiDisplayMode == DISPLAYMODE_TEXT)
@ -534,13 +523,10 @@ VOID UiShowMessageBoxesInSection(PUCHAR SectionName)
U32 Idx;
UCHAR SettingName[80];
UCHAR SettingValue[80];
PUCHAR MessageBoxText;
U32 MessageBoxTextSize;
U32 SectionId;
//
// Zero out message line text
//
strcpy(UiMessageBoxLineText, "");
if (!IniOpenSection(SectionName, &SectionId))
{
sprintf(SettingName, "Section %s not found in freeldr.ini.\n", SectionName);
@ -553,22 +539,53 @@ VOID UiShowMessageBoxesInSection(PUCHAR SectionName)
//
for (Idx=0; Idx<IniGetNumSectionItems(SectionId); Idx++)
{
IniReadSettingByNumber(SectionId, Idx, SettingName, 80, SettingValue, 80);
IniReadSettingByNumber(SectionId, Idx, SettingName, 79, SettingValue, 79);
if (stricmp(SettingName, "MessageBox") == 0)
{
UiMessageBox(SettingValue);
}
else if (stricmp(SettingName, "MessageLine") == 0)
// Get the real length of the MessageBox text
MessageBoxTextSize = IniGetSectionSettingValueSize(SectionId, Idx);
//if (MessageBoxTextSize > 0)
{
UiMessageLine(SettingValue);
// Allocate enough memory to hold the text
MessageBoxText = (PUCHAR)MmAllocateMemory(MessageBoxTextSize);
if (MessageBoxText)
{
// Get the MessageBox text
IniReadSettingByNumber(SectionId, Idx, SettingName, 80, MessageBoxText, MessageBoxTextSize);
// Fix it up
UiEscapeString(MessageBoxText);
// Display it
UiMessageBox(MessageBoxText);
// Free the memory
MmFreeMemory(MessageBoxText);
}
}
}
}
}
//
// Zero out message line text
//
strcpy(UiMessageBoxLineText, "");
VOID UiEscapeString(PUCHAR String)
{
U32 Idx;
for (Idx=0; Idx<strlen(String); Idx++)
{
// Escape the new line characters
if (String[Idx] == '\\' && String[Idx+1] == 'n')
{
// Escape the character
String[Idx] = '\n';
// Move the rest of the string up
strcpy(&String[Idx+1], &String[Idx+2]);
}
}
}
VOID UiTruncateStringEllipsis(PUCHAR StringText, U32 MaxChars)
@ -579,17 +596,17 @@ VOID UiTruncateStringEllipsis(PUCHAR StringText, U32 MaxChars)
}
}
BOOL UiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem, S32 MenuTimeOut, U32* SelectedMenuItem)
BOOL UiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem, S32 MenuTimeOut, U32* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter)
{
if (UiDisplayMode == DISPLAYMODE_TEXT)
{
return TuiDisplayMenu(MenuItemList, MenuItemCount, DefaultMenuItem, MenuTimeOut, SelectedMenuItem);
return TuiDisplayMenu(MenuItemList, MenuItemCount, DefaultMenuItem, MenuTimeOut, SelectedMenuItem, CanEscape, KeyPressFilter);
}
else
{
UNIMPLEMENTED();
return FALSE;
//return GuiDisplayMenu(MenuItemList, MenuItemCount, DefaultMenuItem, MenuTimeOut, SelectedMenuItem);
//return GuiDisplayMenu(MenuItemList, MenuItemCount, DefaultMenuItem, MenuTimeOut, SelectedMenuItem, CanEscape, KeyPressFilter);
}
}
@ -618,3 +635,17 @@ VOID UiFadeOut(VOID)
//GuiFadeInOut();
}
}
BOOL UiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, U32 Length)
{
if (UiDisplayMode == DISPLAYMODE_TEXT)
{
return TuiEditBox(MessageText, EditTextBuffer, Length);
}
else
{
UNIMPLEMENTED();
return FALSE;
//return GuiEditBox(MessageText, EditTextBuffer, Length);
}
}

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -19,7 +19,7 @@
#include <freeldr.h>
#include <video.h>
#include <comm.h>
#include <portio.h>
#define RGB_MAX 64

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -19,7 +19,7 @@
#include <freeldr.h>
#include <video.h>
#include <comm.h>
#include <portio.h>
VOID VideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue)

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -19,7 +19,7 @@
#include <freeldr.h>
#include <video.h>
#include <comm.h>
#include <portio.h>
#include <debug.h>

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -19,7 +19,7 @@
#include <freeldr.h>
#include <video.h>
#include <comm.h>
#include <portio.h>
#include <mm.h>

View file

@ -1,6 +1,6 @@
/*
* FreeLoader
* Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
*
* 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
@ -20,7 +20,7 @@
#include <freeldr.h>
#include <video.h>
#include <debug.h>
#include <comm.h>
#include <portio.h>
U32 CurrentVideoMode = VIDEOMODE_NORMAL_TEXT;
U32 VideoResolutionX = 80;