Remove unused code.

svn path=/trunk/; revision=4459
This commit is contained in:
Eric Kohl 2003-03-31 11:49:38 +00:00
parent 4dc8e937b1
commit 1f8fe422c6
6 changed files with 0 additions and 1235 deletions

View file

@ -1,305 +0,0 @@
;
; File:
; boot.asm
; Description:
; DOS-C boot
;
; Copyright (c) 1997;
; Svante Frey
; All Rights Reserved
;
; This file is part of DOS-C.
;
; DOS-C 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, or (at your option) any later version.
;
; DOS-C 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 DOS-C; see the file COPYING. If not,
; write to the Free Software Foundation, 675 Mass Ave,
; Cambridge, MA 02139, USA.
;
; $Logfile: C:/dos-c/src/boot/boot.asv $
;
; $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/loaders/boot/Attic/boot.asm,v 1.4 2000/06/25 03:59:14 dwelch Exp $
;
; $Log: boot.asm,v $
; Revision 1.4 2000/06/25 03:59:14 dwelch
; Removed from redundant files from the mm directory
; Added some preliminary work on the pager
; Fixed ntoskrnl/mm/npool.c (This may have been the cause of the
; problems reported with loading win32k.sys)
; Fixed problems with reporting space used to store physical page
; information
; Added code to support MmSafeCopy{To/From}User interface work
; (untested)
; Added Event member of the PHYSICAL_PAGE structure to implement Philip
; Susi's suggestion
; Reworked section page-in code (not really tested)
; Replaced inline string functions with gcc builtins to make debugging easier
;
; Revision 1.3 1998/08/25 04:37:43 rex
; new release cleanup
;
; Revision 1.1.1.2 1998/08/25 04:27:38 rex
; A much Needed Update
;
;
; Rev 1.5 10 Jan 1997 4:58:06 patv
; Corrected copyright
;
; Rev 1.4 10 Jan 1997 4:52:50 patv
; Re-written to support C drive and eliminate restrictions on IPL.SYS
;
; Rev 1.3 29 Aug 1996 13:06:50 patv
; Bug fixes for v0.91b
;
; Rev 1.2 01 Sep 1995 17:56:44 patv
; First GPL release.
;
; Rev 1.1 30 Jul 1995 20:37:38 patv
; Initialized stack before use.
;
; Rev 1.0 02 Jul 1995 10:57:52 patv
; Initial revision.
;
section .text
org 0
Entry: jmp real_start
; bp is initialized to 7c00h
%define oem [bp+3]
%define bytesPerSector [bp+0bh]
%define sectPerCluster [bp+0dh]
%define resSectors [bp+0eh]
%define nFats [bp+10h]
%define nRootDir [bp+11h]
%define nSectors [bp+13h]
%define MID [bp+15h]
%define sectPerFat [bp+16h]
%define sectPerTrack [bp+18h]
%define nHeads [bp+1ah]
%define nHidden [bp+1ch]
%define nHidden_hi [bp+1eh]
%define nSectorHuge [bp+20h]
%define drive [bp+24h]
%define extBoot [bp+26h]
%define volid [bp+27h]
%define vollabel [bp+2bh]
%define filesys 36h
LOADSEG equ 2000h
FATBUF equ 4000h ; offset of temporary buffer for FAT
; chain
RETRYCOUNT equ 5 ; number of retries on disk errors
; Some extra variables that are created on the stack frame
%define fat_start [bp-4] ; first FAT sector
%define fat_start_hi [bp-2]
%define root_dir_start [bp-8] ; first root directory sector
%define root_dir_start_hi [bp-6]
%define data_start [bp-12] ; first data sector
%define data_start_hi [bp-10]
;
; Include macros for filesystem access
;
%include "boot.inc"
;
;
;
TIMES 3eh-($-$$) DB 0
%define tempbuf [bp+3eh]
load_seg dw LOADSEG
real_start: cli
cld
mov ax, cs
mov ss, ax ; initialize stack
mov bp, 7c00h
lea sp, [bp-20h]
sti
mov es, ax
mov ds, ax
mov drive, dl ; BIOS passes drive number in DL
GETDRIVEPARMS
FINDFILE ; locate file in root directory
jc boot_error ; fail if not found
GETFATCHAIN ; read FAT chain
LOADFILE ; load file (jumps to boot_sucess if successful)
boot_error: mov cx, ERRMSGLEN
mov si, errmsg+7c00h
next_char: lodsb ; print error message
mov ah, 0eh
xor bh, bh
int 10h
loop next_char
xor ah, ah
int 16h ; wait for keystroke
int 19h ; invoke bootstrap loader
boot_success: mov dl, drive
db 0eah ; far jump to LOADSEG:0000
dw 0
dw LOADSEG
; readDisk: Reads a number of sectors into memory.
;
; Call with: DX:AX = 32-bit DOS sector number
; DI = number of sectors to read
; ES:BX = destination buffer
; ES must be 64k aligned (1000h, 2000h etc).
;
; Returns: CF set on error
; ES:BX points one byte after the last byte read.
readDisk:
push si
read_next: push dx
push ax
;
; translate sector number to BIOS parameters
;
;
; abs = sector offset in track
; + head * sectPerTrack offset in cylinder
; + track * sectPerTrack * nHeads offset in platter
;
; t1 = abs / sectPerTrack (ax has t1)
; sector = abs mod sectPerTrack (cx has sector)
;
div word sectPerTrack
mov cx, dx
;
; t1 = head + track * nHeads
;
; track = t1 / nHeads (ax has track)
; head = t1 mod nHeads (dl has head)
;
xor dx, dx
div word nHeads
; the following manipulations are necessary in order to
; properly place parameters into registers.
; ch = cylinder number low 8 bits
; cl = 7-6: cylinder high two bits
; 5-0: sector
mov dh, dl ; save head into dh for bios
ror ah, 1 ; move track high bits into
ror ah, 1 ; bits 7-6 (assumes top = 0)
xchg al, ah ; swap for later
mov dl, byte sectPerTrack
sub dl, cl
inc cl ; sector offset from 1
or cx, ax ; merge cylinder into sector
mov al, dl ; al has # of sectors left
; Calculate how many sectors can be transfered in this read
; due to dma boundary conditions.
push dx
mov si, di ; temp register save
; this computes remaining bytes because of modulo 65536
; nature of dma boundary condition
mov ax, bx ; get offset pointer
neg ax ; and convert to bytes
jz ax_min_1 ; started at seg:0, skip ahead
xor dx, dx ; convert to sectors
div word bytesPerSector
cmp ax, di ; check remainder vs. asked
jb ax_min_1 ; less, skip ahead
mov si, ax ; transfer only what we can
ax_min_1: pop dx
; Check that request sectors do not exceed track boundary
mov si, sectPerTrack
inc si
mov ax, cx ; get the sector/cyl byte
and ax, 03fh ; and mask out sector
sub si, ax ; si has how many we can read
mov ax, di
cmp si, di ; see if asked <= available
jge ax_min_2
mov ax, si ; get what can be xfered
ax_min_2: mov si, RETRYCOUNT
mov ah, 2
mov dl, drive
retry: push ax
int 13h
pop ax
jnc read_ok
push ax
xor ax, ax ; reset the drive
int 13h
pop ax
dec si
jnz retry
stc
pop ax
pop dx
pop si
ret
read_next_jmp: jmp short read_next
read_ok: xor ah, ah
mov si, ax ; AX = SI = number of sectors read
mul word bytesPerSector ; AX = number of bytes read
add bx, ax ; add number of bytes read to BX
jnc no_incr_es ; if overflow...
mov ax, es
add ah, 10h ; ...add 1000h to ES
mov es, ax
no_incr_es: pop ax
pop dx ; DX:AX = last sector number
add ax, si
adc dx, 0 ; DX:AX = next sector to read
sub di, si ; if there is anything left to read,
jg read_next_jmp ; continue
clc
pop si
ret
errmsg db "Boot error"
ERRMSGLEN equ $ - errmsg
;filename db "OSLDR BIN"
filename db "KERNEL BIN"
TIMES 510-($-$$) DB 0
sign dw 0aa55h

