mirror of https://github.com/FDOS/kernel.git
Added new makefile names, utils sources, kconfig.h
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@316 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
parent
27e19b1af2
commit
a4c844dc62
|
@ -0,0 +1,75 @@
|
|||
#
|
||||
# makefile for DOS-C boot
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
# $Log$
|
||||
# Revision 1.1 2001/11/04 20:10:15 bartoldeman
|
||||
# Added new makefile names, utils sources, kconfig.h
|
||||
#
|
||||
# Revision 1.4 2001/09/23 20:39:44 bartoldeman
|
||||
# FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling
|
||||
#
|
||||
# Revision 1.3 2000/05/25 20:56:19 jimtabor
|
||||
# Fixed project history
|
||||
#
|
||||
# Revision 1.2 2000/05/11 03:56:42 jimtabor
|
||||
# Clean up and Release
|
||||
#
|
||||
# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1
|
||||
# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with
|
||||
# MS-DOS. Distributed under the GNU GPL.
|
||||
#
|
||||
# Revision 1.3 1999/04/23 03:44:17 jprice
|
||||
# Ported to NASM by ror4. Improvements
|
||||
#
|
||||
# Revision 1.2 1999/04/01 07:23:20 jprice
|
||||
# New boot loader
|
||||
#
|
||||
# Revision 1.1.1.1 1999/03/29 15:39:39 jprice
|
||||
# New version without IPL.SYS
|
||||
#
|
||||
# Revision 1.3 1999/02/09 04:49:17 jprice
|
||||
# Make makefile use common config.mak file
|
||||
#
|
||||
# Revision 1.2 1999/01/21 05:03:58 jprice
|
||||
# Formating.
|
||||
#
|
||||
# Revision 1.1.1.1 1999/01/20 05:51:00 jprice
|
||||
# Imported sources
|
||||
#
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
!include "..\config.mak"
|
||||
|
||||
production: b_fat12.bin b_fat16.bin b_fat32.bin
|
||||
|
||||
b_fat12.bin: boot.asm
|
||||
$(NASM) -dISFAT12 boot.asm -ob_fat12.bin
|
||||
|
||||
b_fat16.bin: boot.asm
|
||||
$(NASM) -dISFAT16 boot.asm -ob_fat16.bin
|
||||
|
||||
b_fat32.bin: boot32.asm
|
||||
$(NASM) boot32.asm -ob_fat32.bin
|
||||
|
||||
clobber: clean
|
||||
$(RM) b_fat12.bin b_fat16.bin b_fat32.bin status.me
|
||||
|
||||
clean:
|
||||
$(RM) *.lst *.map *.bak *.obj
|
||||
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
:-@echo off
|
||||
|
||||
:-
|
||||
:- Revision 1.0 2001/09/05 tomehlert
|
||||
:-
|
||||
|
||||
|
||||
:----------------------------------------------------------
|
||||
:- batch file to build _many_ KERNELS, hope build works
|
||||
:-
|
||||
:- takes 3 minutes on my(TE) Win2K/P700. your milage may vary :-)
|
||||
:----------------------------------------------------------
|
||||
|
||||
if \%1 == \$SUMMARY goto summary
|
||||
|
||||
:-goto xsummary
|
||||
|
||||
set onerror=if not \%XERROR% == \ goto daswarwohlnix
|
||||
|
||||
:***** some MSCL kernels
|
||||
|
||||
call config.bat
|
||||
if not \%SKIPMS% == \ goto no_ms
|
||||
call build -r msc 386 fat16
|
||||
%ONERROR%
|
||||
call build -r msc 186 fat16
|
||||
%ONERROR%
|
||||
call build -r msc 86 fat16
|
||||
%ONERROR%
|
||||
call build -r msc 386 fat32
|
||||
%ONERROR%
|
||||
call build -r msc 186 fat32
|
||||
%ONERROR%
|
||||
call build -r msc 86 fat32
|
||||
%ONERROR%
|
||||
no_ms:
|
||||
SET SKIPMS=
|
||||
|
||||
:***** some TC 2.01 kernels
|
||||
|
||||
call build -r tc 186 fat16
|
||||
%ONERROR%
|
||||
call build -r tc 86 fat16
|
||||
%ONERROR%
|
||||
call build -r tc 186 fat32
|
||||
%ONERROR%
|
||||
call build -r tc 86 fat32
|
||||
%ONERROR%
|
||||
|
||||
|
||||
:wc
|
||||
|
||||
:***** some WATCOM kernels - just for fun !!!
|
||||
|
||||
:-
|
||||
:- this is definitively only for fun - now
|
||||
:- hope, this gets better
|
||||
:-
|
||||
call build -r wc 386 fat32
|
||||
call build -r wc 386 fat16
|
||||
call build -r wc 86 fat32
|
||||
call build -r wc 86 fat16
|
||||
|
||||
:- the watcom executables will currently NOT RUN
|
||||
@del bin\kwc*.sys >nul
|
||||
|
||||
|
||||
:***** now rebuild the normal kernel !!
|
||||
call build -r
|
||||
|
||||
|
||||
:**************************************************************
|
||||
:* now we build a summary of all kernels HMA size + total size
|
||||
:* Yes, I know - "mit Linux waer das nicht passiert" :-)
|
||||
:* at least, it's possible with standard DOS tools
|
||||
:**************************************************************
|
||||
|
||||
:xsummary
|
||||
|
||||
set Sumfile=bin\ksummary.txt
|
||||
set TempSumfile=bin\tsummary.txt
|
||||
|
||||
:****@echo >%TempSumfile% Summary of all kernels build
|
||||
:****@echo.|date >>%TempSumfile%
|
||||
:****@echo.|time >>%TempSumfile%
|
||||
:****for %%i in (bin\k*.map) do call %0 $SUMMARY %%i
|
||||
:****for %%i in (bin\k*.map) do call %0 $SUMMARY %%i
|
||||
:****for %%i in (bin\k*.map) do call %0 $SUMMARY %%i
|
||||
|
||||
del %Sumfile%
|
||||
del %TempSumfile%
|
||||
del ktemp.bat
|
||||
for %%i in (bin\k*.map) do echo call %0 $SUMMARY %%i >>ktemp.bat
|
||||
sort <ktemp.bat >ktemps.bat
|
||||
call ktemps
|
||||
del ktemp.bat
|
||||
del ktemps.bat
|
||||
|
||||
|
||||
@echo >>%Sumfile% Summary of all kernels build
|
||||
@echo.|date >>%Sumfile%
|
||||
@echo.|time >>%Sumfile%
|
||||
find <%TempSumfile% "H" >>%Sumfile%
|
||||
del %TempSumfile%
|
||||
|
||||
set TempSumfile=
|
||||
set Sumfile=
|
||||
goto end
|
||||
|
||||
:summary
|
||||
echo >>%TempSumfile% H************************************************* %2
|
||||
type %2| find " HMA_TEXT" |find /V "HMA_TEXT_START" |find /V "HMA_TEXT_END" >>%TempSumfile%
|
||||
type %2| find " STACK" >>%TempSumfile%
|
||||
goto end
|
||||
|
||||
:************* done with summary *********************************
|
||||
|
||||
|
||||
:daswarwohlnix
|
||||
@echo Sorry, something didn't work as expected :-(
|
||||
@set ONERROR=
|
||||
:end
|
||||
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
#
|
||||
# makefile for device.lib
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
# $Log$
|
||||
# Revision 1.1 2001/11/04 20:10:15 bartoldeman
|
||||
# Added new makefile names, utils sources, kconfig.h
|
||||
#
|
||||
# Revision 1.3 2000/05/25 20:56:19 jimtabor
|
||||
# Fixed project history
|
||||
#
|
||||
# Revision 1.2 2000/05/11 03:56:20 jimtabor
|
||||
# Clean up and Release
|
||||
#
|
||||
# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1
|
||||
# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with
|
||||
# MS-DOS. Distributed under the GNU GPL.
|
||||
#
|
||||
# Revision 1.6 1999/08/25 03:16:36 jprice
|
||||
# ror4 patches to allow TC 2.01 compile.
|
||||
#
|
||||
# Revision 1.5 1999/08/10 17:21:08 jprice
|
||||
# ror4 2011-01 patch
|
||||
#
|
||||
# Revision 1.4 1999/04/23 03:44:52 jprice
|
||||
# Improved by jprice
|
||||
#
|
||||
# Revision 1.3 1999/04/13 15:47:07 jprice
|
||||
# no message
|
||||
#
|
||||
# Revision 1.2 1999/03/29 17:08:31 jprice
|
||||
# ror4 changes
|
||||
#
|
||||
# Revision 1.1.1.1 1999/03/29 15:40:23 jprice
|
||||
# New version without IPL.SYS
|
||||
#
|
||||
# Revision 1.3 1999/02/09 04:49:25 jprice
|
||||
# Make makefile use common config.mak file
|
||||
#
|
||||
# Revision 1.2 1999/01/22 04:16:39 jprice
|
||||
# Formating
|
||||
#
|
||||
# Revision 1.1.1.1 1999/01/20 05:51:00 jprice
|
||||
# Imported sources
|
||||
#
|
||||
#
|
||||
# Rev 1.2 29 Aug 1996 13:07:12 patv
|
||||
#Bug fixes for v0.91b
|
||||
#
|
||||
# Rev 1.1 19 Feb 1996 3:19:26 patv
|
||||
#Added NLS, int2f and config.sys processing
|
||||
#
|
||||
# Rev 1.0 02 Jul 1995 7:54:52 patv
|
||||
#Initial revision.
|
||||
#
|
||||
|
||||
!include "..\config.mak"
|
||||
|
||||
|
||||
# MICROSOFT C
|
||||
# -----------
|
||||
#MODEL = s
|
||||
#CFLAGS = /c /Gs /A$(MODEL)
|
||||
#AFLAGS = /Mx /Dmem$(MODEL)=1
|
||||
#TERM = ;
|
||||
|
||||
# BORLAND C
|
||||
# -----------
|
||||
#MODEL = s
|
||||
#CFLAGS = -c -m$(MODEL)
|
||||
#AFLAGS = /Mx /Dmem$(MODEL)=1
|
||||
#LIBFLAGS = /c
|
||||
|
||||
OBJS = devend.obj floppy.obj getvec.obj timer.obj rdpcclk.obj rdatclk.obj \
|
||||
wrpcclk.obj wratclk.obj
|
||||
|
||||
LIBOBJS= +devend +floppy +getvec +timer +rdpcclk +rdatclk +wrpcclk +wratclk
|
||||
|
||||
|
||||
|
||||
# Build the LIBRARY
|
||||
# -----------------
|
||||
all: production
|
||||
|
||||
production: ..\lib\device.lib
|
||||
|
||||
..\lib\device.lib: device.lib
|
||||
copy device.lib ..\lib
|
||||
|
||||
clobber: clean
|
||||
$(RM) device.lib status.me ..\lib\device.lib
|
||||
|
||||
clean:
|
||||
$(RM) *.obj *.bak *.crf *.xrf *.map *.lst
|
||||
|
||||
device.lib : $(OBJS)
|
||||
$(RM) device.lib
|
||||
$(LIBUTIL) $(LIBFLAGS) device $(LIBOBJS) $(LIBTERM)
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
KConfig.h
|
||||
|
||||
DLASortByDriveNo
|
||||
0 : Drive Letter Assignement ike MSDOS
|
||||
1 : DLA - first drive completely first, then to next drive
|
||||
|
||||
InitDiskShowDriveAssignment
|
||||
0 : don't show what drive/partition assigned to what drive letter
|
||||
1 : show info
|
||||
|
||||
SkipConfigSeconds:
|
||||
< 0 : not possible to skip config.sys
|
||||
= 0 : only possible if already pressed before, no message
|
||||
> 0 : wait so long for F5/F8
|
||||
*/
|
||||
typedef struct _KernelConfig {
|
||||
char CONFIG[6]; /* "CONFIG" */
|
||||
unsigned short ConfigSize;
|
||||
|
||||
unsigned char DLASortByDriveNo;
|
||||
unsigned char InitDiskShowDriveAssignment;
|
||||
signed char SkipConfigSeconds;
|
||||
} KernelConfig;
|
||||
extern struct _KernelConfig FAR LowKernelConfig;
|
|
@ -0,0 +1,421 @@
|
|||
#
|
||||
# Makefile for Borland C++ 3.1 for kernel.sys
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
# $Log$
|
||||
# Revision 1.1 2001/11/04 20:10:15 bartoldeman
|
||||
# Added new makefile names, utils sources, kconfig.h
|
||||
#
|
||||
# Revision 1.13 2001/07/24 16:56:29 bartoldeman
|
||||
# fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e).
|
||||
#
|
||||
# Revision 1.12 2001/07/22 01:58:58 bartoldeman
|
||||
# Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX
|
||||
#
|
||||
# Revision 1.11 2001/07/09 22:19:33 bartoldeman
|
||||
# LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings
|
||||
#
|
||||
# Revision 1.10 2001/04/21 22:32:53 bartoldeman
|
||||
# Init DS=Init CS, fixed stack overflow problems and misc bugs.
|
||||
#
|
||||
# Revision 1.9 2001/04/16 14:28:32 bartoldeman
|
||||
# Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs
|
||||
#
|
||||
# Revision 1.8 2001/04/15 03:21:50 bartoldeman
|
||||
# See history.txt for the list of fixes.
|
||||
#
|
||||
# Revision 1.7 2001/03/25 17:11:54 bartoldeman
|
||||
# Fixed sys.com compilation. Updated to 2023. Also: see history.txt.
|
||||
#
|
||||
# Revision 1.6 2001/03/21 02:56:26 bartoldeman
|
||||
# See history.txt for changes. Bug fixes and HMA support are the main ones.
|
||||
#
|
||||
# Revision 1.4 2000/08/06 05:50:17 jimtabor
|
||||
# Add new files and update cvs with patches and changes
|
||||
#
|
||||
# Revision 1.3 2000/05/25 20:56:21 jimtabor
|
||||
# Fixed project history
|
||||
#
|
||||
# Revision 1.2 2000/05/08 04:30:00 jimtabor
|
||||
# Update CVS to 2020
|
||||
#
|
||||
# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1
|
||||
# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with
|
||||
# MS-DOS. Distributed under the GNU GPL.
|
||||
#
|
||||
# Revision 1.14 2000/03/31 05:40:09 jtabor
|
||||
# Added Eric W. Biederman Patches
|
||||
#
|
||||
# Revision 1.13 2000/03/17 22:59:04 kernel
|
||||
# Steffen Kaiser's NLS changes
|
||||
#
|
||||
# Revision 1.12 2000/03/09 06:07:11 kernel
|
||||
# 2017f updates by James Tabor
|
||||
#
|
||||
# Revision 1.11 1999/09/23 04:40:47 jprice
|
||||
# *** empty log message ***
|
||||
#
|
||||
# Revision 1.8 1999/09/13 20:41:41 jprice
|
||||
# Some clean up.
|
||||
#
|
||||
# Revision 1.7 1999/08/25 03:18:09 jprice
|
||||
# ror4 patches to allow TC 2.01 compile.
|
||||
#
|
||||
# Revision 1.6 1999/08/10 17:57:13 jprice
|
||||
# ror4 2011-02 patch
|
||||
#
|
||||
# Revision 1.5 1999/04/23 04:25:15 jprice
|
||||
# no message
|
||||
#
|
||||
# Revision 1.4 1999/04/23 03:45:11 jprice
|
||||
# Improved by jprice
|
||||
#
|
||||
# Revision 1.3 1999/04/16 12:21:22 jprice
|
||||
# Steffen c-break handler changes
|
||||
#
|
||||
# Revision 1.2 1999/04/13 15:48:21 jprice
|
||||
# no message
|
||||
#
|
||||
# Revision 1.1.1.1 1999/03/29 15:41:15 jprice
|
||||
# New version without IPL.SYS
|
||||
#
|
||||
# Revision 1.7 1999/03/01 06:04:37 jprice
|
||||
# Fixed so it'll work with config.mak
|
||||
#
|
||||
# Revision 1.6 1999/03/01 05:46:43 jprice
|
||||
# Turned off DEBUG define.
|
||||
#
|
||||
# Revision 1.5 1999/02/09 04:49:43 jprice
|
||||
# Make makefile use common config.mak file
|
||||
#
|
||||
# Revision 1.4 1999/02/08 05:55:57 jprice
|
||||
# Added Pat's 1937 kernel patches
|
||||
#
|
||||
# Revision 1.3 1999/02/04 03:09:59 jprice
|
||||
# Added option to share constants (-d).
|
||||
#
|
||||
# Revision 1.2 1999/01/22 04:13:26 jprice
|
||||
# Formating
|
||||
#
|
||||
# Revision 1.1.1.1 1999/01/20 05:51:01 jprice
|
||||
# Imported sources
|
||||
#
|
||||
#
|
||||
# Rev 1.8.1 10 Jan 1999 SRM
|
||||
#Took out "/P-" from TLINK
|
||||
#Changed "bcc" to "tcc"
|
||||
#
|
||||
# Rev 1.9 06 Dec 1998 8:45:40 patv
|
||||
#Added new files for I/O subsystem.
|
||||
#
|
||||
# Rev 1.8 22 Jan 1998 14:50:06 patv
|
||||
#Outdated stacks.asm.
|
||||
#
|
||||
# Rev 1.6 03 Jan 1998 8:36:50 patv
|
||||
#Converted data area to SDA format
|
||||
#
|
||||
# Rev 1.5 30 Jan 1997 7:55:54 patv
|
||||
#Added TSC flag for trace support.
|
||||
#
|
||||
# Rev 1.4 16 Jan 1997 12:46:42 patv
|
||||
#pre-Release 0.92 feature additions
|
||||
#
|
||||
# Rev 1.3 29 Aug 1996 13:07:34 patv
|
||||
#Bug fixes for v0.91b
|
||||
#
|
||||
# Rev 1.2 29 May 1996 21:03:32 patv
|
||||
#bug fixes for v0.91a
|
||||
#
|
||||
# Rev 1.1 19 Feb 1996 3:35:38 patv
|
||||
#Added NLS, int2f and config.sys processing
|
||||
#
|
||||
# Rev 1.0 02 Jul 1995 8:30:22 patv
|
||||
#Initial revision.
|
||||
#
|
||||
# $EndLog$
|
||||
#
|
||||
|
||||
!include "..\config.mak"
|
||||
|
||||
RELEASE = 1.00
|
||||
|
||||
# Compiler and Options for Borland C++
|
||||
# ------------------------------------
|
||||
#
|
||||
# -zAname ¦ ¦ Code class
|
||||
# -zBname ¦ ¦ BSS class
|
||||
# -zCname ¦ ¦ Code segment
|
||||
# -zDname ¦ ¦ BSS segment
|
||||
# -zEname ¦ ¦ Far segment
|
||||
# -zFname ¦ ¦ Far class
|
||||
# -zGname ¦ ¦ BSS group
|
||||
# -zHname ¦ ¦ Far group
|
||||
# -zPname ¦ ¦ Code group
|
||||
# -zRname ¦ ¦ Data segment
|
||||
# -zSname ¦ ¦ Data group
|
||||
# -zTname ¦ ¦ Data class
|
||||
# -zX ¦«¦ Use default name for "X"
|
||||
|
||||
|
||||
# Compiler and Options
|
||||
|
||||
INCLUDE=$(COMPILERBASE)\include
|
||||
LIB= $(COMPILERBASE)\lib
|
||||
|
||||
LIBPATH = .
|
||||
#AFLAGS = /Mx /DSTANDALONE=1 /I..\HDR
|
||||
|
||||
LIBS =..\LIB\DEVICE.LIB ..\LIB\LIBM.LIB
|
||||
#INITCFLAGS =$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB \
|
||||
#-zGIGROUP -zSIGROUP
|
||||
#CFLAGS =$(ALLCFLAGS) -zAHMA -zCHMA_TEXT
|
||||
HDR=../hdr/
|
||||
|
||||
# *Implicit Rules*
|
||||
# 'standard' compiles
|
||||
|
||||
.c.obj :
|
||||
$(CC) $(CFLAGS) -c $*.c
|
||||
$(PATCHOBJ) $*.obj $(STDPATCH)
|
||||
|
||||
# *List Macros*
|
||||
|
||||
|
||||
EXE_dependencies = \
|
||||
apisupt.obj \
|
||||
rtlsupt.obj \
|
||||
asmsupt.obj \
|
||||
blockio.obj \
|
||||
break.obj \
|
||||
chario.obj \
|
||||
config.obj \
|
||||
console.obj \
|
||||
dosidle.obj \
|
||||
dosfns.obj \
|
||||
dosnames.obj \
|
||||
dsk.obj \
|
||||
initdisk.obj \
|
||||
entry.obj \
|
||||
error.obj \
|
||||
execrh.obj \
|
||||
fatdir.obj \
|
||||
fatfs.obj \
|
||||
fattab.obj \
|
||||
fcbfns.obj \
|
||||
initoem.obj \
|
||||
int2f.obj \
|
||||
inthndlr.obj \
|
||||
io.obj \
|
||||
intr.obj \
|
||||
ioctl.obj \
|
||||
irqstack.obj \
|
||||
kernel.obj \
|
||||
main.obj \
|
||||
memmgr.obj \
|
||||
misc.obj \
|
||||
newstuff.obj \
|
||||
network.obj \
|
||||
nls.obj \
|
||||
nls_hc.obj \
|
||||
nlssupt.obj \
|
||||
prf.obj \
|
||||
iprf.obj \
|
||||
printer.obj \
|
||||
procsupt.obj \
|
||||
serial.obj \
|
||||
strings.obj \
|
||||
sysclk.obj \
|
||||
syspack.obj \
|
||||
systime.obj \
|
||||
task.obj \
|
||||
inithma.obj \
|
||||
dyndata.obj \
|
||||
dyninit.obj
|
||||
|
||||
# *Explicit Rules*
|
||||
|
||||
production: ..\bin\kernel.sys
|
||||
|
||||
..\bin\kernel.sys: kernel.sys
|
||||
copy kernel.sys ..\bin
|
||||
copy kernel.sys ..\bin\$(THETARGET).sys
|
||||
copy kernel.map ..\bin\$(THETARGET).map
|
||||
|
||||
kernel.sys: kernel.exe ..\utils\exeflat.exe
|
||||
..\utils\exeflat kernel.exe kernel.sys 0x60
|
||||
|
||||
clobber: clean
|
||||
$(RM) kernel.exe kernel.sys status.me
|
||||
|
||||
clean:
|
||||
$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod
|
||||
|
||||
# XXX: This is a very ugly way of linking the kernel, forced upon us by the
|
||||
# inability of Turbo `make' 2.0 to perform command line redirection. -- ror4
|
||||
kernel.exe: $(EXE_dependencies) $(LIBS)
|
||||
$(RM) kernel.lib
|
||||
$(LIBUTIL) kernel.lib $(LIBPLUS)entry.obj $(LIBPLUS)io.obj $(LIBPLUS)blockio.obj $(LIBPLUS)chario.obj $(LIBPLUS)dosfns.obj $(LIBPLUS)console.obj$(LIBTERM)
|
||||
$(LIBUTIL) kernel.lib $(LIBPLUS)printer.obj $(LIBPLUS)serial.obj $(LIBPLUS)dsk.obj $(LIBPLUS)initdisk.obj $(LIBPLUS)error.obj $(LIBPLUS)fatdir.obj $(LIBPLUS)fatfs.obj$(LIBTERM)
|
||||
$(LIBUTIL) kernel.lib $(LIBPLUS)fattab.obj $(LIBPLUS)fcbfns.obj $(LIBPLUS)initoem.obj $(LIBPLUS)initHMA.obj $(LIBPLUS)inthndlr.obj $(LIBPLUS)ioctl.obj $(LIBPLUS)nls_hc.obj$(LIBTERM)
|
||||
$(LIBUTIL) kernel.lib $(LIBPLUS)main.obj $(LIBPLUS)config.obj $(LIBPLUS)memmgr.obj $(LIBPLUS)misc.obj $(LIBPLUS)newstuff.obj $(LIBPLUS)nls.obj $(LIBPLUS)intr.obj$(LIBTERM)
|
||||
$(LIBUTIL) kernel.lib $(LIBPLUS)dosnames.obj $(LIBPLUS)prf.obj $(LIBPLUS)strings.obj $(LIBPLUS)network.obj $(LIBPLUS)sysclk.obj $(LIBPLUS)syspack.obj$(LIBTERM)
|
||||
$(LIBUTIL) kernel.lib $(LIBPLUS)systime.obj $(LIBPLUS)task.obj $(LIBPLUS)int2f.obj $(LIBPLUS)irqstack.obj $(LIBPLUS)apisupt.obj$(LIBTERM)
|
||||
$(LIBUTIL) kernel.lib $(LIBPLUS)asmsupt.obj $(LIBPLUS)execrh.obj $(LIBPLUS)nlssupt.obj $(LIBPLUS)procsupt.obj $(LIBPLUS)break.obj$(LIBTERM)
|
||||
$(LIBUTIL) kernel.lib $(LIBPLUS)dosidle.obj $(LIBPLUS)dyndata.obj $(LIBPLUS)dyninit.obj $(LIBPLUS)rtlsupt.obj $(LIBTERM)
|
||||
$(RM) kernel.bak
|
||||
$(LINK) kernel iprf,kernel,kernel,kernel+$(LIBS)$(LINKTERM)
|
||||
$(RM) kernel.lib
|
||||
|
||||
# *Individual File Dependencies*
|
||||
kernel.obj: kernel.asm segs.inc
|
||||
|
||||
console.obj: console.asm io.inc
|
||||
|
||||
printer.obj: printer.asm io.inc
|
||||
|
||||
serial.obj: serial.asm io.inc
|
||||
|
||||
entry.obj: entry.asm segs.inc $(HDR)stacks.inc
|
||||
|
||||
apisupt.obj: apisupt.asm segs.inc
|
||||
|
||||
rtlsupt.obj: rtlsupt.asm segs.inc
|
||||
|
||||
execrh.obj: execrh.asm segs.inc
|
||||
|
||||
int2f.obj: int2f.asm segs.inc
|
||||
|
||||
intr.obj: intr.asm segs.inc intr.h
|
||||
|
||||
io.obj: io.asm segs.inc
|
||||
|
||||
irqstack.obj: irqstack.asm
|
||||
|
||||
nls_hc.obj: nls_hc.asm segs.inc
|
||||
|
||||
nlssupt.obj: nlssupt.asm segs.inc
|
||||
|
||||
procsupt.obj: procsupt.asm segs.inc $(HDR)stacks.inc
|
||||
|
||||
dosidle.obj: dosidle.asm segs.inc
|
||||
|
||||
# XXX: Special handling for initialization modules -- this is required because
|
||||
# TC 2.01 cannot handle `#pragma option' like TC 3 can. -- ror4
|
||||
|
||||
INITHEADERS=init-mod.h init-dat.h
|
||||
|
||||
CONFIGURATION = turboc.cfg makefile ..\config.mak ..\mkfiles\$(COMPILER).MAK
|
||||
|
||||
HEADERS=\
|
||||
$(HDR)portab.h $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h \
|
||||
$(HDR)fat.h $(HDR)fcb.h $(HDR)tail.h $(HDR)time.h $(HDR)process.h \
|
||||
$(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h \
|
||||
$(HDR)dirmatch.h $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \
|
||||
$(HDR)version.h globals.h proto.h dyndata.h
|
||||
|
||||
# XXX: I generated these using `gcc -MM' and `sed', so they may not be
|
||||
# completely correct... -- ror4
|
||||
|
||||
blockio.obj: blockio.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
break.obj: break.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
chario.obj: chario.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
dosfns.obj: dosfns.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
dosnames.obj: dosnames.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
dsk.obj: dsk.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
error.obj: error.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
fatdir.obj: fatdir.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
fatfs.obj: fatfs.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
fattab.obj: fattab.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
fcbfns.obj: fcbfns.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
inthndlr.obj: inthndlr.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
ioctl.obj: ioctl.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
memmgr.obj: memmgr.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
misc.obj: misc.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
newstuff.obj: newstuff.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
network.obj: network.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
nls.obj: nls.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
# \
|
||||
# 001-437.nls
|
||||
|
||||
prf.obj: prf.c $(HDR)\portab.h $(CONFIGURATION)
|
||||
|
||||
strings.obj: strings.c $(CONFIGURATION)
|
||||
|
||||
sysclk.obj: sysclk.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
syspack.obj: syspack.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
systime.obj: systime.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
task.obj: task.c $(HEADERS) $(CONFIGURATION)
|
||||
|
||||
# now the funny stuff :-)
|
||||
# Files in the INIT segment
|
||||
|
||||
# $(CC) $(INITCFLAGS) -c $*.c
|
||||
# patchobj $*.obj $(INITPATCH)
|
||||
|
||||
config.obj: config.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION)
|
||||
$(CC) $(INITCFLAGS) -c $*.c
|
||||
$(PATCHOBJ) $*.obj $(INITPATCH)
|
||||
|
||||
initoem.obj: initoem.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION)
|
||||
$(CC) $(INITCFLAGS) -c $*.c
|
||||
$(PATCHOBJ) $*.obj $(INITPATCH)
|
||||
|
||||
main.obj: main.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION)
|
||||
$(CC) $(INITCFLAGS) -c $*.c
|
||||
$(PATCHOBJ) $*.obj $(INITPATCH)
|
||||
|
||||
inithma.obj: inithma.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION)
|
||||
$(CC) $(INITCFLAGS) -c $*.c
|
||||
$(PATCHOBJ) $*.obj $(INITPATCH)
|
||||
|
||||
dyninit.obj: dyninit.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION)
|
||||
$(CC) $(INITCFLAGS) -c $*.c
|
||||
$(PATCHOBJ) $*.obj $(INITPATCH)
|
||||
|
||||
initdisk.obj: initdisk.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION)
|
||||
$(CC) $(INITCFLAGS) -c $*.c
|
||||
$(PATCHOBJ) $*.obj $(INITPATCH)
|
||||
|
||||
|
||||
# $(CC) $(CFLAGS) -c $*.c
|
||||
# patchobj $*.obj _DATA=DYN_DATA DATA=DYN_DATA CODE=HMA CONST=DCONST
|
||||
|
||||
dyndata.obj: dyndata.c dyndata.h
|
||||
$(CC) $(DYNCFLAGS) -c $*.c
|
||||
$(PATCHOBJ) $*.obj $(DYNPATCH)
|
||||
|
||||
|
||||
|
||||
#the printf for INIT_TEXT - yet another special case
|
||||
# $(CC) -D_INIT $(INITCFLAGS) -Foiprf.obj -c prf.c
|
||||
# patchobj Iprf.obj $(INITPATCH)
|
||||
|
||||
iprf.obj: prf.c $(HDR)\portab.h $(CONFIGURATION)
|
||||
$(CC) -D_INIT $(IPRFCFLAGS) -c prf.c
|
||||
$(PATCHOBJ) iprf.obj $(INITPATCH)
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
#
|
||||
# makefile for libm.lib
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
# $Log$
|
||||
# Revision 1.1 2001/11/04 20:10:15 bartoldeman
|
||||
# Added new makefile names, utils sources, kconfig.h
|
||||
#
|
||||
# Revision 1.5 2001/06/03 14:16:18 bartoldeman
|
||||
# BUFFERS tuning and misc bug fixes/cleanups (2024c).
|
||||
#
|
||||
# Revision 1.4 2001/03/19 04:50:56 bartoldeman
|
||||
# See history.txt for overview: put kernel 2022beo1 into CVS
|
||||
#
|
||||
# Revision 1.4 2001/03/08 21:15:00 bartoldeman
|
||||
# Fix from Martin Stromberg to make this fully configurable from config.mak
|
||||
#
|
||||
# Revision 1.3 2000/05/25 20:56:22 jimtabor
|
||||
# Fixed project history
|
||||
#
|
||||
# Revision 1.2 2000/05/11 03:57:10 jimtabor
|
||||
# Clean up and Release
|
||||
#
|
||||
# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1
|
||||
# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with
|
||||
# MS-DOS. Distributed under the GNU GPL.
|
||||
#
|
||||
# Revision 1.6 1999/09/14 17:32:20 jprice
|
||||
# no message
|
||||
#
|
||||
# Revision 1.5 1999/09/13 20:13:15 jprice
|
||||
# Added !if so we can use TC2 or TC3 to compile.
|
||||
#
|
||||
# Revision 1.4 1999/08/25 03:19:22 jprice
|
||||
# ror4 patches to allow TC 2.01 compile.
|
||||
#
|
||||
# Revision 1.3 1999/04/23 03:45:18 jprice
|
||||
# Improved by jprice
|
||||
#
|
||||
|
||||
!include "..\config.mak"
|
||||
|
||||
|
||||
libm.lib: $(CLIB) ..\config.mak
|
||||
$(RM) libm.lib
|
||||
$(LIBUTIL) $(CLIB) $(MATH_EXTRACT) $(LIBTERM)
|
||||
$(LIBUTIL) libm $(MATH_INSERT) $(LIBTERM)
|
||||
$(RM) *.OBJ
|
||||
|
||||
|
||||
clobber: clean
|
||||
$(RM) libm.lib status.me
|
||||
|
||||
clean:
|
||||
$(RM) *.obj *.bak
|
|
@ -0,0 +1,85 @@
|
|||
#
|
||||
# makefile for bin2c.com and sys.com
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.1 2001/11/04 20:10:15 bartoldeman
|
||||
# Added new makefile names, utils sources, kconfig.h
|
||||
#
|
||||
# Revision 1.3 2000/05/25 20:56:23 jimtabor
|
||||
# Fixed project history
|
||||
#
|
||||
# Revision 1.2 2000/05/15 05:28:09 jimtabor
|
||||
# Cleanup CRs
|
||||
#
|
||||
# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1
|
||||
# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with
|
||||
# MS-DOS. Distributed under the GNU GPL.
|
||||
#
|
||||
# Revision 1.6 1999/09/20 18:34:40 jprice
|
||||
# *** empty log message ***
|
||||
#
|
||||
# Revision 1.5 1999/08/25 03:19:51 jprice
|
||||
# ror4 patches to allow TC 2.01 compile.
|
||||
#
|
||||
# Revision 1.4 1999/05/03 05:01:38 jprice
|
||||
# no message
|
||||
#
|
||||
# Revision 1.3 1999/04/23 03:45:33 jprice
|
||||
# Improved by jprice
|
||||
#
|
||||
|
||||
!include "..\config.mak"
|
||||
|
||||
CFLAGS = -I$(INCLUDEPATH) -I..\hdr -DFORSYS -DWITHFAT32 $(CFLAGST)
|
||||
NASMFLAGS = -DSYS=1
|
||||
|
||||
# *List Macros*
|
||||
|
||||
BIN2C_EXE_dependencies = \
|
||||
bin2c.obj
|
||||
|
||||
SYS_EXE_dependencies = \
|
||||
sys.obj \
|
||||
fdkrncfg.obj \
|
||||
prf.obj
|
||||
|
||||
# *Explicit Rules*
|
||||
production: bin2c.com ..\bin\sys.com
|
||||
|
||||
bin2c.com: $(BIN2C_EXE_dependencies)
|
||||
$(CC) $(CFLAGST) -L$(LIBPATH) $(BIN2C_EXE_dependencies)
|
||||
|
||||
..\bin\sys.com: sys.com
|
||||
copy sys.com ..\bin
|
||||
|
||||
b_fat12.h: ..\boot\b_fat12.bin bin2c.com
|
||||
.\bin2c ..\boot\b_fat12.bin b_fat12.h b_fat12
|
||||
|
||||
b_fat16.h: ..\boot\b_fat16.bin bin2c.com
|
||||
.\bin2c ..\boot\b_fat16.bin b_fat16.h b_fat16
|
||||
|
||||
b_fat32.h: ..\boot\b_fat32.bin bin2c.com
|
||||
.\bin2c ..\boot\b_fat32.bin b_fat32.h b_fat32
|
||||
|
||||
prf.obj: ..\kernel\prf.c
|
||||
$(CC) $(CFLAGS) -c ..\kernel\prf.c
|
||||
|
||||
fdkrncfg.obj: fdkrncfg.c ..\hdr\kconfig.h
|
||||
|
||||
sys.com: $(SYS_EXE_dependencies)
|
||||
$(CC) $(CFLAGST) -L$(LIBPATH) $(SYS_EXE_dependencies)
|
||||
|
||||
clobber: clean
|
||||
$(RM) bin2c.com sys.com b_fat12.h b_fat16.h b_fat32.h
|
||||
|
||||
clean:
|
||||
$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las status.me
|
||||
|
||||
# *Individual File Dependencies*
|
||||
bin2c.obj: bin2c.c
|
||||
$(CC) $(CFLAGS) -c $*.c
|
||||
|
||||
sys.obj: sys.c ..\hdr\portab.h ..\hdr\device.h b_fat12.h b_fat16.h b_fat32.h
|
||||
$(CC) $(CFLAGS) -c $*.c
|
|
@ -0,0 +1,231 @@
|
|||
/****************************************************************/
|
||||
/* */
|
||||
/* exeflat.c */
|
||||
/* */
|
||||
/* EXE flattening program */
|
||||
/* */
|
||||
/* Copyright (c) 2001 */
|
||||
/* Bart E. Oldeman */
|
||||
/* 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. */
|
||||
/****************************************************************/
|
||||
|
||||
/*
|
||||
|
||||
Usage: exeflat (src.exe) (dest.sys) (relocation-factor)
|
||||
|
||||
large portions copied from task.c
|
||||
|
||||
*/
|
||||
|
||||
#include "portab.h"
|
||||
#include "exe.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define BUFSIZE 32768u
|
||||
|
||||
/* JPP - changed so will accept hex number. */
|
||||
COUNT our_atoi(REG BYTE * pszString)
|
||||
{
|
||||
BYTE Base = 10;
|
||||
BOOL Sign = FALSE;
|
||||
COUNT pnNum = 0;
|
||||
UCOUNT digit;
|
||||
if (*pszString == '-')
|
||||
|
||||
{
|
||||
pszString++;
|
||||
Sign = TRUE;
|
||||
}
|
||||
if (pszString[0] == '0' && toupper(pszString[1]) == 'X')
|
||||
|
||||
{
|
||||
Base = 16;
|
||||
pszString += 2;
|
||||
}
|
||||
for (; isxdigit(*pszString); pszString++)
|
||||
|
||||
{
|
||||
if (isdigit(pszString[0]))
|
||||
digit = pszString[0] - '0';
|
||||
|
||||
else
|
||||
digit = toupper(pszString[0]) - 'A' + 10;
|
||||
if (digit > Base)
|
||||
|
||||
{
|
||||
printf("illegal digit '%s' in offset\n", pszString);
|
||||
exit(1);
|
||||
}
|
||||
pnNum = pnNum * Base + digit;
|
||||
}
|
||||
if (Sign)
|
||||
pnNum = -pnNum;
|
||||
return pnNum;
|
||||
}
|
||||
typedef struct {
|
||||
UWORD off, seg;
|
||||
} farptr;
|
||||
int compReloc(const void *p1, const void *p2)
|
||||
{
|
||||
farptr *r1 = (farptr *) p1;
|
||||
farptr *r2 = (farptr *) p2;
|
||||
if (r1->seg > r2->seg)
|
||||
return 1;
|
||||
if (r1->seg < r2->seg)
|
||||
return -1;
|
||||
if (r1->off > r2->off)
|
||||
return 1;
|
||||
if (r1->off < r2->off)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
exe_header header;
|
||||
int i;
|
||||
size_t bufsize;
|
||||
farptr *reloc;
|
||||
UWORD start_seg;
|
||||
ULONG size, to_xfer;
|
||||
UBYTE **buffers;
|
||||
UBYTE **curbuf;
|
||||
FILE *src, *dest;
|
||||
if (argc != 4)
|
||||
|
||||
{
|
||||
printf("usage: exeflat (src.exe) (dest.sys) (relocation-factor)\n");
|
||||
return 1;
|
||||
}
|
||||
if ((src = fopen(argv[1], "rb")) == NULL)
|
||||
|
||||
{
|
||||
printf("Source file %s could not be opened\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
if (fread(&header, sizeof(header), 1, src) != 1)
|
||||
|
||||
{
|
||||
printf("Error reading header from %s\n", argv[1]);
|
||||
fclose(src);
|
||||
return 1;
|
||||
}
|
||||
if (header.exSignature != MAGIC)
|
||||
|
||||
{
|
||||
printf("Source file %s is not a valid .EXE\n", argv[1]);
|
||||
fclose(src);
|
||||
return 1;
|
||||
}
|
||||
if ((dest = fopen(argv[2], "wb+")) == NULL)
|
||||
|
||||
{
|
||||
printf("Destination file %s could not be created\n", argv[2]);
|
||||
return 1;
|
||||
}
|
||||
start_seg = our_atoi(argv[3]);
|
||||
printf("header len = %ld = 0x%lx\n", header.exHeaderSize * 16UL,
|
||||
header.exHeaderSize * 16UL);
|
||||
fseek(src, 0, SEEK_END);
|
||||
size = ftell(src) - header.exHeaderSize * 16UL;
|
||||
printf("image size (less header) = %ld = 0x%lx\n", size, size);
|
||||
printf("first relocation offset = 0 = 0x0\n");
|
||||
|
||||
/* first read file into memory chunks */
|
||||
fseek(src, header.exHeaderSize * 16UL, SEEK_SET);
|
||||
buffers = malloc((size + BUFSIZE - 1) / BUFSIZE * sizeof(char *));
|
||||
if (buffers == NULL)
|
||||
|
||||
{
|
||||
printf("Allocation error\n");
|
||||
return 1;
|
||||
}
|
||||
bufsize = BUFSIZE;
|
||||
for (to_xfer = size, curbuf = buffers; to_xfer > 0;
|
||||
to_xfer -= bufsize, curbuf++)
|
||||
|
||||
{
|
||||
if (to_xfer < BUFSIZE)
|
||||
bufsize = to_xfer;
|
||||
*curbuf = malloc(bufsize);
|
||||
if (*curbuf == NULL)
|
||||
|
||||
{
|
||||
printf("Allocation error\n");
|
||||
return 1;
|
||||
}
|
||||
if (fread(*curbuf, sizeof(char), bufsize, src) != bufsize)
|
||||
|
||||
{
|
||||
printf("Source file read error %ld %d\n", to_xfer, bufsize);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
fseek(src, header.exRelocTable, SEEK_SET);
|
||||
reloc = malloc(header.exRelocItems * sizeof(farptr));
|
||||
if (reloc == NULL)
|
||||
|
||||
{
|
||||
printf("Allocation error\n");
|
||||
return 1;
|
||||
}
|
||||
if (fread(reloc, sizeof(farptr), header.exRelocItems, src) !=
|
||||
header.exRelocItems)
|
||||
|
||||
{
|
||||
printf("Source file read error\n");
|
||||
return 1;
|
||||
}
|
||||
fclose(src);
|
||||
qsort(reloc, header.exRelocItems, sizeof(reloc[0]), compReloc);
|
||||
for (i = 0; i < header.exRelocItems; i++)
|
||||
|
||||
{
|
||||
ULONG spot = ((ULONG) reloc[i].seg << 4) + reloc[i].off;
|
||||
UBYTE *spot0 = &buffers[spot / BUFSIZE][spot % BUFSIZE];
|
||||
UBYTE *spot1 = &buffers[(spot + 1) / BUFSIZE][(spot + 1) % BUFSIZE];
|
||||
UWORD segment = ((UWORD) * spot1 << 8) + *spot0;
|
||||
printf("relocation at 0x%04x:0x%04x ->%04x\n", reloc[i].seg,
|
||||
reloc[i].off, segment);
|
||||
segment += start_seg;
|
||||
*spot0 = segment & 0xff;
|
||||
*spot1 = segment >> 8;
|
||||
}
|
||||
|
||||
/* write dest file from memory chunks */
|
||||
bufsize = BUFSIZE;
|
||||
for (to_xfer = size, curbuf = buffers; to_xfer > 0;
|
||||
to_xfer -= bufsize, curbuf++)
|
||||
|
||||
{
|
||||
if (to_xfer < BUFSIZE)
|
||||
bufsize = to_xfer;
|
||||
if (fwrite(*curbuf, sizeof(char), bufsize, dest) != bufsize)
|
||||
|
||||
{
|
||||
printf("Destination file write error\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
fclose(dest);
|
||||
printf("\nProcessed %d relocations\n", header.exRelocItems);
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
!include "..\config.mak"
|
||||
|
||||
CFLAGS = -I$(INCLUDEPATH) -I..\hdr
|
||||
|
||||
production: patchobj.exe exeflat.exe
|
||||
|
||||
patchobj.exe: patchobj.obj
|
||||
$(CC) -L$(LIBPATH) patchobj.obj
|
||||
|
||||
exeflat.exe: exeflat.obj
|
||||
$(CC) -L$(LIBPATH) $(CFLAGSC) exeflat.obj
|
||||
|
||||
patchobj.obj: patchobj.c ..\config.mak
|
||||
|
||||
exeflat.obj: exeflat.c ..\hdr\exe.h ..\config.mak
|
||||
$(CC) $(CFLAGSC) $(CFLAGS) -c exeflat.c
|
||||
|
||||
clobber: clean
|
||||
$(RM) bin2c.com exeflat.exe patchobj.exe
|
||||
|
||||
clean:
|
||||
$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las status.me
|
||||
|
|
@ -0,0 +1,215 @@
|
|||
/*****************************************************************************
|
||||
** PATCHOBJ facility - change strings in the LNAMES record
|
||||
**
|
||||
** Copyright 2001 by tom ehlert
|
||||
**
|
||||
** GPL bla to be added, but intended as GPL
|
||||
**
|
||||
**
|
||||
** 09/06/2001 - initial revision
|
||||
** not my biggest kind of software; anyone willing to add
|
||||
** comments, errormessages, usage info,...???
|
||||
**
|
||||
*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE (1==1)
|
||||
#define FALSE (0==1)
|
||||
#endif
|
||||
|
||||
|
||||
struct {
|
||||
char *sin,*sout;
|
||||
} repl[100];
|
||||
int repl_count;
|
||||
|
||||
|
||||
void quit(char *s,...)
|
||||
{
|
||||
vprintf(s,(void*)((char *)&s+sizeof(s)));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void define_replace(char *sin)
|
||||
{
|
||||
char *s;
|
||||
|
||||
if (repl_count >= 99)
|
||||
quit("too many replacements");
|
||||
|
||||
if ((s = strchr(sin, '=')) == NULL)
|
||||
quit("illegal replacement <%s>, missing '='", sin);
|
||||
|
||||
*s = 0;
|
||||
repl[repl_count].sin = sin;
|
||||
repl[repl_count].sout = s+1;
|
||||
|
||||
repl_count++;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *argptr;
|
||||
int argloop;
|
||||
int cont;
|
||||
int file = 0;
|
||||
FILE *fd,*fdo;
|
||||
char *inname=0,*outname= "~patchob.tmp";
|
||||
|
||||
int use_temp_file = TRUE;
|
||||
|
||||
argc--,argv++;
|
||||
|
||||
for (; argc != 0; argc--,argv++)
|
||||
{
|
||||
argptr = *argv;
|
||||
|
||||
if (*argptr != '-' && *argptr != '-')
|
||||
{
|
||||
if (inname == 0) { inname = argptr; continue;}
|
||||
define_replace(argptr);
|
||||
continue;
|
||||
}
|
||||
switch (toupper(argptr[1]))
|
||||
{
|
||||
case 'O':
|
||||
outname = argptr+2;
|
||||
use_temp_file = FALSE;
|
||||
break;
|
||||
default:
|
||||
quit("illegal argument <%s>\n",argptr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (inname == 0)
|
||||
quit("Inputfile must be specified\n");
|
||||
|
||||
if (repl_count == 0)
|
||||
quit("no replacements defined");
|
||||
|
||||
|
||||
if ((fd = fopen(inname,"rb")) == NULL) /* open for READ/WRITE */
|
||||
quit("can't read %s\n",inname);
|
||||
|
||||
if ((fdo = fopen(outname,"wb")) == NULL) /* open for READ/WRITE */
|
||||
quit("can't write %s\n",outname);
|
||||
|
||||
go_records(fd,fdo);
|
||||
|
||||
fclose(fd);
|
||||
fclose(fdo);
|
||||
if (use_temp_file)
|
||||
{
|
||||
unlink(inname);
|
||||
rename(outname,inname);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
fputs(
|
||||
"DELSYM V1.0 5'95by tom ehlert, SIG Aachen\n"
|
||||
" delete symbolic info in object files\n"
|
||||
"usage:\n"
|
||||
" DELSYM infile [outfile]\n"
|
||||
,stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
struct record
|
||||
{
|
||||
unsigned char rectyp;
|
||||
unsigned datalen;
|
||||
unsigned char buffer[0x2000];
|
||||
} Record,Outrecord;
|
||||
|
||||
|
||||
go_records(FILE *fdin,FILE *fdo)
|
||||
{
|
||||
unsigned char stringlen;
|
||||
unsigned char *string,*s;
|
||||
int i,j;
|
||||
unsigned char chksum;
|
||||
|
||||
do {
|
||||
if (fread(&Record,1,3,fdin) != 3) { /* read type and reclen*/
|
||||
/* printf("end of fdin read\n"); */
|
||||
break;
|
||||
}
|
||||
if (Record.datalen > sizeof(Record.buffer))
|
||||
quit ("record to large : length %u Bytes \n",Record.datalen);
|
||||
|
||||
if (fread(Record.buffer,1,Record.datalen,fdin) != Record.datalen)
|
||||
{
|
||||
printf("invalid record format\n");
|
||||
quit ("can't continue\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (Record.rectyp != 0x96) /* we are only interested in LNAMES */
|
||||
{
|
||||
fwrite(&Record,1,3+Record.datalen,fdo);
|
||||
continue;
|
||||
}
|
||||
|
||||
Outrecord.rectyp = 0x96;
|
||||
Outrecord.datalen= 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < Record.datalen-1; )
|
||||
{
|
||||
stringlen = Record.buffer[i];
|
||||
i++;
|
||||
|
||||
string = &Record.buffer[i];
|
||||
i += stringlen;
|
||||
|
||||
|
||||
if (i > Record.datalen)
|
||||
quit("invalid lnames record");
|
||||
|
||||
|
||||
for (j = 0; j < repl_count; j++)
|
||||
if (memcmp(string,repl[j].sin,stringlen) == 0
|
||||
&& strlen(repl[j].sin) == stringlen)
|
||||
{
|
||||
string = repl[j].sout;
|
||||
stringlen = strlen(repl[j].sout);
|
||||
}
|
||||
Outrecord.buffer[Outrecord.datalen] = stringlen;
|
||||
Outrecord.datalen++;
|
||||
memcpy(Outrecord.buffer+Outrecord.datalen,string,stringlen);
|
||||
Outrecord.datalen += stringlen;
|
||||
}
|
||||
|
||||
chksum = 0;
|
||||
for (s = (unsigned char *)&Outrecord; s < &Outrecord.buffer[Outrecord.datalen]; s++)
|
||||
chksum += *s;
|
||||
|
||||
Outrecord.buffer[Outrecord.datalen] = -chksum;
|
||||
Outrecord.datalen++;
|
||||
|
||||
/* printf("^sum = %02x - %02x\n",chksum,-chksum); */
|
||||
|
||||
|
||||
fwrite(&Outrecord,1,3+Outrecord.datalen,fdo);
|
||||
|
||||
} while (Record.rectyp != 0x00 /*ENDFIL*/);
|
||||
|
||||
printf("\n");
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
/*****************************************************************************
|
||||
** RelocInf.C
|
||||
**
|
||||
** provide some info about relocation entries in an exe file
|
||||
**
|
||||
** usage:
|
||||
** RelocInfo exefile
|
||||
**
|
||||
**
|
||||
** Copyright 2001 by tom ehlert
|
||||
**
|
||||
** GPL bla to be added, but intended as GPL
|
||||
**
|
||||
**
|
||||
** 09/06/2001 - initial revision
|
||||
** not my biggest kind of software; anyone willing to add
|
||||
** comments, errormessages, usage info,...???
|
||||
**
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
typedef unsigned short UWORD;
|
||||
typedef unsigned long ULONG;
|
||||
#ifndef _MSC_VER
|
||||
#define const
|
||||
#define __cdecl cdecl
|
||||
#endif
|
||||
|
||||
/* from EXE.H */
|
||||
typedef struct
|
||||
{
|
||||
UWORD exSignature;
|
||||
UWORD exExtraBytes;
|
||||
UWORD exPages;
|
||||
UWORD exRelocItems;
|
||||
UWORD exHeaderSize;
|
||||
UWORD exMinAlloc;
|
||||
UWORD exMaxAlloc;
|
||||
UWORD exInitSS;
|
||||
UWORD exInitSP;
|
||||
UWORD exCheckSum;
|
||||
UWORD exInitIP;
|
||||
UWORD exInitCS;
|
||||
UWORD exRelocTable;
|
||||
UWORD exOverlay;
|
||||
}
|
||||
exe_header;
|
||||
|
||||
#define MAGIC 0x5a4d
|
||||
|
||||
struct relocEntry{
|
||||
UWORD off;
|
||||
UWORD seg;
|
||||
UWORD refseg;
|
||||
};
|
||||
|
||||
int __cdecl compReloc(const void *p1, const void *p2)
|
||||
{
|
||||
struct relocEntry *r1 = (struct relocEntry*)p1;
|
||||
struct relocEntry *r2 = (struct relocEntry*)p2;
|
||||
|
||||
if (r1->refseg > r2->refseg) return 1;
|
||||
if (r1->refseg < r2->refseg) return -1;
|
||||
|
||||
if (r1->seg > r2->seg) return 1;
|
||||
if (r1->seg < r2->seg) return -1;
|
||||
|
||||
if (r1->off > r2->off) return 1;
|
||||
if (r1->off < r2->off) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
main(int argc,char *argv[])
|
||||
{
|
||||
FILE *fdin;
|
||||
exe_header header;
|
||||
struct relocEntry *reloc;
|
||||
|
||||
int i;
|
||||
ULONG image_offset;
|
||||
|
||||
|
||||
if (argc < 2 || (fdin = fopen(argv[1],"rb")) == NULL)
|
||||
{
|
||||
printf("can't open %s\n",argv[1]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (fread(&header, sizeof(header),1,fdin) != 1 ||
|
||||
header.exSignature != MAGIC)
|
||||
{
|
||||
printf("%s is no EXE file\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("%u relocation entries found\n", header.exRelocItems);
|
||||
|
||||
if (header.exRelocItems > 0x8000/sizeof(*reloc))
|
||||
{
|
||||
printf("too many relocation entries \n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((reloc = malloc(header.exRelocItems*sizeof(*reloc))) == NULL)
|
||||
{
|
||||
printf("can't alloc memory\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (fseek(fdin, header.exRelocTable, 0))
|
||||
{
|
||||
printf("can't seek\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (i = 0; i < header.exRelocItems; i++)
|
||||
if (fread(reloc+i, 4,1,fdin) != 1)
|
||||
{
|
||||
printf("can't read reloc info\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (i = 0; i < header.exRelocItems; i++)
|
||||
{
|
||||
image_offset = (ULONG)header.exHeaderSize * 16;
|
||||
|
||||
image_offset += ((ULONG)reloc[i].seg << 4) + reloc[i].off;
|
||||
|
||||
if (fseek(fdin, image_offset, 0))
|
||||
{
|
||||
printf("can't seek reloc data\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (fread(&reloc[i].refseg, 2,1,fdin) != 1)
|
||||
{
|
||||
printf("can't read rel data for item %d\n",i);
|
||||
exit(1);
|
||||
}
|
||||
/* printf("%04x:%04x -> %04x\n", reloc[i].seg, reloc[i].off, reloc[i].refseg); */
|
||||
}
|
||||
|
||||
/* sort reloc entries */
|
||||
|
||||
qsort(reloc, header.exRelocItems, sizeof(*reloc), compReloc);
|
||||
|
||||
for (i = 0; i < header.exRelocItems; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
printf("# seg:off references data in -->\n");
|
||||
printf("%3d %04x:%04x -> %04x\n", i,reloc[i].seg, reloc[i].off, reloc[i].refseg);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue