mirror of
https://github.com/reactos/reactos
synced 2025-10-08 09:22:51 +02:00
Compare commits
28 Commits
backups/ne
...
ReactOS-0.
Author | SHA1 | Date | |
---|---|---|---|
|
13a047a566 | ||
|
834ee7b3fe | ||
|
607690ba55 | ||
|
88e0297e69 | ||
|
a627f8d061 | ||
|
820c67f8ba | ||
|
73f101de0b | ||
|
1c7116cc73 | ||
|
40528bf1be | ||
|
ee1890ff77 | ||
|
7fe7da7475 | ||
|
5a10cf1de5 | ||
|
b192bb32af | ||
|
501c4bcc5c | ||
|
09b7ae5383 | ||
|
add1e4db72 | ||
|
291ec67723 | ||
|
e97e0f5976 | ||
|
583e4a7baf | ||
|
fdc1ba6a56 | ||
|
1b2fc59dc1 | ||
|
d4a3555442 | ||
|
abc01da30c | ||
|
7aeca22fed | ||
|
36e1bb60e8 | ||
|
74e77bb16f | ||
|
e3a75fb4da | ||
|
ce122bcdea |
@@ -51,7 +51,8 @@
|
||||
; [OS-General] Section Commands:
|
||||
;
|
||||
; BootType - sets the boot type: ReactOS, Linux, BootSector, Partition, Drive
|
||||
; BootPath - ARC path e.g. multi(0)disk(0)rdisk(x)partition(y)
|
||||
; BootDrive - sets the boot drive: 0 - first floppy, 1 - second floppy, 0x80 - first hard disk, 0x81 - second hard disk
|
||||
; BootPartition - sets the boot partition
|
||||
; DriveMap - maps a BIOS drive number to another (i.e. DriveMap=hd1,hd0 maps harddisk1 to harddisk0 or DriveMap=fd1,fd0)
|
||||
|
||||
; [BootSector OSType] Section Commands:
|
||||
@@ -133,7 +134,8 @@ Hal=\reactos\HAL.DLL
|
||||
|
||||
[Linux]
|
||||
BootType=Linux
|
||||
BootPath=multi(0)disk(0)rdisk(1)partition(1)
|
||||
BootDrive=hd1
|
||||
BootPartition=1
|
||||
Kernel=/vmlinuz
|
||||
Initrd=/initrd.img
|
||||
CommandLine="root=/dev/sdb1"
|
||||
@@ -144,11 +146,13 @@ BootDrive=fd0
|
||||
|
||||
[MSWinders]
|
||||
BootType=Partition
|
||||
BootPath=multi(0)disk(0)rdisk(0)partition(1)
|
||||
BootDrive=hd0
|
||||
BootPartition=1
|
||||
;DriveMap=hd1,hd0
|
||||
;DriveMap=hd2,hd0
|
||||
;DriveMap=hd3,hd0
|
||||
|
||||
[DriveD]
|
||||
BootType=Partition
|
||||
BootPath=multi(0)disk(0)rdisk(1)partition(1)
|
||||
BootDrive=hd1
|
||||
BootPartition=1
|
45
freeldr/Makefile
Normal file
45
freeldr/Makefile
Normal file
@@ -0,0 +1,45 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# Windows is default host environment
|
||||
ifeq ($(HOST),)
|
||||
HOST = mingw32-windows
|
||||
endif
|
||||
|
||||
include rules.mak
|
||||
|
||||
all:
|
||||
$(MAKE) -C tools
|
||||
$(MAKE) -C bootsect
|
||||
$(MAKE) -C freeldr
|
||||
$(MAKE) -C install
|
||||
$(MAKE) -C fdebug
|
||||
|
||||
freeldr:
|
||||
$(MAKE) -C freeldr
|
||||
.PHONY : freeldr
|
||||
|
||||
clean:
|
||||
$(MAKE) -C bootsect clean
|
||||
$(MAKE) -C freeldr clean
|
||||
$(MAKE) -C install clean
|
||||
$(MAKE) -C fdebug clean
|
||||
$(MAKE) -C tools clean
|
||||
|
||||
.PHONY : clean
|
3
freeldr/bootsect/.cvsignore
Normal file
3
freeldr/bootsect/.cvsignore
Normal file
@@ -0,0 +1,3 @@
|
||||
*.exe
|
||||
*.bin
|
||||
*.h
|
76
freeldr/bootsect/Makefile
Normal file
76
freeldr/bootsect/Makefile
Normal file
@@ -0,0 +1,76 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
BOOTCD_DIR = ../../bootcd
|
||||
|
||||
.PHONY : clean bootcd
|
||||
|
||||
all: $(BIN2C) dosmbr.bin fat.bin fat32.bin isoboot.bin ext2.bin
|
||||
|
||||
|
||||
$(BIN2C) :
|
||||
@$(MAKE) --no-print-directory -C $(TOOLSDIR)
|
||||
|
||||
dosmbr.bin : dosmbr.asm
|
||||
@echo ===================================================== Assembling dosmbr
|
||||
@$(NASM_CMD) $(NFLAGS) -o dosmbr.bin -f bin dosmbr.asm
|
||||
|
||||
fat.bin : fat.asm $(BIN2C)
|
||||
@echo ===================================================== Assembling fat
|
||||
@$(NASM_CMD) $(NFLAGS) -o fat.bin -f bin fat.asm
|
||||
@$(BIN2C) fat.bin fat.h fat_data
|
||||
|
||||
|
||||
fat32.bin : fat32.asm $(BIN2C)
|
||||
@echo ===================================================== Assembling fat32
|
||||
@$(NASM_CMD) $(NFLAGS) -o fat32.bin -f bin fat32.asm
|
||||
@$(BIN2C) fat32.bin fat32.h fat32_data
|
||||
|
||||
isoboot.bin : isoboot.asm
|
||||
@echo ===================================================== Assembling isoboot
|
||||
@$(NASM_CMD) $(NFLAGS) -o isoboot.bin -f bin isoboot.asm
|
||||
|
||||
ext2.bin : ext2.asm
|
||||
@echo ===================================================== Assembling ext2
|
||||
@$(NASM_CMD) $(NFLAGS) -o ext2.bin -f bin ext2.asm
|
||||
@$(BIN2C) ext2.bin ext2.h ext2_data
|
||||
|
||||
|
||||
.PHONY : bootcd
|
||||
bootcd: bootcd_dirs isoboot.bin
|
||||
$(CP) isoboot.bin $(BOOTCD_DIR)
|
||||
$(CP) dosmbr.bin $(BOOTCD_DIR)/disk/loader
|
||||
$(CP) ext2.bin $(BOOTCD_DIR)/disk/loader
|
||||
$(CP) fat.bin $(BOOTCD_DIR)/disk/loader
|
||||
$(CP) fat32.bin $(BOOTCD_DIR)/disk/loader
|
||||
$(CP) isoboot.bin $(BOOTCD_DIR)/disk/loader
|
||||
|
||||
.PHONY : bootcd_dirs
|
||||
bootcd_dirs:
|
||||
$(MKDIR) $(BOOTCD_DIR)
|
||||
$(MKDIR) $(BOOTCD_DIR)/disk
|
||||
$(MKDIR) $(BOOTCD_DIR)/disk/reactos
|
||||
$(MKDIR) $(BOOTCD_DIR)/disk/install
|
||||
$(MKDIR) $(BOOTCD_DIR)/disk/bootdisk
|
||||
$(MKDIR) $(BOOTCD_DIR)/disk/loader
|
||||
|
||||
clean:
|
||||
@-$(RM) *.bin
|
||||
@-$(RM) *.h
|
||||
@echo Clean ALL done.
|
@@ -89,6 +89,9 @@ main:
|
||||
mov es,ax ; Make ES correct
|
||||
|
||||
|
||||
cmp BYTE [BYTE bp+BootDrive],BYTE 0xff ; If they have specified a boot drive then use it
|
||||
jne GetDriveParameters
|
||||
|
||||
mov [BYTE bp+BootDrive],dl ; Save the boot drive
|
||||
|
||||
|
49
freeldr/fdebug/Makefile
Normal file
49
freeldr/fdebug/Makefile
Normal file
@@ -0,0 +1,49 @@
|
||||
#
|
||||
# FreeLoader
|
||||
# Copyright (C) 1999 - 2003 Brian Palmer <brianp@sginet.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# 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.
|
||||
#
|
||||
|
||||
|
||||
FLAGS = -Wall
|
||||
|
||||
OBJS = rs232.o fdebug.o fdebug.res
|
||||
|
||||
.PHONY : clean
|
||||
|
||||
all: fdebug.exe
|
||||
|
||||
fdebug.exe: $(OBJS)
|
||||
@echo ===================================================== LINKING fdebug
|
||||
$(CC) $(FLAGS) -o fdebug.exe $(OBJS) -lgdi32 -lcomdlg32 -Wl,--subsystem,windows
|
||||
|
||||
fdebug.res: fdebug.rc resource.h
|
||||
@echo ===================================================== Compiling $*
|
||||
$(WINDRES) -o fdebug.res fdebug.rc -O coff
|
||||
|
||||
fdebug.o: fdebug.c rs232.h
|
||||
@echo ===================================================== Compiling $*
|
||||
$(CC) $(FLAGS) -o fdebug.o -c fdebug.c
|
||||
|
||||
rs232.o: rs232.c rs232.h
|
||||
@echo ===================================================== Compiling $*
|
||||
$(CC) $(FLAGS) -o rs232.o -c rs232.c
|
||||
|
||||
clean:
|
||||
@-$(RM) *.o
|
||||
@-$(RM) *.res
|
||||
@-$(RM) *.exe
|
||||
@echo Clean ALL done.
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -1,9 +1,3 @@
|
||||
Changes in v2.0.0 (02/07/2005) (alex ionesco)
|
||||
|
||||
- PE loading of ntoskrnl.exe
|
||||
- Work on 3GB support
|
||||
- w32api conversion
|
||||
|
||||
Changes in v1.8.26 (10/30/2004) (chorns)
|
||||
|
||||
- Print stack frames on crashes.
|
413
freeldr/freeldr/Makefile
Normal file
413
freeldr/freeldr/Makefile
Normal file
@@ -0,0 +1,413 @@
|
||||
#
|
||||
# FreeLoader
|
||||
# Copyright (C) 1998-2002 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.
|
||||
#
|
||||
|
||||
#############################################
|
||||
# CHANGE THESE FOR YOUR OUTPUT
|
||||
#
|
||||
TARGET = i386
|
||||
ifeq ($(DEBUG),)
|
||||
# Debugging information on (bigger binary)
|
||||
#DEBUG = yes
|
||||
# Debugging information off (smaller binary)
|
||||
DEBUG = no
|
||||
endif
|
||||
|
||||
OBJDIR = obj
|
||||
OUTPUT_DIR = $(OBJDIR)/$(TARGET)
|
||||
|
||||
BOOTCD_DIR = ../../bootcd
|
||||
|
||||
#############################################
|
||||
# COMPILER AND LINKER PROGRAMS
|
||||
#
|
||||
TOOLSDIR = $(SRCDIR)/../tools
|
||||
|
||||
RM = $(subst /,$(SEP),$(TOOLSDIR))$(SEP)rdel
|
||||
CP = $(subst /,$(SEP),$(TOOLSDIR))$(SEP)rcopy
|
||||
MKDIR = $(subst /,$(SEP),$(TOOLSDIR))$(SEP)rmkdir
|
||||
RMDIR = $(subst /,$(SEP),$(TOOLSDIR))$(SEP)rrmdir
|
||||
OBJCOPY = objcopy
|
||||
NM = nm
|
||||
OBJDUMP = objdump
|
||||
DEPTOOL = $(subst /,$(SEP),$(TOOLSDIR))$(SEP)deptool
|
||||
HOSTTOOL = $(subst /,$(SEP),$(TOOLSDIR))$(SEP)hosttype
|
||||
TOOLS = $(DEPTOOL) $(HOSTTOOL)
|
||||
|
||||
HOSTTYPE = $(shell $(HOSTTOOL))
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------
|
||||
# TEST IF WE ARE IN THE TARGET DIRECTORY
|
||||
# IF NOT WE WILL CHANGE TO THE TARGET DIRECTORY AND RUN MAKE FROM THERE
|
||||
#-----------------------------------------------------------------------------------------------------
|
||||
#ifeq (,$(filter $(CURDIR)/$(OUTPUT_DIR),$(notdir $(CURDIR))))
|
||||
ifneq ($(CURDIR), $(SRCDIR)/$(OUTPUT_DIR))
|
||||
|
||||
SRCDIR = $(CURDIR)
|
||||
|
||||
.SUFFIXES:
|
||||
|
||||
#############################################
|
||||
# VARIABLE TO CHANGE TO TARGET DIRECTORY AND INVOKE MAKE FROM THERE
|
||||
#
|
||||
MAKETARGET = $(MAKE) --no-print-directory -C $(OUTPUT_DIR) \
|
||||
-f ../../Makefile SRCDIR=$(CURDIR) $(MAKECMDGOALS)
|
||||
|
||||
.PHONY: CHANGE_TO_TARGET
|
||||
CHANGE_TO_TARGET setupldr : BUILD_TOOLS $(OBJDIR) $(OBJDIR)/$(TARGET)
|
||||
@echo Calculating source file dependencies...
|
||||
+@$(MAKETARGET)
|
||||
|
||||
.PHONY: BUILD_TOOLS
|
||||
BUILD_TOOLS:
|
||||
@$(MAKE) --no-print-directory -C $(TOOLSDIR)
|
||||
|
||||
$(OBJDIR):
|
||||
@echo Creating directory: $(OBJDIR)
|
||||
@$(MKDIR) $(OBJDIR)
|
||||
|
||||
$(OBJDIR)/$(TARGET): $(OBJDIR)
|
||||
@echo Creating directory: $(OBJDIR)/$(TARGET)
|
||||
@$(MKDIR) $(OBJDIR)/$(TARGET)
|
||||
|
||||
|
||||
Makefile : ;
|
||||
|
||||
% :: CHANGE_TO_TARGET
|
||||
|
||||
#############################################
|
||||
|
||||
.PHONY : clean
|
||||
clean:
|
||||
@$(MAKE) --no-print-directory -C $(TOOLSDIR)
|
||||
@echo Cleaning directory $(OBJDIR)/$(TARGET)
|
||||
@-$(RM) $(OBJDIR)/$(TARGET)/*
|
||||
@echo Removing directory $(OBJDIR)/$(TARGET)
|
||||
@-$(RMDIR) $(OBJDIR)/$(TARGET)
|
||||
@-$(RMDIR) $(OBJDIR)
|
||||
@echo Clean ALL done.
|
||||
|
||||
#############################################
|
||||
|
||||
.PHONY : bootcd
|
||||
bootcd : bootcd_dirs setup_loader boot_loader
|
||||
|
||||
.PHONY : bootcd_dirs
|
||||
bootcd_dirs:
|
||||
$(MKDIR) $(BOOTCD_DIR)
|
||||
$(MKDIR) $(BOOTCD_DIR)/disk
|
||||
$(MKDIR) $(BOOTCD_DIR)/disk/reactos
|
||||
$(MKDIR) $(BOOTCD_DIR)/disk/install
|
||||
$(MKDIR) $(BOOTCD_DIR)/disk/bootdisk
|
||||
$(MKDIR) $(BOOTCD_DIR)/disk/loader
|
||||
|
||||
.PHONY : boot_loader
|
||||
boot_loader : $(OBJDIR)/$(TARGET)/freeldr.sys
|
||||
$(CP) $(OBJDIR)/$(TARGET)/freeldr.sys $(BOOTCD_DIR)/disk/loader/freeldr.sys
|
||||
$(CP) ../freeldr.ini $(BOOTCD_DIR)/disk/loader/freeldr.ini
|
||||
|
||||
.PHONY : setup_loader
|
||||
setup_loader : $(OBJDIR)/$(TARGET)/setupldr.sys
|
||||
$(CP) $(OBJDIR)/$(TARGET)/setupldr.sys $(BOOTCD_DIR)/disk/loader/setupldr.sys
|
||||
|
||||
#############################################
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------
|
||||
# END MAGIC TARGET DIRECTORY CHANGE STUFF
|
||||
#-----------------------------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
#############################################
|
||||
# COMPILER COMMAND LINE OPTIONS
|
||||
#
|
||||
COMPILER_OPTIONS = -Wall -Werror -nostdlib -nostdinc -ffreestanding -fno-builtin -fno-inline \
|
||||
-fno-zero-initialized-in-bss -O1 -MD
|
||||
# FreeLoader does not use any of the standard libraries, includes, or built-in functions
|
||||
|
||||
#############################################
|
||||
# COMPILER DEFINES
|
||||
#
|
||||
ifeq ($(DEBUG),yes)
|
||||
COMPILER_DEBUG_DEFINES = -DDEBUG
|
||||
else
|
||||
COMPILER_DEBUG_DEFINES =
|
||||
endif
|
||||
|
||||
COMPILER_DEFINES = -D__$(TARGET)__ $(COMPILER_DEBUG_DEFINES)
|
||||
|
||||
#############################################
|
||||
# INCLUDE DIRECTORY OPTIONS
|
||||
#
|
||||
COMPILER_INCLUDES = -I$(SRCDIR)/include
|
||||
|
||||
#############################################
|
||||
# COMPILER FLAGS
|
||||
#
|
||||
CFLAGS = $(COMPILER_OPTIONS) \
|
||||
$(COMPILER_DEFINES) \
|
||||
$(COMPILER_INCLUDES)
|
||||
|
||||
#############################################
|
||||
# LINKER COMMAND LINE OPTIONS
|
||||
#
|
||||
#LINKER_OPTIONS = -N -Ttext=0x8000 --oformat=binary -s
|
||||
LINKER_OPTIONS = -N -Ttext=0x8000
|
||||
|
||||
#############################################
|
||||
# LINKER FLAGS
|
||||
#
|
||||
LFLAGS = $(LINKER_OPTIONS)
|
||||
|
||||
#############################################
|
||||
# NASM FLAGS
|
||||
#
|
||||
ifeq ($(HOSTTYPE), dos)
|
||||
NASMFLAGS = -f coff
|
||||
else
|
||||
ifeq ($(HOSTTYPE), win32)
|
||||
NASMFLAGS = -f win32
|
||||
else
|
||||
NASMFLAGS = -f elf
|
||||
endif
|
||||
endif
|
||||
|
||||
#############################################
|
||||
# LIST ALL THE OBJECT FILE GROUPS
|
||||
#
|
||||
# fathelp.o must come first in the link line because it contains bootsector helper code
|
||||
# arch.o must come second in the link line because it contains the startup code
|
||||
ARCH_OBJS = fathelp.o \
|
||||
arch.o \
|
||||
i386idt.o \
|
||||
i386trap.o \
|
||||
i386cpu.o \
|
||||
i386pnp.o \
|
||||
boot.o \
|
||||
linux.o \
|
||||
mb.o \
|
||||
i386rtl.o \
|
||||
i386vid.o \
|
||||
drvmap.o \
|
||||
int386.o \
|
||||
i386disk.o \
|
||||
portio.o \
|
||||
hardware.o \
|
||||
hwacpi.o \
|
||||
hwapm.o \
|
||||
hwcpu.o \
|
||||
hwpci.o \
|
||||
archmach.o \
|
||||
machpc.o \
|
||||
machxbox.o \
|
||||
pccons.o \
|
||||
pcdisk.o \
|
||||
pcmem.o \
|
||||
pcrtc.o \
|
||||
pcvideo.o \
|
||||
xboxcons.o \
|
||||
xboxdisk.o \
|
||||
xboxfont.o \
|
||||
xboxhw.o \
|
||||
xboxmem.o \
|
||||
xboxrtc.o \
|
||||
xboxvideo.o \
|
||||
_alloca.o # For Mingw32 builds
|
||||
|
||||
|
||||
RTL_OBJS = print.o \
|
||||
stdlib.o \
|
||||
string.o \
|
||||
list.o \
|
||||
memcmp.o \
|
||||
memcpy.o \
|
||||
memmove.o \
|
||||
memset.o
|
||||
|
||||
FS_OBJS = fs.o \
|
||||
fat.o \
|
||||
iso.o \
|
||||
ext2.o \
|
||||
ntfs.o \
|
||||
fsrec.o
|
||||
|
||||
UI_OBJS = tui.o \
|
||||
tuimenu.o \
|
||||
ui.o \
|
||||
gui.o
|
||||
|
||||
REACTOS_OBJS= arcname.o \
|
||||
binhive.o \
|
||||
registry.o
|
||||
|
||||
COMM_OBJS = rs232.o
|
||||
|
||||
DISK_OBJS = disk.o \
|
||||
partition.o
|
||||
|
||||
MM_OBJS = mm.o \
|
||||
meminit.o
|
||||
|
||||
CACHE_OBJS = cache.o \
|
||||
blocklist.o
|
||||
|
||||
INIFILE_OBJS= inifile.o \
|
||||
ini_init.o \
|
||||
parse.o
|
||||
|
||||
INFFILE_OBJS= inffile.o
|
||||
|
||||
VIDEO_OBJS = video.o \
|
||||
fade.o \
|
||||
palette.o \
|
||||
pixel.o \
|
||||
bank.o
|
||||
|
||||
# libgcc2.o contains code (__udivdi3, __umoddi3) necessary to do
|
||||
# 64-bit division on the i386 (and other 32-bit) architectures
|
||||
# This code was taken from the GCC v3.1 source
|
||||
MATH_OBJS = libgcc2.o
|
||||
|
||||
BASE_OBJS = freeldr.o \
|
||||
debug.o \
|
||||
multiboot.o \
|
||||
version.o \
|
||||
cmdline.o \
|
||||
machine.o
|
||||
|
||||
FREELDR_OBJS= bootmgr.o \
|
||||
drivemap.o \
|
||||
miscboot.o \
|
||||
options.o \
|
||||
linuxboot.o \
|
||||
oslist.o \
|
||||
custom.o
|
||||
|
||||
ROSLDR_OBJS = reactos.o
|
||||
|
||||
SETUPLDR_OBJS= setupldr.o
|
||||
|
||||
COMMON_OBJS = $(ARCH_OBJS) \
|
||||
$(RTL_OBJS) \
|
||||
$(FS_OBJS) \
|
||||
$(UI_OBJS) \
|
||||
$(REACTOS_OBJS) \
|
||||
$(COMM_OBJS) \
|
||||
$(DISK_OBJS) \
|
||||
$(MM_OBJS) \
|
||||
$(CACHE_OBJS) \
|
||||
$(VIDEO_OBJS) \
|
||||
$(MATH_OBJS) \
|
||||
$(BASE_OBJS)
|
||||
|
||||
SPECIAL_OBJS = $(INIFILE_OBJS) \
|
||||
$(INFFILE_OBJS) \
|
||||
$(FREELDR_OBJS) \
|
||||
$(ROSLDR_OBJS) \
|
||||
$(SETUPLDR_OBJS)
|
||||
|
||||
|
||||
F_OBJS = $(COMMON_OBJS) \
|
||||
$(INIFILE_OBJS) \
|
||||
$(ROSLDR_OBJS) \
|
||||
$(FREELDR_OBJS)
|
||||
|
||||
S_OBJS = $(COMMON_OBJS) \
|
||||
$(INIFILE_OBJS) \
|
||||
$(INFFILE_OBJS) \
|
||||
$(SETUPLDR_OBJS)
|
||||
|
||||
|
||||
#############################################
|
||||
# ALL THE OBJECTS
|
||||
#
|
||||
ALL_OBJS = $(COMMON_OBJS) \
|
||||
$(SPECIAL_OBJS)
|
||||
|
||||
|
||||
#############################################
|
||||
# SET THE VPATH SO MAKE CAN FIND THE SOURCE FILES
|
||||
#
|
||||
VPATH = $(SRCDIR)/ \
|
||||
$(SRCDIR)/arch/$(TARGET) \
|
||||
$(SRCDIR)/rtl \
|
||||
$(SRCDIR)/fs \
|
||||
$(SRCDIR)/ui \
|
||||
$(SRCDIR)/reactos \
|
||||
$(SRCDIR)/comm \
|
||||
$(SRCDIR)/disk \
|
||||
$(SRCDIR)/mm \
|
||||
$(SRCDIR)/cache \
|
||||
$(SRCDIR)/inifile \
|
||||
$(SRCDIR)/inffile \
|
||||
$(SRCDIR)/video \
|
||||
$(SRCDIR)/math \
|
||||
$(SRCDIR)/include
|
||||
|
||||
#############################################
|
||||
|
||||
all : freeldr.sys setupldr.sys
|
||||
@echo Make ALL done.
|
||||
|
||||
#############################################
|
||||
|
||||
freeldr.sys : $(ALL_OBJS)
|
||||
@echo ===================================================== LINKING $@
|
||||
@$(LD) $(LFLAGS) -o freeldr.exe $(F_OBJS)
|
||||
ifeq ($(FULL_MAP),yes)
|
||||
@$(OBJDUMP) -d -S freeldr.exe > freeldr.map
|
||||
else
|
||||
@$(NM) --numeric-sort freeldr.exe > freeldr.map
|
||||
endif
|
||||
@$(OBJCOPY) -O binary freeldr.exe freeldr.sys
|
||||
|
||||
#############################################
|
||||
|
||||
setupldr.sys : $(ALL_OBJS)
|
||||
@echo ===================================================== LINKING $@
|
||||
@$(LD) $(LFLAGS) -Map setupldr.map -o setupldr.exe $(S_OBJS)
|
||||
ifeq ($(FULL_MAP),yes)
|
||||
@$(OBJDUMP) -d -S setupldr.exe > setupldr.map
|
||||
else
|
||||
@$(NM) --numeric-sort setupldr.exe > setupldr.map
|
||||
endif
|
||||
@$(OBJCOPY) -O binary setupldr.exe setupldr.sys
|
||||
|
||||
#############################################
|
||||
|
||||
%.o :: %.c
|
||||
@echo ===================================================== Compiling $*
|
||||
@$(CC) $(CFLAGS) -o $@ -c $<
|
||||
@$(DEPTOOL) $*.d
|
||||
|
||||
%.o :: %.S
|
||||
@echo ===================================================== Assembling $*
|
||||
@$(CC) $(CFLAGS) -o $@ -c $<
|
||||
@$(DEPTOOL) $*.d
|
||||
|
||||
%.o :: %.asm
|
||||
@echo ===================================================== Assembling $*
|
||||
@$(NASM_CMD) $(NASMFLAGS) -o $@ $<
|
||||
|
||||
#############################################
|
||||
|
||||
# Include the automagically generated dependencies
|
||||
-include $(ALL_OBJS:%.o=%.d)
|
||||
|
||||
#############################################
|
||||
|
||||
endif
|
@@ -47,10 +47,10 @@ EXTERN(RealEntryPoint)
|
||||
.code32
|
||||
|
||||
/* Store the boot drive */
|
||||
movb %dl,(_i386BootDrive)
|
||||
movb %dl,(_BootDrive)
|
||||
|
||||
/* Store the boot partition */
|
||||
movb %dh,(_i386BootPartition)
|
||||
movb %dh,(_BootPartition)
|
||||
|
||||
/* GO! */
|
||||
xorl %eax,%eax
|
||||
@@ -275,11 +275,9 @@ EXTERN(_DisableA20)
|
||||
* other boot loaders like Grub
|
||||
*/
|
||||
|
||||
#define MB_INFO_SIZE 90
|
||||
#define MB_INFO_FLAGS_OFFSET 0
|
||||
#define MB_INFO_BOOT_DEVICE_OFFSET 12
|
||||
#define MB_INFO_COMMAND_LINE_OFFSET 16
|
||||
#define CMDLINE_SIZE 256
|
||||
|
||||
/*
|
||||
* We want to execute at 0x8000 (to be compatible with bootsector
|
||||
@@ -287,6 +285,7 @@ EXTERN(_DisableA20)
|
||||
* above 1MB. So we let Grub load us there and then relocate
|
||||
* ourself to 0x8000
|
||||
*/
|
||||
#define CMDLINE_BASE 0x7000
|
||||
#define FREELDR_BASE 0x8000
|
||||
#define INITIAL_BASE 0x200000
|
||||
|
||||
@@ -329,31 +328,6 @@ mb1:
|
||||
movw %dx,%ds
|
||||
movw %dx,%es
|
||||
|
||||
/* Check for valid multiboot signature */
|
||||
cmpl $MULTIBOOT_BOOTLOADER_MAGIC,%eax
|
||||
jne mbfail
|
||||
|
||||
/* Store multiboot info in a safe place */
|
||||
movl %ebx,%esi
|
||||
movl $(mb_info + INITIAL_BASE - FREELDR_BASE),%edi
|
||||
movl $MB_INFO_SIZE,%ecx
|
||||
rep movsb
|
||||
|
||||
/* Save commandline */
|
||||
movl MB_INFO_FLAGS_OFFSET(%ebx),%edx
|
||||
testl $MB_INFO_FLAG_COMMAND_LINE,MB_INFO_FLAGS_OFFSET(%ebx)
|
||||
jz mb3
|
||||
movl MB_INFO_COMMAND_LINE_OFFSET(%ebx),%esi
|
||||
movl $(cmdline + INITIAL_BASE - FREELDR_BASE),%edi
|
||||
movl $CMDLINE_SIZE,%ecx
|
||||
mb2: lodsb
|
||||
stosb
|
||||
testb %al,%al
|
||||
jz mb3
|
||||
dec %ecx
|
||||
jnz mb2
|
||||
mb3:
|
||||
|
||||
/* Copy to low mem */
|
||||
movl $INITIAL_BASE,%esi
|
||||
movl $FREELDR_BASE,%edi
|
||||
@@ -368,8 +342,8 @@ mb3:
|
||||
|
||||
/* Clear prefetch queue & correct CS,
|
||||
* jump to low mem */
|
||||
ljmp $PMODE_CS, $mb4
|
||||
mb4:
|
||||
ljmp $PMODE_CS, $mb2
|
||||
mb2:
|
||||
/* Reload segment selectors */
|
||||
movw $PMODE_DS,%dx
|
||||
movw %dx,%ds
|
||||
@@ -379,28 +353,39 @@ mb4:
|
||||
movw %dx,%ss
|
||||
movl $STACK32ADDR,%esp
|
||||
|
||||
movl $mb_info,%ebx
|
||||
/* Check for valid multiboot signature */
|
||||
cmpl $MULTIBOOT_BOOTLOADER_MAGIC,%eax
|
||||
jne mbfail
|
||||
|
||||
/* See if the boot device was passed in */
|
||||
movl MB_INFO_FLAGS_OFFSET(%ebx),%edx
|
||||
testl $MB_INFO_FLAG_BOOT_DEVICE,%edx
|
||||
jz mb5
|
||||
jz mb3
|
||||
/* Retrieve boot device info */
|
||||
movl MB_INFO_BOOT_DEVICE_OFFSET(%ebx),%eax
|
||||
shrl $16,%eax
|
||||
incb %al
|
||||
movb %al,_i386BootPartition
|
||||
movb %ah,_i386BootDrive
|
||||
jmp mb6
|
||||
mb5: /* No boot device known, assume first partition of first harddisk */
|
||||
movb $0x80,_i386BootDrive
|
||||
movb $1,_i386BootPartition
|
||||
mb6:
|
||||
/* Check for command line */
|
||||
mov $cmdline,%eax
|
||||
testl $MB_INFO_FLAG_COMMAND_LINE,MB_INFO_FLAGS_OFFSET(%ebx)
|
||||
jnz mb7
|
||||
movb %al,_BootPartition
|
||||
movb %ah,_BootDrive
|
||||
jmp mb4
|
||||
mb3: /* No boot device known, assume first partition of first harddisk */
|
||||
movb $0x80,_BootDrive
|
||||
movb $1,_BootPartition
|
||||
mb4:
|
||||
|
||||
/* Check for a command line */
|
||||
xorl %eax,%eax
|
||||
mb7:
|
||||
testl $MB_INFO_FLAG_COMMAND_LINE,%edx
|
||||
jz mb6
|
||||
/* Copy command line to low mem*/
|
||||
movl MB_INFO_COMMAND_LINE_OFFSET(%ebx),%esi
|
||||
movl $CMDLINE_BASE,%edi
|
||||
mb5: lodsb
|
||||
stosb
|
||||
testb %al,%al
|
||||
jnz mb5
|
||||
movl $CMDLINE_BASE,%eax
|
||||
mb6:
|
||||
|
||||
/* GO! */
|
||||
pushl %eax
|
||||
@@ -477,14 +462,8 @@ rmode_idtptr:
|
||||
.word 0x3ff /* Limit */
|
||||
.long 0 /* Base Address */
|
||||
|
||||
EXTERN(_i386BootDrive)
|
||||
EXTERN(_BootDrive)
|
||||
.long 0
|
||||
|
||||
EXTERN(_i386BootPartition)
|
||||
EXTERN(_BootPartition)
|
||||
.long 0
|
||||
|
||||
mb_info:
|
||||
.fill MB_INFO_SIZE, 1, 0
|
||||
|
||||
cmdline:
|
||||
.fill CMDLINE_SIZE, 1, 0
|
@@ -1,4 +1,4 @@
|
||||
/* $Id$
|
||||
/* $Id: archmach.c,v 1.2 2004/11/09 23:36:19 gvg Exp $
|
||||
*
|
||||
* FreeLoader
|
||||
*
|
||||
@@ -27,23 +27,23 @@
|
||||
#include "rtl.h"
|
||||
|
||||
VOID
|
||||
MachInit(char *CmdLine)
|
||||
MachInit(VOID)
|
||||
{
|
||||
ULONG PciId;
|
||||
U32 PciId;
|
||||
|
||||
memset(&MachVtbl, 0, sizeof(MACHVTBL));
|
||||
|
||||
/* Check for Xbox by identifying device at PCI 0:0:0, if it's
|
||||
* 0x10de/0x02a5 then we're running on an Xbox */
|
||||
WRITE_PORT_ULONG((ULONG*) 0xcf8, CONFIG_CMD(0, 0, 0));
|
||||
PciId = READ_PORT_ULONG((ULONG*) 0xcfc);
|
||||
WRITE_PORT_ULONG((U32*) 0xcf8, CONFIG_CMD(0, 0, 0));
|
||||
PciId = READ_PORT_ULONG((U32*) 0xcfc);
|
||||
if (0x02a510de == PciId)
|
||||
{
|
||||
XboxMachInit(CmdLine);
|
||||
XboxMachInit();
|
||||
}
|
||||
else
|
||||
{
|
||||
PcMachInit(CmdLine);
|
||||
PcMachInit();
|
||||
}
|
||||
|
||||
HalpCalibrateStallExecution();
|
@@ -31,7 +31,7 @@ EXTERN(_ChainLoadBiosBootSectorCode)
|
||||
.code16
|
||||
|
||||
/* Set the boot drive */
|
||||
movb (_i386BootDrive),%dl
|
||||
movb (_BootDrive),%dl
|
||||
|
||||
/* Load segment registers */
|
||||
cli
|
File diff suppressed because it is too large
Load Diff
200
freeldr/freeldr/arch/i386/hardware.h
Normal file
200
freeldr/freeldr/arch/i386/hardware.h
Normal file
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
* FreeLoader
|
||||
*
|
||||
* Copyright (C) 2003 Eric Kohl
|
||||
*
|
||||
* 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 __I386_HARDWARE_H_
|
||||
#define __I386_HARDWARE_H_
|
||||
|
||||
#ifndef __REGISTRY_H
|
||||
#include "../../reactos/registry.h"
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
InterfaceTypeUndefined = -1,
|
||||
Internal,
|
||||
Isa,
|
||||
Eisa,
|
||||
MicroChannel,
|
||||
TurboChannel,
|
||||
PCIBus,
|
||||
VMEBus,
|
||||
NuBus,
|
||||
PCMCIABus,
|
||||
CBus,
|
||||
MPIBus,
|
||||
MPSABus,
|
||||
ProcessorInternal,
|
||||
InternalPowerBus,
|
||||
PNPISABus,
|
||||
MaximumInterfaceType
|
||||
} INTERFACE_TYPE, *PINTERFACE_TYPE;
|
||||
|
||||
|
||||
typedef enum _CM_RESOURCE_TYPE
|
||||
{
|
||||
CmResourceTypeNull = 0,
|
||||
CmResourceTypePort,
|
||||
CmResourceTypeInterrupt,
|
||||
CmResourceTypeMemory,
|
||||
CmResourceTypeDma,
|
||||
CmResourceTypeDeviceSpecific,
|
||||
CmResourceTypeMaximum
|
||||
} CM_RESOURCE_TYPE;
|
||||
|
||||
|
||||
typedef enum _CM_SHARE_DISPOSITION
|
||||
{
|
||||
CmResourceShareUndetermined = 0,
|
||||
CmResourceShareDeviceExclusive,
|
||||
CmResourceShareDriverExclusive,
|
||||
CmResourceShareShared
|
||||
} CM_SHARE_DISPOSITION;
|
||||
|
||||
|
||||
typedef U64 PHYSICAL_ADDRESS;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U8 Type;
|
||||
U8 ShareDisposition;
|
||||
U16 Flags;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
PHYSICAL_ADDRESS Start;
|
||||
U32 Length;
|
||||
} __attribute__((packed)) Port;
|
||||
struct
|
||||
{
|
||||
U32 Level;
|
||||
U32 Vector;
|
||||
U32 Affinity;
|
||||
} __attribute__((packed)) Interrupt;
|
||||
struct
|
||||
{
|
||||
PHYSICAL_ADDRESS Start;
|
||||
U32 Length;
|
||||
} __attribute__((packed)) Memory;
|
||||
struct
|
||||
{
|
||||
U32 Channel;
|
||||
U32 Port;
|
||||
U32 Reserved1;
|
||||
} __attribute__((packed)) Dma;
|
||||
struct
|
||||
{
|
||||
U32 DataSize;
|
||||
U32 Reserved1;
|
||||
U32 Reserved2;
|
||||
} __attribute__((packed)) DeviceSpecificData;
|
||||
} __attribute__((packed)) u;
|
||||
} __attribute__((packed)) CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
|
||||
|
||||
|
||||
/* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags */
|
||||
#define CM_RESOURCE_PORT_MEMORY 0x0000
|
||||
#define CM_RESOURCE_PORT_IO 0x0001
|
||||
|
||||
#define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0x0000
|
||||
#define CM_RESOURCE_INTERRUPT_LATCHED 0x0001
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U16 Version;
|
||||
U16 Revision;
|
||||
U32 Count;
|
||||
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
|
||||
} __attribute__((packed))CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
INTERFACE_TYPE InterfaceType;
|
||||
U32 BusNumber;
|
||||
CM_PARTIAL_RESOURCE_LIST PartialResourceList;
|
||||
} __attribute__((packed)) CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR;
|
||||
|
||||
|
||||
typedef struct _CM_COMPONENT_INFORMATION
|
||||
{
|
||||
U32 Flags;
|
||||
U32 Version;
|
||||
U32 Key;
|
||||
U32 Affinity;
|
||||
} __attribute__((packed)) CM_COMPONENT_INFORMATION, *PCM_COMPONENT_INFORMATION;
|
||||
|
||||
|
||||
/* CM_COMPONENT_INFORMATION.Flags */
|
||||
#define Failed 0x00000001
|
||||
#define ReadOnly 0x00000002
|
||||
#define Removable 0x00000004
|
||||
#define ConsoleIn 0x00000008
|
||||
#define ConsoleOut 0x00000010
|
||||
#define Input 0x00000020
|
||||
#define Output 0x00000040
|
||||
|
||||
#define CONFIG_CMD(bus, dev_fn, where) \
|
||||
(0x80000000 | (((U32)(bus)) << 16) | (((dev_fn) & 0x1F) << 11) | (((dev_fn) & 0xE0) << 3) | ((where) & ~3))
|
||||
|
||||
/* PROTOTYPES ***************************************************************/
|
||||
|
||||
/* hardware.c */
|
||||
VOID HalpCalibrateStallExecution(VOID);
|
||||
VOID KeStallExecutionProcessor(U32 Microseconds);
|
||||
|
||||
VOID SetComponentInformation(HKEY ComponentKey,
|
||||
U32 Flags,
|
||||
U32 Key,
|
||||
U32 Affinity);
|
||||
|
||||
/* hwacpi.c */
|
||||
VOID DetectAcpiBios(HKEY SystemKey, U32 *BusNumber);
|
||||
|
||||
/* hwapm.c */
|
||||
VOID DetectApmBios(HKEY SystemKey, U32 *BusNumber);
|
||||
|
||||
/* hwcpu.c */
|
||||
VOID DetectCPUs(HKEY SystemKey);
|
||||
|
||||
/* hwpci.c */
|
||||
VOID DetectPciBios(HKEY SystemKey, U32 *BusNumber);
|
||||
|
||||
/* i386cpu.S */
|
||||
U32 CpuidSupported(VOID);
|
||||
VOID GetCpuid(U32 Level,
|
||||
U32 *eax,
|
||||
U32 *ebx,
|
||||
U32 *ecx,
|
||||
U32 *edx);
|
||||
U64 RDTSC(VOID);
|
||||
|
||||
/* i386pnp.S */
|
||||
U32 PnpBiosSupported(VOID);
|
||||
U32 PnpBiosGetDeviceNodeCount(U32 *NodeSize,
|
||||
U32 *NodeCount);
|
||||
U32 PnpBiosGetDeviceNode(U8 *NodeId,
|
||||
U8 *NodeBuffer);
|
||||
|
||||
#endif /* __I386_HARDWARE_H_ */
|
||||
|
||||
/* EOF */
|
@@ -28,16 +28,15 @@
|
||||
#include "../../reactos/registry.h"
|
||||
#include "hardware.h"
|
||||
|
||||
BOOLEAN AcpiPresent = FALSE;
|
||||
|
||||
static BOOL
|
||||
FindAcpiBios(VOID)
|
||||
{
|
||||
PUCHAR Ptr;
|
||||
PU8 Ptr;
|
||||
|
||||
/* Find the 'Root System Descriptor Table Pointer' */
|
||||
Ptr = (PUCHAR)0xE0000;
|
||||
while ((ULONG)Ptr < 0x100000)
|
||||
Ptr = (PU8)0xE0000;
|
||||
while ((U32)Ptr < 0x100000)
|
||||
{
|
||||
if (!memcmp(Ptr, "RSD PTR ", 8))
|
||||
{
|
||||
@@ -46,7 +45,7 @@ FindAcpiBios(VOID)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Ptr = (PUCHAR)((ULONG)Ptr + 0x10);
|
||||
Ptr = (PU8)((U32)Ptr + 0x10);
|
||||
}
|
||||
|
||||
DbgPrint((DPRINT_HWDETECT, "ACPI not supported\n"));
|
||||
@@ -56,15 +55,14 @@ FindAcpiBios(VOID)
|
||||
|
||||
|
||||
VOID
|
||||
DetectAcpiBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
|
||||
DetectAcpiBios(HKEY SystemKey, U32 *BusNumber)
|
||||
{
|
||||
char Buffer[80];
|
||||
FRLDRHKEY BiosKey;
|
||||
LONG Error;
|
||||
HKEY BiosKey;
|
||||
S32 Error;
|
||||
|
||||
if (FindAcpiBios())
|
||||
{
|
||||
AcpiPresent = TRUE;
|
||||
/* Create new bus key */
|
||||
sprintf(Buffer,
|
||||
"MultifunctionAdapter\\%u", *BusNumber);
|
||||
@@ -92,7 +90,7 @@ DetectAcpiBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
|
||||
Error = RegSetValue(BiosKey,
|
||||
"Identifier",
|
||||
REG_SZ,
|
||||
"ACPI BIOS",
|
||||
(PU8)"ACPI BIOS",
|
||||
10);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
@@ -60,11 +60,11 @@ FindApmBios(VOID)
|
||||
|
||||
|
||||
VOID
|
||||
DetectApmBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
|
||||
DetectApmBios(HKEY SystemKey, U32 *BusNumber)
|
||||
{
|
||||
char Buffer[80];
|
||||
FRLDRHKEY BiosKey;
|
||||
LONG Error;
|
||||
HKEY BiosKey;
|
||||
S32 Error;
|
||||
|
||||
if (FindApmBios())
|
||||
{
|
||||
@@ -95,7 +95,7 @@ DetectApmBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
|
||||
Error = RegSetValue(BiosKey,
|
||||
"Identifier",
|
||||
REG_SZ,
|
||||
"APM",
|
||||
(PU8)"APM",
|
||||
4);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
@@ -35,60 +35,60 @@
|
||||
|
||||
typedef struct _MP_FLOATING_POINT_TABLE
|
||||
{
|
||||
ULONG Signature; /* "_MP_" */
|
||||
ULONG PhysicalAddressPointer;
|
||||
UCHAR Length;
|
||||
UCHAR SpecRev;
|
||||
UCHAR Checksum;
|
||||
UCHAR FeatureByte[5];
|
||||
U32 Signature; /* "_MP_" */
|
||||
U32 PhysicalAddressPointer;
|
||||
U8 Length;
|
||||
U8 SpecRev;
|
||||
U8 Checksum;
|
||||
U8 FeatureByte[5];
|
||||
} PACKED MP_FLOATING_POINT_TABLE, *PMP_FLOATING_POINT_TABLE;
|
||||
|
||||
|
||||
typedef struct _MPS_CONFIG_TABLE_HEADER
|
||||
{
|
||||
ULONG Signature; /* "PCMP" */
|
||||
USHORT BaseTableLength;
|
||||
UCHAR SpecRev;
|
||||
UCHAR Checksum;
|
||||
UCHAR OemIdString[8];
|
||||
UCHAR ProductIdString[12];
|
||||
ULONG OemTablePointer;
|
||||
USHORT OemTableLength;
|
||||
USHORT EntryCount;
|
||||
ULONG AddressOfLocalAPIC;
|
||||
USHORT ExtendedTableLength;
|
||||
UCHAR ExtendedTableChecksum;
|
||||
UCHAR Reserved;
|
||||
U32 Signature; /* "PCMP" */
|
||||
U16 BaseTableLength;
|
||||
U8 SpecRev;
|
||||
U8 Checksum;
|
||||
U8 OemIdString[8];
|
||||
U8 ProductIdString[12];
|
||||
U32 OemTablePointer;
|
||||
U16 OemTableLength;
|
||||
U16 EntryCount;
|
||||
U32 AddressOfLocalAPIC;
|
||||
U16 ExtendedTableLength;
|
||||
U8 ExtendedTableChecksum;
|
||||
U8 Reserved;
|
||||
} PACKED MP_CONFIGURATION_TABLE, *PMP_CONFIGURATION_TABLE;
|
||||
|
||||
|
||||
typedef struct _MP_PROCESSOR_ENTRY
|
||||
{
|
||||
UCHAR EntryType;
|
||||
UCHAR LocalApicId;
|
||||
UCHAR LocalApicVersion;
|
||||
UCHAR CpuFlags;
|
||||
ULONG CpuSignature;
|
||||
ULONG FeatureFlags;
|
||||
ULONG Reserved1;
|
||||
ULONG Reserved2;
|
||||
U8 EntryType;
|
||||
U8 LocalApicId;
|
||||
U8 LocalApicVersion;
|
||||
U8 CpuFlags;
|
||||
U32 CpuSignature;
|
||||
U32 FeatureFlags;
|
||||
U32 Reserved1;
|
||||
U32 Reserved2;
|
||||
} PACKED MP_PROCESSOR_ENTRY, *PMP_PROCESSOR_ENTRY;
|
||||
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
static ULONG
|
||||
static U32
|
||||
GetCpuSpeed(VOID)
|
||||
{
|
||||
ULONGLONG Timestamp1;
|
||||
ULONGLONG Timestamp2;
|
||||
ULONGLONG Diff;
|
||||
U64 Timestamp1;
|
||||
U64 Timestamp2;
|
||||
U64 Diff;
|
||||
|
||||
/* Read TSC (Time Stamp Counter) */
|
||||
Timestamp1 = RDTSC();
|
||||
|
||||
/* Wait for 0.1 seconds (= 100 milliseconds = 100000 microseconds)*/
|
||||
StallExecutionProcessor(100000);
|
||||
KeStallExecutionProcessor(100000);
|
||||
|
||||
/* Read TSC (Time Stamp Counter) again */
|
||||
Timestamp2 = RDTSC();
|
||||
@@ -100,30 +100,30 @@ GetCpuSpeed(VOID)
|
||||
}
|
||||
else
|
||||
{
|
||||
Diff = Timestamp2 + (((ULONGLONG)-1) - Timestamp1);
|
||||
Diff = Timestamp2 + (((U64)-1) - Timestamp1);
|
||||
}
|
||||
|
||||
return (ULONG)(Diff / 100000);
|
||||
return (U32)(Diff / 100000);
|
||||
}
|
||||
|
||||
|
||||
static VOID
|
||||
DetectCPU(FRLDRHKEY CpuKey,
|
||||
FRLDRHKEY FpuKey)
|
||||
DetectCPU(HKEY CpuKey,
|
||||
HKEY FpuKey)
|
||||
{
|
||||
CHAR VendorIdentifier[13];
|
||||
CHAR Identifier[64];
|
||||
ULONG FeatureSet;
|
||||
FRLDRHKEY CpuInstKey;
|
||||
FRLDRHKEY FpuInstKey;
|
||||
ULONG eax = 0;
|
||||
ULONG ebx = 0;
|
||||
ULONG ecx = 0;
|
||||
ULONG edx = 0;
|
||||
ULONG *Ptr;
|
||||
LONG Error;
|
||||
char VendorIdentifier[13];
|
||||
char Identifier[64];
|
||||
U32 FeatureSet;
|
||||
HKEY CpuInstKey;
|
||||
HKEY FpuInstKey;
|
||||
U32 eax = 0;
|
||||
U32 ebx = 0;
|
||||
U32 ecx = 0;
|
||||
U32 edx = 0;
|
||||
U32 *Ptr;
|
||||
S32 Error;
|
||||
BOOL SupportTSC = FALSE;
|
||||
ULONG CpuSpeed;
|
||||
U32 CpuSpeed;
|
||||
|
||||
|
||||
/* Create the CPU instance key */
|
||||
@@ -154,7 +154,7 @@ DetectCPU(FRLDRHKEY CpuKey,
|
||||
/* Get vendor identifier */
|
||||
GetCpuid(0, &eax, &ebx, &ecx, &edx);
|
||||
VendorIdentifier[12] = 0;
|
||||
Ptr = (ULONG*)&VendorIdentifier[0];
|
||||
Ptr = (U32*)&VendorIdentifier[0];
|
||||
*Ptr = ebx;
|
||||
Ptr++;
|
||||
*Ptr = edx;
|
||||
@@ -195,8 +195,8 @@ DetectCPU(FRLDRHKEY CpuKey,
|
||||
Error = RegSetValue(CpuInstKey,
|
||||
"FeatureSet",
|
||||
REG_DWORD,
|
||||
(PCHAR)&FeatureSet,
|
||||
sizeof(ULONG));
|
||||
(PU8)&FeatureSet,
|
||||
sizeof(U32));
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
|
||||
@@ -208,7 +208,7 @@ DetectCPU(FRLDRHKEY CpuKey,
|
||||
Error = RegSetValue(CpuInstKey,
|
||||
"Identifier",
|
||||
REG_SZ,
|
||||
Identifier,
|
||||
(PU8)Identifier,
|
||||
strlen(Identifier) + 1);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
@@ -218,7 +218,7 @@ DetectCPU(FRLDRHKEY CpuKey,
|
||||
Error = RegSetValue(FpuInstKey,
|
||||
"Identifier",
|
||||
REG_SZ,
|
||||
Identifier,
|
||||
(PU8)Identifier,
|
||||
strlen(Identifier) + 1);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
@@ -231,7 +231,7 @@ DetectCPU(FRLDRHKEY CpuKey,
|
||||
Error = RegSetValue(CpuInstKey,
|
||||
"VendorIdentifier",
|
||||
REG_SZ,
|
||||
VendorIdentifier,
|
||||
(PU8)VendorIdentifier,
|
||||
strlen(VendorIdentifier) + 1);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
@@ -250,8 +250,8 @@ DetectCPU(FRLDRHKEY CpuKey,
|
||||
Error = RegSetValue(CpuInstKey,
|
||||
"~MHz",
|
||||
REG_DWORD,
|
||||
(PCHAR)&CpuSpeed,
|
||||
sizeof(ULONG));
|
||||
(PU8)&CpuSpeed,
|
||||
sizeof(U32));
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
|
||||
@@ -261,23 +261,23 @@ DetectCPU(FRLDRHKEY CpuKey,
|
||||
|
||||
|
||||
static VOID
|
||||
SetMpsProcessor(FRLDRHKEY CpuKey,
|
||||
FRLDRHKEY FpuKey,
|
||||
SetMpsProcessor(HKEY CpuKey,
|
||||
HKEY FpuKey,
|
||||
PMP_PROCESSOR_ENTRY CpuEntry)
|
||||
{
|
||||
char VendorIdentifier[13];
|
||||
char Identifier[64];
|
||||
char Buffer[8];
|
||||
ULONG FeatureSet;
|
||||
FRLDRHKEY CpuInstKey;
|
||||
FRLDRHKEY FpuInstKey;
|
||||
ULONG eax = 0;
|
||||
ULONG ebx = 0;
|
||||
ULONG ecx = 0;
|
||||
ULONG edx = 0;
|
||||
ULONG *Ptr;
|
||||
LONG Error;
|
||||
ULONG CpuSpeed;
|
||||
U32 FeatureSet;
|
||||
HKEY CpuInstKey;
|
||||
HKEY FpuInstKey;
|
||||
U32 eax = 0;
|
||||
U32 ebx = 0;
|
||||
U32 ecx = 0;
|
||||
U32 edx = 0;
|
||||
U32 *Ptr;
|
||||
S32 Error;
|
||||
U32 CpuSpeed;
|
||||
|
||||
/* Get processor instance number */
|
||||
sprintf(Buffer, "%u", CpuEntry->LocalApicId);
|
||||
@@ -305,7 +305,7 @@ SetMpsProcessor(FRLDRHKEY CpuKey,
|
||||
/* Get 'VendorIdentifier' */
|
||||
GetCpuid(0, &eax, &ebx, &ecx, &edx);
|
||||
VendorIdentifier[12] = 0;
|
||||
Ptr = (ULONG*)&VendorIdentifier[0];
|
||||
Ptr = (U32*)&VendorIdentifier[0];
|
||||
*Ptr = ebx;
|
||||
Ptr++;
|
||||
*Ptr = edx;
|
||||
@@ -315,9 +315,9 @@ SetMpsProcessor(FRLDRHKEY CpuKey,
|
||||
/* Get 'Identifier' */
|
||||
sprintf(Identifier,
|
||||
"x86 Family %u Model %u Stepping %u",
|
||||
(ULONG)((CpuEntry->CpuSignature >> 8) & 0x0F),
|
||||
(ULONG)((CpuEntry->CpuSignature >> 4) & 0x0F),
|
||||
(ULONG)(CpuEntry->CpuSignature & 0x0F));
|
||||
(U32)((CpuEntry->CpuSignature >> 8) & 0x0F),
|
||||
(U32)((CpuEntry->CpuSignature >> 4) & 0x0F),
|
||||
(U32)(CpuEntry->CpuSignature & 0x0F));
|
||||
|
||||
/* Get FeatureSet */
|
||||
FeatureSet = CpuEntry->FeatureFlags;
|
||||
@@ -339,8 +339,8 @@ SetMpsProcessor(FRLDRHKEY CpuKey,
|
||||
Error = RegSetValue(CpuInstKey,
|
||||
"FeatureSet",
|
||||
REG_DWORD,
|
||||
(PCHAR)&FeatureSet,
|
||||
sizeof(ULONG));
|
||||
(PU8)&FeatureSet,
|
||||
sizeof(U32));
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
|
||||
@@ -352,7 +352,7 @@ SetMpsProcessor(FRLDRHKEY CpuKey,
|
||||
Error = RegSetValue(CpuInstKey,
|
||||
"Identifier",
|
||||
REG_SZ,
|
||||
Identifier,
|
||||
(PU8)Identifier,
|
||||
strlen(Identifier) + 1);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
@@ -362,7 +362,7 @@ SetMpsProcessor(FRLDRHKEY CpuKey,
|
||||
Error = RegSetValue(FpuInstKey,
|
||||
"Identifier",
|
||||
REG_SZ,
|
||||
Identifier,
|
||||
(PU8)Identifier,
|
||||
strlen(Identifier) + 1);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
@@ -375,7 +375,7 @@ SetMpsProcessor(FRLDRHKEY CpuKey,
|
||||
Error = RegSetValue(CpuInstKey,
|
||||
"VendorIdentifier",
|
||||
REG_SZ,
|
||||
VendorIdentifier,
|
||||
(PU8)VendorIdentifier,
|
||||
strlen(VendorIdentifier) + 1);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
@@ -394,8 +394,8 @@ SetMpsProcessor(FRLDRHKEY CpuKey,
|
||||
Error = RegSetValue(CpuInstKey,
|
||||
"~MHz",
|
||||
REG_DWORD,
|
||||
(PCHAR)&CpuSpeed,
|
||||
sizeof(ULONG));
|
||||
(PU8)&CpuSpeed,
|
||||
sizeof(U32));
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
|
||||
@@ -409,12 +409,12 @@ GetMpFloatingPointTable(VOID)
|
||||
{
|
||||
PMP_FLOATING_POINT_TABLE FpTable;
|
||||
char *Ptr;
|
||||
UCHAR Sum;
|
||||
ULONG Length;
|
||||
ULONG i;
|
||||
U8 Sum;
|
||||
U32 Length;
|
||||
U32 i;
|
||||
|
||||
FpTable = (PMP_FLOATING_POINT_TABLE)0xF0000;
|
||||
while ((ULONG)FpTable < 0x100000)
|
||||
while ((U32)FpTable < 0x100000)
|
||||
{
|
||||
if (FpTable->Signature == MP_FP_SIGNATURE)
|
||||
{
|
||||
@@ -440,7 +440,7 @@ GetMpFloatingPointTable(VOID)
|
||||
return FpTable;
|
||||
}
|
||||
|
||||
FpTable = (PMP_FLOATING_POINT_TABLE)((ULONG)FpTable + 0x10);
|
||||
FpTable = (PMP_FLOATING_POINT_TABLE)((U32)FpTable + 0x10);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -452,9 +452,9 @@ GetMpConfigurationTable(PMP_FLOATING_POINT_TABLE FpTable)
|
||||
{
|
||||
PMP_CONFIGURATION_TABLE ConfigTable;
|
||||
char *Ptr;
|
||||
UCHAR Sum;
|
||||
ULONG Length;
|
||||
ULONG i;
|
||||
U8 Sum;
|
||||
U32 Length;
|
||||
U32 i;
|
||||
|
||||
if (FpTable->FeatureByte[0] != 0 ||
|
||||
FpTable->PhysicalAddressPointer == 0)
|
||||
@@ -466,7 +466,7 @@ GetMpConfigurationTable(PMP_FLOATING_POINT_TABLE FpTable)
|
||||
|
||||
DbgPrint((DPRINT_HWDETECT,
|
||||
"MP Configuration Table at: %x\n",
|
||||
(ULONG)ConfigTable));
|
||||
(U32)ConfigTable));
|
||||
|
||||
/* Calculate base table checksum */
|
||||
Length = ConfigTable->BaseTableLength;
|
||||
@@ -498,14 +498,14 @@ GetMpConfigurationTable(PMP_FLOATING_POINT_TABLE FpTable)
|
||||
|
||||
|
||||
static BOOL
|
||||
DetectMps(FRLDRHKEY CpuKey,
|
||||
FRLDRHKEY FpuKey)
|
||||
DetectMps(HKEY CpuKey,
|
||||
HKEY FpuKey)
|
||||
{
|
||||
PMP_FLOATING_POINT_TABLE FpTable;
|
||||
PMP_CONFIGURATION_TABLE ConfigTable;
|
||||
PMP_PROCESSOR_ENTRY CpuEntry;
|
||||
char *Ptr;
|
||||
ULONG Offset;
|
||||
U32 Offset;
|
||||
|
||||
/* Get floating point table */
|
||||
FpTable = GetMpFloatingPointTable();
|
||||
@@ -514,7 +514,7 @@ DetectMps(FRLDRHKEY CpuKey,
|
||||
|
||||
DbgPrint((DPRINT_HWDETECT,
|
||||
"MP Floating Point Table at: %x\n",
|
||||
(ULONG)FpTable));
|
||||
(U32)FpTable));
|
||||
|
||||
if (FpTable->FeatureByte[0] == 0)
|
||||
{
|
||||
@@ -530,7 +530,7 @@ DetectMps(FRLDRHKEY CpuKey,
|
||||
Offset = sizeof(MP_CONFIGURATION_TABLE);
|
||||
while (Offset < ConfigTable->BaseTableLength)
|
||||
{
|
||||
Ptr = (char*)((ULONG)ConfigTable + Offset);
|
||||
Ptr = (char*)((U32)ConfigTable + Offset);
|
||||
|
||||
switch (*Ptr)
|
||||
{
|
||||
@@ -548,9 +548,9 @@ DetectMps(FRLDRHKEY CpuKey,
|
||||
DbgPrint((DPRINT_HWDETECT,
|
||||
"Processor %u: x86 Family %u Model %u Stepping %u\n",
|
||||
CpuEntry->LocalApicId,
|
||||
(ULONG)((CpuEntry->CpuSignature >> 8) & 0x0F),
|
||||
(ULONG)((CpuEntry->CpuSignature >> 4) & 0x0F),
|
||||
(ULONG)(CpuEntry->CpuSignature & 0x0F)));
|
||||
(U32)((CpuEntry->CpuSignature >> 8) & 0x0F),
|
||||
(U32)((CpuEntry->CpuSignature >> 4) & 0x0F),
|
||||
(U32)(CpuEntry->CpuSignature & 0x0F)));
|
||||
|
||||
SetMpsProcessor(CpuKey, FpuKey, CpuEntry);
|
||||
Offset += 0x14;
|
||||
@@ -577,7 +577,7 @@ DetectMps(FRLDRHKEY CpuKey,
|
||||
break;
|
||||
|
||||
default:
|
||||
DbgPrint((DPRINT_HWDETECT, "Unknown Entry %u\n",(ULONG)*Ptr));
|
||||
DbgPrint((DPRINT_HWDETECT, "Unknown Entry %u\n",(U32)*Ptr));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -599,11 +599,11 @@ DetectMps(FRLDRHKEY CpuKey,
|
||||
|
||||
|
||||
VOID
|
||||
DetectCPUs(FRLDRHKEY SystemKey)
|
||||
DetectCPUs(HKEY SystemKey)
|
||||
{
|
||||
FRLDRHKEY CpuKey;
|
||||
FRLDRHKEY FpuKey;
|
||||
LONG Error;
|
||||
HKEY CpuKey;
|
||||
HKEY FpuKey;
|
||||
S32 Error;
|
||||
|
||||
/* Create the 'CentralProcessor' key */
|
||||
Error = RegCreateKey(SystemKey,
|
@@ -30,40 +30,40 @@
|
||||
|
||||
typedef struct _ROUTING_SLOT
|
||||
{
|
||||
UCHAR BusNumber;
|
||||
UCHAR DeviceNumber;
|
||||
UCHAR LinkA;
|
||||
USHORT BitmapA;
|
||||
UCHAR LinkB;
|
||||
USHORT BitmapB;
|
||||
UCHAR LinkC;
|
||||
USHORT BitmapC;
|
||||
UCHAR LinkD;
|
||||
USHORT BitmapD;
|
||||
UCHAR SlotNumber;
|
||||
UCHAR Reserved;
|
||||
U8 BusNumber;
|
||||
U8 DeviceNumber;
|
||||
U8 LinkA;
|
||||
U16 BitmapA;
|
||||
U8 LinkB;
|
||||
U16 BitmapB;
|
||||
U8 LinkC;
|
||||
U16 BitmapC;
|
||||
U8 LinkD;
|
||||
U16 BitmapD;
|
||||
U8 SlotNumber;
|
||||
U8 Reserved;
|
||||
} __attribute__((packed)) ROUTING_SLOT, *PROUTING_SLOT;
|
||||
|
||||
typedef struct _PCI_IRQ_ROUTING_TABLE
|
||||
{
|
||||
ULONG Signature;
|
||||
USHORT Version;
|
||||
USHORT Size;
|
||||
UCHAR RouterBus;
|
||||
UCHAR RouterSlot;
|
||||
USHORT ExclusiveIRQs;
|
||||
ULONG CompatibleRouter;
|
||||
ULONG MiniportData;
|
||||
UCHAR Reserved[11];
|
||||
UCHAR Checksum;
|
||||
U32 Signature;
|
||||
U16 Version;
|
||||
U16 Size;
|
||||
U8 RouterBus;
|
||||
U8 RouterSlot;
|
||||
U16 ExclusiveIRQs;
|
||||
U32 CompatibleRouter;
|
||||
U32 MiniportData;
|
||||
U8 Reserved[11];
|
||||
U8 Checksum;
|
||||
ROUTING_SLOT Slot[1];
|
||||
} __attribute__((packed)) PCI_IRQ_ROUTING_TABLE, *PPCI_IRQ_ROUTING_TABLE;
|
||||
|
||||
typedef struct _CM_PCI_BUS_DATA
|
||||
{
|
||||
UCHAR BusCount;
|
||||
USHORT PciVersion;
|
||||
UCHAR HardwareMechanism;
|
||||
U8 BusCount;
|
||||
U16 PciVersion;
|
||||
U8 HardwareMechanism;
|
||||
} __attribute__((packed)) CM_PCI_BUS_DATA, *PCM_PCI_BUS_DATA;
|
||||
|
||||
|
||||
@@ -71,19 +71,19 @@ static PPCI_IRQ_ROUTING_TABLE
|
||||
GetPciIrqRoutingTable(VOID)
|
||||
{
|
||||
PPCI_IRQ_ROUTING_TABLE Table;
|
||||
PUCHAR Ptr;
|
||||
ULONG Sum;
|
||||
ULONG i;
|
||||
PU8 Ptr;
|
||||
U32 Sum;
|
||||
U32 i;
|
||||
|
||||
Table = (PPCI_IRQ_ROUTING_TABLE)0xF0000;
|
||||
while ((ULONG)Table < 0x100000)
|
||||
while ((U32)Table < 0x100000)
|
||||
{
|
||||
if (Table->Signature == 0x52495024)
|
||||
{
|
||||
DbgPrint((DPRINT_HWDETECT,
|
||||
"Found signature\n"));
|
||||
|
||||
Ptr = (PUCHAR)Table;
|
||||
Ptr = (PU8)Table;
|
||||
Sum = 0;
|
||||
for (i = 0; i < Table->Size; i++)
|
||||
{
|
||||
@@ -103,7 +103,7 @@ GetPciIrqRoutingTable(VOID)
|
||||
return Table;
|
||||
}
|
||||
|
||||
Table = (PPCI_IRQ_ROUTING_TABLE)((ULONG)Table + 0x10);
|
||||
Table = (PPCI_IRQ_ROUTING_TABLE)((U32)Table + 0x10);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -145,14 +145,14 @@ FindPciBios(PCM_PCI_BUS_DATA BusData)
|
||||
|
||||
|
||||
static VOID
|
||||
DetectPciIrqRoutingTable(FRLDRHKEY BusKey)
|
||||
DetectPciIrqRoutingTable(HKEY BusKey)
|
||||
{
|
||||
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
|
||||
PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
|
||||
PPCI_IRQ_ROUTING_TABLE Table;
|
||||
FRLDRHKEY TableKey;
|
||||
ULONG Size;
|
||||
LONG Error;
|
||||
HKEY TableKey;
|
||||
U32 Size;
|
||||
S32 Error;
|
||||
|
||||
Table = GetPciIrqRoutingTable();
|
||||
if (Table != NULL)
|
||||
@@ -178,7 +178,7 @@ DetectPciIrqRoutingTable(FRLDRHKEY BusKey)
|
||||
Error = RegSetValue(TableKey,
|
||||
"Identifier",
|
||||
REG_SZ,
|
||||
"PCI Real-mode IRQ Routing Table",
|
||||
(PU8)"PCI Real-mode IRQ Routing Table",
|
||||
32);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
@@ -216,7 +216,7 @@ DetectPciIrqRoutingTable(FRLDRHKEY BusKey)
|
||||
Error = RegSetValue(TableKey,
|
||||
"Configuration Data",
|
||||
REG_FULL_RESOURCE_DESCRIPTOR,
|
||||
(PCHAR) FullResourceDescriptor,
|
||||
(PU8) FullResourceDescriptor,
|
||||
Size);
|
||||
MmFreeMemory(FullResourceDescriptor);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
@@ -231,17 +231,17 @@ DetectPciIrqRoutingTable(FRLDRHKEY BusKey)
|
||||
|
||||
|
||||
VOID
|
||||
DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
|
||||
DetectPciBios(HKEY SystemKey, U32 *BusNumber)
|
||||
{
|
||||
PCM_FULL_RESOURCE_DESCRIPTOR FullResourceDescriptor;
|
||||
CM_PCI_BUS_DATA BusData;
|
||||
char Buffer[80];
|
||||
FRLDRHKEY BiosKey;
|
||||
ULONG Size;
|
||||
LONG Error;
|
||||
HKEY BiosKey;
|
||||
U32 Size;
|
||||
S32 Error;
|
||||
#if 0
|
||||
FRLDRHKEY BusKey;
|
||||
ULONG i;
|
||||
HKEY BusKey;
|
||||
U32 i;
|
||||
#endif
|
||||
|
||||
/* Report the PCI BIOS */
|
||||
@@ -272,7 +272,7 @@ DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
|
||||
Error = RegSetValue(BiosKey,
|
||||
"Identifier",
|
||||
REG_SZ,
|
||||
"PCI BIOS",
|
||||
(PU8)"PCI BIOS",
|
||||
9);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
||||
@@ -301,7 +301,7 @@ DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
|
||||
Error = RegSetValue(BiosKey,
|
||||
"Configuration Data",
|
||||
REG_FULL_RESOURCE_DESCRIPTOR,
|
||||
(PCHAR) FullResourceDescriptor,
|
||||
(PU8) FullResourceDescriptor,
|
||||
Size);
|
||||
MmFreeMemory(FullResourceDescriptor);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
@@ -322,7 +322,7 @@ DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
|
||||
*/
|
||||
|
||||
/* Report PCI buses */
|
||||
for (i = 0; i < (ULONG)BusData.BusCount; i++)
|
||||
for (i = 0; i < (U32)BusData.BusCount; i++)
|
||||
{
|
||||
sprintf(Buffer,
|
||||
"MultifunctionAdapter\\%u", *BusNumber);
|
||||
@@ -350,7 +350,7 @@ DetectPciBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
|
||||
Error = RegSetValue(BusKey,
|
||||
"Identifier",
|
||||
REG_SZ,
|
||||
(PUCHAR)"PCI",
|
||||
(PU8)"PCI",
|
||||
4);
|
||||
if (Error != ERROR_SUCCESS)
|
||||
{
|
175
freeldr/freeldr/arch/i386/i386disk.c
Normal file
175
freeldr/freeldr/arch/i386/i386disk.c
Normal file
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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 "rtl.h"
|
||||
#include "arch.h"
|
||||
#include "debug.h"
|
||||
#include "portio.h"
|
||||
#include "machine.h"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FUNCTIONS
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __i386__
|
||||
|
||||
BOOL DiskResetController(U32 DriveNumber)
|
||||
{
|
||||
REGS RegsIn;
|
||||
REGS RegsOut;
|
||||
|
||||
DbgPrint((DPRINT_DISK, "DiskResetController(0x%x) DISK OPERATION FAILED -- RESETTING CONTROLLER\n", DriveNumber));
|
||||
|
||||
// BIOS Int 13h, function 0 - Reset disk system
|
||||
// AH = 00h
|
||||
// DL = drive (if bit 7 is set both hard disks and floppy disks reset)
|
||||
// Return:
|
||||
// AH = status
|
||||
// CF clear if successful
|
||||
// CF set on error
|
||||
RegsIn.b.ah = 0x00;
|
||||
RegsIn.b.dl = DriveNumber;
|
||||
|
||||
// Reset the disk controller
|
||||
Int386(0x13, &RegsIn, &RegsOut);
|
||||
|
||||
return INT386_SUCCESS(RegsOut);
|
||||
}
|
||||
|
||||
BOOL DiskInt13ExtensionsSupported(U32 DriveNumber)
|
||||
{
|
||||
REGS RegsIn;
|
||||
REGS RegsOut;
|
||||
|
||||
DbgPrint((DPRINT_DISK, "DiskInt13ExtensionsSupported()\n"));
|
||||
|
||||
// IBM/MS INT 13 Extensions - INSTALLATION CHECK
|
||||
// AH = 41h
|
||||
// BX = 55AAh
|
||||
// DL = drive (80h-FFh)
|
||||
// Return:
|
||||
// CF set on error (extensions not supported)
|
||||
// AH = 01h (invalid function)
|
||||
// CF clear if successful
|
||||
// BX = AA55h if installed
|
||||
// AH = major version of extensions
|
||||
// 01h = 1.x
|
||||
// 20h = 2.0 / EDD-1.0
|
||||
// 21h = 2.1 / EDD-1.1
|
||||
// 30h = EDD-3.0
|
||||
// AL = internal use
|
||||
// CX = API subset support bitmap
|
||||
// DH = extension version (v2.0+ ??? -- not present in 1.x)
|
||||
//
|
||||
// Bitfields for IBM/MS INT 13 Extensions API support bitmap
|
||||
// Bit 0, extended disk access functions (AH=42h-44h,47h,48h) supported
|
||||
// Bit 1, removable drive controller functions (AH=45h,46h,48h,49h,INT 15/AH=52h) supported
|
||||
// Bit 2, enhanced disk drive (EDD) functions (AH=48h,AH=4Eh) supported
|
||||
// extended drive parameter table is valid
|
||||
// Bits 3-15 reserved
|
||||
RegsIn.b.ah = 0x41;
|
||||
RegsIn.w.bx = 0x55AA;
|
||||
RegsIn.b.dl = DriveNumber;
|
||||
|
||||
// Reset the disk controller
|
||||
Int386(0x13, &RegsIn, &RegsOut);
|
||||
|
||||
if (!INT386_SUCCESS(RegsOut))
|
||||
{
|
||||
// CF set on error (extensions not supported)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (RegsOut.w.bx != 0xAA55)
|
||||
{
|
||||
// BX = AA55h if installed
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Note:
|
||||
// The original check is too strict because some BIOSes report that
|
||||
// extended disk access functions are not suported when booting
|
||||
// from a CD (e.g. Phoenix BIOS v6.00PG). Argh!
|
||||
#if 0
|
||||
if (!(RegsOut.w.cx & 0x0001))
|
||||
{
|
||||
// CX = API subset support bitmap
|
||||
// Bit 0, extended disk access functions (AH=42h-44h,47h,48h) supported
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Use this relaxed check instead
|
||||
if (RegsOut.w.cx == 0x0000)
|
||||
{
|
||||
// CX = API subset support bitmap
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
VOID DiskStopFloppyMotor(VOID)
|
||||
{
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x3F2, 0);
|
||||
}
|
||||
|
||||
BOOL DiskGetExtendedDriveParameters(U32 DriveNumber, PVOID Buffer, U16 BufferSize)
|
||||
{
|
||||
REGS RegsIn;
|
||||
REGS RegsOut;
|
||||
PU16 Ptr = (PU16)(BIOSCALLBUFFER);
|
||||
|
||||
DbgPrint((DPRINT_DISK, "DiskGetExtendedDriveParameters()\n"));
|
||||
|
||||
// Initialize transfer buffer
|
||||
*Ptr = BufferSize;
|
||||
|
||||
// BIOS Int 13h, function 48h - Get drive parameters
|
||||
// AH = 48h
|
||||
// DL = drive (bit 7 set for hard disk)
|
||||
// DS:SI = result buffer
|
||||
// Return:
|
||||
// CF set on error
|
||||
// AH = status (07h)
|
||||
// CF clear if successful
|
||||
// AH = 00h
|
||||
// DS:SI -> result buffer
|
||||
RegsIn.b.ah = 0x48;
|
||||
RegsIn.b.dl = DriveNumber;
|
||||
RegsIn.x.ds = BIOSCALLBUFSEGMENT; // DS:SI -> result buffer
|
||||
RegsIn.w.si = BIOSCALLBUFOFFSET;
|
||||
|
||||
// Get drive parameters
|
||||
Int386(0x13, &RegsIn, &RegsOut);
|
||||
|
||||
if (!INT386_SUCCESS(RegsOut))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
memcpy(Buffer, Ptr, BufferSize);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif // defined __i386__
|
@@ -18,6 +18,9 @@
|
||||
*/
|
||||
|
||||
#include <freeldr.h>
|
||||
#include <arch.h>
|
||||
#include <rtl.h>
|
||||
#include <portio.h>
|
||||
|
||||
void beep(void)
|
||||
{
|
@@ -30,31 +30,31 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UCHAR Signature[4]; // (ret) signature ("VESA")
|
||||
U8 Signature[4]; // (ret) signature ("VESA")
|
||||
// (call) VESA 2.0 request signature ("VBE2"), required to receive
|
||||
// version 2.0 info
|
||||
USHORT VesaVersion; // VESA version number (one-digit minor version -- 0102h = v1.2)
|
||||
ULONG OemNamePtr; // pointer to OEM name
|
||||
U16 VesaVersion; // VESA version number (one-digit minor version -- 0102h = v1.2)
|
||||
U32 OemNamePtr; // pointer to OEM name
|
||||
// "761295520" for ATI
|
||||
ULONG Capabilities; // capabilities flags (see #00078)
|
||||
ULONG SupportedModeListPtr; // pointer to list of supported VESA and OEM video modes
|
||||
U32 Capabilities; // capabilities flags (see #00078)
|
||||
U32 SupportedModeListPtr; // pointer to list of supported VESA and OEM video modes
|
||||
// (list of words terminated with FFFFh)
|
||||
USHORT TotalVideoMemory; // total amount of video memory in 64K blocks
|
||||
U16 TotalVideoMemory; // total amount of video memory in 64K blocks
|
||||
|
||||
// ---VBE v1.x ---
|
||||
//UCHAR Reserved[236];
|
||||
//U8 Reserved[236];
|
||||
|
||||
// ---VBE v2.0 ---
|
||||
USHORT OemSoftwareVersion; // OEM software version (BCD, high byte = major, low byte = minor)
|
||||
ULONG VendorNamePtr; // pointer to vendor name
|
||||
ULONG ProductNamePtr; // pointer to product name
|
||||
ULONG ProductRevisionStringPtr; // pointer to product revision string
|
||||
USHORT VBE_AF_Version; // (if capabilities bit 3 set) VBE/AF version (BCD)
|
||||
U16 OemSoftwareVersion; // OEM software version (BCD, high byte = major, low byte = minor)
|
||||
U32 VendorNamePtr; // pointer to vendor name
|
||||
U32 ProductNamePtr; // pointer to product name
|
||||
U32 ProductRevisionStringPtr; // pointer to product revision string
|
||||
U16 VBE_AF_Version; // (if capabilities bit 3 set) VBE/AF version (BCD)
|
||||
// 0100h for v1.0P
|
||||
ULONG AcceleratedModeListPtr; // (if capabilities bit 3 set) pointer to list of supported
|
||||
U32 AcceleratedModeListPtr; // (if capabilities bit 3 set) pointer to list of supported
|
||||
// accelerated video modes (list of words terminated with FFFFh)
|
||||
UCHAR Reserved[216]; // reserved for VBE implementation
|
||||
UCHAR ScratchPad[256]; // OEM scratchpad (for OEM strings, etc.)
|
||||
U8 Reserved[216]; // reserved for VBE implementation
|
||||
U8 ScratchPad[256]; // OEM scratchpad (for OEM strings, etc.)
|
||||
} PACKED VESA_SVGA_INFO, *PVESA_SVGA_INFO;
|
||||
|
||||
// Bitfields for VESA capabilities:
|
||||
@@ -106,11 +106,11 @@ VOID BiosSetVideoFont8x16(VOID)
|
||||
Int386(0x10, &Regs, &Regs);
|
||||
}
|
||||
|
||||
VOID VideoSetTextCursorPosition(ULONG X, ULONG Y)
|
||||
VOID VideoSetTextCursorPosition(U32 X, U32 Y)
|
||||
{
|
||||
}
|
||||
|
||||
ULONG VideoGetTextCursorPositionX(VOID)
|
||||
U32 VideoGetTextCursorPositionX(VOID)
|
||||
{
|
||||
REGS Regs;
|
||||
|
||||
@@ -135,7 +135,7 @@ ULONG VideoGetTextCursorPositionX(VOID)
|
||||
return Regs.b.dl;
|
||||
}
|
||||
|
||||
ULONG VideoGetTextCursorPositionY(VOID)
|
||||
U32 VideoGetTextCursorPositionY(VOID)
|
||||
{
|
||||
REGS Regs;
|
||||
|
||||
@@ -160,13 +160,13 @@ ULONG VideoGetTextCursorPositionY(VOID)
|
||||
return Regs.b.dh;
|
||||
}
|
||||
|
||||
USHORT BiosIsVesaSupported(VOID)
|
||||
U16 BiosIsVesaSupported(VOID)
|
||||
{
|
||||
REGS Regs;
|
||||
PVESA_SVGA_INFO SvgaInfo = (PVESA_SVGA_INFO)BIOSCALLBUFFER;
|
||||
#ifdef DEBUG
|
||||
//USHORT* VideoModes;
|
||||
//USHORT Index;
|
||||
//U16* VideoModes;
|
||||
//U16 Index;
|
||||
#endif // defined DEBUG
|
||||
|
||||
DbgPrint((DPRINT_UI, "BiosIsVesaSupported()\n"));
|
||||
@@ -227,7 +227,7 @@ USHORT BiosIsVesaSupported(VOID)
|
||||
DbgPrint((DPRINT_UI, "SvgaInfo->VBE/AF Version = 0x%x (BCD WORD)\n", SvgaInfo->VBE_AF_Version));
|
||||
|
||||
//DbgPrint((DPRINT_UI, "\nSupported VESA and OEM video modes:\n"));
|
||||
//VideoModes = (USHORT*)SvgaInfo->SupportedModeListPtr;
|
||||
//VideoModes = (U16*)SvgaInfo->SupportedModeListPtr;
|
||||
//for (Index=0; VideoModes[Index]!=0xFFFF; Index++)
|
||||
//{
|
||||
// DbgPrint((DPRINT_UI, "Mode %d: 0x%x\n", Index, VideoModes[Index]));
|
||||
@@ -236,7 +236,7 @@ USHORT BiosIsVesaSupported(VOID)
|
||||
//if (SvgaInfo->VesaVersion >= 0x0200)
|
||||
//{
|
||||
// DbgPrint((DPRINT_UI, "\nSupported accelerated video modes (VESA v2.0):\n"));
|
||||
// VideoModes = (USHORT*)SvgaInfo->AcceleratedModeListPtr;
|
||||
// VideoModes = (U16*)SvgaInfo->AcceleratedModeListPtr;
|
||||
// for (Index=0; VideoModes[Index]!=0xFFFF; Index++)
|
||||
// {
|
||||
// DbgPrint((DPRINT_UI, "Mode %d: 0x%x\n", Index, VideoModes[Index]));
|
@@ -30,7 +30,7 @@ EXTERN(_BootNewLinuxKernel)
|
||||
.code16
|
||||
|
||||
/* Set the boot drive */
|
||||
movb (_i386BootDrive),%dl
|
||||
movb (_BootDrive),%dl
|
||||
|
||||
/* Load segment registers */
|
||||
cli
|
||||
@@ -66,7 +66,7 @@ EXTERN(_BootOldLinuxKernel)
|
||||
.code16
|
||||
|
||||
/* Set the boot drive */
|
||||
movb (_i386BootDrive),%dl
|
||||
movb (_BootDrive),%dl
|
||||
|
||||
/* Load segment registers */
|
||||
cli
|
@@ -1,4 +1,4 @@
|
||||
/* $Id$
|
||||
/* $Id: machpc.c,v 1.7 2004/11/28 22:42:40 gvg Exp $
|
||||
*
|
||||
* FreeLoader
|
||||
*
|
||||
@@ -23,10 +23,9 @@
|
||||
#include "machine.h"
|
||||
#include "machpc.h"
|
||||
#include "rtl.h"
|
||||
#include "i386.h"
|
||||
|
||||
VOID
|
||||
PcMachInit(char *CmdLine)
|
||||
PcMachInit(VOID)
|
||||
{
|
||||
EnableA20();
|
||||
|
||||
@@ -49,11 +48,6 @@ PcMachInit(char *CmdLine)
|
||||
MachVtbl.VideoSync = PcVideoSync;
|
||||
MachVtbl.VideoPrepareForReactOS = PcVideoPrepareForReactOS;
|
||||
MachVtbl.GetMemoryMap = PcMemGetMemoryMap;
|
||||
MachVtbl.DiskGetBootVolume = i386DiskGetBootVolume;
|
||||
MachVtbl.DiskGetSystemVolume = i386DiskGetSystemVolume;
|
||||
MachVtbl.DiskGetBootPath = i386DiskGetBootPath;
|
||||
MachVtbl.DiskGetBootDevice = i386DiskGetBootDevice;
|
||||
MachVtbl.DiskBootingFromFloppy = i386DiskBootingFromFloppy;
|
||||
MachVtbl.DiskReadLogicalSectors = PcDiskReadLogicalSectors;
|
||||
MachVtbl.DiskGetPartitionEntry = PcDiskGetPartitionEntry;
|
||||
MachVtbl.DiskGetDriveGeometry = PcDiskGetDriveGeometry;
|
62
freeldr/freeldr/arch/i386/machpc.h
Normal file
62
freeldr/freeldr/arch/i386/machpc.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/* $Id: machpc.h,v 1.7 2004/11/28 22:42:40 gvg Exp $
|
||||
*
|
||||
* FreeLoader
|
||||
*
|
||||
* Copyright (C) 2003 Eric Kohl
|
||||
*
|
||||
* 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 __I386_MACHPC_H_
|
||||
#define __I386_MACHPC_H_
|
||||
|
||||
#ifndef __MEMORY_H
|
||||
#include "mm.h"
|
||||
#endif
|
||||
|
||||
VOID PcMachInit(VOID);
|
||||
|
||||
VOID PcConsPutChar(int Ch);
|
||||
BOOL PcConsKbHit();
|
||||
int PcConsGetCh();
|
||||
|
||||
VOID PcVideoClearScreen(U8 Attr);
|
||||
VIDEODISPLAYMODE PcVideoSetDisplayMode(char *DisplayMode, BOOL Init);
|
||||
VOID PcVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth);
|
||||
U32 PcVideoGetBufferSize(VOID);
|
||||
VOID PcVideoSetTextCursorPosition(U32 X, U32 Y);
|
||||
VOID PcVideoHideShowTextCursor(BOOL Show);
|
||||
VOID PcVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y);
|
||||
VOID PcVideoCopyOffScreenBufferToVRAM(PVOID Buffer);
|
||||
BOOL PcVideoIsPaletteFixed(VOID);
|
||||
VOID PcVideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue);
|
||||
VOID PcVideoGetPaletteColor(U8 Color, U8* Red, U8* Green, U8* Blue);
|
||||
VOID PcVideoSync(VOID);
|
||||
VOID PcVideoPrepareForReactOS(VOID);
|
||||
|
||||
U32 PcMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize);
|
||||
|
||||
BOOL PcDiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer);
|
||||
BOOL PcDiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
|
||||
BOOL PcDiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY DriveGeometry);
|
||||
U32 PcDiskGetCacheableBlockCount(U32 DriveNumber);
|
||||
|
||||
VOID PcRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second);
|
||||
|
||||
VOID PcHwDetect(VOID);
|
||||
|
||||
#endif /* __I386_MACHPC_H_ */
|
||||
|
||||
/* EOF */
|
@@ -1,4 +1,4 @@
|
||||
/* $Id$
|
||||
/* $Id: machxbox.c,v 1.7 2004/11/28 22:42:40 gvg Exp $
|
||||
*
|
||||
* FreeLoader
|
||||
*
|
||||
@@ -21,10 +21,9 @@
|
||||
#include "mm.h"
|
||||
#include "machine.h"
|
||||
#include "machxbox.h"
|
||||
#include "i386.h"
|
||||
|
||||
VOID
|
||||
XboxMachInit(char *CmdLine)
|
||||
XboxMachInit(VOID)
|
||||
{
|
||||
/* Initialize our stuff */
|
||||
XboxMemInit();
|
||||
@@ -47,11 +46,6 @@ XboxMachInit(char *CmdLine)
|
||||
MachVtbl.VideoSync = XboxVideoSync;
|
||||
MachVtbl.VideoPrepareForReactOS = XboxVideoPrepareForReactOS;
|
||||
MachVtbl.GetMemoryMap = XboxMemGetMemoryMap;
|
||||
MachVtbl.DiskGetBootVolume = i386DiskGetBootVolume;
|
||||
MachVtbl.DiskGetSystemVolume = i386DiskGetSystemVolume;
|
||||
MachVtbl.DiskGetBootPath = i386DiskGetBootPath;
|
||||
MachVtbl.DiskGetBootDevice = i386DiskGetBootDevice;
|
||||
MachVtbl.DiskBootingFromFloppy = i386DiskBootingFromFloppy;
|
||||
MachVtbl.DiskReadLogicalSectors = XboxDiskReadLogicalSectors;
|
||||
MachVtbl.DiskGetPartitionEntry = XboxDiskGetPartitionEntry;
|
||||
MachVtbl.DiskGetDriveGeometry = XboxDiskGetDriveGeometry;
|
65
freeldr/freeldr/arch/i386/machxbox.h
Normal file
65
freeldr/freeldr/arch/i386/machxbox.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/* $Id: machxbox.h,v 1.7 2004/11/28 22:42:40 gvg Exp $
|
||||
*
|
||||
* FreeLoader
|
||||
*
|
||||
* 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 __I386_MACHXBOX_H_
|
||||
#define __I386_MACHXBOX_H_
|
||||
|
||||
#ifndef __MEMORY_H
|
||||
#include "mm.h"
|
||||
#endif
|
||||
|
||||
U8 XboxFont8x16[256 * 16];
|
||||
|
||||
VOID XboxMachInit(VOID);
|
||||
|
||||
VOID XboxConsPutChar(int Ch);
|
||||
BOOL XboxConsKbHit();
|
||||
int XboxConsGetCh();
|
||||
|
||||
VOID XboxVideoInit(VOID);
|
||||
VOID XboxVideoClearScreen(U8 Attr);
|
||||
VIDEODISPLAYMODE XboxVideoSetDisplayMode(char *DisplayModem, BOOL Init);
|
||||
VOID XboxVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth);
|
||||
U32 XboxVideoGetBufferSize(VOID);
|
||||
VOID XboxVideoSetTextCursorPosition(U32 X, U32 Y);
|
||||
VOID XboxVideoHideShowTextCursor(BOOL Show);
|
||||
VOID XboxVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y);
|
||||
VOID XboxVideoCopyOffScreenBufferToVRAM(PVOID Buffer);
|
||||
BOOL XboxVideoIsPaletteFixed(VOID);
|
||||
VOID XboxVideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue);
|
||||
VOID XboxVideoGetPaletteColor(U8 Color, U8* Red, U8* Green, U8* Blue);
|
||||
VOID XboxVideoSync(VOID);
|
||||
VOID XboxVideoPrepareForReactOS(VOID);
|
||||
|
||||
VOID XboxMemInit(VOID);
|
||||
PVOID XboxMemReserveMemory(U32 MbToReserve);
|
||||
U32 XboxMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize);
|
||||
|
||||
BOOL XboxDiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer);
|
||||
BOOL XboxDiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
|
||||
BOOL XboxDiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY DriveGeometry);
|
||||
U32 XboxDiskGetCacheableBlockCount(U32 DriveNumber);
|
||||
|
||||
VOID XboxRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second);
|
||||
|
||||
VOID XboxHwDetect(VOID);
|
||||
|
||||
#endif /* __I386_HWXBOX_H_ */
|
||||
|
||||
/* EOF */
|
153
freeldr/freeldr/arch/i386/mb.S
Normal file
153
freeldr/freeldr/arch/i386/mb.S
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2002 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.
|
||||
*/
|
||||
|
||||
.text
|
||||
.code16
|
||||
|
||||
#define ASM
|
||||
#include <arch.h>
|
||||
#include <multiboot.h>
|
||||
|
||||
/*
|
||||
* Here we assume the kernel is loaded at 1mb
|
||||
* This boots the kernel
|
||||
*/
|
||||
.code32
|
||||
EXTERN(_boot_reactos)
|
||||
call _MachVideoPrepareForReactOS
|
||||
|
||||
call _multi_boot
|
||||
|
||||
// Should never get here
|
||||
cli
|
||||
bootloop:
|
||||
hlt
|
||||
jmp bootloop
|
||||
|
||||
|
||||
/*
|
||||
* After you have setup the _mb_header and _mb_info structures
|
||||
* then call this routine to transfer control to the kernel.
|
||||
*/
|
||||
EXTERN(_multi_boot)
|
||||
|
||||
cli
|
||||
|
||||
/*
|
||||
* Load the absolute address of the multiboot information structure
|
||||
*/
|
||||
movl $_mb_info,%ebx
|
||||
|
||||
/*
|
||||
* Initalize eflags
|
||||
*/
|
||||
pushl $0
|
||||
popfl
|
||||
|
||||
/*
|
||||
* Load the multiboot magic value into eax
|
||||
*/
|
||||
movl $0x2badb002,%eax
|
||||
|
||||
/*
|
||||
* Jump to start of 32 bit code at 0xc0000000 + 0x1000
|
||||
*/
|
||||
|
||||
pushl $KERNEL_CS
|
||||
pushl _mb_entry_addr
|
||||
lretl
|
||||
|
||||
|
||||
EXTERN(_mb_header)
|
||||
_mb_magic:
|
||||
.long 0 // unsigned long magic;
|
||||
_mb_flags:
|
||||
.long 0 // unsigned long flags;
|
||||
_mb_checksum:
|
||||
.long 0 // unsigned long checksum;
|
||||
_mb_header_addr:
|
||||
.long 0 // unsigned long header_addr;
|
||||
_mb_load_addr:
|
||||
.long 0 // unsigned long load_addr;
|
||||
_mb_load_end_addr:
|
||||
.long 0 // unsigned long load_end_addr;
|
||||
_mb_bss_end_addr:
|
||||
.long 0 // unsigned long bss_end_addr;
|
||||
_mb_entry_addr:
|
||||
.long 0 // unsigned long entry_addr;
|
||||
|
||||
//
|
||||
// Boot information structure
|
||||
//
|
||||
|
||||
EXTERN(_mb_info)
|
||||
_multiboot_flags:
|
||||
.long 0
|
||||
_multiboot_mem_lower:
|
||||
.long 0
|
||||
_multiboot_mem_upper:
|
||||
.long 0
|
||||
_multiboot_boot_device:
|
||||
.long 0
|
||||
_multiboot_cmdline:
|
||||
.long 0
|
||||
_multiboot_mods_count:
|
||||
.long 0
|
||||
_multiboot_mods_addr:
|
||||
.long 0
|
||||
_multiboot_syms:
|
||||
.rept 12
|
||||
.byte 0
|
||||
.endr
|
||||
_multiboot_mmap_length:
|
||||
.long 0
|
||||
_multiboot_mmap_addr:
|
||||
.long 0
|
||||
_multiboot_drives_count:
|
||||
.long 0
|
||||
_multiboot_drives_addr:
|
||||
.long 0
|
||||
_multiboot_config_table:
|
||||
.long 0
|
||||
_multiboot_boot_loader_name:
|
||||
.long 0
|
||||
_multiboot_apm_table:
|
||||
.long 0
|
||||
|
||||
EXTERN(_multiboot_modules)
|
||||
.rept (64 * /*multiboot_module_size*/ 16)
|
||||
.byte 0
|
||||
.endr
|
||||
EXTERN(_multiboot_module_strings)
|
||||
.rept (64*256)
|
||||
.byte 0
|
||||
.endr
|
||||
|
||||
EXTERN(_multiboot_memory_map_descriptor_size)
|
||||
.long 0
|
||||
|
||||
EXTERN(_multiboot_memory_map)
|
||||
.rept (32 * /*sizeof(memory_map_t)*/24)
|
||||
.byte 0
|
||||
.endr
|
||||
|
||||
EXTERN(_multiboot_kernel_cmdline)
|
||||
.rept 255
|
||||
.byte 0
|
||||
.endr
|
@@ -1,4 +1,4 @@
|
||||
/* $Id$
|
||||
/* $Id: pccons.c,v 1.3 2004/11/14 22:04:38 gvg Exp $
|
||||
*
|
||||
* FreeLoader
|
||||
*
|
@@ -29,13 +29,13 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UCHAR PacketSize; // 00h - Size of packet (10h or 18h)
|
||||
UCHAR Reserved; // 01h - Reserved (0)
|
||||
USHORT LBABlockCount; // 02h - Number of blocks to transfer (max 007Fh for Phoenix EDD)
|
||||
USHORT TransferBufferOffset; // 04h - Transfer buffer offset (seg:off)
|
||||
USHORT TransferBufferSegment; // Transfer buffer segment (seg:off)
|
||||
ULONGLONG LBAStartBlock; // 08h - Starting absolute block number
|
||||
ULONGLONG TransferBuffer64; // 10h - (EDD-3.0, optional) 64-bit flat address of transfer buffer
|
||||
U8 PacketSize; // 00h - Size of packet (10h or 18h)
|
||||
U8 Reserved; // 01h - Reserved (0)
|
||||
U16 LBABlockCount; // 02h - Number of blocks to transfer (max 007Fh for Phoenix EDD)
|
||||
U16 TransferBufferOffset; // 04h - Transfer buffer offset (seg:off)
|
||||
U16 TransferBufferSegment; // Transfer buffer segment (seg:off)
|
||||
U64 LBAStartBlock; // 08h - Starting absolute block number
|
||||
U64 TransferBuffer64; // 10h - (EDD-3.0, optional) 64-bit flat address of transfer buffer
|
||||
// used if DWORD at 04h is FFFFh:FFFFh
|
||||
} PACKED I386_DISK_ADDRESS_PACKET, *PI386_DISK_ADDRESS_PACKET;
|
||||
|
||||
@@ -43,7 +43,7 @@ typedef struct
|
||||
// FUNCTIONS
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static BOOL PcDiskResetController(ULONG DriveNumber)
|
||||
static BOOL PcDiskResetController(U32 DriveNumber)
|
||||
{
|
||||
REGS RegsIn;
|
||||
REGS RegsOut;
|
||||
@@ -66,11 +66,11 @@ static BOOL PcDiskResetController(ULONG DriveNumber)
|
||||
return INT386_SUCCESS(RegsOut);
|
||||
}
|
||||
|
||||
static BOOL PcDiskReadLogicalSectorsLBA(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
|
||||
static BOOL PcDiskReadLogicalSectorsLBA(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer)
|
||||
{
|
||||
REGS RegsIn;
|
||||
REGS RegsOut;
|
||||
ULONG RetryCount;
|
||||
U32 RetryCount;
|
||||
PI386_DISK_ADDRESS_PACKET Packet = (PI386_DISK_ADDRESS_PACKET)(BIOSCALLBUFFER);
|
||||
|
||||
DbgPrint((DPRINT_DISK, "PcDiskReadLogicalSectorsLBA() DriveNumber: 0x%x SectorNumber: %I64d SectorCount: %d Buffer: 0x%x\n", DriveNumber, SectorNumber, SectorCount, Buffer));
|
||||
@@ -86,8 +86,8 @@ static BOOL PcDiskReadLogicalSectorsLBA(ULONG DriveNumber, ULONGLONG SectorNumbe
|
||||
Packet->PacketSize = sizeof(I386_DISK_ADDRESS_PACKET);
|
||||
Packet->Reserved = 0;
|
||||
Packet->LBABlockCount = SectorCount;
|
||||
Packet->TransferBufferOffset = ((ULONG)Buffer) & 0x0F;
|
||||
Packet->TransferBufferSegment = ((ULONG)Buffer) >> 4;
|
||||
Packet->TransferBufferOffset = ((U32)Buffer) & 0x0F;
|
||||
Packet->TransferBufferSegment = ((U32)Buffer) >> 4;
|
||||
Packet->LBAStartBlock = SectorNumber;
|
||||
Packet->TransferBuffer64 = 0;
|
||||
|
||||
@@ -130,25 +130,23 @@ static BOOL PcDiskReadLogicalSectorsLBA(ULONG DriveNumber, ULONGLONG SectorNumbe
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL PcDiskReadLogicalSectorsCHS(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
|
||||
static BOOL PcDiskReadLogicalSectorsCHS(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer)
|
||||
{
|
||||
ULONG PhysicalSector;
|
||||
ULONG PhysicalHead;
|
||||
ULONG PhysicalTrack;
|
||||
U32 PhysicalSector;
|
||||
U32 PhysicalHead;
|
||||
U32 PhysicalTrack;
|
||||
GEOMETRY DriveGeometry;
|
||||
ULONG NumberOfSectorsToRead;
|
||||
U32 NumberOfSectorsToRead;
|
||||
REGS RegsIn;
|
||||
REGS RegsOut;
|
||||
ULONG RetryCount;
|
||||
U32 RetryCount;
|
||||
|
||||
DbgPrint((DPRINT_DISK, "PcDiskReadLogicalSectorsCHS()\n"));
|
||||
|
||||
//
|
||||
// Get the drive geometry
|
||||
//
|
||||
if (!MachDiskGetDriveGeometry(DriveNumber, &DriveGeometry) ||
|
||||
DriveGeometry.Sectors == 0 ||
|
||||
DriveGeometry.Heads == 0)
|
||||
if (!MachDiskGetDriveGeometry(DriveNumber, &DriveGeometry))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -215,8 +213,8 @@ static BOOL PcDiskReadLogicalSectorsCHS(ULONG DriveNumber, ULONGLONG SectorNumbe
|
||||
RegsIn.b.cl = (PhysicalSector + ((PhysicalTrack & 0x300) >> 2));
|
||||
RegsIn.b.dh = PhysicalHead;
|
||||
RegsIn.b.dl = DriveNumber;
|
||||
RegsIn.w.es = ((ULONG)Buffer) >> 4;
|
||||
RegsIn.w.bx = ((ULONG)Buffer) & 0x0F;
|
||||
RegsIn.w.es = ((U32)Buffer) >> 4;
|
||||
RegsIn.w.bx = ((U32)Buffer) & 0x0F;
|
||||
|
||||
//
|
||||
// Perform the read
|
||||
@@ -266,9 +264,9 @@ static BOOL PcDiskReadLogicalSectorsCHS(ULONG DriveNumber, ULONGLONG SectorNumbe
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL PcDiskInt13ExtensionsSupported(ULONG DriveNumber)
|
||||
static BOOL PcDiskInt13ExtensionsSupported(U32 DriveNumber)
|
||||
{
|
||||
static ULONG LastDriveNumber = 0xffffffff;
|
||||
static U32 LastDriveNumber = 0xffffffff;
|
||||
static BOOL LastSupported;
|
||||
REGS RegsIn;
|
||||
REGS RegsOut;
|
||||
@@ -355,7 +353,7 @@ static BOOL PcDiskInt13ExtensionsSupported(ULONG DriveNumber)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL PcDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
|
||||
BOOL PcDiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer)
|
||||
{
|
||||
|
||||
DbgPrint((DPRINT_DISK, "PcDiskReadLogicalSectors() DriveNumber: 0x%x SectorNumber: %I64d SectorCount: %d Buffer: 0x%x\n", DriveNumber, SectorNumber, SectorCount, Buffer));
|
||||
@@ -385,18 +383,18 @@ BOOL PcDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG S
|
||||
}
|
||||
|
||||
BOOL
|
||||
PcDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
|
||||
PcDiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
|
||||
{
|
||||
/* Just use the standard routine */
|
||||
return DiskGetPartitionEntry(DriveNumber, PartitionNumber, PartitionTableEntry);
|
||||
}
|
||||
|
||||
BOOL
|
||||
PcDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY Geometry)
|
||||
PcDiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY Geometry)
|
||||
{
|
||||
REGS RegsIn;
|
||||
REGS RegsOut;
|
||||
ULONG Cylinders;
|
||||
U32 Cylinders;
|
||||
|
||||
DbgPrint((DPRINT_DISK, "DiskGetDriveGeometry()\n"));
|
||||
|
||||
@@ -442,8 +440,8 @@ PcDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY Geometry)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ULONG
|
||||
PcDiskGetCacheableBlockCount(ULONG DriveNumber)
|
||||
U32
|
||||
PcDiskGetCacheableBlockCount(U32 DriveNumber)
|
||||
{
|
||||
GEOMETRY Geometry;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id$
|
||||
/* $Id: pcmem.c,v 1.2 2004/11/10 23:45:37 gvg Exp $
|
||||
*
|
||||
* FreeLoader
|
||||
*
|
||||
@@ -28,12 +28,12 @@
|
||||
#include "portio.h"
|
||||
#include "rtl.h"
|
||||
|
||||
static ULONG
|
||||
static U32
|
||||
PcMemGetExtendedMemorySize(VOID)
|
||||
{
|
||||
REGS RegsIn;
|
||||
REGS RegsOut;
|
||||
ULONG MemorySize;
|
||||
U32 MemorySize;
|
||||
|
||||
DbgPrint((DPRINT_MEMORY, "GetExtendedMemorySize()\n"));
|
||||
|
||||
@@ -119,7 +119,7 @@ PcMemGetExtendedMemorySize(VOID)
|
||||
return MemorySize;
|
||||
}
|
||||
|
||||
static ULONG
|
||||
static U32
|
||||
PcMemGetConventionalMemorySize(VOID)
|
||||
{
|
||||
REGS Regs;
|
||||
@@ -141,14 +141,14 @@ PcMemGetConventionalMemorySize(VOID)
|
||||
DbgPrint((DPRINT_MEMORY, "Int12h\n"));
|
||||
DbgPrint((DPRINT_MEMORY, "AX = 0x%x\n\n", Regs.w.ax));
|
||||
|
||||
return (ULONG)Regs.w.ax;
|
||||
return (U32)Regs.w.ax;
|
||||
}
|
||||
|
||||
static ULONG
|
||||
PcMemGetBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize)
|
||||
static U32
|
||||
PcMemGetBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize)
|
||||
{
|
||||
REGS Regs;
|
||||
ULONG MapCount;
|
||||
U32 MapCount;
|
||||
|
||||
DbgPrint((DPRINT_MEMORY, "GetBiosMemoryMap()\n"));
|
||||
|
||||
@@ -225,10 +225,10 @@ PcMemGetBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize)
|
||||
return MapCount;
|
||||
}
|
||||
|
||||
ULONG
|
||||
PcMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize)
|
||||
U32
|
||||
PcMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize)
|
||||
{
|
||||
ULONG EntryCount;
|
||||
U32 EntryCount;
|
||||
|
||||
EntryCount = PcMemGetBiosMemoryMap(BiosMemoryMap, MaxMemoryMapSize);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id$
|
||||
/* $Id: pcrtc.c,v 1.1 2004/11/14 22:04:38 gvg Exp $
|
||||
*
|
||||
* FreeLoader
|
||||
*
|
||||
@@ -25,7 +25,7 @@
|
||||
#define BCD_INT(bcd) (((bcd & 0xf0) >> 4) * 10 + (bcd &0x0f))
|
||||
|
||||
VOID
|
||||
PcRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second)
|
||||
PcRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second)
|
||||
{
|
||||
REGS Regs;
|
||||
|
||||
@@ -55,7 +55,7 @@ PcRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULO
|
||||
|
||||
if (NULL != Year)
|
||||
{
|
||||
*Year = 100 * BCD_INT(Regs.b.ch) + BCD_INT(Regs.b.cl);
|
||||
*Year = 100 * BCD_INT(Regs.b.cl) + BCD_INT(Regs.b.ch);
|
||||
}
|
||||
if (NULL != Month)
|
||||
{
|
@@ -1,4 +1,4 @@
|
||||
/* $Id$
|
||||
/* $Id: pcvideo.c,v 1.3 2004/12/13 15:07:33 gvg Exp $
|
||||
*
|
||||
* FreeLoader
|
||||
*
|
||||
@@ -56,69 +56,69 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
USHORT ModeAttributes; /* mode attributes (see #00080) */
|
||||
UCHAR WindowAttributesA; /* window attributes, window A (see #00081) */
|
||||
UCHAR WindowsAttributesB; /* window attributes, window B (see #00081) */
|
||||
USHORT WindowGranularity; /* window granularity in KB */
|
||||
USHORT WindowSize; /* window size in KB */
|
||||
USHORT WindowAStartSegment; /* start segment of window A (0000h if not supported) */
|
||||
USHORT WindowBStartSegment; /* start segment of window B (0000h if not supported) */
|
||||
ULONG WindowPositioningFunction; /* -> FAR window positioning function (equivalent to AX=4F05h) */
|
||||
USHORT BytesPerScanLine; /* bytes per scan line */
|
||||
U16 ModeAttributes; /* mode attributes (see #00080) */
|
||||
U8 WindowAttributesA; /* window attributes, window A (see #00081) */
|
||||
U8 WindowsAttributesB; /* window attributes, window B (see #00081) */
|
||||
U16 WindowGranularity; /* window granularity in KB */
|
||||
U16 WindowSize; /* window size in KB */
|
||||
U16 WindowAStartSegment; /* start segment of window A (0000h if not supported) */
|
||||
U16 WindowBStartSegment; /* start segment of window B (0000h if not supported) */
|
||||
U32 WindowPositioningFunction; /* -> FAR window positioning function (equivalent to AX=4F05h) */
|
||||
U16 BytesPerScanLine; /* bytes per scan line */
|
||||
/* ---remainder is optional for VESA modes in v1.0/1.1, needed for OEM modes--- */
|
||||
USHORT WidthInPixels; /* width in pixels (graphics) or characters (text) */
|
||||
USHORT HeightInPixels; /* height in pixels (graphics) or characters (text) */
|
||||
UCHAR CharacterWidthInPixels; /* width of character cell in pixels */
|
||||
UCHAR CharacterHeightInPixels; /* height of character cell in pixels */
|
||||
UCHAR NumberOfMemoryPlanes; /* number of memory planes */
|
||||
UCHAR BitsPerPixel; /* number of bits per pixel */
|
||||
UCHAR NumberOfBanks; /* number of banks */
|
||||
UCHAR MemoryModel; /* memory model type (see #00082) */
|
||||
UCHAR BankSize; /* size of bank in KB */
|
||||
UCHAR NumberOfImagePanes; /* number of image pages (less one) that will fit in video RAM */
|
||||
UCHAR Reserved1; /* reserved (00h for VBE 1.0-2.0, 01h for VBE 3.0) */
|
||||
U16 WidthInPixels; /* width in pixels (graphics) or characters (text) */
|
||||
U16 HeightInPixels; /* height in pixels (graphics) or characters (text) */
|
||||
U8 CharacterWidthInPixels; /* width of character cell in pixels */
|
||||
U8 CharacterHeightInPixels; /* height of character cell in pixels */
|
||||
U8 NumberOfMemoryPlanes; /* number of memory planes */
|
||||
U8 BitsPerPixel; /* number of bits per pixel */
|
||||
U8 NumberOfBanks; /* number of banks */
|
||||
U8 MemoryModel; /* memory model type (see #00082) */
|
||||
U8 BankSize; /* size of bank in KB */
|
||||
U8 NumberOfImagePanes; /* number of image pages (less one) that will fit in video RAM */
|
||||
U8 Reserved1; /* reserved (00h for VBE 1.0-2.0, 01h for VBE 3.0) */
|
||||
/* ---VBE v1.2+ --- */
|
||||
UCHAR RedMaskSize; /* red mask size */
|
||||
UCHAR RedMaskPosition; /* red field position */
|
||||
UCHAR GreenMaskSize; /* green mask size */
|
||||
UCHAR GreenMaskPosition; /* green field size */
|
||||
UCHAR BlueMaskSize; /* blue mask size */
|
||||
UCHAR BlueMaskPosition; /* blue field size */
|
||||
UCHAR ReservedMaskSize; /* reserved mask size */
|
||||
UCHAR ReservedMaskPosition; /* reserved mask position */
|
||||
UCHAR DirectColorModeInfo; /* direct color mode info */
|
||||
U8 RedMaskSize; /* red mask size */
|
||||
U8 RedMaskPosition; /* red field position */
|
||||
U8 GreenMaskSize; /* green mask size */
|
||||
U8 GreenMaskPosition; /* green field size */
|
||||
U8 BlueMaskSize; /* blue mask size */
|
||||
U8 BlueMaskPosition; /* blue field size */
|
||||
U8 ReservedMaskSize; /* reserved mask size */
|
||||
U8 ReservedMaskPosition; /* reserved mask position */
|
||||
U8 DirectColorModeInfo; /* direct color mode info */
|
||||
/* bit 0:Color ramp is programmable */
|
||||
/* bit 1:Bytes in reserved field may be used by application */
|
||||
/* ---VBE v2.0+ --- */
|
||||
ULONG LinearVideoBufferAddress; /* physical address of linear video buffer */
|
||||
ULONG OffscreenMemoryPointer; /* pointer to start of offscreen memory */
|
||||
USHORT OffscreenMemorySize; /* KB of offscreen memory */
|
||||
U32 LinearVideoBufferAddress; /* physical address of linear video buffer */
|
||||
U32 OffscreenMemoryPointer; /* pointer to start of offscreen memory */
|
||||
U16 OffscreenMemorySize; /* KB of offscreen memory */
|
||||
/* ---VBE v3.0 --- */
|
||||
USHORT LinearBytesPerScanLine; /* bytes per scan line in linear modes */
|
||||
UCHAR BankedNumberOfImages; /* number of images (less one) for banked video modes */
|
||||
UCHAR LinearNumberOfImages; /* number of images (less one) for linear video modes */
|
||||
UCHAR LinearRedMaskSize; /* linear modes:Size of direct color red mask (in bits) */
|
||||
UCHAR LinearRedMaskPosition; /* linear modes:Bit position of red mask LSB (e.g. shift count) */
|
||||
UCHAR LinearGreenMaskSize; /* linear modes:Size of direct color green mask (in bits) */
|
||||
UCHAR LinearGreenMaskPosition; /* linear modes:Bit position of green mask LSB (e.g. shift count) */
|
||||
UCHAR LinearBlueMaskSize; /* linear modes:Size of direct color blue mask (in bits) */
|
||||
UCHAR LinearBlueMaskPosition; /* linear modes:Bit position of blue mask LSB (e.g. shift count) */
|
||||
UCHAR LinearReservedMaskSize; /* linear modes:Size of direct color reserved mask (in bits) */
|
||||
UCHAR LinearReservedMaskPosition; /* linear modes:Bit position of reserved mask LSB */
|
||||
ULONG MaximumPixelClock; /* maximum pixel clock for graphics video mode, in Hz */
|
||||
UCHAR Reserved2[190]; /* 190 BYTEs reserved (0) */
|
||||
U16 LinearBytesPerScanLine; /* bytes per scan line in linear modes */
|
||||
U8 BankedNumberOfImages; /* number of images (less one) for banked video modes */
|
||||
U8 LinearNumberOfImages; /* number of images (less one) for linear video modes */
|
||||
U8 LinearRedMaskSize; /* linear modes:Size of direct color red mask (in bits) */
|
||||
U8 LinearRedMaskPosition; /* linear modes:Bit position of red mask LSB (e.g. shift count) */
|
||||
U8 LinearGreenMaskSize; /* linear modes:Size of direct color green mask (in bits) */
|
||||
U8 LinearGreenMaskPosition; /* linear modes:Bit position of green mask LSB (e.g. shift count) */
|
||||
U8 LinearBlueMaskSize; /* linear modes:Size of direct color blue mask (in bits) */
|
||||
U8 LinearBlueMaskPosition; /* linear modes:Bit position of blue mask LSB (e.g. shift count) */
|
||||
U8 LinearReservedMaskSize; /* linear modes:Size of direct color reserved mask (in bits) */
|
||||
U8 LinearReservedMaskPosition; /* linear modes:Bit position of reserved mask LSB */
|
||||
U32 MaximumPixelClock; /* maximum pixel clock for graphics video mode, in Hz */
|
||||
U8 Reserved2[190]; /* 190 BYTEs reserved (0) */
|
||||
} PACKED SVGA_MODE_INFORMATION, *PSVGA_MODE_INFORMATION;
|
||||
|
||||
static ULONG BiosVideoMode; /* Current video mode as known by BIOS */
|
||||
static ULONG ScreenWidth = 80; /* Screen Width in characters */
|
||||
static ULONG ScreenHeight = 25; /* Screen Height in characters */
|
||||
static ULONG BytesPerScanLine = 160; /* Number of bytes per scanline (delta) */
|
||||
static U32 BiosVideoMode; /* Current video mode as known by BIOS */
|
||||
static U32 ScreenWidth = 80; /* Screen Width in characters */
|
||||
static U32 ScreenHeight = 25; /* Screen Height in characters */
|
||||
static U32 BytesPerScanLine = 160; /* Number of bytes per scanline (delta) */
|
||||
static VIDEODISPLAYMODE DisplayMode = VideoTextMode; /* Current display mode */
|
||||
static BOOL VesaVideoMode = FALSE; /* Are we using a VESA mode? */
|
||||
static SVGA_MODE_INFORMATION VesaVideoModeInformation; /* Only valid when in VESA mode */
|
||||
static ULONG CurrentMemoryBank = 0; /* Currently selected VESA bank */
|
||||
static U32 CurrentMemoryBank = 0; /* Currently selected VESA bank */
|
||||
|
||||
static ULONG
|
||||
static U32
|
||||
PcVideoDetectVideoCard(VOID)
|
||||
{
|
||||
REGS Regs;
|
||||
@@ -192,7 +192,7 @@ PcVideoDetectVideoCard(VOID)
|
||||
}
|
||||
}
|
||||
|
||||
static VOID PcVideoSetBiosMode(ULONG VideoMode)
|
||||
static VOID PcVideoSetBiosMode(U32 VideoMode)
|
||||
{
|
||||
REGS Regs;
|
||||
|
||||
@@ -297,7 +297,7 @@ VOID PcVideoDisableCursorEmulation(VOID)
|
||||
}
|
||||
|
||||
static VOID
|
||||
PcVideoDefineCursor(ULONG StartScanLine, ULONG EndScanLine)
|
||||
PcVideoDefineCursor(U32 StartScanLine, U32 EndScanLine)
|
||||
{
|
||||
REGS Regs;
|
||||
|
||||
@@ -333,7 +333,7 @@ PcVideoDefineCursor(ULONG StartScanLine, ULONG EndScanLine)
|
||||
}
|
||||
|
||||
static VOID
|
||||
PcVideoSetVerticalResolution(ULONG ScanLines)
|
||||
PcVideoSetVerticalResolution(U32 ScanLines)
|
||||
{
|
||||
REGS Regs;
|
||||
|
||||
@@ -439,7 +439,7 @@ PcVideoSetDisplayEnd(VOID)
|
||||
}
|
||||
|
||||
static BOOL
|
||||
PcVideoVesaGetSVGAModeInformation(USHORT Mode, PSVGA_MODE_INFORMATION ModeInformation)
|
||||
PcVideoVesaGetSVGAModeInformation(U16 Mode, PSVGA_MODE_INFORMATION ModeInformation)
|
||||
{
|
||||
REGS Regs;
|
||||
|
||||
@@ -511,7 +511,7 @@ PcVideoVesaGetSVGAModeInformation(USHORT Mode, PSVGA_MODE_INFORMATION ModeInform
|
||||
}
|
||||
|
||||
static BOOL
|
||||
PcVideoSetBiosVesaMode(USHORT Mode)
|
||||
PcVideoSetBiosVesaMode(U16 Mode)
|
||||
{
|
||||
REGS Regs;
|
||||
|
||||
@@ -697,7 +697,7 @@ PcVideoSetMode80x60(VOID)
|
||||
}
|
||||
|
||||
static BOOL
|
||||
PcVideoSetMode(ULONG NewMode)
|
||||
PcVideoSetMode(U32 NewMode)
|
||||
{
|
||||
CurrentMemoryBank = 0;
|
||||
|
||||
@@ -735,7 +735,7 @@ PcVideoSetMode(ULONG NewMode)
|
||||
{
|
||||
/* 640x480x16 */
|
||||
PcVideoSetBiosMode(NewMode);
|
||||
WRITE_PORT_USHORT((USHORT*)0x03CE, 0x0F01); /* For some reason this is necessary? */
|
||||
WRITE_PORT_USHORT((U16*)0x03CE, 0x0F01); /* For some reason this is necessary? */
|
||||
ScreenWidth = 640;
|
||||
ScreenHeight = 480;
|
||||
BytesPerScanLine = 80;
|
||||
@@ -830,7 +830,7 @@ PcVideoSetBlinkBit(BOOL Enable)
|
||||
}
|
||||
|
||||
static VOID
|
||||
PcVideoSetMemoryBank(USHORT BankNumber)
|
||||
PcVideoSetMemoryBank(U16 BankNumber)
|
||||
{
|
||||
REGS Regs;
|
||||
|
||||
@@ -870,7 +870,7 @@ PcVideoSetMemoryBank(USHORT BankNumber)
|
||||
VIDEODISPLAYMODE
|
||||
PcVideoSetDisplayMode(char *DisplayModeName, BOOL Init)
|
||||
{
|
||||
ULONG VideoMode = VIDEOMODE_NORMAL_TEXT;
|
||||
U32 VideoMode = VIDEOMODE_NORMAL_TEXT;
|
||||
|
||||
if (NULL == DisplayModeName || '\0' == *DisplayModeName)
|
||||
{
|
||||
@@ -927,7 +927,7 @@ PcVideoSetDisplayMode(char *DisplayModeName, BOOL Init)
|
||||
}
|
||||
|
||||
VOID
|
||||
PcVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
|
||||
PcVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth)
|
||||
{
|
||||
*Width = ScreenWidth;
|
||||
*Height = ScreenHeight;
|
||||
@@ -950,14 +950,14 @@ PcVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
|
||||
}
|
||||
}
|
||||
|
||||
ULONG
|
||||
U32
|
||||
PcVideoGetBufferSize(VOID)
|
||||
{
|
||||
return ScreenHeight * BytesPerScanLine;
|
||||
}
|
||||
|
||||
VOID
|
||||
PcVideoSetTextCursorPosition(ULONG X, ULONG Y)
|
||||
PcVideoSetTextCursorPosition(U32 X, U32 Y)
|
||||
{
|
||||
REGS Regs;
|
||||
|
||||
@@ -997,10 +997,10 @@ PcVideoHideShowTextCursor(BOOL Show)
|
||||
VOID
|
||||
PcVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
|
||||
{
|
||||
ULONG BanksToCopy;
|
||||
ULONG BytesInLastBank;
|
||||
ULONG CurrentBank;
|
||||
ULONG BankSize;
|
||||
U32 BanksToCopy;
|
||||
U32 BytesInLastBank;
|
||||
U32 CurrentBank;
|
||||
U32 BankSize;
|
||||
|
||||
/* PcVideoWaitForVerticalRetrace(); */
|
||||
|
||||
@@ -1036,14 +1036,14 @@ PcVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
|
||||
}
|
||||
|
||||
VOID
|
||||
PcVideoClearScreen(UCHAR Attr)
|
||||
PcVideoClearScreen(U8 Attr)
|
||||
{
|
||||
USHORT AttrChar;
|
||||
USHORT *BufPtr;
|
||||
U16 AttrChar;
|
||||
U16 *BufPtr;
|
||||
|
||||
AttrChar = ((USHORT) Attr << 8) | ' ';
|
||||
for (BufPtr = (USHORT *) VIDEOTEXT_MEM_ADDRESS;
|
||||
BufPtr < (USHORT *) (VIDEOTEXT_MEM_ADDRESS + VIDEOTEXT_MEM_SIZE);
|
||||
AttrChar = ((U16) Attr << 8) | ' ';
|
||||
for (BufPtr = (U16 *) VIDEOTEXT_MEM_ADDRESS;
|
||||
BufPtr < (U16 *) (VIDEOTEXT_MEM_ADDRESS + VIDEOTEXT_MEM_SIZE);
|
||||
BufPtr++)
|
||||
{
|
||||
*BufPtr = AttrChar;
|
||||
@@ -1051,12 +1051,12 @@ PcVideoClearScreen(UCHAR Attr)
|
||||
}
|
||||
|
||||
VOID
|
||||
PcVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
|
||||
PcVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y)
|
||||
{
|
||||
USHORT *BufPtr;
|
||||
U16 *BufPtr;
|
||||
|
||||
BufPtr = (USHORT *) (VIDEOTEXT_MEM_ADDRESS + Y * BytesPerScanLine + X * 2);
|
||||
*BufPtr = ((USHORT) Attr << 8) | (Ch & 0xff);
|
||||
BufPtr = (U16 *) (VIDEOTEXT_MEM_ADDRESS + Y * BytesPerScanLine + X * 2);
|
||||
*BufPtr = ((U16) Attr << 8) | (Ch & 0xff);
|
||||
}
|
||||
|
||||
BOOL
|
||||
@@ -1066,27 +1066,27 @@ PcVideoIsPaletteFixed(VOID)
|
||||
}
|
||||
|
||||
VOID
|
||||
PcVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
|
||||
PcVideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue)
|
||||
{
|
||||
WRITE_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_WRITE, Color);
|
||||
WRITE_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_DATA, Red);
|
||||
WRITE_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_DATA, Green);
|
||||
WRITE_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_DATA, Blue);
|
||||
WRITE_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_WRITE, Color);
|
||||
WRITE_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_DATA, Red);
|
||||
WRITE_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_DATA, Green);
|
||||
WRITE_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_DATA, Blue);
|
||||
}
|
||||
|
||||
VOID
|
||||
PcVideoGetPaletteColor(UCHAR Color, UCHAR* Red, UCHAR* Green, UCHAR* Blue)
|
||||
PcVideoGetPaletteColor(U8 Color, U8* Red, U8* Green, U8* Blue)
|
||||
{
|
||||
WRITE_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_READ, Color);
|
||||
*Red = READ_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_DATA);
|
||||
*Green = READ_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_DATA);
|
||||
*Blue = READ_PORT_UCHAR((UCHAR*) VIDEOPORT_PALETTE_DATA);
|
||||
WRITE_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_READ, Color);
|
||||
*Red = READ_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_DATA);
|
||||
*Green = READ_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_DATA);
|
||||
*Blue = READ_PORT_UCHAR((U8*) VIDEOPORT_PALETTE_DATA);
|
||||
}
|
||||
|
||||
VOID
|
||||
PcVideoSync(VOID)
|
||||
{
|
||||
while (1 == (READ_PORT_UCHAR((UCHAR*)VIDEOPORT_VERTICAL_RETRACE) & 0x08))
|
||||
while (1 == (READ_PORT_UCHAR((U8*)VIDEOPORT_VERTICAL_RETRACE) & 0x08))
|
||||
{
|
||||
/*
|
||||
* Keep reading the port until bit 3 is clear
|
||||
@@ -1096,7 +1096,7 @@ PcVideoSync(VOID)
|
||||
*/
|
||||
}
|
||||
|
||||
while (0 == (READ_PORT_UCHAR((UCHAR*)VIDEOPORT_VERTICAL_RETRACE) & 0x08))
|
||||
while (0 == (READ_PORT_UCHAR((U8*)VIDEOPORT_VERTICAL_RETRACE) & 0x08))
|
||||
{
|
||||
/*
|
||||
* Keep reading the port until bit 3 is set
|
183
freeldr/freeldr/arch/i386/portio.c
Normal file
183
freeldr/freeldr/arch/i386/portio.c
Normal file
@@ -0,0 +1,183 @@
|
||||
/* $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
|
||||
* FILE: ntoskrnl/hal/x86/portio.c
|
||||
* PURPOSE: Port I/O functions
|
||||
* PROGRAMMER: Eric Kohl (ekohl@abo.rhein-zeitung.de)
|
||||
* UPDATE HISTORY:
|
||||
* Created 18/10/99
|
||||
*/
|
||||
|
||||
//#include <ddk/ntddk.h>
|
||||
#include <freeldr.h>
|
||||
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
/*
|
||||
* This file contains the definitions for the x86 IO instructions
|
||||
* inb/inw/inl/outb/outw/outl and the "string versions" of the same
|
||||
* (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
|
||||
* versions of the single-IO instructions (inb_p/inw_p/..).
|
||||
*
|
||||
* This file is not meant to be obfuscating: it's just complicated
|
||||
* to (a) handle it all in a way that makes gcc able to optimize it
|
||||
* as well as possible and (b) trying to avoid writing the same thing
|
||||
* over and over again with slight variations and possibly making a
|
||||
* mistake somewhere.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Thanks to James van Artsdalen for a better timing-fix than
|
||||
* the two short jumps: using outb's to a nonexistent port seems
|
||||
* to guarantee better timings even on fast machines.
|
||||
*
|
||||
* On the other hand, I'd like to be sure of a non-existent port:
|
||||
* I feel a bit unsafe about using 0x80 (should be safe, though)
|
||||
*
|
||||
* Linus
|
||||
*/
|
||||
|
||||
#ifdef SLOW_IO_BY_JUMPING
|
||||
#define __SLOW_DOWN_IO __asm__ __volatile__("jmp 1f\n1:\tjmp 1f\n1:")
|
||||
#else
|
||||
#define __SLOW_DOWN_IO __asm__ __volatile__("outb %al,$0x80")
|
||||
#endif
|
||||
|
||||
#ifdef REALLY_SLOW_IO
|
||||
#define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; }
|
||||
#else
|
||||
#define SLOW_DOWN_IO __SLOW_DOWN_IO
|
||||
#endif
|
||||
|
||||
VOID /*STDCALL*/
|
||||
READ_PORT_BUFFER_UCHAR (PUCHAR Port,
|
||||
PUCHAR Buffer,
|
||||
U32 Count)
|
||||
{
|
||||
__asm__ __volatile__ ("cld ; rep ; insb\n\t"
|
||||
: "=D" (Buffer), "=c" (Count)
|
||||
: "d" (Port),"0" (Buffer),"1" (Count));
|
||||
}
|
||||
|
||||
VOID /*STDCALL*/
|
||||
READ_PORT_BUFFER_USHORT (U16* Port,
|
||||
U16* Buffer,
|
||||
U32 Count)
|
||||
{
|
||||
__asm__ __volatile__ ("cld ; rep ; insw"
|
||||
: "=D" (Buffer), "=c" (Count)
|
||||
: "d" (Port),"0" (Buffer),"1" (Count));
|
||||
}
|
||||
|
||||
VOID /*STDCALL*/
|
||||
READ_PORT_BUFFER_ULONG (U32* Port,
|
||||
U32* Buffer,
|
||||
U32 Count)
|
||||
{
|
||||
__asm__ __volatile__ ("cld ; rep ; insl"
|
||||
: "=D" (Buffer), "=c" (Count)
|
||||
: "d" (Port),"0" (Buffer),"1" (Count));
|
||||
}
|
||||
|
||||
UCHAR /*STDCALL*/
|
||||
READ_PORT_UCHAR (PUCHAR Port)
|
||||
{
|
||||
UCHAR Value;
|
||||
|
||||
__asm__("inb %w1, %0\n\t"
|
||||
: "=a" (Value)
|
||||
: "d" (Port));
|
||||
SLOW_DOWN_IO;
|
||||
return(Value);
|
||||
}
|
||||
|
||||
U16 /*STDCALL*/
|
||||
READ_PORT_USHORT (U16* Port)
|
||||
{
|
||||
U16 Value;
|
||||
|
||||
__asm__("inw %w1, %0\n\t"
|
||||
: "=a" (Value)
|
||||
: "d" (Port));
|
||||
SLOW_DOWN_IO;
|
||||
return(Value);
|
||||
}
|
||||
|
||||
U32 /*STDCALL*/
|
||||
READ_PORT_ULONG (U32* Port)
|
||||
{
|
||||
U32 Value;
|
||||
|
||||
__asm__("inl %w1, %0\n\t"
|
||||
: "=a" (Value)
|
||||
: "d" (Port));
|
||||
SLOW_DOWN_IO;
|
||||
return(Value);
|
||||
}
|
||||
|
||||
VOID /*STDCALL*/
|
||||
WRITE_PORT_BUFFER_UCHAR (PUCHAR Port,
|
||||
PUCHAR Buffer,
|
||||
U32 Count)
|
||||
{
|
||||
__asm__ __volatile__ ("cld ; rep ; outsb"
|
||||
: "=S" (Buffer), "=c" (Count)
|
||||
: "d" (Port),"0" (Buffer),"1" (Count));
|
||||
}
|
||||
|
||||
VOID /*STDCALL*/
|
||||
WRITE_PORT_BUFFER_USHORT (U16* Port,
|
||||
U16* Buffer,
|
||||
U32 Count)
|
||||
{
|
||||
__asm__ __volatile__ ("cld ; rep ; outsw"
|
||||
: "=S" (Buffer), "=c" (Count)
|
||||
: "d" (Port),"0" (Buffer),"1" (Count));
|
||||
}
|
||||
|
||||
VOID /*STDCALL*/
|
||||
WRITE_PORT_BUFFER_ULONG (U32* Port,
|
||||
U32* Buffer,
|
||||
U32 Count)
|
||||
{
|
||||
__asm__ __volatile__ ("cld ; rep ; outsl"
|
||||
: "=S" (Buffer), "=c" (Count)
|
||||
: "d" (Port),"0" (Buffer),"1" (Count));
|
||||
}
|
||||
|
||||
VOID /*STDCALL*/
|
||||
WRITE_PORT_UCHAR (PUCHAR Port,
|
||||
UCHAR Value)
|
||||
{
|
||||
__asm__("outb %0, %w1\n\t"
|
||||
:
|
||||
: "a" (Value),
|
||||
"d" (Port));
|
||||
SLOW_DOWN_IO;
|
||||
}
|
||||
|
||||
VOID /*STDCALL*/
|
||||
WRITE_PORT_USHORT (U16* Port,
|
||||
U16 Value)
|
||||
{
|
||||
__asm__("outw %0, %w1\n\t"
|
||||
:
|
||||
: "a" (Value),
|
||||
"d" (Port));
|
||||
SLOW_DOWN_IO;
|
||||
}
|
||||
|
||||
VOID /*STDCALL*/
|
||||
WRITE_PORT_ULONG (U32* Port,
|
||||
U32 Value)
|
||||
{
|
||||
__asm__("outl %0, %w1\n\t"
|
||||
:
|
||||
: "a" (Value),
|
||||
"d" (Port));
|
||||
SLOW_DOWN_IO;
|
||||
}
|
||||
|
||||
/* EOF */
|
@@ -1,4 +1,4 @@
|
||||
/* $Id$
|
||||
/* $Id: xboxcons.c,v 1.1 2004/11/14 22:04:38 gvg Exp $
|
||||
*
|
||||
* FreeLoader
|
||||
*
|
||||
@@ -28,9 +28,9 @@ static unsigned CurrentAttr = 0x0f;
|
||||
VOID
|
||||
XboxConsPutChar(int c)
|
||||
{
|
||||
ULONG Width;
|
||||
ULONG Height;
|
||||
ULONG Depth;
|
||||
U32 Width;
|
||||
U32 Height;
|
||||
U32 Depth;
|
||||
|
||||
if ('\r' == c)
|
||||
{
|
@@ -1,4 +1,4 @@
|
||||
/* $Id$
|
||||
/* $Id: xboxdisk.c,v 1.3 2004/11/12 17:17:07 gvg Exp $
|
||||
*
|
||||
* FreeLoader
|
||||
*
|
||||
@@ -38,9 +38,9 @@
|
||||
|
||||
static struct
|
||||
{
|
||||
ULONG SectorCountBeforePartition;
|
||||
ULONG PartitionSectorCount;
|
||||
UCHAR SystemIndicator;
|
||||
U32 SectorCountBeforePartition;
|
||||
U32 PartitionSectorCount;
|
||||
U8 SystemIndicator;
|
||||
} XboxPartitions[] =
|
||||
{
|
||||
/* This is in the \Device\Harddisk0\Partition.. order used by the Xbox kernel */
|
||||
@@ -155,17 +155,17 @@ static struct
|
||||
* Data block read and write commands
|
||||
*/
|
||||
#define IDEReadBlock(Address, Buffer, Count) \
|
||||
(READ_PORT_BUFFER_USHORT((PUSHORT)((Address) + IDE_REG_DATA_PORT), (PUSHORT)(Buffer), (Count) / 2))
|
||||
(READ_PORT_BUFFER_USHORT((PU16)((Address) + IDE_REG_DATA_PORT), (PU16)(Buffer), (Count) / 2))
|
||||
#define IDEWriteBlock(Address, Buffer, Count) \
|
||||
(WRITE_PORT_BUFFER_USHORT((PUSHORT)((Address) + IDE_REG_DATA_PORT), (PUSHORT)(Buffer), (Count) / 2))
|
||||
(WRITE_PORT_BUFFER_USHORT((PU16)((Address) + IDE_REG_DATA_PORT), (PU16)(Buffer), (Count) / 2))
|
||||
|
||||
#define IDEReadBlock32(Address, Buffer, Count) \
|
||||
(READ_PORT_BUFFER_ULONG((PULONG)((Address) + IDE_REG_DATA_PORT), (PULONG)(Buffer), (Count) / 4))
|
||||
(READ_PORT_BUFFER_ULONG((PU32)((Address) + IDE_REG_DATA_PORT), (PU32)(Buffer), (Count) / 4))
|
||||
#define IDEWriteBlock32(Address, Buffer, Count) \
|
||||
(WRITE_PORT_BUFFER_ULONG((PULONG)((Address) + IDE_REG_DATA_PORT), (PULONG)(Buffer), (Count) / 4))
|
||||
(WRITE_PORT_BUFFER_ULONG((PU32)((Address) + IDE_REG_DATA_PORT), (PU32)(Buffer), (Count) / 4))
|
||||
|
||||
#define IDEReadWord(Address) \
|
||||
(READ_PORT_USHORT((PUSHORT)((Address) + IDE_REG_DATA_PORT)))
|
||||
(READ_PORT_USHORT((PU16)((Address) + IDE_REG_DATA_PORT)))
|
||||
|
||||
/*
|
||||
* Access macros for control registers
|
||||
@@ -180,64 +180,64 @@ static struct
|
||||
|
||||
typedef struct _IDE_DRIVE_IDENTIFY
|
||||
{
|
||||
USHORT ConfigBits; /*00*/
|
||||
USHORT LogicalCyls; /*01*/
|
||||
USHORT Reserved02; /*02*/
|
||||
USHORT LogicalHeads; /*03*/
|
||||
USHORT BytesPerTrack; /*04*/
|
||||
USHORT BytesPerSector; /*05*/
|
||||
USHORT SectorsPerTrack; /*06*/
|
||||
UCHAR InterSectorGap; /*07*/
|
||||
UCHAR InterSectorGapSize;
|
||||
UCHAR Reserved08H; /*08*/
|
||||
UCHAR BytesInPLO;
|
||||
USHORT VendorUniqueCnt; /*09*/
|
||||
U16 ConfigBits; /*00*/
|
||||
U16 LogicalCyls; /*01*/
|
||||
U16 Reserved02; /*02*/
|
||||
U16 LogicalHeads; /*03*/
|
||||
U16 BytesPerTrack; /*04*/
|
||||
U16 BytesPerSector; /*05*/
|
||||
U16 SectorsPerTrack; /*06*/
|
||||
U8 InterSectorGap; /*07*/
|
||||
U8 InterSectorGapSize;
|
||||
U8 Reserved08H; /*08*/
|
||||
U8 BytesInPLO;
|
||||
U16 VendorUniqueCnt; /*09*/
|
||||
char SerialNumber[20]; /*10*/
|
||||
USHORT ControllerType; /*20*/
|
||||
USHORT BufferSize; /*21*/
|
||||
USHORT ECCByteCnt; /*22*/
|
||||
U16 ControllerType; /*20*/
|
||||
U16 BufferSize; /*21*/
|
||||
U16 ECCByteCnt; /*22*/
|
||||
char FirmwareRev[8]; /*23*/
|
||||
char ModelNumber[40]; /*27*/
|
||||
USHORT RWMultImplemented; /*47*/
|
||||
USHORT DWordIo; /*48*/
|
||||
USHORT Capabilities; /*49*/
|
||||
U16 RWMultImplemented; /*47*/
|
||||
U16 DWordIo; /*48*/
|
||||
U16 Capabilities; /*49*/
|
||||
#define IDE_DRID_STBY_SUPPORTED 0x2000
|
||||
#define IDE_DRID_IORDY_SUPPORTED 0x0800
|
||||
#define IDE_DRID_IORDY_DISABLE 0x0400
|
||||
#define IDE_DRID_LBA_SUPPORTED 0x0200
|
||||
#define IDE_DRID_DMA_SUPPORTED 0x0100
|
||||
USHORT Reserved50; /*50*/
|
||||
USHORT MinPIOTransTime; /*51*/
|
||||
USHORT MinDMATransTime; /*52*/
|
||||
USHORT TMFieldsValid; /*53*/
|
||||
USHORT TMCylinders; /*54*/
|
||||
USHORT TMHeads; /*55*/
|
||||
USHORT TMSectorsPerTrk; /*56*/
|
||||
USHORT TMCapacityLo; /*57*/
|
||||
USHORT TMCapacityHi; /*58*/
|
||||
USHORT RWMultCurrent; /*59*/
|
||||
USHORT TMSectorCountLo; /*60*/
|
||||
USHORT TMSectorCountHi; /*61*/
|
||||
USHORT DmaModes; /*62*/
|
||||
USHORT MultiDmaModes; /*63*/
|
||||
USHORT Reserved64[5]; /*64*/
|
||||
USHORT Reserved69[2]; /*69*/
|
||||
USHORT Reserved71[4]; /*71*/
|
||||
USHORT MaxQueueDepth; /*75*/
|
||||
USHORT Reserved76[4]; /*76*/
|
||||
USHORT MajorRevision; /*80*/
|
||||
USHORT MinorRevision; /*81*/
|
||||
USHORT SupportedFeatures82; /*82*/
|
||||
USHORT SupportedFeatures83; /*83*/
|
||||
USHORT SupportedFeatures84; /*84*/
|
||||
USHORT EnabledFeatures85; /*85*/
|
||||
USHORT EnabledFeatures86; /*86*/
|
||||
USHORT EnabledFeatures87; /*87*/
|
||||
USHORT UltraDmaModes; /*88*/
|
||||
USHORT Reserved89[11]; /*89*/
|
||||
USHORT Max48BitAddress[4]; /*100*/
|
||||
USHORT Reserved104[151]; /*104*/
|
||||
USHORT Checksum; /*255*/
|
||||
U16 Reserved50; /*50*/
|
||||
U16 MinPIOTransTime; /*51*/
|
||||
U16 MinDMATransTime; /*52*/
|
||||
U16 TMFieldsValid; /*53*/
|
||||
U16 TMCylinders; /*54*/
|
||||
U16 TMHeads; /*55*/
|
||||
U16 TMSectorsPerTrk; /*56*/
|
||||
U16 TMCapacityLo; /*57*/
|
||||
U16 TMCapacityHi; /*58*/
|
||||
U16 RWMultCurrent; /*59*/
|
||||
U16 TMSectorCountLo; /*60*/
|
||||
U16 TMSectorCountHi; /*61*/
|
||||
U16 DmaModes; /*62*/
|
||||
U16 MultiDmaModes; /*63*/
|
||||
U16 Reserved64[5]; /*64*/
|
||||
U16 Reserved69[2]; /*69*/
|
||||
U16 Reserved71[4]; /*71*/
|
||||
U16 MaxQueueDepth; /*75*/
|
||||
U16 Reserved76[4]; /*76*/
|
||||
U16 MajorRevision; /*80*/
|
||||
U16 MinorRevision; /*81*/
|
||||
U16 SupportedFeatures82; /*82*/
|
||||
U16 SupportedFeatures83; /*83*/
|
||||
U16 SupportedFeatures84; /*84*/
|
||||
U16 EnabledFeatures85; /*85*/
|
||||
U16 EnabledFeatures86; /*86*/
|
||||
U16 EnabledFeatures87; /*87*/
|
||||
U16 UltraDmaModes; /*88*/
|
||||
U16 Reserved89[11]; /*89*/
|
||||
U16 Max48BitAddress[4]; /*100*/
|
||||
U16 Reserved104[151]; /*104*/
|
||||
U16 Checksum; /*255*/
|
||||
} IDE_DRIVE_IDENTIFY, *PIDE_DRIVE_IDENTIFY;
|
||||
|
||||
/* XboxDiskPolledRead
|
||||
@@ -249,15 +249,15 @@ typedef struct _IDE_DRIVE_IDENTIFY
|
||||
* PASSIVE_LEVEL
|
||||
*
|
||||
* ARGUMENTS:
|
||||
* ULONG CommandPort Address of command port for drive
|
||||
* ULONG ControlPort Address of control port for drive
|
||||
* UCHAR PreComp Value to write to precomp register
|
||||
* UCHAR SectorCnt Value to write to sectorCnt register
|
||||
* UCHAR SectorNum Value to write to sectorNum register
|
||||
* UCHAR CylinderLow Value to write to CylinderLow register
|
||||
* UCHAR CylinderHigh Value to write to CylinderHigh register
|
||||
* UCHAR DrvHead Value to write to Drive/Head register
|
||||
* UCHAR Command Value to write to Command register
|
||||
* U32 CommandPort Address of command port for drive
|
||||
* U32 ControlPort Address of control port for drive
|
||||
* U8 PreComp Value to write to precomp register
|
||||
* U8 SectorCnt Value to write to sectorCnt register
|
||||
* U8 SectorNum Value to write to sectorNum register
|
||||
* U8 CylinderLow Value to write to CylinderLow register
|
||||
* U8 CylinderHigh Value to write to CylinderHigh register
|
||||
* U8 DrvHead Value to write to Drive/Head register
|
||||
* U8 Command Value to write to Command register
|
||||
* PVOID Buffer Buffer for output data
|
||||
*
|
||||
* RETURNS:
|
||||
@@ -265,21 +265,21 @@ typedef struct _IDE_DRIVE_IDENTIFY
|
||||
*/
|
||||
|
||||
static BOOL
|
||||
XboxDiskPolledRead(ULONG CommandPort,
|
||||
ULONG ControlPort,
|
||||
UCHAR PreComp,
|
||||
UCHAR SectorCnt,
|
||||
UCHAR SectorNum,
|
||||
UCHAR CylinderLow,
|
||||
UCHAR CylinderHigh,
|
||||
UCHAR DrvHead,
|
||||
UCHAR Command,
|
||||
XboxDiskPolledRead(U32 CommandPort,
|
||||
U32 ControlPort,
|
||||
U8 PreComp,
|
||||
U8 SectorCnt,
|
||||
U8 SectorNum,
|
||||
U8 CylinderLow,
|
||||
U8 CylinderHigh,
|
||||
U8 DrvHead,
|
||||
U8 Command,
|
||||
PVOID Buffer)
|
||||
{
|
||||
ULONG SectorCount = 0;
|
||||
ULONG RetryCount;
|
||||
U32 SectorCount = 0;
|
||||
U32 RetryCount;
|
||||
BOOL Junk = FALSE;
|
||||
UCHAR Status;
|
||||
U8 Status;
|
||||
|
||||
/* Wait for BUSY to clear */
|
||||
for (RetryCount = 0; RetryCount < IDE_MAX_BUSY_RETRIES; RetryCount++)
|
||||
@@ -289,7 +289,7 @@ XboxDiskPolledRead(ULONG CommandPort,
|
||||
{
|
||||
break;
|
||||
}
|
||||
StallExecutionProcessor(10);
|
||||
KeStallExecutionProcessor(10);
|
||||
}
|
||||
DbgPrint((DPRINT_DISK, "status=0x%x\n", Status));
|
||||
DbgPrint((DPRINT_DISK, "waited %d usecs for busy to clear\n", RetryCount * 10));
|
||||
@@ -301,11 +301,11 @@ XboxDiskPolledRead(ULONG CommandPort,
|
||||
|
||||
/* Write Drive/Head to select drive */
|
||||
IDEWriteDriveHead(CommandPort, IDE_DH_FIXED | DrvHead);
|
||||
StallExecutionProcessor(500);
|
||||
KeStallExecutionProcessor(500);
|
||||
|
||||
/* Disable interrupts */
|
||||
IDEWriteDriveControl(ControlPort, IDE_DC_nIEN);
|
||||
StallExecutionProcessor(500);
|
||||
KeStallExecutionProcessor(500);
|
||||
|
||||
/* Issue command to drive */
|
||||
if (DrvHead & IDE_DH_LBA)
|
||||
@@ -338,7 +338,7 @@ XboxDiskPolledRead(ULONG CommandPort,
|
||||
|
||||
/* Issue the command */
|
||||
IDEWriteCommand(CommandPort, Command);
|
||||
StallExecutionProcessor(50);
|
||||
KeStallExecutionProcessor(50);
|
||||
|
||||
/* wait for DRQ or error */
|
||||
for (RetryCount = 0; RetryCount < IDE_MAX_POLL_RETRIES; RetryCount++)
|
||||
@@ -349,7 +349,7 @@ XboxDiskPolledRead(ULONG CommandPort,
|
||||
if (Status & IDE_SR_ERR)
|
||||
{
|
||||
IDEWriteDriveControl(ControlPort, 0);
|
||||
StallExecutionProcessor(50);
|
||||
KeStallExecutionProcessor(50);
|
||||
IDEReadStatus(CommandPort);
|
||||
|
||||
return FALSE;
|
||||
@@ -362,20 +362,20 @@ XboxDiskPolledRead(ULONG CommandPort,
|
||||
else
|
||||
{
|
||||
IDEWriteDriveControl(ControlPort, 0);
|
||||
StallExecutionProcessor(50);
|
||||
KeStallExecutionProcessor(50);
|
||||
IDEReadStatus(CommandPort);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
StallExecutionProcessor(10);
|
||||
KeStallExecutionProcessor(10);
|
||||
}
|
||||
|
||||
/* timed out */
|
||||
if (RetryCount >= IDE_MAX_POLL_RETRIES)
|
||||
{
|
||||
IDEWriteDriveControl(ControlPort, 0);
|
||||
StallExecutionProcessor(50);
|
||||
KeStallExecutionProcessor(50);
|
||||
IDEReadStatus(CommandPort);
|
||||
|
||||
return FALSE;
|
||||
@@ -405,7 +405,7 @@ XboxDiskPolledRead(ULONG CommandPort,
|
||||
if (Status & IDE_SR_ERR)
|
||||
{
|
||||
IDEWriteDriveControl(ControlPort, 0);
|
||||
StallExecutionProcessor(50);
|
||||
KeStallExecutionProcessor(50);
|
||||
IDEReadStatus(CommandPort);
|
||||
|
||||
return FALSE;
|
||||
@@ -427,7 +427,7 @@ XboxDiskPolledRead(ULONG CommandPort,
|
||||
SectorCount - SectorCnt));
|
||||
}
|
||||
IDEWriteDriveControl(ControlPort, 0);
|
||||
StallExecutionProcessor(50);
|
||||
KeStallExecutionProcessor(50);
|
||||
IDEReadStatus(CommandPort);
|
||||
|
||||
return TRUE;
|
||||
@@ -438,10 +438,10 @@ XboxDiskPolledRead(ULONG CommandPort,
|
||||
}
|
||||
|
||||
BOOL
|
||||
XboxDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
|
||||
XboxDiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer)
|
||||
{
|
||||
ULONG StartSector;
|
||||
UCHAR Count;
|
||||
U32 StartSector;
|
||||
U8 Count;
|
||||
|
||||
if (DriveNumber < 0x80 || 2 <= (DriveNumber & 0x0f))
|
||||
{
|
||||
@@ -456,7 +456,7 @@ XboxDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG Sect
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
StartSector = (ULONG) SectorNumber;
|
||||
StartSector = (U32) SectorNumber;
|
||||
while (0 < SectorCount)
|
||||
{
|
||||
Count = (SectorCount <= 255 ? SectorCount : 255);
|
||||
@@ -481,9 +481,9 @@ XboxDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG Sect
|
||||
}
|
||||
|
||||
BOOL
|
||||
XboxDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
|
||||
XboxDiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
|
||||
{
|
||||
UCHAR SectorData[IDE_SECTOR_BUF_SZ];
|
||||
U8 SectorData[IDE_SECTOR_BUF_SZ];
|
||||
|
||||
/* This is the Xbox, chances are that there is a Xbox-standard partitionless
|
||||
* disk in it so let's check that first */
|
||||
@@ -491,7 +491,7 @@ XboxDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_T
|
||||
if (1 <= PartitionNumber && PartitionNumber <= sizeof(XboxPartitions) / sizeof(XboxPartitions[0]) &&
|
||||
MachDiskReadLogicalSectors(DriveNumber, XBOX_SIGNATURE_SECTOR, 1, SectorData))
|
||||
{
|
||||
if (*((PULONG) SectorData) == XBOX_SIGNATURE)
|
||||
if (*((PU32) SectorData) == XBOX_SIGNATURE)
|
||||
{
|
||||
memset(PartitionTableEntry, 0, sizeof(PARTITION_TABLE_ENTRY));
|
||||
PartitionTableEntry->SystemIndicator = XboxPartitions[PartitionNumber - 1].SystemIndicator;
|
||||
@@ -506,10 +506,10 @@ XboxDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_T
|
||||
}
|
||||
|
||||
BOOL
|
||||
XboxDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY Geometry)
|
||||
XboxDiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY Geometry)
|
||||
{
|
||||
IDE_DRIVE_IDENTIFY DrvParms;
|
||||
ULONG i;
|
||||
U32 i;
|
||||
BOOL Atapi;
|
||||
|
||||
Atapi = FALSE; /* FIXME */
|
||||
@@ -565,8 +565,8 @@ XboxDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY Geometry)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ULONG
|
||||
XboxDiskGetCacheableBlockCount(ULONG DriveNumber)
|
||||
U32
|
||||
XboxDiskGetCacheableBlockCount(U32 DriveNumber)
|
||||
{
|
||||
/* 64 seems a nice number, it is used by the machpc code for LBA devices */
|
||||
return 64;
|
@@ -1,4 +1,4 @@
|
||||
/* $Id$
|
||||
/* $Id: xboxfont.c,v 1.2 2004/11/10 23:45:37 gvg Exp $
|
||||
*
|
||||
* FreeLoader
|
||||
*
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "machine.h"
|
||||
#include "machxbox.h"
|
||||
|
||||
UCHAR XboxFont8x16[256 * 16] =
|
||||
U8 XboxFont8x16[256 * 16] =
|
||||
{
|
||||
0x00,0x00,0x00,0x7c,0xc6,0xc6,0xde,0xde,0xde,0xdc,0xc0,0x7c,0x00,0x00,0x00,0x00, /* 0x00 */
|
||||
0x00,0x00,0x7e,0x81,0xa5,0x81,0x81,0xa5,0x99,0x81,0x81,0x7e,0x00,0x00,0x00,0x00, /* 0x01 */
|
@@ -1,4 +1,4 @@
|
||||
/* $Id$
|
||||
/* $Id: xboxhw.c,v 1.1 2004/11/28 22:42:40 gvg Exp $
|
||||
*
|
||||
* FreeLoader
|
||||
*
|
@@ -1,4 +1,4 @@
|
||||
/* $Id$
|
||||
/* $Id: xboxmem.c,v 1.3 2004/11/10 23:45:37 gvg Exp $
|
||||
*
|
||||
* FreeLoader
|
||||
*
|
||||
@@ -29,8 +29,8 @@
|
||||
#include "machxbox.h"
|
||||
#include "portio.h"
|
||||
|
||||
static ULONG InstalledMemoryMb = 0;
|
||||
static ULONG AvailableMemoryMb = 0;
|
||||
static U32 InstalledMemoryMb = 0;
|
||||
static U32 AvailableMemoryMb = 0;
|
||||
|
||||
#define TEST_SIZE 0x200
|
||||
#define TEST_PATTERN1 0xaa
|
||||
@@ -39,15 +39,15 @@ static ULONG AvailableMemoryMb = 0;
|
||||
VOID
|
||||
XboxMemInit(VOID)
|
||||
{
|
||||
UCHAR ControlRegion[TEST_SIZE];
|
||||
U8 ControlRegion[TEST_SIZE];
|
||||
PVOID MembaseTop = (PVOID)(64 * 1024 * 1024);
|
||||
PVOID MembaseLow = (PVOID)0;
|
||||
|
||||
(*(PULONG)(0xfd000000 + 0x100200)) = 0x03070103 ;
|
||||
(*(PULONG)(0xfd000000 + 0x100204)) = 0x11448000 ;
|
||||
(*(PU32)(0xfd000000 + 0x100200)) = 0x03070103 ;
|
||||
(*(PU32)(0xfd000000 + 0x100204)) = 0x11448000 ;
|
||||
|
||||
WRITE_PORT_ULONG((ULONG*) 0xcf8, CONFIG_CMD(0, 0, 0x84));
|
||||
WRITE_PORT_ULONG((ULONG*) 0xcfc, 0x7ffffff); /* Prep hardware for 128 Mb */
|
||||
WRITE_PORT_ULONG((U32*) 0xcf8, CONFIG_CMD(0, 0, 0x84));
|
||||
WRITE_PORT_ULONG((U32*) 0xcfc, 0x7ffffff); /* Prep hardware for 128 Mb */
|
||||
|
||||
InstalledMemoryMb = 64;
|
||||
memset(ControlRegion, TEST_PATTERN1, TEST_SIZE);
|
||||
@@ -76,16 +76,16 @@ XboxMemInit(VOID)
|
||||
}
|
||||
|
||||
/* Set hardware for amount of memory detected */
|
||||
WRITE_PORT_ULONG((ULONG*) 0xcf8, CONFIG_CMD(0, 0, 0x84));
|
||||
WRITE_PORT_ULONG((ULONG*) 0xcfc, InstalledMemoryMb * 1024 * 1024 - 1);
|
||||
WRITE_PORT_ULONG((U32*) 0xcf8, CONFIG_CMD(0, 0, 0x84));
|
||||
WRITE_PORT_ULONG((U32*) 0xcfc, InstalledMemoryMb * 1024 * 1024 - 1);
|
||||
|
||||
AvailableMemoryMb = InstalledMemoryMb;
|
||||
}
|
||||
|
||||
ULONG
|
||||
XboxMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize)
|
||||
U32
|
||||
XboxMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize)
|
||||
{
|
||||
ULONG EntryCount = 0;
|
||||
U32 EntryCount = 0;
|
||||
|
||||
/* Synthesize memory map */
|
||||
if (1 <= MaxMemoryMapSize)
|
||||
@@ -110,7 +110,7 @@ XboxMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MaxMemoryMapSize)
|
||||
}
|
||||
|
||||
PVOID
|
||||
XboxMemReserveMemory(ULONG MbToReserve)
|
||||
XboxMemReserveMemory(U32 MbToReserve)
|
||||
{
|
||||
if (0 == InstalledMemoryMb)
|
||||
{
|
@@ -1,4 +1,4 @@
|
||||
/* $Id$
|
||||
/* $Id: xboxrtc.c,v 1.1 2004/11/14 22:04:38 gvg Exp $
|
||||
*
|
||||
* FreeLoader
|
||||
*
|
||||
@@ -41,7 +41,7 @@ HalpQueryCMOS(UCHAR Reg)
|
||||
}
|
||||
|
||||
VOID
|
||||
XboxRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second)
|
||||
XboxRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second)
|
||||
{
|
||||
while (HalpQueryCMOS (RTC_REGISTER_A) & RTC_REG_A_UIP)
|
||||
{
|
@@ -1,4 +1,4 @@
|
||||
/* $Id$
|
||||
/* $Id: xboxvideo.c,v 1.5 2004/11/28 21:54:11 gvg Exp $
|
||||
*
|
||||
* FreeLoader
|
||||
*
|
||||
@@ -30,10 +30,10 @@
|
||||
#define I2C_IO_BASE 0xc000
|
||||
|
||||
static PVOID FrameBuffer;
|
||||
static ULONG ScreenWidth;
|
||||
static ULONG ScreenHeight;
|
||||
static ULONG BytesPerPixel;
|
||||
static ULONG Delta;
|
||||
static U32 ScreenWidth;
|
||||
static U32 ScreenHeight;
|
||||
static U32 BytesPerPixel;
|
||||
static U32 Delta;
|
||||
|
||||
#define CHAR_WIDTH 8
|
||||
#define CHAR_HEIGHT 16
|
||||
@@ -45,16 +45,16 @@ static ULONG Delta;
|
||||
#define MAKE_COLOR(Red, Green, Blue) (0xff000000 | (((Red) & 0xff) << 16) | (((Green) & 0xff) << 8) | ((Blue) & 0xff))
|
||||
|
||||
static VOID
|
||||
XboxVideoOutputChar(UCHAR Char, unsigned X, unsigned Y, ULONG FgColor, ULONG BgColor)
|
||||
XboxVideoOutputChar(U8 Char, unsigned X, unsigned Y, U32 FgColor, U32 BgColor)
|
||||
{
|
||||
PUCHAR FontPtr;
|
||||
PULONG Pixel;
|
||||
UCHAR Mask;
|
||||
PU8 FontPtr;
|
||||
PU32 Pixel;
|
||||
U8 Mask;
|
||||
unsigned Line;
|
||||
unsigned Col;
|
||||
|
||||
FontPtr = XboxFont8x16 + Char * 16;
|
||||
Pixel = (PULONG) ((char *) FrameBuffer + (Y * CHAR_HEIGHT + TOP_BOTTOM_LINES) * Delta
|
||||
Pixel = (PU32) ((char *) FrameBuffer + (Y * CHAR_HEIGHT + TOP_BOTTOM_LINES) * Delta
|
||||
+ X * CHAR_WIDTH * BytesPerPixel);
|
||||
for (Line = 0; Line < CHAR_HEIGHT; Line++)
|
||||
{
|
||||
@@ -64,14 +64,14 @@ XboxVideoOutputChar(UCHAR Char, unsigned X, unsigned Y, ULONG FgColor, ULONG BgC
|
||||
Pixel[Col] = (0 != (FontPtr[Line] & Mask) ? FgColor : BgColor);
|
||||
Mask = Mask >> 1;
|
||||
}
|
||||
Pixel = (PULONG) ((char *) Pixel + Delta);
|
||||
Pixel = (PU32) ((char *) Pixel + Delta);
|
||||
}
|
||||
}
|
||||
|
||||
static ULONG
|
||||
XboxVideoAttrToSingleColor(UCHAR Attr)
|
||||
static U32
|
||||
XboxVideoAttrToSingleColor(U8 Attr)
|
||||
{
|
||||
UCHAR Intensity;
|
||||
U8 Intensity;
|
||||
|
||||
Intensity = (0 == (Attr & 0x08) ? 127 : 255);
|
||||
|
||||
@@ -82,21 +82,21 @@ XboxVideoAttrToSingleColor(UCHAR Attr)
|
||||
}
|
||||
|
||||
static VOID
|
||||
XboxVideoAttrToColors(UCHAR Attr, ULONG *FgColor, ULONG *BgColor)
|
||||
XboxVideoAttrToColors(U8 Attr, U32 *FgColor, U32 *BgColor)
|
||||
{
|
||||
*FgColor = XboxVideoAttrToSingleColor(Attr & 0xf);
|
||||
*BgColor = XboxVideoAttrToSingleColor((Attr >> 4) & 0xf);
|
||||
}
|
||||
|
||||
static VOID
|
||||
XboxVideoClearScreenColor(ULONG Color, BOOL FullScreen)
|
||||
XboxVideoClearScreenColor(U32 Color, BOOL FullScreen)
|
||||
{
|
||||
ULONG Line, Col;
|
||||
PULONG p;
|
||||
U32 Line, Col;
|
||||
PU32 p;
|
||||
|
||||
for (Line = 0; Line < ScreenHeight - (FullScreen ? 0 : 2 * TOP_BOTTOM_LINES); Line++)
|
||||
{
|
||||
p = (PULONG) ((char *) FrameBuffer + (Line + (FullScreen ? 0 : TOP_BOTTOM_LINES)) * Delta);
|
||||
p = (PU32) ((char *) FrameBuffer + (Line + (FullScreen ? 0 : TOP_BOTTOM_LINES)) * Delta);
|
||||
for (Col = 0; Col < ScreenWidth; Col++)
|
||||
{
|
||||
*p++ = Color;
|
||||
@@ -105,9 +105,9 @@ XboxVideoClearScreenColor(ULONG Color, BOOL FullScreen)
|
||||
}
|
||||
|
||||
VOID
|
||||
XboxVideoClearScreen(UCHAR Attr)
|
||||
XboxVideoClearScreen(U8 Attr)
|
||||
{
|
||||
ULONG FgColor, BgColor;
|
||||
U32 FgColor, BgColor;
|
||||
|
||||
XboxVideoAttrToColors(Attr, &FgColor, &BgColor);
|
||||
|
||||
@@ -115,9 +115,9 @@ XboxVideoClearScreen(UCHAR Attr)
|
||||
}
|
||||
|
||||
VOID
|
||||
XboxVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
|
||||
XboxVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y)
|
||||
{
|
||||
ULONG FgColor, BgColor;
|
||||
U32 FgColor, BgColor;
|
||||
|
||||
XboxVideoAttrToColors(Attr, &FgColor, &BgColor);
|
||||
|
||||
@@ -125,11 +125,11 @@ XboxVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
|
||||
}
|
||||
|
||||
static BOOL
|
||||
ReadfromSMBus(UCHAR Address, UCHAR bRegister, UCHAR Size, ULONG *Data_to_smbus)
|
||||
ReadfromSMBus(UCHAR Address, UCHAR bRegister, UCHAR Size, U32 *Data_to_smbus)
|
||||
{
|
||||
int nRetriesToLive=50;
|
||||
|
||||
while (0 != (READ_PORT_USHORT((PUSHORT) (I2C_IO_BASE + 0)) & 0x0800))
|
||||
while (0 != (READ_PORT_USHORT((PU16) (I2C_IO_BASE + 0)) & 0x0800))
|
||||
{
|
||||
; /* Franz's spin while bus busy with any master traffic */
|
||||
}
|
||||
@@ -142,8 +142,8 @@ ReadfromSMBus(UCHAR Address, UCHAR bRegister, UCHAR Size, ULONG *Data_to_smbus)
|
||||
WRITE_PORT_UCHAR((PUCHAR) (I2C_IO_BASE + 4), (Address << 1) | 1);
|
||||
WRITE_PORT_UCHAR((PUCHAR) (I2C_IO_BASE + 8), bRegister);
|
||||
|
||||
temp = READ_PORT_USHORT((USHORT *) (I2C_IO_BASE + 0));
|
||||
WRITE_PORT_USHORT((PUSHORT) (I2C_IO_BASE + 0), temp); /* clear down all preexisting errors */
|
||||
temp = READ_PORT_USHORT((U16 *) (I2C_IO_BASE + 0));
|
||||
WRITE_PORT_USHORT((PU16) (I2C_IO_BASE + 0), temp); /* clear down all preexisting errors */
|
||||
|
||||
switch (Size)
|
||||
{
|
||||
@@ -186,7 +186,7 @@ ReadfromSMBus(UCHAR Address, UCHAR bRegister, UCHAR Size, ULONG *Data_to_smbus)
|
||||
READ_PORT_UCHAR((PUCHAR) (I2C_IO_BASE + 9));
|
||||
break;
|
||||
case 2:
|
||||
*Data_to_smbus = READ_PORT_USHORT((USHORT *) (I2C_IO_BASE + 6));
|
||||
*Data_to_smbus = READ_PORT_USHORT((U16 *) (I2C_IO_BASE + 6));
|
||||
break;
|
||||
default:
|
||||
*Data_to_smbus = READ_PORT_UCHAR((PUCHAR) (I2C_IO_BASE + 6));
|
||||
@@ -203,7 +203,7 @@ ReadfromSMBus(UCHAR Address, UCHAR bRegister, UCHAR Size, ULONG *Data_to_smbus)
|
||||
|
||||
|
||||
static BOOL
|
||||
I2CTransmitByteGetReturn(UCHAR bPicAddressI2cFormat, UCHAR bDataToWrite, ULONG *Return)
|
||||
I2CTransmitByteGetReturn(UCHAR bPicAddressI2cFormat, UCHAR bDataToWrite, U32 *Return)
|
||||
{
|
||||
return ReadfromSMBus(bPicAddressI2cFormat, bDataToWrite, 1, Return);
|
||||
}
|
||||
@@ -212,9 +212,9 @@ I2CTransmitByteGetReturn(UCHAR bPicAddressI2cFormat, UCHAR bDataToWrite, ULONG *
|
||||
VOID
|
||||
XboxVideoInit(VOID)
|
||||
{
|
||||
ULONG AvMode;
|
||||
U32 AvMode;
|
||||
|
||||
FrameBuffer = (PVOID)((ULONG) XboxMemReserveMemory(FB_SIZE_MB) | 0xf0000000);
|
||||
FrameBuffer = (PVOID)((U32) XboxMemReserveMemory(FB_SIZE_MB) | 0xf0000000);
|
||||
|
||||
if (I2CTransmitByteGetReturn(0x10, 0x04, &AvMode))
|
||||
{
|
||||
@@ -247,7 +247,7 @@ XboxVideoInit(VOID)
|
||||
XboxVideoClearScreenColor(MAKE_COLOR(0, 0, 0), TRUE);
|
||||
|
||||
/* Tell the nVidia controller about the framebuffer */
|
||||
*((PULONG) 0xfd600800) = (ULONG) FrameBuffer;
|
||||
*((PU32) 0xfd600800) = (U32) FrameBuffer;
|
||||
}
|
||||
|
||||
VIDEODISPLAYMODE
|
||||
@@ -258,21 +258,21 @@ XboxVideoSetDisplayMode(char *DisplayMode, BOOL Init)
|
||||
}
|
||||
|
||||
VOID
|
||||
XboxVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
|
||||
XboxVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth)
|
||||
{
|
||||
*Width = ScreenWidth / CHAR_WIDTH;
|
||||
*Height = (ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT;
|
||||
*Depth = 0;
|
||||
}
|
||||
|
||||
ULONG
|
||||
U32
|
||||
XboxVideoGetBufferSize(VOID)
|
||||
{
|
||||
return (ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT * (ScreenWidth / CHAR_WIDTH) * 2;
|
||||
}
|
||||
|
||||
VOID
|
||||
XboxVideoSetTextCursorPosition(ULONG X, ULONG Y)
|
||||
XboxVideoSetTextCursorPosition(U32 X, U32 Y)
|
||||
{
|
||||
/* We don't have a cursor yet */
|
||||
}
|
||||
@@ -286,8 +286,8 @@ XboxVideoHideShowTextCursor(BOOL Show)
|
||||
VOID
|
||||
XboxVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
|
||||
{
|
||||
PUCHAR OffScreenBuffer = (PUCHAR) Buffer;
|
||||
ULONG Col, Line;
|
||||
PU8 OffScreenBuffer = (PU8) Buffer;
|
||||
U32 Col, Line;
|
||||
|
||||
for (Line = 0; Line < (ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT; Line++)
|
||||
{
|
||||
@@ -306,13 +306,13 @@ XboxVideoIsPaletteFixed(VOID)
|
||||
}
|
||||
|
||||
VOID
|
||||
XboxVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
|
||||
XboxVideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue)
|
||||
{
|
||||
/* Not supported */
|
||||
}
|
||||
|
||||
VOID
|
||||
XboxVideoGetPaletteColor(UCHAR Color, UCHAR* Red, UCHAR* Green, UCHAR* Blue)
|
||||
XboxVideoGetPaletteColor(U8 Color, U8* Red, U8* Green, U8* Blue)
|
||||
{
|
||||
/* Not supported */
|
||||
}
|
@@ -16,7 +16,7 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include <freeldr.h>
|
||||
#include <rtl.h>
|
||||
#include <fs.h>
|
||||
@@ -39,22 +39,15 @@
|
||||
|
||||
VOID RunLoader(VOID)
|
||||
{
|
||||
CHAR SettingName[80];
|
||||
CHAR SettingValue[80];
|
||||
ULONG SectionId;
|
||||
ULONG OperatingSystemCount;
|
||||
PCHAR *OperatingSystemSectionNames;
|
||||
PCHAR *OperatingSystemDisplayNames;
|
||||
ULONG DefaultOperatingSystem;
|
||||
LONG TimeOut;
|
||||
ULONG SelectedOperatingSystem;
|
||||
|
||||
if (!FsOpenBootVolume())
|
||||
{
|
||||
printf("Error opening boot partition for file access.\n");
|
||||
MachConsGetCh();
|
||||
return;
|
||||
}
|
||||
UCHAR SettingName[80];
|
||||
UCHAR SettingValue[80];
|
||||
U32 SectionId;
|
||||
U32 OperatingSystemCount;
|
||||
PUCHAR *OperatingSystemSectionNames;
|
||||
PUCHAR *OperatingSystemDisplayNames;
|
||||
U32 DefaultOperatingSystem;
|
||||
S32 TimeOut;
|
||||
U32 SelectedOperatingSystem;
|
||||
|
||||
if (!IniFileInitialize())
|
||||
{
|
||||
@@ -77,14 +70,14 @@ VOID RunLoader(VOID)
|
||||
MachConsGetCh();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!InitOperatingSystemList(&OperatingSystemSectionNames, &OperatingSystemDisplayNames, &OperatingSystemCount))
|
||||
{
|
||||
UiMessageBox("Press ENTER to reboot.\n");
|
||||
goto reboot;
|
||||
}
|
||||
|
||||
|
||||
if (OperatingSystemCount == 0)
|
||||
{
|
||||
UiMessageBox("There were no operating systems listed in freeldr.ini.\nPress ENTER to reboot.");
|
||||
@@ -92,7 +85,7 @@ VOID RunLoader(VOID)
|
||||
}
|
||||
|
||||
DefaultOperatingSystem = GetDefaultOperatingSystem(OperatingSystemSectionNames, OperatingSystemCount);
|
||||
|
||||
|
||||
//
|
||||
// Find all the message box settings and run them
|
||||
//
|
||||
@@ -100,13 +93,12 @@ VOID RunLoader(VOID)
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
||||
|
||||
/* If Timeout is 0, don't even bother loading any gui */
|
||||
if (!UserInterfaceUp) {
|
||||
SelectedOperatingSystem = DefaultOperatingSystem;
|
||||
goto NoGui;
|
||||
}
|
||||
|
||||
|
||||
// Redraw the backdrop
|
||||
UiDrawBackdrop();
|
||||
|
||||
@@ -116,9 +108,10 @@ VOID RunLoader(VOID)
|
||||
UiMessageBox("Press ENTER to reboot.\n");
|
||||
goto reboot;
|
||||
}
|
||||
|
||||
|
||||
NoGui:
|
||||
TimeOut = -1;
|
||||
DefaultOperatingSystem = SelectedOperatingSystem;
|
||||
|
||||
// Try to open the operating system section in the .ini file
|
||||
if (!IniOpenSection(OperatingSystemSectionNames[SelectedOperatingSystem], &SectionId))
|
||||
@@ -160,19 +153,19 @@ NoGui:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
reboot:
|
||||
UiUnInitialize("Rebooting...");
|
||||
return;
|
||||
}
|
||||
|
||||
ULONG GetDefaultOperatingSystem(PCHAR OperatingSystemList[], ULONG OperatingSystemCount)
|
||||
U32 GetDefaultOperatingSystem(PUCHAR OperatingSystemList[], U32 OperatingSystemCount)
|
||||
{
|
||||
CHAR DefaultOSText[80];
|
||||
PCHAR DefaultOSName;
|
||||
ULONG SectionId;
|
||||
ULONG DefaultOS = 0;
|
||||
ULONG Idx;
|
||||
UCHAR DefaultOSText[80];
|
||||
char* DefaultOSName;
|
||||
U32 SectionId;
|
||||
U32 DefaultOS = 0;
|
||||
U32 Idx;
|
||||
|
||||
if (!IniOpenSection("FreeLoader", &SectionId))
|
||||
{
|
||||
@@ -203,11 +196,11 @@ ULONG GetDefaultOperatingSystem(PCHAR OperatingSystemList[], ULONG OperatingSy
|
||||
return DefaultOS;
|
||||
}
|
||||
|
||||
LONG GetTimeOut(VOID)
|
||||
S32 GetTimeOut(VOID)
|
||||
{
|
||||
CHAR TimeOutText[20];
|
||||
LONG TimeOut;
|
||||
ULONG SectionId;
|
||||
UCHAR TimeOutText[20];
|
||||
S32 TimeOut;
|
||||
U32 SectionId;
|
||||
|
||||
TimeOut = CmdLineGetTimeOut();
|
||||
if (0 <= TimeOut)
|
||||
@@ -232,7 +225,7 @@ LONG GetTimeOut(VOID)
|
||||
return TimeOut;
|
||||
}
|
||||
|
||||
BOOL MainBootMenuKeyPressFilter(ULONG KeyPress)
|
||||
BOOL MainBootMenuKeyPressFilter(U32 KeyPress)
|
||||
{
|
||||
if (KeyPress == KEY_F8)
|
||||
{
|
@@ -30,7 +30,7 @@
|
||||
// Returns a pointer to a CACHE_BLOCK structure
|
||||
// Adds the block to the cache manager block list
|
||||
// in cache memory if it isn't already there
|
||||
PCACHE_BLOCK CacheInternalGetBlockPointer(PCACHE_DRIVE CacheDrive, ULONG BlockNumber)
|
||||
PCACHE_BLOCK CacheInternalGetBlockPointer(PCACHE_DRIVE CacheDrive, U32 BlockNumber)
|
||||
{
|
||||
PCACHE_BLOCK CacheBlock = NULL;
|
||||
|
||||
@@ -55,7 +55,7 @@ PCACHE_BLOCK CacheInternalGetBlockPointer(PCACHE_DRIVE CacheDrive, ULONG BlockNu
|
||||
return CacheBlock;
|
||||
}
|
||||
|
||||
PCACHE_BLOCK CacheInternalFindBlock(PCACHE_DRIVE CacheDrive, ULONG BlockNumber)
|
||||
PCACHE_BLOCK CacheInternalFindBlock(PCACHE_DRIVE CacheDrive, U32 BlockNumber)
|
||||
{
|
||||
PCACHE_BLOCK CacheBlock = NULL;
|
||||
|
||||
@@ -93,7 +93,7 @@ PCACHE_BLOCK CacheInternalFindBlock(PCACHE_DRIVE CacheDrive, ULONG BlockNumber)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PCACHE_BLOCK CacheInternalAddBlockToCache(PCACHE_DRIVE CacheDrive, ULONG BlockNumber)
|
||||
PCACHE_BLOCK CacheInternalAddBlockToCache(PCACHE_DRIVE CacheDrive, U32 BlockNumber)
|
||||
{
|
||||
PCACHE_BLOCK CacheBlock = NULL;
|
||||
|
||||
@@ -195,7 +195,7 @@ BOOL CacheInternalFreeBlock(PCACHE_DRIVE CacheDrive)
|
||||
|
||||
VOID CacheInternalCheckCacheSizeLimits(PCACHE_DRIVE CacheDrive)
|
||||
{
|
||||
ULONG NewCacheSize;
|
||||
U32 NewCacheSize;
|
||||
|
||||
DbgPrint((DPRINT_CACHE, "CacheInternalCheckCacheSizeLimits()\n"));
|
||||
|
@@ -34,11 +34,11 @@
|
||||
CACHE_DRIVE CacheManagerDrive;
|
||||
BOOL CacheManagerInitialized = FALSE;
|
||||
BOOL CacheManagerDataInvalid = FALSE;
|
||||
ULONG CacheBlockCount = 0;
|
||||
ULONG CacheSizeLimit = 0;
|
||||
ULONG CacheSizeCurrent = 0;
|
||||
U32 CacheBlockCount = 0;
|
||||
U32 CacheSizeLimit = 0;
|
||||
U32 CacheSizeCurrent = 0;
|
||||
|
||||
BOOL CacheInitializeDrive(ULONG DriveNumber)
|
||||
BOOL CacheInitializeDrive(U32 DriveNumber)
|
||||
{
|
||||
PCACHE_BLOCK NextCacheBlock;
|
||||
GEOMETRY DriveGeometry;
|
||||
@@ -116,16 +116,16 @@ VOID CacheInvalidateCacheData(VOID)
|
||||
CacheManagerDataInvalid = TRUE;
|
||||
}
|
||||
|
||||
BOOL CacheReadDiskSectors(ULONG DiskNumber, ULONG StartSector, ULONG SectorCount, PVOID Buffer)
|
||||
BOOL CacheReadDiskSectors(U32 DiskNumber, U32 StartSector, U32 SectorCount, PVOID Buffer)
|
||||
{
|
||||
PCACHE_BLOCK CacheBlock;
|
||||
ULONG StartBlock;
|
||||
ULONG SectorOffsetInStartBlock;
|
||||
ULONG CopyLengthInStartBlock;
|
||||
ULONG EndBlock;
|
||||
ULONG SectorOffsetInEndBlock;
|
||||
ULONG BlockCount;
|
||||
ULONG Idx;
|
||||
U32 StartBlock;
|
||||
U32 SectorOffsetInStartBlock;
|
||||
U32 CopyLengthInStartBlock;
|
||||
U32 EndBlock;
|
||||
U32 SectorOffsetInEndBlock;
|
||||
U32 BlockCount;
|
||||
U32 Idx;
|
||||
|
||||
DbgPrint((DPRINT_CACHE, "CacheReadDiskSectors() DiskNumber: 0x%x StartSector: %d SectorCount: %d Buffer: 0x%x\n", DiskNumber, StartSector, SectorCount, Buffer));
|
||||
|
||||
@@ -248,13 +248,13 @@ BOOL CacheReadDiskSectors(ULONG DiskNumber, ULONG StartSector, ULONG SectorCount
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CacheForceDiskSectorsIntoCache(ULONG DiskNumber, ULONG StartSector, ULONG SectorCount)
|
||||
BOOL CacheForceDiskSectorsIntoCache(U32 DiskNumber, U32 StartSector, U32 SectorCount)
|
||||
{
|
||||
PCACHE_BLOCK CacheBlock;
|
||||
ULONG StartBlock;
|
||||
ULONG EndBlock;
|
||||
ULONG BlockCount;
|
||||
ULONG Idx;
|
||||
U32 StartBlock;
|
||||
U32 EndBlock;
|
||||
U32 BlockCount;
|
||||
U32 Idx;
|
||||
|
||||
DbgPrint((DPRINT_CACHE, "CacheForceDiskSectorsIntoCache() DiskNumber: 0x%x StartSector: %d SectorCount: %d\n", DiskNumber, StartSector, SectorCount));
|
||||
|
||||
@@ -294,9 +294,9 @@ BOOL CacheForceDiskSectorsIntoCache(ULONG DiskNumber, ULONG StartSector, ULONG S
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CacheReleaseMemory(ULONG MinimumAmountToRelease)
|
||||
BOOL CacheReleaseMemory(U32 MinimumAmountToRelease)
|
||||
{
|
||||
ULONG AmountReleased;
|
||||
U32 AmountReleased;
|
||||
|
||||
DbgPrint((DPRINT_CACHE, "CacheReleaseMemory() MinimumAmountToRelease = %d\n", MinimumAmountToRelease));
|
||||
|
@@ -38,9 +38,9 @@ typedef struct
|
||||
{
|
||||
LIST_ITEM ListEntry; // Doubly linked list synchronization member
|
||||
|
||||
ULONG BlockNumber; // Track index for CHS, 64k block index for LBA
|
||||
U32 BlockNumber; // Track index for CHS, 64k block index for LBA
|
||||
BOOL LockedInCache; // Indicates that this block is locked in cache memory
|
||||
ULONG AccessCount; // Access count for this block
|
||||
U32 AccessCount; // Access count for this block
|
||||
|
||||
PVOID BlockData; // Pointer to block data
|
||||
|
||||
@@ -55,10 +55,10 @@ typedef struct
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
typedef struct
|
||||
{
|
||||
ULONG DriveNumber;
|
||||
ULONG BytesPerSector;
|
||||
U32 DriveNumber;
|
||||
U32 BytesPerSector;
|
||||
|
||||
ULONG BlockSize; // Block size (in sectors)
|
||||
U32 BlockSize; // Block size (in sectors)
|
||||
PCACHE_BLOCK CacheBlockHead;
|
||||
|
||||
} CACHE_DRIVE, *PCACHE_DRIVE;
|
||||
@@ -71,18 +71,18 @@ typedef struct
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
extern CACHE_DRIVE CacheManagerDrive;
|
||||
extern BOOL CacheManagerInitialized;
|
||||
extern ULONG CacheBlockCount;
|
||||
extern ULONG CacheSizeLimit;
|
||||
extern ULONG CacheSizeCurrent;
|
||||
extern U32 CacheBlockCount;
|
||||
extern U32 CacheSizeLimit;
|
||||
extern U32 CacheSizeCurrent;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Internal functions
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
PCACHE_BLOCK CacheInternalGetBlockPointer(PCACHE_DRIVE CacheDrive, ULONG BlockNumber); // Returns a pointer to a CACHE_BLOCK structure given a block number
|
||||
PCACHE_BLOCK CacheInternalFindBlock(PCACHE_DRIVE CacheDrive, ULONG BlockNumber); // Searches the block list for a particular block
|
||||
PCACHE_BLOCK CacheInternalAddBlockToCache(PCACHE_DRIVE CacheDrive, ULONG BlockNumber); // Adds a block to the cache's block list
|
||||
PCACHE_BLOCK CacheInternalGetBlockPointer(PCACHE_DRIVE CacheDrive, U32 BlockNumber); // Returns a pointer to a CACHE_BLOCK structure given a block number
|
||||
PCACHE_BLOCK CacheInternalFindBlock(PCACHE_DRIVE CacheDrive, U32 BlockNumber); // Searches the block list for a particular block
|
||||
PCACHE_BLOCK CacheInternalAddBlockToCache(PCACHE_DRIVE CacheDrive, U32 BlockNumber); // Adds a block to the cache's block list
|
||||
BOOL CacheInternalFreeBlock(PCACHE_DRIVE CacheDrive); // Removes a block from the cache's block list & frees the memory
|
||||
VOID CacheInternalCheckCacheSizeLimits(PCACHE_DRIVE CacheDrive); // Checks the cache size limits to see if we can add a new block, if not calls CacheInternalFreeBlock()
|
||||
VOID CacheInternalDumpBlockList(PCACHE_DRIVE CacheDrive); // Dumps the list of cached blocks to the debug output port
|
@@ -1,4 +1,4 @@
|
||||
/* $Id$
|
||||
/* $Id: cmdline.c,v 1.1 2004/11/01 20:49:32 gvg Exp $
|
||||
*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
@@ -112,7 +112,7 @@ CmdLineGetDefaultOS(void)
|
||||
return CmdLineInfo.DefaultOperatingSystem;
|
||||
}
|
||||
|
||||
LONG
|
||||
S32
|
||||
CmdLineGetTimeOut(void)
|
||||
{
|
||||
return CmdLineInfo.TimeOut;
|
@@ -61,8 +61,8 @@
|
||||
|
||||
/* STATIC VARIABLES *********************************************************/
|
||||
|
||||
static ULONG Rs232ComPort = 0;
|
||||
static ULONG Rs232BaudRate = 0;
|
||||
static U32 Rs232ComPort = 0;
|
||||
static U32 Rs232BaudRate = 0;
|
||||
static PUCHAR Rs232PortBase = (PUCHAR)0;
|
||||
|
||||
/* The com port must only be initialized once! */
|
||||
@@ -73,8 +73,8 @@ static BOOLEAN PortInitialized = FALSE;
|
||||
static BOOL Rs232DoesComPortExist(PUCHAR BaseAddress)
|
||||
{
|
||||
BOOLEAN found;
|
||||
UCHAR mcr;
|
||||
UCHAR msr;
|
||||
U8 mcr;
|
||||
U8 msr;
|
||||
|
||||
found = FALSE;
|
||||
|
||||
@@ -118,12 +118,12 @@ static BOOL Rs232DoesComPortExist(PUCHAR BaseAddress)
|
||||
|
||||
/* FUNCTIONS *********************************************************/
|
||||
|
||||
BOOL Rs232PortInitialize(ULONG ComPort, ULONG BaudRate)
|
||||
BOOL Rs232PortInitialize(U32 ComPort, U32 BaudRate)
|
||||
{
|
||||
ULONG BaseArray[5] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8};
|
||||
U32 BaseArray[5] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8};
|
||||
//char buffer[80];
|
||||
ULONG divisor;
|
||||
UCHAR lcr;
|
||||
U32 divisor;
|
||||
U8 lcr;
|
||||
|
||||
if (PortInitialized == FALSE)
|
||||
{
|
||||
@@ -146,7 +146,7 @@ BOOL Rs232PortInitialize(ULONG ComPort, ULONG BaudRate)
|
||||
sprintf (buffer,
|
||||
"\nSerial port COM%ld found at 0x%lx\n",
|
||||
ComPort,
|
||||
(ULONG)PortBase);
|
||||
(U32)PortBase);
|
||||
HalDisplayString (buffer);
|
||||
#endif*/ /* NDEBUG */
|
||||
}
|
||||
@@ -158,7 +158,7 @@ BOOL Rs232PortInitialize(ULONG ComPort, ULONG BaudRate)
|
||||
sprintf (buffer,
|
||||
"\nSerial port COM%ld found at 0x%lx\n",
|
||||
ComPort,
|
||||
(ULONG)PortBase);
|
||||
(U32)PortBase);
|
||||
HalDisplayString (buffer);
|
||||
#endif*/ /* NDEBUG */
|
||||
}
|
||||
@@ -180,7 +180,7 @@ BOOL Rs232PortInitialize(ULONG ComPort, ULONG BaudRate)
|
||||
sprintf (buffer,
|
||||
"\nSerial port COM%ld found at 0x%lx\n",
|
||||
ComPort,
|
||||
(ULONG)PortBase);
|
||||
(U32)PortBase);
|
||||
HalDisplayString (buffer);
|
||||
#endif*/ /* NDEBUG */
|
||||
}
|
||||
@@ -222,7 +222,7 @@ BOOL Rs232PortInitialize(ULONG ComPort, ULONG BaudRate)
|
||||
/*
|
||||
* set global info
|
||||
*/
|
||||
//KdComPortInUse = (ULONG)PortBase;
|
||||
//KdComPortInUse = (U32)PortBase;
|
||||
|
||||
/*
|
||||
* print message to blue screen
|
||||
@@ -230,7 +230,7 @@ BOOL Rs232PortInitialize(ULONG ComPort, ULONG BaudRate)
|
||||
/*sprintf (buffer,
|
||||
"\nKernel Debugger: COM%ld (Port 0x%lx) BaudRate %ld\n\n",
|
||||
ComPort,
|
||||
(ULONG)PortBase,
|
||||
(U32)PortBase,
|
||||
BaudRate);
|
||||
|
||||
HalDisplayString (buffer);*/
|
411
freeldr/freeldr/custom.c
Normal file
411
freeldr/freeldr/custom.c
Normal file
@@ -0,0 +1,411 @@
|
||||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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 <rtl.h>
|
||||
#include <ui.h>
|
||||
#include <options.h>
|
||||
#include <miscboot.h>
|
||||
#include <debug.h>
|
||||
#include <disk.h>
|
||||
#include <arch.h>
|
||||
#include <inifile.h>
|
||||
#include <linux.h>
|
||||
#include <reactos.h>
|
||||
#include <drivemap.h>
|
||||
#include <machine.h>
|
||||
|
||||
|
||||
UCHAR BootDrivePrompt[] = "Enter the boot drive.\n\nExamples:\nfd0 - first floppy drive\nhd0 - first hard drive\nhd1 - second hard drive\ncd0 - first CD-ROM drive.\n\nBIOS drive numbers may also be used:\n0 - first floppy drive\n0x80 - first hard drive\n0x81 - second hard drive";
|
||||
UCHAR BootPartitionPrompt[] = "Enter the boot partition.\n\nEnter 0 for the active (bootable) partition.";
|
||||
UCHAR BootSectorFilePrompt[] = "Enter the boot sector file path.\n\nExamples:\n\\BOOTSECT.DOS\n/boot/bootsect.dos";
|
||||
UCHAR LinuxKernelPrompt[] = "Enter the Linux kernel image path.\n\nExamples:\n/vmlinuz\n/boot/vmlinuz-2.4.18";
|
||||
UCHAR LinuxInitrdPrompt[] = "Enter the initrd image path.\n\nExamples:\n/initrd.gz\n/boot/root.img.gz\n\nLeave blank for no initial ram disk.";
|
||||
UCHAR LinuxCommandLinePrompt[] = "Enter the Linux kernel command line.\n\nExamples:\nroot=/dev/hda1\nroot=/dev/fd0 read-only\nroot=/dev/sdb1 init=/sbin/init";
|
||||
UCHAR ReactOSSystemPathPrompt[] = "Enter the path to your ReactOS system directory.\n\nExamples:\n\\REACTOS\n\\ROS";
|
||||
UCHAR ReactOSOptionsPrompt[] = "Enter the options you want passed to the kernel.\n\nExamples:\n/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200\n/FASTDETECT /SOS /NOGUIBOOT\n/BASEVIDEO /MAXMEM=64\n/KERNEL=NTKRNLMP.EXE /HAL=HALMPS.DLL";
|
||||
|
||||
UCHAR CustomBootPrompt[] = "Press ENTER to boot your custom boot setup.";
|
||||
|
||||
VOID OptionMenuCustomBoot(VOID)
|
||||
{
|
||||
PUCHAR CustomBootMenuList[] = { "Disk", "Partition", "Boot Sector File", "ReactOS", "Linux" };
|
||||
U32 CustomBootMenuCount = sizeof(CustomBootMenuList) / sizeof(CustomBootMenuList[0]);
|
||||
U32 SelectedMenuItem;
|
||||
|
||||
if (!UiDisplayMenu(CustomBootMenuList, CustomBootMenuCount, 0, -1, &SelectedMenuItem, TRUE, NULL))
|
||||
{
|
||||
// The user pressed ESC
|
||||
return;
|
||||
}
|
||||
|
||||
switch (SelectedMenuItem)
|
||||
{
|
||||
case 0: // Disk
|
||||
OptionMenuCustomBootDisk();
|
||||
break;
|
||||
case 1: // Partition
|
||||
OptionMenuCustomBootPartition();
|
||||
break;
|
||||
case 2: // Boot Sector File
|
||||
OptionMenuCustomBootBootSectorFile();
|
||||
break;
|
||||
case 3: // ReactOS
|
||||
OptionMenuCustomBootReactOS();
|
||||
break;
|
||||
case 4: // Linux
|
||||
OptionMenuCustomBootLinux();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
VOID OptionMenuCustomBootDisk(VOID)
|
||||
{
|
||||
UCHAR SectionName[100];
|
||||
UCHAR BootDriveString[20];
|
||||
U32 SectionId;
|
||||
U32 Year, Month, Day, Hour, Minute, Second;
|
||||
|
||||
RtlZeroMemory(SectionName, sizeof(SectionName));
|
||||
RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
|
||||
|
||||
if (!UiEditBox(BootDrivePrompt, BootDriveString, 20))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate a unique section name
|
||||
MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second);
|
||||
sprintf(SectionName, "CustomBootDisk%d%d%d%d%d%d", Year, Day, Month, Hour, Minute, Second);
|
||||
|
||||
// Add the section
|
||||
if (!IniAddSection(SectionName, &SectionId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the BootType
|
||||
if (!IniAddSettingValueToSection(SectionId, "BootType", "Drive"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the BootDrive
|
||||
if (!IniAddSettingValueToSection(SectionId, "BootDrive", BootDriveString))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UiMessageBox(CustomBootPrompt);
|
||||
|
||||
LoadAndBootDrive(SectionName);
|
||||
}
|
||||
|
||||
VOID OptionMenuCustomBootPartition(VOID)
|
||||
{
|
||||
UCHAR SectionName[100];
|
||||
UCHAR BootDriveString[20];
|
||||
UCHAR BootPartitionString[20];
|
||||
U32 SectionId;
|
||||
U32 Year, Month, Day, Hour, Minute, Second;
|
||||
|
||||
RtlZeroMemory(SectionName, sizeof(SectionName));
|
||||
RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
|
||||
RtlZeroMemory(BootPartitionString, sizeof(BootPartitionString));
|
||||
|
||||
if (!UiEditBox(BootDrivePrompt, BootDriveString, 20))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UiEditBox(BootPartitionPrompt, BootPartitionString, 20))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate a unique section name
|
||||
MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second);
|
||||
sprintf(SectionName, "CustomBootPartition%d%d%d%d%d%d", Year, Day, Month, Hour, Minute, Second);
|
||||
|
||||
// Add the section
|
||||
if (!IniAddSection(SectionName, &SectionId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the BootType
|
||||
if (!IniAddSettingValueToSection(SectionId, "BootType", "Partition"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the BootDrive
|
||||
if (!IniAddSettingValueToSection(SectionId, "BootDrive", BootDriveString))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the BootPartition
|
||||
if (!IniAddSettingValueToSection(SectionId, "BootPartition", BootPartitionString))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UiMessageBox(CustomBootPrompt);
|
||||
|
||||
LoadAndBootPartition(SectionName);
|
||||
}
|
||||
|
||||
VOID OptionMenuCustomBootBootSectorFile(VOID)
|
||||
{
|
||||
UCHAR SectionName[100];
|
||||
UCHAR BootDriveString[20];
|
||||
UCHAR BootPartitionString[20];
|
||||
UCHAR BootSectorFileString[200];
|
||||
U32 SectionId;
|
||||
U32 Year, Month, Day, Hour, Minute, Second;
|
||||
|
||||
RtlZeroMemory(SectionName, sizeof(SectionName));
|
||||
RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
|
||||
RtlZeroMemory(BootPartitionString, sizeof(BootPartitionString));
|
||||
RtlZeroMemory(BootSectorFileString, sizeof(BootSectorFileString));
|
||||
|
||||
if (!UiEditBox(BootDrivePrompt, BootDriveString, 20))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UiEditBox(BootPartitionPrompt, BootPartitionString, 20))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UiEditBox(BootSectorFilePrompt, BootSectorFileString, 200))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate a unique section name
|
||||
MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second);
|
||||
sprintf(SectionName, "CustomBootSectorFile%d%d%d%d%d%d", Year, Day, Month, Hour, Minute, Second);
|
||||
|
||||
// Add the section
|
||||
if (!IniAddSection(SectionName, &SectionId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the BootType
|
||||
if (!IniAddSettingValueToSection(SectionId, "BootType", "BootSector"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the BootDrive
|
||||
if (!IniAddSettingValueToSection(SectionId, "BootDrive", BootDriveString))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the BootPartition
|
||||
if (!IniAddSettingValueToSection(SectionId, "BootPartition", BootPartitionString))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the BootSectorFile
|
||||
if (!IniAddSettingValueToSection(SectionId, "BootSectorFile", BootSectorFileString))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UiMessageBox(CustomBootPrompt);
|
||||
|
||||
LoadAndBootBootSector(SectionName);
|
||||
}
|
||||
|
||||
VOID OptionMenuCustomBootReactOS(VOID)
|
||||
{
|
||||
UCHAR SectionName[100];
|
||||
UCHAR BootDriveString[20];
|
||||
UCHAR BootPartitionString[20];
|
||||
UCHAR ReactOSSystemPath[200];
|
||||
UCHAR ReactOSARCPath[200];
|
||||
UCHAR ReactOSOptions[200];
|
||||
U32 SectionId;
|
||||
U32 Year, Month, Day, Hour, Minute, Second;
|
||||
|
||||
RtlZeroMemory(SectionName, sizeof(SectionName));
|
||||
RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
|
||||
RtlZeroMemory(BootPartitionString, sizeof(BootPartitionString));
|
||||
RtlZeroMemory(ReactOSSystemPath, sizeof(ReactOSSystemPath));
|
||||
RtlZeroMemory(ReactOSOptions, sizeof(ReactOSOptions));
|
||||
|
||||
if (!UiEditBox(BootDrivePrompt, BootDriveString, 20))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UiEditBox(BootPartitionPrompt, BootPartitionString, 20))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UiEditBox(ReactOSSystemPathPrompt, ReactOSSystemPath, 200))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UiEditBox(ReactOSOptionsPrompt, ReactOSOptions, 200))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate a unique section name
|
||||
MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second);
|
||||
sprintf(SectionName, "CustomReactOS%d%d%d%d%d%d", Year, Day, Month, Hour, Minute, Second);
|
||||
|
||||
// Add the section
|
||||
if (!IniAddSection(SectionName, &SectionId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the BootType
|
||||
if (!IniAddSettingValueToSection(SectionId, "BootType", "ReactOS"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Construct the ReactOS ARC system path
|
||||
ConstructArcPath(ReactOSARCPath, ReactOSSystemPath, DriveMapGetBiosDriveNumber(BootDriveString), atoi(BootPartitionString));
|
||||
|
||||
// Add the system path
|
||||
if (!IniAddSettingValueToSection(SectionId, "SystemPath", ReactOSARCPath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the CommandLine
|
||||
if (!IniAddSettingValueToSection(SectionId, "Options", ReactOSOptions))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UiMessageBox(CustomBootPrompt);
|
||||
|
||||
LoadAndBootReactOS(SectionName);
|
||||
}
|
||||
|
||||
VOID OptionMenuCustomBootLinux(VOID)
|
||||
{
|
||||
UCHAR SectionName[100];
|
||||
UCHAR BootDriveString[20];
|
||||
UCHAR BootPartitionString[20];
|
||||
UCHAR LinuxKernelString[200];
|
||||
UCHAR LinuxInitrdString[200];
|
||||
UCHAR LinuxCommandLineString[200];
|
||||
U32 SectionId;
|
||||
U32 Year, Month, Day, Hour, Minute, Second;
|
||||
|
||||
RtlZeroMemory(SectionName, sizeof(SectionName));
|
||||
RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
|
||||
RtlZeroMemory(BootPartitionString, sizeof(BootPartitionString));
|
||||
RtlZeroMemory(LinuxKernelString, sizeof(LinuxKernelString));
|
||||
RtlZeroMemory(LinuxInitrdString, sizeof(LinuxInitrdString));
|
||||
RtlZeroMemory(LinuxCommandLineString, sizeof(LinuxCommandLineString));
|
||||
|
||||
if (!UiEditBox(BootDrivePrompt, BootDriveString, 20))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UiEditBox(BootPartitionPrompt, BootPartitionString, 20))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UiEditBox(LinuxKernelPrompt, LinuxKernelString, 200))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UiEditBox(LinuxInitrdPrompt, LinuxInitrdString, 200))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UiEditBox(LinuxCommandLinePrompt, LinuxCommandLineString, 200))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate a unique section name
|
||||
MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second);
|
||||
sprintf(SectionName, "CustomLinux%d%d%d%d%d%d", Year, Day, Month, Hour, Minute, Second);
|
||||
|
||||
// Add the section
|
||||
if (!IniAddSection(SectionName, &SectionId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the BootType
|
||||
if (!IniAddSettingValueToSection(SectionId, "BootType", "Linux"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the BootDrive
|
||||
if (!IniAddSettingValueToSection(SectionId, "BootDrive", BootDriveString))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the BootPartition
|
||||
if (!IniAddSettingValueToSection(SectionId, "BootPartition", BootPartitionString))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the Kernel
|
||||
if (!IniAddSettingValueToSection(SectionId, "Kernel", LinuxKernelString))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the Initrd
|
||||
if (strlen(LinuxInitrdString) > 0)
|
||||
{
|
||||
if (!IniAddSettingValueToSection(SectionId, "Initrd", LinuxInitrdString))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Add the CommandLine
|
||||
if (!IniAddSettingValueToSection(SectionId, "CommandLine", LinuxCommandLineString))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UiMessageBox(CustomBootPrompt);
|
||||
|
||||
LoadAndBootLinux(SectionName, "Custom Linux Setup");
|
||||
}
|
411
freeldr/freeldr/debug.c
Normal file
411
freeldr/freeldr/debug.c
Normal file
@@ -0,0 +1,411 @@
|
||||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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 <debug.h>
|
||||
#include <rtl.h>
|
||||
#include <comm.h>
|
||||
#include <portio.h>
|
||||
#include <machine.h>
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
//#define DEBUG_ALL
|
||||
//#define DEBUG_INIFILE
|
||||
//#define DEBUG_REACTOS
|
||||
//#define DEBUG_CUSTOM
|
||||
#define DEBUG_NONE
|
||||
|
||||
#if defined (DEBUG_ALL)
|
||||
U32 DebugPrintMask = DPRINT_WARNING | DPRINT_MEMORY | DPRINT_FILESYSTEM |
|
||||
DPRINT_UI | DPRINT_DISK | DPRINT_CACHE | DPRINT_REACTOS |
|
||||
DPRINT_LINUX;
|
||||
#elif defined (DEBUG_INIFILE)
|
||||
U32 DebugPrintMask = DPRINT_INIFILE;
|
||||
#elif defined (DEBUG_REACTOS)
|
||||
U32 DebugPrintMask = DPRINT_REACTOS | DPRINT_REGISTRY;
|
||||
#elif defined (DEBUG_CUSTOM)
|
||||
U32 DebugPrintMask = DPRINT_WARNING|DPRINT_FILESYSTEM|DPRINT_MEMORY|DPRINT_LINUX;
|
||||
#else //#elif defined (DEBUG_NONE)
|
||||
U32 DebugPrintMask = 0;
|
||||
#endif
|
||||
|
||||
#define SCREEN 0
|
||||
#define RS232 1
|
||||
#define BOCHS 2
|
||||
|
||||
#define COM1 1
|
||||
#define COM2 2
|
||||
#define COM3 3
|
||||
#define COM4 4
|
||||
|
||||
#define BOCHS_OUTPUT_PORT 0xe9
|
||||
|
||||
U32 DebugPort = RS232;
|
||||
//U32 DebugPort = SCREEN;
|
||||
//U32 DebugPort = BOCHS;
|
||||
U32 ComPort = COM1;
|
||||
//U32 BaudRate = 19200;
|
||||
U32 BaudRate = 115200;
|
||||
|
||||
BOOL DebugStartOfLine = TRUE;
|
||||
|
||||
VOID DebugInit(VOID)
|
||||
{
|
||||
if (DebugPort == RS232)
|
||||
{
|
||||
Rs232PortInitialize(ComPort, BaudRate);
|
||||
}
|
||||
}
|
||||
|
||||
VOID DebugPrintChar(UCHAR Character)
|
||||
{
|
||||
if (Character == '\n')
|
||||
{
|
||||
DebugStartOfLine = TRUE;
|
||||
}
|
||||
|
||||
if (DebugPort == RS232)
|
||||
{
|
||||
if (Character == '\n')
|
||||
{
|
||||
Rs232PortPutByte('\r');
|
||||
}
|
||||
Rs232PortPutByte(Character);
|
||||
}
|
||||
else if (DebugPort == BOCHS)
|
||||
{
|
||||
WRITE_PORT_UCHAR((PUCHAR)BOCHS_OUTPUT_PORT, Character);
|
||||
}
|
||||
else
|
||||
{
|
||||
MachConsPutChar(Character);
|
||||
}
|
||||
}
|
||||
|
||||
VOID DebugPrintHeader(U32 Mask)
|
||||
{
|
||||
/* No header */
|
||||
if (Mask == 0)
|
||||
return;
|
||||
|
||||
switch (Mask)
|
||||
{
|
||||
case DPRINT_WARNING:
|
||||
DebugPrintChar('W');
|
||||
DebugPrintChar('A');
|
||||
DebugPrintChar('R');
|
||||
DebugPrintChar('N');
|
||||
DebugPrintChar('I');
|
||||
DebugPrintChar('N');
|
||||
DebugPrintChar('G');
|
||||
DebugPrintChar(':');
|
||||
DebugPrintChar(' ');
|
||||
break;
|
||||
case DPRINT_MEMORY:
|
||||
DebugPrintChar('M');
|
||||
DebugPrintChar('E');
|
||||
DebugPrintChar('M');
|
||||
DebugPrintChar('O');
|
||||
DebugPrintChar('R');
|
||||
DebugPrintChar('Y');
|
||||
DebugPrintChar(':');
|
||||
DebugPrintChar(' ');
|
||||
break;
|
||||
case DPRINT_FILESYSTEM:
|
||||
DebugPrintChar('F');
|
||||
DebugPrintChar('I');
|
||||
DebugPrintChar('L');
|
||||
DebugPrintChar('E');
|
||||
DebugPrintChar('S');
|
||||
DebugPrintChar('Y');
|
||||
DebugPrintChar('S');
|
||||
DebugPrintChar(':');
|
||||
DebugPrintChar(' ');
|
||||
break;
|
||||
case DPRINT_INIFILE:
|
||||
DebugPrintChar('I');
|
||||
DebugPrintChar('N');
|
||||
DebugPrintChar('I');
|
||||
DebugPrintChar('F');
|
||||
DebugPrintChar('I');
|
||||
DebugPrintChar('L');
|
||||
DebugPrintChar('E');
|
||||
DebugPrintChar(':');
|
||||
DebugPrintChar(' ');
|
||||
break;
|
||||
case DPRINT_UI:
|
||||
DebugPrintChar('U');
|
||||
DebugPrintChar('I');
|
||||
DebugPrintChar(':');
|
||||
DebugPrintChar(' ');
|
||||
break;
|
||||
case DPRINT_DISK:
|
||||
DebugPrintChar('D');
|
||||
DebugPrintChar('I');
|
||||
DebugPrintChar('S');
|
||||
DebugPrintChar('K');
|
||||
DebugPrintChar(':');
|
||||
DebugPrintChar(' ');
|
||||
break;
|
||||
case DPRINT_CACHE:
|
||||
DebugPrintChar('C');
|
||||
DebugPrintChar('A');
|
||||
DebugPrintChar('C');
|
||||
DebugPrintChar('H');
|
||||
DebugPrintChar('E');
|
||||
DebugPrintChar(':');
|
||||
DebugPrintChar(' ');
|
||||
break;
|
||||
case DPRINT_REGISTRY:
|
||||
DebugPrintChar('R');
|
||||
DebugPrintChar('E');
|
||||
DebugPrintChar('G');
|
||||
DebugPrintChar('I');
|
||||
DebugPrintChar('S');
|
||||
DebugPrintChar('T');
|
||||
DebugPrintChar('R');
|
||||
DebugPrintChar('Y');
|
||||
DebugPrintChar(':');
|
||||
DebugPrintChar(' ');
|
||||
break;
|
||||
case DPRINT_REACTOS:
|
||||
DebugPrintChar('R');
|
||||
DebugPrintChar('E');
|
||||
DebugPrintChar('A');
|
||||
DebugPrintChar('C');
|
||||
DebugPrintChar('T');
|
||||
DebugPrintChar('O');
|
||||
DebugPrintChar('S');
|
||||
DebugPrintChar(':');
|
||||
DebugPrintChar(' ');
|
||||
break;
|
||||
case DPRINT_LINUX:
|
||||
DebugPrintChar('L');
|
||||
DebugPrintChar('I');
|
||||
DebugPrintChar('N');
|
||||
DebugPrintChar('U');
|
||||
DebugPrintChar('X');
|
||||
DebugPrintChar(':');
|
||||
DebugPrintChar(' ');
|
||||
break;
|
||||
case DPRINT_HWDETECT:
|
||||
DebugPrintChar('H');
|
||||
DebugPrintChar('W');
|
||||
DebugPrintChar('D');
|
||||
DebugPrintChar('E');
|
||||
DebugPrintChar('T');
|
||||
DebugPrintChar('E');
|
||||
DebugPrintChar('C');
|
||||
DebugPrintChar('T');
|
||||
DebugPrintChar(':');
|
||||
DebugPrintChar(' ');
|
||||
break;
|
||||
default:
|
||||
DebugPrintChar('U');
|
||||
DebugPrintChar('N');
|
||||
DebugPrintChar('K');
|
||||
DebugPrintChar('N');
|
||||
DebugPrintChar('O');
|
||||
DebugPrintChar('W');
|
||||
DebugPrintChar('N');
|
||||
DebugPrintChar(':');
|
||||
DebugPrintChar(' ');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static VOID DebugPrintV(char *format, int *dataptr)
|
||||
{
|
||||
char c, *ptr, str[16];
|
||||
int ll;
|
||||
|
||||
ll = 0;
|
||||
while ((c = *(format++)))
|
||||
{
|
||||
if (c != '%')
|
||||
{
|
||||
DebugPrintChar(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*format == 'I' && *(format+1) == '6' && *(format+2) == '4')
|
||||
{
|
||||
ll = 1;
|
||||
format += 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
ll = 0;
|
||||
}
|
||||
switch (c = *(format++))
|
||||
{
|
||||
case 'd': case 'u': case 'x':
|
||||
|
||||
if (ll)
|
||||
{
|
||||
*convert_i64_to_ascii(str, c, *((unsigned long long*) dataptr)) = 0;
|
||||
dataptr += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
*convert_to_ascii(str, c, *((unsigned long *) dataptr++)) = 0;
|
||||
}
|
||||
|
||||
ptr = str;
|
||||
|
||||
while (*ptr)
|
||||
{
|
||||
DebugPrintChar(*(ptr++));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
|
||||
DebugPrintChar((*(dataptr++))&0xff);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
|
||||
ptr = (char *)(*(dataptr++));
|
||||
|
||||
while ((c = *(ptr++)))
|
||||
{
|
||||
DebugPrintChar(c);
|
||||
}
|
||||
break;
|
||||
case '%':
|
||||
DebugPrintChar(c);
|
||||
break;
|
||||
default:
|
||||
DebugPrint(DPRINT_WARNING, "\nDebugPrint() invalid format specifier - %%%c\n", c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (DebugPort == SCREEN)
|
||||
{
|
||||
//getch();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
VOID DebugPrint(U32 Mask, char *format, ...)
|
||||
{
|
||||
int *dataptr = (int *) &format;
|
||||
|
||||
// Mask out unwanted debug messages
|
||||
if (!(Mask & DebugPrintMask))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Print the header if we have started a new line
|
||||
if (DebugStartOfLine)
|
||||
{
|
||||
DebugPrintHeader(Mask);
|
||||
DebugStartOfLine = FALSE;
|
||||
}
|
||||
|
||||
DebugPrintV(format, ++dataptr);
|
||||
}
|
||||
|
||||
VOID DebugPrint1(char *format, ...)
|
||||
{
|
||||
int *dataptr = (int *) &format;
|
||||
|
||||
DebugPrintV(format, ++dataptr);
|
||||
}
|
||||
|
||||
VOID DebugDumpBuffer(U32 Mask, PVOID Buffer, U32 Length)
|
||||
{
|
||||
PUCHAR BufPtr = (PUCHAR)Buffer;
|
||||
U32 Idx;
|
||||
U32 Idx2;
|
||||
|
||||
// Mask out unwanted debug messages
|
||||
if (!(Mask & DebugPrintMask))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DebugStartOfLine = FALSE; // We don't want line headers
|
||||
DebugPrint(Mask, "Dumping buffer at 0x%x with length of %d bytes:\n", Buffer, Length);
|
||||
|
||||
for (Idx=0; Idx<Length; )
|
||||
{
|
||||
DebugStartOfLine = FALSE; // We don't want line headers
|
||||
|
||||
if (Idx < 0x0010)
|
||||
{
|
||||
DebugPrint(Mask, "000%x:\t", Idx);
|
||||
}
|
||||
else if (Idx < 0x0100)
|
||||
{
|
||||
DebugPrint(Mask, "00%x:\t", Idx);
|
||||
}
|
||||
else if (Idx < 0x1000)
|
||||
{
|
||||
DebugPrint(Mask, "0%x:\t", Idx);
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugPrint(Mask, "%x:\t", Idx);
|
||||
}
|
||||
|
||||
for (Idx2=0; Idx2<16; Idx2++,Idx++)
|
||||
{
|
||||
if (BufPtr[Idx] < 0x10)
|
||||
{
|
||||
DebugPrint(Mask, "0");
|
||||
}
|
||||
DebugPrint(Mask, "%x", BufPtr[Idx]);
|
||||
|
||||
if (Idx2 == 7)
|
||||
{
|
||||
DebugPrint(Mask, "-");
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugPrint(Mask, " ");
|
||||
}
|
||||
}
|
||||
|
||||
Idx -= 16;
|
||||
DebugPrint(Mask, " ");
|
||||
|
||||
for (Idx2=0; Idx2<16; Idx2++,Idx++)
|
||||
{
|
||||
if ((BufPtr[Idx] > 20) && (BufPtr[Idx] < 0x80))
|
||||
{
|
||||
DebugPrint(Mask, "%c", BufPtr[Idx]);
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugPrint(Mask, ".");
|
||||
}
|
||||
}
|
||||
|
||||
DebugPrint(Mask, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
#endif // defined DEBUG
|
112
freeldr/freeldr/disk/disk.c
Normal file
112
freeldr/freeldr/disk/disk.c
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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 <arch.h>
|
||||
#include <rtl.h>
|
||||
#include <ui.h>
|
||||
#include <debug.h>
|
||||
|
||||
|
||||
#undef UNIMPLEMENTED
|
||||
#define UNIMPLEMENTED BugCheck((DPRINT_WARNING, "Unimplemented\n"));
|
||||
|
||||
static BOOL bReportError = TRUE;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FUNCTIONS
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VOID DiskReportError (BOOL bError)
|
||||
{
|
||||
bReportError = bError;
|
||||
}
|
||||
|
||||
VOID DiskError(PUCHAR ErrorString, U32 ErrorCode)
|
||||
{
|
||||
UCHAR ErrorCodeString[200];
|
||||
|
||||
if (bReportError == FALSE)
|
||||
return;
|
||||
|
||||
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)
|
||||
|
||||
BOOL DiskIsDriveRemovable(U32 DriveNumber)
|
||||
{
|
||||
// Hard disks use drive numbers >= 0x80
|
||||
// So if the drive number indicates a hard disk
|
||||
// then return FALSE
|
||||
if (DriveNumber >= 0x80)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Drive is a floppy diskette so return TRUE
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// This function is in arch/i386/i386disk.c
|
||||
//VOID DiskStopFloppyMotor(VOID)
|
||||
|
||||
// This function is in arch/i386/i386disk.c
|
||||
//U32 DiskGetCacheableBlockCount(U32 DriveNumber)
|
@@ -26,10 +26,9 @@
|
||||
#include <machine.h>
|
||||
|
||||
|
||||
BOOL DiskGetActivePartitionEntry(ULONG DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
|
||||
BOOL DiskGetActivePartitionEntry(U32 DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
|
||||
{
|
||||
ULONG BootablePartitionCount = 0;
|
||||
ULONG ActivePartition = 0;
|
||||
U32 BootablePartitionCount = 0;
|
||||
MASTER_BOOT_RECORD MasterBootRecord;
|
||||
|
||||
// Read master boot record
|
||||
@@ -42,22 +41,22 @@ BOOL DiskGetActivePartitionEntry(ULONG DriveNumber, PPARTITION_TABLE_ENTRY Parti
|
||||
if (MasterBootRecord.PartitionTable[0].BootIndicator == 0x80)
|
||||
{
|
||||
BootablePartitionCount++;
|
||||
ActivePartition = 0;
|
||||
BootPartition = 0;
|
||||
}
|
||||
if (MasterBootRecord.PartitionTable[1].BootIndicator == 0x80)
|
||||
{
|
||||
BootablePartitionCount++;
|
||||
ActivePartition = 1;
|
||||
BootPartition = 1;
|
||||
}
|
||||
if (MasterBootRecord.PartitionTable[2].BootIndicator == 0x80)
|
||||
{
|
||||
BootablePartitionCount++;
|
||||
ActivePartition = 2;
|
||||
BootPartition = 2;
|
||||
}
|
||||
if (MasterBootRecord.PartitionTable[3].BootIndicator == 0x80)
|
||||
{
|
||||
BootablePartitionCount++;
|
||||
ActivePartition = 3;
|
||||
BootPartition = 3;
|
||||
}
|
||||
|
||||
// Make sure there was only one bootable partition
|
||||
@@ -73,18 +72,18 @@ BOOL DiskGetActivePartitionEntry(ULONG DriveNumber, PPARTITION_TABLE_ENTRY Parti
|
||||
}
|
||||
|
||||
// Copy the partition table entry
|
||||
RtlCopyMemory(PartitionTableEntry, &MasterBootRecord.PartitionTable[ActivePartition], sizeof(PARTITION_TABLE_ENTRY));
|
||||
RtlCopyMemory(PartitionTableEntry, &MasterBootRecord.PartitionTable[BootPartition], sizeof(PARTITION_TABLE_ENTRY));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL DiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
|
||||
BOOL DiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
|
||||
{
|
||||
MASTER_BOOT_RECORD MasterBootRecord;
|
||||
PARTITION_TABLE_ENTRY ExtendedPartitionTableEntry;
|
||||
ULONG ExtendedPartitionNumber;
|
||||
ULONG ExtendedPartitionOffset;
|
||||
ULONG Index;
|
||||
U32 ExtendedPartitionNumber;
|
||||
U32 ExtendedPartitionOffset;
|
||||
U32 Index;
|
||||
|
||||
// Read master boot record
|
||||
if (!DiskReadBootRecord(DriveNumber, 0, &MasterBootRecord))
|
||||
@@ -158,7 +157,7 @@ BOOL DiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_
|
||||
|
||||
BOOL DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry)
|
||||
{
|
||||
ULONG Index;
|
||||
U32 Index;
|
||||
|
||||
for (Index=0; Index<4; Index++)
|
||||
{
|
||||
@@ -179,7 +178,7 @@ BOOL DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION
|
||||
|
||||
BOOL DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry)
|
||||
{
|
||||
ULONG Index;
|
||||
U32 Index;
|
||||
|
||||
for (Index=0; Index<4; Index++)
|
||||
{
|
||||
@@ -196,11 +195,11 @@ BOOL DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PP
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL DiskReadBootRecord(ULONG DriveNumber, ULONGLONG LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord)
|
||||
BOOL DiskReadBootRecord(U32 DriveNumber, U64 LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord)
|
||||
{
|
||||
char ErrMsg[64];
|
||||
#ifdef DEBUG
|
||||
ULONG Index;
|
||||
U32 Index;
|
||||
#endif
|
||||
|
||||
// Read master boot record
|
@@ -26,21 +26,21 @@
|
||||
#include <debug.h>
|
||||
|
||||
BOOL DriveMapInstalled = FALSE; // Tells us if we have already installed our drive map int 13h handler code
|
||||
ULONG OldInt13HandlerAddress = 0; // Address of BIOS int 13h handler
|
||||
ULONG DriveMapHandlerAddress = 0; // Linear address of our drive map handler
|
||||
ULONG DriveMapHandlerSegOff = 0; // Segment:offset style address of our drive map handler
|
||||
U32 OldInt13HandlerAddress = 0; // Address of BIOS int 13h handler
|
||||
U32 DriveMapHandlerAddress = 0; // Linear address of our drive map handler
|
||||
U32 DriveMapHandlerSegOff = 0; // Segment:offset style address of our drive map handler
|
||||
|
||||
VOID DriveMapMapDrivesInSection(PCHAR SectionName)
|
||||
VOID DriveMapMapDrivesInSection(PUCHAR SectionName)
|
||||
{
|
||||
CHAR SettingName[80];
|
||||
CHAR SettingValue[80];
|
||||
CHAR ErrorText[260];
|
||||
CHAR Drive1[80];
|
||||
CHAR Drive2[80];
|
||||
ULONG SectionId;
|
||||
ULONG SectionItemCount;
|
||||
ULONG Index;
|
||||
ULONG Index2;
|
||||
UCHAR SettingName[80];
|
||||
UCHAR SettingValue[80];
|
||||
UCHAR ErrorText[260];
|
||||
UCHAR Drive1[80];
|
||||
UCHAR Drive2[80];
|
||||
U32 SectionId;
|
||||
U32 SectionItemCount;
|
||||
U32 Index;
|
||||
U32 Index2;
|
||||
DRIVE_MAP_LIST DriveMapList;
|
||||
|
||||
RtlZeroMemory(&DriveMapList, sizeof(DRIVE_MAP_LIST));
|
||||
@@ -117,9 +117,9 @@ VOID DriveMapMapDrivesInSection(PCHAR SectionName)
|
||||
}
|
||||
}
|
||||
|
||||
BOOL DriveMapIsValidDriveString(PCHAR DriveString)
|
||||
BOOL DriveMapIsValidDriveString(PUCHAR DriveString)
|
||||
{
|
||||
ULONG Index;
|
||||
U32 Index;
|
||||
|
||||
// Now verify that the user has given us appropriate strings
|
||||
if ((strlen(DriveString) < 3) ||
|
||||
@@ -147,9 +147,9 @@ BOOL DriveMapIsValidDriveString(PCHAR DriveString)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ULONG DriveMapGetBiosDriveNumber(PCHAR DeviceName)
|
||||
U32 DriveMapGetBiosDriveNumber(PUCHAR DeviceName)
|
||||
{
|
||||
ULONG BiosDriveNumber = 0;
|
||||
U32 BiosDriveNumber = 0;
|
||||
|
||||
// If they passed in a number string then just
|
||||
// convert it to decimal and return it
|
||||
@@ -174,8 +174,8 @@ ULONG DriveMapGetBiosDriveNumber(PCHAR DeviceName)
|
||||
|
||||
VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap)
|
||||
{
|
||||
ULONG* RealModeIVT = (ULONG*)0x00000000;
|
||||
USHORT* BiosLowMemorySize = (USHORT*)0x00000413;
|
||||
U32* RealModeIVT = (U32*)0x00000000;
|
||||
U16* BiosLowMemorySize = (U16*)0x00000413;
|
||||
|
||||
if (!DriveMapInstalled)
|
||||
{
|
||||
@@ -186,7 +186,7 @@ VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap)
|
||||
(*BiosLowMemorySize)--;
|
||||
|
||||
// Get linear address for drive map handler
|
||||
DriveMapHandlerAddress = (ULONG)(*BiosLowMemorySize) << 10;
|
||||
DriveMapHandlerAddress = (U32)(*BiosLowMemorySize) << 10;
|
||||
|
||||
// Convert to segment:offset style address
|
||||
DriveMapHandlerSegOff = (DriveMapHandlerAddress << 12) & 0xffff0000;
|
||||
@@ -199,7 +199,7 @@ VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap)
|
||||
DriveMapOldInt13HandlerAddress = OldInt13HandlerAddress;
|
||||
|
||||
// Copy the code to our reserved area
|
||||
RtlCopyMemory((PVOID)DriveMapHandlerAddress, &DriveMapInt13HandlerStart, ((ULONG)&DriveMapInt13HandlerEnd - (ULONG)&DriveMapInt13HandlerStart));
|
||||
RtlCopyMemory((PVOID)DriveMapHandlerAddress, &DriveMapInt13HandlerStart, ((U32)&DriveMapInt13HandlerEnd - (U32)&DriveMapInt13HandlerStart));
|
||||
|
||||
// Update the IVT
|
||||
RealModeIVT[0x13] = DriveMapHandlerSegOff;
|
||||
@@ -210,8 +210,8 @@ VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap)
|
||||
|
||||
VOID DriveMapRemoveInt13Handler(VOID)
|
||||
{
|
||||
ULONG* RealModeIVT = (ULONG*)0x00000000;
|
||||
USHORT* BiosLowMemorySize = (USHORT*)0x00000413;
|
||||
U32* RealModeIVT = (U32*)0x00000000;
|
||||
U16* BiosLowMemorySize = (U16*)0x00000413;
|
||||
|
||||
if (DriveMapInstalled)
|
||||
{
|
@@ -31,7 +31,7 @@ VOID BootMain(char *CmdLine)
|
||||
{
|
||||
CmdLineParse(CmdLine);
|
||||
|
||||
MachInit(CmdLine);
|
||||
MachInit();
|
||||
|
||||
DebugInit();
|
||||
|
@@ -35,17 +35,17 @@ GEOMETRY Ext2DiskGeometry; // Ext2 file system disk geometry
|
||||
PEXT2_SUPER_BLOCK Ext2SuperBlock = NULL; // Ext2 file system super block
|
||||
PEXT2_GROUP_DESC Ext2GroupDescriptors = NULL; // Ext2 file system group descriptors
|
||||
|
||||
UCHAR Ext2DriveNumber = 0; // Ext2 file system drive number
|
||||
ULONGLONG Ext2VolumeStartSector = 0; // Ext2 file system starting sector
|
||||
ULONG Ext2BlockSizeInBytes = 0; // Block size in bytes
|
||||
ULONG Ext2BlockSizeInSectors = 0; // Block size in sectors
|
||||
ULONG Ext2FragmentSizeInBytes = 0; // Fragment size in bytes
|
||||
ULONG Ext2FragmentSizeInSectors = 0; // Fragment size in sectors
|
||||
ULONG Ext2GroupCount = 0; // Number of groups in this file system
|
||||
ULONG Ext2InodesPerBlock = 0; // Number of inodes in one block
|
||||
ULONG Ext2GroupDescPerBlock = 0; // Number of group descriptors in one block
|
||||
U8 Ext2DriveNumber = 0; // Ext2 file system drive number
|
||||
U64 Ext2VolumeStartSector = 0; // Ext2 file system starting sector
|
||||
U32 Ext2BlockSizeInBytes = 0; // Block size in bytes
|
||||
U32 Ext2BlockSizeInSectors = 0; // Block size in sectors
|
||||
U32 Ext2FragmentSizeInBytes = 0; // Fragment size in bytes
|
||||
U32 Ext2FragmentSizeInSectors = 0; // Fragment size in sectors
|
||||
U32 Ext2GroupCount = 0; // Number of groups in this file system
|
||||
U32 Ext2InodesPerBlock = 0; // Number of inodes in one block
|
||||
U32 Ext2GroupDescPerBlock = 0; // Number of group descriptors in one block
|
||||
|
||||
BOOL Ext2OpenVolume(UCHAR DriveNumber, ULONGLONG VolumeStartSector)
|
||||
BOOL Ext2OpenVolume(U8 DriveNumber, U64 VolumeStartSector)
|
||||
{
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "Ext2OpenVolume() DriveNumber = 0x%x VolumeStartSector = %d\n", DriveNumber, VolumeStartSector));
|
||||
@@ -87,13 +87,13 @@ BOOL Ext2OpenVolume(UCHAR DriveNumber, ULONGLONG VolumeStartSector)
|
||||
* Tries to open the file 'name' and returns true or false
|
||||
* for success and failure respectively
|
||||
*/
|
||||
FILE* Ext2OpenFile(PCHAR FileName)
|
||||
FILE* Ext2OpenFile(PUCHAR FileName)
|
||||
{
|
||||
EXT2_FILE_INFO TempExt2FileInfo;
|
||||
PEXT2_FILE_INFO FileHandle;
|
||||
CHAR SymLinkPath[EXT3_NAME_LEN];
|
||||
CHAR FullPath[EXT3_NAME_LEN * 2];
|
||||
ULONG Index;
|
||||
UCHAR SymLinkPath[EXT3_NAME_LEN];
|
||||
UCHAR FullPath[EXT3_NAME_LEN * 2];
|
||||
U32 Index;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "Ext2OpenFile() FileName = %s\n", FileName));
|
||||
|
||||
@@ -190,13 +190,13 @@ FILE* Ext2OpenFile(PCHAR FileName)
|
||||
* with info describing the file, etc. returns true
|
||||
* if the file exists or false otherwise
|
||||
*/
|
||||
BOOL Ext2LookupFile(PCHAR FileName, PEXT2_FILE_INFO Ext2FileInfoPointer)
|
||||
BOOL Ext2LookupFile(PUCHAR FileName, PEXT2_FILE_INFO Ext2FileInfoPointer)
|
||||
{
|
||||
int i;
|
||||
ULONG NumberOfPathParts;
|
||||
CHAR PathPart[261];
|
||||
U32 NumberOfPathParts;
|
||||
UCHAR PathPart[261];
|
||||
PVOID DirectoryBuffer;
|
||||
ULONG DirectoryInode = EXT3_ROOT_INO;
|
||||
U32 DirectoryInode = EXT3_ROOT_INO;
|
||||
EXT2_INODE InodeData;
|
||||
EXT2_DIR_ENTRY DirectoryEntry;
|
||||
|
||||
@@ -238,7 +238,7 @@ BOOL Ext2LookupFile(PCHAR FileName, PEXT2_FILE_INFO Ext2FileInfoPointer)
|
||||
//
|
||||
// Search for file name in directory
|
||||
//
|
||||
if (!Ext2SearchDirectoryBufferForFile(DirectoryBuffer, (ULONG)Ext2GetInodeFileSize(&InodeData), PathPart, &DirectoryEntry))
|
||||
if (!Ext2SearchDirectoryBufferForFile(DirectoryBuffer, (U32)Ext2GetInodeFileSize(&InodeData), PathPart, &DirectoryEntry))
|
||||
{
|
||||
MmFreeMemory(DirectoryBuffer);
|
||||
return FALSE;
|
||||
@@ -289,9 +289,9 @@ BOOL Ext2LookupFile(PCHAR FileName, PEXT2_FILE_INFO Ext2FileInfoPointer)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL Ext2SearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectorySize, PCHAR FileName, PEXT2_DIR_ENTRY DirectoryEntry)
|
||||
BOOL Ext2SearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectorySize, PUCHAR FileName, PEXT2_DIR_ENTRY DirectoryEntry)
|
||||
{
|
||||
ULONG CurrentOffset;
|
||||
U32 CurrentOffset;
|
||||
PEXT2_DIR_ENTRY CurrentDirectoryEntry;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "Ext2SearchDirectoryBufferForFile() DirectoryBuffer = 0x%x DirectorySize = %d FileName = %s\n", DirectoryBuffer, DirectorySize, FileName));
|
||||
@@ -345,16 +345,16 @@ BOOL Ext2SearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectorySize
|
||||
* Reads BytesToRead from open file and
|
||||
* returns the number of bytes read in BytesRead
|
||||
*/
|
||||
BOOL Ext2ReadFile(FILE *FileHandle, ULONGLONG BytesToRead, ULONGLONG* BytesRead, PVOID Buffer)
|
||||
BOOL Ext2ReadFile(FILE *FileHandle, U64 BytesToRead, U64* BytesRead, PVOID Buffer)
|
||||
{
|
||||
PEXT2_FILE_INFO Ext2FileInfo = (PEXT2_FILE_INFO)FileHandle;
|
||||
ULONG BlockNumber;
|
||||
ULONG BlockNumberIndex;
|
||||
ULONG OffsetInBlock;
|
||||
ULONG LengthInBlock;
|
||||
ULONG NumberOfBlocks;
|
||||
U32 BlockNumber;
|
||||
U32 BlockNumberIndex;
|
||||
U32 OffsetInBlock;
|
||||
U32 LengthInBlock;
|
||||
U32 NumberOfBlocks;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "Ext2ReadFile() BytesToRead = %d Buffer = 0x%x\n", (ULONG)BytesToRead, Buffer));
|
||||
DbgPrint((DPRINT_FILESYSTEM, "Ext2ReadFile() BytesToRead = %d Buffer = 0x%x\n", (U32)BytesToRead, Buffer));
|
||||
|
||||
if (BytesRead != NULL)
|
||||
{
|
||||
@@ -529,7 +529,7 @@ BOOL Ext2ReadFile(FILE *FileHandle, ULONGLONG BytesToRead, ULONGLONG* BytesRead,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ULONGLONG Ext2GetFileSize(FILE *FileHandle)
|
||||
U64 Ext2GetFileSize(FILE *FileHandle)
|
||||
{
|
||||
PEXT2_FILE_INFO Ext2FileHandle = (PEXT2_FILE_INFO)FileHandle;
|
||||
|
||||
@@ -538,7 +538,7 @@ ULONGLONG Ext2GetFileSize(FILE *FileHandle)
|
||||
return Ext2FileHandle->FileSize;
|
||||
}
|
||||
|
||||
VOID Ext2SetFilePointer(FILE *FileHandle, ULONGLONG NewFilePointer)
|
||||
VOID Ext2SetFilePointer(FILE *FileHandle, U64 NewFilePointer)
|
||||
{
|
||||
PEXT2_FILE_INFO Ext2FileHandle = (PEXT2_FILE_INFO)FileHandle;
|
||||
|
||||
@@ -547,7 +547,7 @@ VOID Ext2SetFilePointer(FILE *FileHandle, ULONGLONG NewFilePointer)
|
||||
Ext2FileHandle->FilePointer = NewFilePointer;
|
||||
}
|
||||
|
||||
ULONGLONG Ext2GetFilePointer(FILE *FileHandle)
|
||||
U64 Ext2GetFilePointer(FILE *FileHandle)
|
||||
{
|
||||
PEXT2_FILE_INFO Ext2FileHandle = (PEXT2_FILE_INFO)FileHandle;
|
||||
|
||||
@@ -556,7 +556,7 @@ ULONGLONG Ext2GetFilePointer(FILE *FileHandle)
|
||||
return Ext2FileHandle->FilePointer;
|
||||
}
|
||||
|
||||
BOOL Ext2ReadVolumeSectors(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONGLONG SectorCount, PVOID Buffer)
|
||||
BOOL Ext2ReadVolumeSectors(U8 DriveNumber, U64 SectorNumber, U64 SectorCount, PVOID Buffer)
|
||||
{
|
||||
//GEOMETRY DiskGeometry;
|
||||
//BOOL ReturnValue;
|
||||
@@ -734,8 +734,8 @@ BOOL Ext2ReadSuperBlock(VOID)
|
||||
|
||||
BOOL Ext2ReadGroupDescriptors(VOID)
|
||||
{
|
||||
ULONG GroupDescBlockCount;
|
||||
ULONG CurrentGroupDescBlock;
|
||||
U32 GroupDescBlockCount;
|
||||
U32 CurrentGroupDescBlock;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "Ext2ReadGroupDescriptors()\n"));
|
||||
|
||||
@@ -778,7 +778,7 @@ BOOL Ext2ReadGroupDescriptors(VOID)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL Ext2ReadDirectory(ULONG Inode, PVOID* DirectoryBuffer, PEXT2_INODE InodePointer)
|
||||
BOOL Ext2ReadDirectory(U32 Inode, PVOID* DirectoryBuffer, PEXT2_INODE InodePointer)
|
||||
{
|
||||
EXT2_FILE_INFO DirectoryFileInfo;
|
||||
|
||||
@@ -837,9 +837,9 @@ BOOL Ext2ReadDirectory(ULONG Inode, PVOID* DirectoryBuffer, PEXT2_INODE InodePoi
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL Ext2ReadBlock(ULONG BlockNumber, PVOID Buffer)
|
||||
BOOL Ext2ReadBlock(U32 BlockNumber, PVOID Buffer)
|
||||
{
|
||||
CHAR ErrorString[80];
|
||||
UCHAR ErrorString[80];
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "Ext2ReadBlock() BlockNumber = %d Buffer = 0x%x\n", BlockNumber, Buffer));
|
||||
|
||||
@@ -861,14 +861,14 @@ BOOL Ext2ReadBlock(ULONG BlockNumber, PVOID Buffer)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return Ext2ReadVolumeSectors(Ext2DriveNumber, (ULONGLONG)BlockNumber * Ext2BlockSizeInSectors, Ext2BlockSizeInSectors, Buffer);
|
||||
return Ext2ReadVolumeSectors(Ext2DriveNumber, (U64)BlockNumber * Ext2BlockSizeInSectors, Ext2BlockSizeInSectors, Buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Ext2ReadPartialBlock()
|
||||
* Reads part of a block into memory
|
||||
*/
|
||||
BOOL Ext2ReadPartialBlock(ULONG BlockNumber, ULONG StartingOffset, ULONG Length, PVOID Buffer)
|
||||
BOOL Ext2ReadPartialBlock(U32 BlockNumber, U32 StartingOffset, U32 Length, PVOID Buffer)
|
||||
{
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "Ext2ReadPartialBlock() BlockNumber = %d StartingOffset = %d Length = %d Buffer = 0x%x\n", BlockNumber, StartingOffset, Length, Buffer));
|
||||
@@ -883,37 +883,37 @@ BOOL Ext2ReadPartialBlock(ULONG BlockNumber, ULONG StartingOffset, ULONG Length,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ULONG Ext2GetGroupDescBlockNumber(ULONG Group)
|
||||
U32 Ext2GetGroupDescBlockNumber(U32 Group)
|
||||
{
|
||||
return (((Group * sizeof(EXT2_GROUP_DESC)) / Ext2GroupDescPerBlock) + Ext2SuperBlock->s_first_data_block + 1);
|
||||
}
|
||||
|
||||
ULONG Ext2GetGroupDescOffsetInBlock(ULONG Group)
|
||||
U32 Ext2GetGroupDescOffsetInBlock(U32 Group)
|
||||
{
|
||||
return ((Group * sizeof(EXT2_GROUP_DESC)) % Ext2GroupDescPerBlock);
|
||||
}
|
||||
|
||||
ULONG Ext2GetInodeGroupNumber(ULONG Inode)
|
||||
U32 Ext2GetInodeGroupNumber(U32 Inode)
|
||||
{
|
||||
return ((Inode - 1) / Ext2SuperBlock->s_inodes_per_group);
|
||||
}
|
||||
|
||||
ULONG Ext2GetInodeBlockNumber(ULONG Inode)
|
||||
U32 Ext2GetInodeBlockNumber(U32 Inode)
|
||||
{
|
||||
return (((Inode - 1) % Ext2SuperBlock->s_inodes_per_group) / Ext2InodesPerBlock);
|
||||
}
|
||||
|
||||
ULONG Ext2GetInodeOffsetInBlock(ULONG Inode)
|
||||
U32 Ext2GetInodeOffsetInBlock(U32 Inode)
|
||||
{
|
||||
return (((Inode - 1) % Ext2SuperBlock->s_inodes_per_group) % Ext2InodesPerBlock);
|
||||
}
|
||||
|
||||
BOOL Ext2ReadInode(ULONG Inode, PEXT2_INODE InodeBuffer)
|
||||
BOOL Ext2ReadInode(U32 Inode, PEXT2_INODE InodeBuffer)
|
||||
{
|
||||
ULONG InodeGroupNumber;
|
||||
ULONG InodeBlockNumber;
|
||||
ULONG InodeOffsetInBlock;
|
||||
CHAR ErrorString[80];
|
||||
U32 InodeGroupNumber;
|
||||
U32 InodeBlockNumber;
|
||||
U32 InodeOffsetInBlock;
|
||||
UCHAR ErrorString[80];
|
||||
EXT2_GROUP_DESC GroupDescriptor;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "Ext2ReadInode() Inode = %d\n", Inode));
|
||||
@@ -978,7 +978,7 @@ BOOL Ext2ReadInode(ULONG Inode, PEXT2_INODE InodeBuffer)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL Ext2ReadGroupDescriptor(ULONG Group, PEXT2_GROUP_DESC GroupBuffer)
|
||||
BOOL Ext2ReadGroupDescriptor(U32 Group, PEXT2_GROUP_DESC GroupBuffer)
|
||||
{
|
||||
DbgPrint((DPRINT_FILESYSTEM, "Ext2ReadGroupDescriptor()\n"));
|
||||
|
||||
@@ -1002,13 +1002,13 @@ BOOL Ext2ReadGroupDescriptor(ULONG Group, PEXT2_GROUP_DESC GroupBuffer)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ULONG* Ext2ReadBlockPointerList(PEXT2_INODE Inode)
|
||||
U32* Ext2ReadBlockPointerList(PEXT2_INODE Inode)
|
||||
{
|
||||
ULONGLONG FileSize;
|
||||
ULONG BlockCount;
|
||||
ULONG* BlockList;
|
||||
ULONG CurrentBlockInList;
|
||||
ULONG CurrentBlock;
|
||||
U64 FileSize;
|
||||
U32 BlockCount;
|
||||
U32* BlockList;
|
||||
U32 CurrentBlockInList;
|
||||
U32 CurrentBlock;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "Ext2ReadBlockPointerList()\n"));
|
||||
|
||||
@@ -1023,13 +1023,13 @@ ULONG* Ext2ReadBlockPointerList(PEXT2_INODE Inode)
|
||||
BlockCount = (FileSize / Ext2BlockSizeInBytes);
|
||||
|
||||
// Allocate the memory for the block list
|
||||
BlockList = MmAllocateMemory(BlockCount * sizeof(ULONG));
|
||||
BlockList = MmAllocateMemory(BlockCount * sizeof(U32));
|
||||
if (BlockList == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RtlZeroMemory(BlockList, BlockCount * sizeof(ULONG));
|
||||
RtlZeroMemory(BlockList, BlockCount * sizeof(U32));
|
||||
CurrentBlockInList = 0;
|
||||
|
||||
// Copy the direct block pointers
|
||||
@@ -1072,27 +1072,27 @@ ULONG* Ext2ReadBlockPointerList(PEXT2_INODE Inode)
|
||||
return BlockList;
|
||||
}
|
||||
|
||||
ULONGLONG Ext2GetInodeFileSize(PEXT2_INODE Inode)
|
||||
U64 Ext2GetInodeFileSize(PEXT2_INODE Inode)
|
||||
{
|
||||
if ((Inode->i_mode & EXT2_S_IFMT) == EXT2_S_IFDIR)
|
||||
{
|
||||
return (ULONGLONG)(Inode->i_size);
|
||||
return (U64)(Inode->i_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((ULONGLONG)(Inode->i_size) | ((ULONGLONG)(Inode->i_dir_acl) << 32));
|
||||
return ((U64)(Inode->i_size) | ((U64)(Inode->i_dir_acl) << 32));
|
||||
}
|
||||
}
|
||||
|
||||
BOOL Ext2CopyIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList, ULONG BlockCount, ULONG IndirectBlock)
|
||||
BOOL Ext2CopyIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList, U32 BlockCount, U32 IndirectBlock)
|
||||
{
|
||||
ULONG* BlockBuffer = (ULONG*)FILESYSBUFFER;
|
||||
ULONG CurrentBlock;
|
||||
ULONG BlockPointersPerBlock;
|
||||
U32* BlockBuffer = (U32*)FILESYSBUFFER;
|
||||
U32 CurrentBlock;
|
||||
U32 BlockPointersPerBlock;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "Ext2CopyIndirectBlockPointers() BlockCount = %d\n", BlockCount));
|
||||
|
||||
BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(ULONG);
|
||||
BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(U32);
|
||||
|
||||
if (!Ext2ReadBlock(IndirectBlock, BlockBuffer))
|
||||
{
|
||||
@@ -1108,17 +1108,17 @@ BOOL Ext2CopyIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL Ext2CopyDoubleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList, ULONG BlockCount, ULONG DoubleIndirectBlock)
|
||||
BOOL Ext2CopyDoubleIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList, U32 BlockCount, U32 DoubleIndirectBlock)
|
||||
{
|
||||
ULONG* BlockBuffer;
|
||||
ULONG CurrentBlock;
|
||||
ULONG BlockPointersPerBlock;
|
||||
U32* BlockBuffer;
|
||||
U32 CurrentBlock;
|
||||
U32 BlockPointersPerBlock;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "Ext2CopyDoubleIndirectBlockPointers() BlockCount = %d\n", BlockCount));
|
||||
|
||||
BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(ULONG);
|
||||
BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(U32);
|
||||
|
||||
BlockBuffer = (ULONG*)MmAllocateMemory(Ext2BlockSizeInBytes);
|
||||
BlockBuffer = (U32*)MmAllocateMemory(Ext2BlockSizeInBytes);
|
||||
if (BlockBuffer == NULL)
|
||||
{
|
||||
return FALSE;
|
||||
@@ -1143,17 +1143,17 @@ BOOL Ext2CopyDoubleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockIn
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL Ext2CopyTripleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList, ULONG BlockCount, ULONG TripleIndirectBlock)
|
||||
BOOL Ext2CopyTripleIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList, U32 BlockCount, U32 TripleIndirectBlock)
|
||||
{
|
||||
ULONG* BlockBuffer;
|
||||
ULONG CurrentBlock;
|
||||
ULONG BlockPointersPerBlock;
|
||||
U32* BlockBuffer;
|
||||
U32 CurrentBlock;
|
||||
U32 BlockPointersPerBlock;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "Ext2CopyTripleIndirectBlockPointers() BlockCount = %d\n", BlockCount));
|
||||
|
||||
BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(ULONG);
|
||||
BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(U32);
|
||||
|
||||
BlockBuffer = (ULONG*)MmAllocateMemory(Ext2BlockSizeInBytes);
|
||||
BlockBuffer = (U32*)MmAllocateMemory(Ext2BlockSizeInBytes);
|
||||
if (BlockBuffer == NULL)
|
||||
{
|
||||
return FALSE;
|
697
freeldr/freeldr/fs/ext2.h
Normal file
697
freeldr/freeldr/fs/ext2.h
Normal file
@@ -0,0 +1,697 @@
|
||||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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 __EXT2_H
|
||||
#define __EXT2_H
|
||||
|
||||
|
||||
/*
|
||||
* linux/include/linux/ext3_fs.h
|
||||
*
|
||||
* Copyright (C) 1992, 1993, 1994, 1995
|
||||
* Remy Card (card@masi.ibp.fr)
|
||||
* Laboratoire MASI - Institut Blaise Pascal
|
||||
* Universite Pierre et Marie Curie (Paris VI)
|
||||
*
|
||||
* from
|
||||
*
|
||||
* linux/include/linux/minix_fs.h
|
||||
*
|
||||
* Copyright (C) 1991, 1992 Linus Torvalds
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_EXT3_FS_H
|
||||
#define _LINUX_EXT3_FS_H
|
||||
|
||||
//#include <linux/types.h>
|
||||
|
||||
/*
|
||||
* The second extended filesystem constants/structures
|
||||
*/
|
||||
|
||||
/*
|
||||
* Define EXT3FS_DEBUG to produce debug messages
|
||||
*/
|
||||
#undef EXT3FS_DEBUG
|
||||
|
||||
/*
|
||||
* Define EXT3_PREALLOCATE to preallocate data blocks for expanding files
|
||||
*/
|
||||
#undef EXT3_PREALLOCATE /* @@@ Fix this! */
|
||||
#define EXT3_DEFAULT_PREALLOC_BLOCKS 8
|
||||
|
||||
/*
|
||||
* The second extended file system version
|
||||
*/
|
||||
#define EXT3FS_DATE "10 Jan 2002"
|
||||
#define EXT3FS_VERSION "2.4-0.9.17"
|
||||
|
||||
/*
|
||||
* Debug code
|
||||
*/
|
||||
#ifdef EXT3FS_DEBUG
|
||||
#define ext3_debug(f, a...) \
|
||||
do { \
|
||||
printk (KERN_DEBUG "EXT3-fs DEBUG (%s, %d): %s:", \
|
||||
__FILE__, __LINE__, __FUNCTION__); \
|
||||
printk (KERN_DEBUG f, ## a); \
|
||||
} while (0)
|
||||
#else
|
||||
#define ext3_debug(f, a...) do {} while (0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Special inodes numbers
|
||||
*/
|
||||
#define EXT3_BAD_INO 1 /* Bad blocks inode */
|
||||
#define EXT3_ROOT_INO 2 /* Root inode */
|
||||
#define EXT3_ACL_IDX_INO 3 /* ACL inode */
|
||||
#define EXT3_ACL_DATA_INO 4 /* ACL inode */
|
||||
#define EXT3_BOOT_LOADER_INO 5 /* Boot loader inode */
|
||||
#define EXT3_UNDEL_DIR_INO 6 /* Undelete directory inode */
|
||||
#define EXT3_RESIZE_INO 7 /* Reserved group descriptors inode */
|
||||
#define EXT3_JOURNAL_INO 8 /* Journal inode */
|
||||
|
||||
/* First non-reserved inode for old ext3 filesystems */
|
||||
#define EXT3_GOOD_OLD_FIRST_INO 11
|
||||
|
||||
/*
|
||||
* The second extended file system magic number
|
||||
*/
|
||||
#define EXT3_SUPER_MAGIC 0xEF53
|
||||
|
||||
/*
|
||||
* Maximal count of links to a file
|
||||
*/
|
||||
#define EXT3_LINK_MAX 32000
|
||||
|
||||
/*
|
||||
* Macro-instructions used to manage several block sizes
|
||||
*/
|
||||
#define EXT3_MIN_BLOCK_SIZE 1024
|
||||
#define EXT3_MAX_BLOCK_SIZE 4096
|
||||
#define EXT3_MIN_BLOCK_LOG_SIZE 10
|
||||
#ifdef __KERNEL__
|
||||
# define EXT3_BLOCK_SIZE(s) ((s)->s_blocksize)
|
||||
#else
|
||||
# define EXT3_BLOCK_SIZE(s) (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size)
|
||||
#endif
|
||||
#define EXT3_ACLE_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_acl_entry))
|
||||
#define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (__u32))
|
||||
#ifdef __KERNEL__
|
||||
# define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
|
||||
#else
|
||||
# define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
|
||||
#endif
|
||||
#ifdef __KERNEL__
|
||||
#define EXT3_ADDR_PER_BLOCK_BITS(s) ((s)->u.ext3_sb.s_addr_per_block_bits)
|
||||
#define EXT3_INODE_SIZE(s) ((s)->u.ext3_sb.s_inode_size)
|
||||
#define EXT3_FIRST_INO(s) ((s)->u.ext3_sb.s_first_ino)
|
||||
#else
|
||||
#define EXT3_INODE_SIZE(s) (((s)->s_rev_level == EXT3_GOOD_OLD_REV) ? \
|
||||
EXT3_GOOD_OLD_INODE_SIZE : \
|
||||
(s)->s_inode_size)
|
||||
#define EXT3_FIRST_INO(s) (((s)->s_rev_level == EXT3_GOOD_OLD_REV) ? \
|
||||
EXT3_GOOD_OLD_FIRST_INO : \
|
||||
(s)->s_first_ino)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macro-instructions used to manage fragments
|
||||
*/
|
||||
#define EXT3_MIN_FRAG_SIZE 1024
|
||||
#define EXT3_MAX_FRAG_SIZE 4096
|
||||
#define EXT3_MIN_FRAG_LOG_SIZE 10
|
||||
#ifdef __KERNEL__
|
||||
# define EXT3_FRAG_SIZE(s) ((s)->u.ext3_sb.s_frag_size)
|
||||
# define EXT3_FRAGS_PER_BLOCK(s) ((s)->u.ext3_sb.s_frags_per_block)
|
||||
#else
|
||||
# define EXT3_FRAG_SIZE(s) (EXT3_MIN_FRAG_SIZE << (s)->s_log_frag_size)
|
||||
# define EXT3_FRAGS_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / EXT3_FRAG_SIZE(s))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ACL structures
|
||||
*/
|
||||
struct ext3_acl_header /* Header of Access Control Lists */
|
||||
{
|
||||
__u32 aclh_size;
|
||||
__u32 aclh_file_count;
|
||||
__u32 aclh_acle_count;
|
||||
__u32 aclh_first_acle;
|
||||
};
|
||||
|
||||
struct ext3_acl_entry /* Access Control List Entry */
|
||||
{
|
||||
__u32 acle_size;
|
||||
__u16 acle_perms; /* Access permissions */
|
||||
__u16 acle_type; /* Type of entry */
|
||||
__u16 acle_tag; /* User or group identity */
|
||||
__u16 acle_pad1;
|
||||
__u32 acle_next; /* Pointer on next entry for the */
|
||||
/* same inode or on next free entry */
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure of a blocks group descriptor
|
||||
*/
|
||||
struct ext3_group_desc
|
||||
{
|
||||
__u32 bg_block_bitmap; /* Blocks bitmap block */
|
||||
__u32 bg_inode_bitmap; /* Inodes bitmap block */
|
||||
__u32 bg_inode_table; /* Inodes table block */
|
||||
__u16 bg_free_blocks_count; /* Free blocks count */
|
||||
__u16 bg_free_inodes_count; /* Free inodes count */
|
||||
__u16 bg_used_dirs_count; /* Directories count */
|
||||
__u16 bg_pad;
|
||||
__u32 bg_reserved[3];
|
||||
};
|
||||
|
||||
/*
|
||||
* Macro-instructions used to manage group descriptors
|
||||
*/
|
||||
#ifdef __KERNEL__
|
||||
# define EXT3_BLOCKS_PER_GROUP(s) ((s)->u.ext3_sb.s_blocks_per_group)
|
||||
# define EXT3_DESC_PER_BLOCK(s) ((s)->u.ext3_sb.s_desc_per_block)
|
||||
# define EXT3_INODES_PER_GROUP(s) ((s)->u.ext3_sb.s_inodes_per_group)
|
||||
# define EXT3_DESC_PER_BLOCK_BITS(s) ((s)->u.ext3_sb.s_desc_per_block_bits)
|
||||
#else
|
||||
# define EXT3_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
|
||||
# define EXT3_DESC_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_group_desc))
|
||||
# define EXT3_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Constants relative to the data blocks
|
||||
*/
|
||||
#define EXT3_NDIR_BLOCKS 12
|
||||
#define EXT3_IND_BLOCK EXT3_NDIR_BLOCKS
|
||||
#define EXT3_DIND_BLOCK (EXT3_IND_BLOCK + 1)
|
||||
#define EXT3_TIND_BLOCK (EXT3_DIND_BLOCK + 1)
|
||||
#define EXT3_N_BLOCKS (EXT3_TIND_BLOCK + 1)
|
||||
|
||||
/*
|
||||
* Inode flags
|
||||
*/
|
||||
#define EXT3_SECRM_FL 0x00000001 /* Secure deletion */
|
||||
#define EXT3_UNRM_FL 0x00000002 /* Undelete */
|
||||
#define EXT3_COMPR_FL 0x00000004 /* Compress file */
|
||||
#define EXT3_SYNC_FL 0x00000008 /* Synchronous updates */
|
||||
#define EXT3_IMMUTABLE_FL 0x00000010 /* Immutable file */
|
||||
#define EXT3_APPEND_FL 0x00000020 /* writes to file may only append */
|
||||
#define EXT3_NODUMP_FL 0x00000040 /* do not dump file */
|
||||
#define EXT3_NOATIME_FL 0x00000080 /* do not update atime */
|
||||
/* Reserved for compression usage... */
|
||||
#define EXT3_DIRTY_FL 0x00000100
|
||||
#define EXT3_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
|
||||
#define EXT3_NOCOMPR_FL 0x00000400 /* Don't compress */
|
||||
#define EXT3_ECOMPR_FL 0x00000800 /* Compression error */
|
||||
/* End compression flags --- maybe not all used */
|
||||
#define EXT3_INDEX_FL 0x00001000 /* hash-indexed directory */
|
||||
#define EXT3_IMAGIC_FL 0x00002000 /* AFS directory */
|
||||
#define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
|
||||
#define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
|
||||
|
||||
#define EXT3_FL_USER_VISIBLE 0x00005FFF /* User visible flags */
|
||||
#define EXT3_FL_USER_MODIFIABLE 0x000000FF /* User modifiable flags */
|
||||
|
||||
/*
|
||||
* Inode dynamic state flags
|
||||
*/
|
||||
#define EXT3_STATE_JDATA 0x00000001 /* journaled data exists */
|
||||
#define EXT3_STATE_NEW 0x00000002 /* inode is newly created */
|
||||
|
||||
/*
|
||||
* ioctl commands
|
||||
*/
|
||||
#define EXT3_IOC_GETFLAGS _IOR('f', 1, long)
|
||||
#define EXT3_IOC_SETFLAGS _IOW('f', 2, long)
|
||||
#define EXT3_IOC_GETVERSION _IOR('f', 3, long)
|
||||
#define EXT3_IOC_SETVERSION _IOW('f', 4, long)
|
||||
#define EXT3_IOC_GETVERSION_OLD _IOR('v', 1, long)
|
||||
#define EXT3_IOC_SETVERSION_OLD _IOW('v', 2, long)
|
||||
#ifdef CONFIG_JBD_DEBUG
|
||||
#define EXT3_IOC_WAIT_FOR_READONLY _IOR('f', 99, long)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Structure of an inode on the disk
|
||||
*/
|
||||
struct ext3_inode {
|
||||
__u16 i_mode; /* File mode */
|
||||
__u16 i_uid; /* Low 16 bits of Owner Uid */
|
||||
__u32 i_size; /* Size in bytes */
|
||||
__u32 i_atime; /* Access time */
|
||||
__u32 i_ctime; /* Creation time */
|
||||
__u32 i_mtime; /* Modification time */
|
||||
__u32 i_dtime; /* Deletion Time */
|
||||
__u16 i_gid; /* Low 16 bits of Group Id */
|
||||
__u16 i_links_count; /* Links count */
|
||||
__u32 i_blocks; /* Blocks count */
|
||||
__u32 i_flags; /* File flags */
|
||||
union {
|
||||
struct {
|
||||
__u32 l_i_reserved1;
|
||||
} linux1;
|
||||
struct {
|
||||
__u32 h_i_translator;
|
||||
} hurd1;
|
||||
struct {
|
||||
__u32 m_i_reserved1;
|
||||
} masix1;
|
||||
} osd1; /* OS dependent 1 */
|
||||
__u32 i_block[EXT3_N_BLOCKS];/* Pointers to blocks */
|
||||
__u32 i_generation; /* File version (for NFS) */
|
||||
__u32 i_file_acl; /* File ACL */
|
||||
__u32 i_dir_acl; /* Directory ACL */
|
||||
__u32 i_faddr; /* Fragment address */
|
||||
union {
|
||||
struct {
|
||||
__u8 l_i_frag; /* Fragment number */
|
||||
__u8 l_i_fsize; /* Fragment size */
|
||||
__u16 i_pad1;
|
||||
__u16 l_i_uid_high; /* these 2 fields */
|
||||
__u16 l_i_gid_high; /* were reserved2[0] */
|
||||
__u32 l_i_reserved2;
|
||||
} linux2;
|
||||
struct {
|
||||
__u8 h_i_frag; /* Fragment number */
|
||||
__u8 h_i_fsize; /* Fragment size */
|
||||
__u16 h_i_mode_high;
|
||||
__u16 h_i_uid_high;
|
||||
__u16 h_i_gid_high;
|
||||
__u32 h_i_author;
|
||||
} hurd2;
|
||||
struct {
|
||||
__u8 m_i_frag; /* Fragment number */
|
||||
__u8 m_i_fsize; /* Fragment size */
|
||||
__u16 m_pad1;
|
||||
__u32 m_i_reserved2[2];
|
||||
} masix2;
|
||||
} osd2; /* OS dependent 2 */
|
||||
};
|
||||
|
||||
#define i_size_high i_dir_acl
|
||||
|
||||
#if defined(__KERNEL__) || defined(__linux__)
|
||||
#define i_reserved1 osd1.linux1.l_i_reserved1
|
||||
#define i_frag osd2.linux2.l_i_frag
|
||||
#define i_fsize osd2.linux2.l_i_fsize
|
||||
#define i_uid_low i_uid
|
||||
#define i_gid_low i_gid
|
||||
#define i_uid_high osd2.linux2.l_i_uid_high
|
||||
#define i_gid_high osd2.linux2.l_i_gid_high
|
||||
#define i_reserved2 osd2.linux2.l_i_reserved2
|
||||
|
||||
#elif defined(__GNU__)
|
||||
|
||||
#define i_translator osd1.hurd1.h_i_translator
|
||||
#define i_frag osd2.hurd2.h_i_frag;
|
||||
#define i_fsize osd2.hurd2.h_i_fsize;
|
||||
#define i_uid_high osd2.hurd2.h_i_uid_high
|
||||
#define i_gid_high osd2.hurd2.h_i_gid_high
|
||||
#define i_author osd2.hurd2.h_i_author
|
||||
|
||||
#elif defined(__masix__)
|
||||
|
||||
#define i_reserved1 osd1.masix1.m_i_reserved1
|
||||
#define i_frag osd2.masix2.m_i_frag
|
||||
#define i_fsize osd2.masix2.m_i_fsize
|
||||
#define i_reserved2 osd2.masix2.m_i_reserved2
|
||||
|
||||
#endif /* defined(__KERNEL__) || defined(__linux__) */
|
||||
|
||||
/*
|
||||
* File system states
|
||||
*/
|
||||
#define EXT3_VALID_FS 0x0001 /* Unmounted cleanly */
|
||||
#define EXT3_ERROR_FS 0x0002 /* Errors detected */
|
||||
#define EXT3_ORPHAN_FS 0x0004 /* Orphans being recovered */
|
||||
|
||||
/*
|
||||
* Mount flags
|
||||
*/
|
||||
#define EXT3_MOUNT_CHECK 0x0001 /* Do mount-time checks */
|
||||
#define EXT3_MOUNT_GRPID 0x0004 /* Create files with directory's group */
|
||||
#define EXT3_MOUNT_DEBUG 0x0008 /* Some debugging messages */
|
||||
#define EXT3_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */
|
||||
#define EXT3_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */
|
||||
#define EXT3_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
|
||||
#define EXT3_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */
|
||||
#define EXT3_MOUNT_NOLOAD 0x0100 /* Don't use existing journal*/
|
||||
#define EXT3_MOUNT_ABORT 0x0200 /* Fatal error detected */
|
||||
#define EXT3_MOUNT_DATA_FLAGS 0x0C00 /* Mode for data writes: */
|
||||
#define EXT3_MOUNT_JOURNAL_DATA 0x0400 /* Write data to journal */
|
||||
#define EXT3_MOUNT_ORDERED_DATA 0x0800 /* Flush data before commit */
|
||||
#define EXT3_MOUNT_WRITEBACK_DATA 0x0C00 /* No data ordering */
|
||||
#define EXT3_MOUNT_UPDATE_JOURNAL 0x1000 /* Update the journal format */
|
||||
#define EXT3_MOUNT_NO_UID32 0x2000 /* Disable 32-bit UIDs */
|
||||
|
||||
/* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
|
||||
#ifndef _LINUX_EXT2_FS_H
|
||||
#define clear_opt(o, opt) o &= ~EXT3_MOUNT_##opt
|
||||
#define set_opt(o, opt) o |= EXT3_MOUNT_##opt
|
||||
#define test_opt(sb, opt) ((sb)->u.ext3_sb.s_mount_opt & \
|
||||
EXT3_MOUNT_##opt)
|
||||
#else
|
||||
#define EXT2_MOUNT_NOLOAD EXT3_MOUNT_NOLOAD
|
||||
#define EXT2_MOUNT_ABORT EXT3_MOUNT_ABORT
|
||||
#endif
|
||||
|
||||
#define ext3_set_bit ext2_set_bit
|
||||
#define ext3_clear_bit ext2_clear_bit
|
||||
#define ext3_test_bit ext2_test_bit
|
||||
#define ext3_find_first_zero_bit ext2_find_first_zero_bit
|
||||
#define ext3_find_next_zero_bit ext2_find_next_zero_bit
|
||||
|
||||
/*
|
||||
* Maximal mount counts between two filesystem checks
|
||||
*/
|
||||
#define EXT3_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
|
||||
#define EXT3_DFL_CHECKINTERVAL 0 /* Don't use interval check */
|
||||
|
||||
/*
|
||||
* Behaviour when detecting errors
|
||||
*/
|
||||
#define EXT3_ERRORS_CONTINUE 1 /* Continue execution */
|
||||
#define EXT3_ERRORS_RO 2 /* Remount fs read-only */
|
||||
#define EXT3_ERRORS_PANIC 3 /* Panic */
|
||||
#define EXT3_ERRORS_DEFAULT EXT3_ERRORS_CONTINUE
|
||||
|
||||
/*
|
||||
* Structure of the super block
|
||||
*/
|
||||
struct ext3_super_block {
|
||||
/*00*/ __u32 s_inodes_count; /* Inodes count */
|
||||
__u32 s_blocks_count; /* Blocks count */
|
||||
__u32 s_r_blocks_count; /* Reserved blocks count */
|
||||
__u32 s_free_blocks_count; /* Free blocks count */
|
||||
/*10*/ __u32 s_free_inodes_count; /* Free inodes count */
|
||||
__u32 s_first_data_block; /* First Data Block */
|
||||
__u32 s_log_block_size; /* Block size */
|
||||
__s32 s_log_frag_size; /* Fragment size */
|
||||
/*20*/ __u32 s_blocks_per_group; /* # Blocks per group */
|
||||
__u32 s_frags_per_group; /* # Fragments per group */
|
||||
__u32 s_inodes_per_group; /* # Inodes per group */
|
||||
__u32 s_mtime; /* Mount time */
|
||||
/*30*/ __u32 s_wtime; /* Write time */
|
||||
__u16 s_mnt_count; /* Mount count */
|
||||
__s16 s_max_mnt_count; /* Maximal mount count */
|
||||
__u16 s_magic; /* Magic signature */
|
||||
__u16 s_state; /* File system state */
|
||||
__u16 s_errors; /* Behaviour when detecting errors */
|
||||
__u16 s_minor_rev_level; /* minor revision level */
|
||||
/*40*/ __u32 s_lastcheck; /* time of last check */
|
||||
__u32 s_checkinterval; /* max. time between checks */
|
||||
__u32 s_creator_os; /* OS */
|
||||
__u32 s_rev_level; /* Revision level */
|
||||
/*50*/ __u16 s_def_resuid; /* Default uid for reserved blocks */
|
||||
__u16 s_def_resgid; /* Default gid for reserved blocks */
|
||||
/*
|
||||
* These fields are for EXT3_DYNAMIC_REV superblocks only.
|
||||
*
|
||||
* Note: the difference between the compatible feature set and
|
||||
* the incompatible feature set is that if there is a bit set
|
||||
* in the incompatible feature set that the kernel doesn't
|
||||
* know about, it should refuse to mount the filesystem.
|
||||
*
|
||||
* e2fsck's requirements are more strict; if it doesn't know
|
||||
* about a feature in either the compatible or incompatible
|
||||
* feature set, it must abort and not try to meddle with
|
||||
* things it doesn't understand...
|
||||
*/
|
||||
__u32 s_first_ino; /* First non-reserved inode */
|
||||
__u16 s_inode_size; /* size of inode structure */
|
||||
__u16 s_block_group_nr; /* block group # of this superblock */
|
||||
__u32 s_feature_compat; /* compatible feature set */
|
||||
/*60*/ __u32 s_feature_incompat; /* incompatible feature set */
|
||||
__u32 s_feature_ro_compat; /* readonly-compatible feature set */
|
||||
/*68*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */
|
||||
/*78*/ char s_volume_name[16]; /* volume name */
|
||||
/*88*/ char s_last_mounted[64]; /* directory where last mounted */
|
||||
/*C8*/ __u32 s_algorithm_usage_bitmap; /* For compression */
|
||||
/*
|
||||
* Performance hints. Directory preallocation should only
|
||||
* happen if the EXT3_FEATURE_COMPAT_DIR_PREALLOC flag is on.
|
||||
*/
|
||||
__u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
|
||||
__u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
|
||||
__u16 s_padding1;
|
||||
/*
|
||||
* Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set.
|
||||
*/
|
||||
/*D0*/ __u8 s_journal_uuid[16]; /* uuid of journal superblock */
|
||||
/*E0*/ __u32 s_journal_inum; /* inode number of journal file */
|
||||
__u32 s_journal_dev; /* device number of journal file */
|
||||
__u32 s_last_orphan; /* start of list of inodes to delete */
|
||||
|
||||
/*EC*/ __u32 s_reserved[197]; /* Padding to the end of the block */
|
||||
};
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#define EXT3_SB(sb) (&((sb)->u.ext3_sb))
|
||||
#define EXT3_I(inode) (&((inode)->u.ext3_i))
|
||||
#else
|
||||
/* Assume that user mode programs are passing in an ext3fs superblock, not
|
||||
* a kernel struct super_block. This will allow us to call the feature-test
|
||||
* macros from user land. */
|
||||
#define EXT3_SB(sb) (sb)
|
||||
#endif
|
||||
|
||||
#define NEXT_ORPHAN(inode) (inode)->u.ext3_i.i_dtime
|
||||
|
||||
/*
|
||||
* Codes for operating systems
|
||||
*/
|
||||
#define EXT3_OS_LINUX 0
|
||||
#define EXT3_OS_HURD 1
|
||||
#define EXT3_OS_MASIX 2
|
||||
#define EXT3_OS_FREEBSD 3
|
||||
#define EXT3_OS_LITES 4
|
||||
|
||||
/*
|
||||
* Revision levels
|
||||
*/
|
||||
#define EXT3_GOOD_OLD_REV 0 /* The good old (original) format */
|
||||
#define EXT3_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
|
||||
|
||||
#define EXT3_CURRENT_REV EXT3_GOOD_OLD_REV
|
||||
#define EXT3_MAX_SUPP_REV EXT3_DYNAMIC_REV
|
||||
|
||||
#define EXT3_GOOD_OLD_INODE_SIZE 128
|
||||
|
||||
/*
|
||||
* Feature set definitions
|
||||
*/
|
||||
|
||||
#define EXT3_HAS_COMPAT_FEATURE(sb,mask) \
|
||||
( EXT3_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) )
|
||||
#define EXT3_HAS_RO_COMPAT_FEATURE(sb,mask) \
|
||||
( EXT3_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) )
|
||||
#define EXT3_HAS_INCOMPAT_FEATURE(sb,mask) \
|
||||
( EXT3_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) )
|
||||
#define EXT3_SET_COMPAT_FEATURE(sb,mask) \
|
||||
EXT3_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask)
|
||||
#define EXT3_SET_RO_COMPAT_FEATURE(sb,mask) \
|
||||
EXT3_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask)
|
||||
#define EXT3_SET_INCOMPAT_FEATURE(sb,mask) \
|
||||
EXT3_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask)
|
||||
#define EXT3_CLEAR_COMPAT_FEATURE(sb,mask) \
|
||||
EXT3_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask)
|
||||
#define EXT3_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
|
||||
EXT3_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask)
|
||||
#define EXT3_CLEAR_INCOMPAT_FEATURE(sb,mask) \
|
||||
EXT3_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask)
|
||||
|
||||
#define EXT3_FEATURE_COMPAT_DIR_PREALLOC 0x0001
|
||||
#define EXT3_FEATURE_COMPAT_IMAGIC_INODES 0x0002
|
||||
#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
|
||||
#define EXT3_FEATURE_COMPAT_EXT_ATTR 0x0008
|
||||
#define EXT3_FEATURE_COMPAT_RESIZE_INODE 0x0010
|
||||
#define EXT3_FEATURE_COMPAT_DIR_INDEX 0x0020
|
||||
|
||||
#define EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
|
||||
#define EXT3_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
|
||||
#define EXT3_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
|
||||
|
||||
#define EXT3_FEATURE_INCOMPAT_COMPRESSION 0x0001
|
||||
#define EXT3_FEATURE_INCOMPAT_FILETYPE 0x0002
|
||||
#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
|
||||
#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
|
||||
|
||||
#define EXT3_FEATURE_COMPAT_SUPP 0
|
||||
/*#define EXT3_FEATURE_INCOMPAT_SUPP (EXT3_FEATURE_INCOMPAT_FILETYPE| \
|
||||
EXT3_FEATURE_INCOMPAT_RECOVER)*/
|
||||
#define EXT3_FEATURE_INCOMPAT_SUPP (EXT3_FEATURE_INCOMPAT_FILETYPE)
|
||||
#define EXT3_FEATURE_RO_COMPAT_SUPP (EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \
|
||||
EXT3_FEATURE_RO_COMPAT_LARGE_FILE| \
|
||||
EXT3_FEATURE_RO_COMPAT_BTREE_DIR)
|
||||
|
||||
/*
|
||||
* Default values for user and/or group using reserved blocks
|
||||
*/
|
||||
#define EXT3_DEF_RESUID 0
|
||||
#define EXT3_DEF_RESGID 0
|
||||
|
||||
/*
|
||||
* Structure of a directory entry
|
||||
*/
|
||||
#define EXT3_NAME_LEN 255
|
||||
|
||||
struct ext3_dir_entry {
|
||||
__u32 inode; /* Inode number */
|
||||
__u16 rec_len; /* Directory entry length */
|
||||
__u16 name_len; /* Name length */
|
||||
char name[EXT3_NAME_LEN]; /* File name */
|
||||
};
|
||||
|
||||
/*
|
||||
* The new version of the directory entry. Since EXT3 structures are
|
||||
* stored in intel byte order, and the name_len field could never be
|
||||
* bigger than 255 chars, it's safe to reclaim the extra byte for the
|
||||
* file_type field.
|
||||
*/
|
||||
struct ext3_dir_entry_2 {
|
||||
__u32 inode; /* Inode number */
|
||||
__u16 rec_len; /* Directory entry length */
|
||||
__u8 name_len; /* Name length */
|
||||
__u8 file_type;
|
||||
char name[EXT3_NAME_LEN]; /* File name */
|
||||
};
|
||||
|
||||
/*
|
||||
* Ext3 directory file types. Only the low 3 bits are used. The
|
||||
* other bits are reserved for now.
|
||||
*/
|
||||
#define EXT3_FT_UNKNOWN 0
|
||||
#define EXT3_FT_REG_FILE 1
|
||||
#define EXT3_FT_DIR 2
|
||||
#define EXT3_FT_CHRDEV 3
|
||||
#define EXT3_FT_BLKDEV 4
|
||||
#define EXT3_FT_FIFO 5
|
||||
#define EXT3_FT_SOCK 6
|
||||
#define EXT3_FT_SYMLINK 7
|
||||
|
||||
#define EXT3_FT_MAX 8
|
||||
|
||||
/*
|
||||
* EXT3_DIR_PAD defines the directory entries boundaries
|
||||
*
|
||||
* NOTE: It must be a multiple of 4
|
||||
*/
|
||||
#define EXT3_DIR_PAD 4
|
||||
#define EXT3_DIR_ROUND (EXT3_DIR_PAD - 1)
|
||||
#define EXT3_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT3_DIR_ROUND) & \
|
||||
~EXT3_DIR_ROUND)
|
||||
|
||||
#ifdef __KERNEL__
|
||||
/*
|
||||
* Describe an inode's exact location on disk and in memory
|
||||
*/
|
||||
struct ext3_iloc
|
||||
{
|
||||
struct buffer_head *bh;
|
||||
struct ext3_inode *raw_inode;
|
||||
unsigned long block_group;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#endif /* _LINUX_EXT3_FS_H */
|
||||
|
||||
|
||||
|
||||
typedef struct ext3_super_block EXT2_SUPER_BLOCK, *PEXT2_SUPER_BLOCK;
|
||||
typedef struct ext3_inode EXT2_INODE, *PEXT2_INODE;
|
||||
typedef struct ext3_group_desc EXT2_GROUP_DESC, *PEXT2_GROUP_DESC;
|
||||
typedef struct ext3_dir_entry_2 EXT2_DIR_ENTRY, *PEXT2_DIR_ENTRY;
|
||||
|
||||
// EXT2_INODE::i_mode values
|
||||
#define EXT2_S_IRWXO 0x0007 // Other mask
|
||||
#define EXT2_S_IXOTH 0x0001 // ---------x execute
|
||||
#define EXT2_S_IWOTH 0x0002 // --------w- write
|
||||
#define EXT2_S_IROTH 0x0004 // -------r-- read
|
||||
|
||||
#define EXT2_S_IRWXG 0x0038 // Group mask
|
||||
#define EXT2_S_IXGRP 0x0008 // ------x--- execute
|
||||
#define EXT2_S_IWGRP 0x0010 // -----w---- write
|
||||
#define EXT2_S_IRGRP 0x0020 // ----r----- read
|
||||
|
||||
#define EXT2_S_IRWXU 0x01C0 // User mask
|
||||
#define EXT2_S_IXUSR 0x0040 // ---x------ execute
|
||||
#define EXT2_S_IWUSR 0x0080 // --w------- write
|
||||
#define EXT2_S_IRUSR 0x0100 // -r-------- read
|
||||
|
||||
#define EXT2_S_ISVTX 0x0200 // Sticky bit
|
||||
#define EXT2_S_ISGID 0x0400 // SGID
|
||||
#define EXT2_S_ISUID 0x0800 // SUID
|
||||
|
||||
#define EXT2_S_IFMT 0xF000 // Format mask
|
||||
#define EXT2_S_IFIFO 0x1000 // FIFO buffer
|
||||
#define EXT2_S_IFCHR 0x2000 // Character device
|
||||
#define EXT2_S_IFDIR 0x4000 // Directory
|
||||
#define EXT2_S_IFBLK 0x6000 // Block device
|
||||
#define EXT2_S_IFREG 0x8000 // Regular file
|
||||
#define EXT2_S_IFLNK 0xA000 // Symbolic link
|
||||
#define EXT2_S_IFSOCK 0xC000 // Socket
|
||||
|
||||
#define FAST_SYMLINK_MAX_NAME_SIZE (EXT3_N_BLOCKS * sizeof(U32)) /* 60 bytes */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U64 FileSize; // File size
|
||||
U64 FilePointer; // File pointer
|
||||
U32* FileBlockList; // File block list
|
||||
U8 DriveNumber; // Drive number of open file
|
||||
EXT2_INODE Inode; // File's inode
|
||||
} EXT2_FILE_INFO, * PEXT2_FILE_INFO;
|
||||
|
||||
|
||||
|
||||
BOOL Ext2OpenVolume(U8 DriveNumber, U64 VolumeStartSector);
|
||||
FILE* Ext2OpenFile(PUCHAR FileName);
|
||||
BOOL Ext2LookupFile(PUCHAR FileName, PEXT2_FILE_INFO Ext2FileInfoPointer);
|
||||
BOOL Ext2SearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectorySize, PUCHAR FileName, PEXT2_DIR_ENTRY DirectoryEntry);
|
||||
BOOL Ext2ReadFile(FILE *FileHandle, U64 BytesToRead, U64* BytesRead, PVOID Buffer);
|
||||
U64 Ext2GetFileSize(FILE *FileHandle);
|
||||
VOID Ext2SetFilePointer(FILE *FileHandle, U64 NewFilePointer);
|
||||
U64 Ext2GetFilePointer(FILE *FileHandle);
|
||||
BOOL Ext2ReadVolumeSectors(U8 DriveNumber, U64 SectorNumber, U64 SectorCount, PVOID Buffer);
|
||||
|
||||
BOOL Ext2ReadSuperBlock(VOID);
|
||||
BOOL Ext2ReadGroupDescriptors(VOID);
|
||||
BOOL Ext2ReadDirectory(U32 Inode, PVOID* DirectoryBuffer, PEXT2_INODE InodePointer);
|
||||
BOOL Ext2ReadBlock(U32 BlockNumber, PVOID Buffer);
|
||||
BOOL Ext2ReadPartialBlock(U32 BlockNumber, U32 StartingOffset, U32 Length, PVOID Buffer);
|
||||
U32 Ext2GetGroupDescBlockNumber(U32 Group);
|
||||
U32 Ext2GetGroupDescOffsetInBlock(U32 Group);
|
||||
U32 Ext2GetInodeGroupNumber(U32 Inode);
|
||||
U32 Ext2GetInodeBlockNumber(U32 Inode);
|
||||
U32 Ext2GetInodeOffsetInBlock(U32 Inode);
|
||||
BOOL Ext2ReadInode(U32 Inode, PEXT2_INODE InodeBuffer);
|
||||
BOOL Ext2ReadGroupDescriptor(U32 Group, PEXT2_GROUP_DESC GroupBuffer);
|
||||
U32* Ext2ReadBlockPointerList(PEXT2_INODE Inode);
|
||||
U64 Ext2GetInodeFileSize(PEXT2_INODE Inode);
|
||||
BOOL Ext2CopyIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList, U32 BlockCount, U32 IndirectBlock);
|
||||
BOOL Ext2CopyDoubleIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList, U32 BlockCount, U32 DoubleIndirectBlock);
|
||||
BOOL Ext2CopyTripleIndirectBlockPointers(U32* BlockList, U32* CurrentBlockInList, U32 BlockCount, U32 TripleIndirectBlock);
|
||||
|
||||
#endif // #defined __EXT2_H
|
@@ -29,25 +29,25 @@
|
||||
#include <cache.h>
|
||||
#include <machine.h>
|
||||
|
||||
ULONG BytesPerSector; /* Number of bytes per sector */
|
||||
ULONG SectorsPerCluster; /* Number of sectors per cluster */
|
||||
ULONG FatVolumeStartSector; /* Absolute starting sector of the partition */
|
||||
ULONG FatSectorStart; /* Starting sector of 1st FAT table */
|
||||
ULONG ActiveFatSectorStart; /* Starting sector of active FAT table */
|
||||
ULONG NumberOfFats; /* Number of FAT tables */
|
||||
ULONG SectorsPerFat; /* Sectors per FAT table */
|
||||
ULONG RootDirSectorStart; /* Starting sector of the root directory (non-fat32) */
|
||||
ULONG RootDirSectors; /* Number of sectors of the root directory (non-fat32) */
|
||||
ULONG RootDirStartCluster; /* Starting cluster number of the root directory (fat32 only) */
|
||||
ULONG DataSectorStart; /* Starting sector of the data area */
|
||||
U32 BytesPerSector; /* Number of bytes per sector */
|
||||
U32 SectorsPerCluster; /* Number of sectors per cluster */
|
||||
U32 FatVolumeStartSector; /* Absolute starting sector of the partition */
|
||||
U32 FatSectorStart; /* Starting sector of 1st FAT table */
|
||||
U32 ActiveFatSectorStart; /* Starting sector of active FAT table */
|
||||
U32 NumberOfFats; /* Number of FAT tables */
|
||||
U32 SectorsPerFat; /* Sectors per FAT table */
|
||||
U32 RootDirSectorStart; /* Starting sector of the root directory (non-fat32) */
|
||||
U32 RootDirSectors; /* Number of sectors of the root directory (non-fat32) */
|
||||
U32 RootDirStartCluster; /* Starting cluster number of the root directory (fat32 only) */
|
||||
U32 DataSectorStart; /* Starting sector of the data area */
|
||||
|
||||
ULONG FatType = 0; /* FAT12, FAT16, FAT32, FATX16 or FATX32 */
|
||||
ULONG FatDriveNumber = 0;
|
||||
U32 FatType = 0; /* FAT12, FAT16, FAT32, FATX16 or FATX32 */
|
||||
U32 FatDriveNumber = 0;
|
||||
|
||||
BOOL FatOpenVolume(ULONG DriveNumber, ULONG VolumeStartSector, ULONG PartitionSectorCount)
|
||||
BOOL FatOpenVolume(U32 DriveNumber, U32 VolumeStartSector, U32 PartitionSectorCount)
|
||||
{
|
||||
char ErrMsg[80];
|
||||
ULONG FatSize;
|
||||
U32 FatSize;
|
||||
PFAT_BOOTSECTOR FatVolumeBootSector;
|
||||
PFAT32_BOOTSECTOR Fat32VolumeBootSector;
|
||||
PFATX_BOOTSECTOR FatXVolumeBootSector;
|
||||
@@ -288,13 +288,13 @@ BOOL FatOpenVolume(ULONG DriveNumber, ULONG VolumeStartSector, ULONG PartitionSe
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ULONG FatDetermineFatType(PFAT_BOOTSECTOR FatBootSector, ULONG PartitionSectorCount)
|
||||
U32 FatDetermineFatType(PFAT_BOOTSECTOR FatBootSector, U32 PartitionSectorCount)
|
||||
{
|
||||
ULONG RootDirSectors;
|
||||
ULONG DataSectorCount;
|
||||
ULONG SectorsPerFat;
|
||||
ULONG TotalSectors;
|
||||
ULONG CountOfClusters;
|
||||
U32 RootDirSectors;
|
||||
U32 DataSectorCount;
|
||||
U32 SectorsPerFat;
|
||||
U32 TotalSectors;
|
||||
U32 CountOfClusters;
|
||||
PFAT32_BOOTSECTOR Fat32BootSector = (PFAT32_BOOTSECTOR)FatBootSector;
|
||||
PFATX_BOOTSECTOR FatXBootSector = (PFATX_BOOTSECTOR)FatBootSector;
|
||||
|
||||
@@ -343,7 +343,7 @@ ULONG FatDetermineFatType(PFAT_BOOTSECTOR FatBootSector, ULONG PartitionSectorCo
|
||||
}
|
||||
}
|
||||
|
||||
PVOID FatBufferDirectory(ULONG DirectoryStartCluster, ULONG *DirectorySize, BOOL RootDirectory)
|
||||
PVOID FatBufferDirectory(U32 DirectoryStartCluster, U32 *DirectorySize, BOOL RootDirectory)
|
||||
{
|
||||
PVOID DirectoryBuffer;
|
||||
|
||||
@@ -405,22 +405,22 @@ PVOID FatBufferDirectory(ULONG DirectoryStartCluster, ULONG *DirectorySize, BOOL
|
||||
return DirectoryBuffer;
|
||||
}
|
||||
|
||||
BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectorySize, PCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer)
|
||||
BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectorySize, PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer)
|
||||
{
|
||||
ULONG EntryCount;
|
||||
ULONG CurrentEntry;
|
||||
U32 EntryCount;
|
||||
U32 CurrentEntry;
|
||||
PDIRENTRY DirEntry;
|
||||
PLFN_DIRENTRY LfnDirEntry;
|
||||
CHAR LfnNameBuffer[265];
|
||||
CHAR ShortNameBuffer[20];
|
||||
ULONG StartCluster;
|
||||
UCHAR LfnNameBuffer[265];
|
||||
UCHAR ShortNameBuffer[20];
|
||||
U32 StartCluster;
|
||||
|
||||
EntryCount = DirectorySize / sizeof(DIRENTRY);
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "FatSearchDirectoryBufferForFile() DirectoryBuffer = 0x%x EntryCount = %d FileName = %s\n", DirectoryBuffer, EntryCount, FileName));
|
||||
|
||||
memset(ShortNameBuffer, 0, 13 * sizeof(CHAR));
|
||||
memset(LfnNameBuffer, 0, 261 * sizeof(CHAR));
|
||||
memset(ShortNameBuffer, 0, 13 * sizeof(UCHAR));
|
||||
memset(LfnNameBuffer, 0, 261 * sizeof(UCHAR));
|
||||
|
||||
DirEntry = (PDIRENTRY) DirectoryBuffer;
|
||||
for (CurrentEntry=0; CurrentEntry<EntryCount; CurrentEntry++, DirEntry++)
|
||||
@@ -436,7 +436,7 @@ BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectorySize,
|
||||
// entries after this one are unused. If this is the
|
||||
// last entry then we didn't find the file in this directory.
|
||||
//
|
||||
if (DirEntry->FileName[0] == '\0')
|
||||
if (DirEntry->FileName[0] == 0x00)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -444,10 +444,10 @@ BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectorySize,
|
||||
//
|
||||
// Check if this is a deleted entry or not
|
||||
//
|
||||
if (DirEntry->FileName[0] == '\xE5')
|
||||
if (DirEntry->FileName[0] == 0xE5)
|
||||
{
|
||||
memset(ShortNameBuffer, 0, 13 * sizeof(CHAR));
|
||||
memset(LfnNameBuffer, 0, 261 * sizeof(CHAR));
|
||||
memset(ShortNameBuffer, 0, 13 * sizeof(UCHAR));
|
||||
memset(LfnNameBuffer, 0, 261 * sizeof(UCHAR));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -590,7 +590,7 @@ BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectorySize,
|
||||
//
|
||||
// Get the cluster chain
|
||||
//
|
||||
StartCluster = ((ULONG)DirEntry->ClusterHigh << 16) + DirEntry->ClusterLow;
|
||||
StartCluster = ((U32)DirEntry->ClusterHigh << 16) + DirEntry->ClusterLow;
|
||||
DbgPrint((DPRINT_FILESYSTEM, "StartCluster = 0x%x\n", StartCluster));
|
||||
FatFileInfoPointer->FileFatChain = FatGetClusterChainArray(StartCluster);
|
||||
|
||||
@@ -616,12 +616,12 @@ BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectorySize,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL FatXSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectorySize, PCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer)
|
||||
BOOL FatXSearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectorySize, PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer)
|
||||
{
|
||||
ULONG EntryCount;
|
||||
ULONG CurrentEntry;
|
||||
U32 EntryCount;
|
||||
U32 CurrentEntry;
|
||||
PFATX_DIRENTRY DirEntry;
|
||||
ULONG FileNameLen;
|
||||
U32 FileNameLen;
|
||||
|
||||
EntryCount = DirectorySize / sizeof(FATX_DIRENTRY);
|
||||
|
||||
@@ -687,14 +687,14 @@ BOOL FatXSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectorySize
|
||||
* with info describing the file, etc. returns true
|
||||
* if the file exists or false otherwise
|
||||
*/
|
||||
BOOL FatLookupFile(PCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer)
|
||||
BOOL FatLookupFile(PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer)
|
||||
{
|
||||
int i;
|
||||
ULONG NumberOfPathParts;
|
||||
CHAR PathPart[261];
|
||||
U32 NumberOfPathParts;
|
||||
UCHAR PathPart[261];
|
||||
PVOID DirectoryBuffer;
|
||||
ULONG DirectoryStartCluster = 0;
|
||||
ULONG DirectorySize;
|
||||
U32 DirectoryStartCluster = 0;
|
||||
U32 DirectorySize;
|
||||
FAT_FILE_INFO FatFileInfo;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "FatLookupFile() FileName = %s\n", FileName));
|
||||
@@ -777,9 +777,9 @@ BOOL FatLookupFile(PCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer)
|
||||
* is in the form of "FILE EXT" and puts it in Buffer
|
||||
* in the form of "file.ext"
|
||||
*/
|
||||
void FatParseShortFileName(PCHAR Buffer, PDIRENTRY DirEntry)
|
||||
void FatParseShortFileName(PUCHAR Buffer, PDIRENTRY DirEntry)
|
||||
{
|
||||
ULONG Idx;
|
||||
U32 Idx;
|
||||
|
||||
Idx = 0;
|
||||
RtlZeroMemory(Buffer, 13);
|
||||
@@ -824,9 +824,9 @@ void FatParseShortFileName(PCHAR Buffer, PDIRENTRY DirEntry)
|
||||
* FatGetFatEntry()
|
||||
* returns the Fat entry for a given cluster number
|
||||
*/
|
||||
BOOL FatGetFatEntry(ULONG Cluster, ULONG* ClusterPointer)
|
||||
BOOL FatGetFatEntry(U32 Cluster, U32* ClusterPointer)
|
||||
{
|
||||
ULONG fat = 0;
|
||||
U32 fat = 0;
|
||||
int FatOffset;
|
||||
int ThisFatSecNum;
|
||||
int ThisFatEntOffset;
|
||||
@@ -860,7 +860,7 @@ BOOL FatGetFatEntry(ULONG Cluster, ULONG* ClusterPointer)
|
||||
}
|
||||
}
|
||||
|
||||
fat = *((USHORT *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset));
|
||||
fat = *((U16 *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset));
|
||||
if (Cluster & 0x0001)
|
||||
fat = fat >> 4; /* Cluster number is ODD */
|
||||
else
|
||||
@@ -880,7 +880,7 @@ BOOL FatGetFatEntry(ULONG Cluster, ULONG* ClusterPointer)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fat = *((USHORT *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset));
|
||||
fat = *((U16 *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset));
|
||||
|
||||
break;
|
||||
|
||||
@@ -897,7 +897,7 @@ BOOL FatGetFatEntry(ULONG Cluster, ULONG* ClusterPointer)
|
||||
}
|
||||
|
||||
// Get the fat entry
|
||||
fat = (*((ULONG *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset))) & 0x0FFFFFFF;
|
||||
fat = (*((U32 *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset))) & 0x0FFFFFFF;
|
||||
|
||||
break;
|
||||
|
||||
@@ -915,7 +915,7 @@ BOOL FatGetFatEntry(ULONG Cluster, ULONG* ClusterPointer)
|
||||
* Tries to open the file 'name' and returns true or false
|
||||
* for success and failure respectively
|
||||
*/
|
||||
FILE* FatOpenFile(PCHAR FileName)
|
||||
FILE* FatOpenFile(PUCHAR FileName)
|
||||
{
|
||||
FAT_FILE_INFO TempFatFileInfo;
|
||||
PFAT_FILE_INFO FileHandle;
|
||||
@@ -939,9 +939,9 @@ FILE* FatOpenFile(PCHAR FileName)
|
||||
return (FILE*)FileHandle;
|
||||
}
|
||||
|
||||
ULONG FatCountClustersInChain(ULONG StartCluster)
|
||||
U32 FatCountClustersInChain(U32 StartCluster)
|
||||
{
|
||||
ULONG ClusterCount = 0;
|
||||
U32 ClusterCount = 0;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "FatCountClustersInChain() StartCluster = %d\n", StartCluster));
|
||||
|
||||
@@ -976,17 +976,17 @@ ULONG FatCountClustersInChain(ULONG StartCluster)
|
||||
return ClusterCount;
|
||||
}
|
||||
|
||||
ULONG* FatGetClusterChainArray(ULONG StartCluster)
|
||||
U32* FatGetClusterChainArray(U32 StartCluster)
|
||||
{
|
||||
ULONG ClusterCount;
|
||||
ULONG ArraySize;
|
||||
ULONG* ArrayPointer;
|
||||
ULONG Idx;
|
||||
U32 ClusterCount;
|
||||
U32 ArraySize;
|
||||
U32* ArrayPointer;
|
||||
U32 Idx;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "FatGetClusterChainArray() StartCluster = %d\n", StartCluster));
|
||||
|
||||
ClusterCount = FatCountClustersInChain(StartCluster) + 1; // Lets get the 0x0ffffff8 on the end of the array
|
||||
ArraySize = ClusterCount * sizeof(ULONG);
|
||||
ArraySize = ClusterCount * sizeof(U32);
|
||||
|
||||
//
|
||||
// Allocate array memory
|
||||
@@ -1036,9 +1036,9 @@ ULONG* FatGetClusterChainArray(ULONG StartCluster)
|
||||
* FatReadCluster()
|
||||
* Reads the specified cluster into memory
|
||||
*/
|
||||
BOOL FatReadCluster(ULONG ClusterNumber, PVOID Buffer)
|
||||
BOOL FatReadCluster(U32 ClusterNumber, PVOID Buffer)
|
||||
{
|
||||
ULONG ClusterStartSector;
|
||||
U32 ClusterStartSector;
|
||||
|
||||
ClusterStartSector = ((ClusterNumber - 2) * SectorsPerCluster) + DataSectorStart;
|
||||
|
||||
@@ -1058,9 +1058,9 @@ BOOL FatReadCluster(ULONG ClusterNumber, PVOID Buffer)
|
||||
* FatReadClusterChain()
|
||||
* Reads the specified clusters into memory
|
||||
*/
|
||||
BOOL FatReadClusterChain(ULONG StartClusterNumber, ULONG NumberOfClusters, PVOID Buffer)
|
||||
BOOL FatReadClusterChain(U32 StartClusterNumber, U32 NumberOfClusters, PVOID Buffer)
|
||||
{
|
||||
ULONG ClusterStartSector;
|
||||
U32 ClusterStartSector;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "FatReadClusterChain() StartClusterNumber = %d NumberOfClusters = %d Buffer = 0x%x\n", StartClusterNumber, NumberOfClusters, Buffer));
|
||||
|
||||
@@ -1119,9 +1119,9 @@ BOOL FatReadClusterChain(ULONG StartClusterNumber, ULONG NumberOfClusters, PVOID
|
||||
* FatReadPartialCluster()
|
||||
* Reads part of a cluster into memory
|
||||
*/
|
||||
BOOL FatReadPartialCluster(ULONG ClusterNumber, ULONG StartingOffset, ULONG Length, PVOID Buffer)
|
||||
BOOL FatReadPartialCluster(U32 ClusterNumber, U32 StartingOffset, U32 Length, PVOID Buffer)
|
||||
{
|
||||
ULONG ClusterStartSector;
|
||||
U32 ClusterStartSector;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "FatReadPartialCluster() ClusterNumber = %d StartingOffset = %d Length = %d Buffer = 0x%x\n", ClusterNumber, StartingOffset, Length, Buffer));
|
||||
|
||||
@@ -1142,14 +1142,14 @@ BOOL FatReadPartialCluster(ULONG ClusterNumber, ULONG StartingOffset, ULONG Leng
|
||||
* Reads BytesToRead from open file and
|
||||
* returns the number of bytes read in BytesRead
|
||||
*/
|
||||
BOOL FatReadFile(FILE *FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer)
|
||||
BOOL FatReadFile(FILE *FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer)
|
||||
{
|
||||
PFAT_FILE_INFO FatFileInfo = (PFAT_FILE_INFO)FileHandle;
|
||||
ULONG ClusterNumber;
|
||||
ULONG OffsetInCluster;
|
||||
ULONG LengthInCluster;
|
||||
ULONG NumberOfClusters;
|
||||
ULONG BytesPerCluster;
|
||||
U32 ClusterNumber;
|
||||
U32 OffsetInCluster;
|
||||
U32 LengthInCluster;
|
||||
U32 NumberOfClusters;
|
||||
U32 BytesPerCluster;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "FatReadFile() BytesToRead = %d Buffer = 0x%x\n", BytesToRead, Buffer));
|
||||
|
||||
@@ -1296,7 +1296,7 @@ BOOL FatReadFile(FILE *FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Bu
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ULONG FatGetFileSize(FILE *FileHandle)
|
||||
U32 FatGetFileSize(FILE *FileHandle)
|
||||
{
|
||||
PFAT_FILE_INFO FatFileHandle = (PFAT_FILE_INFO)FileHandle;
|
||||
|
||||
@@ -1305,7 +1305,7 @@ ULONG FatGetFileSize(FILE *FileHandle)
|
||||
return FatFileHandle->FileSize;
|
||||
}
|
||||
|
||||
VOID FatSetFilePointer(FILE *FileHandle, ULONG NewFilePointer)
|
||||
VOID FatSetFilePointer(FILE *FileHandle, U32 NewFilePointer)
|
||||
{
|
||||
PFAT_FILE_INFO FatFileHandle = (PFAT_FILE_INFO)FileHandle;
|
||||
|
||||
@@ -1314,7 +1314,7 @@ VOID FatSetFilePointer(FILE *FileHandle, ULONG NewFilePointer)
|
||||
FatFileHandle->FilePointer = NewFilePointer;
|
||||
}
|
||||
|
||||
ULONG FatGetFilePointer(FILE *FileHandle)
|
||||
U32 FatGetFilePointer(FILE *FileHandle)
|
||||
{
|
||||
PFAT_FILE_INFO FatFileHandle = (PFAT_FILE_INFO)FileHandle;
|
||||
|
||||
@@ -1323,7 +1323,7 @@ ULONG FatGetFilePointer(FILE *FileHandle)
|
||||
return FatFileHandle->FilePointer;
|
||||
}
|
||||
|
||||
BOOL FatReadVolumeSectors(ULONG DriveNumber, ULONG SectorNumber, ULONG SectorCount, PVOID Buffer)
|
||||
BOOL FatReadVolumeSectors(U32 DriveNumber, U32 SectorNumber, U32 SectorCount, PVOID Buffer)
|
||||
{
|
||||
return CacheReadDiskSectors(DriveNumber, SectorNumber + FatVolumeStartSector, SectorCount, Buffer);
|
||||
}
|
192
freeldr/freeldr/fs/fat.h
Normal file
192
freeldr/freeldr/fs/fat.h
Normal file
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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 __FAT_H
|
||||
#define __FAT_H
|
||||
|
||||
typedef struct _FAT_BOOTSECTOR
|
||||
{
|
||||
U8 JumpBoot[3]; // Jump instruction to boot code
|
||||
U8 OemName[8]; // "MSWIN4.1" for MS formatted volumes
|
||||
U16 BytesPerSector; // Bytes per sector
|
||||
U8 SectorsPerCluster; // Number of sectors in a cluster
|
||||
U16 ReservedSectors; // Reserved sectors, usually 1 (the bootsector)
|
||||
U8 NumberOfFats; // Number of FAT tables
|
||||
U16 RootDirEntries; // Number of root directory entries (fat12/16)
|
||||
U16 TotalSectors; // Number of total sectors on the drive, 16-bit
|
||||
U8 MediaDescriptor; // Media descriptor byte
|
||||
U16 SectorsPerFat; // Sectors per FAT table (fat12/16)
|
||||
U16 SectorsPerTrack; // Number of sectors in a track
|
||||
U16 NumberOfHeads; // Number of heads on the disk
|
||||
U32 HiddenSectors; // Hidden sectors (sectors before the partition start like the partition table)
|
||||
U32 TotalSectorsBig; // This field is the new 32-bit total count of sectors on the volume
|
||||
U8 DriveNumber; // Int 0x13 drive number (e.g. 0x80)
|
||||
U8 Reserved1; // Reserved (used by Windows NT). Code that formats FAT volumes should always set this byte to 0.
|
||||
U8 BootSignature; // Extended boot signature (0x29). This is a signature byte that indicates that the following three fields in the boot sector are present.
|
||||
U32 VolumeSerialNumber; // Volume serial number
|
||||
U8 VolumeLabel[11]; // Volume label. This field matches the 11-byte volume label recorded in the root directory
|
||||
U8 FileSystemType[8]; // One of the strings "FAT12 ", "FAT16 ", or "FAT "
|
||||
|
||||
U8 BootCodeAndData[448]; // The remainder of the boot sector
|
||||
|
||||
U16 BootSectorMagic; // 0xAA55
|
||||
|
||||
} PACKED FAT_BOOTSECTOR, *PFAT_BOOTSECTOR;
|
||||
|
||||
typedef struct _FAT32_BOOTSECTOR
|
||||
{
|
||||
U8 JumpBoot[3]; // Jump instruction to boot code
|
||||
U8 OemName[8]; // "MSWIN4.1" for MS formatted volumes
|
||||
U16 BytesPerSector; // Bytes per sector
|
||||
U8 SectorsPerCluster; // Number of sectors in a cluster
|
||||
U16 ReservedSectors; // Reserved sectors, usually 1 (the bootsector)
|
||||
U8 NumberOfFats; // Number of FAT tables
|
||||
U16 RootDirEntries; // Number of root directory entries (fat12/16)
|
||||
U16 TotalSectors; // Number of total sectors on the drive, 16-bit
|
||||
U8 MediaDescriptor; // Media descriptor byte
|
||||
U16 SectorsPerFat; // Sectors per FAT table (fat12/16)
|
||||
U16 SectorsPerTrack; // Number of sectors in a track
|
||||
U16 NumberOfHeads; // Number of heads on the disk
|
||||
U32 HiddenSectors; // Hidden sectors (sectors before the partition start like the partition table)
|
||||
U32 TotalSectorsBig; // This field is the new 32-bit total count of sectors on the volume
|
||||
U32 SectorsPerFatBig; // This field is the FAT32 32-bit count of sectors occupied by ONE FAT. BPB_FATSz16 must be 0
|
||||
U16 ExtendedFlags; // Extended flags (fat32)
|
||||
U16 FileSystemVersion; // File system version (fat32)
|
||||
U32 RootDirStartCluster; // Starting cluster of the root directory (fat32)
|
||||
U16 FsInfo; // Sector number of FSINFO structure in the reserved area of the FAT32 volume. Usually 1.
|
||||
U16 BackupBootSector; // If non-zero, indicates the sector number in the reserved area of the volume of a copy of the boot record. Usually 6.
|
||||
U8 Reserved[12]; // Reserved for future expansion
|
||||
U8 DriveNumber; // Int 0x13 drive number (e.g. 0x80)
|
||||
U8 Reserved1; // Reserved (used by Windows NT). Code that formats FAT volumes should always set this byte to 0.
|
||||
U8 BootSignature; // Extended boot signature (0x29). This is a signature byte that indicates that the following three fields in the boot sector are present.
|
||||
U32 VolumeSerialNumber; // Volume serial number
|
||||
U8 VolumeLabel[11]; // Volume label. This field matches the 11-byte volume label recorded in the root directory
|
||||
U8 FileSystemType[8]; // Always set to the string "FAT32 "
|
||||
|
||||
U8 BootCodeAndData[420]; // The remainder of the boot sector
|
||||
|
||||
U16 BootSectorMagic; // 0xAA55
|
||||
|
||||
} PACKED FAT32_BOOTSECTOR, *PFAT32_BOOTSECTOR;
|
||||
|
||||
typedef struct _FATX_BOOTSECTOR
|
||||
{
|
||||
U8 FileSystemType[4]; /* String "FATX" */
|
||||
U32 VolumeSerialNumber; /* Volume serial number */
|
||||
U32 SectorsPerCluster; /* Number of sectors in a cluster */
|
||||
U16 NumberOfFats; /* Number of FAT tables */
|
||||
U32 Unknown; /* Always 0? */
|
||||
U8 Unused[494]; /* Actually size should be 4078 (boot block is 4096 bytes) */
|
||||
|
||||
} PACKED FATX_BOOTSECTOR, *PFATX_BOOTSECTOR;
|
||||
|
||||
/*
|
||||
* Structure of MSDOS directory entry
|
||||
*/
|
||||
typedef struct //_DIRENTRY
|
||||
{
|
||||
UCHAR FileName[11]; /* Filename + extension */
|
||||
U8 Attr; /* File attributes */
|
||||
U8 ReservedNT; /* Reserved for use by Windows NT */
|
||||
U8 TimeInTenths; /* Millisecond stamp at file creation */
|
||||
U16 CreateTime; /* Time file was created */
|
||||
U16 CreateDate; /* Date file was created */
|
||||
U16 LastAccessDate; /* Date file was last accessed */
|
||||
U16 ClusterHigh; /* High word of this entry's start cluster */
|
||||
U16 Time; /* Time last modified */
|
||||
U16 Date; /* Date last modified */
|
||||
U16 ClusterLow; /* First cluster number low word */
|
||||
U32 Size; /* File size */
|
||||
} PACKED DIRENTRY, * PDIRENTRY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U8 SequenceNumber; /* Sequence number for slot */
|
||||
WCHAR Name0_4[5]; /* First 5 characters in name */
|
||||
U8 EntryAttributes; /* Attribute byte */
|
||||
U8 Reserved; /* Always 0 */
|
||||
U8 AliasChecksum; /* Checksum for 8.3 alias */
|
||||
WCHAR Name5_10[6]; /* 6 more characters in name */
|
||||
U16 StartCluster; /* Starting cluster number */
|
||||
WCHAR Name11_12[2]; /* Last 2 characters in name */
|
||||
} PACKED LFN_DIRENTRY, * PLFN_DIRENTRY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U8 FileNameSize; /* Size of filename (max 42) */
|
||||
U8 Attr; /* File attributes */
|
||||
UCHAR FileName[42]; /* Filename in ASCII, padded with 0xff (not zero-terminated) */
|
||||
U32 StartCluster; /* Starting cluster number */
|
||||
U32 Size; /* File size */
|
||||
U16 Time; /* Time last modified */
|
||||
U16 Date; /* Date last modified */
|
||||
U16 CreateTime; /* Time file was created */
|
||||
U16 CreateDate; /* Date file was created */
|
||||
U16 LastAccessTime; /* Time file was last accessed */
|
||||
U16 LastAccessDate; /* Date file was last accessed */
|
||||
} PACKED FATX_DIRENTRY, * PFATX_DIRENTRY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U32 FileSize; /* File size */
|
||||
U32 FilePointer; /* File pointer */
|
||||
U32* FileFatChain; /* File fat chain array */
|
||||
U32 DriveNumber;
|
||||
} FAT_FILE_INFO, * PFAT_FILE_INFO;
|
||||
|
||||
|
||||
|
||||
BOOL FatOpenVolume(U32 DriveNumber, U32 VolumeStartSector, U32 PartitionSectorCount);
|
||||
U32 FatDetermineFatType(PFAT_BOOTSECTOR FatBootSector, U32 PartitionSectorCount);
|
||||
PVOID FatBufferDirectory(U32 DirectoryStartCluster, U32* EntryCountPointer, BOOL RootDirectory);
|
||||
BOOL FatSearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 EntryCount, PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer);
|
||||
BOOL FatLookupFile(PUCHAR FileName, PFAT_FILE_INFO FatFileInfoPointer);
|
||||
void FatParseShortFileName(PUCHAR Buffer, PDIRENTRY DirEntry);
|
||||
BOOL FatGetFatEntry(U32 Cluster, U32* ClusterPointer);
|
||||
FILE* FatOpenFile(PUCHAR FileName);
|
||||
U32 FatCountClustersInChain(U32 StartCluster);
|
||||
U32* FatGetClusterChainArray(U32 StartCluster);
|
||||
BOOL FatReadCluster(U32 ClusterNumber, PVOID Buffer);
|
||||
BOOL FatReadClusterChain(U32 StartClusterNumber, U32 NumberOfClusters, PVOID Buffer);
|
||||
BOOL FatReadPartialCluster(U32 ClusterNumber, U32 StartingOffset, U32 Length, PVOID Buffer);
|
||||
BOOL FatReadFile(FILE *FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer);
|
||||
U32 FatGetFileSize(FILE *FileHandle);
|
||||
VOID FatSetFilePointer(FILE *FileHandle, U32 NewFilePointer);
|
||||
U32 FatGetFilePointer(FILE *FileHandle);
|
||||
BOOL FatReadVolumeSectors(U32 DriveNumber, U32 SectorNumber, U32 SectorCount, PVOID Buffer);
|
||||
|
||||
|
||||
#define ATTR_NORMAL 0x00
|
||||
#define ATTR_READONLY 0x01
|
||||
#define ATTR_HIDDEN 0x02
|
||||
#define ATTR_SYSTEM 0x04
|
||||
#define ATTR_VOLUMENAME 0x08
|
||||
#define ATTR_DIRECTORY 0x10
|
||||
#define ATTR_ARCHIVE 0x20
|
||||
#define ATTR_LONG_NAME (ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUMENAME)
|
||||
|
||||
#define FAT12 1
|
||||
#define FAT16 2
|
||||
#define FAT32 3
|
||||
#define FATX16 4
|
||||
#define FATX32 5
|
||||
|
||||
#define ISFATX(FT) ((FT) == FATX16 || (FT) == FATX32)
|
||||
|
||||
#endif // #defined __FAT_H
|
419
freeldr/freeldr/fs/fs.c
Normal file
419
freeldr/freeldr/fs/fs.c
Normal file
@@ -0,0 +1,419 @@
|
||||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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 <fs.h>
|
||||
#include "fat.h"
|
||||
#include "iso.h"
|
||||
#include "ext2.h"
|
||||
#include "ntfs.h"
|
||||
#include "fsrec.h"
|
||||
#include <disk.h>
|
||||
#include <rtl.h>
|
||||
#include <ui.h>
|
||||
#include <arch.h>
|
||||
#include <debug.h>
|
||||
#include <machine.h>
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// DATA
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
U32 FileSystemType = 0; // Type of filesystem on boot device, set by FsOpenVolume()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FUNCTIONS
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VOID FileSystemError(PUCHAR ErrorString)
|
||||
{
|
||||
DbgPrint((DPRINT_FILESYSTEM, "%s\n", ErrorString));
|
||||
|
||||
UiMessageBox(ErrorString);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* BOOL FsOpenVolume(U32 DriveNumber, U32 PartitionNumber);
|
||||
*
|
||||
* This function is called to open a disk volume for file access.
|
||||
* It must be called before any of the file functions will work.
|
||||
* It takes two parameters:
|
||||
*
|
||||
* Drive: The BIOS drive number of the disk to open
|
||||
* Partition: This is zero for floppy drives.
|
||||
* If the disk is a hard disk then this specifies
|
||||
* The partition number to open (1 - 4)
|
||||
* If it is zero then it opens the active (bootable) partition
|
||||
*
|
||||
*/
|
||||
BOOL FsOpenVolume(U32 DriveNumber, U32 PartitionNumber)
|
||||
{
|
||||
PARTITION_TABLE_ENTRY PartitionTableEntry;
|
||||
UCHAR ErrorText[80];
|
||||
U8 VolumeType;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "FsOpenVolume() DriveNumber: 0x%x PartitionNumber: 0x%x\n", DriveNumber, PartitionNumber));
|
||||
|
||||
// Check and see if it is a floppy drive
|
||||
// If so then just assume FAT12 file system type
|
||||
if (DiskIsDriveRemovable(DriveNumber))
|
||||
{
|
||||
DbgPrint((DPRINT_FILESYSTEM, "Drive is a floppy diskette drive. Assuming FAT12 file system.\n"));
|
||||
|
||||
FileSystemType = FS_FAT;
|
||||
return FatOpenVolume(DriveNumber, 0, 0);
|
||||
}
|
||||
|
||||
// Check for ISO9660 file system type
|
||||
if (DriveNumber >= 0x80 && FsRecIsIso9660(DriveNumber))
|
||||
{
|
||||
DbgPrint((DPRINT_FILESYSTEM, "Drive is a cdrom drive. Assuming ISO-9660 file system.\n"));
|
||||
|
||||
FileSystemType = FS_ISO9660;
|
||||
return IsoOpenVolume(DriveNumber);
|
||||
}
|
||||
|
||||
// Set the boot partition
|
||||
BootPartition = PartitionNumber;
|
||||
|
||||
// Get the requested partition entry
|
||||
if (PartitionNumber == 0)
|
||||
{
|
||||
// Partition requested was zero which means the boot partition
|
||||
if (DiskGetActivePartitionEntry(DriveNumber, &PartitionTableEntry) == FALSE)
|
||||
{
|
||||
FileSystemError("No active partition.");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get requested partition
|
||||
if (MachDiskGetPartitionEntry(DriveNumber, PartitionNumber, &PartitionTableEntry) == FALSE)
|
||||
{
|
||||
FileSystemError("Partition not found.");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for valid partition
|
||||
if (PartitionTableEntry.SystemIndicator == PARTITION_ENTRY_UNUSED)
|
||||
{
|
||||
FileSystemError("Invalid partition.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Try to recognize the file system
|
||||
if (!FsRecognizeVolume(DriveNumber, PartitionTableEntry.SectorCountBeforePartition, &VolumeType))
|
||||
{
|
||||
FileSystemError("Unrecognized file system.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//switch (PartitionTableEntry.SystemIndicator)
|
||||
switch (VolumeType)
|
||||
{
|
||||
case PARTITION_FAT_12:
|
||||
case PARTITION_FAT_16:
|
||||
case PARTITION_HUGE:
|
||||
case PARTITION_XINT13:
|
||||
case PARTITION_FAT32:
|
||||
case PARTITION_FAT32_XINT13:
|
||||
FileSystemType = FS_FAT;
|
||||
return FatOpenVolume(DriveNumber, PartitionTableEntry.SectorCountBeforePartition, PartitionTableEntry.PartitionSectorCount);
|
||||
case PARTITION_EXT2:
|
||||
FileSystemType = FS_EXT2;
|
||||
return Ext2OpenVolume(DriveNumber, PartitionTableEntry.SectorCountBeforePartition);
|
||||
case PARTITION_NTFS:
|
||||
FileSystemType = FS_NTFS;
|
||||
return NtfsOpenVolume(DriveNumber, PartitionTableEntry.SectorCountBeforePartition);
|
||||
default:
|
||||
FileSystemType = 0;
|
||||
sprintf(ErrorText, "Unsupported file system. Type: 0x%x", VolumeType);
|
||||
FileSystemError(ErrorText);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
PFILE FsOpenFile(PUCHAR FileName)
|
||||
{
|
||||
PFILE FileHandle = NULL;
|
||||
|
||||
//
|
||||
// Print status message
|
||||
//
|
||||
DbgPrint((DPRINT_FILESYSTEM, "Opening file '%s'...\n", FileName));
|
||||
|
||||
//
|
||||
// Check and see if the first character is '\' or '/' and remove it if so
|
||||
//
|
||||
while ((*FileName == '\\') || (*FileName == '/'))
|
||||
{
|
||||
FileName++;
|
||||
}
|
||||
|
||||
//
|
||||
// Check file system type and pass off to appropriate handler
|
||||
//
|
||||
switch (FileSystemType)
|
||||
{
|
||||
case FS_FAT:
|
||||
FileHandle = FatOpenFile(FileName);
|
||||
break;
|
||||
case FS_ISO9660:
|
||||
FileHandle = IsoOpenFile(FileName);
|
||||
break;
|
||||
case FS_EXT2:
|
||||
FileHandle = Ext2OpenFile(FileName);
|
||||
break;
|
||||
case FS_NTFS:
|
||||
FileHandle = NtfsOpenFile(FileName);
|
||||
break;
|
||||
default:
|
||||
FileSystemError("Error: Unknown filesystem.");
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
//
|
||||
// Check return value
|
||||
//
|
||||
if (FileHandle != NULL)
|
||||
{
|
||||
DbgPrint((DPRINT_FILESYSTEM, "FsOpenFile() succeeded. FileHandle: 0x%x\n", FileHandle));
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgPrint((DPRINT_FILESYSTEM, "FsOpenFile() failed.\n"));
|
||||
}
|
||||
#endif // defined DEBUG
|
||||
|
||||
return FileHandle;
|
||||
}
|
||||
|
||||
VOID FsCloseFile(PFILE FileHandle)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* ReadFile()
|
||||
* returns number of bytes read or EOF
|
||||
*/
|
||||
BOOL FsReadFile(PFILE FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer)
|
||||
{
|
||||
U64 BytesReadBig;
|
||||
BOOL Success;
|
||||
|
||||
//
|
||||
// Set the number of bytes read equal to zero
|
||||
//
|
||||
if (BytesRead != NULL)
|
||||
{
|
||||
*BytesRead = 0;
|
||||
}
|
||||
|
||||
switch (FileSystemType)
|
||||
{
|
||||
case FS_FAT:
|
||||
|
||||
return FatReadFile(FileHandle, BytesToRead, BytesRead, Buffer);
|
||||
|
||||
case FS_ISO9660:
|
||||
|
||||
return IsoReadFile(FileHandle, BytesToRead, BytesRead, Buffer);
|
||||
|
||||
case FS_EXT2:
|
||||
|
||||
//return Ext2ReadFile(FileHandle, BytesToRead, BytesRead, Buffer);
|
||||
Success = Ext2ReadFile(FileHandle, BytesToRead, &BytesReadBig, Buffer);
|
||||
*BytesRead = (U32)BytesReadBig;
|
||||
return Success;
|
||||
|
||||
case FS_NTFS:
|
||||
|
||||
return NtfsReadFile(FileHandle, BytesToRead, BytesRead, Buffer);
|
||||
|
||||
default:
|
||||
|
||||
FileSystemError("Unknown file system.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
U32 FsGetFileSize(PFILE FileHandle)
|
||||
{
|
||||
switch (FileSystemType)
|
||||
{
|
||||
case FS_FAT:
|
||||
|
||||
return FatGetFileSize(FileHandle);
|
||||
|
||||
case FS_ISO9660:
|
||||
|
||||
return IsoGetFileSize(FileHandle);
|
||||
|
||||
case FS_EXT2:
|
||||
|
||||
return Ext2GetFileSize(FileHandle);
|
||||
|
||||
case FS_NTFS:
|
||||
|
||||
return NtfsGetFileSize(FileHandle);
|
||||
|
||||
default:
|
||||
FileSystemError("Unknown file system.");
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID FsSetFilePointer(PFILE FileHandle, U32 NewFilePointer)
|
||||
{
|
||||
switch (FileSystemType)
|
||||
{
|
||||
case FS_FAT:
|
||||
|
||||
FatSetFilePointer(FileHandle, NewFilePointer);
|
||||
break;
|
||||
|
||||
case FS_ISO9660:
|
||||
|
||||
IsoSetFilePointer(FileHandle, NewFilePointer);
|
||||
break;
|
||||
|
||||
case FS_EXT2:
|
||||
|
||||
Ext2SetFilePointer(FileHandle, NewFilePointer);
|
||||
break;
|
||||
|
||||
case FS_NTFS:
|
||||
|
||||
NtfsSetFilePointer(FileHandle, NewFilePointer);
|
||||
break;
|
||||
|
||||
default:
|
||||
FileSystemError("Unknown file system.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
U32 FsGetFilePointer(PFILE FileHandle)
|
||||
{
|
||||
switch (FileSystemType)
|
||||
{
|
||||
case FS_FAT:
|
||||
|
||||
return FatGetFilePointer(FileHandle);
|
||||
break;
|
||||
|
||||
case FS_ISO9660:
|
||||
|
||||
return IsoGetFilePointer(FileHandle);
|
||||
break;
|
||||
|
||||
case FS_EXT2:
|
||||
|
||||
return Ext2GetFilePointer(FileHandle);
|
||||
break;
|
||||
|
||||
case FS_NTFS:
|
||||
|
||||
return NtfsGetFilePointer(FileHandle);
|
||||
break;
|
||||
|
||||
default:
|
||||
FileSystemError("Unknown file system.");
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL FsIsEndOfFile(PFILE FileHandle)
|
||||
{
|
||||
if (FsGetFilePointer(FileHandle) >= FsGetFileSize(FileHandle))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* FsGetNumPathParts()
|
||||
* This function parses a path in the form of dir1\dir2\file1.ext
|
||||
* and returns the number of parts it has (i.e. 3 - dir1,dir2,file1.ext)
|
||||
*/
|
||||
U32 FsGetNumPathParts(PUCHAR Path)
|
||||
{
|
||||
U32 i;
|
||||
U32 num;
|
||||
|
||||
for (i=0,num=0; i<(int)strlen(Path); i++)
|
||||
{
|
||||
if ((Path[i] == '\\') || (Path[i] == '/'))
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
num++;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "FatGetNumPathParts() Path = %s NumPathParts = %d\n", Path, num));
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
/*
|
||||
* FsGetFirstNameFromPath()
|
||||
* This function parses a path in the form of dir1\dir2\file1.ext
|
||||
* and puts the first name of the path (e.g. "dir1") in buffer
|
||||
* compatible with the MSDOS directory structure
|
||||
*/
|
||||
VOID FsGetFirstNameFromPath(PUCHAR Buffer, PUCHAR Path)
|
||||
{
|
||||
U32 i;
|
||||
|
||||
// Copy all the characters up to the end of the
|
||||
// string or until we hit a '\' character
|
||||
// and put them in Buffer
|
||||
for (i=0; i<(int)strlen(Path); i++)
|
||||
{
|
||||
if ((Path[i] == '\\') || (Path[i] == '/'))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Buffer[i] = Path[i];
|
||||
}
|
||||
}
|
||||
|
||||
Buffer[i] = 0;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "FatGetFirstNameFromPath() Path = %s FirstName = %s\n", Path, Buffer));
|
||||
}
|
@@ -39,10 +39,10 @@
|
||||
|
||||
/*
|
||||
*
|
||||
* BOOL FsRecognizeVolume(ULONG DriveNumber, ULONG VolumeStartSector, UCHAR* VolumeType);
|
||||
* BOOL FsRecognizeVolume(U32 DriveNumber, U32 VolumeStartSector, U8* VolumeType);
|
||||
*
|
||||
*/
|
||||
BOOL FsRecognizeVolume(ULONG DriveNumber, ULONG VolumeStartSector, UCHAR* VolumeType)
|
||||
BOOL FsRecognizeVolume(U32 DriveNumber, U32 VolumeStartSector, U8* VolumeType)
|
||||
{
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "FsRecognizeVolume() DriveNumber: 0x%x VolumeStartSector: %d\n", DriveNumber, VolumeStartSector));
|
||||
@@ -66,7 +66,7 @@ BOOL FsRecognizeVolume(ULONG DriveNumber, ULONG VolumeStartSector, UCHAR* Volume
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL FsRecIsIso9660(ULONG DriveNumber)
|
||||
BOOL FsRecIsIso9660(U32 DriveNumber)
|
||||
{
|
||||
PUCHAR Sector = (PUCHAR)DISKREADBUFFER;
|
||||
|
||||
@@ -84,7 +84,7 @@ BOOL FsRecIsIso9660(ULONG DriveNumber)
|
||||
Sector[5] == '1');
|
||||
}
|
||||
|
||||
BOOL FsRecIsExt2(ULONG DriveNumber, ULONG VolumeStartSector)
|
||||
BOOL FsRecIsExt2(U32 DriveNumber, U32 VolumeStartSector)
|
||||
{
|
||||
PEXT2_SUPER_BLOCK SuperBlock = (PEXT2_SUPER_BLOCK)DISKREADBUFFER;
|
||||
|
||||
@@ -102,7 +102,7 @@ BOOL FsRecIsExt2(ULONG DriveNumber, ULONG VolumeStartSector)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL FsRecIsFat(ULONG DriveNumber, ULONG VolumeStartSector)
|
||||
BOOL FsRecIsFat(U32 DriveNumber, U32 VolumeStartSector)
|
||||
{
|
||||
PFAT_BOOTSECTOR BootSector = (PFAT_BOOTSECTOR)DISKREADBUFFER;
|
||||
PFAT32_BOOTSECTOR BootSector32 = (PFAT32_BOOTSECTOR)DISKREADBUFFER;
|
||||
@@ -124,7 +124,7 @@ BOOL FsRecIsFat(ULONG DriveNumber, ULONG VolumeStartSector)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL FsRecIsNtfs(ULONG DriveNumber, ULONG VolumeStartSector)
|
||||
BOOL FsRecIsNtfs(U32 DriveNumber, U32 VolumeStartSector)
|
||||
{
|
||||
PNTFS_BOOTSECTOR BootSector = (PNTFS_BOOTSECTOR)DISKREADBUFFER;
|
||||
if (!MachDiskReadLogicalSectors(DriveNumber, VolumeStartSector, 1, BootSector))
|
29
freeldr/freeldr/fs/fsrec.h
Normal file
29
freeldr/freeldr/fs/fsrec.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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 __FSREC_H
|
||||
#define __FSREC_H
|
||||
|
||||
BOOL FsRecognizeVolume(U32 DriveNumber, U32 VolumeStartSector, U8* VolumeType);
|
||||
BOOL FsRecIsIso9660(U32 DriveNumber);
|
||||
BOOL FsRecIsExt2(U32 DriveNumber, U32 VolumeStartSector);
|
||||
BOOL FsRecIsFat(U32 DriveNumber, U32 VolumeStartSector);
|
||||
BOOL FsRecIsNtfs(U32 DriveNumber, U32 VolumeStartSector);
|
||||
|
||||
#endif // #defined __FSREC_H
|
@@ -32,13 +32,13 @@
|
||||
|
||||
#define SECTORSIZE 2048
|
||||
|
||||
static ULONG IsoRootSector; // Starting sector of the root directory
|
||||
static ULONG IsoRootLength; // Length of the root directory
|
||||
static U32 IsoRootSector; // Starting sector of the root directory
|
||||
static U32 IsoRootLength; // Length of the root directory
|
||||
|
||||
ULONG IsoDriveNumber = 0;
|
||||
U32 IsoDriveNumber = 0;
|
||||
|
||||
|
||||
BOOL IsoOpenVolume(ULONG DriveNumber)
|
||||
BOOL IsoOpenVolume(U32 DriveNumber)
|
||||
{
|
||||
PPVD Pvd = (PPVD)DISKREADBUFFER;
|
||||
|
||||
@@ -65,12 +65,12 @@ BOOL IsoOpenVolume(ULONG DriveNumber)
|
||||
}
|
||||
|
||||
|
||||
static BOOL IsoSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectoryLength, PCHAR FileName, PISO_FILE_INFO IsoFileInfoPointer)
|
||||
static BOOL IsoSearchDirectoryBufferForFile(PVOID DirectoryBuffer, U32 DirectoryLength, PUCHAR FileName, PISO_FILE_INFO IsoFileInfoPointer)
|
||||
{
|
||||
PDIR_RECORD Record;
|
||||
ULONG Offset;
|
||||
ULONG i;
|
||||
CHAR Name[32];
|
||||
U32 Offset;
|
||||
U32 i;
|
||||
UCHAR Name[32];
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "IsoSearchDirectoryBufferForFile() DirectoryBuffer = 0x%x DirectoryLength = %d FileName = %s\n", DirectoryBuffer, DirectoryLength, FileName));
|
||||
|
||||
@@ -133,12 +133,12 @@ static BOOL IsoSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG Directo
|
||||
* if allocation or read fails. The directory is specified by its
|
||||
* starting sector and length.
|
||||
*/
|
||||
static PVOID IsoBufferDirectory(ULONG DirectoryStartSector, ULONG DirectoryLength)
|
||||
static PVOID IsoBufferDirectory(U32 DirectoryStartSector, U32 DirectoryLength)
|
||||
{
|
||||
PVOID DirectoryBuffer;
|
||||
PVOID Ptr;
|
||||
ULONG SectorCount;
|
||||
ULONG i;
|
||||
U32 SectorCount;
|
||||
U32 i;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "IsoBufferDirectory() DirectoryStartSector = %d DirectoryLength = %d\n", DirectoryStartSector, DirectoryLength));
|
||||
|
||||
@@ -180,14 +180,14 @@ static PVOID IsoBufferDirectory(ULONG DirectoryStartSector, ULONG DirectoryLengt
|
||||
* with info describing the file, etc. returns true
|
||||
* if the file exists or false otherwise
|
||||
*/
|
||||
static BOOL IsoLookupFile(PCHAR FileName, PISO_FILE_INFO IsoFileInfoPointer)
|
||||
static BOOL IsoLookupFile(PUCHAR FileName, PISO_FILE_INFO IsoFileInfoPointer)
|
||||
{
|
||||
int i;
|
||||
ULONG NumberOfPathParts;
|
||||
CHAR PathPart[261];
|
||||
U32 NumberOfPathParts;
|
||||
UCHAR PathPart[261];
|
||||
PVOID DirectoryBuffer;
|
||||
ULONG DirectorySector;
|
||||
ULONG DirectoryLength;
|
||||
U32 DirectorySector;
|
||||
U32 DirectoryLength;
|
||||
ISO_FILE_INFO IsoFileInfo;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "IsoLookupFile() FileName = %s\n", FileName));
|
||||
@@ -263,7 +263,7 @@ static BOOL IsoLookupFile(PCHAR FileName, PISO_FILE_INFO IsoFileInfoPointer)
|
||||
* Tries to open the file 'name' and returns true or false
|
||||
* for success and failure respectively
|
||||
*/
|
||||
FILE* IsoOpenFile(PCHAR FileName)
|
||||
FILE* IsoOpenFile(PUCHAR FileName)
|
||||
{
|
||||
ISO_FILE_INFO TempFileInfo;
|
||||
PISO_FILE_INFO FileHandle;
|
||||
@@ -293,14 +293,14 @@ FILE* IsoOpenFile(PCHAR FileName)
|
||||
* Reads BytesToRead from open file and
|
||||
* returns the number of bytes read in BytesRead
|
||||
*/
|
||||
BOOL IsoReadFile(FILE *FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer)
|
||||
BOOL IsoReadFile(FILE *FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer)
|
||||
{
|
||||
PISO_FILE_INFO IsoFileInfo = (PISO_FILE_INFO)FileHandle;
|
||||
ULONG SectorNumber;
|
||||
ULONG OffsetInSector;
|
||||
ULONG LengthInSector;
|
||||
ULONG NumberOfSectors;
|
||||
ULONG i;
|
||||
U32 SectorNumber;
|
||||
U32 OffsetInSector;
|
||||
U32 LengthInSector;
|
||||
U32 NumberOfSectors;
|
||||
U32 i;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "IsoReadFile() BytesToRead = %d Buffer = 0x%x\n", BytesToRead, Buffer));
|
||||
|
||||
@@ -451,7 +451,7 @@ BOOL IsoReadFile(FILE *FileHandle, ULONG BytesToRead, ULONG* BytesRead, PVOID Bu
|
||||
}
|
||||
|
||||
|
||||
ULONG IsoGetFileSize(FILE *FileHandle)
|
||||
U32 IsoGetFileSize(FILE *FileHandle)
|
||||
{
|
||||
PISO_FILE_INFO IsoFileHandle = (PISO_FILE_INFO)FileHandle;
|
||||
|
||||
@@ -460,7 +460,7 @@ ULONG IsoGetFileSize(FILE *FileHandle)
|
||||
return IsoFileHandle->FileSize;
|
||||
}
|
||||
|
||||
VOID IsoSetFilePointer(FILE *FileHandle, ULONG NewFilePointer)
|
||||
VOID IsoSetFilePointer(FILE *FileHandle, U32 NewFilePointer)
|
||||
{
|
||||
PISO_FILE_INFO IsoFileHandle = (PISO_FILE_INFO)FileHandle;
|
||||
|
||||
@@ -469,7 +469,7 @@ VOID IsoSetFilePointer(FILE *FileHandle, ULONG NewFilePointer)
|
||||
IsoFileHandle->FilePointer = NewFilePointer;
|
||||
}
|
||||
|
||||
ULONG IsoGetFilePointer(FILE *FileHandle)
|
||||
U32 IsoGetFilePointer(FILE *FileHandle)
|
||||
{
|
||||
PISO_FILE_INFO IsoFileHandle = (PISO_FILE_INFO)FileHandle;
|
||||
|
115
freeldr/freeldr/fs/iso.h
Normal file
115
freeldr/freeldr/fs/iso.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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 __ISO_H
|
||||
#define __ISO_H
|
||||
|
||||
|
||||
struct _DIR_RECORD
|
||||
{
|
||||
UCHAR RecordLength; // 1
|
||||
UCHAR ExtAttrRecordLength; // 2
|
||||
U32 ExtentLocationL; // 3-6
|
||||
U32 ExtentLocationM; // 7-10
|
||||
U32 DataLengthL; // 11-14
|
||||
U32 DataLengthM; // 15-18
|
||||
UCHAR Year; // 19
|
||||
UCHAR Month; // 20
|
||||
UCHAR Day; // 21
|
||||
UCHAR Hour; // 22
|
||||
UCHAR Minute; // 23
|
||||
UCHAR Second; // 24
|
||||
UCHAR TimeZone; // 25
|
||||
UCHAR FileFlags; // 26
|
||||
UCHAR FileUnitSize; // 27
|
||||
UCHAR InterleaveGapSize; // 28
|
||||
U32 VolumeSequenceNumber; // 29-32
|
||||
UCHAR FileIdLength; // 33
|
||||
UCHAR FileId[1]; // 34
|
||||
} __attribute__((packed));
|
||||
|
||||
typedef struct _DIR_RECORD DIR_RECORD, *PDIR_RECORD;
|
||||
|
||||
|
||||
|
||||
|
||||
/* Volume Descriptor header*/
|
||||
struct _VD_HEADER
|
||||
{
|
||||
UCHAR VdType; // 1
|
||||
UCHAR StandardId[5]; // 2-6
|
||||
UCHAR VdVersion; // 7
|
||||
} __attribute__((packed));
|
||||
|
||||
typedef struct _VD_HEADER VD_HEADER, *PVD_HEADER;
|
||||
|
||||
|
||||
|
||||
/* Primary Volume Descriptor */
|
||||
struct _PVD
|
||||
{
|
||||
UCHAR VdType; // 1
|
||||
UCHAR StandardId[5]; // 2-6
|
||||
UCHAR VdVersion; // 7
|
||||
UCHAR unused0; // 8
|
||||
UCHAR SystemId[32]; // 9-40
|
||||
UCHAR VolumeId[32]; // 41-72
|
||||
UCHAR unused1[8]; // 73-80
|
||||
U32 VolumeSpaceSizeL; // 81-84
|
||||
U32 VolumeSpaceSizeM; // 85-88
|
||||
UCHAR unused2[32]; // 89-120
|
||||
U32 VolumeSetSize; // 121-124
|
||||
U32 VolumeSequenceNumber; // 125-128
|
||||
U32 LogicalBlockSize; // 129-132
|
||||
U32 PathTableSizeL; // 133-136
|
||||
U32 PathTableSizeM; // 137-140
|
||||
U32 LPathTablePos; // 141-144
|
||||
U32 LOptPathTablePos; // 145-148
|
||||
U32 MPathTablePos; // 149-152
|
||||
U32 MOptPathTablePos; // 153-156
|
||||
DIR_RECORD RootDirRecord; // 157-190
|
||||
UCHAR VolumeSetIdentifier[128]; // 191-318
|
||||
UCHAR PublisherIdentifier[128]; // 319-446
|
||||
|
||||
/* more data ... */
|
||||
|
||||
} __attribute__((packed));
|
||||
|
||||
typedef struct _PVD PVD, *PPVD;
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U32 FileStart; // File start sector
|
||||
U32 FileSize; // File size
|
||||
U32 FilePointer; // File pointer
|
||||
BOOL Directory;
|
||||
U32 DriveNumber;
|
||||
} ISO_FILE_INFO, * PISO_FILE_INFO;
|
||||
|
||||
|
||||
BOOL IsoOpenVolume(U32 DriveNumber);
|
||||
FILE* IsoOpenFile(PUCHAR FileName);
|
||||
BOOL IsoReadFile(FILE *FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer);
|
||||
U32 IsoGetFileSize(FILE *FileHandle);
|
||||
VOID IsoSetFilePointer(FILE *FileHandle, U32 NewFilePointer);
|
||||
U32 IsoGetFilePointer(FILE *FileHandle);
|
||||
|
||||
#endif // #defined __FAT_H
|
@@ -21,7 +21,7 @@
|
||||
* Limitations:
|
||||
* - No support for compressed files.
|
||||
* - No attribute list support.
|
||||
* - May crash on corrupted filesystem.
|
||||
* - May crash on currupted filesystem.
|
||||
*/
|
||||
|
||||
#include <freeldr.h>
|
||||
@@ -37,19 +37,19 @@
|
||||
#include "ntfs.h"
|
||||
|
||||
PNTFS_BOOTSECTOR NtfsBootSector;
|
||||
ULONG NtfsClusterSize;
|
||||
ULONG NtfsMftRecordSize;
|
||||
ULONG NtfsIndexRecordSize;
|
||||
ULONG NtfsDriveNumber;
|
||||
ULONG NtfsSectorOfClusterZero;
|
||||
U32 NtfsClusterSize;
|
||||
U32 NtfsMftRecordSize;
|
||||
U32 NtfsIndexRecordSize;
|
||||
U32 NtfsDriveNumber;
|
||||
U32 NtfsSectorOfClusterZero;
|
||||
PNTFS_MFT_RECORD NtfsMasterFileTable;
|
||||
NTFS_ATTR_CONTEXT NtfsMFTContext;
|
||||
|
||||
PUCHAR NtfsDecodeRun(PUCHAR DataRun, LONGLONG *DataRunOffset, ULONGLONG *DataRunLength)
|
||||
PUCHAR NtfsDecodeRun(PUCHAR DataRun, S64 *DataRunOffset, U64 *DataRunLength)
|
||||
{
|
||||
UCHAR DataRunOffsetSize;
|
||||
UCHAR DataRunLengthSize;
|
||||
CHAR i;
|
||||
U8 DataRunOffsetSize;
|
||||
U8 DataRunLengthSize;
|
||||
S8 i;
|
||||
|
||||
DataRunOffsetSize = (*DataRun >> 4) & 0xF;
|
||||
DataRunLengthSize = *DataRun & 0xF;
|
||||
@@ -75,7 +75,7 @@ PUCHAR NtfsDecodeRun(PUCHAR DataRun, LONGLONG *DataRunOffset, ULONGLONG *DataRun
|
||||
DataRun++;
|
||||
}
|
||||
/* The last byte contains sign so we must process it different way. */
|
||||
*DataRunOffset = ((CHAR)(*(DataRun++)) << (i << 3)) + *DataRunOffset;
|
||||
*DataRunOffset = ((S8)(*(DataRun++)) << (i << 3)) + *DataRunOffset;
|
||||
}
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "DataRunOffsetSize: %x\n", DataRunOffsetSize));
|
||||
@@ -87,11 +87,11 @@ PUCHAR NtfsDecodeRun(PUCHAR DataRun, LONGLONG *DataRunOffset, ULONGLONG *DataRun
|
||||
}
|
||||
|
||||
/* FIXME: Add support for attribute lists! */
|
||||
BOOL NtfsFindAttribute(PNTFS_ATTR_CONTEXT Context, PNTFS_MFT_RECORD MftRecord, ULONG Type, PWCHAR Name)
|
||||
BOOL NtfsFindAttribute(PNTFS_ATTR_CONTEXT Context, PNTFS_MFT_RECORD MftRecord, U32 Type, PWCHAR Name)
|
||||
{
|
||||
PNTFS_ATTR_RECORD AttrRecord;
|
||||
PNTFS_ATTR_RECORD AttrRecordEnd;
|
||||
ULONG NameLength;
|
||||
U32 NameLength;
|
||||
PWCHAR AttrName;
|
||||
|
||||
AttrRecord = (PNTFS_ATTR_RECORD)((PCHAR)MftRecord + MftRecord->AttributesOffset);
|
||||
@@ -115,8 +115,8 @@ BOOL NtfsFindAttribute(PNTFS_ATTR_CONTEXT Context, PNTFS_MFT_RECORD MftRecord, U
|
||||
Context->Record = AttrRecord;
|
||||
if (AttrRecord->IsNonResident)
|
||||
{
|
||||
LONGLONG DataRunOffset;
|
||||
ULONGLONG DataRunLength;
|
||||
S64 DataRunOffset;
|
||||
U64 DataRunLength;
|
||||
|
||||
Context->CacheRun = (PUCHAR)Context->Record + Context->Record->NonResident.MappingPairsOffset;
|
||||
Context->CacheRunOffset = 0;
|
||||
@@ -148,9 +148,9 @@ BOOL NtfsFindAttribute(PNTFS_ATTR_CONTEXT Context, PNTFS_MFT_RECORD MftRecord, U
|
||||
}
|
||||
|
||||
/* FIXME: Optimize for multisector reads. */
|
||||
BOOL NtfsDiskRead(ULONGLONG Offset, ULONGLONG Length, PCHAR Buffer)
|
||||
BOOL NtfsDiskRead(U64 Offset, U64 Length, PCHAR Buffer)
|
||||
{
|
||||
USHORT ReadLength;
|
||||
U16 ReadLength;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "NtfsDiskRead - Offset: %I64d Length: %I64d\n", Offset, Length));
|
||||
RtlZeroMemory((PCHAR)DISKREADBUFFER, 0x1000);
|
||||
@@ -190,16 +190,16 @@ BOOL NtfsDiskRead(ULONGLONG Offset, ULONGLONG Length, PCHAR Buffer)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ULONGLONG NtfsReadAttribute(PNTFS_ATTR_CONTEXT Context, ULONGLONG Offset, PCHAR Buffer, ULONGLONG Length)
|
||||
U64 NtfsReadAttribute(PNTFS_ATTR_CONTEXT Context, U64 Offset, PCHAR Buffer, U64 Length)
|
||||
{
|
||||
ULONGLONG LastLCN;
|
||||
U64 LastLCN;
|
||||
PUCHAR DataRun;
|
||||
LONGLONG DataRunOffset;
|
||||
ULONGLONG DataRunLength;
|
||||
LONGLONG DataRunStartLCN;
|
||||
ULONGLONG CurrentOffset;
|
||||
ULONGLONG ReadLength;
|
||||
ULONGLONG AlreadyRead;
|
||||
S64 DataRunOffset;
|
||||
U64 DataRunLength;
|
||||
S64 DataRunStartLCN;
|
||||
U64 CurrentOffset;
|
||||
U64 ReadLength;
|
||||
U64 AlreadyRead;
|
||||
|
||||
if (!Context->Record->IsNonResident)
|
||||
{
|
||||
@@ -316,31 +316,31 @@ ULONGLONG NtfsReadAttribute(PNTFS_ATTR_CONTEXT Context, ULONGLONG Offset, PCHAR
|
||||
|
||||
BOOL NtfsFixupRecord(PNTFS_RECORD Record)
|
||||
{
|
||||
USHORT *USA;
|
||||
USHORT USANumber;
|
||||
USHORT USACount;
|
||||
USHORT *Block;
|
||||
U16 *USA;
|
||||
U16 USANumber;
|
||||
U16 USACount;
|
||||
U16 *Block;
|
||||
|
||||
USA = (USHORT*)((PCHAR)Record + Record->USAOffset);
|
||||
USA = (U16*)((PCHAR)Record + Record->USAOffset);
|
||||
USANumber = *(USA++);
|
||||
USACount = Record->USACount - 1; /* Exclude the USA Number. */
|
||||
Block = (USHORT*)((PCHAR)Record + NtfsBootSector->BytesPerSector - 2);
|
||||
Block = (U16*)((PCHAR)Record + NtfsBootSector->BytesPerSector - 2);
|
||||
|
||||
while (USACount)
|
||||
{
|
||||
if (*Block != USANumber)
|
||||
return FALSE;
|
||||
*Block = *(USA++);
|
||||
Block = (USHORT*)((PCHAR)Block + NtfsBootSector->BytesPerSector);
|
||||
Block = (U16*)((PCHAR)Block + NtfsBootSector->BytesPerSector);
|
||||
USACount--;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL NtfsReadMftRecord(ULONG MFTIndex, PNTFS_MFT_RECORD Buffer)
|
||||
BOOL NtfsReadMftRecord(U32 MFTIndex, PNTFS_MFT_RECORD Buffer)
|
||||
{
|
||||
ULONGLONG BytesRead;
|
||||
U64 BytesRead;
|
||||
|
||||
BytesRead = NtfsReadAttribute(&NtfsMFTContext, MFTIndex * NtfsMftRecordSize, (PCHAR)Buffer, NtfsMftRecordSize);
|
||||
if (BytesRead != NtfsMftRecordSize)
|
||||
@@ -354,9 +354,9 @@ BOOL NtfsReadMftRecord(ULONG MFTIndex, PNTFS_MFT_RECORD Buffer)
|
||||
VOID NtfsPrintFile(PNTFS_INDEX_ENTRY IndexEntry)
|
||||
{
|
||||
PWCHAR FileName;
|
||||
UCHAR FileNameLength;
|
||||
U8 FileNameLength;
|
||||
CHAR AnsiFileName[256];
|
||||
UCHAR i;
|
||||
U8 i;
|
||||
|
||||
FileName = IndexEntry->FileName.FileName;
|
||||
FileNameLength = IndexEntry->FileName.FileNameLength;
|
||||
@@ -372,8 +372,8 @@ VOID NtfsPrintFile(PNTFS_INDEX_ENTRY IndexEntry)
|
||||
BOOL NtfsCompareFileName(PCHAR FileName, PNTFS_INDEX_ENTRY IndexEntry)
|
||||
{
|
||||
PWCHAR EntryFileName;
|
||||
UCHAR EntryFileNameLength;
|
||||
UCHAR i;
|
||||
U8 EntryFileNameLength;
|
||||
U8 i;
|
||||
|
||||
EntryFileName = IndexEntry->FileName.FileName;
|
||||
EntryFileNameLength = IndexEntry->FileName.FileNameLength;
|
||||
@@ -402,21 +402,21 @@ BOOL NtfsCompareFileName(PCHAR FileName, PNTFS_INDEX_ENTRY IndexEntry)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL NtfsFindMftRecord(ULONG MFTIndex, PCHAR FileName, ULONG *OutMFTIndex)
|
||||
BOOL NtfsFindMftRecord(U32 MFTIndex, PCHAR FileName, U32 *OutMFTIndex)
|
||||
{
|
||||
PNTFS_MFT_RECORD MftRecord;
|
||||
ULONG Magic;
|
||||
U32 Magic;
|
||||
NTFS_ATTR_CONTEXT IndexRootCtx;
|
||||
NTFS_ATTR_CONTEXT IndexBitmapCtx;
|
||||
NTFS_ATTR_CONTEXT IndexAllocationCtx;
|
||||
PNTFS_INDEX_ROOT IndexRoot;
|
||||
ULONGLONG BitmapDataSize;
|
||||
ULONGLONG IndexAllocationSize;
|
||||
U64 BitmapDataSize;
|
||||
U64 IndexAllocationSize;
|
||||
PCHAR BitmapData;
|
||||
PCHAR IndexRecord;
|
||||
PNTFS_INDEX_ENTRY IndexEntry, IndexEntryEnd;
|
||||
ULONG RecordOffset;
|
||||
ULONG IndexBlockSize;
|
||||
U32 RecordOffset;
|
||||
U32 IndexBlockSize;
|
||||
|
||||
MftRecord = MmAllocateMemory(NtfsMftRecordSize);
|
||||
if (MftRecord == NULL)
|
||||
@@ -508,8 +508,8 @@ BOOL NtfsFindMftRecord(ULONG MFTIndex, PCHAR FileName, ULONG *OutMFTIndex)
|
||||
DbgPrint((DPRINT_FILESYSTEM, "RecordOffset: %x IndexAllocationSize: %x\n", RecordOffset, IndexAllocationSize));
|
||||
for (; RecordOffset < IndexAllocationSize;)
|
||||
{
|
||||
UCHAR Bit = 1 << ((RecordOffset / IndexBlockSize) & 7);
|
||||
ULONG Byte = (RecordOffset / IndexBlockSize) >> 3;
|
||||
U8 Bit = 1 << ((RecordOffset / IndexBlockSize) & 7);
|
||||
U32 Byte = (RecordOffset / IndexBlockSize) >> 3;
|
||||
if ((BitmapData[Byte] & Bit))
|
||||
break;
|
||||
RecordOffset += IndexBlockSize;
|
||||
@@ -528,7 +528,7 @@ BOOL NtfsFindMftRecord(ULONG MFTIndex, PCHAR FileName, ULONG *OutMFTIndex)
|
||||
}
|
||||
|
||||
/* FIXME */
|
||||
IndexEntry = (PNTFS_INDEX_ENTRY)(IndexRecord + 0x18 + *(USHORT *)(IndexRecord + 0x18));
|
||||
IndexEntry = (PNTFS_INDEX_ENTRY)(IndexRecord + 0x18 + *(U16 *)(IndexRecord + 0x18));
|
||||
IndexEntryEnd = (PNTFS_INDEX_ENTRY)(IndexRecord + IndexBlockSize);
|
||||
|
||||
while (IndexEntry < IndexEntryEnd &&
|
||||
@@ -563,12 +563,12 @@ BOOL NtfsFindMftRecord(ULONG MFTIndex, PCHAR FileName, ULONG *OutMFTIndex)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL NtfsLookupFile(PCHAR FileName, PNTFS_MFT_RECORD MftRecord, PNTFS_ATTR_CONTEXT DataContext)
|
||||
BOOL NtfsLookupFile(PUCHAR FileName, PNTFS_MFT_RECORD MftRecord, PNTFS_ATTR_CONTEXT DataContext)
|
||||
{
|
||||
ULONG NumberOfPathParts;
|
||||
CHAR PathPart[261];
|
||||
ULONG CurrentMFTIndex;
|
||||
UCHAR i;
|
||||
U32 NumberOfPathParts;
|
||||
UCHAR PathPart[261];
|
||||
U32 CurrentMFTIndex;
|
||||
U8 i;
|
||||
|
||||
DbgPrint((DPRINT_FILESYSTEM, "NtfsLookupFile() FileName = %s\n", FileName));
|
||||
|
||||
@@ -606,7 +606,7 @@ BOOL NtfsLookupFile(PCHAR FileName, PNTFS_MFT_RECORD MftRecord, PNTFS_ATTR_CONTE
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL NtfsOpenVolume(ULONG DriveNumber, ULONG VolumeStartSector)
|
||||
BOOL NtfsOpenVolume(U32 DriveNumber, U32 VolumeStartSector)
|
||||
{
|
||||
NtfsBootSector = (PNTFS_BOOTSECTOR)DISKREADBUFFER;
|
||||
|
||||
@@ -680,7 +680,7 @@ BOOL NtfsOpenVolume(ULONG DriveNumber, ULONG VolumeStartSector)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
FILE* NtfsOpenFile(PCHAR FileName)
|
||||
FILE* NtfsOpenFile(PUCHAR FileName)
|
||||
{
|
||||
PNTFS_FILE_HANDLE FileHandle;
|
||||
PNTFS_MFT_RECORD MftRecord;
|
||||
@@ -703,36 +703,36 @@ FILE* NtfsOpenFile(PCHAR FileName)
|
||||
return (FILE*)FileHandle;
|
||||
}
|
||||
|
||||
BOOL NtfsReadFile(FILE *File, ULONG BytesToRead, ULONG* BytesRead, PVOID Buffer)
|
||||
BOOL NtfsReadFile(FILE *File, U32 BytesToRead, U32* BytesRead, PVOID Buffer)
|
||||
{
|
||||
PNTFS_FILE_HANDLE FileHandle = (PNTFS_FILE_HANDLE)File;
|
||||
ULONGLONG BytesRead64;
|
||||
U64 BytesRead64;
|
||||
BytesRead64 = NtfsReadAttribute(&FileHandle->DataContext, FileHandle->Offset, Buffer, BytesToRead);
|
||||
if (BytesRead64)
|
||||
{
|
||||
*BytesRead = (ULONG)BytesRead64;
|
||||
*BytesRead = (U32)BytesRead64;
|
||||
FileHandle->Offset += BytesRead64;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ULONG NtfsGetFileSize(FILE *File)
|
||||
U32 NtfsGetFileSize(FILE *File)
|
||||
{
|
||||
PNTFS_FILE_HANDLE FileHandle = (PNTFS_FILE_HANDLE)File;
|
||||
if (FileHandle->DataContext.Record->IsNonResident)
|
||||
return (ULONG)FileHandle->DataContext.Record->NonResident.DataSize;
|
||||
return (U32)FileHandle->DataContext.Record->NonResident.DataSize;
|
||||
else
|
||||
return (ULONG)FileHandle->DataContext.Record->Resident.ValueLength;
|
||||
return (U32)FileHandle->DataContext.Record->Resident.ValueLength;
|
||||
}
|
||||
|
||||
VOID NtfsSetFilePointer(FILE *File, ULONG NewFilePointer)
|
||||
VOID NtfsSetFilePointer(FILE *File, U32 NewFilePointer)
|
||||
{
|
||||
PNTFS_FILE_HANDLE FileHandle = (PNTFS_FILE_HANDLE)File;
|
||||
FileHandle->Offset = NewFilePointer;
|
||||
}
|
||||
|
||||
ULONG NtfsGetFilePointer(FILE *File)
|
||||
U32 NtfsGetFilePointer(FILE *File)
|
||||
{
|
||||
PNTFS_FILE_HANDLE FileHandle = (PNTFS_FILE_HANDLE)File;
|
||||
return FileHandle->Offset;
|
228
freeldr/freeldr/fs/ntfs.h
Normal file
228
freeldr/freeldr/fs/ntfs.h
Normal file
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
* FreeLoader NTFS support
|
||||
* Copyright (C) 2004 Filip Navara <xnavara@volny.cz>
|
||||
*
|
||||
* 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 __NTFS_H
|
||||
#define __NTFS_H
|
||||
|
||||
#define NTFS_FILE_MFT 0
|
||||
#define NTFS_FILE_MFTMIRR 1
|
||||
#define NTFS_FILE_LOGFILE 2
|
||||
#define NTFS_FILE_VOLUME 3
|
||||
#define NTFS_FILE_ATTRDEF 4
|
||||
#define NTFS_FILE_ROOT 5
|
||||
#define NTFS_FILE_BITMAP 6
|
||||
#define NTFS_FILE_BOOT 7
|
||||
#define NTFS_FILE_BADCLUS 8
|
||||
#define NTFS_FILE_QUOTA 9
|
||||
#define NTFS_FILE_UPCASE 10
|
||||
|
||||
#define NTFS_ATTR_TYPE_STANDARD_INFORMATION 0x10
|
||||
#define NTFS_ATTR_TYPE_ATTRIBUTE_LIST 0x20
|
||||
#define NTFS_ATTR_TYPE_FILENAME 0x30
|
||||
#define NTFS_ATTR_TYPE_SECURITY_DESCRIPTOR 0x50
|
||||
#define NTFS_ATTR_TYPE_DATA 0x80
|
||||
#define NTFS_ATTR_TYPE_INDEX_ROOT 0x90
|
||||
#define NTFS_ATTR_TYPE_INDEX_ALLOCATION 0xa0
|
||||
#define NTFS_ATTR_TYPE_BITMAP 0xb0
|
||||
#define NTFS_ATTR_TYPE_SYMLINK 0xc0
|
||||
#define NTFS_ATTR_TYPE_END 0xffffffff
|
||||
|
||||
#define NTFS_ATTR_NORMAL 0
|
||||
#define NTFS_ATTR_COMPRESSED 1
|
||||
#define NTFS_ATTR_RESIDENT 2
|
||||
#define NTFS_ATTR_ENCRYPTED 0x4000
|
||||
|
||||
#define NTFS_SMALL_INDEX 0
|
||||
#define NTFS_LARGE_INDEX 1
|
||||
|
||||
#define NTFS_INDEX_ENTRY_NODE 1
|
||||
#define NTFS_INDEX_ENTRY_END 2
|
||||
|
||||
#define NTFS_FILE_NAME_POSIX 0
|
||||
#define NTFS_FILE_NAME_WIN32 1
|
||||
#define NTFS_FILE_NAME_DOS 2
|
||||
#define NTFS_FILE_NAME_WIN32_AND_DOS 3
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U8 JumpBoot[3]; // Jump to the boot loader routine
|
||||
U8 SystemId[8]; // System Id ("NTFS ")
|
||||
U16 BytesPerSector; // Bytes per sector
|
||||
U8 SectorsPerCluster; // Number of sectors in a cluster
|
||||
U8 Unused1[7];
|
||||
U8 MediaDescriptor; // Media descriptor byte
|
||||
U8 Unused2[2];
|
||||
U16 SectorsPerTrack; // Number of sectors in a track
|
||||
U16 NumberOfHeads; // Number of heads on the disk
|
||||
U8 Unused3[8];
|
||||
U8 DriveNumber; // Int 0x13 drive number (e.g. 0x80)
|
||||
U8 CurrentHead;
|
||||
U8 BootSignature; // Extended boot signature (0x80)
|
||||
U8 Unused4;
|
||||
U64 VolumeSectorCount; // Number of sectors in the volume
|
||||
U64 MftLocation;
|
||||
U64 MftMirrorLocation;
|
||||
S8 ClustersPerMftRecord; // Clusters per MFT Record
|
||||
U8 Unused5[3];
|
||||
S8 ClustersPerIndexRecord; // Clusters per Index Record
|
||||
U8 Unused6[3];
|
||||
U64 VolumeSerialNumber; // Volume serial number
|
||||
U8 BootCodeAndData[430]; // The remainder of the boot sector
|
||||
U16 BootSectorMagic; // 0xAA55
|
||||
} PACKED NTFS_BOOTSECTOR, *PNTFS_BOOTSECTOR;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U32 Magic;
|
||||
U16 USAOffset; // Offset to the Update Sequence Array from the start of the ntfs record
|
||||
U16 USACount;
|
||||
} PACKED NTFS_RECORD, *PNTFS_RECORD;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U32 Magic;
|
||||
U16 USAOffset; // Offset to the Update Sequence Array from the start of the ntfs record
|
||||
U16 USACount;
|
||||
U64 LogSequenceNumber;
|
||||
U16 SequenceNumber;
|
||||
U16 LinkCount;
|
||||
U16 AttributesOffset;
|
||||
U16 Flags;
|
||||
U32 BytesInUse; // Number of bytes used in this mft record.
|
||||
U32 BytesAllocated;
|
||||
U64 BaseMFTRecord;
|
||||
U16 NextAttributeInstance;
|
||||
} PACKED NTFS_MFT_RECORD, *PNTFS_MFT_RECORD;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U32 Type;
|
||||
U32 Length;
|
||||
U8 IsNonResident;
|
||||
U8 NameLength;
|
||||
U16 NameOffset;
|
||||
U16 Flags;
|
||||
U16 Instance;
|
||||
union
|
||||
{
|
||||
// Resident attributes
|
||||
struct
|
||||
{
|
||||
U32 ValueLength;
|
||||
U16 ValueOffset;
|
||||
U16 Flags;
|
||||
} PACKED Resident;
|
||||
// Non-resident attributes
|
||||
struct
|
||||
{
|
||||
U64 LowestVCN;
|
||||
U64 HighestVCN;
|
||||
U16 MappingPairsOffset;
|
||||
U8 CompressionUnit;
|
||||
U8 Reserved[5];
|
||||
S64 AllocatedSize;
|
||||
S64 DataSize;
|
||||
S64 InitializedSize;
|
||||
S64 CompressedSize;
|
||||
} PACKED NonResident;
|
||||
} PACKED;
|
||||
} PACKED NTFS_ATTR_RECORD, *PNTFS_ATTR_RECORD;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U32 EntriesOffset;
|
||||
U32 IndexLength;
|
||||
U32 AllocatedSize;
|
||||
U8 Flags;
|
||||
U8 Reserved[3];
|
||||
} PACKED NTFS_INDEX_HEADER, *PNTFS_INDEX_HEADER;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U32 Type;
|
||||
U32 CollationRule;
|
||||
U32 IndexBlockSize;
|
||||
U8 ClustersPerIndexBlock;
|
||||
U8 Reserved[3];
|
||||
NTFS_INDEX_HEADER IndexHeader;
|
||||
} PACKED NTFS_INDEX_ROOT, *PNTFS_INDEX_ROOT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U64 ParentDirectory;
|
||||
S64 CreationTime;
|
||||
S64 LastDataChangeTime;
|
||||
S64 LastMftChangeTime;
|
||||
S64 LastAccessTime;
|
||||
S64 AllocatedSize;
|
||||
S64 DataSize;
|
||||
U32 FileAttributes;
|
||||
U16 PackedExtendedAttributeSize;
|
||||
U16 Reserved;
|
||||
U8 FileNameLength;
|
||||
U8 FileNameType;
|
||||
WCHAR FileName[0];
|
||||
} PACKED NTFS_FILE_NAME_ATTR, *PNTFS_FILE_NAME_ATTR;
|
||||
|
||||
typedef struct {
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
U64 IndexedFile;
|
||||
} PACKED Directory;
|
||||
struct
|
||||
{
|
||||
U16 DataOffset;
|
||||
U16 DataLength;
|
||||
U32 Reserved;
|
||||
} PACKED ViewIndex;
|
||||
} PACKED Data;
|
||||
U16 Length;
|
||||
U16 KeyLength;
|
||||
U16 Flags;
|
||||
U16 Reserved;
|
||||
NTFS_FILE_NAME_ATTR FileName;
|
||||
} PACKED NTFS_INDEX_ENTRY, *PNTFS_INDEX_ENTRY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PNTFS_ATTR_RECORD Record;
|
||||
PUCHAR CacheRun;
|
||||
U64 CacheRunOffset;
|
||||
S64 CacheRunStartLCN;
|
||||
U64 CacheRunLength;
|
||||
S64 CacheRunLastLCN;
|
||||
U64 CacheRunCurrentOffset;
|
||||
} NTFS_ATTR_CONTEXT, *PNTFS_ATTR_CONTEXT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
NTFS_ATTR_CONTEXT DataContext;
|
||||
U64 Offset;
|
||||
} PACKED NTFS_FILE_HANDLE, *PNTFS_FILE_HANDLE;
|
||||
|
||||
BOOL NtfsOpenVolume(U32 DriveNumber, U32 VolumeStartSector);
|
||||
FILE* NtfsOpenFile(PUCHAR FileName);
|
||||
BOOL NtfsReadFile(FILE *FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer);
|
||||
U32 NtfsGetFileSize(FILE *FileHandle);
|
||||
VOID NtfsSetFilePointer(FILE *FileHandle, U32 NewFilePointer);
|
||||
U32 NtfsGetFilePointer(FILE *FileHandle);
|
||||
|
||||
#endif // #defined __NTFS_H
|
@@ -21,9 +21,9 @@
|
||||
#define __BOOTMGR_H
|
||||
|
||||
|
||||
ULONG GetDefaultOperatingSystem(PCHAR OperatingSystemList[], ULONG OperatingSystemCount);
|
||||
LONG GetTimeOut(VOID);
|
||||
BOOL MainBootMenuKeyPressFilter(ULONG KeyPress);
|
||||
U32 GetDefaultOperatingSystem(PUCHAR OperatingSystemList[], U32 OperatingSystemCount);
|
||||
S32 GetTimeOut(VOID);
|
||||
BOOL MainBootMenuKeyPressFilter(U32 KeyPress);
|
||||
|
||||
|
||||
#endif // #defined __BOOTMGR_H
|
@@ -21,10 +21,10 @@
|
||||
#ifndef __CACHE_H
|
||||
#define __CACHE_H
|
||||
|
||||
BOOL CacheInitializeDrive(ULONG DriveNumber);
|
||||
BOOL CacheInitializeDrive(U32 DriveNumber);
|
||||
VOID CacheInvalidateCacheData(VOID);
|
||||
BOOL CacheReadDiskSectors(ULONG DiskNumber, ULONG StartSector, ULONG SectorCount, PVOID Buffer);
|
||||
BOOL CacheForceDiskSectorsIntoCache(ULONG DiskNumber, ULONG StartSector, ULONG SectorCount);
|
||||
BOOL CacheReleaseMemory(ULONG MinimumAmountToRelease);
|
||||
BOOL CacheReadDiskSectors(U32 DiskNumber, U32 StartSector, U32 SectorCount, PVOID Buffer);
|
||||
BOOL CacheForceDiskSectorsIntoCache(U32 DiskNumber, U32 StartSector, U32 SectorCount);
|
||||
BOOL CacheReleaseMemory(U32 MinimumAmountToRelease);
|
||||
|
||||
#endif // defined __CACHE_H
|
@@ -1,4 +1,4 @@
|
||||
/* $Id$
|
||||
/* $Id: cmdline.h,v 1.1 2004/11/01 20:49:32 gvg Exp $
|
||||
*
|
||||
* FreeLdr boot loader
|
||||
* Copyright (C) 2002, 2003 ReactOS Team
|
||||
@@ -24,13 +24,13 @@
|
||||
typedef struct tagCMDLINEINFO
|
||||
{
|
||||
char *DefaultOperatingSystem;
|
||||
LONG TimeOut;
|
||||
S32 TimeOut;
|
||||
} CMDLINEINFO, *PCMDLINEINFO;
|
||||
|
||||
extern void CmdLineParse(char *CmdLine);
|
||||
|
||||
extern char *CmdLineGetDefaultOS(void);
|
||||
extern LONG CmdLineGetTimeOut(void);
|
||||
extern S32 CmdLineGetTimeOut(void);
|
||||
|
||||
#endif /* __CMDLINE_H__ */
|
||||
|
@@ -22,7 +22,7 @@
|
||||
#ifndef __RS232_H
|
||||
#define __RS232_H
|
||||
|
||||
BOOL Rs232PortInitialize(ULONG ComPort, ULONG BaudRate);
|
||||
BOOL Rs232PortInitialize(U32 ComPort, U32 BaudRate);
|
||||
BOOL Rs232PortGetByte(PUCHAR ByteRecieved);
|
||||
BOOL Rs232PortPollByte(PUCHAR ByteRecieved);
|
||||
VOID Rs232PortPutByte(UCHAR ByteToSend);
|
88
freeldr/freeldr/include/debug.h
Normal file
88
freeldr/freeldr/include/debug.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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 __DEBUG_H
|
||||
#define __DEBUG_H
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
#define DPRINT_NONE 0x00000000 // No debug print
|
||||
#define DPRINT_WARNING 0x00000001 // OR this with DebugPrintMask to enable debugger messages and other misc stuff
|
||||
#define DPRINT_MEMORY 0x00000002 // OR this with DebugPrintMask to enable memory management messages
|
||||
#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
|
||||
#define DPRINT_CACHE 0x00000040 // OR this with DebugPrintMask to enable cache messages
|
||||
#define DPRINT_REGISTRY 0x00000080 // OR this with DebugPrintMask to enable registry messages
|
||||
#define DPRINT_REACTOS 0x00000100 // OR this with DebugPrintMask to enable ReactOS messages
|
||||
#define DPRINT_LINUX 0x00000200 // OR this with DebugPrintMask to enable Linux messages
|
||||
#define DPRINT_HWDETECT 0x00000400 // OR this with DebugPrintMask to enable hardware detection messages
|
||||
|
||||
VOID DebugInit(VOID);
|
||||
VOID DebugPrint(U32 Mask, char *format, ...);
|
||||
VOID DebugPrint1(char *format, ...);
|
||||
VOID DebugDumpBuffer(U32 Mask, PVOID Buffer, U32 Length);
|
||||
|
||||
#define DbgPrint(_x_) DebugPrint _x_ ;
|
||||
#define DPRINT1 DebugPrint1
|
||||
#define BugCheck(_x_) { DebugPrint(DPRINT_WARNING, "Fatal Error: %s:%d(%s)\n", __FILE__, __LINE__, __FUNCTION__); DebugPrint _x_ ; for (;;); }
|
||||
#define DbgDumpBuffer(_x_, _y_, _z_) DebugDumpBuffer(_x_, _y_, _z_)
|
||||
|
||||
#ifdef __i386__
|
||||
|
||||
// Debugging support functions:
|
||||
//
|
||||
// BREAKPOINT() - Inserts an "int 3" instruction
|
||||
// INSTRUCTION_BREAKPOINTX(x) - Enters exception handler right before instruction at address "x" is executed
|
||||
// MEMORY_READWRITE_BREAKPOINTX(x) - Enters exception handler when a read or write occurs at address "x"
|
||||
// MEMORY_WRITE_BREAKPOINTX(x) - Enters exception handler when a write occurs at address "x"
|
||||
//
|
||||
// You may have as many BREAKPOINT()'s as you like but you may only
|
||||
// have up to four of any of the others.
|
||||
#define BREAKPOINT() __asm__ ("int $3");
|
||||
void INSTRUCTION_BREAKPOINT1(unsigned long addr);
|
||||
void MEMORY_READWRITE_BREAKPOINT1(unsigned long addr);
|
||||
void MEMORY_WRITE_BREAKPOINT1(unsigned long addr);
|
||||
void INSTRUCTION_BREAKPOINT2(unsigned long addr);
|
||||
void MEMORY_READWRITE_BREAKPOINT2(unsigned long addr);
|
||||
void MEMORY_WRITE_BREAKPOINT2(unsigned long addr);
|
||||
void INSTRUCTION_BREAKPOINT3(unsigned long addr);
|
||||
void MEMORY_READWRITE_BREAKPOINT3(unsigned long addr);
|
||||
void MEMORY_WRITE_BREAKPOINT3(unsigned long addr);
|
||||
void INSTRUCTION_BREAKPOINT4(unsigned long addr);
|
||||
void MEMORY_READWRITE_BREAKPOINT4(unsigned long addr);
|
||||
void MEMORY_WRITE_BREAKPOINT4(unsigned long addr);
|
||||
|
||||
#endif // defined __i386__
|
||||
|
||||
#else
|
||||
|
||||
#define DebugInit()
|
||||
#define DbgPrint(_x_)
|
||||
#define DPRINT1(_x_)
|
||||
#define BugCheck(_x_)
|
||||
#define DbgDumpBuffer(_x_, _y_, _z_)
|
||||
|
||||
#endif // defined DEBUG
|
||||
|
||||
#define UNIMPLEMENTED() BugCheck((DPRINT_WARNING, "This function is unimplemented!\n"))
|
||||
|
||||
#endif // defined __DEBUG_H
|
139
freeldr/freeldr/include/disk.h
Normal file
139
freeldr/freeldr/include/disk.h
Normal file
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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
|
||||
{
|
||||
U32 Cylinders; // Number of cylinders on the disk
|
||||
U32 Heads; // Number of heads on the disk
|
||||
U32 Sectors; // Number of sectors per track
|
||||
U32 BytesPerSector; // Number of bytes per sector
|
||||
|
||||
} GEOMETRY, *PGEOMETRY;
|
||||
|
||||
//
|
||||
// Extended disk geometry (Int13 / ah=48h)
|
||||
//
|
||||
typedef struct _EXTENDED_GEOMETRY
|
||||
{
|
||||
U16 Size;
|
||||
U16 Flags;
|
||||
U32 Cylinders;
|
||||
U32 Heads;
|
||||
U32 SectorsPerTrack;
|
||||
U64 Sectors;
|
||||
U16 BytesPerSector;
|
||||
U32 PDPTE;
|
||||
} __attribute__((packed)) EXTENDED_GEOMETRY, *PEXTENDED_GEOMETRY;
|
||||
|
||||
//
|
||||
// Define the structure of a partition table entry
|
||||
//
|
||||
typedef struct _PARTITION_TABLE_ENTRY
|
||||
{
|
||||
U8 BootIndicator; // 0x00 - non-bootable partition, 0x80 - bootable partition (one partition only)
|
||||
U8 StartHead; // Beginning head number
|
||||
U8 StartSector; // Beginning sector (2 high bits of cylinder #)
|
||||
U8 StartCylinder; // Beginning cylinder# (low order bits of cylinder #)
|
||||
U8 SystemIndicator; // System indicator
|
||||
U8 EndHead; // Ending head number
|
||||
U8 EndSector; // Ending sector (2 high bits of cylinder #)
|
||||
U8 EndCylinder; // Ending cylinder# (low order bits of cylinder #)
|
||||
U32 SectorCountBeforePartition; // Number of sectors preceding the partition
|
||||
U32 PartitionSectorCount; // Number of sectors in the partition
|
||||
|
||||
} PACKED PARTITION_TABLE_ENTRY, *PPARTITION_TABLE_ENTRY;
|
||||
|
||||
//
|
||||
// Define the structure of the master boot record
|
||||
//
|
||||
typedef struct _MASTER_BOOT_RECORD
|
||||
{
|
||||
U8 MasterBootRecordCodeAndData[0x1b8]; /* 0x000 */
|
||||
U32 Signature; /* 0x1B8 */
|
||||
U16 Reserved; /* 0x1BC */
|
||||
PARTITION_TABLE_ENTRY PartitionTable[4]; /* 0x1BE */
|
||||
U16 MasterBootRecordMagic; /* 0x1FE */
|
||||
|
||||
} PACKED MASTER_BOOT_RECORD, *PMASTER_BOOT_RECORD;
|
||||
|
||||
//
|
||||
// Partition type defines
|
||||
//
|
||||
#define PARTITION_ENTRY_UNUSED 0x00 // Entry unused
|
||||
#define PARTITION_FAT_12 0x01 // 12-bit FAT entries
|
||||
#define PARTITION_XENIX_1 0x02 // Xenix
|
||||
#define PARTITION_XENIX_2 0x03 // Xenix
|
||||
#define PARTITION_FAT_16 0x04 // 16-bit FAT entries
|
||||
#define PARTITION_EXTENDED 0x05 // Extended partition entry
|
||||
#define PARTITION_HUGE 0x06 // Huge partition MS-DOS V4
|
||||
#define PARTITION_IFS 0x07 // IFS Partition
|
||||
#define PARTITION_OS2BOOTMGR 0x0A // OS/2 Boot Manager/OPUS/Coherent swap
|
||||
#define PARTITION_FAT32 0x0B // FAT32
|
||||
#define PARTITION_FAT32_XINT13 0x0C // FAT32 using extended int13 services
|
||||
#define PARTITION_XINT13 0x0E // Win95 partition using extended int13 services
|
||||
#define PARTITION_XINT13_EXTENDED 0x0F // Same as type 5 but uses extended int13 services
|
||||
#define PARTITION_NTFS 0x17 // NTFS
|
||||
#define PARTITION_PREP 0x41 // PowerPC Reference Platform (PReP) Boot Partition
|
||||
#define PARTITION_LDM 0x42 // Logical Disk Manager partition
|
||||
#define PARTITION_UNIX 0x63 // Unix
|
||||
#define PARTITION_LINUX_SWAP 0x82 // Linux Swap Partition
|
||||
#define PARTITION_EXT2 0x83 // Linux Ext2/Ext3
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// i386 BIOS Disk Functions (i386disk.c)
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef __i386__
|
||||
|
||||
BOOL DiskResetController(U32 DriveNumber);
|
||||
BOOL DiskInt13ExtensionsSupported(U32 DriveNumber);
|
||||
//VOID DiskStopFloppyMotor(VOID);
|
||||
BOOL DiskGetExtendedDriveParameters(U32 DriveNumber, PVOID Buffer, U16 BufferSize);
|
||||
|
||||
#endif // defined __i386__
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FreeLoader Disk Functions
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
VOID DiskReportError (BOOL bError);
|
||||
VOID DiskError(PUCHAR ErrorString, U32 ErrorCode);
|
||||
PUCHAR DiskGetErrorCodeString(U32 ErrorCode);
|
||||
BOOL DiskReadLogicalSectors(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer); // Implemented in i386disk.c
|
||||
BOOL DiskIsDriveRemovable(U32 DriveNumber);
|
||||
VOID DiskStopFloppyMotor(VOID); // Implemented in i386disk.c
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Fixed Disk Partition Management Functions
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
BOOL DiskGetActivePartitionEntry(U32 DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
|
||||
BOOL DiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
|
||||
BOOL DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry);
|
||||
BOOL DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry);
|
||||
BOOL DiskReadBootRecord(U32 DriveNumber, U64 LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord);
|
||||
|
||||
#endif // defined __DISK_H
|
43
freeldr/freeldr/include/drivemap.h
Normal file
43
freeldr/freeldr/include/drivemap.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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 __DRIVEMAP_H
|
||||
#define __DRIVEMAP_H
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U8 DriveMapCount; // Count of drives currently mapped
|
||||
|
||||
U8 DriveMap[8]; // Map of BIOS drives
|
||||
|
||||
} PACKED DRIVE_MAP_LIST, *PDRIVE_MAP_LIST;
|
||||
|
||||
VOID DriveMapMapDrivesInSection(PUCHAR SectionName);
|
||||
BOOL DriveMapIsValidDriveString(PUCHAR DriveString); // Checks the drive string ("hd0") for validity
|
||||
U32 DriveMapGetBiosDriveNumber(PUCHAR DeviceName); // Returns a BIOS drive number for any given device name (e.g. 0x80 for 'hd0')
|
||||
VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap); // Installs the int 13h handler for the drive mapper
|
||||
VOID DriveMapRemoveInt13Handler(VOID); // Removes a previously installed int 13h drive map handler
|
||||
|
||||
extern PVOID DriveMapInt13HandlerStart;
|
||||
extern PVOID DriveMapInt13HandlerEnd;
|
||||
extern U32 DriveMapOldInt13HandlerAddress;
|
||||
extern DRIVE_MAP_LIST DriveMapInt13HandlerMapList;
|
||||
|
||||
#endif // #defined __DRIVEMAP_H
|
81
freeldr/freeldr/include/freeldr.h
Normal file
81
freeldr/freeldr/include/freeldr.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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 __FREELDR_H
|
||||
#define __FREELDR_H
|
||||
|
||||
#define NULL 0
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#define BOOL int
|
||||
#define BOOLEAN int
|
||||
typedef BOOLEAN *PBOOLEAN;
|
||||
|
||||
#define CHAR char
|
||||
#define PCHAR char *
|
||||
#define UCHAR unsigned char
|
||||
#define PUCHAR unsigned char *
|
||||
#define WCHAR unsigned short
|
||||
#define PWCHAR unsigned short *
|
||||
|
||||
#define VOID void
|
||||
#define PVOID VOID*
|
||||
|
||||
#ifdef __i386__
|
||||
|
||||
#define size_t unsigned int
|
||||
|
||||
typedef unsigned char U8;
|
||||
typedef char S8;
|
||||
typedef unsigned short U16;
|
||||
typedef short S16;
|
||||
typedef unsigned long U32;
|
||||
typedef long S32;
|
||||
typedef unsigned long long U64;
|
||||
typedef long long S64;
|
||||
|
||||
typedef U8 __u8;
|
||||
typedef S8 __s8;
|
||||
typedef U16 __u16;
|
||||
typedef S16 __s16;
|
||||
typedef U32 __u32;
|
||||
typedef S32 __s32;
|
||||
typedef U64 __u64;
|
||||
typedef S64 __s64;
|
||||
|
||||
#endif // __i386__
|
||||
|
||||
typedef U8 *PU8;
|
||||
typedef U16 *PU16;
|
||||
typedef U32 *PU32;
|
||||
|
||||
#define ROUND_UP(N, S) ((N) + (S) - ((N) % (S)))
|
||||
#define ROUND_DOWN(N, S) ((N) - ((N) % (S)))
|
||||
|
||||
#define PACKED __attribute__((packed))
|
||||
|
||||
extern U32 BootDrive; // BIOS boot drive, 0-A:, 1-B:, 0x80-C:, 0x81-D:, etc.
|
||||
extern U32 BootPartition; // Boot Partition, 1-4
|
||||
extern BOOL UserInterfaceUp; // Tells us if the user interface is displayed
|
||||
|
||||
void BootMain(char *CmdLine);
|
||||
VOID RunLoader(VOID);
|
||||
|
||||
#endif // defined __FREELDR_H
|
47
freeldr/freeldr/include/fs.h
Normal file
47
freeldr/freeldr/include/fs.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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 __FS_H
|
||||
#define __FS_H
|
||||
|
||||
|
||||
#define EOF -1
|
||||
|
||||
#define FS_FAT 1
|
||||
#define FS_NTFS 2
|
||||
#define FS_EXT2 3
|
||||
#define FS_REISER 4
|
||||
#define FS_ISO9660 5
|
||||
|
||||
#define FILE VOID
|
||||
#define PFILE FILE *
|
||||
|
||||
VOID FileSystemError(PUCHAR ErrorString);
|
||||
BOOL FsOpenVolume(U32 DriveNumber, U32 PartitionNumber);
|
||||
PFILE FsOpenFile(PUCHAR FileName);
|
||||
VOID FsCloseFile(PFILE FileHandle);
|
||||
BOOL FsReadFile(PFILE FileHandle, U32 BytesToRead, U32* BytesRead, PVOID Buffer);
|
||||
U32 FsGetFileSize(PFILE FileHandle);
|
||||
VOID FsSetFilePointer(PFILE FileHandle, U32 NewFilePointer);
|
||||
U32 FsGetFilePointer(PFILE FileHandle);
|
||||
BOOL FsIsEndOfFile(PFILE FileHandle);
|
||||
U32 FsGetNumPathParts(PUCHAR Path);
|
||||
VOID FsGetFirstNameFromPath(PUCHAR Buffer, PUCHAR Path);
|
||||
|
||||
#endif // #defined __FS_H
|
@@ -16,7 +16,7 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id$
|
||||
/* $Id: inffile.h,v 1.1 2003/05/25 21:17:30 ekohl Exp $
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS text-mode setup
|
||||
* FILE: subsys/system/usetup/infcache.h
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#define MAX_INF_STRING_LENGTH 512
|
||||
|
||||
typedef PULONG HINF, *PHINF;
|
||||
typedef PU32 HINF, *PHINF;
|
||||
|
||||
typedef struct _INFCONTEXT
|
||||
{
|
||||
@@ -52,7 +52,7 @@ typedef struct _INFCONTEXT
|
||||
BOOLEAN
|
||||
InfOpenFile (PHINF InfHandle,
|
||||
PCHAR FileName,
|
||||
PULONG ErrorLine);
|
||||
PU32 ErrorLine);
|
||||
|
||||
VOID
|
||||
InfCloseFile (HINF InfHandle);
|
||||
@@ -79,39 +79,39 @@ InfFindNextMatchLine (PINFCONTEXT ContextIn,
|
||||
PINFCONTEXT ContextOut);
|
||||
|
||||
|
||||
LONG
|
||||
S32
|
||||
InfGetLineCount (HINF InfHandle,
|
||||
PCHAR Section);
|
||||
|
||||
LONG
|
||||
S32
|
||||
InfGetFieldCount (PINFCONTEXT Context);
|
||||
|
||||
|
||||
BOOLEAN
|
||||
InfGetBinaryField (PINFCONTEXT Context,
|
||||
ULONG FieldIndex,
|
||||
PUCHAR ReturnBuffer,
|
||||
ULONG ReturnBufferSize,
|
||||
PULONG RequiredSize);
|
||||
U32 FieldIndex,
|
||||
PU8 ReturnBuffer,
|
||||
U32 ReturnBufferSize,
|
||||
PU32 RequiredSize);
|
||||
|
||||
BOOLEAN
|
||||
InfGetIntField (PINFCONTEXT Context,
|
||||
ULONG FieldIndex,
|
||||
LONG *IntegerValue);
|
||||
U32 FieldIndex,
|
||||
S32 *IntegerValue);
|
||||
|
||||
BOOLEAN
|
||||
InfGetMultiSzField (PINFCONTEXT Context,
|
||||
ULONG FieldIndex,
|
||||
U32 FieldIndex,
|
||||
PCHAR ReturnBuffer,
|
||||
ULONG ReturnBufferSize,
|
||||
PULONG RequiredSize);
|
||||
U32 ReturnBufferSize,
|
||||
PU32 RequiredSize);
|
||||
|
||||
BOOLEAN
|
||||
InfGetStringField (PINFCONTEXT Context,
|
||||
ULONG FieldIndex,
|
||||
U32 FieldIndex,
|
||||
PCHAR ReturnBuffer,
|
||||
ULONG ReturnBufferSize,
|
||||
PULONG RequiredSize);
|
||||
U32 ReturnBufferSize,
|
||||
PU32 RequiredSize);
|
||||
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ InfGetData (PINFCONTEXT Context,
|
||||
|
||||
BOOLEAN
|
||||
InfGetDataField (PINFCONTEXT Context,
|
||||
ULONG FieldIndex,
|
||||
U32 FieldIndex,
|
||||
PCHAR *Data);
|
||||
|
||||
#endif /* __INFCACHE_H__ */
|
35
freeldr/freeldr/include/inifile.h
Normal file
35
freeldr/freeldr/include/inifile.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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 __PARSEINI_H
|
||||
#define __PARSEINI_H
|
||||
|
||||
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
|
139
freeldr/freeldr/include/linux.h
Normal file
139
freeldr/freeldr/include/linux.h
Normal file
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* 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 <fs.h>
|
||||
|
||||
#ifndef __LINUX_H
|
||||
#define __LINUX_H
|
||||
|
||||
|
||||
#define LINUX_LOADER_TYPE_LILO 0x01
|
||||
#define LINUX_LOADER_TYPE_LOADLIN 0x11
|
||||
#define LINUX_LOADER_TYPE_BOOTSECT 0x21
|
||||
#define LINUX_LOADER_TYPE_SYSLINUX 0x31
|
||||
#define LINUX_LOADER_TYPE_ETHERBOOT 0x41
|
||||
#define LINUX_LOADER_TYPE_FREELOADER 0x81
|
||||
|
||||
#define LINUX_COMMAND_LINE_MAGIC 0xA33F
|
||||
|
||||
#define LINUX_SETUP_HEADER_ID 0x53726448 // 'HdrS'
|
||||
|
||||
#define LINUX_BOOT_SECTOR_MAGIC 0xAA55
|
||||
|
||||
#define LINUX_KERNEL_LOAD_ADDRESS 0x100000
|
||||
|
||||
#define LINUX_FLAG_LOAD_HIGH 0x01
|
||||
#define LINUX_FLAG_CAN_USE_HEAP 0x80
|
||||
|
||||
#define LINUX_MAX_INITRD_ADDRESS 0x38000000
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U8 BootCode1[0x20];
|
||||
|
||||
U16 CommandLineMagic;
|
||||
U16 CommandLineOffset;
|
||||
|
||||
U8 BootCode2[0x1CD];
|
||||
|
||||
U8 SetupSectors;
|
||||
U16 RootFlags;
|
||||
U16 SystemSize;
|
||||
U16 SwapDevice;
|
||||
U16 RamSize;
|
||||
U16 VideoMode;
|
||||
U16 RootDevice;
|
||||
U16 BootFlag; // 0xAA55
|
||||
|
||||
} PACKED LINUX_BOOTSECTOR, *PLINUX_BOOTSECTOR;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
U8 JumpInstruction[2];
|
||||
U32 SetupHeaderSignature; // Signature for SETUP-header
|
||||
U16 Version; // Version number of header format
|
||||
U16 RealModeSwitch; // Default switch
|
||||
U16 SetupSeg; // SETUPSEG
|
||||
U16 StartSystemSeg;
|
||||
U16 KernelVersion; // Offset to kernel version string
|
||||
U8 TypeOfLoader; // Loader ID
|
||||
// =0, old one (LILO, Loadlin,
|
||||
// Bootlin, SYSLX, bootsect...)
|
||||
// else it is set by the loader:
|
||||
// 0xTV: T=0 for LILO
|
||||
// T=1 for Loadlin
|
||||
// T=2 for bootsect-loader
|
||||
// T=3 for SYSLX
|
||||
// T=4 for ETHERBOOT
|
||||
// V = version
|
||||
|
||||
U8 LoadFlags; // flags, unused bits must be zero (RFU)
|
||||
// LOADED_HIGH = 1
|
||||
// bit within loadflags,
|
||||
// if set, then the kernel is loaded high
|
||||
// CAN_USE_HEAP = 0x80
|
||||
// if set, the loader also has set heap_end_ptr
|
||||
// to tell how much space behind setup.S
|
||||
// can be used for heap purposes.
|
||||
// Only the loader knows what is free!
|
||||
|
||||
U16 SetupMoveSize; // size to move, when we (setup) are not
|
||||
// loaded at 0x90000. We will move ourselves
|
||||
// to 0x90000 then just before jumping into
|
||||
// the kernel. However, only the loader
|
||||
// know how much of data behind us also needs
|
||||
// to be loaded.
|
||||
|
||||
U32 Code32Start; // here loaders can put a different
|
||||
// start address for 32-bit code.
|
||||
//
|
||||
// 0x1000 = default for zImage
|
||||
//
|
||||
// 0x100000 = default for big kernel
|
||||
|
||||
U32 RamdiskAddress; // address of loaded ramdisk image
|
||||
// Here the loader (or kernel generator) puts
|
||||
// the 32-bit address were it loaded the image.
|
||||
U32 RamdiskSize; // its size in bytes
|
||||
|
||||
U16 BootSectKludgeOffset;
|
||||
U16 BootSectKludgeSegment;
|
||||
U16 HeapEnd; // space from here (exclusive) down to
|
||||
// end of setup code can be used by setup
|
||||
// for local heap purposes.
|
||||
U16 Pad1;
|
||||
U32 CommandLinePointer; // 32-bit pointer to the kernel command line
|
||||
U32 InitrdAddressMax; // Highest legal initrd address
|
||||
|
||||
|
||||
} PACKED LINUX_SETUPSECTOR, *PLINUX_SETUPSECTOR;
|
||||
|
||||
VOID BootNewLinuxKernel(VOID); // Implemented in linux.S
|
||||
VOID BootOldLinuxKernel(U32 KernelSize); // Implemented in linux.S
|
||||
|
||||
VOID LoadAndBootLinux(PUCHAR OperatingSystemName, PUCHAR Description);
|
||||
|
||||
BOOL LinuxParseIniSection(PUCHAR OperatingSystemName);
|
||||
BOOL LinuxReadBootSector(PFILE LinuxKernelFile);
|
||||
BOOL LinuxReadSetupSector(PFILE LinuxKernelFile);
|
||||
BOOL LinuxReadKernel(PFILE LinuxKernelFile);
|
||||
BOOL LinuxCheckKernelVersion(VOID);
|
||||
BOOL LinuxReadInitrd(PFILE LinuxInitrdFile);
|
||||
|
||||
#endif // defined __LINUX_H
|
99
freeldr/freeldr/include/machine.h
Normal file
99
freeldr/freeldr/include/machine.h
Normal file
@@ -0,0 +1,99 @@
|
||||
/* $Id: machine.h,v 1.7 2004/11/28 22:42:40 gvg Exp $
|
||||
*
|
||||
* FreeLoader
|
||||
*
|
||||
* 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 __MACHINE_H_
|
||||
#define __MACHINE_H_
|
||||
|
||||
#ifndef __DISK_H
|
||||
#include "disk.h"
|
||||
#endif
|
||||
|
||||
#ifndef __MEMORY_H
|
||||
#include "mm.h"
|
||||
#endif
|
||||
|
||||
typedef enum tagVIDEODISPLAYMODE
|
||||
{
|
||||
VideoTextMode,
|
||||
VideoGraphicsMode
|
||||
} VIDEODISPLAYMODE, *PVIDEODISPLAYMODE;
|
||||
|
||||
typedef struct tagMACHVTBL
|
||||
{
|
||||
VOID (*ConsPutChar)(int Ch);
|
||||
BOOL (*ConsKbHit)(VOID);
|
||||
int (*ConsGetCh)(VOID);
|
||||
|
||||
VOID (*VideoClearScreen)(U8 Attr);
|
||||
VIDEODISPLAYMODE (*VideoSetDisplayMode)(char *DisplayMode, BOOL Init);
|
||||
VOID (*VideoGetDisplaySize)(PU32 Width, PU32 Height, PU32 Depth);
|
||||
U32 (*VideoGetBufferSize)(VOID);
|
||||
VOID (*VideoSetTextCursorPosition)(U32 X, U32 Y);
|
||||
VOID (*VideoHideShowTextCursor)(BOOL Show);
|
||||
VOID (*VideoPutChar)(int Ch, U8 Attr, unsigned X, unsigned Y);
|
||||
VOID (*VideoCopyOffScreenBufferToVRAM)(PVOID Buffer);
|
||||
BOOL (*VideoIsPaletteFixed)(VOID);
|
||||
VOID (*VideoSetPaletteColor)(U8 Color, U8 Red, U8 Green, U8 Blue);
|
||||
VOID (*VideoGetPaletteColor)(U8 Color, U8* Red, U8* Green, U8* Blue);
|
||||
VOID (*VideoSync)(VOID);
|
||||
VOID (*VideoPrepareForReactOS)(VOID);
|
||||
|
||||
U32 (*GetMemoryMap)(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize);
|
||||
|
||||
BOOL (*DiskReadLogicalSectors)(U32 DriveNumber, U64 SectorNumber, U32 SectorCount, PVOID Buffer);
|
||||
BOOL (*DiskGetPartitionEntry)(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
|
||||
BOOL (*DiskGetDriveGeometry)(U32 DriveNumber, PGEOMETRY DriveGeometry);
|
||||
U32 (*DiskGetCacheableBlockCount)(U32 DriveNumber);
|
||||
|
||||
VOID (*RTCGetCurrentDateTime)(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second);
|
||||
|
||||
VOID (*HwDetect)(VOID);
|
||||
} MACHVTBL, *PMACHVTBL;
|
||||
|
||||
VOID MachInit(VOID);
|
||||
|
||||
extern MACHVTBL MachVtbl;
|
||||
|
||||
#define MachConsPutChar(Ch) MachVtbl.ConsPutChar(Ch)
|
||||
#define MachConsKbHit() MachVtbl.ConsKbHit()
|
||||
#define MachConsGetCh() MachVtbl.ConsGetCh()
|
||||
#define MachVideoClearScreen(Attr) MachVtbl.VideoClearScreen(Attr)
|
||||
#define MachVideoSetDisplayMode(Mode, Init) MachVtbl.VideoSetDisplayMode((Mode), (Init))
|
||||
#define MachVideoGetDisplaySize(W, H, D) MachVtbl.VideoGetDisplaySize((W), (H), (D))
|
||||
#define MachVideoGetBufferSize() MachVtbl.VideoGetBufferSize()
|
||||
#define MachVideoSetTextCursorPosition(X, Y) MachVtbl.VideoSetTextCursorPosition((X), (Y))
|
||||
#define MachVideoHideShowTextCursor(Show) MachVtbl.VideoHideShowTextCursor(Show)
|
||||
#define MachVideoPutChar(Ch, Attr, X, Y) MachVtbl.VideoPutChar((Ch), (Attr), (X), (Y))
|
||||
#define MachVideoCopyOffScreenBufferToVRAM(Buf) MachVtbl.VideoCopyOffScreenBufferToVRAM(Buf)
|
||||
#define MachVideoIsPaletteFixed() MachVtbl.VideoIsPaletteFixed()
|
||||
#define MachVideoSetPaletteColor(Col, R, G, B) MachVtbl.VideoSetPaletteColor((Col), (R), (G), (B))
|
||||
#define MachVideoGetPaletteColor(Col, R, G, B) MachVtbl.VideoGetPaletteColor((Col), (R), (G), (B))
|
||||
#define MachVideoSync() MachVtbl.VideoSync()
|
||||
#define MachVideoPrepareForReactOS() MachVtbl.VideoPrepareForReactOS()
|
||||
#define MachGetMemoryMap(MMap, Size) MachVtbl.GetMemoryMap((MMap), (Size))
|
||||
#define MachDiskReadLogicalSectors(Drive, Start, Count, Buf) MachVtbl.DiskReadLogicalSectors((Drive), (Start), (Count), (Buf))
|
||||
#define MachDiskGetPartitionEntry(Drive, Part, Entry) MachVtbl.DiskGetPartitionEntry((Drive), (Part), (Entry))
|
||||
#define MachDiskGetDriveGeometry(Drive, Geom) MachVtbl.DiskGetDriveGeometry((Drive), (Geom))
|
||||
#define MachDiskGetCacheableBlockCount(Drive) MachVtbl.DiskGetCacheableBlockCount(Drive)
|
||||
#define MachRTCGetCurrentDateTime(Y, Mo, D, H, Mi, S) MachVtbl.RTCGetCurrentDateTime((Y), (Mo), (D), (H), (Mi), (S));
|
||||
#define MachHwDetect() MachVtbl.HwDetect()
|
||||
|
||||
#endif /* __MACHINE_H_ */
|
||||
|
||||
/* EOF */
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user