View file

@ -1,196 +0,0 @@
; To save space, functions that are just called once are
; implemented as macros instead. Four bytes are saved by
; avoiding the call / ret instructions.
; FINDFILE: Searches for the file in the root directory.
;
; Returns:
;
; If file not found: CF set
;
; If file found: CF clear
; AX = first cluster of file
%macro FINDFILE 0
; First, read the whole root directory
; into the temporary buffer.
mov ax, word root_dir_start
mov dx, word root_dir_start_hi
mov di, nRootDir
xor bx, bx
mov es, tempbuf
call readDisk
jc ffDone
xor di, di
next_entry: mov cx, 11
mov si, filename+7c00h
push di
repe cmpsb
pop di
mov ax, [es:di+1ah] ; get cluster number from directory entry
clc
je ffDone
add di, 20h ; go to next directory entry
cmp byte [es:di], 0 ; if the first byte of the name is 0,
jnz next_entry ; there is no more files in the directory
stc
ffDone:
%endmacro
; GETDRIVEPARMS: Calculate start of some disk areas.
%macro GETDRIVEPARMS 0
mov si, word nHidden
mov di, word nHidden_hi
add si, word resSectors
adc di, 0 ; DI:SI = first FAT sector
mov word fat_start, si
mov word fat_start_hi, di
mov al, nFats
xor ah, ah
mul word sectPerFat ; DX:AX = total number of FAT sectors
add si, ax
adc di, dx ; DI:SI = first root directory sector
mov word root_dir_start, si
mov word root_dir_start_hi, di
; Calculate how many sectors the root directory occupies.
mov bx, bytesPerSector
mov cl, 5 ; divide BX by 32
shr bx, cl ; BX = directory entries per sector
mov ax, nRootDir
xor dx, dx
div bx
mov nRootDir, ax ; AX = sectors per root directory
add si, ax
adc di, 0 ; DI:SI = first data sector
mov data_start, si
mov data_start_hi, di
%endmacro
; GETFATCHAIN:
;
; Reads the FAT chain and stores it in a temporary buffer in the first
; 64 kb. The FAT chain is stored an array of 16-bit cluster numbers,
; ending with 0.
;
; The file must fit in conventional memory, so it can't be larger than
; 640 kb. The sector size must be at least 512 bytes, so the FAT chain
; can't be larger than around 3 kb.
;
; Call with: AX = first cluster in chain
;
; Returns: CF clear on success, set on error
%macro GETFATCHAIN 0
push ax ; store first cluster number
; Load the complete FAT into memory. The FAT can't be larger
; than 128 kb, so it should fit in the temporary buffer.
mov es, tempbuf
xor bx, bx
mov di, sectPerFat
mov ax, word fat_start
mov dx, word fat_start_hi
call readDisk
pop ax ; restore first cluster number
jc boot_error
; Set ES:DI to the temporary storage for the FAT chain.
push ds
push es
pop ds
pop es
mov di, FATBUF
next_clust: stosw ; store cluster number
mov si, ax ; SI = cluster number
cmp byte extBoot, 29h
jne fat_12
cmp byte [bp+filesys+4], '6' ; check for FAT-16 system
je fat_16
; This is a FAT-12 disk.
fat_12: add si, si ; multiply cluster number by 3...
add si, ax
shr si, 1 ; ...and divide by 2
lodsw
; If the cluster number was even, the cluster value is now in
; bits 0-11 of AX. If the cluster number was odd, the cluster
; value is in bits 4-15, and must be shifted right 4 bits. If
; the number was odd, CF was set in the last shift instruction.
jnc fat_even
mov cl, 4
shr ax, cl ; shift the cluster number
fat_even: and ah, 0fh ; mask off the highest 4 bits
cmp ax, 0fffh ; check for EOF
jmp short next_test
; This is a FAT-16 disk. The maximal size of a 16-bit FAT
; is 128 kb, so it may not fit within a single 64 kb segment.
fat_16: mov dx, tempbuf
add si, si ; multiply cluster number by two
jnc first_half ; if overflow...
add dh, 10h ; ...add 64 kb to segment value
first_half: mov ds, dx ; DS:SI = pointer to next cluster
lodsw ; AX = next cluster
cmp ax, 0fff8h ; >= FFF8 = 16-bit EOF
next_test: jb next_clust ; continue if not EOF
finished: ; Mark end of FAT chain with 0, so we have a single
; EOF marker for both FAT-12 and FAT-16 systems.
xor ax, ax
stosw
fatError:
%endmacro
; loadFile: Loads the file into memory, one cluster at a time.
%macro LOADFILE 0
mov es, tempbuf ; set ES:BX to load address
xor bx, bx
mov si, FATBUF ; set DS:SI to the FAT chain
push cs
pop ds
next_cluster: lodsw ; AX = next cluster to read
or ax, ax ; if EOF...
je boot_success ; ...boot was successful
dec ax ; cluster numbers start with 2
dec ax
mov di, word sectPerCluster
and di, 0ffh ; DI = sectors per cluster
mul di
add ax, data_start
adc dx, data_start_hi ; DX:AX = first sector to read
call readDisk
jnc next_cluster
%endmacro

