Re-organized things a slight bit.

Split up stdlib.c and renamed it to rtl.
Separated disk functions from file system functions.

svn path=/trunk/; revision=2403
This commit is contained in:
Brian Palmer 2001-11-28 10:26:53 +00:00
parent d4d6b6dbf7
commit 12e0be217f
47 changed files with 1460 additions and 899 deletions

View file

@ -25,17 +25,17 @@ export RM = cmd /C del
export CP = cmd /C copy
#FLAGS = -Wall -nostdinc -fno-builtin
FLAGS = -Wall -fno-builtin -DDEBUG -O3
FLAGS = -Wall -fno-builtin -I./ -DDEBUG -O3
#FLAGS = -Wall -fno-builtin
# asmcode.o has to be first in the link line because it contains the startup code
#OBJS = asmcode.a asmcode.o mb.o boot.o freeldr.o stdlib.o fs.a fs.o fat.o \
#OBJS = asmcode.a asmcode.o mb.o boot.o freeldr.o rtl.o fs.a fs.o fat.o \
# reactos.o tui.o menu.o miscboot.o options.o linux.o multiboot.o arcname.o \
# mem.o memory.o debug.o parseini.o registry.o import.o
ASM_OBJS = asmcode.o mb.o boot.o mem.o
C_OBJS = freeldr.o stdlib.o fs.a tui.o menu.o miscboot.o options.o linux.o multiboot.o \
reactos/reactos.o reactos/registry.o reactos/reghive.o reactos/hwdetect.o
C_OBJS2 = arcname.o memory.o debug.o parseini.o rs232.o portio.o oslist.o
C_OBJS = freeldr.o rtl/rtl.a fs/fs.a ui/ui.a miscboot.o options.o linux.o multiboot.o \
reactos/reactos.a comm/comm.a disk/disk.a mm/mm.a
C_OBJS2 = debug.o parseini.o oslist.o
.PHONY : clean
@ -63,56 +63,50 @@ c_code2.a: $(C_OBJS2)
asmcode.o: asmcode.S asmcode.h Makefile
$(CC) $(FLAGS) -o asmcode.o -c asmcode.S
freeldr.o: freeldr.c freeldr.h stdlib.h fs.h reactos/reactos.h tui.h asmcode.h menu.h miscboot.h Makefile
$(CC) $(FLAGS) -o freeldr.o -c freeldr.c
stdlib.o: stdlib.c freeldr.h stdlib.h Makefile
$(CC) $(FLAGS) -o stdlib.o -c stdlib.c
fs.a: fs.o fat.o Makefile
$(LD) -r -o fs.a fs.o fat.o
fs.o: fs.c freeldr.h fs.h stdlib.h tui.h asmcode.h Makefile
$(CC) $(FLAGS) -o fs.o -c fs.c
fat.o: fat.c fat.h freeldr.h fs.h stdlib.h tui.h Makefile
$(CC) $(FLAGS) -o fat.o -c fat.c
reactos/reactos.o: reactos/reactos.c freeldr.h reactos/reactos.h reactos/registry.h reactos/hwdetect.h stdlib.h fs.h tui.h multiboot.h Makefile
$(CC) $(FLAGS) -o reactos/reactos.o -c reactos/reactos.c
multiboot.o: multiboot.c freeldr.h stdlib.h fs.h multiboot.h tui.h Makefile
$(CC) $(FLAGS) -o multiboot.o -c multiboot.c
mb.o: mb.S asmcode.h multiboot.h Makefile
$(CC) $(FLAGS) -o mb.o -c mb.S
tui.o: tui.c freeldr.h stdlib.h tui.h Makefile
$(CC) $(FLAGS) -o tui.o -c tui.c
menu.o: menu.c freeldr.h stdlib.h tui.h menu.h Makefile
$(CC) $(FLAGS) -o menu.o -c menu.c
boot.o: boot.S asmcode.h Makefile
$(CC) $(FLAGS) -o boot.o -c boot.S
miscboot.o: miscboot.c freeldr.h asmcode.h stdlib.h fs.h tui.h miscboot.h Makefile
$(CC) $(FLAGS) -o miscboot.o -c miscboot.c
options.o: options.c freeldr.h stdlib.h tui.h options.h Makefile
$(CC) $(FLAGS) -o options.o -c options.c
linux.o: linux.c freeldr.h stdlib.h tui.h linux.h Makefile
$(CC) $(FLAGS) -o linux.o -c linux.c
arcname.o: arcname.c freeldr.h arcname.h stdlib.h Makefile
$(CC) $(FLAGS) -o arcname.o -c arcname.c
mem.o: mem.S asmcode.h Makefile
$(CC) $(FLAGS) -o mem.o -c mem.S
memory.o: memory.c memory.h Makefile
$(CC) $(FLAGS) -o memory.o -c memory.c
freeldr.o: freeldr.c freeldr.h rtl.h fs.h reactos.h ui.h asmcode.h miscboot.h Makefile
$(CC) $(FLAGS) -o freeldr.o -c freeldr.c
rtl/rtl.a: rtl/print.o rtl/stdlib.o rtl/string.o rtl/memory.o Makefile
$(MAKE) -C rtl
fs/fs.a: fs/fs.o fs/fat.o Makefile
$(MAKE) -C fs
ui/ui.a: ui/tui.o ui/menu.o Makefile
$(MAKE) -C ui
miscboot.o: miscboot.c freeldr.h asmcode.h rtl.h fs.h ui.h miscboot.h Makefile
$(CC) $(FLAGS) -o miscboot.o -c miscboot.c
options.o: options.c freeldr.h rtl.h ui.h options.h Makefile
$(CC) $(FLAGS) -o options.o -c options.c
linux.o: linux.c freeldr.h rtl.h ui.h linux.h Makefile
$(CC) $(FLAGS) -o linux.o -c linux.c
multiboot.o: multiboot.c freeldr.h rtl.h fs.h multiboot.h ui.h Makefile
$(CC) $(FLAGS) -o multiboot.o -c multiboot.c
reactos/reactos.a: reactos/arcname.o reactos/reactos.o reactos/reghive.o reactos/registry.o reactos/hwdetect.o Makefile
$(MAKE) -C reactos
comm/comm.a: comm/rs232.o comm/portio.o Makefile
$(MAKE) -C comm
disk/disk.a: disk/disk.o Makefile
$(MAKE) -C disk
mm/mm.a: mm/mm.o Makefile
$(MAKE) -C mm
debug.o: debug.c debug.h Makefile
$(CC) $(FLAGS) -o debug.o -c debug.c
@ -120,25 +114,17 @@ debug.o: debug.c debug.h Makefile
parseini.o: parseini.c parseini.h Makefile
$(CC) $(FLAGS) -o parseini.o -c parseini.c
rs232.o: rs232.c rs232.h Makefile
$(CC) $(FLAGS) -o rs232.o -c rs232.c
portio.o: portio.c portio.h Makefile
$(CC) $(FLAGS) -o portio.o -c portio.c
oslist.o: oslist.c oslist.h Makefile
$(CC) $(FLAGS) -o oslist.o -c oslist.c
reactos/registry.o: reactos/registry.c freeldr.h memory.h reactos/registry.h stdlib.h Makefile
$(CC) $(FLAGS) -o reactos/registry.o -c reactos/registry.c
reactos/reghive.o: reactos/reghive.c freeldr.h reactos/registry.h stdlib.h memory.h Makefile
$(CC) $(FLAGS) -o reactos/reghive.o -c reactos/reghive.c
reactos/hwdetect.o: reactos/hwdetect.c freeldr.h reactos/hwdetect.h Makefile
$(CC) $(FLAGS) -o reactos/hwdetect.o -c reactos/hwdetect.c
clean:
$(RM) *.o
$(RM) *.a
$(RM) *.sys
$(MAKE) -C reactos clean
$(MAKE) -C comm clean
$(MAKE) -C disk clean
$(MAKE) -C mm clean
$(MAKE) -C ui clean
$(MAKE) -C fs clean
$(MAKE) -C rtl clean

144
freeldr/freeldr/cache/Makefile vendored Normal file
View file

