From 59f1842f56fcd8607f9f51802a7bc5f898507162 Mon Sep 17 00:00:00 2001 From: Brian Palmer Date: Sun, 19 Jan 2003 01:04:01 +0000 Subject: [PATCH] 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 --- freeldr/freeldr/arch/i386/boot.S | 16 + freeldr/freeldr/arch/i386/i386disk.c | 4 +- freeldr/freeldr/arch/i386/i386mem.c | 4 +- freeldr/freeldr/arch/i386/i386rtl.c | 72 +++- freeldr/freeldr/arch/i386/i386vid.c | 6 +- freeldr/freeldr/{comm => arch/i386}/portio.c | 2 +- freeldr/freeldr/cache/blocklist.c | 2 +- freeldr/freeldr/cache/cache.c | 2 +- freeldr/freeldr/cache/cm.h | 2 +- freeldr/freeldr/comm/rs232.c | 1 + freeldr/freeldr/disk/disk.c | 41 +- freeldr/freeldr/disk/geometry.c | 2 +- freeldr/freeldr/disk/partition.c | 2 +- freeldr/freeldr/freeldr.c | 4 +- freeldr/freeldr/fs/ext2.c | 2 +- freeldr/freeldr/fs/ext2.h | 2 +- freeldr/freeldr/fs/fat.c | 2 +- freeldr/freeldr/fs/fat.h | 2 +- freeldr/freeldr/fs/fs.c | 2 +- freeldr/freeldr/fs/iso.c | 2 +- freeldr/freeldr/fs/iso.h | 2 +- freeldr/freeldr/include/arch.h | 5 +- freeldr/freeldr/include/bootmgr.h | 3 +- freeldr/freeldr/include/cache.h | 2 +- freeldr/freeldr/include/comm.h | 53 --- freeldr/freeldr/include/debug.h | 2 +- freeldr/freeldr/include/disk.h | 3 +- freeldr/freeldr/include/drivemap.h | 2 +- freeldr/freeldr/include/freeldr.h | 2 +- freeldr/freeldr/include/fs.h | 2 +- freeldr/freeldr/include/inifile.h | 6 +- freeldr/freeldr/{ui => include}/keycodes.h | 3 +- freeldr/freeldr/include/linux.h | 6 +- freeldr/freeldr/include/miscboot.h | 4 +- freeldr/freeldr/include/mm.h | 2 +- freeldr/freeldr/include/options.h | 19 +- freeldr/freeldr/include/oslist.h | 2 +- freeldr/freeldr/include/portio.h | 78 ++++ freeldr/freeldr/include/reactos.h | 6 +- freeldr/freeldr/include/rtl.h | 6 +- freeldr/freeldr/include/ui.h | 14 +- freeldr/freeldr/include/version.h | 10 +- freeldr/freeldr/include/video.h | 2 +- freeldr/freeldr/inifile/ini.h | 5 +- freeldr/freeldr/inifile/ini_init.c | 2 +- freeldr/freeldr/inifile/inifile.c | 119 +++++- freeldr/freeldr/inifile/parse.c | 5 +- freeldr/freeldr/linuxboot.c | 34 +- freeldr/freeldr/miscboot.c | 9 +- freeldr/freeldr/mm/mem.h | 14 +- freeldr/freeldr/mm/meminit.c | 28 +- freeldr/freeldr/mm/mm.c | 2 +- freeldr/freeldr/multiboot.c | 2 +- freeldr/freeldr/options.c | 426 ++++--------------- freeldr/freeldr/oslist.c | 58 +-- freeldr/freeldr/reactos/arcname.c | 67 +++ freeldr/freeldr/reactos/hwdetect.h | 2 +- freeldr/freeldr/reactos/reactos.c | 2 +- freeldr/freeldr/reactos/setupldr.c | 2 +- freeldr/freeldr/rtl/list.c | 2 +- freeldr/freeldr/rtl/memcmp.c | 2 +- freeldr/freeldr/rtl/memcpy.c | 2 +- freeldr/freeldr/rtl/memset.c | 2 +- freeldr/freeldr/rtl/print.c | 2 +- freeldr/freeldr/rtl/stdlib.c | 2 +- freeldr/freeldr/rtl/string.c | 6 +- freeldr/freeldr/ui/gui.c | 2 +- freeldr/freeldr/ui/gui.h | 2 +- freeldr/freeldr/ui/tui.c | 170 +++++++- freeldr/freeldr/ui/tui.h | 7 +- freeldr/freeldr/ui/tuimenu.c | 93 +++- freeldr/freeldr/ui/ui.c | 117 +++-- freeldr/freeldr/version.c | 2 +- freeldr/freeldr/video/bank.c | 2 +- freeldr/freeldr/video/fade.c | 4 +- freeldr/freeldr/video/palette.c | 4 +- freeldr/freeldr/video/pixel.c | 4 +- freeldr/freeldr/video/video.c | 4 +- freeldr/freeldr/video/vidmode.c | 4 +- 79 files changed, 971 insertions(+), 645 deletions(-) rename freeldr/freeldr/{comm => arch/i386}/portio.c (98%) rename freeldr/freeldr/{ui => include}/keycodes.h (93%) create mode 100644 freeldr/freeldr/include/portio.h diff --git a/freeldr/freeldr/arch/i386/boot.S b/freeldr/freeldr/arch/i386/boot.S index 67af7cc2aea..ef465851862 100644 --- a/freeldr/freeldr/arch/i386/boot.S +++ b/freeldr/freeldr/arch/i386/boot.S @@ -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 diff --git a/freeldr/freeldr/arch/i386/i386disk.c b/freeldr/freeldr/arch/i386/i386disk.c index 4a59ba5004f..9f05a9cf038 100644 --- a/freeldr/freeldr/arch/i386/i386disk.c +++ b/freeldr/freeldr/arch/i386/i386disk.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 #include #include -#include +#include typedef struct diff --git a/freeldr/freeldr/arch/i386/i386mem.c b/freeldr/freeldr/arch/i386/i386mem.c index 4257b3716e5..29e9f931497 100644 --- a/freeldr/freeldr/arch/i386/i386mem.c +++ b/freeldr/freeldr/arch/i386/i386mem.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 #include #include -#include +#include U32 GetExtendedMemorySize(VOID) diff --git a/freeldr/freeldr/arch/i386/i386rtl.c b/freeldr/freeldr/arch/i386/i386rtl.c index c180fe36329..b06690c245b 100644 --- a/freeldr/freeldr/arch/i386/i386rtl.c +++ b/freeldr/freeldr/arch/i386/i386rtl.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 #include - +#include +#include 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); +} diff --git a/freeldr/freeldr/arch/i386/i386vid.c b/freeldr/freeldr/arch/i386/i386vid.c index 974b9a060c8..5586d2c9dad 100644 --- a/freeldr/freeldr/arch/i386/i386vid.c +++ b/freeldr/freeldr/arch/i386/i386vid.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * Portions from Linux video.S - Display adapter & video mode setup, version 2.13 (14-May-99) * Copyright (C) 1995 -- 1999 Martin Mares * Based on the original setup.S code (C) Linus Torvalds and Mats Anderson @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include @@ -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; diff --git a/freeldr/freeldr/comm/portio.c b/freeldr/freeldr/arch/i386/portio.c similarity index 98% rename from freeldr/freeldr/comm/portio.c rename to freeldr/freeldr/arch/i386/portio.c index cd942f80925..7e3ecd0a349 100644 --- a/freeldr/freeldr/comm/portio.c +++ b/freeldr/freeldr/arch/i386/portio.c @@ -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 diff --git a/freeldr/freeldr/cache/blocklist.c b/freeldr/freeldr/cache/blocklist.c index d181a8bff96..35ee9e2d5bd 100644 --- a/freeldr/freeldr/cache/blocklist.c +++ b/freeldr/freeldr/cache/blocklist.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/cache/cache.c b/freeldr/freeldr/cache/cache.c index 8ac83d49961..04a731934d2 100644 --- a/freeldr/freeldr/cache/cache.c +++ b/freeldr/freeldr/cache/cache.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/cache/cm.h b/freeldr/freeldr/cache/cm.h index b6fbbf68997..7e4e4cb141d 100644 --- a/freeldr/freeldr/cache/cm.h +++ b/freeldr/freeldr/cache/cm.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/comm/rs232.c b/freeldr/freeldr/comm/rs232.c index 7adeadf5093..f203655fbfd 100644 --- a/freeldr/freeldr/comm/rs232.c +++ b/freeldr/freeldr/comm/rs232.c @@ -21,6 +21,7 @@ #include #include +#include /* MACROS *******************************************************************/ diff --git a/freeldr/freeldr/disk/disk.c b/freeldr/freeldr/disk/disk.c index 169956d5d57..ff5281f3b85 100644 --- a/freeldr/freeldr/disk/disk.c +++ b/freeldr/freeldr/disk/disk.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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) diff --git a/freeldr/freeldr/disk/geometry.c b/freeldr/freeldr/disk/geometry.c index 0aef1443f72..627c2e1996d 100644 --- a/freeldr/freeldr/disk/geometry.c +++ b/freeldr/freeldr/disk/geometry.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/disk/partition.c b/freeldr/freeldr/disk/partition.c index efed2e39866..58a7c2810da 100644 --- a/freeldr/freeldr/disk/partition.c +++ b/freeldr/freeldr/disk/partition.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/freeldr.c b/freeldr/freeldr/freeldr.c index e2554cd66e3..0b0384ec721 100644 --- a/freeldr/freeldr/freeldr.c +++ b/freeldr/freeldr/freeldr.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 @@ -16,8 +16,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -//20030118 RJJ added comment to test CVS #include #include diff --git a/freeldr/freeldr/fs/ext2.c b/freeldr/freeldr/fs/ext2.c index 5198bc1b03f..5526fde3ade 100644 --- a/freeldr/freeldr/fs/ext2.c +++ b/freeldr/freeldr/fs/ext2.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/fs/ext2.h b/freeldr/freeldr/fs/ext2.h index 7b7329c7f4c..8204f1eac3e 100644 --- a/freeldr/freeldr/fs/ext2.h +++ b/freeldr/freeldr/fs/ext2.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/fs/fat.c b/freeldr/freeldr/fs/fat.c index ec72f2c81ab..52edcdfbe9a 100644 --- a/freeldr/freeldr/fs/fat.c +++ b/freeldr/freeldr/fs/fat.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/fs/fat.h b/freeldr/freeldr/fs/fat.h index c6a9378b7c6..d1ab0ff00f1 100644 --- a/freeldr/freeldr/fs/fat.h +++ b/freeldr/freeldr/fs/fat.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/fs/fs.c b/freeldr/freeldr/fs/fs.c index 71de1c4ae1f..5bfe4314ff2 100644 --- a/freeldr/freeldr/fs/fs.c +++ b/freeldr/freeldr/fs/fs.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/fs/iso.c b/freeldr/freeldr/fs/iso.c index a2a6dea0d70..2c31212effa 100644 --- a/freeldr/freeldr/fs/iso.c +++ b/freeldr/freeldr/fs/iso.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/fs/iso.h b/freeldr/freeldr/fs/iso.h index 685fb2027d8..feaa1b57896 100644 --- a/freeldr/freeldr/fs/iso.h +++ b/freeldr/freeldr/fs/iso.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/include/arch.h b/freeldr/freeldr/include/arch.h index d7699fbd98d..b316af73abf 100644 --- a/freeldr/freeldr/include/arch.h +++ b/freeldr/freeldr/include/arch.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 */ diff --git a/freeldr/freeldr/include/bootmgr.h b/freeldr/freeldr/include/bootmgr.h index 38d5e9b230e..330010d2523 100644 --- a/freeldr/freeldr/include/bootmgr.h +++ b/freeldr/freeldr/include/bootmgr.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/include/cache.h b/freeldr/freeldr/include/cache.h index 960e2ca953f..c9b07c759f9 100644 --- a/freeldr/freeldr/include/cache.h +++ b/freeldr/freeldr/include/cache.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/include/comm.h b/freeldr/freeldr/include/comm.h index 9b491cad1fd..84fa9a6b98a 100644 --- a/freeldr/freeldr/include/comm.h +++ b/freeldr/freeldr/include/comm.h @@ -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 diff --git a/freeldr/freeldr/include/debug.h b/freeldr/freeldr/include/debug.h index ac712dbb466..33f522ccc8f 100644 --- a/freeldr/freeldr/include/debug.h +++ b/freeldr/freeldr/include/debug.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/include/disk.h b/freeldr/freeldr/include/disk.h index 9d34ff2c1b4..8cf9e3f9161 100644 --- a/freeldr/freeldr/include/disk.h +++ b/freeldr/freeldr/include/disk.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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); diff --git a/freeldr/freeldr/include/drivemap.h b/freeldr/freeldr/include/drivemap.h index 002ec322199..af4b1c91c87 100644 --- a/freeldr/freeldr/include/drivemap.h +++ b/freeldr/freeldr/include/drivemap.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/include/freeldr.h b/freeldr/freeldr/include/freeldr.h index 3773c95e6f1..40303cd3c65 100644 --- a/freeldr/freeldr/include/freeldr.h +++ b/freeldr/freeldr/include/freeldr.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/include/fs.h b/freeldr/freeldr/include/fs.h index e1bbec08748..35ab38f4c09 100644 --- a/freeldr/freeldr/include/fs.h +++ b/freeldr/freeldr/include/fs.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/include/inifile.h b/freeldr/freeldr/include/inifile.h index a132d9591bd..646d5319a3f 100644 --- a/freeldr/freeldr/include/inifile.h +++ b/freeldr/freeldr/include/inifile.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/ui/keycodes.h b/freeldr/freeldr/include/keycodes.h similarity index 93% rename from freeldr/freeldr/ui/keycodes.h rename to freeldr/freeldr/include/keycodes.h index cd23ad0e138..dda8ebaea6b 100644 --- a/freeldr/freeldr/ui/keycodes.h +++ b/freeldr/freeldr/include/keycodes.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/include/linux.h b/freeldr/freeldr/include/linux.h index 805c72c6d85..9bcaf7db80d 100644 --- a/freeldr/freeldr/include/linux.h +++ b/freeldr/freeldr/include/linux.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 + #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); diff --git a/freeldr/freeldr/include/miscboot.h b/freeldr/freeldr/include/miscboot.h index 4a777c5dea0..bbd4110a85a 100644 --- a/freeldr/freeldr/include/miscboot.h +++ b/freeldr/freeldr/include/miscboot.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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); diff --git a/freeldr/freeldr/include/mm.h b/freeldr/freeldr/include/mm.h index 87d205a7361..d744faba6f0 100644 --- a/freeldr/freeldr/include/mm.h +++ b/freeldr/freeldr/include/mm.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/include/options.h b/freeldr/freeldr/include/options.h index d58eb71dda7..82ac6150e69 100644 --- a/freeldr/freeldr/include/options.h +++ b/freeldr/freeldr/include/options.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/include/oslist.h b/freeldr/freeldr/include/oslist.h index 105db778590..5f874066bd6 100644 --- a/freeldr/freeldr/include/oslist.h +++ b/freeldr/freeldr/include/oslist.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/include/portio.h b/freeldr/freeldr/include/portio.h new file mode 100644 index 00000000000..f7aba205aa0 --- /dev/null +++ b/freeldr/freeldr/include/portio.h @@ -0,0 +1,78 @@ +/* + * FreeLoader + * Copyright (C) 2001 Brian Palmer + * 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 diff --git a/freeldr/freeldr/include/reactos.h b/freeldr/freeldr/include/reactos.h index 6cfcc6f784c..780bb139afc 100644 --- a/freeldr/freeldr/include/reactos.h +++ b/freeldr/freeldr/include/reactos.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/include/rtl.h b/freeldr/freeldr/include/rtl.h index fc239ed2a2b..6ee208545fa 100644 --- a/freeldr/freeldr/include/rtl.h +++ b/freeldr/freeldr/include/rtl.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/include/ui.h b/freeldr/freeldr/include/ui.h index d9e2ffe0d25..c8b0a58922d 100644 --- a/freeldr/freeldr/include/ui.h +++ b/freeldr/freeldr/include/ui.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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); diff --git a/freeldr/freeldr/include/version.h b/freeldr/freeldr/include/version.h index 1ec4d6b1d2c..1956b579df0 100644 --- a/freeldr/freeldr/include/version.h +++ b/freeldr/freeldr/include/version.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 " +#define VERSION "FreeLoader v1.8" +#define COPYRIGHT "Copyright (C) 1998-2003 Brian Palmer " #define AUTHOR_EMAIL "" #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); diff --git a/freeldr/freeldr/include/video.h b/freeldr/freeldr/include/video.h index a9ad80b5783..dfc2fe19d18 100644 --- a/freeldr/freeldr/include/video.h +++ b/freeldr/freeldr/include/video.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/inifile/ini.h b/freeldr/freeldr/inifile/ini.h index 6e779035f76..b24c1f0cab2 100644 --- a/freeldr/freeldr/inifile/ini.h +++ b/freeldr/freeldr/inifile/ini.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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); diff --git a/freeldr/freeldr/inifile/ini_init.c b/freeldr/freeldr/inifile/ini_init.c index d72d51c6442..d47cdc11ad6 100644 --- a/freeldr/freeldr/inifile/ini_init.c +++ b/freeldr/freeldr/inifile/ini_init.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/inifile/inifile.c b/freeldr/freeldr/inifile/inifile.c index 0dc1a88af0c..4b8d32796bf 100644 --- a/freeldr/freeldr/inifile/inifile.c +++ b/freeldr/freeldr/inifile/inifile.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 #include #include +#include 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; +} diff --git a/freeldr/freeldr/inifile/parse.c b/freeldr/freeldr/inifile/parse.c index 06c042f2491..329b197893e 100644 --- a/freeldr/freeldr/inifile/parse.c +++ b/freeldr/freeldr/inifile/parse.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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; diff --git a/freeldr/freeldr/linuxboot.c b/freeldr/freeldr/linuxboot.c index 43aecfc4bdd..70f233472b1 100644 --- a/freeldr/freeldr/linuxboot.c +++ b/freeldr/freeldr/linuxboot.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 #include // For RemoveQuotes() #include +#include @@ -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)) diff --git a/freeldr/freeldr/miscboot.c b/freeldr/freeldr/miscboot.c index 8a630416ebf..154b69f017c 100644 --- a/freeldr/freeldr/miscboot.c +++ b/freeldr/freeldr/miscboot.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 #include #include +#include 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 diff --git a/freeldr/freeldr/mm/mem.h b/freeldr/freeldr/mm/mem.h index 55645ebdcbd..c70a64ee9ae 100644 --- a/freeldr/freeldr/mm/mem.h +++ b/freeldr/freeldr/mm/mem.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/mm/meminit.c b/freeldr/freeldr/mm/meminit.c index a7a6e0fc761..6a63b284857 100644 --- a/freeldr/freeldr/mm/meminit.c +++ b/freeldr/freeldr/mm/meminit.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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) { diff --git a/freeldr/freeldr/mm/mm.c b/freeldr/freeldr/mm/mm.c index bb84b02e046..ada9d510c97 100644 --- a/freeldr/freeldr/mm/mm.c +++ b/freeldr/freeldr/mm/mm.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/multiboot.c b/freeldr/freeldr/multiboot.c index 03768649dcc..4f6f6195d27 100644 --- a/freeldr/freeldr/multiboot.c +++ b/freeldr/freeldr/multiboot.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/options.c b/freeldr/freeldr/options.c index d5c5916a010..e56480c4703 100644 --- a/freeldr/freeldr/options.c +++ b/freeldr/freeldr/options.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 #include #include +#include +#include +#include -#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) - { - OptionsMenuItemSelected = RunOptionsMenu(OptionsMenuItems, OptionsMenuItemCount, OptionsMenuItemSelected, "[Advanced Options]"); + "SEPARATOR", - switch (OptionsMenuItemSelected) - { - case 0: - DoDiskOptionsMenu(); - break; - } - } -} + "Enable Boot Logging", + "Enable VGA Mode", + "Last Known Good Configuration", + "Directory Services Restore Mode", + "Debugging Mode", -void DoDiskOptionsMenu(void) + "SEPARATOR", + + "Custom Boot", + "Reboot", +}; + +enum OptionMenuItems { - char DiskMenuItems[25][80]; - int DiskMenuItemCount = 0; - int FloppyDiskMenuItemCount = 0; - int HardDiskMenuItemCount = 0; - int DiskMenuItemSelected = 0; + SAFE_MODE = 0, + SAFE_MODE_WITH_NETWORKING = 1, + SAFE_MODE_WITH_COMMAND_PROMPT = 2, - char temp[255]; - int i; + SEPARATOR1 = 3, - 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; + ENABLE_BOOT_LOGGING = 4, + ENABLE_VGA_MODE = 5, + LAST_KNOWN_GOOD_CONFIGURATION = 6, + DIRECTORY_SERVICES_RESTORE_MODE = 7, + DEBUGGING_MODE = 8, - for (i=0; i 0) - { - if (getsecond() != second) - { - second = getsecond(); - nTimeOut--; - - // 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 + * Copyright (C) 1998-2003 Brian Palmer * * 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,44 +58,25 @@ 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 + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/reactos/reactos.c b/freeldr/freeldr/reactos/reactos.c index c18535f8bcf..25d8b7c4af6 100644 --- a/freeldr/freeldr/reactos/reactos.c +++ b/freeldr/freeldr/reactos/reactos.c @@ -1,7 +1,7 @@ /* * FreeLoader * - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/reactos/setupldr.c b/freeldr/freeldr/reactos/setupldr.c index bc399b47093..7e3cc5faca7 100644 --- a/freeldr/freeldr/reactos/setupldr.c +++ b/freeldr/freeldr/reactos/setupldr.c @@ -1,7 +1,7 @@ /* * FreeLoader * - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/rtl/list.c b/freeldr/freeldr/rtl/list.c index e6a61306d40..962289b451f 100644 --- a/freeldr/freeldr/rtl/list.c +++ b/freeldr/freeldr/rtl/list.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/rtl/memcmp.c b/freeldr/freeldr/rtl/memcmp.c index 8395dd5e0d9..1adbf9bce61 100644 --- a/freeldr/freeldr/rtl/memcmp.c +++ b/freeldr/freeldr/rtl/memcmp.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/rtl/memcpy.c b/freeldr/freeldr/rtl/memcpy.c index fdcae46f4bd..bc94bf2ab16 100644 --- a/freeldr/freeldr/rtl/memcpy.c +++ b/freeldr/freeldr/rtl/memcpy.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/rtl/memset.c b/freeldr/freeldr/rtl/memset.c index 60e6ba4d4c1..99a92b46715 100644 --- a/freeldr/freeldr/rtl/memset.c +++ b/freeldr/freeldr/rtl/memset.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/rtl/print.c b/freeldr/freeldr/rtl/print.c index d7586847306..5ff16e91f15 100644 --- a/freeldr/freeldr/rtl/print.c +++ b/freeldr/freeldr/rtl/print.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/rtl/stdlib.c b/freeldr/freeldr/rtl/stdlib.c index 3908df8fcce..6460efbefcc 100644 --- a/freeldr/freeldr/rtl/stdlib.c +++ b/freeldr/freeldr/rtl/stdlib.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/rtl/string.c b/freeldr/freeldr/rtl/string.c index 6b44a3dfd30..369ae54e6ac 100644 --- a/freeldr/freeldr/rtl/string.c +++ b/freeldr/freeldr/rtl/string.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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,7 +45,9 @@ char *strncpy(char *dest, char *src, size_t count) while((*src) && (count--)) *dest++ = *src++; - *dest = 0; + + if (count) + *dest = 0; return ret; } diff --git a/freeldr/freeldr/ui/gui.c b/freeldr/freeldr/ui/gui.c index 3c8e6d324d4..0cdb3ae8ab6 100644 --- a/freeldr/freeldr/ui/gui.c +++ b/freeldr/freeldr/ui/gui.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/ui/gui.h b/freeldr/freeldr/ui/gui.h index b83e6f32eb3..4084b043cf7 100644 --- a/freeldr/freeldr/ui/gui.h +++ b/freeldr/freeldr/ui/gui.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/ui/tui.c b/freeldr/freeldr/ui/tui.c index 4465201d394..6a8d7eb926e 100644 --- a/freeldr/freeldr/ui/tui.c +++ b/freeldr/freeldr/ui/tui.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 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 (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; +} diff --git a/freeldr/freeldr/ui/tui.h b/freeldr/freeldr/ui/tui.h index 9dc7231fb37..78eea5946c8 100644 --- a/freeldr/freeldr/ui/tui.h +++ b/freeldr/freeldr/ui/tui.h @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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); /* diff --git a/freeldr/freeldr/ui/tuimenu.c b/freeldr/freeldr/ui/tuimenu.c index d970274c5b2..d0d971b3b85 100644 --- a/freeldr/freeldr/ui/tuimenu.c +++ b/freeldr/freeldr/ui/tuimenu.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 -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; IdxMenuItemCount; 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 } diff --git a/freeldr/freeldr/ui/ui.c b/freeldr/freeldr/ui/ui.c index 7c2bb460fee..3b6df58ac03 100644 --- a/freeldr/freeldr/ui/ui.c +++ b/freeldr/freeldr/ui/ui.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 @@ -69,15 +69,6 @@ BOOL UiInitialize(VOID) U32 VideoMode = VIDEOMODE_NORMAL_TEXT; 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")); @@ -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 0) + { + // 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 + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/video/bank.c b/freeldr/freeldr/video/bank.c index 27685dcdd91..91859f4b4dc 100644 --- a/freeldr/freeldr/video/bank.c +++ b/freeldr/freeldr/video/bank.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 diff --git a/freeldr/freeldr/video/fade.c b/freeldr/freeldr/video/fade.c index 40dd07d8b76..4fadf4c8a9d 100644 --- a/freeldr/freeldr/video/fade.c +++ b/freeldr/freeldr/video/fade.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 #include -#include +#include #define RGB_MAX 64 diff --git a/freeldr/freeldr/video/palette.c b/freeldr/freeldr/video/palette.c index a1fd773a978..1d077b4e1ed 100644 --- a/freeldr/freeldr/video/palette.c +++ b/freeldr/freeldr/video/palette.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 #include -#include +#include VOID VideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue) diff --git a/freeldr/freeldr/video/pixel.c b/freeldr/freeldr/video/pixel.c index 158f6e76437..35ceb1f5882 100644 --- a/freeldr/freeldr/video/pixel.c +++ b/freeldr/freeldr/video/pixel.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 #include -#include +#include #include diff --git a/freeldr/freeldr/video/video.c b/freeldr/freeldr/video/video.c index df9f0e1cd7e..6747a552ecd 100644 --- a/freeldr/freeldr/video/video.c +++ b/freeldr/freeldr/video/video.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 #include -#include +#include #include diff --git a/freeldr/freeldr/video/vidmode.c b/freeldr/freeldr/video/vidmode.c index fe885397146..b87934a5213 100644 --- a/freeldr/freeldr/video/vidmode.c +++ b/freeldr/freeldr/video/vidmode.c @@ -1,6 +1,6 @@ /* * FreeLoader - * Copyright (C) 1998-2002 Brian Palmer + * Copyright (C) 1998-2003 Brian Palmer * * 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 #include #include -#include +#include U32 CurrentVideoMode = VIDEOMODE_NORMAL_TEXT; U32 VideoResolutionX = 80;