View file

@ -1,73 +0,0 @@
#
# makefile for DOS-C boot
#
# $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/loaders/boot/Attic/boot.mak,v 1.4 2000/06/25 03:59:14 dwelch Exp $
#
# $Log: boot.mak,v $
# Revision 1.4 2000/06/25 03:59:14 dwelch
# Removed from redundant files from the mm directory
# Added some preliminary work on the pager
# Fixed ntoskrnl/mm/npool.c (This may have been the cause of the
# problems reported with loading win32k.sys)
# Fixed problems with reporting space used to store physical page
# information
# Added code to support MmSafeCopy{To/From}User interface work
# (untested)
# Added Event member of the PHYSICAL_PAGE structure to implement Philip
# Susi's suggestion
# Reworked section page-in code (not really tested)
# Replaced inline string functions with gcc builtins to make debugging easier
#
# Revision 1.3 1998/08/25 04:39:40 rex
# Release cleanup
#
# Revision 1.1.1.2 1998/08/25 04:27:38 rex
# A much Needed Update
#
#
# Rev 1.3 10 Jan 1997 4:51:54 patv
#Changed to use FreeDOS exe2bin and support new boot code
#
# Rev 1.2 17 Dec 1996 12:52:32 patv
#Converted to FreeDOS exe2bin.
#.
#d
#
# Rev 1.1 29 Aug 1996 13:06:50 patv
#Bug fixes for v0.91b
#
# Rev 1.0 02 Jul 1995 9:11:26 patv
#Initial revision.
#
#
# Uncomment the following for a debug version
#
#AFLAGS = /zi /DDEBUG
#LFLAGS = /v
PRODUCT = boot.bin
all: $(PRODUCT)
production: all
copy boot.bin ..\..\dist\boot.bin
del *.bin
del *.map
boot.bin: boot.asm
tasm $(AFLAGS) boot,,
tlink $(LFLAGS) boot
..\utils\exe2bin boot boot.bin
del boot.obj
del boot.exe
clean:
del *.lst
del *.map
del *.bin
del *.bak
del *.las
del *.obj
del *.exe