@ -0,0 +1,144 @@
#
# FreeLoader
# Copyright (C) 1999, 2000, 2001 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
# 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.
#
export CC = gcc
export LD = ld
export AR = ar
export RM = cmd /C del
export CP = cmd /C copy
#FLAGS = -Wall -nostdinc -fno-builtin
FLAGS = -Wall -fno-builtin -DDEBUG -O3
#FLAGS = -Wall -fno-builtin
# asmcode.o has to be first in the link line because it contains the startup code
#OBJS = asmcode.a asmcode.o mb.o boot.o freeldr.o stdlib.o fs.a fs.o fat.o \
# reactos.o tui.o menu.o miscboot.o options.o linux.o multiboot.o arcname.o \
# mem.o memory.o debug.o parseini.o registry.o import.o
ASM_OBJS = asmcode.o mb.o boot.o mem.o
C_OBJS = freeldr.o stdlib.o fs.a tui.o menu.o miscboot.o options.o linux.o multiboot.o \
reactos/reactos.o reactos/registry.o reactos/reghive.o reactos/hwdetect.o
C_OBJS2 = arcname.o memory.o debug.o parseini.o rs232.o portio.o oslist.o
.PHONY : clean
all: freeldr.sys
freeldr.sys: asmcode.a c_code.a
$(LD) -N -Ttext=0x8000 --oformat=binary -s -o f.sys asmcode.a c_code.a
../bootsect/stubit ../bootsect/fatstub.bin f.sys freeldr.sys
freeldr.exe: asmcode.a c_code.a
$(LD) -o freeldr.exe asmcode.a c_code.a
asmcode.a: $(ASM_OBJS)
$(LD) -r -o asmcode.a $(ASM_OBJS)
c_code.a: c_code1.a c_code2.a
$(LD) -r -o c_code.a c_code1.a c_code2.a
c_code1.a: $(C_OBJS)
$(LD) -r -o c_code1.a $(C_OBJS)
c_code2.a: $(C_OBJS2)
$(LD) -r -o c_code2.a $(C_OBJS2)
asmcode.o: asmcode.S asmcode.h Makefile
$(CC) $(FLAGS) -o asmcode.o -c asmcode.S
freeldr.o: freeldr.c freeldr.h stdlib.h fs.h reactos/reactos.h tui.h asmcode.h menu.h miscboot.h Makefile
$(CC) $(FLAGS) -o freeldr.o -c freeldr.c
stdlib.o: stdlib.c freeldr.h stdlib.h Makefile
$(CC) $(FLAGS) -o stdlib.o -c stdlib.c
fs.a: fs.o fat.o Makefile
$(LD) -r -o fs.a fs.o fat.o
fs.o: fs.c freeldr.h fs.h stdlib.h tui.h asmcode.h Makefile
$(CC) $(FLAGS) -o fs.o -c fs.c
fat.o: fat.c fat.h freeldr.h fs.h stdlib.h tui.h Makefile
$(CC) $(FLAGS) -o fat.o -c fat.c
reactos/reactos.o: reactos/reactos.c freeldr.h reactos/reactos.h reactos/registry.h reactos/hwdetect.h stdlib.h fs.h tui.h multiboot.h Makefile
$(CC) $(FLAGS) -o reactos/reactos.o -c reactos/reactos.c
multiboot.o: multiboot.c freeldr.h stdlib.h fs.h multiboot.h tui.h Makefile
$(CC) $(FLAGS) -o multiboot.o -c multiboot.c
mb.o: mb.S asmcode.h multiboot.h Makefile
$(CC) $(FLAGS) -o mb.o -c mb.S
tui.o: tui.c freeldr.h stdlib.h tui.h Makefile
$(CC) $(FLAGS) -o tui.o -c tui.c
menu.o: menu.c freeldr.h stdlib.h tui.h menu.h Makefile
$(CC) $(FLAGS) -o menu.o -c menu.c
boot.o: boot.S asmcode.h Makefile
$(CC) $(FLAGS) -o boot.o -c boot.S
miscboot.o: miscboot.c freeldr.h asmcode.h stdlib.h fs.h tui.h miscboot.h Makefile
$(CC) $(FLAGS) -o miscboot.o -c miscboot.c
options.o: options.c freeldr.h stdlib.h tui.h options.h Makefile
$(CC) $(FLAGS) -o options.o -c options.c
linux.o: linux.c freeldr.h stdlib.h tui.h linux.h Makefile
$(CC) $(FLAGS) -o linux.o -c linux.c
arcname.o: arcname.c freeldr.h arcname.h stdlib.h Makefile
$(CC) $(FLAGS) -o arcname.o -c arcname.c
mem.o: mem.S asmcode.h Makefile
$(CC) $(FLAGS) -o mem.o -c mem.S
memory.o: memory.c memory.h Makefile
$(CC) $(FLAGS) -o memory.o -c memory.c
debug.o: debug.c debug.h Makefile
$(CC) $(FLAGS) -o debug.o -c debug.c
parseini.o: parseini.c parseini.h Makefile
$(CC) $(FLAGS) -o parseini.o -c parseini.c
rs232.o: rs232.c rs232.h Makefile
$(CC) $(FLAGS) -o rs232.o -c rs232.c
portio.o: portio.c portio.h Makefile
$(CC) $(FLAGS) -o portio.o -c portio.c
oslist.o: oslist.c oslist.h Makefile
$(CC) $(FLAGS) -o oslist.o -c oslist.c
reactos/registry.o: reactos/registry.c freeldr.h memory.h reactos/registry.h stdlib.h Makefile
$(CC) $(FLAGS) -o reactos/registry.o -c reactos/registry.c
reactos/reghive.o: reactos/reghive.c freeldr.h reactos/registry.h stdlib.h memory.h Makefile
$(CC) $(FLAGS) -o reactos/reghive.o -c reactos/reghive.c
reactos/hwdetect.o: reactos/hwdetect.c freeldr.h reactos/hwdetect.h Makefile
$(CC) $(FLAGS) -o reactos/hwdetect.o -c reactos/hwdetect.c
clean:
$(RM) *.o
$(RM) *.a
$(RM) *.sys

View file

@ -1,6 +1,8 @@
/*
* 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
@ -17,8 +19,14 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __PORTIO_H
#define __PORTIO_H
#ifndef __RS232_H
#define __RS232_H
BOOL Rs232PortInitialize(ULONG ComPort, ULONG BaudRate);
BOOL Rs232PortGetByte(PUCHAR ByteRecieved);
BOOL Rs232PortPollByte(PUCHAR ByteRecieved);
VOID Rs232PortPutByte(UCHAR ByteToSend);
/*
@ -74,4 +82,4 @@ VOID
WRITE_PORT_USHORT (PUSHORT Port, USHORT Value);
#endif // defined __PORTIO_H
#endif // defined __RS232_H

View file

@ -0,0 +1,46 @@
#
# FreeLoader
# Copyright (C) 1999, 2000, 2001 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
# 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.
#
export CC = gcc
export LD = ld
export AR = ar
export RM = cmd /C del
export CP = cmd /C copy
FLAGS = -Wall -fno-builtin -I../ -DDEBUG -O3
OBJS = rs232.o portio.o
.PHONY : clean
all: comm.a
comm.a: $(OBJS)
$(LD) -r -o comm.a $(OBJS)
rs232.o: rs232.c ../comm.h Makefile
$(CC) $(FLAGS) -o rs232.o -c rs232.c
portio.o: portio.c ../comm.h Makefile
$(CC) $(FLAGS) -o portio.o -c portio.c
clean:
$(RM) *.o
$(RM) *.a

View file

@ -1,4 +1,4 @@
/* $Id: portio.c,v 1.1 2001/08/07 06:19:43 bpalmer Exp $
/* $Id: portio.c,v 1.1 2001/11/28 10:26:52 bpalmer Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel

View file

@ -19,8 +19,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "freeldr.h"
#include "portio.h"
#include <freeldr.h>
#include <comm.h>
/* MACROS *******************************************************************/
@ -120,7 +120,7 @@ static BOOL Rs232DoesComPortExist(PUCHAR BaseAddress)
BOOL Rs232PortInitialize(ULONG ComPort, ULONG BaudRate)
{
ULONG BaseArray[5] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8};
char buffer[80];
//char buffer[80];
ULONG divisor;
BYTE lcr;

View file

@ -17,16 +17,14 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "freeldr.h"
#include "debug.h"
#include "stdlib.h"
#include "rs232.h"
#include "parseini.h"
#include "portio.h"
#include <freeldr.h>
#include <debug.h>
#include <rtl.h>
#include <comm.h>
#ifdef DEBUG
ULONG DebugPrintMask = DPRINT_WARNING | DPRINT_MEMORY | DPRINT_FILESYSTEM | DPRINT_UI;
ULONG DebugPrintMask = DPRINT_WARNING | DPRINT_MEMORY | DPRINT_FILESYSTEM | DPRINT_UI | DPRINT_DISK;
#define SCREEN 0
#define RS232 1

View file

@ -28,6 +28,7 @@
#define DPRINT_FILESYSTEM 0x00000004 // OR this with DebugPrintMask to enable file system messages
#define DPRINT_INIFILE 0x00000008 // OR this with DebugPrintMask to enable .ini file messages
#define DPRINT_UI 0x00000010 // OR this with DebugPrintMask to enable user interface messages
#define DPRINT_DISK 0x00000020 // OR this with DebugPrintMask to enable disk messages
VOID DebugInit(VOID);
VOID DebugPrint(ULONG Mask, char *format, ...);

59
freeldr/freeldr/disk.h Normal file
View file

