Removed code to save screen contents before entering freeldr

Moved all architecture specific code to the arch & arch/i386 directories
Renamed asmcode.* to arch.*

svn path=/trunk/; revision=2545
This commit is contained in:
Brian Palmer 2002-01-23 19:57:42 +00:00
parent fd75e7d985
commit 198a544138
22 changed files with 635 additions and 582 deletions

View file

@ -276,24 +276,6 @@ LoadFile:
push ax ; First save AX - the start cluster of freeldr.sys
; Lets save the contents of the screen
; from B800:0000 to 9000:8000
push ds
mov ax,0b800h
mov ds,ax
xor si,si
mov ax,9800h
mov es,ax
xor di,di
mov cx,2000 ; Copy 2000 characters [words] (screen is 80x25)
rep movsw ; 2 bytes a character (one is the attribute byte)
pop ds
mov ah,03h ; AH = 03h
xor bx,bx ; BH = video page
int 10h ; BIOS Int 10h Func 3 - Read Cursor Position and Size
mov [es:di],dx ; DH = row, DL = column
; Display "Loading FreeLoader..." message
mov si,msgLoading ; Loading message
call PutChars ; Display it

View file

@ -332,24 +332,6 @@ FindFile:
FoundFile:
; Lets save the contents of the screen
; from B800:0000 to 9000:8000
pushad
mov ax,0b800h
mov ds,ax
xor si,si
mov ax,9800h
mov es,ax
xor di,di
mov cx,2000 ; Copy 2000 characters (screen is 80x25)
rep movsw ; 2 bytes a character (one is the attribute byte)
mov ah,03h ; AH = 03h
xor bx,bx ; BH = video page
int 10h ; BIOS Int 10h Func 3 - Read Cursor Position and Size
mov [es:di],dx ; DH = row, DL = column
; Display "Loading FreeLoader..." message
mov si,msgLoading ; Loading message
call PutChars ; Display it

View file

@ -23,47 +23,36 @@ include rules.mk
#OBJS = asmcode.a asmcode.o mb.o boot.o freeldr.o rtl.o fs.a fs.o fat.o \
# reactos.o tui.o menu.o miscboot.o options.o linux.o multiboot.o arcname.o \
# mem.o memory.o debug.o parseini.o registry.o import.o
ASM_OBJS = asmcode.o mb.o boot.o mem.o
#ASM_OBJS = asmcode.o mb.o boot.o mem.o
OBJS = freeldr.o miscboot.o options.o linux.o multiboot.o debug.o parseini.o oslist.o
LIBS = rtl fs ui reactos comm disk mm cache
LIB_FILES = rtl/rtl.a fs/fs.a ui/ui.a reactos/reactos.a comm/comm.a disk/disk.a mm/mm.a cache/cache.a
LIBS = arch rtl fs ui reactos comm disk mm cache
LIB_FILES = arch/arch.a rtl/rtl.a fs/fs.a ui/ui.a reactos/reactos.a
LIB_FILES2 = comm/comm.a disk/disk.a mm/mm.a cache/cache.a
.PHONY : clean
all: freeldr.sys
freeldr.sys: asmcode.a c_code.a
$(LD) -N -Ttext=0x8000 --oformat=binary -s -o f.sys asmcode.a c_code.a
freeldr.sys: c_code.a
$(LD) -N -Ttext=0x8000 --oformat=binary -s -o f.sys c_code.a
../bootsect/stubit ../bootsect/fatstub.bin f.sys freeldr.sys
freeldr.exe: asmcode.a c_code.a
$(LD) -o freeldr.exe asmcode.a c_code.a
asmcode.a: $(ASM_OBJS)
$(LD) -r -o asmcode.a $(ASM_OBJS)
c_code.a: $(LIBS) c_code1.a c_code2.a
$(LD) -r -o c_code.a $(LIB_FILES) c_code1.a c_code2.a
c_code.a: c_code1.a $(LIBS)
$(LD) -r -o c_code.a c_code1.a $(LIB_FILES)
c_code1.a: $(LIBS)
$(LD) -r -o c_code1.a $(LIB_FILES2)
c_code1.a: $(OBJS)
$(LD) -r -o c_code1.a $(OBJS)
c_code2.a: $(OBJS)
$(LD) -r -o c_code2.a $(OBJS)
asmcode.o: asmcode.S asmcode.h
$(CC) $(FLAGS) -o asmcode.o -c asmcode.S
mb.o: mb.S asmcode.h multiboot.h
$(CC) $(FLAGS) -o mb.o -c mb.S
boot.o: boot.S asmcode.h
$(CC) $(FLAGS) -o boot.o -c boot.S
mem.o: mem.S asmcode.h
$(CC) $(FLAGS) -o mem.o -c mem.S
freeldr.o: freeldr.c freeldr.h rtl.h fs.h reactos.h ui.h asmcode.h miscboot.h
freeldr.o: freeldr.c freeldr.h rtl.h fs.h reactos.h ui.h arch.h miscboot.h
$(CC) $(FLAGS) -o freeldr.o -c freeldr.c
miscboot.o: miscboot.c freeldr.h asmcode.h rtl.h fs.h ui.h miscboot.h
miscboot.o: miscboot.c freeldr.h arch.h rtl.h fs.h ui.h miscboot.h
$(CC) $(FLAGS) -o miscboot.o -c miscboot.c
options.o: options.c freeldr.h rtl.h ui.h options.h
@ -75,15 +64,18 @@ linux.o: linux.c freeldr.h rtl.h ui.h linux.h
multiboot.o: multiboot.c freeldr.h rtl.h fs.h multiboot.h ui.h
$(CC) $(FLAGS) -o multiboot.o -c multiboot.c
debug.o: debug.c debug.h Makefile
debug.o: debug.c debug.h
$(CC) $(FLAGS) -o debug.o -c debug.c
parseini.o: parseini.c parseini.h Makefile
parseini.o: parseini.c parseini.h
$(CC) $(FLAGS) -o parseini.o -c parseini.c
oslist.o: oslist.c oslist.h Makefile
oslist.o: oslist.c oslist.h
$(CC) $(FLAGS) -o oslist.o -c oslist.c
arch:
$(MAKE) -C arch
rtl:
$(MAKE) -C rtl
@ -114,6 +106,7 @@ clean:
- $(RM) *.o
- $(RM) *.a
- $(RM) *.sys
$(MAKE) -C arch clean
$(MAKE) -C reactos clean
$(MAKE) -C comm clean
$(MAKE) -C disk clean