View file

@ -1,309 +0,0 @@
;
; File:
; boot.asm
; Description:
; DOS-C boot
;
; Copyright (c) 1997;
; Svante Frey
; All Rights Reserved
;
; This file is part of DOS-C.
;
; DOS-C 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, or (at your option) any later version.
;
; DOS-C 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 DOS-C; see the file COPYING. If not,
; write to the Free Software Foundation, 675 Mass Ave,
; Cambridge, MA 02139, USA.
;
; $Logfile: C:/dos-c/src/boot/boot.asv $
;
; $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/loaders/boot/Attic/bootbk.asm,v 1.4 2000/06/25 03:59:14 dwelch Exp $
;
; $Log: bootbk.asm,v $
; Revision 1.4 2000/06/25 03:59:14 dwelch
; Removed from redundant files from the mm directory
; Added some preliminary work on the pager
; Fixed ntoskrnl/mm/npool.c (This may have been the cause of the
; problems reported with loading win32k.sys)
; Fixed problems with reporting space used to store physical page
; information
; Added code to support MmSafeCopy{To/From}User interface work
; (untested)
; Added Event member of the PHYSICAL_PAGE structure to implement Philip
; Susi's suggestion
; Reworked section page-in code (not really tested)
; Replaced inline string functions with gcc builtins to make debugging easier
;
; Revision 1.3 1998/08/25 04:40:47 rex
; Release cleanup
;
; Revision 1.1.1.2 1998/08/25 04:27:38 rex
; A much Needed Update
;
;
; Rev 1.5 10 Jan 1997 4:58:06 patv
; Corrected copyright
;
; Rev 1.4 10 Jan 1997 4:52:50 patv
; Re-written to support C drive and eliminate restrictions on IPL.SYS
;
; Rev 1.3 29 Aug 1996 13:06:50 patv
; Bug fixes for v0.91b
;
; Rev 1.2 01 Sep 1995 17:56:44 patv
; First GPL release.
;
; Rev 1.1 30 Jul 1995 20:37:38 patv
; Initialized stack before use.
;
; Rev 1.0 02 Jul 1995 10:57:52 patv
; Initial revision.
;
.text
BASE equ 0
org BASE
Entry: jmp real_start
; bp is initialized to 7c00h
oem equ [bp+3]
bytesPerSector equ [bp+0bh]
sectPerCluster equ [bp+0dh]
resSectors equ [bp+0eh]
nFats equ [bp+10h]
nRootDir equ [bp+11h]
nSectors equ [bp+13h]
MID equ [bp+15h]
sectPerFat equ [bp+16h]
sectPerTrack equ [bp+18h]
nHeads equ [bp+1ah]
nHidden equ [bp+1ch]
nSectorHuge equ [bp+20h]
drive equ [bp+24h]
extBoot equ [bp+26h]
volid equ [bp+27h]
vollabel equ [bp+2bh]
filesys equ [bp+36h]
LOADSEG equ 2000h
FATBUF equ 4000h ; offset of temporary buffer for FAT
; chain
RETRYCOUNT equ 5 ; number of retries on disk errors
; Some extra variables that are created on the stack frame
fat_start equ [bp-4] ; first FAT sector
root_dir_start equ [bp-8] ; first root directory sector
data_start equ [bp-12] ; first data sector
;
; Include macros for filesystem access
;
include boot.inc
;
;
;
org BASE+3eh
tempbuf equ [bp+3eh]
load_seg dw LOADSEG
real_start: cli
cld
mov ax, cs
mov ss, ax ; initialize stack
mov bp, 7c00h
lea sp, [bp-20h]
sti
mov es, ax
mov ds, ax
mov drive, dl ; BIOS passes drive number in DL
GETDRIVEPARMS
FINDFILE ; locate file in root directory
jc boot_error ; fail if not found
GETFATCHAIN ; read FAT chain
LOADFILE ; load file (jumps to boot_sucess if successful)
boot_error: mov cx, ERRMSGLEN
mov si, offset errmsg+7c00h
next_char: lodsb ; print error message
mov ah, 0eh
xor bh, bh
int 10h
loop next_char
xor ah, ah
int 16h ; wait for keystroke
int 19h ; invoke bootstrap loader
boot_success: mov dl, drive
db 0eah ; far jump to LOADSEG:0000
dw 0
dw LOADSEG
; readDisk: Reads a number of sectors into memory.
;
; Call with: DX:AX = 32-bit DOS sector number
; DI = number of sectors to read
; ES:BX = destination buffer
; ES must be 64k aligned (1000h, 2000h etc).
;
; Returns: CF set on error
; ES:BX points one byte after the last byte read.
readDisk proc
push si
read_next: push dx
push ax
;
; translate sector number to BIOS parameters
;
;
; abs = sector offset in track
; + head * sectPerTrack offset in cylinder
; + track * sectPerTrack * nHeads offset in platter
;
; t1 = abs / sectPerTrack (ax has t1)
; sector = abs mod sectPerTrack (cx has sector)
;
div word ptr sectPerTrack
mov cx, dx
;
; t1 = head + track * nHeads
;
; track = t1 / nHeads (ax has track)
; head = t1 mod nHeads (dl has head)
;
xor dx, dx
div word ptr nHeads
; the following manipulations are necessary in order to
; properly place parameters into registers.
; ch = cylinder number low 8 bits
; cl = 7-6: cylinder high two bits
; 5-0: sector
mov dh, dl ; save head into dh for bios
ror ah, 1 ; move track high bits into
ror ah, 1 ; bits 7-6 (assumes top = 0)
xchg al, ah ; swap for later
mov dl, byte ptr sectPerTrack
sub dl, cl
inc cl ; sector offset from 1
or cx, ax ; merge cylinder into sector
mov al, dl ; al has # of sectors left
; Calculate how many sectors can be transfered in this read
; due to dma boundary conditions.
push dx
mov si, di ; temp register save
; this computes remaining bytes because of modulo 65536
; nature of dma boundary condition
mov ax, bx ; get offset pointer
neg ax ; and convert to bytes
jz ax_min_1 ; started at seg:0, skip ahead
xor dx, dx ; convert to sectors
div word ptr bytesPerSector
cmp ax, di ; check remainder vs. asked
jb ax_min_1 ; less, skip ahead
mov si, ax ; transfer only what we can
ax_min_1: pop dx
; Check that request sectors do not exceed track boundary
mov si, sectPerTrack
inc si
mov ax, cx ; get the sector/cyl byte
and ax, 03fh ; and mask out sector
sub si, ax ; si has how many we can read
mov ax, di
cmp si, di ; see if asked <= available
jge ax_min_2
mov ax, si ; get what can be xfered
ax_min_2: mov si, RETRYCOUNT
mov ah, 2
mov dl, drive
retry: push ax
int 13h
pop ax
jnc read_ok
push ax
xor ax, ax ; reset the drive
int 13h
pop ax
dec si
jnz retry
stc
pop ax
pop dx
pop si
ret
read_next_jmp: jmp short read_next
read_ok: xor ah, ah
mov si, ax ; AX = SI = number of sectors read
mul word ptr bytesPerSector ; AX = number of bytes read
add bx, ax ; add number of bytes read to BX
jnc no_incr_es ; if overflow...
mov ax, es
add ah, 10h ; ...add 1000h to ES
mov es, ax
no_incr_es: pop ax
pop dx ; DX:AX = last sector number
add ax, si
adc dx, 0 ; DX:AX = next sector to read
sub di, si ; if there is anything left to read,
jg read_next_jmp ; continue
clc
pop si
ret
readDisk endp
errmsg db "Boot error"
ERRMSGLEN equ $ - errmsg
;filename db "OSLDR BIN"
filename db "KERNEL BIN"
org BASE+01feh
sign dw 0aa55h
TEXT ENDS
end