@ -0,0 +1,59 @@
/*
* FreeLoader
* Copyright (C) 1999, 2000, 2001 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
* 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 __DISK_H
#define __DISK_H
typedef struct _GEOMETRY
{
ULONG Cylinders;
ULONG Heads;
ULONG Sectors;
ULONG BytesPerSector;
} GEOMETRY, *PGEOMETRY;
///////////////////////////////////////////////////////////////////////////////////////
//
// BIOS Disk Functions
//
///////////////////////////////////////////////////////////////////////////////////////
int biosdisk(int cmd, int drive, int head, int track, int sector, int nsects, void *buffer); // Implemented in asmcode.S
BOOL BiosInt13Read(ULONG Drive, ULONG Head, ULONG Track, ULONG Sector, ULONG SectorCount, PVOID Buffer); // Implemented in asmcode.S
BOOL BiosInt13ReadExtended(ULONG Drive, ULONG Sector, ULONG SectorCount, PVOID Buffer); // Implemented in asmcode.S
BOOL BiosInt13ExtensionsSupported(ULONG Drive);
void stop_floppy(void); // Implemented in asmcode.S
int get_heads(int drive); // Implemented in asmcode.S
int get_cylinders(int drive); // Implemented in asmcode.S
int get_sectors(int drive); // Implemented in asmcode.S
///////////////////////////////////////////////////////////////////////////////////////
//
// FreeLoader Disk Functions
//
///////////////////////////////////////////////////////////////////////////////////////
VOID DiskSetDriveGeometry(ULONG Cylinders, ULONG Heads, ULONG Sectors, ULONG BytesPerSector);
VOID DiskSetVolumeProperties(ULONG HiddenSectors);
BOOL DiskReadMultipleLogicalSectors(ULONG SectorNumber, ULONG SectorCount, PVOID Buffer);
BOOL DiskReadLogicalSector(ULONG SectorNumber, PVOID Buffer);
#endif // defined __DISK_H

View file

@ -0,0 +1,43 @@
#
# FreeLoader
# Copyright (C) 1999, 2000, 2001 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
# 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.
#
export CC = gcc
export LD = ld
export AR = ar
export RM = cmd /C del
export CP = cmd /C copy
FLAGS = -Wall -fno-builtin -I../ -DDEBUG -O3
OBJS = disk.o
.PHONY : clean
all: disk.a
disk.a: $(OBJS)
$(LD) -r -o disk.a $(OBJS)
disk.o: disk.c ../disk.h Makefile
$(CC) $(FLAGS) -o disk.o -c disk.c
clean:
$(RM) *.o
$(RM) *.a

188
freeldr/freeldr/disk/disk.c Normal file
View file

@ -0,0 +1,188 @@
/*
* FreeLoader
* Copyright (C) 1999, 2000, 2001 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
* 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.
*/
#include <freeldr.h>
#include <disk.h>
#include <fs.h>
#include <rtl.h>
#include <ui.h>
#include <asmcode.h>
#include <debug.h>
/////////////////////////////////////////////////////////////////////////////////////////////
// DATA
/////////////////////////////////////////////////////////////////////////////////////////////
GEOMETRY DriveGeometry;
ULONG VolumeHiddenSectors;
ULONG CurrentlyOpenDriveNumber;
/////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
/////////////////////////////////////////////////////////////////////////////////////////////
VOID DiskError(PUCHAR ErrorString)
{
DbgPrint((DPRINT_DISK, "%s\n", ErrorString));
if (UserInterfaceUp)
{
MessageBox(ErrorString);
}
else
{
printf("%s", ErrorString);
printf("\nPress any key\n");
getch();
}
}
VOID DiskSetDriveGeometry(ULONG Cylinders, ULONG Heads, ULONG Sectors, ULONG BytesPerSector)
{
DriveGeometry.Cylinders = Cylinders;
DriveGeometry.Heads = Heads;
DriveGeometry.Sectors = Sectors;
DriveGeometry.BytesPerSector = BytesPerSector;
DbgPrint((DPRINT_DISK, "DriveGeometry.Cylinders: %d\n", DriveGeometry.Cylinders));
DbgPrint((DPRINT_DISK, "DriveGeometry.Heads: %d\n", DriveGeometry.Heads));
DbgPrint((DPRINT_DISK, "DriveGeometry.Sectors: %d\n", DriveGeometry.Sectors));
DbgPrint((DPRINT_DISK, "DriveGeometry.BytesPerSector: %d\n", DriveGeometry.BytesPerSector));
}
VOID DiskSetVolumeProperties(ULONG HiddenSectors)
{
VolumeHiddenSectors = HiddenSectors;
}
BOOL DiskReadMultipleLogicalSectors(ULONG SectorNumber, ULONG SectorCount, PVOID Buffer)
{
/*BOOL bRetVal;
int PhysicalSector;
int PhysicalHead;
int PhysicalTrack;
int nNum;
nSect += nHiddenSectors;
while (nNumberOfSectors)
{
PhysicalSector = 1 + (nSect % nSectorsPerTrack);
PhysicalHead = (nSect / nSectorsPerTrack) % nNumberOfHeads;
PhysicalTrack = nSect / (nSectorsPerTrack * nNumberOfHeads);
if (PhysicalSector > 1)
{
if (nNumberOfSectors >= (nSectorsPerTrack - (PhysicalSector - 1)))
nNum = (nSectorsPerTrack - (PhysicalSector - 1));
else
nNum = nNumberOfSectors;
}
else
{
if (nNumberOfSectors >= nSectorsPerTrack)
nNum = nSectorsPerTrack;
else
nNum = nNumberOfSectors;
}
bRetVal = biosdisk(CurrentlyOpenDriveNumber, PhysicalHead, PhysicalTrack, PhysicalSector, nNum, pBuffer);
if (!bRetVal)
{
FS_DO_ERROR("Disk Error");
return FALSE;
}
pBuffer += (nNum * 512);
nNumberOfSectors -= nNum;
nSect += nNum;
}*/
ULONG CurrentSector;
PVOID RealBuffer = Buffer;
for (CurrentSector=SectorNumber; CurrentSector<(SectorNumber + SectorCount); CurrentSector++)
{
if (!DiskReadLogicalSector(CurrentSector, RealBuffer) )
{
return FALSE;
}
RealBuffer += DriveGeometry.BytesPerSector;
}
return TRUE;
}
BOOL DiskReadLogicalSector(ULONG SectorNumber, PVOID Buffer)
{
ULONG PhysicalSector;
ULONG PhysicalHead;
ULONG PhysicalTrack;
DbgPrint((DPRINT_DISK, "ReadLogicalSector() SectorNumber: %d Buffer: 0x%x\n", SectorNumber, Buffer));
SectorNumber += VolumeHiddenSectors;
PhysicalSector = 1 + (SectorNumber % DriveGeometry.Sectors);
PhysicalHead = (SectorNumber / DriveGeometry.Sectors) % DriveGeometry.Heads;
PhysicalTrack = (SectorNumber / DriveGeometry.Sectors) / DriveGeometry.Heads;
//DbgPrint((DPRINT_FILESYSTEM, "Calling BiosInt13Read() with PhysicalHead: %d\n", PhysicalHead));
//DbgPrint((DPRINT_FILESYSTEM, "Calling BiosInt13Read() with PhysicalTrack: %d\n", PhysicalTrack));
//DbgPrint((DPRINT_FILESYSTEM, "Calling BiosInt13Read() with PhysicalSector: %d\n", PhysicalSector));
if (PhysicalHead >= DriveGeometry.Heads)
{
BugCheck((DPRINT_DISK, "PhysicalHead >= DriveGeometry.Heads\nPhysicalHead = %d\nDriveGeometry.Heads = %d\n", PhysicalHead, DriveGeometry.Heads));
}
if (PhysicalTrack >= DriveGeometry.Cylinders)
{
BugCheck((DPRINT_DISK, "PhysicalTrack >= DriveGeometry.Cylinders\nPhysicalTrack = %d\nDriveGeometry.Cylinders = %d\n", PhysicalTrack, DriveGeometry.Cylinders));
}
if (PhysicalSector > DriveGeometry.Sectors)
{
BugCheck((DPRINT_DISK, "PhysicalSector > DriveGeometry.Sectors\nPhysicalSector = %d\nDriveGeometry.Sectors = %d\n", PhysicalSector, DriveGeometry.Sectors));
}
//
// Check to see if it is a fixed disk drive
// If so then check to see if Int13 extensions work
// If they do then use them, otherwise default back to BIOS calls
//
if ((CurrentlyOpenDriveNumber >= 0x80) && (BiosInt13ExtensionsSupported(CurrentlyOpenDriveNumber)) && (SectorNumber > (DriveGeometry.Cylinders * DriveGeometry.Heads * DriveGeometry.Sectors)))
{
DbgPrint((DPRINT_DISK, "Using Int 13 Extensions for read. BiosInt13ExtensionsSupported(%d) = %s\n", CurrentlyOpenDriveNumber, BiosInt13ExtensionsSupported(CurrentlyOpenDriveNumber) ? "TRUE" : "FALSE"));
if ( !BiosInt13ReadExtended(CurrentlyOpenDriveNumber, SectorNumber, 1, Buffer) )
{
DiskError("Disk read error.");
return FALSE;
}
}
else
{
if ( !BiosInt13Read(CurrentlyOpenDriveNumber, PhysicalHead, PhysicalTrack, PhysicalSector, 1, Buffer) )
{
DiskError("Disk read error.");
return FALSE;
}
}
return TRUE;
}

View file

@ -18,15 +18,14 @@
*/
#include "freeldr.h"
#include "stdlib.h"
#include "rtl.h"
#include "fs.h"
#include "reactos/reactos.h"
#include "tui.h"
#include "reactos.h"
#include "ui.h"
#include "asmcode.h"
#include "menu.h"
#include "miscboot.h"
#include "linux.h"
#include "memory.h"
#include "mm.h"
#include "parseini.h"
#include "debug.h"
#include "oslist.h"

View file