View file

@ -43,10 +43,6 @@
#define DISKREADBUFFER 0x90000 /* Buffer to store data read in from the disk via the BIOS */
#define SCREENBUFFER 0x98000 /* The screen contents will be saved here */
#define SCREENXCOORD 0x98FA0 /* Address of the byte that contains the current column of the cursor */
#define SCREENYCOORD 0x98FA1 /* Address of the byte that contains the current row of the cursor */
/* Makes "x" a global variable or label */
#define EXTERN(x) .global x; x:

View file

@ -0,0 +1,33 @@
#
# 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.
#
include ../rules.mk
TARGET = i386
.PHONY : clean
all: arch.a
arch.a:
$(MAKE) -C $(TARGET)
clean:
- $(RM) *.a
$(MAKE) -C $(TARGET) clean

View file

@ -0,0 +1,50 @@
#
# 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.
#
include ../../rules.mk
OBJS = arch.o boot.o mb.o mem.o disk.o
.PHONY : clean
all: arch.a
arch.a: $(OBJS)
$(LD) -r -o arch.a $(OBJS)
- $(RM) ..\arch.a
$(CP) arch.a ..\arch.a
arch.o: arch.S
$(CC) $(FLAGS) -o arch.o -c arch.S
boot.o: boot.S
$(CC) $(FLAGS) -o boot.o -c boot.S
mb.o: mb.S
$(CC) $(FLAGS) -o mb.o -c mb.S
mem.o: mem.S
$(CC) $(FLAGS) -o mem.o -c mem.S
disk.o: disk.S
$(CC) $(FLAGS) -o disk.o -c disk.S
clean:
- $(RM) *.o
- $(RM) *.a

View file