View file

@ -1,340 +0,0 @@
;
; Loads the kernel and any required modules
;
org 0
;
; Segment where we are loaded
;
LOADSEG equ 02000h
;
; Segment used for temporay storage
;
WORKSEG equ 01000h
KERNELBASE equ 05000h
;
; Offsets of work areas
;
FAT_CHAIN equ 0h
DIR_BUFFER equ 4000h
END_DIR_BUFFER equ 0ffe0h
FAT_SEG equ 03000h
;
; These are all on the stack
;
%define oem [bp+3]
%define bytesPerSector [bp+0bh]
%define sectPerCluster [bp+0dh]
%define resSectors [bp+0eh]
%define nFats [bp+10h]
%define nRootDir [bp+11h]
%define nSectors [bp+13h]
%define MID [bp+15h]
%define sectPerFat [bp+16h]
%define sectPerTrack [bp+18h]
%define nHeads [bp+1ah]
%define nHidden [bp+1ch]
%define nHidden_hi [bp+1eh]
%define nSectorHuge [bp+20h]
%define drive [bp+24h]
%define extBoot [bp+26h]
%define volid [bp+27h]
%define vollabel [bp+2bh]
%define filesys 36h
RETRYCOUNT equ 5
%define fat_start [bp-4] ; first FAT sector
%define fat_start_hi [bp-2]
%define root_dir_start [bp-8] ; first root directory sector
%define root_dir_start_hi [bp-6]
%define data_start [bp-12] ; first data sector
%define data_start_hi [bp-10]
entry:
mov drive,dl
mov ax,LOADSEG
mov ds,ax
;
; Print out a message
;
mov di,loadmsg
call printmsg
;
; Check here for shift pressed and if so display boot menu
;
;
; Load the entire fat
;
; mov ax,fat_start
; mov dx,fat_start_hi
; mov di,sectPerFat
; mov ax,FAT_SEG
; mov es,ax
; mov bx,0
; call readDisk
;
; Load root directory
;
mov ax,WORKSEG
mov es,ax
mov dx,root_dir_start_hi
mov ax,root_dir_start
mov bx,DIR_BUFFER
mov di,nRootDir
shr di,4
mov di,1
call readDisk
jc disk_error
;
; Look for a directory called boot
;
mov di,DIR_BUFFER
cld
mov cx,4
l1:
mov si,boot_dir_name
; cmp byte [di],0
; je boot_error
repe cmpsb
je found_it
or di,31
inc di
cmp di,END_DIR_BUFFER
jge boot_error
jmp l1
boot_error:
mov di,errormsg
call printmsg
l3:
jmp l3
disk_error:
mov di,errormsg1
call printmsg
jmp l3
found_it:
mov di,msg1
call printmsg
;
; Load the boot directory found above
;
sub di,4
call readFile
l2:
jmp l2
;
; readFile
;
%define file_length [di+01ch]
%define start_cluster [di+01ah]
readFile:
cmp byte extBoot, 29h
jne fat_12
cmp byte [bp+filesys+4], '6' ; check for FAT-16 system
je fat_16
fat_12:
mov di,msg2
call printmsg
l4:
jmp l4
fat_16:
mov di,msg3
call printmsg
jmp l4
; readDisk: Reads a number of sectors into memory.
;
; Call with: DX:AX = 32-bit DOS sector number
; DI = number of sectors to read
; ES:BX = destination buffer
; ES must be 64k aligned (1000h, 2000h etc).
;
; Returns: CF set on error
; ES:BX points one byte after the last byte read.
readDisk:
push bp
push si
read_next: push dx
push ax
;
; translate sector number to BIOS parameters
;
;
; abs = sector offset in track
; + head * sectPerTrack offset in cylinder
; + track * sectPerTrack * nHeads offset in platter
;
; t1 = abs / sectPerTrack (ax has t1)
; sector = abs mod sectPerTrack (cx has sector)
;
div word sectPerTrack
mov cx, dx
;
; t1 = head + track * nHeads
;
; track = t1 / nHeads (ax has track)
; head = t1 mod nHeads (dl has head)
;
xor dx, dx
div word nHeads
; the following manipulations are necessary in order to
; properly place parameters into registers.
; ch = cylinder number low 8 bits
; cl = 7-6: cylinder high two bits
; 5-0: sector
mov dh, dl ; save head into dh for bios
ror ah, 1 ; move track high bits into
ror ah, 1 ; bits 7-6 (assumes top = 0)
xchg al, ah ; swap for later
mov dl, byte sectPerTrack
sub dl, cl
inc cl ; sector offset from 1
or cx, ax ; merge cylinder into sector
mov al, dl ; al has # of sectors left
; Calculate how many sectors can be transfered in this read
; due to dma boundary conditions.
push dx
mov si, di ; temp register save
; this computes remaining bytes because of modulo 65536
; nature of dma boundary condition
mov ax, bx ; get offset pointer
neg ax ; and convert to bytes
jz ax_min_1 ; started at seg:0, skip ahead
xor dx, dx ; convert to sectors
div word bytesPerSector
cmp ax, di ; check remainder vs. asked
jb ax_min_1 ; less, skip ahead
mov si, ax ; transfer only what we can
ax_min_1: pop dx
; Check that request sectors do not exceed track boundary
mov si, sectPerTrack
inc si
mov ax, cx ; get the sector/cyl byte
and ax, 03fh ; and mask out sector
sub si, ax ; si has how many we can read
mov ax, di
cmp si, di ; see if asked <= available
jge ax_min_2
mov ax, si ; get what can be xfered
ax_min_2: mov si, RETRYCOUNT
mov ah, 2
mov dl, drive
retry: push ax
int 13h
pop ax
jnc read_ok
push ax
xor ax, ax ; reset the drive
int 13h
pop ax
dec si
jnz retry
stc
pop ax
pop dx
pop si
pop bp
ret
read_next_jmp: jmp short read_next
read_ok: xor ah, ah
mov si, ax ; AX = SI = number of sectors read
mul word bytesPerSector ; AX = number of bytes read
add bx, ax ; add number of bytes read to BX
jnc no_incr_es ; if overflow...
mov ax, es
add ah, 10h ; ...add 1000h to ES
mov es, ax
no_incr_es: pop ax
pop dx ; DX:AX = last sector number
add ax, si
adc dx, 0 ; DX:AX = next sector to read
sub di, si ; if there is anything left to read,
jg read_next_jmp ; continue
clc
pop si
pop bp
ret
;
; Print string (DI = start)
;
printmsg:
push ax
push bx
push di
mov ah,0eh
mov bh,0
mov bl,07h
.l1
mov al,[di]
cmp al,0
je .l2
inc di
int 10h
jmp .l1
.l2
pop di
pop bx
pop ax
ret
loadmsg db "Starting ReactOS...",0xd,0xa,0
boot_dir_name db 'BOOT'
errormsg db "Files missing on boot disk",0
errormsg1 db "Disk read error",0
msg1 db "Found boot directory",0xd,0xa,0
msg2 db 'FAT12',0
msg3 db 'FAT16',0

View file

@ -1,12 +0,0 @@
Mem layout for osldr
0000 - 07C0 = BIOS data and stack
07C0 - 1000 = Boot sector
1000 - 1400 = Tempory storage for fat chains
1400 - 2000 = Tempory storage for directory entries
2000 - 3000 = OSLDR
3000 - 5000 = FAT
5000 - a000 = Kernel and modules load area