@ -75,24 +75,11 @@ typedef struct _MASTER_BOOT_RECORD
#define PARTITION_LDM 0x42 // Logical Disk Manager partition
#define PARTITION_UNIX 0x63 // Unix
typedef struct _GEOMETRY
{
ULONG Cylinders;
ULONG Heads;
ULONG Sectors;
ULONG BytesPerSector;
} GEOMETRY, *PGEOMETRY;
#define FILE VOID
#define PFILE FILE *
VOID FileSystemError(PUCHAR ErrorString);
BOOL OpenDiskDrive(ULONG DriveNumber, ULONG PartitionNumber);
VOID SetDriveGeometry(ULONG Cylinders, ULONG Heads, ULONG Sectors, ULONG BytesPerSector);
VOID SetVolumeProperties(ULONG HiddenSectors);
BOOL ReadMultipleLogicalSectors(ULONG SectorNumber, ULONG SectorCount, PVOID Buffer);
BOOL ReadLogicalSector(ULONG SectorNumber, PVOID Buffer);
PFILE OpenFile(PUCHAR FileName);
VOID CloseFile(PFILE FileHandle);
BOOL ReadFile(PFILE FileHandle, ULONG BytesToRead, PULONG BytesRead, PVOID Buffer);

View file

@ -0,0 +1,46 @@
#
# FreeLoader
# Copyright (C) 1999, 2000, 2001 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
# 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.
#
export CC = gcc
export LD = ld
export AR = ar
export RM = cmd /C del
export CP = cmd /C copy
FLAGS = -Wall -fno-builtin -I../ -DDEBUG -O3
OBJS = fs.o fat.o
.PHONY : clean
all: fs.a
fs.a: $(OBJS)
$(LD) -r -o fs.a $(OBJS)
fs.o: fs.c fat.h ../fs.h Makefile
$(CC) $(FLAGS) -o fs.o -c fs.c
fat.o: fat.c fat.h ../fs.h Makefile
$(CC) $(FLAGS) -o fat.o -c fat.c
clean:
$(RM) *.o
$(RM) *.a

View file