@ -21,7 +21,7 @@
.code16
#define ASM
#include "asmcode.h"
#include "arch.h"
EXTERN(start)
@ -375,312 +375,6 @@ EXTERN(_gotoxy)
pop %ebp
ret
/*
* BOOL BiosInt13Read(ULONG Drive, ULONG Head, ULONG Track, ULONG Sector, ULONG SectorCount, PVOID Buffer);
*/
_biosdisk_drive:
.long 0
_biosdisk_head:
.long 0
_biosdisk_track:
.long 0
_biosdisk_sector:
.long 0
_biosdisk_nsects:
.long 0
_biosdisk_buffer:
.long 0
_biosdisk_retval:
.long 0
_biosdisk_retrycount:
.byte 0
_biosdisk_error_code:
.byte 0
EXTERN(_BiosInt13Read)
.code32
push %ebp
push %esi
push %edi
push %ebx
push %ecx
push %edx
/* Get parameters */
movl 0x1c(%esp),%eax
movl %eax,_biosdisk_drive
movl 0x20(%esp),%eax
movl %eax,_biosdisk_head
movl 0x24(%esp),%eax
movl %eax,_biosdisk_track
movl 0x28(%esp),%eax
movl %eax,_biosdisk_sector
movl 0x2c(%esp),%eax
movl %eax,_biosdisk_nsects
movl 0x30(%esp),%eax
movl %eax,_biosdisk_buffer
call switch_to_real
.code16
pushw %es // Save this just in case
movb $3,_biosdisk_retrycount // Set the retry count to 3
_biosdisk_read:
movl _biosdisk_buffer,%eax // Get buffer address in eax
shrl $4,%eax // Make linear address into segment
movw %ax,%es // Load ES with segment
movl _biosdisk_buffer,%ebx // and BX with offset
andl $0x0f,%ebx // so that data gets loaded to [ES:BX]
movb _biosdisk_sector,%cl // Get the sector in CL
movw _biosdisk_track,%ax // Cylinder in AX
movb %al,%ch // Now put it in CH
rorb $1,%ah // Low 8 bits of cylinder in CH, high 2 bits
rorb $1,%ah // in CL shifted to bits 6 & 7
andb $0xc0,%ah // Clear out low six bits
orb %ah,%cl // Or with sector number
movb _biosdisk_head,%dh // Get the head
movb _biosdisk_drive,%dl // Get the drive
movb $2,%ah // BIOS int 0x13, function 2 - Read Disk Sectors
movb _biosdisk_nsects,%al // Number of sectors to read
int $0x13 // Read a sector
// I have recently learned that not all bioses return
// the sector read count in the AL register (at least mine doesn't)
// even if the sectors were read correctly. So instead
// of checking the sector read count we will rely solely
// on the carry flag being set on error
//jmp _biosdisk_done
//cmpb _biosdisk_nsects,%al // See how many sectors we actually read
//jne _biosdisk_error // Jump if no error
movb $1,%al // Set the return value to be one (will be set to zero later if needed)
jc _biosdisk_error // Jump if error (CF = 1 on error)
jmp _biosdisk_done
_biosdisk_error:
movb %ah,_biosdisk_error_code// Save the error code
cmpb $0x11,%ah // Check and see if it was a corrected ECC error
je _biosdisk_done // If so then the data is still good, if not fail
movb _biosdisk_retrycount,%al// Get the current retry count
decb %al // Decrement it
movb %al,_biosdisk_retrycount// Save it
cmpb $0,%al // Is it zero?
jz _biosdisk_zero // Yes, return zero
movb $0,%ah // BIOS int 0x13, function 0 - Reset Disk System
movb _biosdisk_drive,%dl // Get the drive
int $0x13 // Reset the disk system
jmp _biosdisk_read // Try reading again
_biosdisk_zero:
movb $0,%al // We will return zero
_biosdisk_done:
movzbl %al,%eax // Put the number of sectors read into EAX
movl %eax,_biosdisk_retval // Save it as the return value
popw %es // Restore ES
call switch_to_prot
.code32
movl _biosdisk_retval,%eax // Get return value
//movl $1,%eax
pop %edx
pop %ecx
pop %ebx
pop %edi
pop %esi
pop %ebp
ret
/*
* BOOL BiosInt13ReadExtended(ULONG Drive, ULONG Sector, ULONG SectorCount, PVOID Buffer);
*/
_disk_address_packet:
_packet_size:
.byte 0x10
_packet_reserved:
.byte 0
_packet_sector_count:
.word 0
_packet_transfer_buffer_segment:
.word 0
_packet_transfer_buffer_offset:
.word 0
_packet_lba_sector_number:
.quad 0
_packet_64bit_flat_address:
.quad 0
_int13_extended_drive:
.long 0
_int13_extended_sector_count:
.long 0
_int13_extended_retval:
.long 0
_int13_extended_retrycount:
.byte 0
EXTERN(_BiosInt13ReadExtended)
.code32
push %ebp
push %esi
push %edi
push %ebx
push %ecx
push %edx
/* Get parameters */
movl 0x1c(%esp),%eax
movl %eax,_int13_extended_drive
movl 0x20(%esp),%eax
movl %eax,_packet_lba_sector_number
movl 0x24(%esp),%eax
movw %ax,_packet_sector_count
movl %eax,_int13_extended_sector_count
movl 0x28(%esp),%eax // Get buffer address in eax
shrl $4,%eax // Make linear address into segment
movw %ax,_packet_transfer_buffer_segment // Save segment
movl 0x28(%esp),%eax // Get buffer address in eax
andl $0x0f,%eax // Make linear address into offset
movw %ax,_packet_transfer_buffer_offset // Save offset
call switch_to_real
.code16
pushw %es // Save this just in case
movb $3,_int13_extended_retrycount // Set the retry count to 3
_int13_extended_read:
movb _int13_extended_drive,%dl // Get the drive
movb $42,%ah // BIOS int 0x13, function 42h - IBM/MS INT 13 Extensions - EXTENDED READ
movw $_disk_address_packet,%si // DS:SI -> disk address packet
int $0x13 // Read sectors
movb $1,%al // Set the return value to be one (will be set to zero later if needed)
jc _int13_extended_error // Jump if error (CF = 1 on error)
movl _int13_extended_sector_count,%eax // Get the sector count in eax
cmpw _packet_sector_count,%ax // See how many sectors we actually read (returned in disk address packet sector count)
jne _int13_extended_error // Jump if not equal
jmp _int13_extended_done
_int13_extended_error:
movb %ah,_biosdisk_error_code // Save the error code
cmpb $0x11,%ah // Check and see if it was a corrected ECC error
je _int13_extended_done // If so then the data is still good, if not fail
movb _int13_extended_retrycount,%al // Get the current retry count
decb %al // Decrement it
movb %al,_int13_extended_retrycount // Save it
cmpb $0,%al // Is it zero?
jz _int13_extended_zero // Yes, return zero
movb $0,%ah // BIOS int 0x13, function 0 - Reset Disk System
movb _int13_extended_drive,%dl // Get the drive
int $0x13 // Reset the disk system
jmp _int13_extended_read // Try reading again
_int13_extended_zero:
movb $0,%al // We will return zero
_int13_extended_done:
movzbl %al,%eax // Put the number of sectors read into EAX
movl %eax,_int13_extended_retval // Save it as the return value
popw %es // Restore ES
call switch_to_prot
.code32
movl _int13_extended_retval,%eax // Get return value
//movl $1,%eax
pop %edx
pop %ecx
pop %ebx
pop %edi
pop %esi
pop %ebp
ret
/*
* BOOL BiosInt13ExtensionsSupported(ULONG Drive);
*/
_int13_extension_check_drive:
.long 0
_int13_extension_check_retval:
.long 0
EXTERN(_BiosInt13ExtensionsSupported)
.code32
push %ebp
push %esi
push %edi
push %ebx
push %ecx
push %edx
/* Get parameters */
movl 0x1c(%esp),%eax
movl %eax,_int13_extension_check_drive
call switch_to_real
.code16
// Now make sure this computer supports extended reads
movb $0x41,%ah // AH = 41h
movw $0x55aa,%bx // BX = 55AAh
movb _int13_extension_check_drive,%dl // DL = drive (80h-FFh)
int $0x13 // IBM/MS INT 13 Extensions - INSTALLATION CHECK
jc _int13_extension_check_error // CF set on error (extensions not supported)
cmpw $0x55aa,%bx // BX = AA55h if installed
jne _int13_extension_check_error
testb $1,%cl // CX = API subset support bitmap
jz _int13_extension_check_error // Bit 0, extended disk access functions (AH=42h-44h,47h,48h) supported
// If we get here then we passed all the int13 extension tests
movl $1,_int13_extension_check_retval // Set return value to TRUE
jmp _int13_extension_check_done
_int13_extension_check_error:
movl $0,_int13_extension_check_retval // The tests failed so return FALSE
_int13_extension_check_done:
call switch_to_prot
.code32
movl _int13_extension_check_retval,%eax // Get return value
pop %edx
pop %ecx
pop %ebx
pop %edi
pop %esi
pop %ebp
ret
/*
* ULONG BiosInt13GetLastErrorCode(VOID);
*/
EXTERN(_BiosInt13GetLastErrorCode)
.code32
movzbl _biosdisk_error_code,%eax // Get return value
ret
/*
* int getyear(void);
@ -1110,184 +804,6 @@ EXTERN(_wherey)
pop %ebp
ret
/*
* void stop_floppy(void);
*
* Stops the floppy drive from spinning, so that other software is
* jumped to with a known state.
*/
EXTERN(_stop_floppy)
.code32
push %eax
push %edx
call switch_to_real
.code16
movw $0x3F2, %dx
xorb %al, %al
outb %al, %dx
call switch_to_prot
.code32
pop %edx
pop %eax
ret
/*
* int get_heads(int drive);
*/
EXTERN(_get_heads)
.code32
push %ebx
push %ecx
push %edx
push %edi
push %es
/* Get drive */
movl 0x18(%esp),%eax
movl %eax,_biosdisk_drive
call switch_to_real
.code16
movb $0x08,%ah
movb _biosdisk_drive,%dl
int $0x13
jc _get_heads_error
incb %dh
movzbl %dh,%edx
movl %edx,_biosdisk_retval
jmp _get_heads_done
_get_heads_error:
movl $0xff,_biosdisk_retval
_get_heads_done:
call switch_to_prot
.code32
movl _biosdisk_retval,%eax // Get return value
pop %es
pop %edi
pop %edx
pop %ecx
pop %ebx
ret
/*
* int get_cylinders(int drive);
*/
EXTERN(_get_cylinders)
.code32
push %ebx
push %ecx
push %edx
push %edi
push %es
/* Get drive */
movl 0x18(%esp),%eax
movl %eax,_biosdisk_drive
call switch_to_real
.code16
movb $0x08,%ah
movb _biosdisk_drive,%dl
int $0x13
jc _get_cylinders_error
xorl %edx,%edx
andb $0xc0,%cl
shrb $0x06,%cl
movb %cl,%dh
movb %ch,%dl
incl %edx
movl %edx,_biosdisk_retval
jmp _get_cylinders_done
_get_cylinders_error:
movl $0xff,_biosdisk_retval
_get_cylinders_done:
call switch_to_prot
.code32
movl _biosdisk_retval,%eax // Get return value
pop %es
pop %edi
pop %edx
pop %ecx
pop %ebx
ret
/*
* int get_sectors(int drive);
*/
EXTERN(_get_sectors)
.code32
push %ebx
push %ecx
push %edx
push %edi
push %es
/* Get drive */
movl 0x18(%esp),%eax
movl %eax,_biosdisk_drive
call switch_to_real
.code16
movb $0x08,%ah
movb _biosdisk_drive,%dl
int $0x13
jc _get_sectors_error
andb $0x3f,%cl
movzbl %cl,%ecx
movl %ecx,_biosdisk_retval
jmp _get_sectors_done
_get_sectors_error:
movl $0xff,_biosdisk_retval
_get_sectors_done:
call switch_to_prot
.code32
movl _biosdisk_retval,%eax // Get return value
pop %es
pop %edi
pop %edx
pop %ecx
pop %ebx
ret
/*

View file

@ -21,7 +21,7 @@
.code16
#define ASM
#include "asmcode.h"
#include "arch.h"
#include "multiboot.h"

View file

@ -0,0 +1,515 @@
/*
* 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"
/*
* BOOL BiosInt13Read(ULONG Drive, ULONG Head, ULONG Track, ULONG Sector, ULONG SectorCount, PVOID Buffer);
*/
_biosdisk_drive:
.long 0
_biosdisk_head:
.long 0
_biosdisk_track:
.long 0
_biosdisk_sector:
.long 0
_biosdisk_nsects:
.long 0
_biosdisk_buffer:
.long 0
_biosdisk_retval:
.long 0
_biosdisk_retrycount:
.byte 0
_biosdisk_error_code:
.byte 0
EXTERN(_BiosInt13Read)
.code32
push %ebp
push %esi
push %edi
push %ebx
push %ecx
push %edx
/* Get parameters */
movl 0x1c(%esp),%eax
movl %eax,_biosdisk_drive
movl 0x20(%esp),%eax
movl %eax,_biosdisk_head
movl 0x24(%esp),%eax
movl %eax,_biosdisk_track
movl 0x28(%esp),%eax
movl %eax,_biosdisk_sector
movl 0x2c(%esp),%eax
movl %eax,_biosdisk_nsects
movl 0x30(%esp),%eax
movl %eax,_biosdisk_buffer
call switch_to_real
.code16
pushw %es // Save this just in case
movb $3,_biosdisk_retrycount // Set the retry count to 3
_biosdisk_read:
movl _biosdisk_buffer,%eax // Get buffer address in eax
shrl $4,%eax // Make linear address into segment
movw %ax,%es // Load ES with segment
movl _biosdisk_buffer,%ebx // and BX with offset
andl $0x0f,%ebx // so that data gets loaded to [ES:BX]
movb _biosdisk_sector,%cl // Get the sector in CL
movw _biosdisk_track,%ax // Cylinder in AX
movb %al,%ch // Now put it in CH
rorb $1,%ah // Low 8 bits of cylinder in CH, high 2 bits
rorb $1,%ah // in CL shifted to bits 6 & 7
andb $0xc0,%ah // Clear out low six bits
orb %ah,%cl // Or with sector number
movb _biosdisk_head,%dh // Get the head
movb _biosdisk_drive,%dl // Get the drive
movb $2,%ah // BIOS int 0x13, function 2 - Read Disk Sectors
movb _biosdisk_nsects,%al // Number of sectors to read
int $0x13 // Read a sector
// I have recently learned that not all bioses return
// the sector read count in the AL register (at least mine doesn't)
// even if the sectors were read correctly. So instead
// of checking the sector read count we will rely solely
// on the carry flag being set on error
//jmp _biosdisk_done
//cmpb _biosdisk_nsects,%al // See how many sectors we actually read
//jne _biosdisk_error // Jump if no error
movb $1,%al // Set the return value to be one (will be set to zero later if needed)
jc _biosdisk_error // Jump if error (CF = 1 on error)
jmp _biosdisk_done
_biosdisk_error:
movb %ah,_biosdisk_error_code// Save the error code
cmpb $0x11,%ah // Check and see if it was a corrected ECC error
je _biosdisk_done // If so then the data is still good, if not fail
movb _biosdisk_retrycount,%al// Get the current retry count
decb %al // Decrement it
movb %al,_biosdisk_retrycount// Save it
cmpb $0,%al // Is it zero?
jz _biosdisk_zero // Yes, return zero
movb $0,%ah // BIOS int 0x13, function 0 - Reset Disk System
movb _biosdisk_drive,%dl // Get the drive
int $0x13 // Reset the disk system
jmp _biosdisk_read // Try reading again
_biosdisk_zero:
movb $0,%al // We will return zero
_biosdisk_done:
movzbl %al,%eax // Put the number of sectors read into EAX
movl %eax,_biosdisk_retval // Save it as the return value
popw %es // Restore ES
call switch_to_prot
.code32
movl _biosdisk_retval,%eax // Get return value
//movl $1,%eax
pop %edx
pop %ecx
pop %ebx
pop %edi
pop %esi
pop %ebp
ret
/*
* BOOL BiosInt13ReadExtended(ULONG Drive, ULONG Sector, ULONG SectorCount, PVOID Buffer);
*/
_disk_address_packet:
_packet_size:
.byte 0x10
_packet_reserved:
.byte 0
_packet_sector_count:
.word 0
_packet_transfer_buffer_segment:
.word 0
_packet_transfer_buffer_offset:
.word 0
_packet_lba_sector_number:
.quad 0
_packet_64bit_flat_address:
.quad 0
_int13_extended_drive:
.long 0
_int13_extended_sector_count:
.long 0
_int13_extended_retval:
.long 0
_int13_extended_retrycount:
.byte 0
EXTERN(_BiosInt13ReadExtended)
.code32
push %ebp
push %esi
push %edi
push %ebx
push %ecx
push %edx
/* Get parameters */
movl 0x1c(%esp),%eax
movl %eax,_int13_extended_drive
movl 0x20(%esp),%eax
movl %eax,_packet_lba_sector_number
movl 0x24(%esp),%eax
movw %ax,_packet_sector_count
movl %eax,_int13_extended_sector_count
movl 0x28(%esp),%eax // Get buffer address in eax
shrl $4,%eax // Make linear address into segment
movw %ax,_packet_transfer_buffer_segment // Save segment
movl 0x28(%esp),%eax // Get buffer address in eax
andl $0x0f,%eax // Make linear address into offset
movw %ax,_packet_transfer_buffer_offset // Save offset
call switch_to_real
.code16
pushw %es // Save this just in case
movb $3,_int13_extended_retrycount // Set the retry count to 3
_int13_extended_read:
movb _int13_extended_drive,%dl // Get the drive
movb $42,%ah // BIOS int 0x13, function 42h - IBM/MS INT 13 Extensions - EXTENDED READ
movw $_disk_address_packet,%si // DS:SI -> disk address packet
int $0x13 // Read sectors
movb $1,%al // Set the return value to be one (will be set to zero later if needed)
jc _int13_extended_error // Jump if error (CF = 1 on error)
movl _int13_extended_sector_count,%eax // Get the sector count in eax
cmpw _packet_sector_count,%ax // See how many sectors we actually read (returned in disk address packet sector count)
jne _int13_extended_error // Jump if not equal
jmp _int13_extended_done
_int13_extended_error:
movb %ah,_biosdisk_error_code // Save the error code
cmpb $0x11,%ah // Check and see if it was a corrected ECC error
je _int13_extended_done // If so then the data is still good, if not fail
movb _int13_extended_retrycount,%al // Get the current retry count
decb %al // Decrement it
movb %al,_int13_extended_retrycount // Save it
cmpb $0,%al // Is it zero?
jz _int13_extended_zero // Yes, return zero
movb $0,%ah // BIOS int 0x13, function 0 - Reset Disk System
movb _int13_extended_drive,%dl // Get the drive
int $0x13 // Reset the disk system
jmp _int13_extended_read // Try reading again
_int13_extended_zero:
movb $0,%al // We will return zero
_int13_extended_done:
movzbl %al,%eax // Put the number of sectors read into EAX
movl %eax,_int13_extended_retval // Save it as the return value
popw %es // Restore ES
call switch_to_prot
.code32
movl _int13_extended_retval,%eax // Get return value
//movl $1,%eax
pop %edx
pop %ecx
pop %ebx
pop %edi
pop %esi
pop %ebp
ret
/*
* BOOL BiosInt13ExtensionsSupported(ULONG Drive);
*/
_int13_extension_check_drive:
.long 0
_int13_extension_check_retval:
.long 0
EXTERN(_BiosInt13ExtensionsSupported)
.code32
push %ebp
push %esi
push %edi
push %ebx
push %ecx
push %edx
/* Get parameters */
movl 0x1c(%esp),%eax
movl %eax,_int13_extension_check_drive
call switch_to_real
.code16
// Now make sure this computer supports extended reads
movb $0x41,%ah // AH = 41h
movw $0x55aa,%bx // BX = 55AAh
movb _int13_extension_check_drive,%dl // DL = drive (80h-FFh)
int $0x13 // IBM/MS INT 13 Extensions - INSTALLATION CHECK
jc _int13_extension_check_error // CF set on error (extensions not supported)
cmpw $0x55aa,%bx // BX = AA55h if installed
jne _int13_extension_check_error
testb $1,%cl // CX = API subset support bitmap
jz _int13_extension_check_error // Bit 0, extended disk access functions (AH=42h-44h,47h,48h) supported
// If we get here then we passed all the int13 extension tests
movl $1,_int13_extension_check_retval // Set return value to TRUE
jmp _int13_extension_check_done
_int13_extension_check_error:
movl $0,_int13_extension_check_retval // The tests failed so return FALSE
_int13_extension_check_done:
call switch_to_prot
.code32
movl _int13_extension_check_retval,%eax // Get return value
pop %edx
pop %ecx
pop %ebx
pop %edi
pop %esi
pop %ebp
ret
/*
* ULONG BiosInt13GetLastErrorCode(VOID);
*/
EXTERN(_BiosInt13GetLastErrorCode)
.code32
movzbl _biosdisk_error_code,%eax // Get return value
ret
/*
* void stop_floppy(void);
*
* Stops the floppy drive from spinning, so that other software is
* jumped to with a known state.
*/
EXTERN(_stop_floppy)
.code32
push %eax
push %edx
call switch_to_real
.code16
movw $0x3F2, %dx
xorb %al, %al
outb %al, %dx
call switch_to_prot
.code32
pop %edx
pop %eax
ret
/*
* int get_heads(int drive);
*/
EXTERN(_get_heads)
.code32
push %ebx
push %ecx
push %edx
push %edi
push %es
/* Get drive */
movl 0x18(%esp),%eax
movl %eax,_biosdisk_drive
call switch_to_real
.code16
movb $0x08,%ah
movb _biosdisk_drive,%dl
int $0x13
jc _get_heads_error
incb %dh
movzbl %dh,%edx
movl %edx,_biosdisk_retval
jmp _get_heads_done
_get_heads_error:
movl $0xff,_biosdisk_retval
_get_heads_done:
call switch_to_prot
.code32
movl _biosdisk_retval,%eax // Get return value
pop %es
pop %edi
pop %edx
pop %ecx
pop %ebx
ret
/*
* int get_cylinders(int drive);
*/
EXTERN(_get_cylinders)
.code32
push %ebx
push %ecx
push %edx
push %edi
push %es
/* Get drive */
movl 0x18(%esp),%eax
movl %eax,_biosdisk_drive
call switch_to_real
.code16
movb $0x08,%ah
movb _biosdisk_drive,%dl
int $0x13
jc _get_cylinders_error
xorl %edx,%edx
andb $0xc0,%cl
shrb $0x06,%cl
movb %cl,%dh
movb %ch,%dl
incl %edx
movl %edx,_biosdisk_retval
jmp _get_cylinders_done
_get_cylinders_error:
movl $0xff,_biosdisk_retval
_get_cylinders_done:
call switch_to_prot
.code32
movl _biosdisk_retval,%eax // Get return value
pop %es
pop %edi
pop %edx
pop %ecx
pop %ebx
ret
/*
* int get_sectors(int drive);
*/
EXTERN(_get_sectors)
.code32
push %ebx
push %ecx
push %edx
push %edi
push %es
/* Get drive */
movl 0x18(%esp),%eax
movl %eax,_biosdisk_drive
call switch_to_real
.code16
movb $0x08,%ah
movb _biosdisk_drive,%dl
int $0x13
jc _get_sectors_error
andb $0x3f,%cl
movzbl %cl,%ecx
movl %ecx,_biosdisk_retval
jmp _get_sectors_done
_get_sectors_error:
movl $0xff,_biosdisk_retval
_get_sectors_done:
call switch_to_prot
.code32
movl _biosdisk_retval,%eax // Get return value
pop %es
pop %edi
pop %edx
pop %ecx
pop %ebx
ret

View file

@ -21,7 +21,7 @@
.code16
#define ASM
#include "asmcode.h"
#include "arch.h"
#include "multiboot.h"
/*

View file

@ -21,7 +21,7 @@
.code16
#define ASM
#include "asmcode.h"
#include "arch.h"
#include "multiboot.h"

View file

@ -24,7 +24,7 @@
#include <disk.h>
#include <rtl.h>
#include <debug.h>
#include <asmcode.h>
#include <arch.h>
// Returns a pointer to a CACHE_BLOCK structure
// Adds the block to the cache manager block list

View file

@ -22,7 +22,7 @@
#include <fs.h>
#include <rtl.h>
#include <ui.h>
#include <asmcode.h>
#include <arch.h>
#include <debug.h>

View file

@ -22,7 +22,7 @@
#include "fs.h"
#include "reactos.h"
#include "ui.h"
#include "asmcode.h"
#include "arch.h"
#include "miscboot.h"
#include "linux.h"
#include "mm.h"
@ -35,10 +35,6 @@
//ULONG BootDrive = 0; // BIOS boot drive, 0-A:, 1-B:, 0x80-C:, 0x81-D:, etc.
ULONG BootPartition = 0; // Boot Partition, 1-4
PUCHAR ScreenBuffer = (PUCHAR)(SCREENBUFFER); // Save buffer for screen contents
ULONG CursorXPos = 0; // Cursor's X Position
ULONG CursorYPos = 0; // Cursor's Y Position
ULONG GetDefaultOperatingSystem(PUCHAR OperatingSystemList[], ULONG OperatingSystemCount);
LONG GetTimeOut(VOID);
@ -57,9 +53,6 @@ VOID BootMain(VOID)
enable_a20();
CursorXPos = (ULONG) *((PUCHAR)(SCREENXCOORD));
CursorYPos = (ULONG) *((PUCHAR)(SCREENYCOORD));
#ifdef DEBUG
DebugInit();
#endif
@ -139,9 +132,8 @@ VOID BootMain(VOID)
reboot:
RestoreScreen(ScreenBuffer);
clrscr();
showcursor();
gotoxy(CursorXPos, CursorYPos);
return;
}

View file

@ -72,10 +72,6 @@ extern ULONG BootDrive; // BIOS boot drive, 0-A:, 1-B:, 0x80-C:, 0x81-D:, etc
extern ULONG BootPartition; // Boot Partition, 1-4
extern BOOL UserInterfaceUp; // Tells us if the user interface is displayed
extern PUCHAR ScreenBuffer; // Save buffer for screen contents
extern ULONG CursorXPos; // Cursor's X Position
extern ULONG CursorYPos; // Cursor's Y Position
void BootMain(void);
#endif // defined __FREELDR_H

View file

@ -23,7 +23,7 @@
#include <disk.h>
#include <rtl.h>
#include <ui.h>
#include <asmcode.h>
#include <arch.h>
#include <mm.h>
#include <debug.h>
#include <cache.h>

View file

@ -24,7 +24,7 @@
#include <disk.h>
#include <rtl.h>
#include <ui.h>
#include <asmcode.h>
#include <arch.h>
#include <debug.h>

View file

@ -19,7 +19,7 @@
#include "freeldr.h"
#include "asmcode.h"
#include "arch.h"
#include "miscboot.h"
#include "rtl.h"
#include "fs.h"

View file

@ -19,7 +19,7 @@
#include "freeldr.h"
#include "asmcode.h"
#include "arch.h"
#include "miscboot.h"
#include "rtl.h"
#include "fs.h"

View file

@ -19,7 +19,7 @@
#include "freeldr.h"
#include "asmcode.h"
#include "arch.h"
#include "rtl.h"
#include "fs.h"
#include "multiboot.h"

View file

@ -19,7 +19,7 @@
*/
#include <freeldr.h>
#include <asmcode.h>
#include <arch.h>
#include <reactos.h>
#include <rtl.h>
#include <fs.h>
@ -646,8 +646,6 @@ void LoadAndBootReactOS(PUCHAR OperatingSystemName)
strcat(name, ".");
//MessageBox(name);
RestoreScreen(ScreenBuffer);
/*
* Now boot the kernel
*/

View file

@ -26,7 +26,7 @@ CP = cmd /C copy
MAKE = make
# For a release build uncomment this line
FLAGS = -Wall -nostdlib -nostdinc -fno-builtin -I./ -I../ -O3
FLAGS = -Wall -nostdlib -nostdinc -fno-builtin -I./ -I../ -I../../ -O3
# For a debug build uncomment this line
#FLAGS = -Wall -nostdlib -nostdinc -fno-builtin -I./ -I../ -DDEBUG -O3
#FLAGS = -Wall -nostdlib -nostdinc -fno-builtin -I./ -I../ -I../../ -DDEBUG -O3