@ -17,14 +17,15 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "freeldr.h"
#include "fs.h"
#include <freeldr.h>
#include <fs.h>
#include "fat.h"
#include "stdlib.h"
#include "tui.h"
#include "asmcode.h"
#include "memory.h"
#include "debug.h"
#include <disk.h>
#include <rtl.h>
#include <ui.h>
#include <asmcode.h>
#include <mm.h>
#include <debug.h>
PFAT_BOOTSECTOR FatVolumeBootSector = NULL;
@ -152,8 +153,8 @@ BOOL FatOpenVolume(ULONG DriveNumber, ULONG VolumeStartHead, ULONG VolumeStartTr
return FALSE;
}
SetDriveGeometry(get_cylinders(DriveNumber), get_heads(DriveNumber), get_sectors(DriveNumber), FatVolumeBootSector->BytesPerSector);
SetVolumeProperties(FatVolumeBootSector->HiddenSectors);
DiskSetDriveGeometry(get_cylinders(DriveNumber), get_heads(DriveNumber), get_sectors(DriveNumber), FatVolumeBootSector->BytesPerSector);
DiskSetVolumeProperties(FatVolumeBootSector->HiddenSectors);
//
// Check the FAT cluster size
@ -267,7 +268,7 @@ PVOID FatBufferDirectory(UINT32 DirectoryStartCluster, PUINT32 EntryCountPointer
RootDirectoryStartSector = FatVolumeBootSector->ReservedSectors + (FatVolumeBootSector->NumberOfFats * FatVolumeBootSector->SectorsPerFat);
RootDirectorySectorCount = FatVolumeBootSector->RootDirEntries / 32;
if (!ReadMultipleLogicalSectors(RootDirectoryStartSector, RootDirectorySectorCount, DirectoryBuffer))
if (!DiskReadMultipleLogicalSectors(RootDirectoryStartSector, RootDirectorySectorCount, DirectoryBuffer))
{
FreeMemory(DirectoryBuffer);
return NULL;
@ -698,14 +699,14 @@ DWORD FatGetFatEntry(DWORD nCluster)
if (ThisFatEntOffset == (FatVolumeBootSector->BytesPerSector - 1))
{
if (!ReadMultipleLogicalSectors(ThisFatSecNum, 2, (PVOID)DISKREADBUFFER))
if (!DiskReadMultipleLogicalSectors(ThisFatSecNum, 2, (PVOID)DISKREADBUFFER))
{
return NULL;
}
}
else
{
if (!ReadLogicalSector(ThisFatSecNum, (PVOID)DISKREADBUFFER))
if (!DiskReadLogicalSector(ThisFatSecNum, (PVOID)DISKREADBUFFER))
{
return NULL;
}
@ -725,7 +726,7 @@ DWORD FatGetFatEntry(DWORD nCluster)
ThisFatSecNum = FatVolumeBootSector->ReservedSectors + (FatOffset / FatVolumeBootSector->BytesPerSector);
ThisFatEntOffset = (FatOffset % FatVolumeBootSector->BytesPerSector);
if (!ReadLogicalSector(ThisFatSecNum, (PVOID)DISKREADBUFFER))
if (!DiskReadLogicalSector(ThisFatSecNum, (PVOID)DISKREADBUFFER))
{
return NULL;
}
@ -740,7 +741,7 @@ DWORD FatGetFatEntry(DWORD nCluster)
ThisFatSecNum = FatVolumeBootSector->ReservedSectors + (FatOffset / FatVolumeBootSector->BytesPerSector);
ThisFatEntOffset = (FatOffset % FatVolumeBootSector->BytesPerSector);
if (!ReadLogicalSector(ThisFatSecNum, (PVOID)DISKREADBUFFER))
if (!DiskReadLogicalSector(ThisFatSecNum, (PVOID)DISKREADBUFFER))
{
return NULL;
}
@ -885,7 +886,7 @@ BOOL FatReadCluster(ULONG ClusterNumber, PVOID Buffer)
DbgPrint((DPRINT_FILESYSTEM, "FatReadCluster() ClusterNumber = %d Buffer = 0x%x ClusterStartSector = %d\n", ClusterNumber, Buffer, ClusterStartSector));
if (!ReadMultipleLogicalSectors(ClusterStartSector, FatVolumeBootSector->SectorsPerCluster, (PVOID)DISKREADBUFFER))
if (!DiskReadMultipleLogicalSectors(ClusterStartSector, FatVolumeBootSector->SectorsPerCluster, (PVOID)DISKREADBUFFER))
{
return FALSE;
}
@ -917,7 +918,7 @@ BOOL FatReadClusterChain(ULONG StartClusterNumber, ULONG NumberOfClusters, PVOID
//
// Read cluster into memory
//
if (!ReadMultipleLogicalSectors(ClusterStartSector, FatVolumeBootSector->SectorsPerCluster, (PVOID)DISKREADBUFFER))
if (!DiskReadMultipleLogicalSectors(ClusterStartSector, FatVolumeBootSector->SectorsPerCluster, (PVOID)DISKREADBUFFER))
{
return FALSE;
}
@ -965,7 +966,7 @@ BOOL FatReadPartialCluster(ULONG ClusterNumber, ULONG StartingOffset, ULONG Leng
ClusterStartSector = ((ClusterNumber - 2) * FatVolumeBootSector->SectorsPerCluster) + DataSectorStart;
if (!ReadMultipleLogicalSectors(ClusterStartSector, FatVolumeBootSector->SectorsPerCluster, (PVOID)DISKREADBUFFER))
if (!DiskReadMultipleLogicalSectors(ClusterStartSector, FatVolumeBootSector->SectorsPerCluster, (PVOID)DISKREADBUFFER))
{
return FALSE;
}

View file

@ -17,13 +17,14 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "freeldr.h"
#include "fs.h"
#include <freeldr.h>
#include <fs.h>
#include "fat.h"
#include "stdlib.h"
#include "tui.h"
#include "asmcode.h"
#include "debug.h"
#include <disk.h>
#include <rtl.h>
#include <ui.h>
#include <asmcode.h>
#include <debug.h>
/////////////////////////////////////////////////////////////////////////////////////////////
@ -230,136 +231,6 @@ BOOL OpenDiskDrive(ULONG DriveNumber, ULONG PartitionNumber)
return TRUE;
}
VOID SetDriveGeometry(ULONG Cylinders, ULONG Heads, ULONG Sectors, ULONG BytesPerSector)
{
DriveGeometry.Cylinders = Cylinders;
DriveGeometry.Heads = Heads;
DriveGeometry.Sectors = Sectors;
DriveGeometry.BytesPerSector = BytesPerSector;
DbgPrint((DPRINT_FILESYSTEM, "DriveGeometry.Cylinders: %d\n", DriveGeometry.Cylinders));
DbgPrint((DPRINT_FILESYSTEM, "DriveGeometry.Heads: %d\n", DriveGeometry.Heads));
DbgPrint((DPRINT_FILESYSTEM, "DriveGeometry.Sectors: %d\n", DriveGeometry.Sectors));
DbgPrint((DPRINT_FILESYSTEM, "DriveGeometry.BytesPerSector: %d\n", DriveGeometry.BytesPerSector));
}
VOID SetVolumeProperties(ULONG HiddenSectors)
{
VolumeHiddenSectors = HiddenSectors;
}
BOOL ReadMultipleLogicalSectors(ULONG SectorNumber, ULONG SectorCount, PVOID Buffer)
{
/*BOOL bRetVal;
int PhysicalSector;
int PhysicalHead;
int PhysicalTrack;
int nNum;
nSect += nHiddenSectors;
while (nNumberOfSectors)
{
PhysicalSector = 1 + (nSect % nSectorsPerTrack);
PhysicalHead = (nSect / nSectorsPerTrack) % nNumberOfHeads;
PhysicalTrack = nSect / (nSectorsPerTrack * nNumberOfHeads);
if (PhysicalSector > 1)
{
if (nNumberOfSectors >= (nSectorsPerTrack - (PhysicalSector - 1)))
nNum = (nSectorsPerTrack - (PhysicalSector - 1));
else
nNum = nNumberOfSectors;
}
else
{
if (nNumberOfSectors >= nSectorsPerTrack)
nNum = nSectorsPerTrack;
else
nNum = nNumberOfSectors;
}
bRetVal = biosdisk(CurrentlyOpenDriveNumber, PhysicalHead, PhysicalTrack, PhysicalSector, nNum, pBuffer);
if (!bRetVal)
{
FS_DO_ERROR("Disk Error");
return FALSE;
}
pBuffer += (nNum * 512);
nNumberOfSectors -= nNum;
nSect += nNum;
}*/
ULONG CurrentSector;
PVOID RealBuffer = Buffer;
for (CurrentSector=SectorNumber; CurrentSector<(SectorNumber + SectorCount); CurrentSector++)
{
if (!ReadLogicalSector(CurrentSector, RealBuffer) )
{
return FALSE;
}
RealBuffer += DriveGeometry.BytesPerSector;
}
return TRUE;
}
BOOL ReadLogicalSector(ULONG SectorNumber, PVOID Buffer)
{
ULONG PhysicalSector;
ULONG PhysicalHead;
ULONG PhysicalTrack;
DbgPrint((DPRINT_FILESYSTEM, "ReadLogicalSector() SectorNumber: %d Buffer: 0x%x\n", SectorNumber, Buffer));
SectorNumber += VolumeHiddenSectors;
PhysicalSector = 1 + (SectorNumber % DriveGeometry.Sectors);
PhysicalHead = (SectorNumber / DriveGeometry.Sectors) % DriveGeometry.Heads;
PhysicalTrack = (SectorNumber / DriveGeometry.Sectors) / DriveGeometry.Heads;
//DbgPrint((DPRINT_FILESYSTEM, "Calling BiosInt13Read() with PhysicalHead: %d\n", PhysicalHead));
//DbgPrint((DPRINT_FILESYSTEM, "Calling BiosInt13Read() with PhysicalTrack: %d\n", PhysicalTrack));
//DbgPrint((DPRINT_FILESYSTEM, "Calling BiosInt13Read() with PhysicalSector: %d\n", PhysicalSector));
if (PhysicalHead >= DriveGeometry.Heads)
{
BugCheck((DPRINT_FILESYSTEM, "PhysicalHead >= DriveGeometry.Heads\nPhysicalHead = %d\nDriveGeometry.Heads = %d\n", PhysicalHead, DriveGeometry.Heads));
}
if (PhysicalTrack >= DriveGeometry.Cylinders)
{
BugCheck((DPRINT_FILESYSTEM, "PhysicalTrack >= DriveGeometry.Cylinders\nPhysicalTrack = %d\nDriveGeometry.Cylinders = %d\n", PhysicalTrack, DriveGeometry.Cylinders));
}
if (PhysicalSector > DriveGeometry.Sectors)
{
BugCheck((DPRINT_FILESYSTEM, "PhysicalSector > DriveGeometry.Sectors\nPhysicalSector = %d\nDriveGeometry.Sectors = %d\n", PhysicalSector, DriveGeometry.Sectors));
}
if ((CurrentlyOpenDriveNumber >= 0x80) &&
(BiosInt13ExtensionsSupported(CurrentlyOpenDriveNumber)) &&
(SectorNumber > (DriveGeometry.Cylinders * DriveGeometry.Heads * DriveGeometry.Sectors)))
{
DbgPrint((DPRINT_FILESYSTEM, "Using Int 13 Extensions for read. BiosInt13ExtensionsSupported(%d) = %s\n", CurrentlyOpenDriveNumber, BiosInt13ExtensionsSupported(CurrentlyOpenDriveNumber) ? "TRUE" : "FALSE"));
if ( !BiosInt13ReadExtended(CurrentlyOpenDriveNumber, SectorNumber, 1, Buffer) )
{
FileSystemError("Disk read error.");
return FALSE;
}
}
else
{
if ( !BiosInt13Read(CurrentlyOpenDriveNumber, PhysicalHead, PhysicalTrack, PhysicalSector, 1, Buffer) )
{
FileSystemError("Disk read error.");
return FALSE;
}
}
return TRUE;
}
PFILE OpenFile(PUCHAR FileName)
{
PFILE FileHandle = NULL;

View file

@ -21,9 +21,9 @@
#include "freeldr.h"
#include "asmcode.h"
#include "miscboot.h"
#include "stdlib.h"
#include "rtl.h"
#include "fs.h"
#include "tui.h"
#include "ui.h"
#include "linux.h"
void LoadAndBootLinux(int DriveNum, int Partition, char *vmlinuz, char *cmd_line)

View file

@ -21,9 +21,9 @@
#include "freeldr.h"
#include "asmcode.h"
#include "miscboot.h"
#include "stdlib.h"
#include "rtl.h"
#include "fs.h"
#include "tui.h"
#include "ui.h"
#include "parseini.h"
void LoadAndBootBootSector(int nOSToBoot)

View file

@ -21,7 +21,7 @@
#ifndef __MEMORY_H
#define __MEMORY_H
#include "multiboot.h"
#include <multiboot.h>
VOID InitMemoryManager(PVOID BaseAddress, ULONG Length);

View file

@ -0,0 +1,43 @@
#
# FreeLoader
# Copyright (C) 1999, 2000, 2001 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
# 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.
#
export CC = gcc
export LD = ld
export AR = ar
export RM = cmd /C del
export CP = cmd /C copy
FLAGS = -Wall -fno-builtin -I../ -DDEBUG -O3
OBJS = mm.o
.PHONY : clean
all: mm.a
mm.a: $(OBJS)
$(LD) -r -o mm.a $(OBJS)
mm.o: mm.c ../mm.h Makefile
$(CC) $(FLAGS) -o mm.o -c mm.c
clean:
$(RM) *.o
$(RM) *.a

View file

@ -17,11 +17,11 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "freeldr.h"
#include "memory.h"
#include "stdlib.h"
#include "debug.h"
#include "tui.h"
#include <freeldr.h>
#include <mm.h>
#include <rtl.h>
#include <debug.h>
#include <ui.h>
//
@ -72,8 +72,8 @@ VOID InitMemoryManager(PVOID BaseAddress, ULONG Length)
HeapMemBlockArray = (PMEMBLOCK)(HeapBaseAddress + HeapLengthInBytes);
// Clear the memory
ZeroMemory(HeapBaseAddress, HeapLengthInBytes);
ZeroMemory(HeapMemBlockArray, (HeapMemBlockCount * sizeof(MEMBLOCK)));
RtlZeroMemory(HeapBaseAddress, HeapLengthInBytes);
RtlZeroMemory(HeapMemBlockArray, (HeapMemBlockCount * sizeof(MEMBLOCK)));
#ifdef DEBUG
DbgPrint((DPRINT_MEMORY, "Memory Manager initialized. BaseAddress = 0x%x Length = 0x%x. %d blocks in heap.\n", BaseAddress, Length, HeapMemBlockCount));

View file

@ -20,10 +20,10 @@
#include "freeldr.h"
#include "asmcode.h"
#include "stdlib.h"
#include "rtl.h"
#include "fs.h"
#include "multiboot.h"
#include "tui.h"
#include "ui.h"
#include "parseini.h"
unsigned long next_module_load_base = 0;

View file

@ -18,8 +18,8 @@
*/
#include "freeldr.h"
#include "stdlib.h"
#include "tui.h"
#include "rtl.h"
#include "ui.h"
#include "options.h"
#include "miscboot.h"

View file

@ -20,9 +20,9 @@
#include "freeldr.h"
#include "parseini.h"
#include "oslist.h"
#include "stdlib.h"
#include "memory.h"
#include "tui.h"
#include "rtl.h"
#include "mm.h"
#include "ui.h"
BOOL InitOperatingSystemList(PUCHAR **SectionNamesPointer, PUCHAR **DisplayNamesPointer, PULONG OperatingSystemCountPointer)
{

View file

@ -19,10 +19,10 @@
#include "freeldr.h"
#include "parseini.h"
#include "tui.h"
#include "ui.h"
#include "fs.h"
#include "stdlib.h"
#include "memory.h"
#include "rtl.h"
#include "mm.h"
#include "debug.h"
PUCHAR FreeLoaderIniFileData = NULL;

View file

@ -1,8 +1,7 @@
/*
* FreeLoader - arcname.h
* FreeLoader
*
* Copyright (C) 2001 Brian Palmer <brianp@sginet.com>
* Copyright (C) 2001 Eric Kohl
* Copyright (C) 1999, 2000, 2001 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,11 +18,26 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __ARCNAME_H
#define __ARCNAME_H
#ifndef __REACTOS_H
#define __REACTOS_H
///////////////////////////////////////////////////////////////////////////////////////
//
// ReactOS Loading Functions
//
///////////////////////////////////////////////////////////////////////////////////////
void LoadAndBootReactOS(PUCHAR OperatingSystemName);
///////////////////////////////////////////////////////////////////////////////////////
//
// ARC Path Functions
//
///////////////////////////////////////////////////////////////////////////////////////
BOOL DissectArcPath(char *ArcPath, char *BootPath, PULONG BootDrive, PULONG BootPartition);
//BOOL ConvertBiosDriveToArcName(PUCHAR ArcName, ULONG BiosDriveNumber);
//ULONG ConvertArcNameToBiosDrive(PUCHAR ArcName);
#endif // defined __ARCNAME_H
#endif // defined __REACTOS_H

View file

@ -0,0 +1,55 @@
#
# FreeLoader
# Copyright (C) 1999, 2000, 2001 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
# 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.
#
export CC = gcc
export LD = ld
export AR = ar
export RM = cmd /C del
export CP = cmd /C copy
FLAGS = -Wall -fno-builtin -I../ -DDEBUG -O3
OBJS = reactos.o arcname.o hwdetect.o reghive.o registry.o
.PHONY : clean
all: reactos.a
reactos.a: $(OBJS)
$(LD) -r -o reactos.a $(OBJS)
reactos.o: reactos.c ../reactos.h Makefile
$(CC) $(FLAGS) -o reactos.o -c reactos.c
arcname.o: arcname.c ../reactos.h Makefile
$(CC) $(FLAGS) -o arcname.o -c arcname.c
hwdetect.o: hwdetect.c ../reactos.h Makefile
$(CC) $(FLAGS) -o hwdetect.o -c hwdetect.c
reghive.o: reghive.c ../reactos.h Makefile
$(CC) $(FLAGS) -o reghive.o -c reghive.c
registry.o: registry.c ../reactos.h Makefile
$(CC) $(FLAGS) -o registry.o -c registry.c
clean:
$(RM) *.o
$(RM) *.a

View file

@ -19,9 +19,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "freeldr.h"
#include "arcname.h"
#include "stdlib.h"
#include <freeldr.h>
#include <rtl.h>
BOOL DissectArcPath(char *ArcPath, char *BootPath, PULONG BootDrive, PULONG BootPartition)

View file

@ -18,8 +18,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "../freeldr.h"
#include "../stdlib.h"
#include <freeldr.h>
#include <rtl.h>
//#define NDEBUG

View file

@ -18,16 +18,15 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "../freeldr.h"
#include "../asmcode.h"
#include "reactos.h"
#include "../stdlib.h"
#include "../fs.h"
#include "../tui.h"
#include "../multiboot.h"
#include "../arcname.h"
#include "../memory.h"
#include "../parseini.h"
#include <freeldr.h>
#include <asmcode.h>
#include <reactos.h>
#include <rtl.h>
#include <fs.h>
#include <ui.h>
#include <multiboot.h>
#include <mm.h>
#include <parseini.h>
#include "registry.h"
#include "hwdetect.h"

View file

@ -1,28 +0,0 @@
/*
* FreeLoader
*
* Copyright (C) 1999, 2000 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
* 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 __REACTOS_H
#define __REACTOS_H
void LoadAndBootReactOS(PUCHAR OperatingSystemName);
#endif // defined __REACTOS_H

View file

@ -19,9 +19,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "../freeldr.h"
#include "../stdlib.h"
#include "../memory.h"
#include <freeldr.h>
#include <rtl.h>
#include <mm.h>
#include "registry.h"

View file

@ -25,9 +25,9 @@
* - Fix RegEnumValue().
*/
#include "../freeldr.h"
#include "../memory.h"
#include "../stdlib.h"
#include <freeldr.h>
#include <mm.h>
#include <rtl.h>
#include "registry.h"
#define NDEBUG

View file

@ -1,31 +0,0 @@
/*
* 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 __RS232_H
#define __RS232_H
BOOL Rs232PortInitialize(ULONG ComPort, ULONG BaudRate);
BOOL Rs232PortGetByte(PUCHAR ByteRecieved);
BOOL Rs232PortPollByte(PUCHAR ByteRecieved);
VOID Rs232PortPutByte(UCHAR ByteToSend);
#endif // defined __RS232_H

106
freeldr/freeldr/rtl.h Normal file
View file

@ -0,0 +1,106 @@
/*
* FreeLoader
* Copyright (C) 1999, 2000, 2001 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
* 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 __STDLIB_H
#define __STDLIB_H
#include <freeldr.h>
///////////////////////////////////////////////////////////////////////////////////////
//
// String Functions
//
///////////////////////////////////////////////////////////////////////////////////////
int strlen(char *str);
char * strcpy(char *dest, char *src);
char * strncpy(char *dest, char *src, size_t count);
char * strcat(char *dest, char *src);
char * strchr(const char *s, int c);
char * strrchr(const char *s, int c);
int strcmp(const char *string1, const char *string2);
int stricmp(const char *string1, const char *string2);
int strncmp(const char *string1, const char *string2, size_t length);
int _strnicmp(const char *string1, const char *string2, size_t length);
///////////////////////////////////////////////////////////////////////////////////////
//
// Memory Functions
//
///////////////////////////////////////////////////////////////////////////////////////
int RtlCompareMemory(const PVOID Source1, const PVOID Source2, ULONG Length);
VOID RtlCopyMemory(PVOID Destination, const PVOID Source, ULONG Length);
VOID RtlFillMemory(PVOID Destination, ULONG Length, UCHAR Fill);
VOID RtlZeroMemory(PVOID Destination, ULONG Length);
#define memcmp(buf1, buf2, count) RtlCompareMemory(buf1, buf2, count)
#define memcpy(dest, src, count) RtlCopyMemory(dest, src,count)
#define memset(dest, c, count) RtlFillMemory(dest,count, c)
///////////////////////////////////////////////////////////////////////////////////////
//
// Standard Library Functions
//
///////////////////////////////////////////////////////////////////////////////////////
int atoi(char *string);
char * itoa(int value, char *string, int radix);
int toupper(int c);
int tolower(int c);
int isspace(int c);
int isdigit(int c);
int isxdigit(int c);
char * convert_to_ascii(char *buf, int c, ...);
void putchar(int ch); // Implemented in asmcode.S
void clrscr(void); // Implemented in asmcode.S
int kbhit(void); // Implemented in asmcode.S
int getch(void); // Implemented in asmcode.S
void gotoxy(int x, int y); // Implemented in asmcode.S
int getyear(void); // Implemented in asmcode.S
int getday(void); // Implemented in asmcode.S
int getmonth(void); // Implemented in asmcode.S
int gethour(void); // Implemented in asmcode.S
int getminute(void); // Implemented in asmcode.S
int getsecond(void); // Implemented in asmcode.S
void hidecursor(void); // Implemented in asmcode.S
void showcursor(void); // Implemented in asmcode.S
int wherex(void); // Implemented in asmcode.S
int wherey(void); // Implemented in asmcode.S
///////////////////////////////////////////////////////////////////////////////////////
//
// Screen Output Functions
//
///////////////////////////////////////////////////////////////////////////////////////
void print(char *str);
void printf(char *fmt, ...);
void sprintf(char *buffer, char *format, ...);
#ifndef max
#define max(a, b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif
#endif // defined __STDLIB_H

View file

@ -0,0 +1,52 @@
#
# FreeLoader
# Copyright (C) 1999, 2000, 2001 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
# 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.
#
export CC = gcc
export LD = ld
export AR = ar
export RM = cmd /C del
export CP = cmd /C copy
FLAGS = -Wall -fno-builtin -I../ -DDEBUG -O3
OBJS = memory.o print.o stdlib.o string.o
.PHONY : clean
all: rtl.a
rtl.a: $(OBJS)
$(LD) -r -o rtl.a $(OBJS)
memory.o: memory.c ../rtl.h Makefile
$(CC) $(FLAGS) -o memory.o -c memory.c
print.o: print.c ../rtl.h Makefile
$(CC) $(FLAGS) -o print.o -c print.c
stdlib.o: stdlib.c ../rtl.h Makefile
$(CC) $(FLAGS) -o stdlib.o -c stdlib.c
string.o: string.c ../rtl.h Makefile
$(CC) $(FLAGS) -o string.o -c string.c
clean:
$(RM) *.o
$(RM) *.a

View file

@ -17,9 +17,51 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __MENU_H
#define __MENU_H
#include <freeldr.h>
BOOL DisplayMenu(PUCHAR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, PULONG SelectedMenuItem);
int RtlCompareMemory(const PVOID Source1, const PVOID Source2, ULONG Length)
{
ULONG i;
const PCHAR buffer1 = Source1;
const PCHAR buffer2 = Source2;
#endif // #defined __MENU_H
for (i=0; i<Length; i++)
{
if(buffer1[i] == buffer2[i])
continue;
else
return (buffer1[i] - buffer2[i]);
}
return 0;
}
VOID RtlCopyMemory(PVOID Destination, const PVOID Source, ULONG Length)
{
ULONG i;
PCHAR buf1 = Destination;
const PCHAR buf2 = Source;
for (i=0; i<Length; i++)
{
buf1[i] = buf2[i];
}
}
VOID RtlFillMemory(PVOID Destination, ULONG Length, UCHAR Fill)
{
ULONG i;
PUCHAR buf1 = Destination;
for (i=0; i<Length; i++)
{
buf1[i] = Fill;
}
}
VOID RtlZeroMemory(PVOID Destination, ULONG Length)
{
RtlFillMemory(Destination, Length, 0);
}

121
freeldr/freeldr/rtl/print.c Normal file
View file

@ -0,0 +1,121 @@
/*
* FreeLoader
* Copyright (C) 1999, 2000, 2001 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
* 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.
*/
#include <rtl.h>
/*
* print() - prints unformatted text to stdout
*/
void print(char *str)
{
int i;
for(i=0; i<strlen(str); i++)
putchar(str[i]);
}
/*
* printf() - prints formatted text to stdout
* from:
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
*/
void printf(char *format, ... )
{
int *dataptr = (int *) &format;
char c, *ptr, str[16];
dataptr++;
while ((c = *(format++)))
{
if (c != '%')
putchar(c);
else
switch (c = *(format++))
{
case 'd': case 'u': case 'x':
*convert_to_ascii(str, c, *((unsigned long *) dataptr++)) = 0;
ptr = str;
while (*ptr)
putchar(*(ptr++));
break;
case 'c': putchar((*(dataptr++))&0xff); break;
case 's':
ptr = (char *)(*(dataptr++));
while ((c = *(ptr++)))
putchar(c);
break;
}
}
}
void sprintf(char *buffer, char *format, ... )
{
int *dataptr = (int *) &format;
char c, *ptr, str[16];
char *p = buffer;
dataptr++;
while ((c = *(format++)))
{
if (c != '%')
{
*p = c;
p++;
}
else
switch (c = *(format++))
{
case 'd': case 'u': case 'x':
*convert_to_ascii(str, c, *((unsigned long *) dataptr++)) = 0;
ptr = str;
while (*ptr)
{
*p = *(ptr++);
p++;
}
break;
case 'c':
*p = (*(dataptr++))&0xff;
p++;
break;
case 's':
ptr = (char *)(*(dataptr++));
while ((c = *(ptr++)))
{
*p = c;
p++;
}
break;
}
}
*p=0;
}

View file

@ -0,0 +1,135 @@
/*
* FreeLoader
* Copyright (C) 1999, 2000, 2001 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
* 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.
*/
/*
* convert_to_ascii() - converts a number to it's ascii equivalent
* from:
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
*/
char *convert_to_ascii(char *buf, int c, ...)
{
unsigned long num = *((&c) + 1), mult = 10;
char *ptr = buf;
if (c == 'x')
mult = 16;
if ((num & 0x80000000uL) && c == 'd')
{
num = (~num)+1;
*(ptr++) = '-';
buf++;
}
do
{
int dig = num % mult;
*(ptr++) = ( (dig > 9) ? dig + 'a' - 10 : '0' + dig );
}
while (num /= mult);
/* reorder to correct direction!! */
{
char *ptr1 = ptr-1;
char *ptr2 = buf;
while (ptr1 > ptr2)
{
int c = *ptr1;
*ptr1 = *ptr2;
*ptr2 = c;
ptr1--;
ptr2++;
}
}
return ptr;
}
char *itoa(int value, char *string, int radix)
{
if(radix == 16)
*convert_to_ascii(string, 'x', value) = 0;
else
*convert_to_ascii(string, 'd', value) = 0;
return string;
}
int toupper(int c)
{
if((c >= 'a') && (c <= 'z'))
c -= 32;
return c;
}
int tolower(int c)
{
if((c >= 'A') && (c <= 'Z'))
c += 32;
return c;
}
int atoi(char *string)
{
int base;
int result = 0;
char *str;
if((string[0] == '0') && (string[1] == 'x'))
{
base = 16;
str = string + 2;
}
else
{
base = 10;
str = string;
}
while(1)
{
if((*str < '0') || (*str > '9'))
break;
result *= base;
result += (*str - '0');
str++;
}
return result;
}
int isspace(int c)
{
return(c == ' ' || (c >= 0x09 && c <= 0x0D));
}
int isdigit(int c)
{
return(c >= '0' && c <= '9');
}
int isxdigit(int c)
{
return((c >= '0' && c <= '9')||(c >= 'a' && c <= 'f')||(c >= 'A' && c <= 'F'));
}

View file

@ -0,0 +1,152 @@
/*
* FreeLoader
* Copyright (C) 1999, 2000, 2001 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
* 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.
*/
#include <rtl.h>
int strlen(char *str)
{
int len;
for(len=0; str[len] != '\0'; len++);
return len;
}
char *strcpy(char *dest, char *src)
{
char *ret = dest;
while(*src)
*dest++ = *src++;
*dest = 0;
return ret;
}
char *strncpy(char *dest, char *src, size_t count)
{
char *ret = dest;
while((*src) && (count--))
*dest++ = *src++;
*dest = 0;
return ret;
}
char *strcat(char *dest, char *src)
{
char *ret = dest;
while(*dest)
dest++;
while(*src)
*dest++ = *src++;
*dest = 0;
return ret;
}
char *strchr(const char *s, int c)
{
char cc = c;
while (*s)
{
if (*s == cc)
return (char *)s;
s++;
}
if (cc == 0)
return (char *)s;
return 0;
}
char *strrchr(const char *s, int c)
{
char cc = c;
const char *sp=(char *)0;
while (*s)
{
if (*s == cc)
sp = s;
s++;
}
if (cc == 0)
sp = s;
return (char *)sp;
}
int strcmp(const char *string1, const char *string2)
{
while(*string1 == *string2)
{
if(*string1 == 0)
return 0;
string1++;
string2++;
}
return *(unsigned const char *)string1 - *(unsigned const char *)(string2);
}
int stricmp(const char *string1, const char *string2)
{
while(tolower(*string1) == tolower(*string2))
{
if(*string1 == 0)
return 0;
string1++;
string2++;
}
return (int)tolower(*string1) - (int)tolower(*string2);
}
int _strnicmp(const char *string1, const char *string2, size_t length)
{
if (length == 0)
return 0;
do
{
if (toupper(*string1) != toupper(*string2++))
return toupper(*(unsigned const char *)string1) - toupper(*(unsigned const char *)--string2);
if (*string1++ == 0)
break;
}
while (--length != 0);
return 0;
}
int strncmp(const char *string1, const char *string2, size_t length)
{
if (length == 0)
return 0;
do
{
if (*string1 != *string2++)
return *(unsigned const char *)string1 - *(unsigned const char *)--string2;
if (*string1++ == 0)
break;
}
while (--length != 0);
return 0;
}

View file

@ -1,436 +0,0 @@
/*
* FreeLoader
* Copyright (C) 1999, 2000 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
* 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.
*/
#include "freeldr.h"
#include "stdlib.h"
/*
* print() - prints unformatted text to stdout
*/
void print(char *str)
{
int i;
for(i=0; i<strlen(str); i++)
putchar(str[i]);
}
/*
* convert_to_ascii() - converts a number to it's ascii equivalent
* from:
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
*/
char *convert_to_ascii(char *buf, int c, ...)
{
unsigned long num = *((&c) + 1), mult = 10;
char *ptr = buf;
if (c == 'x')
mult = 16;
if ((num & 0x80000000uL) && c == 'd')
{
num = (~num)+1;
*(ptr++) = '-';
buf++;
}
do
{
int dig = num % mult;
*(ptr++) = ( (dig > 9) ? dig + 'a' - 10 : '0' + dig );
}
while (num /= mult);
/* reorder to correct direction!! */
{
char *ptr1 = ptr-1;
char *ptr2 = buf;
while (ptr1 > ptr2)
{
int c = *ptr1;
*ptr1 = *ptr2;
*ptr2 = c;
ptr1--;
ptr2++;
}
}
return ptr;
}
/*
* printf() - prints formatted text to stdout
* from:
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org>
*/
void printf(char *format, ... )
{
int *dataptr = (int *) &format;
char c, *ptr, str[16];
dataptr++;
while ((c = *(format++)))
{
if (c != '%')
putchar(c);
else
switch (c = *(format++))
{
case 'd': case 'u': case 'x':
*convert_to_ascii(str, c, *((unsigned long *) dataptr++)) = 0;
ptr = str;
while (*ptr)
putchar(*(ptr++));
break;
case 'c': putchar((*(dataptr++))&0xff); break;
case 's':
ptr = (char *)(*(dataptr++));
while ((c = *(ptr++)))
putchar(c);
break;
}
}
}
void sprintf(char *buffer, char *format, ... )
{
int *dataptr = (int *) &format;
char c, *ptr, str[16];
char *p = buffer;
dataptr++;
while ((c = *(format++)))
{
if (c != '%')
{
*p = c;
p++;
}
else
switch (c = *(format++))
{
case 'd': case 'u': case 'x':
*convert_to_ascii(str, c, *((unsigned long *) dataptr++)) = 0;
ptr = str;
while (*ptr)
{
*p = *(ptr++);
p++;
}
break;
case 'c':
*p = (*(dataptr++))&0xff;
p++;
break;
case 's':
ptr = (char *)(*(dataptr++));
while ((c = *(ptr++)))
{
*p = c;
p++;
}
break;
}
}
*p=0;
}
int strlen(char *str)
{
int len;
for(len=0; str[len] != '\0'; len++);
return len;
}
char *itoa(int value, char *string, int radix)
{
if(radix == 16)
*convert_to_ascii(string, 'x', value) = 0;
else
*convert_to_ascii(string, 'd', value) = 0;
return string;
}
int toupper(int c)
{
if((c >= 'a') && (c <= 'z'))
c -= 32;
return c;
}
int tolower(int c)
{
if((c >= 'A') && (c <= 'Z'))
c += 32;
return c;
}
int memcmp(const void *buf1, const void *buf2, size_t count)
{
size_t i;
const char *buffer1 = buf1;
const char *buffer2 = buf2;
for(i=0; i<count; i++)
{
if(buffer1[i] == buffer2[i])
continue;
else
return (buffer1[i] - buffer2[i]);
}
return 0;
}
void *memcpy(void *dest, const void *src, size_t count)
{
size_t i;
char *buf1 = dest;
const char *buf2 = src;
for(i=0; i<count; i++)
buf1[i] = buf2[i];
return dest;
}
void *memset(void *dest, int c, size_t count)
{
size_t i;
char *buf1 = dest;
for(i=0; i<count; i++)
buf1[i] = c;
return dest;
}
char *strcpy(char *dest, char *src)
{
char *ret = dest;
while(*src)
*dest++ = *src++;
*dest = 0;
return ret;
}
char *strncpy(char *dest, char *src, size_t count)
{
char *ret = dest;
while((*src) && (count--))
*dest++ = *src++;
*dest = 0;
return ret;
}
char *strcat(char *dest, char *src)
{
char *ret = dest;
while(*dest)
dest++;
while(*src)
*dest++ = *src++;
*dest = 0;
return ret;
}
char *strchr(const char *s, int c)
{
char cc = c;
while (*s)
{
if (*s == cc)
return (char *)s;
s++;
}
if (cc == 0)
return (char *)s;
return 0;
}
char *strrchr(const char *s, int c)
{
char cc = c;
const char *sp=(char *)0;
while (*s)
{
if (*s == cc)
sp = s;
s++;
}
if (cc == 0)
sp = s;
return (char *)sp;
}
int strcmp(const char *string1, const char *string2)
{
while(*string1 == *string2)
{
if(*string1 == 0)
return 0;
string1++;
string2++;
}
return *(unsigned const char *)string1 - *(unsigned const char *)(string2);
}
int stricmp(const char *string1, const char *string2)
{
while(tolower(*string1) == tolower(*string2))
{
if(*string1 == 0)
return 0;
string1++;
string2++;
}
return (int)tolower(*string1) - (int)tolower(*string2);
}
int _strnicmp(const char *string1, const char *string2, size_t length)
{
if (length == 0)
return 0;
do
{
if (toupper(*string1) != toupper(*string2++))
return toupper(*(unsigned const char *)string1) - toupper(*(unsigned const char *)--string2);
if (*string1++ == 0)
break;
}
while (--length != 0);
return 0;
}
int strncmp(const char *string1, const char *string2, size_t length)
{
if (length == 0)
return 0;
do
{
if (*string1 != *string2++)
return *(unsigned const char *)string1 - *(unsigned const char *)--string2;
if (*string1++ == 0)
break;
}
while (--length != 0);
return 0;
}
char *fgets(char *string, int n, PFILE stream)
{
int i;
for(i=0; i<(n-1); i++)
{
if(IsEndOfFile(stream))
{
i++;
break;
}
ReadFile(stream, 1, NULL, string+i);
if(string[i] == '\n')
{
i++;
break;
}
}
string[i] = '\0';
return string;
}
int atoi(char *string)
{
int base;
int result = 0;
char *str;
if((string[0] == '0') && (string[1] == 'x'))
{
base = 16;
str = string + 2;
}
else
{
base = 10;
str = string;
}
while(1)
{
if((*str < '0') || (*str > '9'))
break;
result *= base;
result += (*str - '0');
str++;
}
return result;
}
int isspace(int c)
{
return(c == ' ' || (c >= 0x09 && c <= 0x0D));
}
int isdigit(int c)
{
return(c >= '0' && c <= '9');
}
int isxdigit(int c)
{
return((c >= '0' && c <= '9')||(c >= 'a' && c <= 'f')||(c >= 'A' && c <= 'F'));
}

View file

@ -1,93 +0,0 @@
/*
* FreeLoader
* Copyright (C) 1999, 2000 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
* 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 __STDLIB_H
#define __STDLIB_H
#include "fs.h"
void putchar(int ch); // Implemented in asmcode.S
void clrscr(void); // Implemented in asmcode.S
int kbhit(void); // Implemented in asmcode.S
int getch(void); // Implemented in asmcode.S
void gotoxy(int x, int y); // Implemented in asmcode.S
int getyear(void); // Implemented in asmcode.S
int getday(void); // Implemented in asmcode.S
int getmonth(void); // Implemented in asmcode.S
int gethour(void); // Implemented in asmcode.S
int getminute(void); // Implemented in asmcode.S
int getsecond(void); // Implemented in asmcode.S
void hidecursor(void); // Implemented in asmcode.S
void showcursor(void); // Implemented in asmcode.S
int wherex(void); // Implemented in asmcode.S
int wherey(void); // Implemented in asmcode.S
int strlen(char *str);
char *strcpy(char *dest, char *src);
char *strncpy(char *dest, char *src, size_t count);
char *strcat(char *dest, char *src);
char *strchr(const char *s, int c);
char *strrchr(const char *s, int c);
int strcmp(const char *string1, const char *string2);
int stricmp(const char *string1, const char *string2);
int strncmp(const char *string1, const char *string2, size_t length);
int _strnicmp(const char *string1, const char *string2, size_t length);
char *itoa(int value, char *string, int radix);
int toupper(int c);
int tolower(int c);
int memcmp(const void *buf1, const void *buf2, size_t count);
void *memcpy(void *dest, const void *src, size_t count);
void *memset(void *dest, int c, size_t count);
char *fgets(char *string, int n, PFILE stream);
int atoi(char *string);
#define ZeroMemory(Destination, Length) memset(Destination, 0, Length)
int isspace(int c);
int isdigit(int c);
int isxdigit(int c);
void print(char *str);
void printf(char *fmt, ...);
void sprintf(char *buffer, char *format, ...);
char *convert_to_ascii(char *buf, int c, ...);
int biosdisk(int cmd, int drive, int head, int track, int sector, int nsects, void *buffer); // Implemented in asmcode.S
BOOL BiosInt13Read(ULONG Drive, ULONG Head, ULONG Track, ULONG Sector, ULONG SectorCount, PVOID Buffer); // Implemented in asmcode.S
BOOL BiosInt13ReadExtended(ULONG Drive, ULONG Sector, ULONG SectorCount, PVOID Buffer); // Implemented in asmcode.S
BOOL BiosInt13ExtensionsSupported(ULONG Drive);
void stop_floppy(void); // Implemented in asmcode.S
int get_heads(int drive); // Implemented in asmcode.S
int get_cylinders(int drive); // Implemented in asmcode.S
int get_sectors(int drive); // Implemented in asmcode.S
#ifndef max
#define max(a, b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif
#endif // defined __STDLIB_H

View file

@ -143,4 +143,13 @@ void DrawProgressBar(int nPos);
#define KEY_F9 0x43
#define KEY_F10 0x44
///////////////////////////////////////////////////////////////////////////////////////
//
// Menu Functions
//
///////////////////////////////////////////////////////////////////////////////////////
BOOL DisplayMenu(PUCHAR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, PULONG SelectedMenuItem);
#endif // #defined __TUI_H

View file

@ -0,0 +1,46 @@
#
# FreeLoader
# Copyright (C) 1999, 2000, 2001 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
# 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.
#
export CC = gcc
export LD = ld
export AR = ar
export RM = cmd /C del
export CP = cmd /C copy
FLAGS = -Wall -fno-builtin -I../ -DDEBUG -O3
OBJS = tui.o menu.o
.PHONY : clean
all: ui.a
ui.a: $(OBJS)
$(LD) -r -o ui.a $(OBJS)
tui.o: tui.c ../ui.h Makefile
$(CC) $(FLAGS) -o tui.o -c tui.c
menu.o: menu.c ../ui.h Makefile
$(CC) $(FLAGS) -o menu.o -c menu.c
clean:
$(RM) *.o
$(RM) *.a

View file

@ -17,12 +17,11 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "freeldr.h"
#include "stdlib.h"
#include "tui.h"
#include "menu.h"
#include "options.h"
#include "memory.h"
#include <freeldr.h>
#include <rtl.h>
#include <ui.h>
#include <options.h>
#include <mm.h>
typedef struct

View file

@ -17,12 +17,12 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "freeldr.h"
#include "stdlib.h"
#include "tui.h"
#include "memory.h"
#include "debug.h"
#include "parseini.h"
#include <freeldr.h>
#include <rtl.h>
#include <ui.h>
#include <mm.h>
#include <debug.h>
#include <parseini.h>
ULONG nScreenWidth = 80; // Screen Width
ULONG nScreenHeight = 25; // Screen Height