Compare commits

...

392 Commits

Author SHA1 Message Date
Kenneth J Davis
654e7b7a6c
debug macro adjustments to separate what is printed in DEBUG mode 2025-03-28 19:57:59 -04:00
Kenneth J Davis
7fd6a6b71b
add alternative path (compile time determined) if attempt to write >4GB should fail whole write or succeed but only up to 4GB (based on email from Tom) 2025-03-28 17:04:59 -04:00
Kenneth J Davis
767cafa737
initialize pChildEnvSeg to 0 as if failed, callers would potentially free random memory address 2025-03-28 17:03:58 -04:00
Kenneth J Davis
868ae24d3c
correct env size allocated, should be 0x80+3 not 80+3 as filename is 128 bytes 2025-03-28 17:02:58 -04:00
Kenneth J Davis
bb8b581915
add some comments and debug prints 2025-03-28 17:01:49 -04:00
Kenneth J Davis
93add63a3b
add assert macro 2025-03-28 16:59:13 -04:00
Kenneth J Davis
fa0959cb82
keep history.txt updated for pending release 2025-03-28 14:21:09 -04:00
Kenneth J Davis
9967d2d662
add some debug prints and update some to use debug print facility 2025-03-28 14:20:26 -04:00
Kenneth J Davis
de08998969
From Tom Ehlert, gracefully error when attempting to write past 4GB instead of wrapping and causing corruption. 2025-03-28 14:14:44 -04:00
Kenneth J Davis
42a006b964
add some comments regarding share 2025-03-28 10:24:19 -04:00
Kenneth J Davis
634257b913
add convenience switch to redirect debug output to COM port when building, update some debug prints to use our debug interface so print to COM port when enabled. 2025-03-28 10:24:19 -04:00
E. C. Masloch
192cccc68f in 2F.4A02 advance firstAvailableBuf past the alignment as well (neater) 2025-03-16 20:56:22 -04:00
E. C. Masloch
85be764a50 fix 2F.4A MS-DOS v5 style HMA access services
* Reject allocation call with too large requested size,
rather than allocating the remaining HMA.
* Align returned offset to paragraph boundary.
* Allow to allocate up to the very last byte of the HMA,
rather than 1 byte less.
* Pass last allocated byte to AllocateHMASpace instead
of the byte past it, which would carry for a full allocation.
2025-03-16 20:56:22 -04:00
Kenneth J Davis
5de2eb1aa0
avoid some useless messages when building release 2024-12-31 18:08:11 -05:00
Kenneth J Davis
dffdc492bf
linker arguments passed via response file, doesn't interact well with explicit options 2024-12-31 16:55:23 -05:00
Kenneth J Davis
6f5a136a60
ensure cloning submodules 2024-12-31 16:23:20 -05:00
Kenneth J Davis
44dd357f86
update readme for v2.44 2024-12-31 15:44:14 -05:00
Andrew Bird
6cd67917a8
Merge pull request #192 from jmalak/fix-2
CI-build: do download and setup Open Watcom more transparent
2024-12-23 22:52:27 +00:00
Andrew Bird
abeda02ee1
Merge pull request #191 from jmalak/fix-1
build: modify echoto.bat to check arguments overflow
2024-12-23 22:47:26 +00:00
Jiri Malak
86ea0f75aa CI-build: do download and setup Open Watcom more transparent 2024-12-23 23:37:16 +01:00
Jiri Malak
ced1587aa4 build: modify echoto.bat to check arguments overflow 2024-12-23 23:28:49 +01:00
Kenneth J Davis
7cd0e19681
build 2044 - update release documentation 2024-12-21 13:09:09 -05:00
Kenneth J Davis
1cc00e194d
avoid race condition that could corrupt user stack if DOS re-entered too soon
apply suggested fix from SF bug 215 (https://sourceforge.net/p/freedos/bugs/215/), InDOS cleared but small chance DOS re-entered before user stack restored thus corrupting user stack
2024-08-19 16:31:22 -04:00
Kenneth J Davis
dabfaf7d54
enable installation check for driver.sys
For now we still only support subfunction 3 (return drive table) and subfunction 0 (check if installed) which we say yes.  This allows DOS Internals DRVINFO.EXE to correctly use internal drive table (it checks if installed and doesn't bother if not) and return corresponding information.  Note: subfunction 3 is still handled in int2f.asm for now, but may be moved to cleaner (but bigger and slower) implementation in inthndlr.c
2024-08-19 15:05:12 -04:00
Kenneth J Davis
1c6d1e8434
add reminder comment 2024-08-18 16:25:18 -04:00
Kenneth J Davis
f25e959e0a
response file is generated during build, update gitignore 2024-08-18 16:24:21 -04:00
Kenneth J Davis
2ce6dc00de
exeflat failed to advance str so didn't actually skip whitespace at beginning of string, additional comments 2024-08-18 16:22:15 -04:00
Andrew Bird
8f056cce6d
Merge pull request #187 from andrewbird/pr180
exeflat: Update usage text for indirect file
2024-08-18 13:55:22 +01:00
Andrew Bird
c6b227b783
Merge pull request #186 from andrewbird/pr177a
Resurrected Pr177
2024-08-18 10:43:00 +01:00
Andrew Bird
fb9704f62e sys: Correct bin2c usage text 2024-08-18 10:40:52 +01:00
E. C. Masloch
f7947771cb config: only overwrite skip config prompt if it was displayed
This allows to boot with SWITCHES=/F without any lone CRs.
2024-08-05 20:45:16 -04:00
E. C. Masloch
314c8b627b do not display any lone Carriage Returns
In combination with SWITCHES=/N in fdconfig.sys this commit makes
it so only proper CR LF linebreaks are displayed, for instance when
piping dosemu2 output to a file.

SWITCHES=/F will set SkipConfigSeconds so that config.c SkipLine will
display a string reading "\r%79s\r" to delete the prompt that it has
displayed. This overwriting should not be needed for SkipConfigSeconds=0
however. Refer to subsequent commit.
2024-08-05 20:45:16 -04:00
Bernd Böckmann
42980dfe7d fix list traversal bug in update_dcb()
This caused the kernel to hang when loading NETDRIVE.SYS
2024-08-05 20:44:15 -04:00
Kenneth J Davis
ed2fd81927
add initial support for DRIVER.SYS
currently only skeleton logic and implementation of install check & get drive data table list [returns ddt* which allows mapping DOS drive # to BIOS drive # for drives handled by default DOS block driver]
2024-08-05 20:37:25 -04:00
Kenneth J Davis
8bdb2db5f6
missing 0 in constant - build fix 2024-08-05 09:49:54 -04:00
Kenneth J Davis
b9440c7e0e
additional comments 2024-08-05 09:41:13 -04:00
Jiří Malák
bf53e22d7a
exeflat: Update usage text for indirect file 2024-07-17 22:28:01 +02:00
Jiri Malak
db43a4b343 far-fix: symbols BIOSInt13, UserInt13 and BIOSInt19 are far (in LGROUP)
these symbols are in LGROUP and generaly cannot be addressed by DGROUP:offset
for Turbo C DGROUP offset overflow because symbols are too far to be addressed by DGROUP offset
2024-07-15 15:21:36 -04:00
Jiri Malak
4a1fd57f3a libm.lib: The i4m module from OW-CRTL is no longer used
now FreeDOS own implementation is used
this module is removed from the library to prevent misuse of this module
2024-07-15 15:20:21 -04:00
Jiri Malak
7a5af34727 ow-dos4gw: move configuration for DOS4GW to config.b 2024-07-15 08:04:43 -04:00
Jiri Malak
0231c98e3f ow-build: add global compiler control option to CC and CL macros
move only options which is related to the host environment not for target
-zq quiet output (all)
-fo=.obj set default extension for object file to .obj instead .o (Linux only)
2024-07-15 08:03:18 -04:00
Jiri Malak
c0009ebaaf echoto.bat: correct batch file for all parameters blank 2024-07-14 17:09:14 -04:00
Jiri Malak
a5b516dd7b exeflat: add support for response file to exeflat utility
the command line can overflow DOS max length that it fixes this issue
2024-07-14 15:19:48 -04:00
Jiri Malak
2fb0956513 tc2-build: correct various build breaks for Turbo C 2.0 build 2024-07-13 19:37:21 -04:00
Jiri Malak
58573d69d9 tc2-build: correct various build breaks for Turbo C 2.0 build 2024-07-13 19:37:21 -04:00
Jiří Malák
d6c50ebbe6 fix dos environment size issue with TC make 2024-07-13 07:43:07 -04:00
Jiri Malak
f9beab6d61 headers: resolve headers minor issues
correct header name in comments
use algnbyte.h and algndflt.h as "user" header instead of "system" header
2024-07-11 06:37:00 -04:00
Jiri Malak
2985b3386c ow: use safer form of #pragma aux
using ISO standard reserved word form of #pragma aux
2024-07-11 06:35:41 -04:00
Jiri Malak
5304e657fd time.t: resolve issue with internal and standard C time.h files and remove all hacks
- fix issue by renaming header file and symbols which consolidate with standard C time.h
- rename also date.h for consistency
- remove all hacks from make files and from sys.c

now can share new dtime.h with standard C time.h without any collision that any order of internal and standard C header path is possible
2024-07-10 11:32:10 -04:00
Jiri Malak
4ca28252da code-mismatch: fix various kernel code discrepancies which break TURBO C build
main issue is missing ASM attributes that C and asm code uses different names
correct long constant by standard suffix 'L' or 'UL'
2024-07-10 11:30:20 -04:00
Andrew Bird
c928849cea
Merge pull request #163 from jmalak/ci-build
CI-build: a little simplify CI-build development
2024-07-08 20:33:12 +01:00
Jiri Malak
799a09681e CI-build: a little simplify CI-build development
ignore _downloads, _output and _watcom sub-directories contents in git
use _downloads sub-directory for CI buil OW snapshot
2024-07-08 20:04:44 +02:00
Jiří Malák
1d4ac3bcc5 utils: remove wcl386 banners 2024-07-06 07:52:39 -04:00
Jiří Malák
046638f48c utils: remove wcl386 banners 2024-07-06 07:52:39 -04:00
Jiří Malák
e985cc36b3 utils: build utility programs by Open Watcom for Linux and Windows 2024-07-06 07:52:39 -04:00
Bernd Wilhelm Böckmann
c012700190 sys: update for DR-DOS 7.02-03, documentation update 2024-05-20 07:08:27 -04:00
Bernd Wilhelm Böckmann
fb07348b7c sys: Enhanced DR-DOS 7.01.01-06 actually not called Enhanced 2024-05-20 07:08:27 -04:00
Bernd Wilhelm Böckmann
e9c6682dbe sys: add newest findings regarding operation system support 2024-05-20 07:08:27 -04:00
Bernd Wilhelm Böckmann
7ce25f0ac4 sys: more bootloader / OS compatibility work 2024-05-20 07:08:27 -04:00
Bernd Wilhelm Böckmann
cc4ad94f0a update /OEM:LMSPACK description 2024-05-20 07:08:27 -04:00
Bernd Wilhelm Böckmann
ab9ad1e299 sys: fix Bernds version confusion 2024-05-20 07:08:27 -04:00
Bernd Wilhelm Böckmann
3b9403a353 first print version info, then operating mode 2024-05-20 07:08:27 -04:00
Bernd Wilhelm Böckmann
76f14d608d add support for more kernels to SYS, throw out EDR specifics 2024-05-20 07:08:27 -04:00
E. C. Masloch
8e8fcd1628 sys: fix, work on DOS versions that clobber di in int 25h/26h
Running on DR-DOS v7.03, the int 25h call zeroes di leading to a crash
here when di is expected to preserve the stack pointer. So push di twice
and pop it twice. The second pop always gets the saved sp, regardless of
whether int 21h or int 25h/26h are used.

Refer to https://github.com/SvarDOS/edrdos/issues/57#issuecomment-2119360035
2024-05-19 17:39:15 -04:00
Bernd Wilhelm Böckmann
1ce349ef26 fixes #148 2024-05-16 18:01:06 -04:00
Andrew Bird
1b6de0fda6
Merge pull request #155 from andrewbird/ow-01
CI: Switch back to openwatcom current build
2024-04-29 01:05:56 +01:00
Andrew Bird
875d12dc56 CI: Switch back to openwatcom current build
The latest build got some compatibilty fixes so we can now start using
it again [fixes #138]
2024-04-29 00:56:11 +01:00
Bernd Boeckmann
c08313ab62 fix issue #144 by correcting getbpb return code
getbpb now returns 0 instead of S_DONE in case of an uninitialized
partition, copying the default BPB into the BPB.

The previous return of S_DONE in case of uninitialized partitions
resulted in rp->r_bpptr not getting set in bldbpb. This in
combination with indicating success resulted in garbage returned
via rp->r_bpptr.

The DPB values are now being set to the default BPB ones in media_check
ea951d8136/kernel/fatfs.c (L1728)
via call to bpb_to_dpb in case of an uninitialized partition.
This may have side effects. But because DF_NOACCESS is still set, I
think it is the right way to do it.

The commit also masks high bit of AL for INT25/26 containing the drive
number. Some programs may set the bit according to RBIL:

"examination of CPWIN386.CPL indicates that if this call fails with
error 0408h on an old-style (<32M) call, one should retry the
call with the high bit of the drive number in AL set"

Leaving the bit set may render the given drive number unusable.
It should do no harm to mask it to increase the chance of the operation
to succeed. Also, the AH should be set to zero, because drive is given
only in AL.
2024-03-05 16:35:31 -05:00
Andrew Bird
ea951d8136
Merge pull request #137 from andrewbird/ci-dos
CI add Watcom and optionally Turbo C 2.01 builds
2024-03-05 10:11:25 +00:00
Andrew Bird
d8ecb409a9 CI: Use FreeDOS kernel and FreeCOM 2024-02-24 19:38:56 +00:00
Andrew Bird
5b87617f66 CI: No need to rerun the workflow if PR is edited 2024-02-24 17:38:16 +00:00
Andrew Bird
92f9a5125e CI: Test DOS built kernels for existence and boot 2024-02-24 17:38:15 +00:00
Andrew Bird
6092afc74d Build: Country submodule now has production target
When country was converted to a submodule (by me) the production
installation target was hacked onto the kernel subdirectory Makefile
which wasn't ideal. Introduce a production target into the country
Makefile that does the installation. Since we want the submodule to be
buildable standalone, we can't include the variable definitions from the
upper level, such as $(DIRSEP) and $(CP), so the caller has to pass those
in at build time if using the production target.

Tested on Linux (GCC + Watcom) and DOS (Watcom)
2024-02-24 17:38:14 +00:00
Andrew Bird
3c97674cbf Country: Update submodule 2024-02-24 17:38:13 +00:00
Andrew Bird
4c58d4c7e2 CI: Add DOS builds
1/ Watcom 1.9
   a) Kernel and other directories building fine
   b) Share doesn't support Watcom for TSR.

2/ Turbo C 2.01
   a) Kernel build needs some functions that are missing.
   b) Sys not building for the same reason,
   c) Share building nicely.
   d) Need to figure out how to get tc201 compiler to Github Actions

3/ IA16-GCC
   a) not currently supported by build.bat so commented out
2024-02-24 17:37:41 +00:00
Andrew Bird
be11b50252 Share: Update submodule 2024-02-23 15:00:48 +00:00
E. C. Masloch
8552d833bb boot: fix boot loader assembly listing files [fixes #97] 2024-02-18 14:20:56 -05:00
E. C. Masloch
1cd4a75e98 sys: fix, allow odd magic offsets to work as expected
Created using this scriptlet:

sed -i -re 's/\(\(int \*\)newboot\)\[([0-9A-Fa-fxX]+)\/sizeof\(int\)\]/\*\(int \*\)\(\&newboot\[\1\]\)/g' sys/sys.c
2024-02-18 14:20:56 -05:00
E. C. Masloch
fc3032deb7 oemboot: use magic offsets macro 2024-02-18 14:20:56 -05:00
E. C. Masloch
19058ff1bf sys: correct a magic offset (problem: odd offsets won't work) 2024-02-18 14:20:56 -05:00
E. C. Masloch
9783ac97e0 boot32, boot32lb: mark magic offsets with macro 2024-02-18 14:20:56 -05:00
E. C. Masloch
d9b0615ad5 magic: prepare for FAT32 use 2024-02-18 14:20:56 -05:00
E. C. Masloch
5a6d3a449f makefile: list magic.mac for boot 2024-02-18 14:20:56 -05:00
E. C. Masloch
bcf3c1701a magic.mac: extract from boot.asm 2024-02-18 14:20:56 -05:00
E. C. Masloch
4ae6f22249 sys, boot: mark additional magic offsets 2024-02-18 14:20:56 -05:00
E. C. Masloch
eb75bea6c1 boot: display new magic offset in hexadecimal 2024-02-18 14:20:56 -05:00
E. C. Masloch
4d30378bb6 boot: extract magicoffset macro 2024-02-18 14:20:56 -05:00
E. C. Masloch
b5414153c6 boot: display new magic offset (but in decimal) 2024-02-18 14:20:56 -05:00
E. C. Masloch
f036741b6b sys: update magic offset of OEM FAT12 jmp offset 2024-02-18 14:20:56 -05:00
E. C. Masloch
55f2a81406 sys: check default content of all magic offset patchsites 2024-02-18 14:20:56 -05:00
E. C. Masloch
0776645017 boot: move READBUF and READADDR_OFF/SEG to allow 8 KiB sector size 2024-02-18 14:20:56 -05:00
E. C. Masloch
5cbe1ffcf0 boot: fix and update memory layout map 2024-02-18 14:20:56 -05:00
E. C. Masloch
ef10fa11e3 boot32, boot32lb: fix and update memory layout maps 2024-02-18 14:20:56 -05:00
E. C. Masloch
2aa51a1992 boot: move cluster list to 1FE0h:2200h (128 KiB file, up to /L 0x200)
1FE0h:2200h happens to be linear 22000h. Like the memory map
update to the FAT32 loaders for #127 this allows to load a
file of up to 128 KiB (rounded to cluster size) with an /L
parameter for SYS of up to 0x200.
2024-02-18 14:20:56 -05:00
E. C. Masloch
4682e23b57 boot: rename FATBUF to CLUSTLIST to better reflect use (oemboot pick) 2024-02-18 14:20:56 -05:00
E. C. Masloch
9ac407ae63 boot32, boot32lb: avoid big file overlap with FAT sector [fixes #127] 2024-02-18 14:20:56 -05:00
Kenneth J Davis
edd0732433
move FAR item to own line 2024-02-11 08:59:32 -05:00
Kenneth J Davis
a593799eb0
add some comments regarding relocation of kernel during configuration 2024-02-10 17:38:19 -05:00
Kenneth J Davis
114236da17
allow selection of COM port for debug prints easily overridden during compile, e.g. build.bat /D DEBUG_PRINT_COMPORT /V 2 2024-02-10 17:36:33 -05:00
Kenneth J Davis
716f732e3a
rework to make handling flags simpler, from ecm 2024-02-10 17:34:00 -05:00
Kenneth J Davis
7a73120228
copy over debug print to COM ports from UNSTABLE branch 2024-02-10 17:27:23 -05:00
Kenneth J Davis
795c1df742
prevent possible hang on loading device driver, from ecm 2024-02-08 19:24:55 -05:00
Andrew Bird
db949bf0b2
Merge pull request #136 from andrewbird/ci-update
CI: Update github actions and runner versions
2024-02-07 12:46:05 +00:00
Andrew Bird
c0467ef7e3 CI: Update github actions and runner versions 2024-02-07 12:35:27 +00:00
Kenneth J Davis
6a94489230
handle wmake and gmake differences
wmake requires changing into directory as ignores -C option, gmake ignores cd into directory so requires -C subdir option
2024-02-06 18:26:26 -05:00
Kenneth J Davis
19c35ee574
use tab not spaces for Makefile 2024-02-06 16:36:15 -05:00
Bocke
9b6a8579d1 Make build work on DOS
Double ampersands are not supported by DOS command line interpreters. The previous would work only on (modern-ish) Windows.
2024-02-05 10:47:59 -05:00
Bernd Boeckmann
093dea9a7b initdisk.c: format specifier fixes 2 2024-02-04 20:44:19 -05:00
Kenneth J Davis
4ffc5c10a5 fix bug#121 don't look for 123? unless still looking for verb at start of line
allows correctly parsing lines like SHELL=4DOS.COM which otherwise strips 4 leading to looking for shell of "DOS.COM"
2024-02-04 20:37:43 -05:00
Kenneth J Davis
f7bf549544 correct xor to test not clear value, invert test so 808x is 0 and NEC is 1 matching returned value 2024-02-04 19:43:09 -05:00
Kenneth J Davis
07155e6184 fix bug#123, detect NEC V20/V30 as 186 instead of only 8086/8088, based on ecm-pushbx ldebug
see https://hg.pushbx.org/ecm/ldebug/file/7f3440d5824d/source/init.asm#l3071

(cherry picked from commit 5fdcc1d214b821fde33a5bd92ea7d7c0134a2056)
2024-02-04 19:43:09 -05:00
Kenneth J Davis
431be02b0a rework update_dcb() to avoid potential access uninitialized memory 2024-02-03 22:00:17 -05:00
C. Masloch
1c2f541689 intr: avoid random trace in (init_)call_intr 2024-02-03 21:04:11 -05:00
C. Masloch
3ef6d61609 main: fix, only init env once in PSPInit, do not set cmdline tail 2024-02-03 21:01:17 -05:00
C. Masloch
ab3cac6d0c allow gcc build to succeed with -DWIN31SUPPORT 2024-02-03 20:59:11 -05:00
E. C. Masloch
42d3ae6aac boot32, boot32lb: fix EDR-DOS incompatibility [fixes #119] 2024-02-03 20:55:57 -05:00
E. C. Masloch
53d3fd556b boot32: display an error indicator instead of silently waiting 2024-02-03 20:55:57 -05:00
E. C. Masloch
a189ceb650 boot32: comment out unused print function 2024-02-03 20:55:57 -05:00
E. C. Masloch
630735e14a boot32: save another byte, use loop instruction 2024-02-03 20:55:57 -05:00
E. C. Masloch
3415ad93c9 boot32: fix very old bug, init high byte of fat_secshift
It turned out that this loader was severely broken for many years,
at least since 2012 (the git repo's creation). This variable was
read as a word to set cx for a loop, but only the low byte had
been written. The high byte happened to be 0EEh so cn_loop would
always zero out the FAT sector to read.

This _happened_ to work if the first root directory cluster and
all the kernel file clusters were all referenced in the first
sector of the FAT. Otherwise it would blow up.
2024-02-03 20:55:57 -05:00
E. C. Masloch
52136b27d6 boot32: optimise read sector increment to prepare for DL patch 2024-02-03 20:55:57 -05:00
Bernd Boeckmann
9a7d22701d initdisk.c: fix wrong printf format specifiers, fixes #122 2024-02-03 20:52:42 -05:00
Kenneth J Davis
db71b1a783
don't normally show InitDisk while booting 2023-12-20 17:17:08 -05:00
Kenneth J Davis
de96d00402
additional comments about LBA detection 2023-12-20 00:35:01 -05:00
Bernd Boeckmann
cab32344bb only use AH for EDD version detection, as AL is reserved...
...according to the spec
2023-12-19 23:50:02 -05:00
Bernd Boeckmann
a5431d9245 remove BIOS assisted LBA translation, not sure its worth including it 2023-12-19 23:50:02 -05:00
Bernd Boeckmann
b33afdbfad change handling of head count < 2, was a no-op since last commit...
... because heads was always at least 1.
2023-12-19 23:50:02 -05:00
Bernd Boeckmann
c20a97e844 initdisk: actually restrict disk size to 2TB, fix ExtLBAForce usage 2023-12-19 23:50:02 -05:00
Kenneth J Davis
569337a7ef
fix bug# 98 (correct bad CONFIG value 19 with bad value 14, should be 6) and add support for additional CONFIG options Verbose and PartitionMode to sys CONFIG processing 2023-12-19 19:50:22 -05:00
Kenneth J Davis
d027c797a0
update docs/history.txt from git log in preparation for build 2044 / v2.44 release 2023-12-18 22:00:30 -05:00
Kenneth J Davis
2da3aafa80
add example build command line for Windows 2023-12-18 20:32:53 -05:00
Kenneth J Davis
9f9323612a
update comment 2023-12-18 20:25:35 -05:00
Kenneth J Davis
2e849b36c1
update copyright string to 2023 2023-12-18 20:23:04 -05:00
Kenneth J Davis
7b0633b26b
only print messages once, not each time processing partitions; use LBA if forceLBA enabled in additional cases where LBA support not detected 2023-12-18 18:37:19 -05:00
Kenneth J Davis
4b0162c2a6
default to normal not quiet for initial messages 2023-12-18 18:31:20 -05:00
Kenneth J Davis
600192784b
add back building boot files with extra defines but use explicitly specified values instead of generic NASMFLAGS so flags used for other assembly files does not effect building 2023-12-18 17:25:15 -05:00
Kenneth J Davis
f666ac9804
revert changes to boot/makefile; introduces additional command line flags that may break build on different platforms 2023-12-17 22:20:21 -05:00
Kenneth J Davis
b79f0003ac
only create list file if requested, avoids error due to duplicated command line option for generating list file 2023-12-17 22:10:32 -05:00
Kenneth J Davis
cfdd09963f
fix from boeckmann (Bernd Böckmann) for Format GitHub issue #1 - format divide by 0 due to kernel function 440D, subfunction 60 returning a zero for logical_sectors_per_fat as initdisk overflows and calculates incorrect value 2023-12-17 21:01:37 -05:00
Kenneth J Davis
f1249dcd6f
From bzt, initialize drive parameter head & sector values to avoid potential divisions by 0 2023-12-08 21:20:46 -05:00
Kenneth J Davis
5880d36ba9
add ability to adjust verboseness of messages during booting 2023-12-08 18:08:11 -05:00
Bernd Boeckmann
e4a62f239d fix exeflat not deleting temporary file 2023-12-08 17:00:17 -05:00
C. Masloch
95694f7e34 config: delete variable only if it makes enough space to write new 2023-08-30 06:59:41 -04:00
C. Masloch
6101fb2aed config: pass searchvar result to deletevar 2023-08-30 06:59:41 -04:00
C. Masloch
24d19cd05c config: allow to delete variable with empty SET command 2023-08-30 06:59:41 -04:00
C. Masloch
3dafa54e8b config: delete existing variable before writing new contents 2023-08-30 06:59:41 -04:00
C. Masloch
132a0a9f94 truename: fix array overrun (pick from fdpp)
Picked from the commit at fe1c4dc7fe

The referenced issue is at https://github.com/dosemu2/fdpp/issues/212

The patch was applied using unix2dos on the patch file
then `patch -p1 --binary` with the patch file as stdin.
The original used a new define for the maximum path length.
As there is no difference to our current SFTMAX define I
changed this hunk to retain the SFTMAX use.

This fixes a bug when eg function 3Dh receives a buffer
that starts with ".\" but the byte in memory before this
buffer happens to be also a dot. I ran into this problem
semi-randomly during building EDR-DOS with the most recent
WarpLink build. If WarpLink was placed somewhat low in the
Low Memory Area then one of its function 3Dh calls would
happen to have a dot before the pathname buffer. (I had to
load lCDebug using the last fit strategy then enter TSR mode,
to catch the bug without the presence of the debugger working
around the occurrence of the bug.)

Original commit Metadata:

From: Stas Sergeev <stsp@users.sourceforge.net>
Date: Wed, 1 Feb 2023 13:01:55 +0500
Subject: [PATCH] truename: fix array overrun [fixes #212]

src[-2] was peeking into a random memory location.
It seems entire truename() is written by some morons... :(
Its completely unreadable and full of bugs.
2023-08-26 21:32:19 -04:00
C. Masloch
29ccb6e454 main: insure master environment starts out empty 2023-07-03 07:37:00 -04:00
C. Masloch
a0549a395e config: make sure word marker trailing in environment is zero 2023-07-03 07:37:00 -04:00
C. Masloch
3d1ba0d486 config: build master environment during FDCONFIG.SYS processing
lDebug wants to access the environment while executing
as a device driver. Instead of building it in a variable
then copying it to 68h:0 after FDCONFIG.SYS processing,
just build it there to begin with.
2023-07-03 07:37:00 -04:00
Andrew Bird
afe7fbe068 inthndlr: align hma size to para
Based on a patch https://github.com/dosemu2/fdpp/commit/e7fe81d458
for FDDP by @stsp

[fixes #101]
2023-04-13 18:05:24 -04:00
C. Masloch
4973031b00 test: use new bootimg option _BOOTPATCHFILE
This will allow to use file system parameters other than
the default 1440 KiB 90mm diskette's default FAT12 FS.
2023-04-02 12:09:13 +02:00
C. Masloch
abc5ab7f0a update bootimg from hg 380400d3d48e
From https://hg.pushbx.org/ecm/bootimg/file/380400d3d48e
2023-04-02 12:09:13 +02:00
C. Masloch
cba5ee259d update ldosboot from hg 798e0b02fedc
From https://hg.pushbx.org/ecm/ldosboot/file/798e0b02fedc
2023-04-02 12:09:13 +02:00
C. Masloch
adbc31edea update lmacros from hg 99b01fa65007
From https://hg.pushbx.org/ecm/lmacros/file/99b01fa65007
2023-04-02 12:09:13 +02:00
C. Masloch
04353fe9e4 ci_test: do simple boot tests 2023-04-02 12:09:13 +02:00
C. Masloch
6d1ee95e10 ci_test: use bash for better error messages 2023-04-02 12:09:13 +02:00
C. Masloch
26607e9297 test: add a simple boot test using qemu, ldosboot, bootimg 2023-04-02 12:09:13 +02:00
C. Masloch
014111dc39 ci-build: install more packages in preparation for boot test 2023-04-02 12:09:13 +02:00
C. Masloch
a5e479c013 import bootimg from snapshot of hg ed7b734a8d06
From https://hg.pushbx.org/ecm/bootimg/file/ed7b734a8d06
2023-04-02 12:09:13 +02:00
C. Masloch
f84d9290b6 import ldosboot from snapshot of hg b9b7d2cf8971
From https://hg.pushbx.org/ecm/ldosboot/file/b9b7d2cf8971
2023-04-02 12:09:13 +02:00
C. Masloch
fb689c1372 import lmacros from snapshot of hg 9fa0e64034cd
From https://hg.pushbx.org/ecm/lmacros/file/9fa0e64034cd
2023-04-02 12:09:13 +02:00
C. Masloch
fd281799eb fix git attributes for test subdirectory 2023-04-02 12:09:13 +02:00
C. Masloch
559813c5fc ci_build: do not remove test subdirectory 2023-04-02 12:09:13 +02:00
Andrew Bird
fa3dc59367 DosGetExtFree: Use new redirector function 11a3
To be able to return free space on larger non local disks, the redirector
needs an extension. Dosemu2 has implemented this function and FDPP
has an almost identical patch to this. If the extension is not
implemented by your chosen redirector, then fallback to the standard
110c function is done for int21/7303.

With this patch up to 2TB (with Dosemu2 reporting in 512 blocks) can be
displayed.
2023-03-21 20:54:17 -04:00
Andrew Bird
4e23a63e72 CI: Use tagged release of Open Watcom
The current snapshot proved unreliable.
2023-03-21 20:54:17 -04:00
C. Masloch
384e68529a sys: detect small FAT32 as FAT32 (zero in word SPF)
Also checks that the total amount of clusters is possible
for the detected file system, erroring out otherwise.
Small FAT32 is displayed in the verbose output specifically.
2023-01-10 13:17:16 -05:00
C. Masloch
7115d69cd2 sys: support 256 sectors per cluster
This was overlooked in the earlier commits because SYS
uses its own BPB structures and name for the SPC field.
2023-01-10 13:17:16 -05:00
C. Masloch
2efe4ab9f4 boot: enable loading from file systems with 256 sectors per cluster
This should be Enhanced DR-DOS compatible.

oemboot.asm contains an optimisation to save 2 bytes,
by using mov instead of a lea with bp evaluating to
a constant value. This was needed to fit the addition
for 256 spc support. It is otherwise unrelated.

The LBA detection patch offsets in SYS have also been
updated to match the changed boot.asm offsets.
2023-01-04 19:38:57 -05:00
C. Masloch
28cd58688a fatfs.c: allow bpbSectorsPerCluster == 0 to mean 256
This should be compatible to Enhanced DR-DOS.

Tested by building a boot image like the following:

nasm ../ldosmbr/oldmbr.asm -o oldmbr.bin
nasm ../ldosboot/boot.asm -D_FAT16=1 -I ../lmacros/ \
 -D_LOAD_NAME="'LDEBUG'" -o boot16.bin
nasm bootimg.asm -I ../lmacros/ -o disk16.img \
 -D_MBR -D_ALIGNDATA -D_BOOTPATCHFILE=boot16.bin \
 -D_MBRPATCHFILE=oldmbr.bin -D_BPE=16 \
 -D_SPI='(_SPC * 5000)' -D_NUMROOT=512 -D_SPC=256 \
 -D_SPF='((_SPI / _SPC + 255) / 256)' \
 -D_PAYLOADFILE=../ldebug/bin/ldebug.com,quit.com,\
::rename,../k256spc/bin/kernel.sys,kernel.sys,\
command.com,::fill,1,32,autoexec.bat

The repos bootimg, ldosboot, ldosmbr, and lmacros are
available at https://hg.pushbx.org/ecm/

The file ldebug.com is a recent bootable lDebug debugger.
The file command.com is a recent FreeCOM. The file quit.com
is assembled with NASM from
https://hg.pushbx.org/ecm/ldebug/file/e6035c05670a/misc/quit.asm

Run like this:

qemu-system-i386 -hda disk16.img -boot order=c -display curses

To the lDebug prompt "-" enter "boot protocol freedos",
then a "q" command. On success, the quit.com command
can be run to quit the qemu VM.

Not yet done:

- initdisk.c:512 uses MAXCLUSTSIZE defined to 128. This is
not difficult to change but it is unclear whether this
should be changed.

- The boot loaders are not yet adjuscted, requiring use of
the ldosboot or lDebug loaders instead.

- A patch for FORMAT (copylefted) version 0.91u is available
from the Enhanced DR-DOS project. Mirrored in the directory at
https://pushbx.org/ecm/download/edrdos/freedos/
This should be easy enough to update to the most recent version.
2023-01-04 19:38:57 -05:00
C. Masloch
302b002adb sys: enable building without WITHFAT32 defined 2022-12-31 09:37:42 -05:00
C. Masloch
bf085a7ed6 sys: fix gcc build, int86 has to preserve ds
The int86 function is used to call interrupt 21h
service 32h in the reset_drive function. This
function returns a pointer using the ds register.
ds will usually point into the DOS data segment
then (for our kernel). However, the compiler
assumed ds to be unchanged.
2022-12-31 09:37:42 -05:00
Andrew Bird
bb1bbbb1cb CI: Update deprecated output method 2022-10-28 07:05:26 -04:00
Andrew Bird
ccf4367729 CI: Update std actions to avoid node version warnings 2022-10-28 07:05:26 -04:00
Kenneth J Davis
339256d6aa
revert changes to ci-build.yml 2022-10-25 07:12:50 -04:00
Kenneth J Davis
1c25390e49
update deprecated set-output 2022-10-25 07:01:09 -04:00
Kenneth J Davis
e1b22c7035
update comments
(from Geoff Chappell blog and RBIL)
2022-10-24 20:19:32 -04:00
Kenneth J Davis
6f6e44e1b5
fix OW warning W115 in config.c 2022-10-24 18:08:27 -04:00
Kenneth J Davis
af52b0c8c3
fix OW warning W115 in dsk.c 2022-10-24 18:01:50 -04:00
Kenneth J Davis
c152d551de
fix OW warning W115
cast array using pointer to first element [newboot] instead of pointer to whole array [&newboot] to avoid OW error W115 "&array may not produce intended result" since the address of operator "&" is not required for getting the address of an array.
2022-10-24 17:56:33 -04:00
Kenneth J Davis
9d799c2a1e
Update ci-build.yml
enable ability to manually run workflow
2022-10-24 17:28:56 -04:00
tkchia
7149a8efe4 FCB (int 21h func 29h): should not accept field separator as "drive letter" 2022-07-16 07:20:24 -04:00
tkchia
031f17068a FCB (int 21h func 29h): should keep parsing name even if drive letter invalid 2022-07-15 09:45:10 -04:00
Kenneth J Davis
0e6d90cf82
build fixes, declare variables at start of block, use size_t to avoid int vs long errors 2022-06-03 23:29:37 -04:00
Kenneth J Davis
bfd5328183
fix building on Windows with Open Watcom, using OWWIN helper tools built as win32 executables instead of DOS executables as done using WATCOM for COMPILER 2022-06-03 23:28:51 -04:00
C. Masloch
9343e00f9a exeflat: try to fix CI displaying upx output before exeflat output 2022-05-30 17:37:26 -04:00
C. Masloch
b5299924c2 exeflat: update comments before prepending entry header 2022-05-30 17:37:26 -04:00
C. Masloch
70c498a309 exeflat: update usage screen with -E, -D, and -U switches 2022-05-30 17:37:26 -04:00
C. Masloch
e3e58ee3fd upxentry, upxdevic: add header comments 2022-05-30 17:37:26 -04:00
C. Masloch
77d3c7e1d7 exeflat: document UPX 3.96 exact DOS/SYS limit but use a lower number 2022-05-30 17:37:26 -04:00
C. Masloch
f23f035554 exeflat: allow to force either DOS/EXE or DOS/SYS compression format 2022-05-30 17:37:26 -04:00
C. Masloch
10b4d1581f exeflat: implement new-style UPX compression in DOS/SYS format 2022-05-30 17:37:26 -04:00
C. Masloch
9382d7ce00 exeflat: pass argv[3] to use as start_seg in write_header 2022-05-30 17:37:26 -04:00
C. Masloch
99614259ae exeflat: jump across nop slide when the stub is shorter than 192 bytes 2022-05-30 17:37:26 -04:00
C. Masloch
7f38303ade exeflat: shrink uncompressed stub size to 64 bytes
The code still allows for up to 192 bytes, should that
be useful. Simply by re-assembling upxentry.asm then
re-running exeflat, the changes will be picked up.
2022-05-30 17:37:26 -04:00
C. Masloch
45b3d9ef67 exeflat: move reading entry file into main, pass code to write_header 2022-05-30 17:37:26 -04:00
C. Masloch
992a898076 kernel.asm, exeflat: new format with UPX entry at 006C0h
This format has several advantages:

* The CONFIG block need not be moved.

* The entire compressed image (depacker and payload) need
not be moved another time before the UPX depacker's own
operation.

* The CONFIG block always lives at 00602h, and the kernel
need not be aware whether it was compressed for detecting
which CONFIG block to use.

* Support for compressed images beyond 64 KiB for free.
(The assembly define TEST_FILL_INIT_TEXT can be passed in
NASMENV to test this support with 32 KiB of LFSR output.)

* A subsequent commit will shorten the stub to 64 bytes,
compared to the prior 32 + 45 = 77 bytes, with no loss
of features. (The packed payload is a bit shorter too.)

* The new stub also sets ds and es to the segment value
that would point to the DOS/EXE process's PSP. This is
apparently not used by the UPX depacker but could be in
a future or past version, or if another packer is used.
2022-05-30 17:37:26 -04:00
C. Masloch
9dcd9ba051 mkfiles: add -Wall switch to host gcc variable
Refer to https://github.com/FDOS/kernel/pull/72#issuecomment-1133770757
2022-05-29 19:25:00 -04:00
C. Masloch
d91c14723a kernel: optimise A20 check and enable/disable calls
Some assembly tricks:

* SMC instead of checking the XMS driver address
in the DOS DS stub,

* SMC so that the address goes right into a
`call far immediate` instruction,

* use `repe cmpsw` to compare multiple words (saves
space over the individual word compares),

* near calls to far functions use push cs to build
a far-call stack frame,

* segments 0 and FFFFh generated by segment arithmetic
instead of loading from memory,

* common case (A20 already enabled) made to be the case
where the conditional branch just falls through, which
may be slightly better.
2022-05-29 19:24:00 -04:00
C. Masloch
72edabfdb7 gcc.mak: make sure to redirect more internal function calls in init
Refer to https://github.com/tkchia/gcc-ia16/issues/109#issuecomment-1133867169
2022-05-29 18:05:46 -04:00
C. Masloch
8e6fc98a94 config: bugfix, make struct array configcommands static (fixes #73)
A crash was introduced by the prior commit, ee255d2. I
tested that the kernel still did build with gcc, but I
failed to test whether it also still runs. Turns out that
apparently changing the pointers to static made it so gcc
put the structure into the init data segment and
implicitly called memcpy to put it on the stack. That's
wrong, however. We depend on #define to convert all calls
in init to the init text copies of memcpy etc. The
implicit call by gcc however attempts to call the HMA text
copy of memcpy which happens to be at another offset.

The fix is to make the entire array of structs static so
that memory for it is allocated only in the init data
segment, not on the stack. This seems to work for both
gcc and OpenWatcom (no warnings, it builds, it runs).
2022-05-22 13:16:39 -04:00
C. Masloch
ee255d2355 main, config: fix OW build (char not UBYTE, static file pointers) 2022-05-21 23:22:08 -04:00
C. Masloch
42b8e12bc7 ci_build.sh: fix CI build to correct OW file, wget --no-verbose
Refer to https://github.com/tkchia/gcc-ia16/issues/108
2022-05-21 23:22:08 -04:00
C. Masloch
5df9dbdbd7 mkfiles: fix compilation with current gcc-ia16
Refer to https://github.com/tkchia/gcc-ia16/issues/108
2022-05-21 23:22:08 -04:00
C. Masloch
c0b8aa2bf4 task: return Invalid format on empty executable (fixes #70) 2022-05-21 23:22:08 -04:00
C. Masloch
b562983222 config: add the CONFIG, ALTCONFIG, and OLDCONFIG kernel command line commands
CONFIG takes precedence and is by default initialised
to the empty string, that is, skipped. ALTCONFIG is
used to specify the 'alternative' filename and defaults
to fdconfig.sys. Finally, OLDCONFIG defaults to the
config.sys filename.
2022-05-21 23:22:08 -04:00
C. Masloch
4377a257e0 kernel, main: read kernel command line into init segment buffer
The protocol for this extension is based on what lDebug
already does given the PROTOCOL=FREEDOS with the switch
CMDLINE=1 (which was originally defined for the lDOS and
RxDOS load protocols). Therefore the stack frame mirrors
that of the lDOS protocol.
2022-05-21 23:22:08 -04:00
C. Masloch
49733547f1 kernel, main: add debugger_present variable and skip ints 0, 1, 3, 6
Also adds a CheckDebugger byte to the CONFIG block and
support for reading and writing this setting in the
SYS CONFIG program. Default is 0 (no check assume absent).
2022-05-21 23:22:08 -04:00
C. Masloch
7ff6c06814 kernel: copy CONFIG block from UPX help data early in kernel.asm
Here we depend on the signal instruction that is patched
by exeflat to indicate whether we were compressed. This
replaces the prior check that detected the UPX help data
solely by checking the CONFIG signature at 05E2h.
2022-05-21 23:22:08 -04:00
C. Masloch
b7345d9165 main: note that we want to set int 31h segment to DOS DS
This commit does not change the behaviour of the code
as it already did the right thing. However, it notes
that that should happen. (This is DR DOS compatible.
For example, SHSUCDX depends on DR DOS setting this
segment so that it can keep track of the DOS DS
across it being relocated. We do not yet relocate it
but keeping a reference here is still useful.)
2022-05-21 23:22:08 -04:00
C. Masloch
3b6d8362b3 exeflat: store original ss:sp in UPX help data 2022-05-21 23:22:08 -04:00
C. Masloch
ad368a4420 exeflat: support signal byte (clc/stc) to indicate compression to kernel 2022-05-21 23:22:08 -04:00
C. Masloch
f51c8a5304 exeflat: copy original CONFIG block to the depacker header 2022-05-21 23:22:08 -04:00
C. Masloch
6d23a787fb fdkrncfg: bugfix, version info check should not include signature 2022-05-21 23:22:08 -04:00
Andrew Bird
8c8d213119 Build: Don't flip video mode for -DDEBUG in Dosemu 2022-01-16 12:40:47 -05:00
Andrew Bird
9135a644c2 Build: Fix missing constant for -DDEBUG 2022-01-16 12:40:47 -05:00
Andrew Bird
7b6c8fb7fe Build: Fixup compile with GCC and -DDEBUG 2022-01-16 12:40:47 -05:00
Kenneth J Davis
a6781df62d Update copyright year 2022-01-12 17:59:54 -05:00
Andrew Bird
dd69862b93 CI: Remove Travis as it no longer works for us. 2022-01-10 17:58:30 -05:00
Andrew Bird
202e3c1c94 Build: Update country submodule 2021-12-31 17:27:32 -05:00
Andrew Bird
cd0a9dfe48 CI: Use Country.sys submodule 2021-12-30 11:55:17 -05:00
Andrew Bird
b7a65d9f73 Build: Build country.sys from submodule 2021-12-30 11:55:17 -05:00
Andrew Bird
bd5a68552e Build: Use country submodule data
Use table content from country submodule for
  "struct CountrySpecificInfoSmall specificCountriesSupported[]"
2021-12-30 11:55:17 -05:00
Andrew Bird
f2cf8220de Build: Add country submodule 2021-12-30 11:55:17 -05:00
lpproj
571cf11111 fix 2nd parameter of "DOS=" statement in config.sys does not take effect in some cases:
* preceding space(s): e.g. "DOS=UMB, HIGH"
* after unknown keyword: e.g. "DOS=NOUMB,HIGH"
2021-11-23 07:22:21 -05:00
Andrew Bird
34c452a29e Share: Update submodule 2021-11-08 08:59:00 -05:00
C. Masloch
cedcaee5ad dosfns, int2f: make SHARE uninstallable
Refer to https://github.com/FDOS/share/issues/10
2021-10-28 07:37:54 -04:00
Kenneth J Davis
fbc95b7cc2
Updated submodule share 2021-10-25 15:27:58 -04:00
Jiří Malák
246d99c4a6 suppress NASM warning 2021-10-17 06:37:05 -04:00
Jiří Malák
a69abe43aa add one directory level for files upload 2021-10-17 06:36:24 -04:00
Andrew Bird
7479889e79 CI: Split into two output directories 2021-10-16 20:43:58 -04:00
Andrew Bird
fb372711e5 Update submodule share 2021-10-16 20:43:58 -04:00
Jiri Malak
6e0a415ed3 Fix incorrect date format for Czech and Slovak Republic.
Both Countries use DD.MM.YYYY date format.
Microsoft DOS also use this format.
2021-09-30 07:14:45 -04:00
Margen67
908ffb49d9 ci_build.sh: Rename BUILD_DIR
Travis is no longer the only CI so this name doesn't make sense.
2021-09-27 18:46:02 -04:00
Andrew Bird
4b3f7e0088 int2f: make share_open_check() to accept FAR
Fixes problem with GCC-ia16 compiled share not allowing open of files.
It seems that the TCC 2.01 compiled version was fortunate in that DS
happened to be correct when the interrupt was called, but this was
not the case for the GCC ia16 compiled version.

It's an analogue of this patch by @stsp for FDPP.
https://github.com/dosemu2/fdpp/commit/5b52510b
2021-09-25 19:33:16 -04:00
Andrew Bird
5b9e8fedcc dosfns: Check share table before delete/rename
Delete and Rename should not be able to remove an open file,
so check share's open file table first. Behaviour is now identical
to MS-DOS 6.22.

Note: Uses a new subfunction of the FreeDOS share multiplex
      interrupt int2f/0x10a6 called is_file_open()

A similar patch was applied to FDPP at
https://github.com/dosemu2/fdpp/commit/691721f1

Fixes dosemu2 tests:
  test_fat_ds3_share_open_rename_fcb
  test_fat_ds3_share_open_rename_ds2
  test_fat_ds3_share_open_delete_ds2
  test_fat_ds3_share_open_delete_fcb
2021-09-25 19:33:16 -04:00
Andrew Bird
78d0e09e98 Update share 2021-09-25 19:33:16 -04:00
Andrew Bird
296a37aee0 Build: Update upload artefact file selection 2021-09-24 13:33:02 -04:00
Andrew Bird
778a03f8c3 Build: Use share submodule
1/ Replace copy of share with submodule
2/ Add to the CI build
2021-09-24 11:49:13 -04:00
Kenneth J Davis
23d9c2ecf0 FCB: Rename should support asterisk wildcards - based on dosemu fdpp patch f3cb0719ca, fixes issue #43 2021-08-21 11:09:17 -04:00
Kenneth J Davis
cb908cf803 add tests for FCB rename - based on tests from andrewbird https://github.com/dosemu2/fdpp/pull/42#issuecomment-446309983 2021-08-21 10:01:12 -04:00
Kenneth J Davis
79a6504e89 change test to build as exe instead of com 2021-08-20 18:25:16 -04:00
Kenneth J Davis
740e31fd2e don't overwrite CX on windows startup broadcast, windows sets this to 0 so unneeded and another program in chain may have set to nonzero for a reason 2021-08-20 18:24:45 -04:00
Kenneth J Davis
b0f5e79205 _winInstanced is only used when compiled with WIN31SUPPORT, fix build error on CI 2021-08-19 14:16:50 -04:00
Kenneth J Davis
9186e6c5ed initial windows 3 enhanced support based on unstable kernel branch 2021-08-19 11:46:10 -04:00
Kenneth J Davis
292f3079be update share MAKEFILE so more path agnostic 2021-08-19 00:09:53 -04:00
Kenneth J Davis
6ada304ec2 allow opening a character device prefixed with invalid drive letter (e.g. "@:NUL") but not with invalid path 2021-08-19 00:00:29 -04:00
Kenneth J Davis
c69638def9 add test for opening character devices (all pass on DOS 5,6, NT VDM, @:dev fail currently on FD kernel) 2021-08-16 22:15:41 -04:00
Kenneth J Davis
77b36d2458 revert this change - does not seem correct testing with MSDOS 5 and 6
original commit notes 'Fix an error at opening a character device prefixed with invalid drive letter (e.g. "@:NUL") (some application use it for opening character device driver)', need to test case but breaks TRUENAME asis
2021-08-15 18:00:10 -04:00
Kenneth J Davis
e341cce4ed fix build error on FAT16 (non FAT32) variant because of unused label 2021-08-14 19:22:09 -04:00
Kenneth J Davis
b0653c0c5f add missing #ifdef, this code is part of skeleton logic for upcoming LFN support - int 2F 1242 internal 64 bit LSEEK should only be active if LFN API available 2021-08-09 17:42:07 -04:00
Kenneth J Davis
1bb536c383 LONG SEEK actually use lower 32 bits of 64 bit value (not 16 bits) 2021-08-08 14:37:07 -04:00
Kenneth J Davis
b7bcef73a1 build fixes - update inthndlr.c to compile with LFNAPI enabled (more fixes from earlier oops, lfnapi.c still doesn't compile) 2021-08-08 14:26:34 -04:00
Kenneth J Davis
74e9d4afd7 build.bat add lfn alias to lfnapi 2021-08-08 14:24:26 -04:00
Kenneth J Davis
246b0037a8 initial implementation of extended seek (0x7142 - LONG LSEEK with 64-bit file position) 2021-08-08 03:52:58 -04:00
Kenneth J Davis
15900d7827 add implementation of int 0x2F function 0x1f build CDS from dosemu2/fdpp 2021-08-08 02:19:14 -04:00
Kenneth J Davis
c4d6f885f4 correct INTR macro (fix oops, LFN skeleton wasn't meant to be pushed yet) 2021-08-08 00:55:02 -04:00
Kenneth J Davis
e2832a5563 skip redundant skipwh(pLine) call - its the first thing scan(...) does 2021-08-07 22:15:24 -04:00
Kenneth J Davis
d410370580 add skeleton for LFN API, includes 0x71a6 implementation (call to redirector only) from dosemu2/fdpp 2021-08-07 20:43:04 -04:00
Kenneth J Davis
cd4709f09b ensure offset to critical patch tables doesn't change - from a921e21edc (add 0x315 mark) 2021-07-30 23:10:15 -04:00
Kenneth J Davis
dd91e3c005 From Tom Ehlert: don't split disk transfers crossing DMA boundary if BIOS indicates can handle transparently 2021-07-30 23:04:06 -04:00
Andrew Bird
ab1e31e0ba fcbfns: Fix for FcbFindFirstNext [fixes #40]
The "next" part of this function never returned any results, initialise
only on the first call.

Fix by @stsp, minor edits @andrewbird
2021-07-29 20:31:25 -04:00
Tee-Kiah Chia
de7f0d6489 task: don't zero parent_psp on 0x26
Patch ported from
  * f49252ac6b
See
  * https://github.com/dosemu2/fdpp/issues/112
  * https://github.com/FDOS/kernel/issues/38
2021-07-29 17:20:38 -04:00
C. Masloch
858934f152 boot, oemboot: fix to abort properly on file not found
Prior to this commit the first cluster specified from the last
compared directory entry would be used if the file is not found.
Fix the wrong (boot.asm) or missing (oemboot.asm) jump to the
error handler so that on file not found an error is displayed.

Reference: https://sourceforge.net/p/freedos/bugs/97/
"Bugs in FAT12/16 boot sector loaders if file not found"
This commit fixes the most crucial bug of this 2012-09-27 report.
2021-07-29 17:19:45 -04:00
C. Masloch
f267341281 oemboot: optimise FAT12 entry loading (picked from lDOS boot)
This way of clearing the upper 4 bits of even FAT entries
saves a byte compared to the prior way. (The next commit
needs one more byte than was previously left over.)

Reference: https://hg.pushbx.org/ecm/ldosboot/file/410b870c0222/boot.asm#l1629
2021-07-29 17:19:45 -04:00
C. Masloch
4c2bda46b2 boot: put placeholder LBA_TEST_OFFSET if no ISFATx define 2021-07-29 17:19:45 -04:00
Kenneth J Davis
edfb0db758 adjust padding to be same as in PC-DOS (90h/nop)
see 1dc244b09b
2021-07-22 23:32:22 -04:00
Kenneth J Davis
afca594446 from RBIL int 21h/4400h (table 01423) add definition for bit 11 if SFT is not for a device (for a file) - media not removable, currently unused 2021-07-22 23:22:38 -04:00
Kenneth J Davis
9d293d7815 since both refer to critical sections to patch and we have none, i.e. both empty lists, use same location for unused hard coded critical patch list and critical patch list passed to Win3 2021-07-22 23:12:56 -04:00
Kenneth J Davis
a193ba3116 from dosemu2/fdpp - zero out critical patch list
Personal NetWare Server really writes to these addresses, so
putting 0x0d0c the way DOS does, is not safe.

See dosemu2/dosemu2#428
see 94bd3eb4b5
2021-07-22 23:02:18 -04:00
Kenneth J Davis
c6fafbbb2d int 21h/4400h only return low byte of SFT flags if not a device, part of dosemu2/fdpp bug #147 fix - b2b55fc1af 2021-07-22 22:31:45 -04:00
Kenneth J Davis
516a4e7e55 check for unsupported function call in console - from dosemu2/fdpp bug# 101 fix see c6efa7a203 2021-07-22 21:21:01 -04:00
Kenneth J Davis
00daebd468 update to make current FreeDOS style package, not 1.0 version 2021-05-14 22:58:43 -04:00
Kenneth J Davis
46c1ec3b4a
Update index.md with GitHub information 2021-05-14 07:45:55 -04:00
Kenneth J Davis
d363e4d283 add example of pushing tag to origin, use HEAD instead of just tagged branch to avoid detached head warning as should be same 2021-05-13 23:38:29 -04:00
Kenneth J Davis
4f7bdda16a update for releases using git instead of svn 2021-05-13 23:30:27 -04:00
Kenneth J Davis
4f73b446c0 update LSM, omit GitHub specific docs files from packages 2021-05-13 22:17:48 -04:00
Kenneth J Davis
60067953b6
Update version in preparation for new release
Next release will be 2.43 (2043)
2021-05-11 22:10:46 -04:00
Kenneth J Davis
bd3a1d8047
Update README.md 2021-05-11 22:08:19 -04:00
Kenneth J Davis
d3dc83a876
update for Issues on GitHub instead of Sourceforge
update where to report issues and suggestions
2021-05-11 22:02:58 -04:00
Tee-Kiah Chia
e8a125281c ia16-elf-gcc: update information on available Ubuntu packages 2021-05-11 21:47:12 -04:00
Tee-Kiah Chia
26626f2fed ia16-elf-gcc: use new SS != DGROUP support for int21_syscall(.) 2021-05-11 21:47:12 -04:00
Piotr Durlej
5ec1e993b4 read_line: skip characters > 255 2021-05-11 21:45:38 -04:00
Piotr Durlej
e0818e305b SYS: Fix a bad merge 2021-05-11 21:45:38 -04:00
Piotr Durlej
0a0d55ea53 SYS: Reduce verbosity when the verbose flag is not set 2021-05-11 21:45:38 -04:00
Kenneth J Davis
49d3c8d76b add safety check to FAT12/16 boot sector to warn about breaking sys, update new offset in sys.c for NOPing out use of BIOS boot drive during boot (fix error about boot sector unsupported format) 2021-05-11 21:39:29 -04:00
Ricardo Hanke
66df13c4d8 .gitignore: add setver.sys 2021-03-26 02:19:33 -04:00
Ricardo Hanke
7496c685ea Implement version table support for int21/ah=4b, subfunctions 0 and 1 2021-03-10 22:21:19 -05:00
Andrew Bird
35a18350a0 CI: Update workflow and readme badge 2021-01-15 08:39:46 -05:00
Andrew Bird
7a2748585c CI: Add Github Action 2021-01-09 09:12:47 -05:00
Andrew Bird
4e21e947fc FATFS: rmdir of read only directories is valid
After comparison with DR-DOS 7.01 and MS-DOS 6.22 over at Dosemu2 it
was seen that rmdir of a directory having the _A_RDONLY bit set should
succeed. This patch makes that change.

For reference the test report can be found in the fdpp issue
https://github.com/dosemu2/fdpp/issues/161. An identical patch has
been applied there.
2021-01-07 21:23:10 -05:00
C. Masloch
92ae538f1d boot: allow instsect to match the filesystem ID string
Reference: https://hg.ulukai.org/ecm/instsect/file/33218c729b43/instsect.asm#l1257

lDOS's instsect recently started to default to checking
the filesystem ID string in order to validate that the
boot sector loader to write matches the detected FS.
Using the /S=filename option or building instsect to
include the FreeDOS kernel's loaders would require use
of the /SN switch without this commit.

In addition, boot.asm and oemboot.asm are made to check
that exactly one of the ISFAT12 and ISFAT16 defs is
defined so as to select the FS. Prior to this commit
using both or neither def would silently result in a
broken loader.
2020-11-28 12:11:16 -05:00
Andrew Bird
6e42bb6d7c Travis: Update build env to Ubuntu Focal
1/ Update to Focal environment
2/ Make build stop on first error
3/ Remove unnecessary PPAs
2020-10-14 10:34:27 -04:00
Andrew Bird
a7b7ce71d0 GCC build: Remove duplicate argument [#fixes #27]
No need to specify output file in NASMFLAGS as Watcom needs it specified
in the rule. Newer versions of NASM see duplicate output file as an error.
2020-10-14 10:34:27 -04:00
C. Masloch
977023f85c boot: fix Int10.0E expected not to alter al (SBC188)
Reference: https://www.bttr-software.de/forum/forum_entry.php?id=16934

The SBC188 video ROM-BIOS handling returns with al=0Ah (LF)
upon interrupt 10h function 0Eh calls that scroll the screen.
This made the FAT12 boot loader crash when booting FreeDOS
off a 1440 KiB diskette. While a fix is expected from their
side too, hardening the loader too is the right thing to do.

With the way this fix is implemented by this commit, it only
needs one additional byte for the loader. The error message
changes from "Error!." to just "Error!", other than
that the behaviour is the same.

The FAT32 loaders already used zero-terminated strings and
thus were not affected by the dependence.
2020-09-18 13:37:49 -04:00
lpproj
ef945b1192 Fix Func 2Dh (Set System Time) sets wrong time 2020-08-21 13:57:26 -04:00
Jiri Malak
093c6dd924 correct I186 and I386 macros definition
correct I186 and I386 macros definition to work with all Open Watcom toolchain versions
command line definition macro has "1" value but in header file it is defined as blank value
anyway I86/I186/I386 macros usage is not transparent, it is definition duplicity in header file and on command line
it is wrong solution even if it works on most of compilers (command line macro re-definition is hidden)
2020-08-02 10:22:56 -04:00
Andrew Bird
5ecfdd572c Travis: Build and test with both GCC and Watcom
Watcom compiler is downloaded and extracted if necessary. On Travis this
will be always, but if you build locally multiple times using
./travis_build, it will use the previous watcom installation.

[fixes #18]
2020-08-01 08:53:46 -04:00
Kenneth J Davis
65e0101c17
Add index.md
Add index.md for initial page shown when viewing docs online via GitHub
2020-05-01 13:54:53 -04:00
Kenneth J Davis
6bfc2c5c2d
Add title and description 2020-05-01 13:50:25 -04:00
Kenneth J Davis
579ae7eb9f Set theme jekyll-theme-tactile 2020-05-01 13:37:10 -04:00
Kenneth J Davis
a8e44f0e33 Create CNAME 2020-05-01 13:36:38 -04:00
lpproj
19a6dc1ba4 Fix func 0Bh (Get STDIN Status) always returns AL=FFh with some alternative CON drivers:
* qwikansi.sys (simtelnet: simtelnet/msdos/screen/qwikansi.zip
* most of Japanese input methods (Microsoft MS-IME, ATOK, WXP/WX2/WX3)
2019-12-27 08:18:39 -05:00
lpproj
9eb9b1a046 Fix Func 30h (Get DOS Version) return version 0.0 in config.sys 2019-12-19 21:07:06 -05:00
Tee-Kiah Chia
6a29f57715 int2f: fix call interface around syscall_MUX14( ) (inthndlr.c)
The issues are similar to those surrounding int2F_12_hanndler( )
(see https://github.com/FDOS/kernel/issues/11).
2019-12-09 06:23:12 -05:00
Tee-Kiah Chia
c07577cbfb (Mostly) fix gcc-ia16 code for non-stack-switching int21 funcs. 2019-12-09 06:23:12 -05:00
Tee-Kiah Chia
0114ab3be4 int2f: fix call interface around int2F_12_handler( )
This changes the interface between reloc_call_int2f_handler
(int2f.asm) and int2F_12_handler( ) (inthndlr.c) so that

  - int2F_12_handler( ) will not try to output values to its
    caller by passing "back" input parameter values
  - reloc_call_int2f_handler will switch to an internal
    stack before calling int2F_12_handler( ), so that SS ==
    DGROUP as expected by the latter.

This partly addresses https://github.com/FDOS/kernel/issues/11 .

(The call to syscall_MUX14( ) in int2f.asm seems to have
similar issues, and should probably also be updated.)
2019-12-09 06:23:12 -05:00
Andrew Bird
241875a742 Make: Allow clean and clobber to work with gcc
Currently the sed trickery for gcc is only setup on the all target, but
if we want to do `make COMPILER=gcc clean all` the clean will fail.
Setup and remove the GNUmakefiles for each main target.
2019-12-08 09:28:56 -05:00
Kenneth J Davis
7cbd272ca5
Update readme with build status 2019-12-03 19:57:03 -05:00
Andrew Bird
0dc6a02450 int2f: Allow 1217h function to return new CDS entry
DOS provides the interrupt 2f/12xx functions for use by
filesystem redirectors in order that they do not need to access
structures and variables using undocumented methods. Interrupt
2f/1217 is a function used by a redirector to get the CDS entry
corresponding to a drive without iterating the CDS array found
via SYSVARS LOL.
    FreeDOS currently validates the flags in CDS entry before
deciding whether to return the entry to the caller. This behaviour
prevents a redirector receiving the CDS entry corresponding to
an as yet unassigned drive so preventing any new drive mapping.

    I've tested the following flavours of DOS and only FreeDOS
does this.

 # DOS variants returning new CDS entries okay
    DR-DOS
        6.00-930319 7.00 7.01 7.02-971119 7.02-980123 7.03 8.00
    MS-DOS
        3.10 3.20 3.21 3.30-Nec 3.30 3.31 4.01 5.00 6.00 6.20 6.21 6.22
        7.00 7.10
    PC-DOS
        3.00-Compaq 3.00 3.10-850307 3.10-850422 3.10-Compaq 3.20-851230
        3.20-860221 3.30 3.31-Compaq 4.00 4.01 5.00 5.02 6.10 6.30 7.00
        7.10 7.2K

 # DOS variants that return error rather than new CDS entry
    FR-DOS
        1.00 1.10 1.20

    This patch introduces an unvalidated version of get_cds() and calls
it only for the int2f/1217h call, other uses remain as before.
2019-12-02 15:09:23 -05:00
Andrew Bird
687f31fdae Travis: Initial build attempt
Note: Forced Unix scripts to LF endings
2019-12-02 15:06:22 -05:00
Mondgestein
a2ad348ed8 Function 30h (Get DOS Version): Get DOS version from PSP
- Upon creation, initialize the PSP version field
    to os_setver_minor / os_setver_major.
  - When calling Function 30h, return the contents
    of the current PSP's version field to the caller.
2019-12-02 12:06:22 -05:00
Lino Mastrodomenico
61499ae6aa Add the full text of the license (GPL v2). (#8)
* Move the text of the GPLv2 to the top-level directory

This to make it easier to find, it also allows to be autodetectable by github and other automated tools.  Note: this is not a license change, the FreeDOS kernel is already released under the GPL v2.
2019-12-01 21:08:56 -05:00
lpproj
6be00f83c1 Fix func 36h (Get free disk space) fails in some redirectors:
- David Maxey's PHANTOM (Undocumented DOS 2nd edition)
  - Novell CD-ROM extension NWCDEX (DR DOS 7.03)
2019-11-08 18:41:50 -05:00
C. Masloch
61647299c6 dosfns.c: only copy to current_ldt if pointer is valid 2019-11-08 18:19:11 -05:00
C. Masloch
6fbb1d0043 inthndlr.c: in Int21.43FF, dispatch DosMkRmdir on CL not AH 2019-11-08 18:19:11 -05:00
Tee-Kiah Chia
6f9648672e EXEC (func 0x4b): fix: do not crash if exMinAlloc == 0xffff
Some ancient NE programs set exMinAlloc to 0xffff to signify
that they should not be run as normal MZ programs at all:

00000000  4d 5a 40 00 01 00 00 00  04 00 ff ff ff ff 00 00
00000010  00 00 00 00 00 00 00 00  40 00 00 00 00 00 00 00
00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00000030  00 00 00 00 00 00 00 00  00 00 00 00 40 00 00 00
00000040  4e 45 04 00 9b 00 07 00  00 00 00 00 06 40 02 00
...

The kernel should reject these programs, rather than try to
run them (and crash the system).
2019-11-05 12:49:41 -05:00
Kenneth J Davis
9d5abfe25a
Merge pull request #2 from PerditionC/master
sync
2018-10-20 20:58:47 -04:00
Kenneth J Davis
80c1184294
Merge pull request #31 from FDOS/master
sync
2018-10-20 20:54:34 -04:00
Andrew Bird
d5b5505013 FCB: Rename return value lost
Two variables named 'result' were defined, at the outer level a
UBYTE to hold the function return value and the inner a COUNT to
hold returns from 'truename()'. The overall function return value
was always FCB_SUCCESS due to shadowing, however removing the
inner variable definition as a fix does not work due to sign
issues and intermixing of the variable uses, so rename the inner
variable.

Tested this patch using FDPP platform
1/ Simple rename of file with conditions for success (ok)
2/ Simple rename of file with conditions for failure - source missing (ok)
3/ Simple rename of file with conditions for failure - target exists (ok)

Fixes #16
2018-10-20 20:45:24 -04:00
Bart Oldeman
8c45af38c7 Implement suggested instead of minimal fix for ludivmul.
See https://sourceforge.net/p/freedos/bugs/106/
(Gerd Grosse)
2018-10-20 19:47:09 -04:00
Bart Oldeman
5e31e7fe58 Fix division for some large numbers such as 0xFFFF01FF/0x10101FF
See also https://sourceforge.net/p/freedos/bugs/106/
(Gerd Grosse)
2018-10-20 19:47:09 -04:00
Bart Oldeman
c4d18100e7 Fix comments (Gerd Grosse, https://sourceforge.net/p/freedos/bugs/106/) 2018-10-20 19:47:09 -04:00
Bart Oldeman
761582ec0d ia16-elf-gcc: eliminate DOSDATA, DOSTEXT and C use of TGROUP.
Now that it understands relocations those are no longer necessary.
2018-10-20 19:47:09 -04:00
Bart Oldeman
204c2d5ba9 ia16-elf-gcc: eliminate _EnableA20 and _DisableA20 wrappers. 2018-10-20 19:47:09 -04:00
Bart Oldeman
384c5d302f ia16-elf-gcc: eliminate wrapper for init_call_p_0 and make it "noreturn". 2018-10-20 19:47:09 -04:00
Bart Oldeman
112f0fea42 ia16-elf-gcc port: use CDECL = __attribute__((cdecl)) instead of varargs. 2018-10-20 19:47:09 -04:00
Tee-Kiah Chia
656afa7873 ia16-elf-gcc: remove need for far function wrappers 2018-10-20 19:47:09 -04:00
Tee-Kiah Chia
a4e7d1bf08 ia16-elf-gcc: remove some DOSDATA(.) & DOSTEXT(.) uses; replace
with actual __far declarations which ia16-elf-gcc now supports
2018-10-20 19:47:09 -04:00
Tee-Kiah Chia
41cb3a9dc1 ia16-elf-gcc: use special .msdos_mz_{hdr, reloc} section names
recognized by my recent (post-20 Mar 2018) binutils-ia16 patches
2018-10-20 19:47:09 -04:00
Tee-Kiah Chia
ab6a76d049 Fix minor issues in diagnostic messages in utils/exeflat.c 2018-10-20 19:47:09 -04:00
Tee-Kiah Chia
2b96ed38d9 ia16-elf-gcc: use ia16-elf-objcopy instead of host objcopy
to process the ia16-elf object files
2018-10-20 19:47:09 -04:00
Tee-Kiah Chia
955cfc6df1 ia16-elf-gcc: update docs.: pkgs. for Ubuntu Trusty now avail. 2018-10-20 19:47:09 -04:00
Andrew Bird
7ec9c456ea FCB: Rename return value lost
Two variables named 'result' were defined, at the outer level a
UBYTE to hold the function return value and the inner a COUNT to
hold returns from 'truename()'. The overall function return value
was always FCB_SUCCESS due to shadowing, however removing the
inner variable definition as a fix does not work due to sign
issues and intermixing of the variable uses, so rename the inner
variable.

Tested this patch using FDPP platform
1/ Simple rename of file with conditions for success (ok)
2/ Simple rename of file with conditions for failure - source missing (ok)
3/ Simple rename of file with conditions for failure - target exists (ok)

Fixes #16
2018-10-18 07:08:30 -04:00
Bart Oldeman
e6d427834f Implement suggested instead of minimal fix for ludivmul.
See https://sourceforge.net/p/freedos/bugs/106/
(Gerd Grosse)
2018-09-06 10:30:04 -04:00
Bart Oldeman
eda671d079 Fix division for some large numbers such as 0xFFFF01FF/0x10101FF
See also https://sourceforge.net/p/freedos/bugs/106/
(Gerd Grosse)
2018-09-06 10:12:41 -04:00
Bart Oldeman
fa36d8aa25 Fix comments (Gerd Grosse, https://sourceforge.net/p/freedos/bugs/106/) 2018-09-06 10:07:00 -04:00
Bart Oldeman
5ff361314c ia16-elf-gcc: eliminate DOSDATA, DOSTEXT and C use of TGROUP.
Now that it understands relocations those are no longer necessary.
2018-07-12 14:27:03 -04:00
Bart Oldeman
1bb9496c48 ia16-elf-gcc: eliminate _EnableA20 and _DisableA20 wrappers. 2018-07-12 12:14:47 -04:00
Bart Oldeman
25071a8df2 ia16-elf-gcc: eliminate wrapper for init_call_p_0 and make it "noreturn". 2018-07-12 11:47:41 -04:00
Bart Oldeman
36e31078ce Merge branch 'ia16-elf-gcc' into fdos_master 2018-07-12 11:01:38 -04:00
Bart Oldeman
8ee8135d4f ia16-elf-gcc port: use CDECL = __attribute__((cdecl)) instead of varargs. 2018-07-12 10:56:26 -04:00
bartoldeman
0954613e2a
Merge pull request #1 from bartoldeman/ia16-elf-gcc
Ia16 elf gcc
2018-07-11 16:14:29 -04:00
bartoldeman
fefd37f0dd
Merge branch 'master' into ia16-elf-gcc 2018-07-11 16:14:09 -04:00
bartoldeman
ca7fb8e71b
Merge pull request #4 from tkchia/ia16-elf-gcc-post20180708
Simplify ia16-elf-gcc port, by taking advantage of recently-added gcc features
2018-07-11 16:06:59 -04:00
Tee-Kiah Chia
49d1939ed7 ia16-elf-gcc: remove need for far function wrappers 2018-07-08 18:10:18 +08:00
Tee-Kiah Chia
fd770f50df ia16-elf-gcc: remove some DOSDATA(.) & DOSTEXT(.) uses; replace
with actual __far declarations which ia16-elf-gcc now supports
2018-04-21 10:36:42 +08:00
Tee-Kiah Chia
fdbea16132 ia16-elf-gcc: use special .msdos_mz_{hdr, reloc} section names
recognized by my recent (post-20 Mar 2018) binutils-ia16 patches
2018-04-21 00:13:05 +08:00
bartoldeman
fe57c89061
Merge pull request #3 from tkchia/ia16-elf-gcc
Minor fixes for mkfiles/gcc.mak and utils/exeflat.c
2018-04-07 15:42:10 -04:00
Tee-Kiah Chia
2111b543c1 Fix minor issues in diagnostic messages in utils/exeflat.c 2018-04-07 22:22:12 +08:00
Tee-Kiah Chia
7eec989c22 ia16-elf-gcc: use ia16-elf-objcopy instead of host objcopy
to process the ia16-elf object files
2018-04-07 22:20:37 +08:00
bartoldeman
a954b21261
Merge pull request #2 from tkchia/ia16-elf-gcc
ia16-elf-gcc: update documentation to mention (new) ia16-elf-gcc packages for Ubuntu Trusty
2018-03-05 12:19:55 -05:00
Tee-Kiah Chia
f2bd7233e9 ia16-elf-gcc: update docs.: pkgs. for Ubuntu Trusty now avail. 2018-03-04 23:43:56 +08:00
Bart Oldeman
9c39f76155 Fix ret in LSHLU/LSHRU long shift macros, since they already pop of stack. 2018-02-22 18:44:49 -05:00
Tee-Kiah Chia
7160ff10c2 ia16-elf-gcc: precompiled Ubuntu pkgs. as a way to get toolchain 2018-02-22 18:44:49 -05:00
Bart Oldeman
a3a3c2cfe9 Fix ret in LSHLU/LSHRU long shift macros, since they already pop of stack. 2018-02-22 12:51:20 -05:00
Tee-Kiah Chia
0128621e1f ia16-elf-gcc: precompiled Ubuntu pkgs. as a way to get toolchain 2018-02-22 12:51:20 -05:00
Bart Oldeman
e83ebed451 Add build instructions for ia16-elf-gcc. 2018-01-11 17:50:31 -05:00
Bart Oldeman
a70f31bf61 ia16-elf-gcc: enable and fix basic warnings; don't do strict ptr aliasing for now 2018-01-11 17:50:31 -05:00
Bart Oldeman
ce8e4fd091 Use static for GCC, which makes the kernel smaller (automatic inlining) 2018-01-11 17:50:31 -05:00
Bart Oldeman
d7a05ab6cd For GCC builds use GNU make instead of wmake throughout.
This eliminates all build-dependencies on Open Watcom.
2018-01-11 17:50:31 -05:00
Bart Oldeman
7705558b3e Use "ar" instead of "wlib" in gcc build. 2018-01-11 17:50:31 -05:00
Bart Oldeman
9e04932d2b sys.com compiled with ia16-elf-gcc: fill in missing functions. 2018-01-11 17:50:31 -05:00
Bart Oldeman
89d97b18de Fix ASMCFUNC (FAR) functions for ia16-elf-gcc.
We need to use make the functions vararg (,...) to make them cdecl.
For FAR functions we need wrappers.
2018-01-11 17:50:31 -05:00
Bart Oldeman
9b5b2e7d60 Create init varieties for unsigned long helper functions.
An INITPATCH is used to make sure the correct symbols are used.
The GCC kernel now shows the copyright string and boots a little further.
2018-01-11 17:50:31 -05:00
Bart Oldeman
97003a8aca Introduce popargs and arg macros to distinguish PASCAL/STDCALL conventions.
GCC has -mrtd but the args are pushed in reverse versus PASCAL. So asm
routines have to use macros to obtain the stack arguments.
For the complex call_nls assembly, revert the arguments in C using a
preprocessor macro.
2018-01-11 17:50:31 -05:00
Bart Oldeman
f6d62165e0 ia16-elf-gcc: introduce DOSTEXT and DOSDATA macros.
Using DOSTEXT(x) accesses x in LGROUP and DOSDATA(x) in DGROUP.
This is necessary since ia16-elf-gcc does not understand data
in far segments.

For non-macro'ed symbols, FP_SEG needs to be replaced by explicit
segment references.
2018-01-11 17:50:31 -05:00
Bart Oldeman
71a7d0d264 ia16-elf-gcc: provide GNU LD linker script and symbols to link kernel.
The resulting kernel and sys.com do not work yet (kernel prints 123 only).
Some functions in sys.com are placeholders.
2018-01-11 17:50:31 -05:00
Bart Oldeman
7bf4b77233 ia16-elf-gcc port: compile all asm files with -f elf.
Because ia16-elf-gcc and the GNU linker do not understand OMF we
need to use ELF everywhere.
This also means we cannot use "wrt", "seg" and "call/jmp far".
Most wrt's are superfluous, and seg and call/jmp far can be
replaced by explicit ?GROUP references (to be defined in the
linker script).
2018-01-11 17:50:31 -05:00
Bart Oldeman
fbdbc4c25c C source code changes so the kernel can compile with ia16-elf-gcc.
Use "make all COMPILER=gcc".
Linking does not work yet with these changes.
2018-01-11 17:50:31 -05:00
Bart Oldeman
705268267c Use DOSTEXTFAR and DOSFAR for kbdType and internal_data. 2018-01-11 17:50:31 -05:00
Bart Oldeman
0b26c3f18f NLS: clean up to use the struct more and fewer relocations. 2018-01-11 17:50:31 -05:00
Bart Oldeman
fdac78cc67 Fix compilation with TC2 (no // comments; a global variable needs ASM) 2017-12-22 13:14:11 -05:00
Bart Oldeman
33d707ba7f Fix compilation with MSVC 1.52c.
Needs one more file from the c library, BSS_INIT all uninitialized
globals in config.c and a define of SEEK_SET.
2017-12-22 13:13:37 -05:00
Bart Oldeman
e82de4b707 Introduce end-of-line normalization 2017-12-22 09:37:31 -05:00
Bart Oldeman
ab6d98ff56 .gitignore: be more thorough 2017-12-22 09:37:31 -05:00
Stas Sergeev
44cf0a17a1 fix and enable i386 support
This gives ~5K size reduction with bc3.1.
Today no one uses pre-i386 CPUs so there is no good
reason against having an extra optimization.
2017-12-06 23:13:47 -05:00
Stas Sergeev
8187fd8153 disk: fix sectors count truncation for CHS [fixes #10]
LBA_to_CHS() uses geometry taken from BIOS, but LBA_Transfer()
was using the geometry from VBR. This caused "count" variable
to underflow over unsigned long, then corrupting the entire
DOS memory with the large read.

This patch makes LBA_to_CHS() to return the geometry to caller,
so that the calculus do always match.

Thanks to @ecm-pushbx and @andrewbird for helping to
nail this down.
2017-09-22 23:03:47 -04:00
Stas Sergeev
5fb0c4482d config: enable fat32 support
These days everyone wants fat32 support. :)
2017-09-22 07:12:15 -04:00
PerditionC
2835dfe920 Merge pull request #8 from stsp/chain
Implement CHAIN directive
2017-02-11 13:00:40 -05:00
Stas Sergeev
0b541ffd81 implement CHAIN directive for config.sys 2016-10-07 00:22:56 +03:00
Stas Sergeev
baad0b69dd remove trailing spaces in config.c 2016-10-06 23:01:14 +03:00
Stas Sergeev
5c168c350e add bc3 build support 2016-10-06 07:23:59 -04:00
Stas Sergeev
f4c9691ef5 fix watcom check
WATCOM var may be defined in autoexec.bat, but this doesn't
mean the user wants to build with watcom.
Check the COMPILER="WATCOM" instead.
2016-10-06 07:23:59 -04:00
Stas Sergeev
0b303a23b4 nasm16 no longer exists 2016-10-06 07:23:59 -04:00
Stas Sergeev
68693a71c5 add missing ASM to fix build
Without this I am getting undefined reference to
_ReturnAnyDosVersionExpected
2016-10-06 07:23:59 -04:00
Stas Sergeev
e698ae2b3b unix2dos bat files
ms-dos/pc-dos command.com does not understand unix line-endings.
2016-10-06 07:23:59 -04:00
PerditionC
63b31b301d Merge pull request #4 from lpproj/fix_20160206
some fixes (initial DTA and NUL device)
2016-10-05 17:50:51 -04:00
KJD
5406ba5a9b add initial tests for DOS absolute sector read/write 2016-05-12 19:44:39 -04:00
KJD
bdc2e068c4 remove some additional built files during clobber, ignore command.com in bin directory 2016-05-12 19:05:02 -04:00
lpproj
cab8092ad6 Fix memory break in NUL device 2016-02-06 13:43:34 +09:00
lpproj
e024f72a4c Fix initial DTA 2016-02-06 13:32:36 +09:00
184 changed files with 22764 additions and 7752 deletions

6
.gitattributes vendored Normal file
View File

@ -0,0 +1,6 @@
* text eol=crlf
*.up -text
*.UP -text
ci_*.sh text eol=lf
.github/workflows/*.yml text eol=lf
test/** binary diff

48
.github/workflows/ci-build.yml vendored Normal file
View File

@ -0,0 +1,48 @@
name: Build
on:
pull_request:
types:
- opened
- ready_for_review
- reopened
- synchronize
push:
workflow_dispatch:
jobs:
build:
if: contains(github.event.head_commit.message, '[skip ci]') == false
runs-on: ubuntu-22.04
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
submodules: recursive
- name: Package install
run: ./ci_prereq.sh
- name: build
run: ./ci_build.sh
- name: test
run: ./ci_test.sh
- name: make snapshot name
id: snapshotname
run: |
(
today=`date -u +%F | tr '\n' '-'`
s_sha=`echo -n ${GITHUB_SHA} | cut -c1-8`
printf "fname=snapshot-%s%s\n" $today $s_sha >> $GITHUB_OUTPUT
)
- name: upload
if: github.repository == 'FDOS/kernel' &&
(github.event_name == 'push' || github.event.pull_request.merged == true)
uses: actions/upload-artifact@v4
with:
name: ${{ steps.snapshotname.outputs.fname }}
path: _output/*/*.???

45
.gitignore vendored
View File

@ -1,17 +1,60 @@
# Object Files
*.OBJ
*.obj
# List Files
*.LST
*.lst
# Map files
*.MAP
*.map
*.SYM
*.sym
# Executable files
*.EXE
*.exe
*.COM
*.com
# Bin files
*.BIN
*.bin
# Libraries
*.LIB
*.lib
# generated text files
sys/*.h
sys/*.H
kernel/*.lnk
kernel/*.LNK
# FreeDOS build tools configuration
config.bat
config.mak
kernel/*.SYS
kernel/*.sys
bin/[kK]*.SYS
bin/[kK]*.sys
bin/COMMAND.COM
bin/command.com
bin/COUNTRY.SYS
bin/country.sys
bin/SETVER.SYS
bin/setver.sys
kernel/KERNEL.SYS
# backup files
*.orig
*~
*.diff
*.rej
# CI build
_downloads/**
_output/**
_watcom/**
kernel/exeflat.rsp

7
.gitmodules vendored Normal file
View File

@ -0,0 +1,7 @@
[submodule "share"]
path = share
url = https://github.com/FDOS/share.git
ignore = untracked
[submodule "country"]
path = country
url = https://github.com/FDOS/country.git

View File

@ -3,12 +3,18 @@ IF "%1"=="" GOTO USAGE
REM assumes ran in same directory as this file, ie base of kernel source
SET BASEPATH=%CD%
CD ..
REM setup command aliases
SET ZIPIT=7z.exe a -tzip -mx9 -mm=deflate -mpass15 -r
REM when called from RELEASE.BAT assume clean source exported from version control
IF "%2"=="RELEASE" GOTO PACK
ECHO create source copy
if EXIST SOURCE RMDIR /S /Q SOURCE > NUL
MKDIR SOURCE
ECHO \.svn>SOURCE\SKIPLIST
ECHO .git>>SOURCE\SKIPLIST
ECHO .yml>>SOURCE\SKIPLIST
ECHO CNAME>>SOURCE\SKIPLIST
XCOPY %BASEPATH% SOURCE\ke%1 /S /V /I /Q /G /H /R /Y /EXCLUDE:SOURCE\SKIPLIST
DEL SOURCE\SKIPLIST > NUL
ECHO ensuring clean
@ -16,34 +22,56 @@ PUSHD .
CD SOURCE\ke%1
CALL clobber.bat
POPD
PAUSE
:PACK
SET VERSION=%1
SET LSMRET=SRC
SET LSMFILE=SOURCE\ke%1\docs\fdkernel.lsm
GOTO LSM
:SRC
REM remove CONFIG.BAT if exists, such as building packages from develoment directory
IF EXIST SOURCE\ke%1\CONFIG.BAT DEL SOURCE\ke%1\CONFIG.BAT > NUL
ECHO zipping source
7z.exe a -tzip -mx9 -mpass15 -r ke%1s.zip SOURCE\*
ECHO creating APPINFO and expected packaging dir structure
%ZIPIT% ke%1s.zip SOURCE\*
ECHO gathering source and creating APPINFO and expected packaging dir structure
REM FreeDOS package format, has APPINFO, BIN, DOC\KERNEL, SOURCE\KERNEL\
IF EXIST PACKAGE ECHO PACKAGE directory exists, break now to avoid deleting it!
IF EXIST PACKAGE pause
IF EXIST PACKAGE RMDIR /S PACKAGE
MKDIR PACKAGE
MKDIR PACKAGE\SOURCE
XCOPY /S /I /Q SOURCE\ke%1 PACKAGE\SOURCE\KERNEL
MKDIR PACKAGE\DOC
MKDIR PACKAGE\DOC\KERNEL
COPY /N SOURCE\ke%1\DOCS\* PACKAGE\DOC\KERNEL\
COPY SOURCE\ke%1\COPYING PACKAGE\DOC\KERNEL\COPYING
MKDIR PACKAGE\APPINFO
MOVE PACKAGE\DOC\KERNEL\fdkernel.lsm PACKAGE\APPINFO\KERNEL.LSM
MKDIR PACKAGE\BIN
ECHO using working configuration file
::COPY trunk\CONFIG.BAT SOURCE\ke%1 > NUL
COPY %BASEPATH%\CONFIG.BAT SOURCE\ke%1\ > NUL
CD SOURCE\ke%1
ECHO build and packaging
SET VERSION=%1 (FAT12/FAT16)
SET FAT=16
SET CPU=86
SET BZKRET=F16
GOTO BZK
:F16
SET VERSION=%1 (FAT12/FAT16/FAT32)
SET FAT=32
SET CPU=386
SET BZKRET=F32
GOTO BZK
:F32
ECHO building FreeDOS package
CD ..\..\PACKAGE
%ZIPIT% ..\kernel.zip APPINFO BIN DOC SOURCE
ECHO clean up
CD ..\..
CD ..
RMDIR /S /Q SOURCE > NUL
RMDIR /S /Q PACKAGE > NUL
ECHO Done.
SET BZKRET=
GOTO DONE
@ -51,27 +79,23 @@ GOTO DONE
:BZK
ECHO build kernel %VERSION%
CALL build.bat /D KERNEL_VERSION /V "%1 " 86 win upx fat%FAT%
DEL BIN\K??86??.sys
CALL build.bat /D KERNEL_VERSION /V "%1 " %CPU% win upx fat%FAT%
DEL BIN\K*86??.sys
SET LSMRET=BZK_2
SET LSMFILE=docs\fdkernel.lsm
GOTO LSM
:BZK_2
SET LSMRET=
ECHO zipping FAT%FAT% release version
7z.exe a -tzip -mx9 -mpass15 -r ..\..\ke%1_86f%FAT%.zip BIN\* DOCS\*
ECHO restructuring and zipping update package
DEL BIN\K??86??.* > NUL
MKDIR DOC
MKDIR DOC\KERNEL
COPY DOCS\* DOC\KERNEL\
MKDIR APPINFO
MOVE DOC\KERNEL\*.lsm APPINFO\
7z.exe a -tzip -mx9 -mpass15 -r ..\..\kernel%FAT%.zip APPINFO\* BIN\* DOC\*
%ZIPIT% ..\..\ke%1_%CPU%f%FAT%.zip BIN\* DOCS\*
ECHO storing binaries for FreeDOS package
COPY BIN\KERNEL.SYS ..\..\PACKAGE\BIN\KERNL%CPU%.SYS
COPY /B /Y BIN\country.sys ..\..\PACKAGE\BIN\COUNTRY.SYS
COPY /B /Y BIN\setver.sys ..\..\PACKAGE\BIN\SETVER.SYS
COPY /B /Y BIN\sys.com ..\..\PACKAGE\BIN\SYS.COM
IF EXIST BIN\share.com COPY /B /Y BIN\share.com ..\..\PACKAGE\BIN\SHARE.COM
ECHO cleaning up between builds
CALL clobber.bat
RMDIR /S /Q DOC
RMDIR /S /Q APPINFO
GOTO %BZKRET%
:LSM
@ -83,12 +107,11 @@ ECHO Description: The FreeDOS Kernel>>%LSMFILE%
ECHO Keywords: kernel, FreeDOS, DOS, MSDOS>>%LSMFILE%
ECHO Author: (developers: can be reached on the freedos-kernel mailing list)>>%LSMFILE%
ECHO Maintained-by: freedos-kernel@lists.sourceforge.net>>%LSMFILE%
ECHO Primary-site: http://freedos.sourceforge.net/kernel/>>%LSMFILE%
ECHO Primary-site: http://github.com/fdos/kernel>>%LSMFILE%
ECHO Alternate-site: http://www.fdos.org/kernel/>>%LSMFILE%
ECHO Alternate-site: https://github.com/PerditionC/fdkernel>>%LSMFILE%
ECHO Alternate-site: https://freedos.svn.sourceforge.net/svnroot/freedos>>%LSMFILE%
ECHO Alternate-site: http://freedos.sourceforge.net/kernel/>>%LSMFILE%
ECHO Original-site: http://www.gcfl.net/pub/FreeDOS/kernel>>%LSMFILE%
ECHO Platforms: DOS, FreeDOS, DOSEMU (OpenWatcom C or Turbo C, NASM, UPX)>>%LSMFILE%
ECHO Platforms: DOS, FreeDOS, DOSEMU (OpenWatcom/Borland/GCC-ia16, NASM, UPX)>>%LSMFILE%
ECHO Copying-policy: GPL2>>%LSMFILE%
ECHO End>>%LSMFILE%
SET LSMFILE=
@ -96,8 +119,8 @@ SET VERSION=
GOTO %LSMRET%
:USAGE
ECHO Build kernel packages (interim builds or release without tagging) - usage: RELEASE {VERSION} e.g. RELEASE 2039
ECHO Build kernel packages (interim builds or release without tagging) - usage: %0 {VERSION} e.g. %0 2039 or %0 git
:DONE
CD %BASEPATH%
SET BASEPATH=
SET ZIPIT=

View File

@ -1,14 +1,17 @@
fdkernel
========
fd kernel
=========
FreeDOS kernel - branch from 2042 SVN 0xFD kernel
FreeDOS kernel - current 0xFD version is 2.44 (2044)
http://www.fdos.org/kernel/
The FreeDOS kernel implements the core MS/PC-DOS (R) compatible functions. It is derived from Pat Villani's DOS-C kernel and released under the GPL v2. Please see http://www.freedos.org/ for more details about the FreeDOS (TM) Project. Compiled kernels ready to use (just copy kernel.sys over an existing install) are available at http://www.fdos.org/kernel/testing/git/ - also available are the source archive and fdpkg compatible packages.
The FreeDOS kernel implements the core MS/PC-DOS (R) compatible functions. It is derived from Pat Villani's DOS-C kernel and released under the GPL v2. Please see http://www.freedos.org/ for more details about the FreeDOS (TM) Project. This was originally a branch based on 2042 SVN 0xFD kernel; the full svn history has since been added to git (see other branches) and current development of release kernels are available here. Please fork and submit a Pull Request!
Compiled kernels ready to use (just copy kernel.sys over an existing install) are available at http://www.fdos.org/kernel/testing/git/ - also available are the source archive and fdpkg compatible packages. *** TODO update links/upload archives
This version of the kernel is intended only for 8086+ or 80386+ IBM compatible computers in continuation of the goals of the FreeDOS Project. Please see http://www.fdos.org/kernel for my 0xDC kernel that is work on merging back in some of the original portability aspects and other supported features at the cost of some compatibility with older hardware/software.
Please feel free to email me - PerditionC@gmail.com
Jan 2014
Now with automatic builds and soon tests [![Build](../../workflows/Build/badge.svg)](../../actions)

View File

@ -1,92 +1,30 @@
@ECHO OFF
IF "%1"=="" GOTO USAGE
REM goto to just below trunk and tags directory, assume ran in trunk directory
CD ..
REM assume ran in root directory of kernel checkout, e.g. C:\fdos\source\kernel\
ECHO tag SVN with release version - svn copy trunk/ tags/ke%1
svn copy https://freedos.svn.sourceforge.net/svnroot/freedos/kernel/trunk/ https://freedos.svn.sourceforge.net/svnroot/freedos/kernel/tags/ke%1 -m "Tag kernel release %1"
PAUSE
ECHO svn export to get clean tree
if EXIST SOURCE RMDIR /S /Q SOURCE > NUL
svn export https://freedos.svn.sourceforge.net/svnroot/freedos/kernel/tags/ke%1 SOURCE\ke%1
REM svn export https://freedos.svn.sourceforge.net/svnroot/freedos/kernel/trunk SOURCE\ke%1
ECHO tag git with release version -
git tag -a -m "Tag kernel release %1" ke%1 HEAD
ECHO get a clean tree
if EXIST ..\SOURCE RMDIR /S /Q ..\SOURCE > NUL
::git clone -v --local --branch ke%1 . ..\SOURCE\ke%1\
git clone -v --recurse-submodules --local . ..\SOURCE\ke%1\
SET VERSION=%1
SET LSMRET=SRC
SET LSMFILE=SOURCE\ke%1\docs\fdkernel.lsm
GOTO LSM
:SRC
ECHO zipping source
7z.exe a -tzip -mx9 -mpass15 -r ke%1s.zip SOURCE\*
ECHO creating APPINFO and expected packaging dir structure
ECHO using working configuration file
COPY trunk\CONFIG.BAT SOURCE\ke%1 > NUL
CD SOURCE\ke%1
REM delete files to exclude
RD /S /Q ..\SOURCE\ke%1\.git > NUL
RD /S /Q ..\SOURCE\ke%1\.github > NUL
IF EXIST ..\SOURCE\ke%1\.git* DEL /Q ..\SOURCE\ke%1\.git* > NUL
IF EXIST ..\SOURCE\ke%1\*.yml DEL /Q ..\SOURCE\ke%1\*.yml > NUL
IF EXIST ..\SOURCE\ke%1\ci*.sh DEL /Q ..\SOURCE\ke%1\ci*.sh > NUL
IF EXIST ..\SOURCE\ke%1\docs\*.yml DEL /Q ..\SOURCE\ke%1\docs\*.yml > NUL
IF EXIST ..\SOURCE\ke%1\docs\CNAME DEL /Q ..\SOURCE\ke%1\docs\CNAME > NUL
::pause
ECHO build and packaging
SET VERSION=%1 (FAT12/FAT16)
SET FAT=16
SET BZKRET=F16
GOTO BZK
:F16
SET VERSION=%1 (FAT12/FAT16/FAT32)
SET FAT=32
SET BZKRET=F32
GOTO BZK
:F32
ECHO clean up
CD ..\..
RMDIR /S /Q SOURCE > NUL
ECHO Done.
SET BZKRET=
ECHO %CD%
CALL MAKEPKGS.BAT %1 RELEASE
GOTO DONE
:BZK
ECHO build kernel %VERSION%
CALL build.bat /D KERNEL_VERSION /V "%1 " 86 upx fat%FAT%
DEL BIN\K??86??.sys
SET LSMRET=BZK_2
SET LSMFILE=docs\fdkernel.lsm
GOTO LSM
:BZK_2
SET LSMRET=
ECHO zipping FAT%FAT% release version
7z.exe a -tzip -mx9 -mpass15 -r ..\..\ke%1_86f%FAT%.zip BIN\* DOCS\*
ECHO restructuring and zipping update package
DEL BIN\K??86??.* > NUL
MKDIR DOC
MKDIR DOC\KERNEL
COPY DOCS\* DOC\KERNEL\
MKDIR APPINFO
MOVE DOC\KERNEL\*.lsm APPINFO\
7z.exe a -tzip -mx9 -mpass15 -r ..\..\kernel%FAT%.zip APPINFO\* BIN\* DOC\*
ECHO cleaning up between builds
CALL clobber.bat
RMDIR /S /Q DOC
RMDIR /S /Q APPINFO
GOTO %BZKRET%
:LSM
ECHO Begin3>%LSMFILE%
ECHO Title: The FreeDOS Kernel>>%LSMFILE%
ECHO Version: %VERSION%>>%LSMFILE%
ECHO Entered-date: %DATE%>>%LSMFILE%
ECHO Description: The FreeDOS Kernel>>%LSMFILE%
ECHO Keywords: kernel, FreeDOS, DOS, MSDOS>>%LSMFILE%
ECHO Author: (developers: can be reached on the freedos-kernel mailing list)>>%LSMFILE%
ECHO Maintained-by: freedos-kernel@lists.sourceforge.net>>%LSMFILE%
ECHO Primary-site: http://freedos.sourceforge.net/kernel/>>%LSMFILE%
ECHO Alternate-site: http://www.fdos.org/kernel/>>%LSMFILE%
ECHO Alternate-site: https://freedos.svn.sourceforge.net/svnroot/freedos>>%LSMFILE%
ECHO Original-site: http://www.gcfl.net/pub/FreeDOS/kernel>>%LSMFILE%
ECHO Platforms: DOS, FreeDOS, DOSEMU (OpenWatcom C or Turbo C, NASM, UPX)>>%LSMFILE%
ECHO Copying-policy: GPL2>>%LSMFILE%
ECHO End>>%LSMFILE%
SET LSMFILE=
SET VERSION=
GOTO %LSMRET%
:USAGE
ECHO Tag and build release kernels - usage: RELEASE {VERSION} e.g. RELEASE 2039
:DONE
ECHO Please git push the tag to origin and upload the archives.
ECHO E.g. git push origin ke%1

View File

@ -24,40 +24,73 @@
; License along with DOS-C; see the file COPYING. If not,
; write to the Free Software Foundation, 675 Mass Ave,
; Cambridge, MA 02139, USA.
;
;
; +--------+ 1FE0:7E00
; |BOOT SEC|
; |RELOCATE|
; |--------| 1FE0:7C00
; |LBA PKT |
; |--------| 1FE0:7BC0
; |--------| 1FE0:7BA0
; |BS STACK|
; |--------|
; |4KBRDBUF| used to avoid crossing 64KB DMA boundary
; |--------| 1FE0:63A0
; | |
; |--------| 1FE0:3000
; | CLUSTER|
; | LIST |
; |--------| 1FE0:2000
; | |
; |--------| 0000:7E00
; |BOOT SEC| overwritten by max 128k FAT buffer
; |ORIGIN | and later by max 134k loaded kernel
; |--------| 0000:7C00
; | |
; |--------|
; |KERNEL | also used as max 128k FAT buffer
; |LOADED | before kernel loading starts
; |--------| 0060:0000
; | |
; +--------+
; Memory layout for the FreeDOS FAT12/FAT16 boot process:
;
; ...
; |-------| 1FE0h:7E00h = 27C00h (159 KiB)
; |BOOTSEC| loader relocates itself here first thing,
; |RELOC. | before loading root directory/FAT/kernel file
; |-------| 1FE0h:7C00h = 27A00h (158 KiB)
; | gap | PARAMS live here
; |LBA PKT| LBA disk packet
; |-------| 1FE0h:7BC0h = 279C0h (158 KiB)
; | gap | READADDR_* live here
; |-------| 1FE0h:7BA0h = 279A0h (158 KiB)
; | STACK | below relocated loader, above sector buffer (size 5.9 KiB)
; ...
; |-------| 1FE0h:6400h = 26200h (152 KiB)
; |SEC.BUF| sector buffer, to avoid crossing 64 KiB DMA boundary (size 8 KiB)
; |-------| 1FE0h:4400h = 24200h (144 KiB)
; ...
; |-------| 1FE0h:4380h = 24182h (144 KiB)
; |CLUSTER| built from FAT, listing every cluster of the kernel file.
; | LIST | file <= 134 KiB, cluster >= 32 Byte, hence <= 8578 B list.
; |-------| 1FE0h:2200h = 22000h (136 KiB)
; ...
; |-------| 0000h:7E00h = 07E00h (31.5 KiB)
; |BOOTSEC| possibly overwritten by the FAT (<= 128 KiB) and the kernel,
; |ORIGIN | so the bootsector relocates itself up...
; |-------| 0000h:7C00h = 07C00h (31 KiB)
; ...
; |-------|
; |KERNEL | maximum size 128 KiB (overwrites bootsec origin)
; |LOADED | (holds directory then FAT before kernel file load)
; |-------| 0060h:0000h = 00600h (1.5 KiB)
; ...
; The entire root directory is loaded to the kernel load address
; to scan for the kernel file. It is assumed to fit into 128 KiB.
; Typical root directory size is up to 512 entries = 16 KiB.
; Further, it is assumed that at least one root directory entry
; starts with a NUL byte to signify the end of the directory.
; After the directory entry is found, the entire FAT is loaded to
; the kernel load address. It is assumed that the size of the FAT
; in sectPerFat will not lead to a FAT larger than 128 KiB, which
; is the maximum size a FAT16 may fully utilise.
; The kernel load segment may be patched using the SYS /L switch.
; We support values between 0x60 and 0x200 here, with file size
; of up to 128 KiB (rounded to cluster size). Default is 0x60.
; This loader traditionally supports file sizes up to 134 KiB,
; assuming the default segment of 0x60. This does require a
; cluster size of 4 KiB (leads to maximum 132 KiB) or 2 KiB or
; lower (maximum 134 KiB). A more portable maximum is 128 KiB,
; which works with cluster sizes up to 128 KiB.
;%define ISFAT12 1
;%define ISFAT16 1
;verify one and only one of ISFAT12 or ISFAT16 is defined
%ifdef ISFAT12
%ifdef ISFAT16
%error Must select one FS
%endif
%elifndef ISFAT16
%error Must select one FS
%endif
; NOTE: sys must be updated if magic offsets change
%assign ISFAT1216DUAL 1
%include "magic.mac"
segment .text
@ -91,8 +124,8 @@ Entry: jmp short real_start
%define LOADSEG 0x0060
%define FATBUF 0x2000 ; offset of temporary buffer for FAT
; chain
%define CLUSTLIST 0x2200 ; offset of temporary buffer for FAT
; chain cluster list
; Some extra variables
@ -100,7 +133,16 @@ Entry: jmp short real_start
;-----------------------------------------------------------------------
times 0x3E-$+$$ db 0
times 36h - ($ - $$) db 0
; The filesystem ID is used by lDOS's instsect (by ecm)
; by default to validate that the filesystem matches.
%ifdef ISFAT12
%define FATFS "FAT12"
%elifdef ISFAT16
%define FATFS "FAT16"
%endif
db FATFS
times 3Eh - ($ - $$) db 32
; using bp-Entry+loadseg_xxx generates smaller code than using just
; loadseg_xxx, where bp is initialized to Entry, so bp-Entry equals 0
@ -117,9 +159,9 @@ Entry: jmp short real_start
%define LBA_SECTOR_32 word [LBA_PACKET+12]
%define LBA_SECTOR_48 word [LBA_PACKET+14]
%define READBUF 0x63A0 ; max 4KB buffer (min 2KB stack), == stacktop-0x1800
%define READADDR_OFF BP-0x60-0x1804 ; pointer within user buffer
%define READADDR_SEG BP-0x60-0x1802
%define READBUF 0x4400 ; max 8 KiB buffer
%define READADDR_OFF word BP-0x60 ; pointer within user buffer
%define READADDR_SEG word BP-0x60+2
%define PARAMS LBA_PACKET+0x10
;%define RootDirSecs PARAMS+0x0 ; # of sectors root dir uses
@ -161,6 +203,7 @@ real_start:
jmp word 0x1FE0:cont
loadseg_off dw 0
magicoffset "loadseg", 5Ch, 5Ch
loadseg_seg dw LOADSEG
cont:
@ -173,6 +216,7 @@ cont:
; in DL, however we work around this in SYS.COM by NOP'ing out the use of DL
; (formerly we checked for [drive]==0xff; update sys.c if code moves)
;
magicoffset "set unit", 66h, 66h
mov [drive], dl ; rely on BIOS drive number in DL
mov LBA_SIZE, 10h
@ -249,7 +293,7 @@ next_entry: mov cx, 11
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
jc boot_error ; fail if not found
jmp boot_error ; fail if not found
ffDone:
push ax ; store first cluster number
@ -277,7 +321,7 @@ ffDone:
push ds
pop es
mov ds, [loadseg_60]
mov di, FATBUF
mov di, CLUSTLIST
next_clust: stosw ; store cluster number
mov si, ax ; SI = cluster number
@ -334,7 +378,7 @@ finished: ; Mark end of FAT chain with 0, so we have a single
les bx, [loadsegoff_60] ; set ES:BX to load address 60:0
mov si, FATBUF ; set DS:SI to the FAT chain
mov si, CLUSTLIST ; set DS:SI to the FAT chain
cluster_next: lodsw ; AX = next cluster to read
or ax, ax ; EOF?
@ -346,7 +390,9 @@ load_next: dec ax ; cluster numbers start with 2
dec ax
mov di, word [bsSecPerClust]
and di, 0xff ; DI = sectors per cluster
dec di ; minus one if 256 spc
and di, 0xff ; DI = sectors per cluster - 1
inc di ; = spc
mul di
add ax, [data_start]
adc dx, [data_start+2] ; DX:AX = first sector to read
@ -355,18 +401,19 @@ load_next: dec ax ; cluster numbers start with 2
; shows text after the call to this function.
show.do_show:
mov ah, 0Eh ; show character
int 10h ; via "TTY" mode
show: pop si
lodsb ; get character
push si ; stack up potential return address
mov ah,0x0E ; show character
int 0x10 ; via "TTY" mode
cmp al,'.' ; end of string?
jne show ; until done
cmp al, 0 ; end of string?
jne .do_show ; until done
ret
boot_error: call show
; db "Error! Hit a key to reboot."
db "Error!."
; db "Error! Hit a key to reboot.",0
db "Error!",0
xor ah,ah
int 0x13 ; reset floppy
@ -390,8 +437,12 @@ readDisk: push si
mov word [READADDR_SEG], es
mov word [READADDR_OFF], bx
%ifndef QUIET
call show
db "."
db ".",0
%else ; ensure code after this still at same location
times 5 nop
%endif
read_next:
;******************** LBA_READ *******************************
@ -402,7 +453,7 @@ read_next:
mov bx,055aah ;
mov dl, [drive]
; NOTE: sys must be updated if location changes!!!
magicoffset "LBA detection", 17Bh, 178h
test dl,dl ; don't use LBA addressing on A:
jz read_normal_BIOS ; might be a (buggy)
; CDROM-BOOT floppy emulation
@ -506,6 +557,7 @@ do_int13_read:
times 0x01f1-$+$$ db 0
magicoffset "kernel name", 1F1h, 1F1h
filename db "KERNEL SYS",0,0
sign dw 0xAA55

View File

@ -1,34 +1,37 @@
; +--------+
; | |
; | |
; |--------| 4000:0000
; | |
; | FAT |
; | |
; |--------| 2000:0000
; |BOOT SEC|
; |RELOCATE|
; |--------| 1FE0:0000
; | |
; | |
; | |
; | |
; |--------|
; |BOOT SEC|
; |ORIGIN | 07C0:0000
; |--------|
; | |
; | |
; | |
; |--------|
; |KERNEL |
; |LOADED |
; |--------| 0060:0000
; | |
; +--------+
; Memory layout for the FreeDOS FAT32 single stage boot process:
;
; ...
; |-------| 1FE0h:7E00h = 27C00h (159 KiB)
; |BOOTSEC| loader relocates itself here first thing,
; |RELOC. | before loading root directory/FAT/kernel file
; |-------| 1FE0h:7C00h = 27A00h (158 KiB)
; | STACK | below relocated loader, above FAT sector (size 22 KiB)
; ...
; |-------| 2200h:2000h = 24000h (144 KiB)
; | FAT | (only 1 sector buffered, maximum sector size 8 KiB)
; |-------| 2200h:0000h = 22000h (136 KiB)
; ...
; |-------| 0000h:7E00h = 07E00h (31.5 KiB)
; |BOOTSEC| overwritten by the kernel, so the
; |ORIGIN | bootsector relocates itself up...
; |-------| 0000h:7C00h = 07C00h (31 KiB)
; ...
; |-------|
; |KERNEL | maximum size 128 KiB (overwrites bootsec origin)
; |LOADED | (holds 1 sector directory buffer before kernel file load)
; |-------| 0060h:0000h = 00600h (1.5 KiB)
; ...
; The kernel load segment may be patched using the SYS /L switch.
; We support values between 0x60 and 0x200 here, with file size
; of up to 128 KiB (rounded to cluster size). Default is 0x60.
;%define MULTI_SEC_READ 1
; NOTE: sys must be updated if magic offsets change
%assign ISFAT1216DUAL 0
%include "magic.mac"
segment .text
@ -57,11 +60,16 @@ Entry: jmp short real_start
%define xrootClst bp+0x2c ; Starting cluster of root directory
%define drive bp+0x40 ; Drive number
times 0x5a-$+$$ db 0
times 52h - ($ - $$) db 0
; The filesystem ID is used by lDOS's instsect (by ecm)
; by default to validate that the filesystem matches.
db "FAT32"
times 5Ah - ($ - $$) db 32
%define LOADSEG 0x0060
%define FATSEG 0x2000
%define FATSEG 0x2200
%define fat_sector bp+0x48 ; last accessed sector of the FAT
@ -92,12 +100,14 @@ real_start: cld
jmp word 0x1FE0:cont
loadseg_off dw 0
magicoffset "loadseg", 78h
loadseg_seg dw LOADSEG
cont: mov ds, ax
mov ss, ax
lea sp, [bp-0x20]
sti
magicoffset "set unit", 82h
mov [drive], dl ; BIOS passes drive number in DL
; call print
@ -139,7 +149,7 @@ secshift: inc ax
shr cx, 1
cmp cx, 1
jne secshift
mov byte [fat_secshift], al
mov word [fat_secshift], ax
dec cx
; FINDFILE: Searches for the file in the root directory.
@ -211,6 +221,10 @@ c6:
jmp short c5
boot_error:
mov ax, 0E00h | '!'
int 10h ; display the error sign
mov al, 07h
int 10h ; beep
xor ah,ah
int 0x16 ; wait for a key
int 0x19 ; reboot the machine
@ -231,8 +245,7 @@ next_cluster:
cn_loop:
shr dx,1
rcr ax,1
dec cx
jnz cn_loop ; DX:AX fat sector where our
loop cn_loop ; DX:AX fat sector where our
; cluster resides
; DI - cluster index in this
; sector
@ -264,8 +277,9 @@ cn_exit:
ret
boot_success:
mov bl, [drive]
boot_success:
mov dl, [drive] ; for Enhanced DR-DOS load
mov bl, dl ; for FreeDOS load
jmp far [loadsegoff_60]
; Convert cluster to the absolute sector
@ -289,7 +303,9 @@ c3:
sub ax, 2
sbb cx, byte 0 ; CX:AX == cluster - 2
mov bl, [bsSecPerClust]
sub bh, bh
dec bx ; bl = spc - 1, 0FFh if 256 spc
sub bh, bh ; bx = spc - 1
inc bx ; bx = spc
xchg cx, ax ; AX:CX == cluster - 2
mul bx ; first handle high word
; DX must be 0 here
@ -300,6 +316,7 @@ c3:
adc dx, [data_start + 2]
ret
%if 0
; prints text after call to this function.
print_1char:
@ -312,7 +329,8 @@ print1: lodsb ; get token
cmp al, 0 ; end of string?
jne print_1char ; until done
ret ; and jump to it
%endif
;input:
; DX:AX - 32-bit DOS sector number
; ES:BX - destination buffer
@ -381,12 +399,15 @@ read_ok:
mov es, cx
no_incr_es:
add ax,byte 1
adc dx,byte 0
inc ax
jnz .no_carry
inc dx
.no_carry:
ret
times 0x01f1-$+$$ db 0
magicoffset "kernel name", 1F1h
filename db "KERNEL SYS",0,0
sign dw 0xAA55

View File

@ -27,27 +27,36 @@
; Memory layout for the FreeDOS FAT32 single stage boot process:
;
; ...
; |-------| 1FE0:7E00
; |BOOTSEC|
; |RELOC. |
; |-------| 1FE0:7C00
; |-------| 1FE0h:7E00h = 27C00h (159 KiB)
; |BOOTSEC| loader relocates itself here first thing,
; |RELOC. | before loading root directory/FAT/kernel file
; |-------| 1FE0h:7C00h = 27A00h (158 KiB)
; | STACK | below relocated loader, above FAT sector (size 22 KiB)
; ...
; |-------| 2000:0200
; | FAT | (only 1 sector buffered)
; |-------| 2000:0000
; |-------| 2200h:2000h = 24000h (144 KiB)
; | FAT | (only 1 sector buffered, maximum sector size 8 KiB)
; |-------| 2200h:0000h = 22000h (136 KiB)
; ...
; |-------| 0000:7E00
; |-------| 0000h:7E00h = 07E00h (31.5 KiB)
; |BOOTSEC| overwritten by the kernel, so the
; |ORIGIN | bootsector relocates itself up...
; |-------| 0000:7C00
; |-------| 0000h:7C00h = 07C00h (31 KiB)
; ...
; |-------|
; |KERNEL | maximum size 134k (overwrites bootsec origin)
; |LOADED | (holds 1 sector directory buffer before kernel load)
; |-------| 0060:0000
; |KERNEL | maximum size 128 KiB (overwrites bootsec origin)
; |LOADED | (holds 1 sector directory buffer before kernel file load)
; |-------| 0060h:0000h = 00600h (1.5 KiB)
; ...
; The kernel load segment may be patched using the SYS /L switch.
; We support values between 0x60 and 0x200 here, with file size
; of up to 128 KiB (rounded to cluster size). Default is 0x60.
; NOTE: sys must be updated if magic offsets change
%assign ISFAT1216DUAL 0
%include "magic.mac"
segment .text
@ -85,7 +94,7 @@ Entry: jmp short real_start
%define LOADSEG 0x0060
%define FATSEG 0x2000
%define FATSEG 0x2200
%define fat_secshift fat_afterss-1 ; each fat sector describes 2^??
; clusters (db) (selfmodifying)
@ -96,7 +105,11 @@ Entry: jmp short real_start
%define data_start bp+0x4c ; first data sector (dd)
; (overwriting unused bytes)
times 0x5a-$+$$ db 0
times 52h - ($ - $$) db 0
; The filesystem ID is used by lDOS's instsect (by ecm)
; by default to validate that the filesystem matches.
db "FAT32"
times 5Ah - ($ - $$) db 32
; not used: [0x42] = byte 0x29 (ext boot param flag)
; [0x43] = dword serial
; [0x47] = label (padded with 00, 11 bytes)
@ -121,7 +134,9 @@ real_start: cld
rep movsw ; move boot code to the 0x1FE0:0x0000
jmp word 0x1FE0:cont
loadseg_off dw 0, LOADSEG
loadseg_off dw 0
magicoffset "loadseg", 78h
dw LOADSEG
; -------------
@ -129,10 +144,15 @@ cont: mov ds, ax
mov ss, ax ; stack and BP-relative moves up, too
lea sp, [bp-0x20]
sti
magicoffset "set unit", 82h
mov [drive], dl ; BIOS passes drive number in DL
%ifndef QUIET
mov si, msg_LoadFreeDOS
call print ; modifies AX BX SI
%else ; ensure code after this still at same location
times 6 nop
%endif
; -------------
@ -234,7 +254,9 @@ rk_walk_fat: pop eax
;-----------------------------------------------------------------------
boot_success: mov bl, [drive]
boot_success:
mov dl, [drive] ; for Enhanced DR-DOS load
mov bl, dl ; for FreeDOS load
jmp far [loadsegoff_60]
;-----------------------------------------------------------------------
@ -309,6 +331,8 @@ convert_cluster:
dec eax
movzx edx, byte [bsSecPerClust]
dec dl ; spc - 1
inc dx ; spc
push edx
mul edx
pop edx
@ -397,6 +421,7 @@ msg_BootError db "No "
; currently, only "kernel.sys not found" gives a message,
; but read errors in data or root or fat sectors do not.
magicoffset "kernel name", 1F1h
filename db "KERNEL SYS"
sign dw 0, 0xAA55

76
boot/magic.mac Normal file
View File

@ -0,0 +1,76 @@
; Public Domain 2024 by E. C. Masloch
%macro _appenddigitstrdef 2.nolist
%substr %%ii "0123456789ABCDEF" (%2) + 1
%strcat _%1 _%1,%%ii
%endmacro
; %1 = name of single-line macro to set. will be prefixed by underscore
; %2 = number to write
; %3 = minimal number of hexits, 0..8. defaults to 1
; (setting it to 0 with a number of 0 defines macro to "")
%macro _autohexitsstrdef 2-3.nolist 1
%if %3 > 8
%error Minimal number of hexits 9 or more: %3
%endif
%define _%1 ""
%if (%2) >= 1_0000_0000h
%error Number has to use 9 or more hexits: %2
%endif
%if (%2) >= 1000_0000h || %3 >= 8
_appenddigitstrdef %1, (%2 >> (7 * 4)) & 0Fh
%endif
%if (%2) >= 100_0000h || %3 >= 7
_appenddigitstrdef %1, (%2 >> (6 * 4)) & 0Fh
%endif
%if (%2) >= 10_0000h || %3 >= 6
_appenddigitstrdef %1, (%2 >> (5 * 4)) & 0Fh
%endif
%if (%2) >= 1_0000h || %3 >= 5
_appenddigitstrdef %1, (%2 >> (4 * 4)) & 0Fh
%endif
%if (%2) >= 1000h || %3 >= 4
_appenddigitstrdef %1, (%2 >> (3 * 4)) & 0Fh
%endif
%if (%2) >= 100h || %3 >= 3
_appenddigitstrdef %1, (%2 >> (2 * 4)) & 0Fh
%endif
%if (%2) >= 10h || %3 >= 2
_appenddigitstrdef %1, (%2 >> (1 * 4)) & 0Fh
%endif
%if (%2) >= 1h || %3 >= 1
_appenddigitstrdef %1, (%2 >> (0 * 4)) & 0Fh
%endif
%endmacro
%macro magicoffset 2-4.nolist ,0
%if ISFAT1216DUAL
%ifdef ISFAT12
%define SYSOFFSET %2
%elifdef ISFAT16
%define SYSOFFSET %3
%else
%define SYSOFFSET 0
; Just a placeholder, so the proper error message
; will be shown when assembling without either
; of the ISFATx defines.
%endif
%else
%define SYSOFFSET %2
%ifnempty %3
%error Not in dual mode
%endif
%endif
%assign NEWOFFSET $ + %4 - Entry
%if NEWOFFSET != SYSOFFSET
_autohexitsstrdef NEWOFFSETHEX, NEWOFFSET
%strcat _NEWOFFSETHEX _NEWOFFSETHEX,'h'
%deftok NEWOFFSET _NEWOFFSETHEX
%if ISFAT1216DUAL
%error Magic offset %1 changed for FATFS, old=SYSOFFSET, new=NEWOFFSET
%else
%error Magic offset %1 changed, old=SYSOFFSET, new=NEWOFFSET
%endif
%endif
%endmacro

View File

@ -7,23 +7,23 @@
production: fat12com.bin fat16com.bin fat32chs.bin fat32lba.bin oemfat12.bin oemfat16.bin
fat12com.bin: boot.asm
$(NASM) -dISFAT12 boot.asm -l$*.lst -ofat12com.bin
fat12com.bin: boot.asm magic.mac
$(NASM) -dISFAT12 $(NASMBOOTFLAGS) boot.asm -lfat12com.lst -ofat12com.bin
fat16com.bin: boot.asm
$(NASM) -dISFAT16 boot.asm -l$*.lst -ofat16com.bin
fat16com.bin: boot.asm magic.mac
$(NASM) -dISFAT16 $(NASMBOOTFLAGS) boot.asm -lfat16com.lst -ofat16com.bin
fat32chs.bin: boot32.asm
$(NASM) boot32.asm -l$*.lst -ofat32chs.bin
fat32chs.bin: boot32.asm magic.mac
$(NASM) $(NASMBOOTFLAGS) boot32.asm -lfat32chs.lst -ofat32chs.bin
fat32lba.bin: boot32lb.asm
$(NASM) boot32lb.asm -l$*.lst -ofat32lba.bin
fat32lba.bin: boot32lb.asm magic.mac
$(NASM) $(NASMBOOTFLAGS) boot32lb.asm -lfat32lba.lst -ofat32lba.bin
oemfat12.bin: oemboot.asm
$(NASM) -dISFAT12 oemboot.asm -l$*.lst -ooemfat12.bin
oemfat12.bin: oemboot.asm magic.mac
$(NASM) -dISFAT12 $(NASMBOOTFLAGS) oemboot.asm -loemfat12.lst -ooemfat12.bin
oemfat16.bin: oemboot.asm
$(NASM) -dISFAT16 oemboot.asm -l$*.lst -ooemfat16.bin
oemfat16.bin: oemboot.asm magic.mac
$(NASM) -dISFAT16 $(NASMBOOTFLAGS) oemboot.asm -loemfat16.lst -ooemfat16.bin
clobber: clean
-$(RM) *.bin status.me

View File

@ -116,6 +116,11 @@
; |IVT | Interrupt Vector Table
; +--------+ 0000:0000
; NOTE: sys must be updated if magic offsets change
%assign ISFAT1216DUAL 1
%include "magic.mac"
CPU 8086 ; enable assembler warnings to limit instruction set
;%define ISFAT12 1 ; only 1 of these should be set,
@ -143,7 +148,7 @@ segment .text
%define FATBUF bp-0x7500 ; offset of temporary buffer for FAT
; chain 0:FATBUF = 0:0700 = LOADSEG:0
%define ROOTDIR bp-0x7700 ; offset to buffer for root directory
%define ROOTDIR 0x7C00-0x7700 ; offset to buffer for root directory
; entry of kernel 0:ROOTDIR
%define CLUSTLIST bp+0x0300 ; zero terminated list of clusters
; that the kernel occupies
@ -223,7 +228,22 @@ Entry: jmp short real_start
db 0x29 ; extended boot record id
dd 0x12345678 ; volume serial number
db 'NO NAME '; volume label
db 'FAT12 ' ; filesystem id
times 36h - ($ - $$) db 0
; The filesystem ID is used by lDOS's instsect (by ecm)
; by default to validate that the filesystem matches.
%ifdef ISFAT12
%define FATFS "FAT12"
%ifdef ISFAT16
%error Must select one FS
%endif
%elifdef ISFAT16
%define FATFS "FAT16"
%else
%define FATFS "unknown"
%error Must select one FS
%endif
db FATFS ; filesystem id
times 3Eh - ($ - $$) db 32
;-----------------------------------------------------------------------
; ENTRY
@ -269,6 +289,7 @@ real_start:
; in DL, however we work around this in SYS.COM by NOP'ing out the use of DL
; (formerly we checked for [drive]==0xff; update sys.c if code moves)
;
magicoffset "set unit", 4Fh, 4Fh
mov [drive], dl ; rely on BIOS drive number in DL
@ -319,11 +340,11 @@ real_start:
pop di ; mov di, word [RootDirSecs]
pop ax ; mov ax, word [root_dir_start]
pop dx ; mov dx, word [root_dir_start+2]
lea bx, [ROOTDIR] ; es:bx = 0:0500
mov bx, ROOTDIR ; es:bx = 0:0500
push es ; save pointer to ROOTDIR
call readDisk
pop es ; restore pointer to ROOTDIR
lea si, [ROOTDIR] ; ds:si = 0:0500
mov si, ROOTDIR ; ds:si = 0:0500
; Search for kernel file name, and find start cluster.
@ -340,6 +361,7 @@ next_entry: mov cx, 11
jc boot_error ; fail if not found and si wraps
cmp byte [si], 0 ; if the first byte of the name is 0,
jnz next_entry ; there are no more files in the directory
jmp boot_error
ffDone:
mov [first_cluster], ax ; store first cluster number
@ -347,7 +369,7 @@ ffDone:
%ifdef SETROOTDIR
; copy over this portion of root dir to 0x0:500 for PC-DOS
; (this may allow IBMBIO.COM to start in any directory entry)
lea di, [ROOTDIR] ; es:di = 0:0500
mov di, ROOTDIR ; es:di = 0:0500
mov cx, 32 ; limit to this 1 entry (rest don't matter)
rep movsw
%endif
@ -399,11 +421,12 @@ fat_12: add si, si ; multiply cluster number by 3...
; 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
mov cl, 4 ; always initialise shift counter
jc fat_odd ; is odd, only shift down -->
shl ax, cl ; shift up (effectively masks off
; the highest 4 bits)
fat_odd:
shr ax, cl
fat_even: and ah, 0x0f ; mask off the highest 4 bits
cmp ax, 0x0ff8 ; check for EOF
jb next_clust ; continue if not EOF
@ -455,13 +478,14 @@ cluster_next: lodsw ; AX = next cluster to read
%else
jmp LOADSEG:0000 ; yes, pass control to kernel
%endif
magicoffset "load jump ofs", 11Ah, 118h, -4
; failed to boot
boot_error:
call show
; db "Error! Hit a key to reboot."
db "):."
; db "Error! Hit a key to reboot.",0
db "):",0
%ifdef LOOPONERR
jmp $
%else
@ -478,7 +502,9 @@ load_next: dec ax ; cluster numbers start with 2
dec ax
mov di, word [bsSecPerClust]
and di, 0xff ; DI = sectors per cluster
dec di ; minus one if 256 spc
and di, 0xff ; DI = sectors per cluster - 1
inc di ; = spc
mul di
add ax, [data_start]
adc dx, [data_start+2] ; DX:AX = first sector to read
@ -488,13 +514,14 @@ load_next: dec ax ; cluster numbers start with 2
; shows text after the call to this function.
show.do_show:
mov ah, 0Eh ; show character
int 10h ; via "TTY" mode
show: pop si
lodsb ; get character
push si ; stack up potential return address
mov ah,0x0E ; show character
int 0x10 ; via "TTY" mode
cmp al,'.' ; end of string?
jne show ; until done
cmp al, 0 ; end of string?
jne .do_show ; until done
ret
@ -516,7 +543,7 @@ readDisk: push si ; preserve cluster #
mov word [LBA_OFF], bx
call show
db "."
db ".",0
read_next:
; initialize constants
@ -637,6 +664,8 @@ read_skip:
ret
times 0x01f1-$+$$ db 0
magicoffset "kernel name", 1F1h, 1F1h
%ifdef MSCOMPAT
filename db "IO SYS"
%else

View File

@ -6,8 +6,10 @@ if NOT "%1" == "/?" goto start
echo ":-----------------------------------------------------------------------"
echo ":- Syntax: BUILD [-r] [fat32|fat16] [msc|wc|tc|tcpp|bc] [86|186|386] "
echo ":- [debug] [lfnapi] [/L #] [/D value] [list] [upx] [win] "
echo ":- [com] [com# #] "
echo ":- option case is significant !! "
echo ":- Note: Open Watcom (wc) is the preferred compiler "
echo ":- com does debug output on COM2, whereas com# 0 for COM1 ... "
echo ":-----------------------------------------------------------------------"
goto end
@ -25,7 +27,6 @@ if not exist config.bat goto abort
call config.bat
:-if "%LAST%" == "" goto noenv
set dos4g=quiet
:-----------------------------------------------------------------------
:- following is command line handling
@ -51,11 +52,20 @@ if "%1" == "x86" goto setCPU
if "%1" == "upx" set XUPX=upx --8086 --best
if "%1" == "debug" set ALLCFLAGS=%ALLCFLAGS% -DDEBUG
if "%1" == "lfn" set ALLCFLAGS=%ALLCFLAGS% -DWITHLFNAPI
if "%1" == "lfnapi" set ALLCFLAGS=%ALLCFLAGS% -DWITHLFNAPI
if "%1" == "win" set ALLCFLAGS=%ALLCFLAGS% -DWIN31SUPPORT
if "%1" == "win" set NASMFLAGS=%NASMFLAGS% -DWIN31SUPPORT
if "%1" == "com" set ALLCFLAGS=%ALLCFLAGS% -DDEBUG_PRINT_COMPORT
if "%1" == "com" set NASMFLAGS=%ALLCFLAGS% -DDEBUG_PRINT_COMPORT
REM specify comport, default is COM2, 0=COM1, 1=COM2, 2=COM3
if "%1" == "com#" set ALLCFLAGS=%ALLCFLAGS% -DDEBUG_PRINT_COMPORT %2
if "%1" == "com#" set NASMFLAGS=%ALLCFLAGS% -DDEBUG_PRINT_COMPORT %2
if "%1" == "com#" shift
if "%1" == "com#" goto nextOption
if "%1" == "list" set NASMFLAGS=%NASMFLAGS% -l$*.lst
if "%1" == "/L" goto setLoadSeg
@ -117,6 +127,20 @@ cd ..\kernel
%MAKE% production
if errorlevel 1 goto abort-cd
echo.
echo Process COUNTRY +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo.
cd ..\country
%MAKE% DIRSEP=\ CP=copy production
if errorlevel 1 goto abort-cd
echo.
echo Process SETVER +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo.
cd ..\setver
%MAKE% production
if errorlevel 1 goto abort-cd
cd ..
set XERROR=
@ -155,6 +179,8 @@ if "%1" == "" goto abort
if "%2" == "/V" goto :setDefineWithValue
set ALLCFLAGS=%ALLCFLAGS% -D%1
set NASMFLAGS=%NASMFLAGS% -D%1
REM $(NASMBOOTFLAGS) are extra flags only used when building boot sectors
set NASMBOOTFLAGS=%NASMBOOTFLAGS% -d%1
goto nextOption
:setDefineWithValue

View File

@ -15,7 +15,6 @@ set onerror=if not "%XERROR%" == "" goto daswarwohlnix
:***** MSCL kernels
call config.bat
set dos4g=quiet
if "%MS_BASE%" == "" goto no_ms
call build -r msc 386 fat16
@ -47,7 +46,7 @@ call build -r tc 86 fat32
:***** (Open) Watcom kernels
if "%WATCOM%" == "" goto no_wc
if not "%COMPILER%" == "WATCOM" goto no_wc
call build -r wc 386 fat32
%ONERROR%
call build -r wc 386 fat16

107
ci_build.sh Executable file
View File

@ -0,0 +1,107 @@
#!/bin/sh
set -e
if [ -z "${BUILD_DIR}" ] ; then
BUILD_DIR=$(pwd)
fi
echo BUILD_DIR is \"${BUILD_DIR}\"
# Output directory
rm -rf _output
mkdir _output
# GCC
mkdir _output/gcc
git clean -x -d -f -e test -e _output -e _downloads -e _watcom
make -C country clean
make all COMPILER=gcc
mv -n bin/KGC*.map bin/KGC*.sys _output/gcc/.
mv -n bin/country.sys _output/gcc/.
# GCC share
(
cd share
git submodule update --init --recursive
git clean -x -d -f
env COMPILER=gcc ./build.sh
)
mv -n share/src/share.com _output/gcc/.
mv -n share/src/share.map _output/gcc/.
# Open Watcom Environment Setup
export WATCOM=$BUILD_DIR/_watcom
export PATH=$BUILD_DIR/bin:$PATH:$WATCOM/binl64
mkdir _output/wc
git clean -x -d -f -e test -e _output -e _downloads -e _watcom
make -C country clean
make all COMPILER=owlinux
mv -n bin/KWC*.map bin/KWC*.sys _output/wc/.
mv -n bin/country.sys _output/wc/.
## DOS (GCC)
#mkdir _output/gcc_dos
#git clean -x -d -f -e test -e _output -e _downloads -e _watcom
#{
# echo set COMPILER=GCC
# echo set MAKE=make
# echo set XCPU=386
# echo set XFAT=32
# echo set XNASM='C:\\devel\\nasm\\nasm'
# echo set OLDPATH=%PATH%
# echo set PATH='C:\\devel\\i16gnu\\bin;C:\\bin;%OLDPATH%'
#} | unix2dos > config.bat
#dosemu -td -q -K . -E "build.bat"
# DOS (Watcom)
mkdir _output/wc_dos
git clean -x -d -f -e test -e _output -e _downloads -e _watcom
{
echo set COMPILER=WATCOM
echo set WATCOM='C:\\devel\\watcomc'
echo set MAKE=wmake /ms
echo set XCPU=386
echo set XFAT=32
echo set XNASM='C:\\devel\\nasm\\nasm'
echo set XUPX=upx --8086 --best
echo set OLDPATH=%PATH%
echo set PATH='%WATCOM%\\binw;C:\\bin;%OLDPATH%'
echo set DOS4G=QUIET
} | unix2dos > config.bat
dosemu -td -q -K . -E "build.bat"
mv -n bin/KWC*.map bin/KWC*.sys _output/wc_dos/.
mv -n bin/country.sys _output/wc_dos/.
# DOS (Turbo C 2.01)
if [ -d ${HOME}/.dosemu/drive_c/tc201 ] ; then
mkdir _output/tc_dos
git clean -x -d -f -e test -e _output -e _downloads -e _watcom
{
echo set COMPILER=TC2
echo set TC2_BASE='C:\\tc201'
echo set MAKE=make
echo set XCPU=386
echo set XFAT=32
echo set XNASM=nasm
echo set OLDPATH=%PATH%
echo set PATH='%TC2_BASE%;C:\\devel\\nasm;C:\\bin;%OLDPATH%'
} | unix2dos > config.bat
dosemu -td -q -K . -E "build.bat lfn"
mv -n bin/KTC*.map bin/KTC*.sys _output/tc_dos/.
mv -n bin/country.sys _output/tc_dos/.
# TC share
(
cd share
git submodule update --init --recursive
git clean -x -d -f
env COMPILER=tcc2-emu ./build.sh
)
mv -n share/src/share.com _output/tc_dos/.
mv -n share/src/share.map _output/tc_dos/.
fi
echo done

87
ci_prereq.sh Executable file
View File

@ -0,0 +1,87 @@
#!/bin/sh
set -e
sudo add-apt-repository -y ppa:tkchia/build-ia16
sudo add-apt-repository -y ppa:dosemu2/ppa
sudo apt update
# for cross building
sudo apt install gcc-ia16-elf libi86-ia16-elf nasm upx qemu-system-x86 mtools util-linux bash
# for building with DOS using an emulator
sudo apt install dosemu2 dos2unix
# Perhaps later we should build using Freecom from published package
mkdir -p _downloads
mkdir -p _watcom
cd _downloads
HERE=$(pwd)
# download and unpack Open Watcom snapshot
[ -f ow-snapshot.tar.xz ] || wget --no-verbose https://github.com/open-watcom/open-watcom-v2/releases/download/Current-build/ow-snapshot.tar.xz
tar -C ../_watcom -xf ow-snapshot.tar.xz
#IBIBLIO_PATH='http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos'
IBIBLIO_PATH='https://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/repositories/1.3'
BASE=${IBIBLIO_PATH}/base
# get FreeDOS kernel
[ -f kernel.zip ] || wget --no-verbose ${BASE}/kernel.zip
# get FreeCOM
[ -f freecom.zip ] || wget --no-verbose ${BASE}/freecom.zip
DEVEL=${IBIBLIO_PATH}/devel
# get gnumake for DOS
[ -f djgpp_mk.zip ] || wget --no-verbose ${DEVEL}/djgpp_mk.zip
# get nasm for DOS
[ -f nasm.zip ] || wget --no-verbose ${DEVEL}/nasm.zip
# get upx for DOS
[ -f upx.zip ] || wget --no-verbose ${DEVEL}/upx.zip
# grab ia16-gcc from ibiblio.org
#[ -f i16gcc.zip ] || wget --no-verbose ${DEVEL}/i16gcc.zip
#[ -f i16newli.zip ] || wget --no-verbose ${DEVEL}/i16newli.zip
#[ -f i16butil.zip ] || wget --no-verbose ${DEVEL}/i16butil.zip
#[ -f i16lbi86.zip ] || wget --no-verbose ${DEVEL}/i16lbi86.zip
# get watcom for DOS
[ -f watcomc.zip ] || wget --no-verbose ${DEVEL}/watcomc.zip
mkdir -p ${HOME}/.dosemu/drive_c
cd ${HOME}/.dosemu/drive_c && (
mkdir -p bin
# Boot files
unzip -L -q ${HERE}/kernel.zip
cp -p bin/kernl386.sys ./kernel.sys
unzip -L -q ${HERE}/freecom.zip
cp -p bin/command.com ./command.com
cp -p /usr/share/dosemu/dosemu2-cmds-0.3/c/fdconfig.sys .
# Development files
unzip -L -q ${HERE}/djgpp_mk.zip
cp -p devel/djgpp/bin/make.exe bin/.
unzip -L -q ${HERE}/upx.zip
cp -p devel/upx/upx.exe bin/.
echo PATH to make and upx binaries is 'c:/bin'
unzip -L -q ${HERE}/nasm.zip
echo PATH to nasm binary is 'c:/devel/nasm'
# unzip -L -q ${HERE}/i16gcc.zip
# unzip -L -q ${HERE}/i16newli.zip
# unzip -L -q ${HERE}/i16butil.zip
# unzip -L -q ${HERE}/i16lbi86.zip
# echo PATH to ia16 binaries is 'c:/devel/i16gnu/bin'
unzip -L -q ${HERE}/watcomc.zip
echo PATH to watcom binaries is 'c:/devel/watcomc/binw'
)

52
ci_test.sh Executable file
View File

@ -0,0 +1,52 @@
#! /bin/bash
KVER=8632
if [ ! -f _output/gcc/KGC${KVER}.sys ] ; then
echo GCC built kernel not present
exit 1
fi
if [ ! -f _output/wc/KWC${KVER}.sys ] ; then
echo Watcom built kernel not present
exit 1
fi
if [ ! -f _output/wc_dos/KWC38632.sys ] ; then
echo Watcom DOS built kernel not present
exit 1
fi
if [ ! -f _output/tc_dos/KTC38632.sys ] && [ -d ${HOME}/.dosemu/drive_c/tc201 ] ; then
echo Turbo C 2.01 built kernel not present
exit 1
fi
echo Kernels have all been built
find _output -ls
cd test
if ! ./test.sh ../_output/gcc/KGC${KVER}.sys diskgc bootgc 'boot gcc: '
then
echo GCC boot test failed
exit 2
fi
if ! ./test.sh ../_output/wc/KWC${KVER}.sys diskwc bootwc 'boot wc: '
then
echo OpenWatcom boot test failed
exit 2
fi
if ! ./test.sh ../_output/wc_dos/KWC38632.sys diskwcd bootwcd 'boot wcd: '
then
echo 'OpenWatcom(DOS) boot test failed'
exit 2
fi
if [ -d ${HOME}/.dosemu/drive_c/tc201 ] ; then
if ! ./test.sh ../_output/tc_dos/KTC38632.sys disktcd boottcd 'boot tcd: '
then
echo 'Turbo C 2.01 boot test failed'
exit 2
fi
fi
cd ..
exit 0

View File

@ -27,6 +27,9 @@ cd ..\sys
cd ..\kernel
%MAKE% clean
cd ..\setver
%MAKE% clean
cd ..\hdr
if exist *.bak del *.bak

View File

@ -27,12 +27,20 @@ cd ..\sys
cd ..\kernel
%MAKE% clobber
cd ..\setver
%MAKE% clobber
cd ..\hdr
if exist *.bak del *.bak
cd ..\bin
if exist sys.com del sys.com
if exist country.sys del country.sys
cd ..
if exist *.bak del *.bak
if exist status.me del status.me
:end
default.bat clearset

View File

@ -19,35 +19,41 @@
:-**********************************************************************
:-- define NASM executable - remember - it should not be protected
:- mode DJGPP version if you're using Windows NT/2k/XP to compile
:- also: DJGPP-nasm crashes when using protected mode Borland's make
:- because DJGPP-nasm crashes when using protected mode Borland's
:- make under Windows NT/2k/XP
:-**********************************************************************
set XNASM=c:\bin\nasm16
set XNASM=nasm
:**********************************************************************
:- define your COMPILER type here, pick one of them
:**********************************************************************
:- Turbo C 2.01
set COMPILER=TC2
:- set COMPILER=TC2
:- Turbo C++ 1.01
:- set COMPILER=TURBOCPP
:- Turbo C 3.0
:- set COMPILER=TC3
:- Borland C 3.1
set COMPILER=BC3
:- Borland C
:- set COMPILER=BC5
:- Microsoft C
:- set COMPILER=MSCL8
:- Watcom C
:- Watcom C (for DOS)
:- set COMPILER=WATCOM
:- Watcom C (for Windows)
:- set COMPILER=OWWIN
:-**********************************************************************
:-- where is the BASE dir of your compiler(s) ??
:-**********************************************************************
set TC2_BASE=c:\tc201
:- set TC2_BASE=c:\tc201
:- set TP1_BASE=c:\tcpp
:- set TC3_BASE=c:\tc3
set BC3_BASE=c:\bc
:- set BC5_BASE=c:\bc5
:- set MS_BASE=c:\msvc
@ -56,6 +62,7 @@ set TC2_BASE=c:\tc201
:- if not \%WATCOM% == \ goto watcom_defined
:- set WATCOM=c:\watcom
:- set PATH=%PATH%;%WATCOM%\binw
:- set DOS4G=QUIET
:watcom_defined
:-**********************************************************************
@ -101,12 +108,12 @@ set XUPX=upx --8086 --best
:* select your default target: required CPU and what FAT system to support
:**********************************************************************
set XCPU=86
:- set XCPU=86
:- set XCPU=186
:- set XCPU=386
set XCPU=386
set XFAT=16
:- set XFAT=32
:- set XFAT=16
set XFAT=32
:- Give extra compiler DEFINE flags here
:- such as -DDEBUG : extra DEBUG output

View File

@ -15,8 +15,8 @@ XNASM=nasm
#**********************************************************************
#- where is the BASE dir of your compiler(s) ??
#**********************************************************************
# if WATCOM maybe you need to set your WATCOM environment variables
# if WATCOM maybe you need to set your WATCOM environment variables
# and path
ifndef WATCOM
WATCOM=$(HOME)/watcom
@ -28,7 +28,7 @@ endif
#**********************************************************************
XUPX=upx --8086 --best
# or use
# or use
#unexport XUPX
# without the # if you don't want to use it
@ -52,12 +52,12 @@ XUPX=upx --8086 --best
# select your default target: required CPU and what FAT system to support
#*********************************************************************
XCPU=86
# XCPU=86
# XCPU=186
# XCPU=386
XCPU=386
XFAT=16
# XFAT=32
# XFAT=16
XFAT=32
# Give extra compiler DEFINE flags here
# such as -DDEBUG : extra DEBUG output

1
country Submodule

@ -0,0 +1 @@
Subproject commit 13587a32d6fda6cf1a1ce9bd9c3da7d3ae5a8dd5

View File

@ -23,8 +23,10 @@ if not "%MAKE%" == "" goto skip_make
if "%COMPILER%" == "TC2" set MAKE=%TC2_BASE%\make
if "%COMPILER%" == "TURBOCPP" set MAKE=%TP1_BASE%\bin\make
if "%COMPILER%" == "TC3" set MAKE=%TC3_BASE%\bin\make
if "%COMPILER%" == "BC3" set MAKE=%BC3_BASE%\bin\make
if "%COMPILER%" == "BC5" set MAKE=%BC5_BASE%\bin\make
if "%COMPILER%" == "WATCOM" set MAKE=wmake /ms /h
if "%COMPILER%" == "OWWIN" set MAKE=wmake /ms /h
if "%COMPILER%" == "MSCL8" set MAKE=%MS_BASE%\bin\nmake /nologo
echo Make is %MAKE%.
@ -38,8 +40,10 @@ if not "%XLINK%" == "" goto skip_xlink
if "%COMPILER%" == "TC2" set XLINK=%TC2_BASE%\tlink /m/c
if "%COMPILER%" == "TURBOCPP" set XLINK=%TP1_BASE%\bin\tlink /m/c
if "%COMPILER%" == "TC3" set XLINK=%TC3_BASE%\bin\tlink /m/c
if "%COMPILER%" == "BC3" set XLINK=%BC3_BASE%\bin\tlink /m/c
if "%COMPILER%" == "BC5" set XLINK=%BC5_BASE%\bin\tlink /m/c
if "%COMPILER%" == "WATCOM" set XLINK=..\utils\wlinker /ma/nologo
if "%COMPILER%" == "OWWIN" set XLINK=..\utils\wlinker /ma/nologo
if "%COMPILER%" == "MSCL8" set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo
echo Linker is %XLINK%.
@ -71,10 +75,12 @@ set XLINK=
set TC2_BASE=
set TP1_BASE=
set TC3_BASE=
set BC3_BASE=
set BC5_BASE=
set MS_BASE=
set XNASM=
set NASMFLAGS=
set NASMBOOTFLAGS=
set XUPX=
set UPXOPT=
set LOADSEG=

1
docs/CNAME Normal file
View File

@ -0,0 +1 @@
kernel.fdos.org

4
docs/_config.yml Normal file
View File

@ -0,0 +1,4 @@
theme: jekyll-theme-tactile
title: "FreeDOS kernel"
description: "Implementation of the core DOS API for FreeDOS, kernel.sys"
show_downloads: "true"

View File

@ -1,8 +1,15 @@
The current bug database is available on the web at
Please report kernel bugs / issues on GitHub at
https://github.com/FDOS/kernel/issues
For support (or if you don't wish to use GitHub) then
please use the FreeDOS developer and/or user mailing list.
The former bug database is available on the web at
http://sourceforge.net/tracker/?group_id=5109&atid=105109
Please request an account if you want to report or
update bugs. Reading the database needs no login.
(All bugs reported there are reviewed, but not updated!)
Thanks!

View File

@ -15,6 +15,11 @@ kernel come out, you can extract them over your previous source, and
not have to worry about resetting up your configuration because your
CONFIG.BAT file will not get replaced!
For example to build your custom branded kernel for 386+ with FAT32
support using OpenWatcom compilers use a command such as:
BUILD.BAT 386 ow fat32 upx /D CUSTOM_BRANDING /V "MyDOS"
Building on Linux:
==================
@ -33,6 +38,16 @@ make clean
- to clobber (delete everything that was generated):
make clobber
You can now also cross compile with T.K. Chia's fork of ia16-elf-gcc,
which is available at https://github.com/tkchia/gcc-ia16, using
make all COMPILER=gcc
or by setting COMPILER=gcc in config.mak. If you are using Ubuntu
Linux 20.04 LTS (Focal Fossa), 18.04 (Bionic Beaver), or 16.04 LTS
(Xenial Xerus), there are precompiled ia16-elf-gcc packages at
https://launchpad.net/~tkchia/+archive/ubuntu/build-ia16/.
Otherwise, for now ia16-elf-gcc needs to be compiled from source.
Only releases 20180708 and later are supported.
Notes:
======
The recommended compiler and assembler at the time of writing (2009/05/19)

View File

@ -1,13 +1,15 @@
Begin3
Title: The FreeDOS Kernel
Version: SVN
Version: git
Entered-date: N/A
Description: The FreeDOS Kernel
Keywords: kernel, FreeDOS, DOS, MSDOS
Author: (developers: can be reached on the freedos-kernel mailing list)
Maintained-by: freedos-kernel@lists.sourceforge.net
Primary-site: http://freedos.sourceforge.net/kernel/
Primary-site: http://github.com/fdos/kernel
Alternate-site: http://www.fdos.org/kernel/
Alternate-site: http://freedos.sourceforge.net/kernel/
Original-site: http://www.gcfl.net/pub/FreeDOS/kernel
Platforms: DOS, FreeDOS, DOSEMU (OpenWatcom C or Turbo C, NASM, optionally UPX)
Platforms: DOS, FreeDOS, DOSEMU (OpenWatcom/Borland/GCC-ia16, NASM, UPX)
Copying-policy: GPL2
End

View File

@ -10,6 +10,116 @@ http://freedos.svn.sf.net/viewvc/freedos?view=rev&sortby=rev&revision=NUMBER
Changelog items can list SVN revision rNUMBER and bugzilla bug NUMBER.
2025 ?? - Build 2045
-------- Jeremy Davis
+ Changes Jeremy Davis and Tom Ehlert
* initial GPT partition support
2025 ?? - Build 2044
-------- Jeremy Davis
+ Changes Jeremy Davis, Andrew Bird, Tee-Kiah Chia (tkchia), Sava (lpproj),
Stas Sergeev (stsp), C. Masloch, Jiri Malak, Bernd Böckmann, Tom Ehlert
* fixes for building with various compilers / different environments
* boot sector improvements (improve compatibility/reduce boot problems)
* support determining kernel file version without booting it
* only print messages once, not each time processing partitions
* fix for Format GitHub issue #1 - format divide by 0 due to kernel function 440D, subfunction 60 returning a zero for logical_sectors_per_fat as initdisk overflows and calculates incorrect value
* From bzt, initialize drive parameter head & sector values to avoid potential divisions by 0
* config: allow to delete variable with empty SET command
* truename: fix array overrun (pick from fdpp)
* main: insure master environment starts out empty
* config: make sure word marker trailing in environment is zero
* inthndlr: align hma size to para
* DosGetExtFree: Use new redirector function 11a3
* sys: detect small FAT32 as FAT32 (zero in word SPF)
* boot: enable loading from file systems with 256 sectors per cluster
* fatfs.c: allow bpbSectorsPerCluster == 0 to mean 256
* FCB (int 21h func 29h): should not accept field separator as "drive letter"
* FCB (int 21h func 29h): should keep parsing name even if drive letter invalid
* exeflat: update usage screen with -E, -D, and -U switches
* upxentry, upxdevic: add header comments
* exeflat: improve compressed stub handling, fixes, update documentation, various other updates
* kernel: optimise A20 check and enable/disable calls
* improve/fix gcc and OpenWatcom build support
* task: return Invalid format on empty executable (fixes #70)
* fdkrncfg: bugfix, version info check should not include signature
* fix 2nd parameter of "DOS=" statement in config.sys does not take effect in some cases:
* dosfns, int2f: make SHARE uninstallable
* CI: improvements
* Fix incorrect date format for Czech and Slovak Republic. Both Countries use DD.MM.YYYY date format. Microsoft DOS also use this format.
* dosfns: Check share table before delete/rename
* various build updates and move share and country to submodules
* FCB: Rename should support asterisk wildcards - based on dosemu fdpp, fixes issue #43
* add tests for FCB rename - based on tests from andrewbird
* allow opening a character device prefixed with invalid drive letter (e.g. "@:NUL") but not with invalid path
* add test for opening character devices (all pass on DOS 5,6, NT VDM, @:dev fail currently on FD kernel)
* initial implementation of extended seek (0x7142 - LONG LSEEK with 64-bit file position)
* add implementation of int 0x2F function 0x1f build CDS from dosemu2/fdpp
* add skeleton for LFN API, includes 0x71a6 implementation (call to redirector only) from dosemu2/fdpp
* ensure offset to critical patch tables doesn't change
* From Tom Ehlert: don't split disk transfers crossing DMA boundary if BIOS indicates can handle transparently
* fcbfns: Fix for FcbFindFirstNext [fixes #40]
* task: don't zero parent_psp on 0x26
* boot, oemboot: fix to abort properly on file not found
* oemboot: optimise FAT12 entry loading (picked from lDOS boot)
* adjust padding to be same as in PC-DOS (90h/nop)
* from RBIL int 21h/4400h (table 01423) add definition for bit 11 if SFT is not for a device (for a file) - media not removable, currently unused
* from dosemu2/fdpp - zero out critical patch list Personal NetWare Server really writes to these addresses, so putting 0x0d0c the way DOS does, is not safe.
* int 21h/4400h only return low byte of SFT flags if not a device, part of dosemu2/fdpp bug #147 fix
* check for unsupported function call in console - from dosemu2/fdpp bug# 101 fix
* improve support for Windows 3 Enhanced mode
* From Tom Ehlert: properly error when attempting to write past 4GB
2021 May 13 - Build 2043
-------- Jeremy Davis
+ Changes Bart Oldeman, Jeremy Davis, Andrew Bird, Tee-Kiah Chia (tkchia), Sava (lpproj),
Stas Sergeev (stsp), C. Masloch, Jiri Malak, Piotr Durlej, Ricardo Hanke
* update for releases using git instead of svn
* Update README.md
* add support for building with ia16-elf-gcc, including multiple updates/fixes
* SYS: Reduce verbosity when the verbose flag is not set
* add safety check to FAT12/16 boot sector to warn about breaking sys if boot code updated
* Implement version table support for int21/ah=4b, subfunctions 0 and 1
* CI: Add Github Action to automatically build and minimal test kernel on commit
* FATFS: rmdir of read only directories is valid
* boot: allow instsect to match the filesystem ID string
* boot: fix Int10.0E expected not to alter al (SBC188)
* Fix Func 2Dh (Set System Time) sets wrong time
* Fix func 0Bh (Get STDIN Status) always returns AL=FFh with some alternative CON drivers:
* Fix Func 30h (Get DOS Version) return version 0.0 in config.sys
* int2f: fix call interface around syscall_MUX14( ) (inthndlr.c)
* int2f: fix call interface around int2F_12_handler( )
* int2f: Allow 1217h function to return new CDS entry
* from Mondgestein, Function 30h (Get DOS Version): Get DOS version from PSP
* Fix func 36h (Get free disk space) fails in some redirectors:
* dosfns.c: only copy to current_ldt if pointer is valid
* inthndlr.c: in Int21.43FF, dispatch DosMkRmdir on CL not AH
* EXEC (func 0x4b): fix: do not crash if exMinAlloc == 0xffff
* FCB: Rename return value lost
* Fix division for some large numbers such as 0xFFFF01FF/0x10101FF
* Fix comments (Gerd Grosse, https://sourceforge.net/p/freedos/bugs/106/)
* FCB: Rename return value lost
* Fix compilation with TC2 and MSVC 1.52c.
* disk: fix sectors count truncation for CHS [fixes #10]
* implement CHAIN directive for config.sys
* add some initial (minimal) tests
* Fix memory break in NUL device
* Fix initial DTA
* Implement Int 2F/AX=120Bh based on RBIL description
* Implement Int 2F/AX=120Ah based on RBIL description - untested!
* From Evelyn, CPU unsupported message missing loading error msg address (pop si)
* Copy FCB-format filename from PriPathName (some redirectors require FCB-format filename stored in SDA+22Bh DirEntBuffer)
* Fix an error at opening a character device prefixed with invalid drive letter (e.g. "@:NUL") (some application use it for opening character device driver)
* Fix incompletion on loading huge (more than 65280 bytes) binary device driver
* On creating child PSP (func 0x55), copy command line parameters from the parent (required for some device loaders)
* Improve support for older BPB based volumes lacking extended fields. (Based on lpproj's nec98:Fix for DOS 3.x partitions)
2016 May 16 - Build 2042
-------- Jeremy Davis, Sava

37
docs/index.md Normal file
View File

@ -0,0 +1,37 @@
INTRODUCTION
------------
The release archives contains the current FreeDOS Kernel, also
known as DOS-C, originally written by Pasquale J. Villani.
The FreeDOS Kernel is available from https://github.com/FDOS/kernel/
(formally http://freedos.sourceforge.net/ ).
It's also available from http://www.dosemu.org/ (somewhere on there).
The FreeDOS Kernel is also available through the FreeDOS Project at
http://www.freedos.org/
See the DOCS directory for more documentation and information about
the FreeDOS Kernel.
Contents of zip files:
* [ke20xx_f16.zip](https://github.com/FDOS/kernel/releases/download/ke2043/ke2043_86f16.zip) : binaries for 8086, FAT12 and FAT16 only
* [ke20xx_f32.zip](https://github.com/FDOS/kernel/releases/download/ke2043/ke2043_86f32.zip) : binaries for 8086, FAT12, FAT16, and FAT32
* [ke20xxs.zip](https://github.com/FDOS/kernel/releases/download/ke2043/ke2043s.zip) : sources for the kernel
BUG REPORTS
-----------
If you have found a bug, think you have found a bug, or would just
like to make a suggestion, go to the bug tracking web page at
https://github.com/FDOS/kernel/issues
(Previously at http://sourceforge.net/tracker/?group_id=5109&atid=105109, and
even earlier archive of old (Bugzilla) items is at www.freedos.org/bugzilla/ )
Copyright
---------
DOS-C is (c) Copyright 1995, 1996 by Pasquale J. Villani
All Rights Reserved.

View File

@ -1,64 +0,0 @@
Thanks to Bart Oldeman for helping us with moving the FreeDOS source code
from CVS to Subversion! The old CVS repository is still available for
browsing, but will no longer be used for managing FreeDOS Projects - and
will probably be deleted later. Please use Subversion for the FreeDOS
kernel, FreeCOM (FreeDOS command.com), Install, and Mem.
Bart has also written a Subversion at SourceForge Mini How-to:
http://fd-doc.sourceforge.net/wiki/index.php?n=FdDocEn.SVN
This information was mostly lifted from SourceForge.net:
https://sourceforge.net/svn/?group_id
FreeDOS Subversion:
Subversion (SVN) is a tool used by many software developers to manage
changes within their source code tree. SVN provides the means to store not
only the current version of a piece of source code, but a record of all
changes (and who made those changes) that have occurred to that source code.
Use of SVN is particularly common on projects with multiple developers,
since SVN ensures changes made by one developer are not accidentally removed
when another developer posts their changes to the source tree.
In order to access a Subversion repository, you must install a special piece
of software called a Subversion client. Subversion clients are available for
most any operating system.
To get a working copy, do svn co URL freedos where URL is the complete path
to the trunk of the project you want. For example:
FreeDOS kernel
https://freedos.svn.sourceforge.net/svnroot/freedos/kernel/trunk
FreeDOS FreeCOM
https://freedos.svn.sourceforge.net/svnroot/freedos/freecom/trunk
FreeDOS MEM
https://freedos.svn.sourceforge.net/svnroot/freedos/mem/trunk
FreeDOS Install
https://freedos.svn.sourceforge.net/svnroot/freedos/install/trunk
Be careful NOT to use the top level
* https://freedos.svn.sourceforge.net/svnroot/freedos URL
instead of one of the trunk URLs. This will pull all modules, tags and/or
branches of the project - it will be huge. Instead, you will want to use
/trunk to the URL to check out only the trunk code (main development line).
Though Subversion repositories are most commonly accessed using a special
piece of software called a Subversion client, SourceForge also provides a
web-based interface to view Subversion repositories. Browsing the Subversion
tree gives you a great view into the current status of this project's code.
You may also view the complete history of any file in the repository.
* Browse Subversion repository
http://freedos.svn.sourceforge.net/viewvc/freedos/
FreeDOS is a trademark of Jim Hall.
Note: Readonly access via the old CVS interface worked as follows:
To check out the code, first log in:
cvs -z3 -d:pserver:anonymous@cvs.freedos.sourceforge.net:/cvsroot/freedos login
Password: Press the Enter key.
Then, to get the kernel code:
cvs -z3 -d:pserver:anonymous@cvs.freedos.sourceforge.net:/cvsroot/freedos checkout kernel

View File

@ -13,7 +13,7 @@ http://www.freedos.org/
See the DOCS directory for more documentation and information about
the FreeDOS Kernel.
Contents of zip files:
Contents of release zip files:
ke20xx_16.zip : binaries for 8086, FAT16
ke20xx_32.zip : binaries for 8086, FAT16, FAT32
ke20xxsrc.zip : sources for the kernel
@ -22,17 +22,22 @@ BUG REPORTS
-----------
If you have found a bug, think you have found a bug, or would just
like to make a suggestion, go to the bug tracking web page at
http://sourceforge.net/tracker/?group_id=5109&atid=105109
like to make a suggestion or feature request, then add an issue to
the kernel's GitHub site:
https://github.com/FDOS/kernel/issues
Note: bugs (or feature requests) reported at the old bug tracking
web page http://sourceforge.net/tracker/?group_id=5109&atid=105109
and http://sourceforge.net/tracker/?atid=355109&group_id=5109&func=browse
will still be reviewed, but not actively.
An archive of old (Bugzilla) items is at www.freedos.org/bugzilla/
There is also a feature request tracker on our SourceForge pages at
http://sourceforge.net/tracker/?atid=355109&group_id=5109&func=browse
Copyright
---------
DOS-C is (c) Copyright 1995, 1996 by Pasquale J. Villani
All Rights Reserved.
Portions of FreeDOS kernel copyright others, 199?-2024

View File

@ -1,4 +1,4 @@
FreeDOS System Installer v3.6e - Nov 13, 2009
FreeDOS System Installer v3.6f - Nov 20, 2024
documentation by:
Jeremy Davis
Bart Oldeman
@ -23,12 +23,18 @@ Usage: SYS [source] drive: [bootsect] [{option}]
/BOOTONLY: do *not* copy kernel / shell, only update boot sector or image
/UPDATE : copy kernel and update boot sector (do *not* copy shell)
/OEM : indicates boot sector, filenames, and load segment to use
/OEM:FD use FreeDOS compatible settings
/OEM:DR use DR DOS 7+ compatible settings (same as /OEM)
/OEM:PC use PC-DOS compatible settings
/OEM:MS use MS-DOS compatible settings
/OEM:W9x use MS Win9x DOS compatible settings
default is /OEM:AUTO, select DOS based on existing files
/OEM:FD FreeDOS settings
/OEM:EDR Enhanced DR-DOS (DRBIO.SYS and DRDOS.SYS)
/OEM:LEDRPACK Enhanced DR-DOS (EDRPACK.SYS, lDOS drload)
/OEM:LEDR Enhanced DR-DOS (EDRDOS.COM, lDOS iniload)
/OEM:LMSPACK OSS MS-DOS (LMSPACK.SYS, lDOS drload)
/OEM:LMS OSS MS-DOS (LMSDOS.COM, lDOS iniload)
/OEM:OPENDOS Caldera OpenDOS 7.01 (and Novell DOS 7),
DR-DOS 7.02 - 7.03, 7.01.01 - 7.01.06
/OEM:PC PC-DOS, DR DOS 5 - Novell DOS 7
/OEM:MS MS-DOS
/OEM:W9x MS Win9x DOS
default is /OEM[:AUTO], select DOS based on existing files
/K name : name of kernel to use in boot sector instead of KERNEL.SYS
/L segm : hex load segment to use in boot sector instead of 0x60
/B btdrv : hex BIOS # of boot drive set in bs, 0=A:, 80=1st hd,...
@ -102,6 +108,12 @@ even 1st floppy drive attempts to use LBA support
(note that CHS may still be used if LBA check fails)
and /FORCE:CHS will always bypass use of LBA extensions.
SYS by default installs the FreeDOS kernel KERNEL.SYS.
If KERNEL.SYS is not found, it may install a different
kernel, like an Enhanced DR-DOS kernel, provided it
finds one. You may explicitly tell SYS which kernel
flavour to install via the /OEM argument.
Kernel Configuration Options:

View File

@ -29,6 +29,7 @@
;
%include "../kernel/segs.inc"
%include "../hdr/stacks.inc"
segment HMA_TEXT
;
@ -112,7 +113,8 @@ fl_common:
push bp ; setup stack frame
mov bp,sp
mov cx,[bp+0Ch] ; cylinder number
arg drive, head, track, sector, count, {buffer,4}
mov cx,[.track] ; cylinder number
mov al,1 ; this should be an error code
cmp ch,3 ; this code can't write above 3FFh=1023
@ -121,13 +123,13 @@ fl_common:
xchg ch,cl ; ch=low 8 bits of cyl number
ror cl,1 ; bits 8-9 of cylinder number...
ror cl,1 ; ...to bits 6-7 in CL
or cl,[bp+0Ah] ; or in the sector number (bits 0-5)
or cl,[.sector] ; or in the sector number (bits 0-5)
mov al,[bp+08h] ; count of sectors to read/write/...
les bx,[bp+04h] ; Load 32 bit buffer ptr into ES:BX
mov al,[.count] ; count of sectors to read/write/...
les bx,[.buffer] ; Load 32 bit buffer ptr into ES:BX
mov dl,[bp+10h] ; drive (if or'ed 80h its a hard drive)
mov dh,[bp+0Eh] ; get the head number
mov dl,[.drive] ; drive (if or'ed 80h its a hard drive)
mov dh,[.head] ; get the head number
int 13h ; process sectors
@ -152,9 +154,10 @@ FL_LBA_READWRITE:
push ds
push si ; wasn't in kernel < KE2024Bo6!!
mov dl,[bp+10] ; drive (if or'ed with 80h a hard drive)
mov ax,[bp+8] ; get the command
lds si,[bp+4] ; get far dap pointer
arg drive, mode, {dap_p,4}
mov dl,[.drive] ; drive (if or'ed with 80h a hard drive)
mov ax,[.mode] ; get the command
lds si,[.dap_p] ; get far dap pointer
int 13h ; read from/write to drive
pop si
@ -182,8 +185,7 @@ FL_READKEY: xor ah, ah
global FL_SETDISKTYPE
FL_SETDISKTYPE:
pop bx ; return address
pop ax ; disk format type (al)
pop dx ; drive number (dl)
popargs dx,ax ; drive number(dl),disk format type(al)
push bx ; restore stack
mov ah,17h ; floppy set disk type for format
int 13h
@ -198,9 +200,7 @@ ret_AH:
global FL_SETMEDIATYPE
FL_SETMEDIATYPE:
pop ax ; return address
pop bx ; sectors/track
pop cx ; number of tracks
pop dx ; drive number
popargs dx,cx,bx ; drive number,#tracks,sectors/track
push ax ; restore stack
push di

View File

@ -24,7 +24,7 @@
OBJS = floppy.obj rdpcclk.obj wrpcclk.obj wratclk.obj
LIBOBJS= +floppy.obj +rdpcclk.obj +wrpcclk.obj +wratclk.obj
LIBOBJS= $(LIBPLUS)floppy.obj $(LIBPLUS)rdpcclk.obj $(LIBPLUS)wrpcclk.obj $(LIBPLUS)wratclk.obj
@ -45,5 +45,5 @@ clean:
device.lib : $(OBJS)
-$(RM) device.lib
$(LIBUTIL) $(LIBFLAGS) device $(LIBOBJS) $(LIBTERM)
$(LIBUTIL) $(LIBFLAGS) device.lib $(LIBOBJS) $(LIBTERM)

View File

@ -29,6 +29,7 @@
;
%include "../kernel/segs.inc"
%include "../hdr/stacks.inc"
segment HMA_TEXT
@ -47,13 +48,14 @@ WRITEATCLOCK:
; bcdMinutes = 6
; bcdHours = 8
; bcdDays = 10
mov ch,byte [bp+8] ;bcdHours
mov cl,byte [bp+6] ;bcdMinutes
mov dh,byte [bp+4] ;bcdSeconds
arg bcdDays, bcdHours, bcdMinutes, bcdSeconds
mov ch,byte [.bcdHours]
mov cl,byte [.bcdMinutes]
mov dh,byte [.bcdSeconds]
mov dl,0
mov ah,3
int 1ah
mov bx,word [bp+10] ;bcdDays
mov bx,word [.bcdDays]
mov dx,word [bx]
mov cx,word [bx+2]
mov ah,5

View File

@ -28,6 +28,7 @@
; $Header$
;
%include "../kernel/segs.inc"
%include "../hdr/stacks.inc"
segment HMA_TEXT
@ -40,8 +41,7 @@ segment HMA_TEXT
WRITEPCCLOCK:
; Ticks = 4
pop ax ; return address
pop dx
pop cx ; Ticks
popargs {cx,dx} ; Ticks
push ax ; restore stack
mov ah,1
int 1ah

View File

@ -34,10 +34,11 @@
*/*/hdr/buffer.h
*/*/hdr/cds.h
*/*/hdr/clock.h
*/*/hdr/date.h
*/*/hdr/dcb.h
*/*/hdr/ddate.h
*/*/hdr/device.h
*/*/hdr/dirmatch.h
*/*/hdr/dtime.h
*/*/hdr/error.h
*/*/hdr/exe.h
*/*/hdr/fat.h
@ -56,7 +57,6 @@
*/*/hdr/sft.h
*/*/hdr/stacks.inc
*/*/hdr/tail.h
*/*/hdr/time.h
*/*/hdr/version.h
*/*/hdr/xstructs.h
*/*/kernel/nls/001-437.hc

View File

@ -1,6 +1,6 @@
/****************************************************************/
/* */
/* date.h */
/* ddate.h */
/* */
/* DOS General Date Structure */
/* */
@ -51,7 +51,7 @@ static BYTE *date_hRcsId =
#define EPOCH_DAY 1 /* 1 for January 1 */
#define EPOCH_YEAR 1980 /* for Tues 1-1-80 epoch */
typedef UWORD date;
typedef UWORD ddate;
#endif

View File

@ -44,6 +44,16 @@
#endif
#endif
/* assert macro */
#ifdef DEBUG
VOID panic(BYTE * s);
#define assert(condition) (void)(!(condition)?panic(#condition),0:0)
#else
#define assert(condition) /* ((void)0) */
#endif
/* use to limit output to debug builds */
#ifdef DEBUG
#ifdef DEBUG_PRINT_COMPORT
@ -66,7 +76,7 @@
/* #define DEBUGIRQ */
/* show output related to moving kernel into HMA */
#ifdef DEBUG
#ifdef DEBUGHMA
#define HMAInitPrintf(x) DebugPrintf(x)
#else
#define HMAInitPrintf(x)
@ -117,13 +127,24 @@
#endif
/* debug truename */
/* #define DEBUG_TRUENAME */
#ifdef DEBUG
#ifndef DEBUG_TRUENAME
#define DEBUG_TRUENAME
#endif
#endif
#ifdef DEBUG_TRUENAME
#define tn_printf(x) DebugPrintf(x)
#else
#define tn_printf(x)
#endif
/* debug task/process creation */
#ifdef DEBUGTASK
#define ProcDbgPrintf(x) DebugPrintf(x)
#else
#define ProcDbgPrintf(x)
#endif
/* ensure printf is prototyped */
#if defined(DEBUG) || defined(DEBUGIRQ) || defined(DEBUGCFG) || \

View File

@ -152,13 +152,13 @@ typedef struct {
UWORD bpb_nreserved; /* # Reserved Sectors */
UBYTE bpb_nfat; /* # FATs */
UWORD bpb_ndirent; /* # Root Directory entries */
UWORD bpb_nsize; /* Size in sectors */
UWORD bpb_nsize; /* Total volume Size in sectors */
UBYTE bpb_mdesc; /* MEDIA Descriptor Byte */
UWORD bpb_nfsect; /* FAT size in sectors */
UWORD bpb_nsecs; /* Sectors per track */
UWORD bpb_nheads; /* Number of heads */
ULONG bpb_hidden; /* Hidden sectors */
ULONG bpb_huge; /* Size in sectors if */
ULONG bpb_huge; /* Total volume Size in sectors if*/
/* bpb_nsize == 0 */
#ifdef WITHFAT32
ULONG bpb_xnfsect; /* FAT size in sectors if */
@ -253,6 +253,7 @@ typedef struct ddtstruct {
/* freedos specific flag bits */
#define DF_LBA 0x400
#define DF_WRTVERIFY 0x800
#define DF_DMA_TRANSPARENT 0x1000 /* DMA boundary errors are handled transparently */
/* typedef struct ddtstruct ddt;*/
@ -495,7 +496,7 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp);
/* execrh.asm */
#if defined(__WATCOMC__) && _M_IX86 >= 300
WORD execrh(request FAR *, struct dhdr FAR *);
#pragma aux execrh "^" parm reverse routine [] modify [ax bx cx dx es fs gs]
#pragma aux execrh "^" __parm __reverse __routine [] __modify [__ax __bx __cx __dx __es __fs __gs]
#else
WORD ASMPASCAL execrh(request FAR *, struct dhdr FAR *);
#endif

View File

@ -47,8 +47,8 @@ typedef struct {
UWORD reserved2;
UBYTE dm_attr_fnd; /* found file attribute */
time dm_time; /* file time */
date dm_date; /* file date */
dtime dm_time; /* file time */
ddate dm_date; /* file date */
ULONG dm_size; /* file size */
BYTE dm_name[FNAME_SIZE + FEXT_SIZE + 2]; /* file name */
} dmatch;

View File

@ -1,6 +1,6 @@
/****************************************************************/
/* */
/* time.h */
/* dtime.h */
/* */
/* DOS General Time Structure */
/* */
@ -39,7 +39,7 @@ static BYTE *time_hRcsId =
#endif
#endif
typedef UWORD time;
typedef UWORD dtime;
struct dostime
{

View File

@ -105,8 +105,8 @@ struct dirent {
UWORD dir_crdate; /* Creation date */
UWORD dir_accdate; /* Last access date */
UWORD dir_start_high; /* High word of the cluster */
time dir_time; /* Time file created/updated */
date dir_date; /* Date file created/updated */
dtime dir_time; /* Time file created/updated */
ddate dir_date; /* Date file created/updated */
UWORD dir_start; /* Starting cluster */
/* 1st available = 2 */
ULONG dir_size; /* File size in bytes */

View File

@ -86,8 +86,8 @@ typedef struct {
UWORD fcb_recsiz; /* Logical record size in bytes, */
/* default = 128 */
ULONG fcb_fsize; /* File size in bytes */
date fcb_date; /* Date file created */
time fcb_time; /* Time of last write */
ddate fcb_date; /* Date file created */
dtime fcb_time; /* Time of last write */
/* the following are reserved by system */
BYTE fcb_sftno; /* Device ID */
BYTE fcb_attrib_hi; /* share info, dev attrib word hi */

View File

@ -28,6 +28,22 @@
Revision: revision sequence, e.g. 42 for kernel 2042
Release: 0 if released version, >0 for svn builds (e.g. svn revision #)
CheckDebugger: during initialization enable/disable check to stop in debugger if one is active
0 = do not check (assume absent),
1 = do check by running breakpoint,
2 = assume present
Verbose: amount of messages to display during initialization
-1 = quiet
0 = normal
1 = verbose
PartitionMode: how to handle GPT and MBR partitions
bits 0-1: 01=GPT if found, 00=MBR if found, 11=Hybrid, GPT first then MBR, 10=Hybrid, MBR first then GPT
in hybrid mode, EE partitions ignored, drives assigned by GPT or MBR first based on hybrid type
bits 2-4: 001=mount ESP (usually FAT32) partition, 010=mount MS Basic partitions, 100=mount unknown partitions
111=attempt to mount all paritions, 110=attempt to mount all but ESP partitions
bits 5-7: reserved, 0 else undefined behavior
*/
typedef struct _KernelConfig {
char CONFIG[6]; /* "CONFIG" */
@ -46,4 +62,8 @@ typedef struct _KernelConfig {
unsigned short Version_Revision;
unsigned short Version_Release;
/* for version 2044 and higher only */
unsigned char CheckDebugger;
signed char Verbose;
unsigned char PartitionMode;
} KernelConfig;

View File

@ -59,6 +59,9 @@
#define REM_PRINTREDIR 0x1125
#define REM_EXTOC 0x112e
/* Redirector extensions */
#define REM_GETLARGESPACE 0x11a3
struct rgds {
UWORD r_spc;
UWORD r_navc;

View File

@ -28,7 +28,7 @@
/****************************************************************/
/* one byte alignment */
#include <algnbyte.h>
#include "algnbyte.h"
/*
* Description of the organization of NLS information -- 2000/02/13 ska
@ -175,7 +175,7 @@
*
* Performance tweaks:
* When the system -- This word applies to the combination of kernel and
* any loaded MUX-14 extension á la NLSFUNC here. -- uppercases
* any loaded MUX-14 extension <EFBFBD> la NLSFUNC here. -- uppercases
* _filenames_, it must perform a DOS-65-A2 internally. In the basic
* implementation this request would be channeled through MUX-14, even
* if there is no external NLSFUNC at all. Also, when a NLS pkg had
@ -403,7 +403,7 @@ struct nlsExtCntryInfo {
0: 12 hours (append AM/PM)
1: 24 houres
*/
VOID(FAR * upCaseFct) (VOID); /* far call to a function upcasing the
intvec upCaseFct; /* far call to a function upcasing the
character in register AL */
char dataSep[2]; /* ASCIZ of separator in data records */
};
@ -430,7 +430,8 @@ struct nlsPackage { /* the contents of one chain item of the
UWORD yeschar; /* yes / no character DOS-65-23 */
UWORD nochar;
unsigned numSubfct; /* number of supported sub-functions */
struct nlsPointer nlsPointers[1]; /* grows dynamically */
struct nlsPointer nlsPointers[5]; /* may grow dynamically */
struct nlsExtCntryInfo nlsExt;
};
struct nlsDBCS { /* The internal structure is unknown to me */
@ -473,20 +474,23 @@ struct nlsInfoBlock { /* This block contains all information
maybe tweaked by NLSFUNC */
UWORD sysCodePage; /* system code page */
unsigned flags; /* implementation flags */
#ifdef __GNUC__
/* need to initialize using explicit segment/offset */
union {
struct { struct nlsPackage *off; char *seg; };
struct nlsPackage FAR *p;
} actPkg, chain;
#define actPkg actPkg.p
#define chain chain.p
#else
struct nlsPackage FAR *actPkg; /* current NLS package */
struct nlsPackage FAR *chain; /* first item of info chain --
hardcoded U.S.A./CP437 */
#endif
};
extern struct nlsInfoBlock ASM nlsInfo;
extern struct nlsPackage FAR ASM nlsPackageHardcoded;
/* These are the "must have" tables within the hard coded NLS pkg */
extern struct nlsFnamTerm FAR ASM nlsFnameTermHardcoded;
extern struct nlsDBCS FAR ASM nlsDBCSHardcoded;
extern struct nlsCharTbl FAR ASM nlsUpcaseHardcoded;
extern struct nlsCharTbl FAR ASM nlsFUpcaseHardcoded;
extern struct nlsCharTbl FAR ASM nlsCollHardcoded;
extern struct nlsExtCntryInfo FAR ASM nlsCntryInfoHardcoded;
extern struct nlsPackage DOSFAR ASM nlsPackageHardcoded;
extern BYTE FAR hcTablesStart[], hcTablesEnd[];
/***********************************************************************
@ -619,7 +623,7 @@ struct nlsCSys_loadPackage {
};
/* standard alignment */
#include <algndflt.h>
#include "algndflt.h"
#ifdef DEBUG
/* Enable debugging of NLS part */

View File

@ -57,7 +57,7 @@ static BYTE *pcb_hRcsId =
#endif
/* Force one-byte alignment for all the internal structures, see above */
#include <algnbyte.h>
#include "algnbyte.h"
/* */
/* interrupt handler structure definition */
/* */
@ -87,14 +87,6 @@ typedef struct {
UWORD si, di, ds, es;
} lregs;
/* Registers directly passed to syscall;
must be the same order as iregs!
Is used to define parameters. */
#define DIRECT_IREGS \
xreg a, xreg b, xreg c, xreg d, \
UWORD si, UWORD di, UWORD bp, UWORD ds, UWORD es, \
UWORD ip, UWORD cs, UWORD flags
/* Process control block for task switching */
typedef struct {
UWORD pc_ss;
@ -166,7 +158,7 @@ typedef struct {
#define FLG_CARRY 0x0001
/* Allow default alignment from now on */
#include <algndflt.h>
#include "algndflt.h"
#endif

View File

@ -77,7 +77,7 @@ void __emit__(char, ...);
#define enable() __emit__(0xfb)
#endif
#elif defined (_MSC_VER)
#elif defined(_MSC_VER)
#define I86
#define asm __asm
@ -100,19 +100,16 @@ static unsigned short __inline getSS(void)
asm mov ax, ss;
}
#elif defined(__WATCOMC__) && defined(BUILD_UTILS)
/* workaround for building some utils with OpenWatcom (owcc) */
#define MC68K
#elif defined(__WATCOMC__) /* don't know a better way */
#if defined(_M_I86)
#define I86
#endif
#define __int__(intno) asm int intno;
void disable(void);
#pragma aux disable = "cli" modify exact [];
#pragma aux disable = "cli" __modify __exact [];
void enable(void);
#pragma aux enable = "sti" modify exact [];
#pragma aux enable = "sti" __modify __exact [];
#define asm __asm
#define far __far
#define CDECL __cdecl
@ -120,19 +117,22 @@ void enable(void);
#define PASCAL pascal
#define _CS getCS()
unsigned short getCS(void);
#pragma aux getCS = "mov dx,cs" value [dx] modify exact[dx];
#pragma aux getCS = "mov dx,cs" __value [__dx] __modify __exact[__dx];
#define _SS getSS()
unsigned short getSS(void);
#pragma aux getSS = "mov dx,ss" value [dx] modify exact[dx];
#pragma aux getSS = "mov dx,ss" __value [__dx] __modify __exact[__dx];
#if !defined(FORSYS) && !defined(EXEFLAT) && _M_IX86 >= 300
#pragma aux default parm [ax dx cx] modify [ax dx es fs] /* min.unpacked size */
#pragma aux __default __parm [__ax __dx __cx] __modify [__ax __dx __es __fs] /* min.unpacked size */
#endif
/* enable Possible loss of precision warning for compatibility with Borland */
#pragma enable_message(130)
#if _M_IX86 >= 300 || defined(M_I386)
#define I386
#else
/* workaround for building some utils with OpenWatcom (flat model) */
#define MC68K
#endif
#elif defined (_MYMC68K_COMILER_)
@ -140,8 +140,44 @@ unsigned short getSS(void);
#define MC68K
#elif defined(__GNUC__)
#ifdef __FAR
#define I86
#define STRINGIFY(x) #x
#define __int__(intno) asm volatile(STRINGIFY(int $##intno))
static inline void disable(void)
{
asm volatile("cli");
}
static inline void enable(void)
{
asm volatile("sti");
}
#define far __far
#define CDECL __attribute__((cdecl))
#define VA_CDECL
#define PASCAL
#define _CS getCS()
static inline unsigned short getCS(void)
{
unsigned short ret;
asm volatile("mov %%cs, %0" : "=r"(ret));
return ret;
}
#define _SS getSS()
static inline unsigned short getSS(void)
{
unsigned short ret;
asm volatile("mov %%ss, %0" : "=r"(ret));
return ret;
}
extern char DosDataSeg[];
#else
/* for warnings only ! */
#define MC68K
#endif
#else
#error Unknown compiler
@ -150,11 +186,15 @@ We might even deal with a pre-ANSI compiler. This will certainly not compile.
#ifdef I86
#if _M_IX86 >= 300 || defined(M_I386)
#ifndef I386
#define I386
#endif
#elif _M_IX86 >= 100 || defined(M_I286)
#ifndef I186
#define I186
#endif
#endif
#endif
#ifdef MC68K
#define far /* No far type */
@ -197,7 +237,16 @@ typedef unsigned size_t;
as 'ASMCFUNC', and is (and will be ?-) cdecl */
#define ASMCFUNC CDECL
#define ASMPASCAL PASCAL
#if defined(__GNUC__)
#define ASM
#else
#define ASM ASMCFUNC
#endif
/* variables that can be near or far: redefined in init-dat.h */
#define DOSFAR
#define DOSTEXTFAR
/* */
/* Boolean type & definitions of TRUE and FALSE boolean values */
/* */
@ -249,7 +298,7 @@ typedef unsigned short CLUSTER;
#endif
typedef unsigned short UNICODE;
#if defined(STATICS) || defined(__WATCOMC__)
#if defined(STATICS) || defined(__WATCOMC__) || defined(__GNUC__)
#define STATIC static /* local calls inside module */
#else
#define STATIC
@ -267,6 +316,13 @@ typedef signed long LONG;
#define LONG long
#endif
#if USHRT_MAX == 0xFFFF
# define loword(v) ((unsigned short)(v))
#else
# define loword(v) (0xFFFF & (unsigned)(v))
#endif
#define hiword(v) loword ((v) >> 16u)
#define MK_UWORD(hib,lob) (((UWORD)(hib) << 8u) | (UBYTE)(lob))
#define MK_ULONG(hiw,low) (((ULONG)(hiw) << 16u) | (UWORD)(low))
@ -297,7 +353,11 @@ typedef signed long LONG;
#define FP_SEG(fp) ((unsigned)((ULONG)(VOID FAR *)(fp)>>16))
#endif
#if defined(__GNUC__) && defined(__BUILTIN_IA16_FP_OFF)
#define FP_OFF(fp) __builtin_ia16_FP_OFF(fp)
#else
#define FP_OFF(fp) ((unsigned)(fp))
#endif
#endif
#endif
@ -308,7 +368,11 @@ typedef signed long LONG;
#define FP_OFF(fp) ((size_t)(fp))
#endif
#if defined(__GNUC__) && defined(__FAR)
typedef VOID FAR *intvec;
#else
typedef VOID (FAR ASMCFUNC * intvec) (void);
#endif
#define MK_PTR(type,seg,ofs) ((type FAR*) MK_FP (seg, ofs))
#if __TURBOC__ > 0x202

View File

@ -67,7 +67,7 @@ typedef struct {
for compatiblity with CP/M apps that do a near call to psp:5
and expect size (KB) of allocated segment in word at offset 6 */
UBYTE ps_farcall; /* 05 far call opcode */
VOID(FAR ASMCFUNC * ps_reentry) (void); /* 06 re-entry point */
intvec ps_reentry; /* 06 re-entry point */
intvec ps_isv22, /* 0a terminate address */
ps_isv23, /* 0e ctrl-break address */
@ -79,10 +79,10 @@ typedef struct {
UWORD ps_maxfiles; /* 32 maximum open files */
UBYTE FAR *ps_filetab; /* 34 open file table pointer */
VOID FAR *ps_prevpsp; /* 38 previous psp pointer */
UBYTE ps_fill2; /* 3c unused */
UBYTE ps_truename; /* 3d [unused] append truename flag int2f/B711h */
UBYTE ps_dbcs_inputmode; /* 3c unused,see int21/6301h/6302h */
UBYTE ps_truename; /* 3d unused,append truename flag int2f/B711h */
UBYTE ps_netx_taskid[2]; /* 3e [Novell only field] task id */
UWORD ps_retdosver; /* 40 [unused] version to return on int21/30h */
UWORD ps_retdosver; /* 40 version to return on int21/30h, defaults to true version */
UWORD pdb_next; /* 42 [Win only field] PSP chain */
UBYTE ps_fill2b[4]; /* 44 unused, 4 bytes */
UBYTE ps_olddos; /* 48 [Win only field] DOS/Win program */

View File

@ -61,8 +61,8 @@ typedef struct {
#else
CLUSTER sft_stclust; /* 0b - Starting cluster */
#endif
time sft_time; /* 0d - File time */
date sft_date; /* 0f - File date */
dtime sft_time; /* 0d - File time */
ddate sft_date; /* 0f - File date */
ULONG sft_size; /* 11 - File size */
ULONG sft_posit; /* 15 - Current file position */
UWORD sft_relclust; /* 19 - File relative cluster (low part) */
@ -115,6 +115,7 @@ typedef struct sfttbl {
/* the following bits are file (block) unique */
#define SFT_FDATE 0x4000 /* File date set */
#define SFT_FFIXEDMEDIA 0x0800 /* File on non-removable media - unused */
#define SFT_FCLEAN 0x0040 /* File has not been written to */
#define SFT_FDMASK 0x003f /* File mask for drive no */

View File

@ -196,3 +196,57 @@ irp_hi equ 26
%endif
%ENDIF
; macros to define stack arguments
; arg a, {b,4}, c
; defines a and c as "word" arguments and b as a "dword" argument
; for STDCALL defines .a as [bp+4], .b as [bp+6] and .c as [bp+10]
; for PASCAL defines .a as [bp+10], .b as [bp+6] and .c as [bp+4]
;
; popargs bx, {dx,ax}, cx pops these arguments of the stack (for PASCAL
; in reverse order). Here dx,ax is a dword argument dx:ax where dx is
; the high word. The caller is responsible for dealing with instruction
; pointer (ip) on the stack.
%ifdef gcc
%define STDCALL
%else
%define PASCAL
%endif
%macro definearg 1-2 2
%xdefine .%1 bp+.argloc
%assign .argloc .argloc+%2
%endmacro
%macro arg 1-*
%assign .argloc 4
%rep %0
%ifdef PASCAL
%rotate -1
%endif
definearg %1
%ifdef STDCALL
%rotate 1
%endif
%endrep
%endmacro
%macro multipop 1-*
%rep %0
%rotate -1
pop %1
%endrep
%endmacro
%macro popargs 1-*
%rep %0
%ifdef PASCAL
%rotate -1
%endif
multipop %1
%ifdef STDCALL
%rotate 1
%endif
%endrep
%endmacro

View File

@ -36,12 +36,12 @@
#endif
/* The actual kernel revision, 2000+REVISION_SEQ = 2.REVISION_SEQ */
#define REVISION_SEQ 42 /* returned in BL by int 21 function 30 */
#define REVISION_SEQ 43 /* returned in BL by int 21 function 30 */
#define OEM_ID 0xfd /* FreeDOS, returned in BH by int 21 30 */
/* Used for version information displayed to user at boot (& stored in os_release string) */
#ifndef KERNEL_VERSION
#define KERNEL_VERSION "- SVN "
#define KERNEL_VERSION "- GIT "
#endif
/* actual version string */

View File

@ -18,6 +18,12 @@ struct WinStartupInfo
ULONG optInstanceTable; /* used only if winver set to 0x400 (w95)*/
};
extern struct WinStartupInfo winStartupInfo;
#if defined __GNUC__
extern UWORD winseg1, winseg2, winseg3;
extern UBYTE markEndInstanceData;
extern struct lol FAR ASM DATASTART;
#endif
/* contains a list of offsets relative to DOS data segment of
various internal variables.

View File

@ -48,6 +48,7 @@
%ifndef WATCOM_INIT
%include "segs.inc"
%include "stacks.inc"
%ifdef _INIT
@ -134,9 +135,10 @@ pascal_setup:
cld
mov bl,6 ; majority (4) wants that
mov cx,[4+bp] ; majority (8) wants that (near and far)
mov si,[6+bp] ; majority (3) wants that (near)
mov di,[8+bp] ; majority (3) wants that (near)
arg arg1, arg2, arg3
mov cx,[.arg3] ; majority (8) wants that (near and far)
mov si,[.arg2] ; majority (3) wants that (near)
mov di,[.arg1] ; majority (3) wants that (near)
jmp ax
@ -192,14 +194,17 @@ FMEMCPYBACK:
FMEMCPY:
call pascal_setup
arg {d,4}, {s,4}, n
; Get the repetition count, n preset above
; mov cx,[bp+4]
%ifdef STDCALL
mov cx,[.n]
%endif
; Get the far source pointer, s
lds si,[bp+6]
lds si,[.s]
; Get the far destination pointer d
les di,[bp+10]
les di,[.d]
mov bl,10
jmp short domemcpy
@ -212,14 +217,17 @@ FMEMCPY:
FMEMSET:
call pascal_setup
arg {d,4}, ch, n
; Get the repetition count, n - preset above
; mov cx,[bp+4]
%ifdef STDCALL
mov cx,[.n]
%endif
; Get the fill byte ch
mov ax,[bp+6]
mov ax,[.ch]
; Get the far source pointer, s
les di,[bp+8]
les di,[.d]
mov bl,8
domemset:
@ -240,11 +248,12 @@ domemset:
MEMSET:
call pascal_setup
arg d, ch, n
; Get the repitition count, n - preset above
; mov cx,[bp+4]
; Get the char ch
mov ax, [bp+6]
mov ax, [.ch]
; Get the far source pointer, d - preset above
; mov di,[bp+8]
@ -277,21 +286,20 @@ pascal_return:
; fstrcpy (void FAR*dest, void FAR *src);
%ifndef _INIT
global FSTRCPY
FSTRCPY:
call pascal_setup
arg {dest,4}, {src,4}
; Get the source pointer, ss
lds si,[bp+4]
lds si,[.src]
; and the destination pointer, d
les di,[bp+8]
les di,[.dest]
mov bl,8
jmp short dostrcpy
%endif
;******
global STRCPY
@ -299,11 +307,13 @@ STRCPY:
call pascal_setup
%ifdef PASCAL
; Get the source pointer, ss
mov si,[bp+4]
; and the destination pointer, d
mov di,[bp+6]
%endif
mov bl,4
dostrcpy:
@ -317,7 +327,6 @@ strcpy_loop:
jmp short pascal_return
;******************************************************************
%ifndef _INIT
global FSTRLEN
FSTRLEN:
call pascal_setup
@ -327,14 +336,15 @@ FSTRLEN:
mov bl,4
jmp short dostrlen
%endif
;**********************************************
global STRLEN
STRLEN:
call pascal_setup
; Get the source pointer, ss
%ifdef PASCAL
mov di,[bp+4]
%endif
mov bl,2
dostrlen:
@ -356,8 +366,11 @@ STRCHR:
call pascal_setup
; Get the source pointer, ss
; mov cx,[bp+4] - preset above
; mov si,[bp+6] - preset above
arg src, ch
%ifdef STDCALL ; preset above for PASCAL
mov cx,[.ch]
mov si,[.src]
%endif
mov bl,4
strchr_loop:
@ -388,11 +401,12 @@ strchr_found1:
FSTRCHR:
call pascal_setup
arg {src,4}, ch
; Get ch (preset above)
;mov cx, [bp+4]
;and the source pointer, src
lds si, [bp+6]
lds si, [.src]
;mov bl, 6 - preset above
@ -403,14 +417,17 @@ FSTRCHR:
FMEMCHR:
call pascal_setup
arg {src,4}, ch, n
; Get the length - preset above
; mov cx, [bp+4]
%ifdef STDCALL
mov cx, [.n]
%endif
; and the search value
mov ax, [bp+6]
mov ax, [.ch]
; and the source pointer, ss
les di, [bp+8]
les di, [.src]
mov bl, 8
@ -426,11 +443,12 @@ FMEMCHR:
FSTRCMP:
call pascal_setup
arg {dest,4}, {src,4}
; Get the source pointer, ss
lds si,[bp+4]
lds si,[.src]
; and the destination pointer, d
les di,[bp+8]
les di,[.dest]
mov bl,8
@ -507,14 +525,17 @@ strncmp_loop:
FMEMCMP:
call pascal_setup
arg {dest,4}, {src,4}, n
; the length - preset above
; mov cx, [bp+4]
%ifdef STDCALL
mov cx, [.n]
%endif
; Get the source pointer, ss
les di,[bp+6]
les di,[.src]
; and the destination pointer, d
lds si,[bp+10]
lds si,[.dest]
mov bl,10
@ -545,10 +566,6 @@ strncmp_retzero:
strncmp_done:
lahf
ror ah,1
%ifdef _INIT
strncmp_done2: jmp short pascal_return
%else
strncmp_done2: jmp pascal_return
%endif
%endif

View File

@ -500,7 +500,7 @@ void AllocateHMASpace (size_t lowbuffer, size_t highbuffer)
do
{
/* check if buffer intersects with requested area */
if (FP_OFF(bp) < highbuffer && FP_OFF(bp+1) > lowbuffer)
if (FP_OFF(bp) <= highbuffer && FP_OFF(bp+1) > lowbuffer)
{
flush1(bp);
/* unlink bp from buffer chain */

View File

@ -96,7 +96,9 @@ STATIC void CharCmd(struct dhdr FAR **pdev, unsigned command)
STATIC int Busy(struct dhdr FAR **pdev)
{
CharCmd(pdev, C_ISTAT);
CharCmd(pdev, C_NDREAD);
if (CharReqHdr.r_status & S_ERROR)
CharCmd(pdev, C_ISTAT);
return CharReqHdr.r_status & S_BUSY;
}
@ -140,7 +142,7 @@ int ndread(struct dhdr FAR **pdev)
#ifdef __WATCOMC__
void fast_put_char(char c);
#pragma aux fast_put_char = "int 29h" parm[al] modify exact [bx]
#pragma aux fast_put_char = "int 29h" __parm[__al] __modify __exact [__bx]
#else
/* writes a character in raw mode using int29 for speed */
@ -149,6 +151,8 @@ STATIC void fast_put_char(unsigned char chr)
#if defined(__TURBOC__)
_AL = chr;
__int__(0x29);
#elif defined(__GNUC__)
asm volatile("int $0x29":: "a"(chr):"bx");
#elif defined(I86)
asm
{
@ -493,6 +497,8 @@ void read_line(int sft_in, int sft_out, keyboard FAR * kp)
/* fall through */
default:
if (c >= 256)
break;
if (count < size - 1 || c == CR)
local_buffer[count++] = echo_char(c, sft_out);
else

File diff suppressed because it is too large Load Diff

View File

@ -57,6 +57,11 @@ uScanCode db 0 ; Scan code for con: device
global _kbdType
_kbdType db 0 ; 00 for 84key, 10h for 102key
%IFDEF DEBUG_PRINT_COMPORT
ASYNC_NEED_INIT db 1
%ENDIF
global ConInit
ConInit:
xor ax,ax
@ -156,6 +161,8 @@ CommonNdRdExit: ; *** tell if key waiting and return its ASCII if yes
add ah,[cs:_kbdType]
int 16h ; Get status, if zf=0 al=char
jz ConNdRd4 ; Jump if no char available
or ax,ax ; Also check for ax=0 as apparently some
jz ConNdRd4 ; int16h handlers set ax=0 to indicate unsupported function
call checke0 ; check for e0 scancode
or ax,ax ; Zero ?
jnz ConNdRd1 ; Jump if not zero
@ -243,12 +250,63 @@ _int29_handler:
push di
push bp
push bx
%IFDEF DEBUG_PRINT_COMPORT
cmp bx, 0xFD05 ; magic value for COM print routine
je .comprint
%ENDIF
mov ah,0Eh
mov bx,7
int 10h ; write char al, teletype mode
.int29hndlr_ret:
pop bx
pop bp
pop di
pop si
pop ax
iret
%IFDEF DEBUG_PRINT_COMPORT
%ifnum DEBUG_PRINT_COMPORT
%define DEBUG_USE_COMPORT DEBUG_PRINT_COMPORT
%else
%define DEBUG_USE_COMPORT 1 ; default to COM2 if not specified
%endif
.comprint:
push dx
mov dx, DEBUG_USE_COMPORT ; 0=COM1,1=COM2,2=COM3,3=COM4
mov ah, [cs:ASYNC_NEED_INIT]
or ah,ah
jz .skip_init
push ax ; preserve char (AL) to print
; initialize serial port using BIOS to DOS default
; of 2400 bps, 8 data bits, 1 stop bit, and no parity
mov ax, 0x00A3
int 14h ; BIOS initialize serial port
mov ax, 0x011B ; clear the remote screen (ESC[2J)
int 14h ; BIOS write character to serial port
mov ax, 0x015B ; '['
int 14h ; BIOS write character to serial port
mov ax, 0x0132 ; '2'
int 14h ; BIOS write character to serial port
mov ax, 0x014A ; 'J'
int 14h ; BIOS write character to serial port
; mark initialization complete
mov byte [cs:ASYNC_NEED_INIT], 0
pop ax ; restore char to print
.skip_init:
cmp al, 0x0A ; do we need to add a carriage return?
jne .print_it
mov ax, 0x010D ; print as \r\n
int 14h
mov al, 0x0A
.print_it:
mov ah, 0x01
int 14h ; BIOS write character to serial port
pop dx
jmp .int29hndlr_ret
%ENDIF ; DEBUG_PRINT_COMPORT

File diff suppressed because it is too large Load Diff

View File

@ -48,6 +48,22 @@ CPU 386
and ax, 0f000h
cmp ax, 0f000h
jnz is286 ; no the 4 msb stuck set to 1, so is a 808x or 8018x
; NEC V20/V30 support 186 instructions but
; do not mask the shift count like a 186.
; based on https://hg.pushbx.org/ecm/ldebug/file/7f3440d5824d/source/init.asm#l3071
; which is based on http://www.textfiles.com/hamradio/v20_bug.txt
mov ax, sp ; we use stack to do test
mov cx, 0 ; after pop still 0 if 8088/8086
push cx
inc cx ; after pop still 1 if NEC V20/V30
; next instructions may lock system if breakpoint or trace flag set
db 8Fh, 0C1h; pop r/m16 with operand cx on 808x, nop on NEC V20/V30
mov sp, ax ; reset stack to known good state (pre push, optional pop)
or cx, cx ; cx is 0 if 808x, 1 if NEC
jz is808x ; if not NEC then goto test for 808x vs 8018x
mov bx, cx ; treat NEC V20/V30 as 8018x, i.e. return 1
jmp short cleanup
is808x:
mov ax,1 ; determine if 8086 or 186
mov cl,64 ; try to shift further than size of ax
shr ax,cl

View File

@ -34,6 +34,7 @@ static BYTE *dosfnsRcsId =
#endif
#include "globals.h"
#include "debug.h"
/* /// Added for SHARE. - Ron Cemer */
@ -46,7 +47,7 @@ BYTE share_installed = 0;
code, so DOS simply negates this value and returns it in
AX. */
extern int ASMPASCAL
share_open_check(char * filename, /* pointer to fully qualified filename */
share_open_check(const char FAR * filename, /* pointer to fully qualified filename */
unsigned short pspseg, /* psp segment address of owner process */
int openmode, /* 0=read-only, 1=write-only, 2=read-write */
int sharemode); /* SHARE_COMPAT, etc... */
@ -86,6 +87,13 @@ extern int ASMPASCAL
unsigned long len, /* length (in bytes) of region to lock or unlock */
int unlock); /* one to unlock; zero to lock */
/* DOS calls this to see if share already has the file marked as open.
Returns:
1 if open
0 if not */
extern int ASMPASCAL
share_is_file_open(const char far * filename);
/* /// End of additions for SHARE. - Ron Cemer */
STATIC int remote_lock_unlock(sft FAR *sftp, /* SFT for file */
@ -93,6 +101,13 @@ STATIC int remote_lock_unlock(sft FAR *sftp, /* SFT for file */
unsigned long len, /* length (in bytes) of region to lock or unlock */
int unlock); /* one to unlock; zero to lock */
struct cds FAR *get_cds_unvalidated(unsigned drive)
{
if (drive >= lastdrive)
return NULL;
return &CDSp[drive];
}
/* get current directory structure for drive
return NULL if the CDS is not valid or the
drive is not within range */
@ -290,6 +305,7 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode)
/* /// Added for SHARE - Ron Cemer */
if (IsShareInstalled(FALSE) && (s->sft_shroff >= 0))
{
/* sft_shroff is file_table index in share */
int rc = share_access_check(cu_psp, s->sft_shroff, s->sft_posit,
(unsigned long)n, 1);
if (rc != SUCCESS)
@ -299,7 +315,7 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode)
return rwblock(sft_idx, bp, n, mode);
}
COUNT SftSeek(int sft_idx, LONG new_pos, unsigned mode)
COUNT SftSeek2(int sft_idx, LONG new_pos, unsigned mode, UDWORD * p_result)
{
sft FAR *s = idx_to_sft(sft_idx);
if (FP_OFF(s) == (size_t) -1)
@ -340,17 +356,25 @@ COUNT SftSeek(int sft_idx, LONG new_pos, unsigned mode)
}
s->sft_posit = new_pos;
*p_result = new_pos;
return SUCCESS;
}
COUNT SftSeek(int sft_idx, LONG new_pos, unsigned mode)
{
UDWORD result;
return SftSeek2(sft_idx, new_pos, mode, &result);
}
ULONG DosSeek(unsigned hndl, LONG new_pos, COUNT mode, int *rc)
{
int sft_idx = get_sft_idx(hndl);
UDWORD result;
/* Get the SFT block that contains the SFT */
*rc = SftSeek(sft_idx, new_pos, mode);
*rc = SftSeek2(sft_idx, new_pos, mode, &result);
if (*rc == SUCCESS)
return idx_to_sft(sft_idx)->sft_posit;
return result;
return *rc;
}
@ -574,21 +598,28 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib)
/* /// Added for SHARE. - Ron Cemer */
if (IsShareInstalled(TRUE))
{
DebugPrintf(("Share installed - open_check(%s)\n", PriPathName));
if ((sftp->sft_shroff =
share_open_check(PriPathName, cu_psp,
flags & 0x03, (flags >> 4) & 0x07)) < 0)
return sftp->sft_shroff;
}
else
{
DebugPrintf(("Share NOT installed - open_check(%s)\n", PriPathName));
}
/* /// End of additions for SHARE. - Ron Cemer */
sftp->sft_count++;
sftp->sft_flags = PriPathName[0] - 'A';
result = dos_open(PriPathName, flags, attrib, sft_idx);
DebugPrintf(("dos_open(%s) returned %i\n", PriPathName, result));
if (result < 0)
{
/* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***. - Ron Cemer */
if (IsShareInstalled(TRUE))
/* if we allocated a share slot above, but open failed, free slot */
if (sftp->sft_shroff >= 0) /* SHARE installed status can't change since check above */
{
share_close_file(sftp->sft_shroff);
sftp->sft_shroff = -1;
@ -689,7 +720,7 @@ COUNT DosCloseSft(int sft_idx, BOOL commitonly)
*/
if (sftp->sft_flags & SFT_FSHARED)
{
/* printf("closing SFT %d = %p\n",sft_idx,sftp); */
/* DebugPrintf(("closing SFT %d = %p\n",sft_idx,sftp)); */
return network_redirector_fp(commitonly ? REM_FLUSH: REM_CLOSE, sftp);
}
@ -749,7 +780,7 @@ UWORD DosGetFree(UBYTE drive, UWORD * navc, UWORD * bps, UWORD * nc)
/* navc==NULL means: called from FatGetDrvData, fcbfns.c */
struct dpb FAR *dpbp;
struct cds FAR *cdsp;
COUNT rg[4];
COUNT rg[5]; /* add space for SI, although it's unused here */
UWORD spc;
/* first check for valid drive */
@ -759,6 +790,7 @@ UWORD DosGetFree(UBYTE drive, UWORD * navc, UWORD * bps, UWORD * nc)
if (cdsp == NULL)
return spc;
current_ldt = cdsp;
if (cdsp->cdsFlags & CDSNETWDRV)
{
if (remote_getfree(cdsp, rg) != SUCCESS)
@ -853,7 +885,7 @@ COUNT DosGetExtFree(BYTE FAR * DriveString, struct xfreespace FAR * xfsp)
{
struct dpb FAR *dpbp;
struct cds FAR *cdsp;
UCOUNT rg[4];
UCOUNT rg[5];
/* ensure all fields known value - clear reserved bytes & set xfs_version.actual to 0 */
fmemset(xfsp, 0, sizeof(struct xfreespace));
@ -876,13 +908,44 @@ COUNT DosGetExtFree(BYTE FAR * DriveString, struct xfreespace FAR * xfsp)
if (cdsp->cdsFlags & CDSNETWDRV)
{
if (remote_getfree(cdsp, rg) != SUCCESS)
return DE_INVLDDRV;
/* Try redirector extension */
if (remote_getfree_11a3(cdsp, rg) != SUCCESS)
{
/* Fallback */
if (remote_getfree(cdsp, rg) != SUCCESS)
return DE_INVLDDRV;
xfsp->xfs_clussize = rg[0];
xfsp->xfs_totalclusters = rg[1];
xfsp->xfs_secsize = rg[2];
xfsp->xfs_freeclusters = rg[3];
xfsp->xfs_clussize = rg[0];
xfsp->xfs_totalclusters = rg[1];
xfsp->xfs_secsize = rg[2];
xfsp->xfs_freeclusters = rg[3];
}
else /* Supports extension */
{
UDWORD total, avail;
UDWORD bps, spc;
bps = rg[4];
spc = 1;
total = (((UDWORD)rg[0] << 16UL) | rg[1]);
avail = (((UDWORD)rg[2] << 16UL) | rg[3]);
while (total > 0x00ffffffUL && spc < 128) {
spc *= 2;
avail /= 2;
total /= 2;
}
while (total > 0x00ffffffUL && bps < 32768UL) {
bps *= 2;
avail /= 2;
total /= 2;
}
xfsp->xfs_secsize = bps;
xfsp->xfs_clussize = spc;
xfsp->xfs_totalclusters = total;
xfsp->xfs_freeclusters = avail;
}
}
else
{
@ -939,14 +1002,14 @@ COUNT DosChangeDir(BYTE FAR * s)
return DE_PATHNOTFND;
#if defined(CHDIR_DEBUG)
printf("Remote Chdir: n='%Fs' p='%Fs\n", s, PriPathName);
DebugPrintf(("Remote Chdir: n='%Fs' p='%Fs\n", s, PriPathName));
#endif
/* now get fs to change to new */
/* directory */
result = (result & IS_NETWORK ? network_redirector(REM_CHDIR) :
dos_cd(PriPathName));
#if defined(CHDIR_DEBUG)
printf("status = %04x, new_path='%Fs'\n", result, cdsd->cdsCurrentPath);
DebugPrintf(("status = %04x, new_path='%Fs'\n", result, cdsd->cdsCurrentPath));
#endif
if (result != SUCCESS)
return result;
@ -957,7 +1020,6 @@ COUNT DosChangeDir(BYTE FAR * s)
Some redirectors do not write back to the CDS.
SHSUCdX needs this. jt
*/
fstrcpy(current_ldt->cdsCurrentPath, PriPathName);
if (FP_OFF(current_ldt) != 0xFFFF)
{
fstrcpy(current_ldt->cdsCurrentPath, PriPathName);
@ -1005,7 +1067,7 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name)
SAttr = (BYTE) attr;
#if defined(FIND_DEBUG)
printf("Remote Find: n='%Fs\n", PriPathName);
DebugPrintf(("Remote Find: n='%Fs\n", PriPathName));
#endif
dta = &sda_tmp_dm;
@ -1060,7 +1122,7 @@ COUNT DosFindNext(void)
* (12h, DE_NFILES)
*/
#if 0
printf("findnext: %d\n", dmp->dm_drive);
DebugPrintf(("findnext: %d\n", dmp->dm_drive));
#endif
fmemcpy(&sda_tmp_dm, dmp, 21);
@ -1077,7 +1139,7 @@ COUNT DosFindNext(void)
return pop_dmp(rc, dmp);
}
COUNT DosGetFtime(COUNT hndl, date * dp, time * tp)
COUNT DosGetFtime(COUNT hndl, ddate * dp, dtime * tp)
{
sft FAR *s;
/*sfttbl FAR *sp;*/
@ -1091,7 +1153,7 @@ COUNT DosGetFtime(COUNT hndl, date * dp, time * tp)
return SUCCESS;
}
COUNT DosSetFtimeSft(int sft_idx, date dp, time tp)
COUNT DosSetFtimeSft(int sft_idx, ddate dp, dtime tp)
{
/* Get the SFT block that contains the SFT */
sft FAR *s = idx_to_sft(sft_idx);
@ -1160,6 +1222,7 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD attrp)
if (result & IS_DEVICE)
return DE_FILENOTFND;
DebugPrintf(("DosSetFattr(%s)\n", name));
if (IsShareInstalled(TRUE))
{
/* SHARE closes the file if it is opened in
@ -1199,6 +1262,9 @@ COUNT DosDelete(BYTE FAR * path, int attrib)
if (result & IS_DEVICE)
return DE_FILENOTFND;
if (IsShareInstalled(TRUE) && share_is_file_open(PriPathName))
return DE_ACCESS;
return dos_delete(PriPathName, attrib);
}
@ -1211,6 +1277,9 @@ COUNT DosRenameTrue(BYTE * path1, BYTE * path2, int attrib)
if (FP_OFF(current_ldt) == 0xFFFF || (current_ldt->cdsFlags & CDSNETWDRV))
return network_redirector(REM_RENAME);
if (IsShareInstalled(TRUE) && share_is_file_open(path1))
return DE_ACCESS;
return dos_rename(path1, path2, attrib);
}
@ -1365,10 +1434,13 @@ struct dhdr FAR *IsDevice(const char FAR * fname)
BOOL IsShareInstalled(BOOL recheck)
{
extern unsigned char ASMPASCAL share_check(void);
//DebugPrintf(("Share_check at %p and share_installed at %p\n", (void far *)&share_check, (void far *)&share_installed));
if (recheck == FALSE)
return share_installed;
if (!share_installed && share_check() == 0xff)
if (share_check() == 0xff)
share_installed = TRUE;
else
share_installed = FALSE;
return share_installed;
}

View File

@ -36,15 +36,15 @@ segment HMA_TEXT
global _DosIdle_int
global _DosIdle_hlt
extern _InDOS:wrt DGROUP
extern _cu_psp:wrt DGROUP
extern _MachineId:wrt DGROUP
extern critical_sp:wrt DGROUP
extern _user_r:wrt DGROUP
extern _InDOS
extern _cu_psp
extern _MachineId
extern critical_sp
extern _user_r
; variables as the following are "part of" module inthndlr.c
; because of the define MAIN before include globals.h there!
extern _HaltCpuWhileIdle:wrt DGROUP
extern _DGROUP_:wrt HMA_TEXT
extern _HaltCpuWhileIdle
extern _DGROUP_
;
_DosIdle_hlt:
push ds

View File

@ -56,12 +56,12 @@ extern COUNT ASMPASCAL fl_lba_ReadWrite(BYTE drive, WORD mode,
* dap_p);
UWORD ASMPASCAL floppy_change(UWORD);
#ifdef __WATCOMC__
#pragma aux (pascal) fl_reset modify exact [ax dx]
#pragma aux (pascal) fl_diskchanged modify exact [ax dx]
#pragma aux (pascal) fl_setdisktype modify exact [ax bx dx]
#pragma aux (pascal) fl_readkey modify exact [ax]
#pragma aux (pascal) fl_lba_ReadWrite modify exact [ax dx]
#pragma aux (pascal) floppy_change modify exact [ax cx dx]
#pragma aux (__pascal) fl_reset __modify __exact [__ax __dx]
#pragma aux (__pascal) fl_diskchanged __modify __exact [__ax __dx]
#pragma aux (__pascal) fl_setdisktype __modify __exact [__ax __bx __dx]
#pragma aux (__pascal) fl_readkey __modify __exact [__ax]
#pragma aux (__pascal) fl_lba_ReadWrite __modify __exact [__ax __dx]
#pragma aux (__pascal) floppy_change __modify __exact [__ax __cx __dx]
#endif
STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer,
@ -290,7 +290,7 @@ STATIC WORD RWzero(ddt * pddt, UWORD mode)
UWORD done;
return LBA_Transfer(pddt, mode,
(UBYTE FAR *) & DiskTransferBuffer,
(UBYTE FAR *) DiskTransferBuffer,
pddt->ddt_offset, 1, &done);
}
@ -392,7 +392,7 @@ STATIC WORD getbpb(ddt * pddt)
{
/* copy default bpb to be sure that there is no bogus data */
memcpy(pbpbarray, &pddt->ddt_defbpb, sizeof(bpb));
return S_DONE;
return 0;
}
pddt->ddt_descflags &= ~DF_NOACCESS; /* set drive to accessible */
@ -901,7 +901,8 @@ STATIC WORD dskerr(COUNT code)
translate LBA sectors into CHS addressing
*/
STATIC int LBA_to_CHS(ULONG LBA_address, struct CHS *chs, const ddt * pddt)
STATIC int LBA_to_CHS(ULONG LBA_address, struct CHS *chs, const ddt * pddt,
const bpb ** ppbpb)
{
/* we need the defbpb values since those are taken from the
BIOS, not from some random boot sector, except when
@ -926,6 +927,7 @@ STATIC int LBA_to_CHS(ULONG LBA_address, struct CHS *chs, const ddt * pddt)
chs->Cylinder = (UWORD)LBA_address;
chs->Head = hsrem / pbpb->bpb_nsecs;
chs->Sector = hsrem % pbpb->bpb_nsecs + 1;
*ppbpb = pbpb;
return 0;
}
@ -1019,8 +1021,13 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer,
buffer = adjust_far(buffer);
for (; totaltodo != 0;)
{
/* avoid overflowing 64K DMA boundary */
count = DMA_max_transfer(buffer, totaltodo);
count = totaltodo;
if ((pddt->ddt_descflags & DF_DMA_TRANSPARENT) == 0)
{
/* avoid overflowing 64K DMA boundary
for drives that don't handle this transparently */
count = DMA_max_transfer(buffer, totaltodo);
}
if (FP_SEG(buffer) >= 0xa000 || count == 0)
{
@ -1069,15 +1076,15 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer,
}
else
{ /* transfer data, using old bios functions */
if (LBA_to_CHS(LBA_address, &chs, pddt))
const bpb *pbpb;
if (LBA_to_CHS(LBA_address, &chs, pddt, &pbpb))
return 1;
/* avoid overflow at end of track */
if (chs.Sector + count > (unsigned)pddt->ddt_bpb.bpb_nsecs + 1)
if (chs.Sector + count > (unsigned)pbpb->bpb_nsecs + 1)
{
count = pddt->ddt_bpb.bpb_nsecs + 1 - chs.Sector;
count = pbpb->bpb_nsecs + 1 - chs.Sector;
}
error_code = (mode == LBA_READ ? fl_read :

View File

@ -48,7 +48,6 @@ additionally:
/*extern struct DynS FAR Dyn;*/
#ifndef __TURBOC__
#include "init-dat.h"
extern struct DynS DOSFAR ASM Dyn;
#else
extern struct DynS FAR ASM Dyn;

View File

@ -35,20 +35,23 @@ segment HMA_TEXT
extern _int21_syscall
extern _int21_service
extern _int2526_handler
extern _error_tos:wrt DGROUP
extern _char_api_tos:wrt DGROUP
extern _disk_api_tos:wrt DGROUP
extern _user_r:wrt DGROUP
extern _ErrorMode:wrt DGROUP
extern _InDOS:wrt DGROUP
extern _cu_psp:wrt DGROUP
extern _MachineId:wrt DGROUP
extern critical_sp:wrt DGROUP
extern _error_tos
extern _char_api_tos
extern _disk_api_tos
extern _user_r
extern _ErrorMode
extern _InDOS
%IFDEF WIN31SUPPORT
extern _winInstanced
%ENDIF ; WIN31SUPPORT
extern _cu_psp
extern _MachineId
extern critical_sp
extern int21regs_seg:wrt DGROUP
extern int21regs_off:wrt DGROUP
extern int21regs_seg
extern int21regs_off
extern _Int21AX:wrt DGROUP
extern _Int21AX
extern _DGROUP_
@ -236,6 +239,10 @@ reloc_call_int20_handler:
; int21_handler(iregs UserRegs)
;
reloc_call_int21_handler:
cmp ah,25h
je int21_func25
cmp ah,35h
je int21_func35
;
; Create the stack frame for C call. This is done to
; preserve machine state and provide a C structure for
@ -262,12 +269,8 @@ int21_reentry:
mov dx,[cs:_DGROUP_]
mov ds,dx
cmp ah,25h
je int21_user
cmp ah,33h
je int21_user
cmp ah,35h
je int21_user
cmp ah,50h
je int21_user
cmp ah,51h
@ -276,7 +279,9 @@ int21_reentry:
jne int21_1
int21_user:
call dos_crit_sect
%IFNDEF WIN31SUPPORT
call end_dos_crit_sect
%ENDIF ; NOT WIN31SUPPORT
push ss
push bp
@ -285,6 +290,29 @@ int21_user:
pop cx
jmp short int21_ret
int21_func25:
push es
push bx
xor bx,bx
mov es,bx
mov bl,al
shl bx,1
shl bx,1
mov [es:bx],dx
mov [es:bx+2],ds
pop bx
pop es
iret
int21_func35:
xor bx,bx
mov es,bx
mov bl,al
shl bx,1
shl bx,1
les bx,[es:bx]
iret
;
; normal entry, use one of our 4 stacks
;
@ -339,15 +367,27 @@ int21_onerrorstack:
jmp short int21_exit_nodec
int21_2: inc byte [_InDOS]
int21_2:
%IFDEF WIN31SUPPORT ; begin critical section
; should be called as needed, but we just
; mark the whole int21 api as critical
call begin_dos_crit_sect
%ENDIF ; WIN31SUPPORT
inc byte [_InDOS]
mov cx,_char_api_tos
or ah,ah
jz int21_3
%IFDEF WIN31SUPPORT ; testing, this function call crashes
cmp ah,06h
je int21_3
%ENDIF ; WIN31SUPPORT
cmp ah,0ch
jbe int21_normalentry
int21_3:
call dos_crit_sect
%IFNDEF WIN31SUPPORT
call end_dos_crit_sect
%ENDIF ; NOT WIN31SUPPORT
mov cx,_disk_api_tos
int21_normalentry:
@ -366,8 +406,21 @@ int21_normalentry:
push bp
call _int21_service
int21_exit: dec byte [_InDOS]
int21_exit:
%IFDEF WIN31SUPPORT
call end_dos_crit_sect ; release all critical sections
%if 0
push ax
mov ax, 8101h ; Leave Critical Section
int 2ah
pop ax
%endif
%ENDIF ; WIN31SUPPORT
; tiny chance DOS re-entered between clearing InDOS and restoring user stack,
; so we disable interrupts until user stack restored; see SF bug# 215
cli
dec byte [_InDOS]
;
; Recover registers from system call. Registers and flags
; were modified by the system call.
@ -392,11 +445,28 @@ int21_ret:
; ... and return.
;
iret
%IFDEF WIN31SUPPORT
;
; begin DOS Critical Section 1
;
;
begin_dos_crit_sect:
; we only enable critical sections if Windows is active
; we currently use winInstanced, but may need to use separate patchable location
cmp word [_winInstanced], 0
jz skip_crit_sect
push ax
mov ax, 8001h ; Enter Critical Section
int 2ah
pop ax
skip_crit_sect:
ret
%ENDIF ; WIN31SUPPORT
;
; end Dos Critical Section 0 thur 7
;
;
dos_crit_sect:
end_dos_crit_sect:
mov [_Int21AX],ax ; needed!
push ax ; This must be here!!!
mov ah,82h ; re-enrty sake before disk stack

View File

@ -27,24 +27,20 @@
/****************************************************************/
#include "portab.h"
#ifdef VERSION_STRINGS
static BYTE *errorRcsId =
"$Id: error.c 709 2003-09-24 19:34:11Z bartoldeman $";
#endif
#include "globals.h"
#include "debug.h"
#ifdef DEBUG
/* error registers */
VOID dump(void)
{
printf("Register Dump [AH = %02x CS:IP = %04x:%04x FLAGS = %04x]\n",
error_regs.AH, error_regs.CS, error_regs.IP, error_regs.FLAGS);
printf("AX:%04x BX:%04x CX:%04x DX:%04x\n",
error_regs.AX, error_regs.BX, error_regs.CX, error_regs.DX);
printf("SI:%04x DI:%04x DS:%04x ES:%04x\n",
error_regs.SI, error_regs.DI, error_regs.DS, error_regs.ES);
DebugPrintf(("Register Dump [AH = %02x CS:IP = %04x:%04x FLAGS = %04x]\n",
error_regs.AH, error_regs.CS, error_regs.IP, error_regs.FLAGS));
DebugPrintf(("AX:%04x BX:%04x CX:%04x DX:%04x\n",
error_regs.AX, error_regs.BX, error_regs.CX, error_regs.DX));
DebugPrintf(("SI:%04x DI:%04x DS:%04x ES:%04x\n",
error_regs.SI, error_regs.DI, error_regs.DS, error_regs.ES));
}
#endif

View File

@ -51,17 +51,18 @@ segment HMA_TEXT
push si
push ds ; sp=bp-8
lds si,[bp+4] ; ds:si = device header
les bx,[bp+8] ; es:bx = request header
arg {rhp,4}, {dhp,4}
lds si,[.dhp] ; ds:si = device header
les bx,[.rhp] ; es:bx = request header
mov ax, [si+6] ; construct strategy address
mov [bp+4], ax
mov [.dhp], ax
push si ; the bloody fucking RTSND.DOS
push di ; driver destroys SI,DI (tom 14.2.03)
call far[bp+4] ; call far the strategy
call far[.dhp] ; call far the strategy
pop di
pop si
@ -69,8 +70,8 @@ segment HMA_TEXT
; Protect386Registers ; old free-EMM386 versions destroy regs in their INIT method
mov ax,[si+8] ; construct 'interrupt' address
mov [bp+4],ax ; construct interrupt address
call far[bp+4] ; call far the interrupt
mov [.dhp],ax ; construct interrupt address
call far[.dhp] ; call far the interrupt
; Restore386Registers ; less stack load and better performance...

View File

@ -29,10 +29,8 @@
#include "portab.h"
#include "globals.h"
#include "debug.h"
#ifdef VERSION_STRINGS
BYTE *RcsId = "$Id: fatfs.c 1632 2011-06-13 16:29:14Z bartoldeman $";
#endif
/* */
/* function prototypes */
@ -52,7 +50,7 @@ COUNT map_cluster(f_node_ptr, COUNT);
STATIC int shrink_file(f_node_ptr fnp);
/* FAT time notation in the form of hhhh hmmm mmmd dddd (d = double second) */
STATIC time time_encode(struct dostime *t)
STATIC dtime time_encode(struct dostime *t)
{
return (t->hour << 11) | (t->minute << 5) | (t->second >> 1);
}
@ -463,8 +461,9 @@ COUNT dos_rmdir(BYTE * path)
return DE_PATHNOTFND;
/* Directories may have attributes, but if other than 'archive' */
/* then do not allow (RDONLY|SYSTEM|HIDDEN) directory to be deleted. */
if (fnp->f_dir.dir_attrib & ~(D_DIR |D_ARCHIVE))
/* or 'read only' then deny i.e. do not allow (SYSTEM|HIDDEN) */
/* directory to be deleted. */
if (fnp->f_dir.dir_attrib & ~(D_DIR | D_RDONLY | D_ARCHIVE))
return DE_ACCESS;
dir_read(fnp);
@ -665,7 +664,7 @@ STATIC int alloc_find_free(f_node_ptr fnp, char *path)
/* */
/* dos_getdate for the file date */
/* */
date dos_getdate(void)
ddate dos_getdate(void)
{
struct dosdate dd;
@ -678,7 +677,7 @@ date dos_getdate(void)
/* */
/* dos_gettime for the file time */
/* */
time dos_gettime(void)
dtime dos_gettime(void)
{
struct dostime dt;
@ -1244,6 +1243,24 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode)
return 0;
}
/* prevent overwriting beginning of file when write exceeds 4GB,
i.e. when overflow of offset occurs, return error on write */
if (fnp->f_offset + count < fnp->f_offset) /* unsigned overflow */
{
if (mode == XFR_WRITE)
{
#if 1 /* we fail write call even if could partially succeed */
/* can't extend beyond 4G so return '0 byte written, DISK_FULL */
return DE_HNDLDSKFULL;
#else
/* truncate request to max size can write */
ULONG max_count = (ULONG)-1 - fnp->f_offset;
count = (max_count >= (UCOUNT)-1)?(UCOUNT)-1:(UCOUNT)max_count;
#endif
}
/* else XFR_READ should end automatically at EOF */
}
/* The variable secsize will be used later. */
secsize = fnp->f_dpb->dpb_secsize;
@ -1583,13 +1600,17 @@ VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp)
bpb sbpb;
fmemcpy(&sbpb, bpbp, sizeof(sbpb));
for (shftcnt = 0; (sbpb.bpb_nsector >> shftcnt) > 1; shftcnt++)
;
if (sbpb.bpb_nsector == 0) {
shftcnt = 8;
} else {
for (shftcnt = 0; (sbpb.bpb_nsector >> shftcnt) > 1; shftcnt++)
;
}
dpbp->dpb_shftcnt = shftcnt;
dpbp->dpb_mdb = sbpb.bpb_mdesc;
dpbp->dpb_secsize = sbpb.bpb_nbyte;
dpbp->dpb_clsmask = sbpb.bpb_nsector - 1;
dpbp->dpb_clsmask = (sbpb.bpb_nsector - 1) & 0xFF;
dpbp->dpb_fatstrt = sbpb.bpb_nreserved;
dpbp->dpb_fats = sbpb.bpb_nfat;
dpbp->dpb_dirents = sbpb.bpb_ndirent;

View File

@ -226,7 +226,7 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1,
if (ISFAT12(dpbp))
{
REG UBYTE FAR *fbp0, FAR * fbp1;
REG UBYTE FAR *fbp0; REG UBYTE FAR * fbp1;
struct buffer FAR * bp1;
unsigned cluster, cluster2;

View File

@ -90,7 +90,7 @@ BYTE FAR *FatGetDrvData(UBYTE drive, UBYTE * pspc, UWORD * bps, UWORD * nc)
#ifndef IPL
UWORD FcbParseFname(UBYTE *wTestMode, const BYTE FAR * lpFileName, fcb FAR * lpFcb)
{
WORD wRetCodeName = FALSE, wRetCodeExt = FALSE;
WORD wRetCodeDrive = FALSE, wRetCodeName = FALSE, wRetCodeExt = FALSE;
/* pjv -- ExtFcbToFcb? */
@ -105,18 +105,20 @@ UWORD FcbParseFname(UBYTE *wTestMode, const BYTE FAR * lpFileName, fcb FAR * lpF
lpFileName = ParseSkipWh(lpFileName);
/* Now check for drive specification */
/* If drive specified, set to it (when valid) otherwise */
/* If drive specified, set to it otherwise */
/* set to default drive unless leave as-is requested */
if (*(lpFileName + 1) == ':')
/* Undocumented behavior: should keep parsing even if drive */
/* specification is invalid -- tkchia 20220715 */
/* drive specification can refer to an invalid drive, but must */
/* not itself be a file name delimiter! -- tkchia 20220716 */
if (!TestFieldSeps(lpFileName) && *(lpFileName + 1) == ':')
{
/* non-portable construct to be changed */
REG UBYTE Drive = DosUpFChar(*lpFileName) - 'A';
if (get_cds(Drive) == NULL)
{
*wTestMode = PARSE_RET_BADDRIVE;
return FP_OFF(lpFileName);
}
wRetCodeDrive = TRUE;
lpFcb->fcb_drive = Drive + 1;
lpFileName += 2;
@ -163,7 +165,12 @@ UWORD FcbParseFname(UBYTE *wTestMode, const BYTE FAR * lpFileName, fcb FAR * lpF
GetNameField(++lpFileName, (BYTE FAR *) lpFcb->fcb_fext,
FEXT_SIZE, (BOOL *) & wRetCodeExt);
*wTestMode = (wRetCodeName | wRetCodeExt) ? PARSE_RET_WILD : PARSE_RET_NOWILD;
if (wRetCodeDrive)
*wTestMode = PARSE_RET_BADDRIVE;
else if (wRetCodeName | wRetCodeExt)
*wTestMode = PARSE_RET_WILD;
else
*wTestMode = PARSE_RET_NOWILD;
return FP_OFF(lpFileName);
}
@ -510,6 +517,8 @@ UBYTE FcbDelete(xfcb FAR * lpXfcb)
UBYTE FcbRename(xfcb FAR * lpXfcb)
{
BYTE buf[FNAME_SIZE + FEXT_SIZE];
BOOL bWildCard;
rfcb FAR *lpRenameFcb;
COUNT FcbDrive;
UBYTE result = FCB_SUCCESS;
@ -517,7 +526,10 @@ UBYTE FcbRename(xfcb FAR * lpXfcb)
/* Build a traditional DOS file name */
lpRenameFcb = (rfcb FAR *) CommonFcbInit(lpXfcb, SecPathName, &FcbDrive);
/* expand wildcards in dest */
GetNameField(lpRenameFcb->renNewName, buf, FNAME_SIZE, &bWildCard);
GetNameField(lpRenameFcb->renNewExtent, buf + FNAME_SIZE, FEXT_SIZE, &bWildCard);
/* check for a device */
if (IsDevice(SecPathName))
{
@ -526,7 +538,7 @@ UBYTE FcbRename(xfcb FAR * lpXfcb)
else
{
dmatch Dmatch;
COUNT result;
COUNT rc;
wAttr = (lpXfcb->xfcb_flag == 0xff ? lpXfcb->xfcb_attrib : D_ALL);
dta = &Dmatch;
@ -541,6 +553,7 @@ UBYTE FcbRename(xfcb FAR * lpXfcb)
fcb LocalFcb;
BYTE *pToName;
const BYTE FAR *pFromPattern = Dmatch.dm_name;
const char *pToPattern = buf;
int i;
UBYTE mode = 0;
@ -549,21 +562,20 @@ UBYTE FcbRename(xfcb FAR * lpXfcb)
/* I'm cheating because this assumes that the */
/* struct alignments are on byte boundaries */
pToName = LocalFcb.fcb_fname;
pFromPattern = lpRenameFcb->renNewName;
for (i = 0; i < FNAME_SIZE + FEXT_SIZE; i++)
{
if (*pFromPattern != '?')
*pToName = *pFromPattern;
if (*pToPattern != '?')
*pToName = *pToPattern;
pToName++;
pFromPattern++;
pToPattern++;
}
SecPathName[0] = 'A' + FcbDrive - 1;
SecPathName[1] = ':';
strcpy(&SecPathName[2], Dmatch.dm_name);
result = truename(SecPathName, PriPathName, 0);
rc = truename(SecPathName, PriPathName, 0);
if (result < SUCCESS || (result & IS_DEVICE))
if (rc < SUCCESS || (rc & IS_DEVICE))
{
result = FCB_ERROR;
break;
@ -571,8 +583,8 @@ UBYTE FcbRename(xfcb FAR * lpXfcb)
/* now to build a dos name again */
LocalFcb.fcb_drive = FcbDrive;
FcbNameInit(&LocalFcb, loc_szBuffer, &FcbDrive);
result = truename(loc_szBuffer, SecPathName, 0);
if (result < SUCCESS || (result & (IS_NETWORK|IS_DEVICE)) == IS_DEVICE
rc = truename(loc_szBuffer, SecPathName, 0);
if (rc < SUCCESS || (rc & (IS_NETWORK|IS_DEVICE)) == IS_DEVICE
|| DosRenameTrue(PriPathName, SecPathName, wAttr) != SUCCESS)
{
result = FCB_ERROR;
@ -643,17 +655,20 @@ UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First)
/* Next initialze local variables by moving them from the fcb */
lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive);
/* Reconstrct the dirmatch structure from the fcb - doesn't hurt for first */
Dmatch.dm_drive = lpFcb->fcb_sftno;
if (First)
{
/* Reconstruct the dirmatch structure from the fcb */
Dmatch.dm_drive = lpFcb->fcb_sftno;
fmemcpy(Dmatch.dm_name_pat, lpFcb->fcb_fname, FNAME_SIZE + FEXT_SIZE);
DosUpFMem((BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE);
fmemcpy(Dmatch.dm_name_pat, lpFcb->fcb_fname, FNAME_SIZE + FEXT_SIZE);
DosUpFMem((BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE);
Dmatch.dm_attr_srch = wAttr;
Dmatch.dm_entry = lpFcb->fcb_strtclst;
Dmatch.dm_dircluster = lpFcb->fcb_dirclst;
Dmatch.dm_attr_srch = wAttr;
Dmatch.dm_entry = lpFcb->fcb_strtclst;
Dmatch.dm_dircluster = lpFcb->fcb_dirclst;
wAttr = D_ALL;
wAttr = D_ALL;
}
if ((xfcb FAR *) lpFcb != lpXfcb)
{

View File

@ -37,8 +37,8 @@ static BYTE *Globals_hRcsId =
#include "device.h"
#include "mcb.h"
#include "pcb.h"
#include "date.h"
#include "time.h"
#include "ddate.h"
#include "dtime.h"
#include "fat.h"
#include "fcb.h"
#include "tail.h"
@ -156,18 +156,17 @@ typedef BYTE *UPMAP;
/* */
/* External Assembly variables */
/* */
extern struct dhdr
FAR ASM clk_dev, /* Clock device driver */
FAR ASM con_dev, /* Console device driver */
FAR ASM prn_dev, /* Generic printer device driver */
FAR ASM aux_dev, /* Generic aux device driver */
FAR ASM blk_dev; /* Block device (Disk) driver */
extern struct dhdr FAR ASM clk_dev; /* Clock device driver */
extern struct dhdr FAR ASM con_dev; /* Console device driver */
extern struct dhdr FAR ASM prn_dev; /* Generic printer device driver */
extern struct dhdr FAR ASM aux_dev; /* Generic aux device driver */
extern struct dhdr FAR ASM blk_dev; /* Block device (Disk) driver */
extern COUNT *error_tos, /* error stack */
disk_api_tos, /* API handler stack - disk fns */
char_api_tos; /* API handler stack - char fns */
extern BYTE FAR _HMATextAvailable, /* first byte of available CODE area */
FAR _HMATextStart[], /* first byte of HMAable CODE area */
FAR _HMATextEnd[]; /* and the last byte of it */
extern BYTE FAR _HMATextAvailable; /* first byte of available CODE area */
extern BYTE FAR _HMATextStart[]; /* first byte of HMAable CODE area */
extern BYTE FAR _HMATextEnd[]; /* and the last byte of it */
extern
BYTE DosLoadedInHMA; /* if InitHMA has moved DOS up */
@ -236,9 +235,8 @@ extern UWORD ASM first_mcb, /* Start of user memory */
ASM uppermem_root; /* Start of umb chain (usually 9fff) */
extern char * ASM inputptr; /* pointer to unread CON input */
extern sfttbl FAR * ASM sfthead; /* System File Table head */
extern struct dhdr
FAR * ASM clock, /* CLOCK$ device */
FAR * ASM syscon; /* console device */
extern struct dhdr FAR * ASM clock; /* CLOCK$ device */
extern struct dhdr FAR * ASM syscon;/* console device */
extern WORD ASM maxsecsize; /* largest sector size in use (can use) */
extern struct buffer
FAR *ASM firstbuf; /* head of buffers linked list */
@ -270,6 +268,8 @@ extern BYTE ASM ErrorMode, /* Critical error flag */
ASM CritErrClass, ASM VgaSet,
ASM njoined; /* number of joined devices */
extern VOID FAR * ASM setverPtr; /* Pointer to SETVER list */
extern UWORD ASM Int21AX;
extern COUNT ASM CritErrCode;
extern BYTE FAR * ASM CritErrDev;
@ -372,9 +372,9 @@ VOID ASMPASCAL WriteATClock(BYTE *, BYTE, BYTE, BYTE);
VOID ASMPASCAL WritePCClock(ULONG);
intvec getvec(unsigned char);
#ifdef __WATCOMC__
#pragma aux (pascal) ReadPCClock modify exact [ax cx dx]
#pragma aux (pascal) WriteATClock modify exact [ax bx cx dx]
#pragma aux (pascal) WritePCClock modify exact [ax cx dx]
#pragma aux (__pascal) ReadPCClock __modify __exact [__ax __cx __dx]
#pragma aux (__pascal) WriteATClock __modify __exact [__ax __bx __cx __dx]
#pragma aux (__pascal) WritePCClock __modify __exact [__ax __cx __dx]
#endif
/* */
@ -410,12 +410,12 @@ void setvec(unsigned char intno, intvec vector);
/* ^Break handling */
#ifdef __WATCOMC__
#pragma aux (cdecl) spawn_int23 aborts;
#pragma aux (__cdecl) spawn_int23 __aborts;
#endif
void ASMCFUNC spawn_int23(void); /* procsupt.asm */
void ASMCFUNC DosIdle_hlt(void); /* dosidle.asm */
GLOBAL BYTE ReturnAnyDosVersionExpected;
GLOBAL BYTE ASM ReturnAnyDosVersionExpected;
GLOBAL BYTE ASM HaltCpuWhileIdle;
/* near fnodes:

View File

@ -1,3 +1,6 @@
#undef DOSFAR
#undef DOSTEXTFAR
/* Included by initialisation functions */
#if _MSC_VER != 0
@ -20,6 +23,11 @@ extern __segment DosTextSeg;
#define DOSFAR FAR
#define DOSTEXTFAR FAR
#elif defined(__GNUC__)
#define DOSFAR FAR
#define DOSTEXTFAR FAR
#elif !defined(I86)
#define DOSFAR

View File

@ -2,8 +2,8 @@
#define IN_INIT_MOD
#include "version.h"
#include "date.h"
#include "time.h"
#include "ddate.h"
#include "dtime.h"
#include "mcb.h"
#include "sft.h"
#include "fat.h"
@ -16,12 +16,12 @@
#include "tail.h"
#include "process.h"
#include "pcb.h"
#include "nls.h"
#include "buffer.h"
#include "dcb.h"
#include "lol.h"
#include "init-dat.h"
#include "nls.h"
#include "kconfig.h"
@ -38,7 +38,7 @@
#define BSS_INIT(x)
#endif
extern struct _KernelConfig InitKernelConfig;
extern struct _KernelConfig ASM InitKernelConfig;
/*
* Functions in `INIT_TEXT' may need to call functions in `_TEXT'. The entry
@ -57,6 +57,7 @@ extern struct _KernelConfig InitKernelConfig;
#define memset init_memset
#define strchr init_strchr
#define strcpy init_strcpy
#define fstrcpy init_fstrcpy
#define strlen init_strlen
#define fstrlen init_fstrlen
#endif
@ -75,6 +76,7 @@ int ASMPASCAL fmemcmp(const void FAR *m1, const void FAR *m2, size_t n);
VOID ASMPASCAL memcpy( void *d, const void *s, size_t n);
VOID ASMPASCAL fmemcpy( void FAR *d, const void FAR *s, size_t n);
VOID ASMPASCAL strcpy(char *d, const char *s);
VOID ASMPASCAL fstrcpy(char FAR *d, const char FAR *s);
size_t ASMPASCAL strlen(const char *s);
size_t ASMPASCAL fstrlen(const char FAR *s);
char * ASMPASCAL strchr(const char *s, int ch);
@ -82,17 +84,18 @@ char * ASMPASCAL strchr(const char *s, int ch);
#ifdef __WATCOMC__
/* bx, cx, dx and es not used or clobbered for all asmsupt.asm functions except
(f)memchr/(f)strchr (which clobber dx) */
#pragma aux (pascal) pascal_ax modify exact [ax]
#pragma aux (__pascal) pascal_ax __modify __exact [__ax]
#pragma aux (pascal_ax) memset
#pragma aux (pascal_ax) fmemset
#pragma aux (pascal_ax) memcpy
#pragma aux (pascal_ax) fmemcpy
#pragma aux (pascal_ax) memcmp modify nomemory
#pragma aux (pascal_ax) fmemcmp modify nomemory
#pragma aux (pascal_ax) memcmp __modify __nomemory
#pragma aux (pascal_ax) fmemcmp __modify __nomemory
#pragma aux (pascal_ax) strcpy
#pragma aux (pascal_ax) strlen modify nomemory
#pragma aux (pascal_ax) fstrlen modify nomemory
#pragma aux (pascal) strchr modify exact [ax dx] nomemory
#pragma aux (pascal_ax) fstrcpy
#pragma aux (pascal_ax) strlen __modify __nomemory
#pragma aux (pascal_ax) fstrlen __modify __nomemory
#pragma aux (__pascal) strchr __modify __exact [__ax __dx] __nomemory
#endif
#undef LINESIZE
@ -144,7 +147,7 @@ COUNT ASMPASCAL Umb_Test(void);
COUNT ASMPASCAL UMB_get_largest(void FAR * driverAddress,
UCOUNT * seg, UCOUNT * size);
#ifdef __WATCOMC__
#pragma aux (pascal) UMB_get_largest modify exact [ax bx cx dx]
#pragma aux (__pascal) UMB_get_largest __modify __exact [__ax __bx __cx __dx]
#endif
/* inithma.c */
@ -182,18 +185,18 @@ int ASMPASCAL init_switchar(int chr);
void ASMPASCAL keycheck(void);
void ASMPASCAL set_DTA(void far *dta);
#ifdef __WATCOMC__
#pragma aux (pascal) init_call_intr modify exact [ax]
#pragma aux (pascal) read modify exact [ax bx cx dx]
#pragma aux (pascal) init_DosOpen modify exact [ax bx dx]
#pragma aux (pascal) close modify exact [ax bx]
#pragma aux (pascal) dup2 modify exact [ax bx cx]
#pragma aux (pascal) allocmem modify exact [ax bx]
#pragma aux (pascal) init_PSPSet modify exact [ax bx]
#pragma aux (pascal) init_DosExec modify exact [ax bx dx es]
#pragma aux (pascal) init_setdrive modify exact [ax bx dx]
#pragma aux (pascal) init_switchar modify exact [ax bx dx]
#pragma aux (pascal) keycheck modify exact [ax]
#pragma aux (pascal) set_DTA modify exact [ax bx dx]
#pragma aux (__pascal) init_call_intr __modify __exact [__ax]
#pragma aux (__pascal) read __modify __exact [__ax __bx __cx __dx]
#pragma aux (__pascal) init_DosOpen __modify __exact [__ax __bx __dx]
#pragma aux (__pascal) close __modify __exact [__ax __bx]
#pragma aux (__pascal) dup2 __modify __exact [__ax __bx __cx]
#pragma aux (__pascal) allocmem __modify __exact [__ax __bx]
#pragma aux (__pascal) init_PSPSet __modify __exact [__ax __bx]
#pragma aux (__pascal) init_DosExec __modify __exact [__ax __bx __dx __es]
#pragma aux (__pascal) init_setdrive __modify __exact [__ax __bx __dx]
#pragma aux (__pascal) init_switchar __modify __exact [__ax __bx __dx]
#pragma aux (__pascal) keycheck __modify __exact [__ax]
#pragma aux (__pascal) set_DTA __modify __exact [__ax __bx __dx]
#endif
/* irqstack.asm */
@ -201,8 +204,6 @@ VOID ASMCFUNC init_stacks(VOID FAR * stack_base, COUNT nStacks,
WORD stackSize);
/* inthndlr.c */
VOID ASMCFUNC FAR int21_entry(iregs UserRegs);
VOID ASMCFUNC int21_service(iregs far * r);
VOID ASMCFUNC FAR int0_handler(void);
VOID ASMCFUNC FAR int6_handler(void);
VOID ASMCFUNC FAR int19_handler(void);
@ -221,7 +222,11 @@ VOID ASMCFUNC FAR int2f_handler(void);
VOID ASMCFUNC FAR cpm_entry(void);
/* kernel.asm */
#ifdef __GNUC__
VOID ASMCFUNC init_call_p_0(struct config FAR *Config) FAR __attribute__((noreturn));
#else
VOID ASMCFUNC FAR init_call_p_0(struct config FAR *Config); /* P_0, actually */
#endif
/* main.c */
VOID ASMCFUNC FreeDOSmain(void);
@ -249,25 +254,26 @@ extern BYTE ASM _ib_start[], ASM _ib_end[], ASM _init_end[];
extern UWORD ram_top; /* How much ram in Kbytes */
extern char singleStep;
extern char SkipAllConfig;
extern char master_env[128];
extern char FAR ASM master_env[128];
extern struct lol FAR *LoL;
extern struct dhdr DOSTEXTFAR ASM blk_dev; /* Block device (Disk) driver */
extern struct buffer FAR *DOSFAR firstAvailableBuf; /* first 'available' buffer */
extern struct lol ASM FAR DATASTART;
extern struct lol FAR ASM DATASTART;
extern BYTE DOSFAR ASM _HMATextAvailable, /* first byte of available CODE area */
FAR ASM _HMATextStart[], /* first byte of HMAable CODE area */
FAR ASM _HMATextEnd[], DOSFAR ASM break_ena; /* break enabled flag */
extern BYTE DOSFAR ASM _InitTextStart[], /* first available byte of ram */
DOSFAR ASM _InitTextEnd[],
DOSFAR ReturnAnyDosVersionExpected,
DOSFAR ASM HaltCpuWhileIdle;
extern BYTE DOSFAR ASM _HMATextAvailable; /* first byte of available CODE area */
extern BYTE FAR ASM _HMATextStart[]; /* first byte of HMAable CODE area */
extern BYTE FAR ASM _HMATextEnd[];
extern BYTE DOSFAR ASM break_ena; /* break enabled flag */
extern BYTE DOSFAR ASM _InitTextStart[]; /* first available byte of ram */
extern BYTE DOSFAR ASM _InitTextEnd[];
extern BYTE DOSFAR ASM ReturnAnyDosVersionExpected;
extern BYTE DOSFAR ASM HaltCpuWhileIdle;
extern BYTE FAR ASM internal_data[];
extern unsigned char FAR ASM kbdType;
extern BYTE DOSFAR ASM internal_data[];
extern unsigned char DOSTEXTFAR ASM kbdType;
extern struct {
char ThisIsAConstantOne;
@ -275,7 +281,7 @@ extern struct {
struct CountrySpecificInfo C;
} FAR ASM nlsCountryInfoHardcoded;
} DOSFAR ASM nlsCountryInfoHardcoded;
/*
data shared between DSK.C and INITDISK.C
@ -310,21 +316,26 @@ struct RelocatedEntry {
UWORD jmpSegment;
};
extern struct RelocationTable
DOSFAR ASM _HMARelocationTableStart[],
DOSFAR ASM _HMARelocationTableEnd[];
extern struct RelocationTable DOSFAR ASM _HMARelocationTableStart[];
extern struct RelocationTable DOSFAR ASM _HMARelocationTableEnd[];
extern void FAR *DOSFAR ASM XMSDriverAddress;
extern UBYTE DOSFAR ASM XMS_Enable_Patch;
#ifdef __GNUC__
extern VOID ASMPASCAL _EnableA20(VOID) FAR;
extern VOID ASMPASCAL _DisableA20(VOID) FAR;
#else
extern VOID ASMPASCAL FAR _EnableA20(VOID);
extern VOID ASMPASCAL FAR _DisableA20(VOID);
#endif
extern void FAR * ASMPASCAL DetectXMSDriver(VOID);
extern int ASMPASCAL init_call_XMScall(void FAR * driverAddress, UWORD ax,
UWORD dx);
#ifdef __WATCOMC__
#pragma aux (pascal) DetectXMSDriver modify exact [ax dx]
#pragma aux (pascal) _EnableA20 modify exact [ax]
#pragma aux (pascal) _DisableA20 modify exact [ax]
#pragma aux (__pascal) DetectXMSDriver __modify __exact [__ax __dx]
#pragma aux (__pascal) _EnableA20 __modify __exact [__ax]
#pragma aux (__pascal) _DisableA20 __modify __exact [__ax]
#endif
#if defined(WATCOM) && 0

View File

@ -356,7 +356,7 @@ void init_LBA_to_CHS(struct CHS *chs, ULONG LBA_address,
void printCHS(char *title, struct CHS *chs)
{
/* has no fixed size for head/sect: is often 1/1 in our context */
printf("%s%4u-%u-%u", title, chs->Cylinder, chs->Head, chs->Sector);
if (InitKernelConfig.Verbose >= 0) printf("%s%4u-%u-%u", title, chs->Cylinder, chs->Head, chs->Sector);
}
/*
@ -417,7 +417,7 @@ VOID CalculateFATData(ddt * pddt, ULONG NumSectors, UBYTE FileSystem)
* (This is really done in fatfs.c, bpbtodpb) */
{
unsigned clust = (fatdat - 2 * defbpb->bpb_nfsect) / NSECTORFAT12;
unsigned maxclust = (defbpb->bpb_nfsect * 2 * SEC_SIZE) / 3;
unsigned maxclust = (defbpb->bpb_nfsect * 2 * FLOPPY_SEC_SIZE) / 3;
if (maxclust > FAT12MAX)
maxclust = FAT12MAX;
printf("FAT12: #clu=%u, fatlength=%u, maxclu=%u, limit=%u\n",
@ -434,7 +434,7 @@ VOID CalculateFATData(ddt * pddt, ULONG NumSectors, UBYTE FileSystem)
else
{ /* FAT16/FAT32 */
CLUSTER fatlength, maxcl;
unsigned long clust, maxclust;
unsigned long clust, maxclust, rest;
unsigned fatentpersec;
unsigned divisor;
@ -458,7 +458,7 @@ VOID CalculateFATData(ddt * pddt, ULONG NumSectors, UBYTE FileSystem)
defbpb->bpb_ndirent = 0;
defbpb->bpb_nreserved = 0x20;
fatdata = NumSectors - 0x20;
fatentpersec = FLOPPY_SEC_SIZE/4;
fatentpersec = FLOPPY_SEC_SIZE/4; /* how many 32bit FAT values fit in a default 512 byte sector */
maxcl = FAT32MAX;
}
else
@ -473,17 +473,19 @@ VOID CalculateFATData(ddt * pddt, ULONG NumSectors, UBYTE FileSystem)
max FAT16 size for FreeDOS = 4,293,984,256 bytes = 4GiB-983,040 */
if (fatdata > 8386688ul)
fatdata = 8386688ul;
fatentpersec = FLOPPY_SEC_SIZE/2;
fatentpersec = FLOPPY_SEC_SIZE/2; /* how many 16bit FAT values fit in a default 512 byte sector */
maxcl = FAT16MAX;
}
DebugPrintf(("%ld sectors for FAT+data, starting with %d sectors/cluster\n", fatdata, defbpb->bpb_nsector));
DebugPrintf(("%lu sectors for FAT+data, starting with %u sectors/cluster\n", fatdata, defbpb->bpb_nsector));
do
{
DebugPrintf(("Trying with %d sectors/cluster:\n", defbpb->bpb_nsector));
divisor = fatentpersec * defbpb->bpb_nsector + NFAT;
fatlength = (CLUSTER)((fatdata + (2 * defbpb->bpb_nsector + divisor - 1))/
divisor);
DebugPrintf(("Trying with %u sectors/cluster:\n", defbpb->bpb_nsector));
divisor = fatentpersec * defbpb->bpb_nsector + NFAT; /* # of fat entries per cluster + 2 */
rest = (unsigned)(fatdata % divisor);
fatlength = (CLUSTER)(fatdata / divisor);
fatlength += (CLUSTER)((2 * defbpb->bpb_nsector + divisor + rest - 1) / divisor);
/* Need to calculate number of clusters, since the unused parts of the
* FATS and data area together could make up space for an additional,
* not really present cluster. */
@ -492,7 +494,7 @@ VOID CalculateFATData(ddt * pddt, ULONG NumSectors, UBYTE FileSystem)
if (maxclust > maxcl)
maxclust = maxcl;
DebugPrintf(("FAT: #clu=%lu, fatlen=%lu, maxclu=%lu, limit=%lu\n",
clust, fatlength, maxclust, maxcl));
clust, (ULONG)fatlength, maxclust, (ULONG)maxcl));
if (clust > maxclust - 2)
{
clust = 0;
@ -562,10 +564,10 @@ void DosDefinePartition(struct DriveParamS *driveParam,
pddt->ddt_driveno = driveParam->driveno;
pddt->ddt_logdriveno = nUnits;
pddt->ddt_descflags = driveParam->descflags;
/* Turn of LBA if not forced and the partition is within 1023 cyls and of the right type */
/* Turn off LBA if not forced and the partition is within 1023 cyls and of the right type */
/* the FileSystem type was internally converted to LBA_xxxx if a non-LBA partition
above cylinder 1023 was found */
if (!InitKernelConfig.ForceLBA && !ExtLBAForce && !IsLBAPartition(pEntry->FileSystem))
if (!(InitKernelConfig.ForceLBA || IsLBAPartition(pEntry->FileSystem) || ExtLBAForce))
pddt->ddt_descflags &= ~DF_LBA;
pddt->ddt_ncyl = driveParam->chs.Cylinder;
@ -616,7 +618,7 @@ void DosDefinePartition(struct DriveParamS *driveParam,
ExtPri = "Ext";
num = extendedPartNo;
}
printf("\r%c: HD%d, %s[%2d]", 'A' + nUnits,
printf("%c: HD%d, %s[%2d]", 'A' + nUnits,
(driveParam->driveno & 0x7f) + 1, ExtPri, num);
printCHS(", CHS= ", &chs);
@ -629,49 +631,47 @@ void DosDefinePartition(struct DriveParamS *driveParam,
}
/* Get the parameters of the hard disk */
STATIC int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam)
STATIC int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam, int firstPass)
{
iregs regs;
struct _bios_LBA_disk_parameterS lba_bios_parameters;
ExtLBAForce = FALSE;
if (firstPass && (InitKernelConfig.Verbose >= 1))
printf("Checking for LBA support in BIOS for drive %02x\n", drive);
memset(driveParam, 0, sizeof *driveParam);
drive |= 0x80;
/* for tests - disable LBA support,
even if exists */
/* use CHS if LBA support is not enabled by kernel configuration */
if (!InitKernelConfig.GlobalEnableLBAsupport)
{
if (firstPass && (InitKernelConfig.Verbose >= 1)) printf("LBA support disabled.\n");
goto StandardBios;
}
/* check for LBA support */
regs.b.x = 0x55aa;
regs.a.b.h = 0x41;
regs.d.b.l = drive;
regs.flags = FLG_CARRY; /* ensure carry is set to force error if unsupported */
init_call_intr(0x13, &regs);
if (regs.b.x != 0xaa55 || (regs.flags & 0x01))
if ((regs.flags & FLG_CARRY) || regs.b.x != 0xaa55 || !(regs.c.x & 0x01))
{
/* error conditions:
carry set or BX != 0xaa55 => no EDD spec compatible BIOS (LBA extensions not supported)
CX bit 1 is set if BIOS supports fixed disk subset (Disk Address Packet [DAP] subset),
or clear if fixed disk access subset not supported by LBA extensions
*/
goto StandardBios;
}
/* by ralph :
if DAP cannot be used, don't use
LBA
*/
if ((regs.c.x & 1) == 0)
{
goto StandardBios;
}
/* drive supports LBA addressing */
/* version 1.0, 2.0 have different verify */
if (regs.a.x < 0x2100)
LBA_WRITE_VERIFY = 0x4301;
if (regs.a.b.h < 0x21)
LBA_WRITE_VERIFY = 0x4301; /* may be problematic if INT13 is hooked by
different controllers / drivers */
/* query disk size and DMA handling, geometry is queried later by INT13,08 */
memset(&lba_bios_parameters, 0, sizeof(lba_bios_parameters));
lba_bios_parameters.size = sizeof(lba_bios_parameters);
@ -681,45 +681,66 @@ STATIC int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam)
regs.d.b.l = drive;
init_call_intr(0x13, &regs);
/* error or DMA boundary errors not handled transparently */
if (regs.flags & 0x01)
if (regs.flags & FLG_CARRY)
{
/* carry flag set indicates failed LBA disk parameter query */
goto StandardBios;
}
/* verify maximum settings, we can't handle more */
if (lba_bios_parameters.heads > 0xffff ||
lba_bios_parameters.sectors > 0xffff ||
lba_bios_parameters.totalSectHigh != 0)
(lba_bios_parameters.totalSect == 0 &&
lba_bios_parameters.totalSectHigh == 0))
{
printf("Drive is too large to handle, using only 1st 8 GB\n"
" drive %02x heads %lu sectors %lu , total=0x%lx-%08lx\n",
if (firstPass)
{
printf("Suspicious LBA disk parameters, reverting to CHS access:\n");
printf(" drive %02x, heads=%lu, sectors=%lu, total=0x%lx-%08lx\n",
drive,
(ULONG) lba_bios_parameters.heads,
(ULONG) lba_bios_parameters.sectors,
(ULONG) lba_bios_parameters.totalSect,
(ULONG) lba_bios_parameters.totalSectHigh);
}
goto StandardBios;
}
driveParam->total_sectors = lba_bios_parameters.totalSect;
/* restrict disk size to 2TB, because we can not handle more */
if (lba_bios_parameters.totalSectHigh == 0)
{
driveParam->total_sectors = lba_bios_parameters.totalSect;
}
else
{
if (firstPass) printf("Drive %02x is too large to handle, restricted to 2TB\n", drive);
driveParam->total_sectors = 0xffffffffUL;
}
/* if we arrive here, success */
/* if we arrive here, mark drive as LBA capable */
driveParam->descflags = DF_LBA;
if (lba_bios_parameters.information & 8)
driveParam->descflags |= DF_WRTVERIFY;
if (lba_bios_parameters.information & 1)
{
/* DMA boundary errors are handled transparently */
driveParam->descflags |= DF_DMA_TRANSPARENT;
}
StandardBios: /* old way to get parameters */
StandardBios: /* get disk geometry, and if LBA is not enabled, also size */
if (firstPass && (InitKernelConfig.Verbose >= 1))
printf("Retrieving CHS values for drive\n");
regs.a.b.h = 0x08;
regs.d.b.l = drive;
init_call_intr(0x13, &regs);
if (regs.flags & 0x01)
if (regs.flags & 0x01)
{
goto ErrorReturn;
}
/* int13h call returns max value, store as count (#) i.e. +1 for 0 based heads & cylinders */
driveParam->chs.Head = (regs.d.x >> 8) + 1; /* DH = max head value = # of heads - 1 (0-255) */
@ -730,7 +751,8 @@ StandardBios: /* old way to get parameters */
if (driveParam->chs.Sector == 0) {
/* happens e.g. with Bochs 1.x if no harddisk defined */
driveParam->chs.Sector = 63; /* avoid division by zero...! */
printf("BIOS reported 0 sectors/track, assuming 63!\n");
if (firstPass && (InitKernelConfig.Verbose >= 0))
printf("BIOS reported 0 sectors/track, assuming 63!\n");
}
if (!(driveParam->descflags & DF_LBA))
@ -748,9 +770,15 @@ StandardBios: /* old way to get parameters */
driveParam->chs.Head, driveParam->chs.Sector));
DebugPrintf((" total size %luMB\n\n", driveParam->total_sectors / 2048));
ErrorReturn:
return driveParam->driveno;
ErrorReturn:
/* to avoid division by zero later, use some sane defaults */
driveParam->total_sectors = 0;
driveParam->chs.Head = 16;
driveParam->chs.Sector = 63;
return 0;
}
/*
@ -814,10 +842,13 @@ void print_warning_suspect(char *partitionName, UBYTE fs, struct CHS *chs,
{
if (!InitKernelConfig.ForceLBA)
{
printf("WARNING: using suspect partition %s FS %02x:", partitionName, fs);
printCHS(" with calculated values ", chs);
printCHS(" instead of ", pEntry_chs);
printf("\n");
if (InitKernelConfig.Verbose >= 0)
{
printf("WARNING: using suspect partition %s FS %02x:", partitionName, fs);
printCHS(" with calculated values ", chs);
printCHS(" instead of ", pEntry_chs);
printf("\n");
}
}
memcpy(pEntry_chs, chs, sizeof(struct CHS));
}
@ -888,6 +919,7 @@ BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type,
if (chs.Cylinder > 1023 || end.Cylinder > 1023)
{
/* if partition exceeds bounds of CHS addressing but LBA is not supported then skip partition */
if (!(driveParam->descflags & DF_LBA))
{
printf
@ -901,8 +933,11 @@ BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type,
continue;
}
if (!InitKernelConfig.ForceLBA && !ExtLBAForce
&& !IsLBAPartition(pEntry->FileSystem))
/* if partition exceeds bounds of CHS addressing and we can use LBA
but partition type indicates to use CHS then print warning
and force internal filesystem indicator to enable LBA
*/
if (!(InitKernelConfig.ForceLBA || IsLBAPartition(pEntry->FileSystem) || ExtLBAForce))
{
printf
("WARNING: Partition ID does not suggest LBA - part %s FS %02x.\n"
@ -973,6 +1008,11 @@ int Read1LBASector(struct DriveParamS *driveParam, unsigned drive,
for (num_retries = 0; num_retries < N_RETRY; num_retries++)
{
if (InitKernelConfig.Verbose >= 1)
{
printf("retry# %i sector %lu\n", num_retries, LBA_address);
}
regs.d.b.l = drive | 0x80;
LBA_to_CHS(&chs, LBA_address, driveParam);
/* Some old "security" software (PROT) traps int13 and assumes non
@ -982,8 +1022,9 @@ int Read1LBASector(struct DriveParamS *driveParam, unsigned drive,
the extended LBA partition type indicator.
*/
if ((driveParam->descflags & DF_LBA) &&
(InitKernelConfig.ForceLBA || ExtLBAForce || chs.Cylinder > 1023))
(InitKernelConfig.ForceLBA || ExtLBAForce || (chs.Cylinder > 1023)))
{
if (InitKernelConfig.Verbose >= 1) printf("LBA mode\n");
dap.number_of_blocks = 1;
dap.buffer_address = buffer;
dap.block_address_high = 0; /* clear high part */
@ -996,6 +1037,7 @@ int Read1LBASector(struct DriveParamS *driveParam, unsigned drive,
}
else
{ /* transfer data, using old bios functions */
if (InitKernelConfig.Verbose >= 1) printf("CHS mode\n");
/* avoid overflow at end of track */
if (chs.Cylinder > 1023)
@ -1024,6 +1066,7 @@ int Read1LBASector(struct DriveParamS *driveParam, unsigned drive,
/* Load the Partition Tables and get information on all drives */
int ProcessDisk(int scanType, unsigned drive, int PartitionsToIgnore)
{
/* note: error messages are only printed on first call, where (scanType==SCAN_PRIMARYBOOT) */
struct PartTableEntry PTable[4];
ULONG RelSectorOffset;
@ -1038,7 +1081,7 @@ int ProcessDisk(int scanType, unsigned drive, int PartitionsToIgnore)
/* Get the hard drive parameters and ensure that the drive exists. */
/* If there was an error accessing the drive, skip that drive. */
if (!LBA_Get_Drive_Parameters(drive, &driveParam))
if (!LBA_Get_Drive_Parameters(drive, &driveParam,(scanType==SCAN_PRIMARYBOOT)))
{
printf("can't get drive parameters for drive %02x\n", drive);
return PartitionsToIgnore;
@ -1046,6 +1089,9 @@ int ProcessDisk(int scanType, unsigned drive, int PartitionsToIgnore)
RelSectorOffset = 0; /* boot sector */
ExtendedPartitionOffset = 0; /* not found yet */
ExtLBAForce = 0; /* initially we are not dealing with partitions
within a type 0x0E LBA extended partition,
so we do not enforce LBA access by now */
/* Read the Primary Partition Table. */
@ -1072,7 +1118,7 @@ strange_restart:
if (++strangeHardwareLoop < 3)
goto strange_restart;
printf("illegal partition table - drive %02x sector %lu\n", drive,
if (scanType==SCAN_PRIMARYBOOT) printf("illegal partition table - drive %02x sector %lu\n", drive,
RelSectorOffset);
return PartitionsToIgnore;
}
@ -1102,7 +1148,7 @@ strange_restart:
{
RelSectorOffset = ExtendedPartitionOffset + PTable[iPart].RelSect;
if (ExtendedPartitionOffset == 0)
if (ExtendedPartitionOffset == 0) /* first extended in chain? */
{
ExtendedPartitionOffset = PTable[iPart].RelSect;
/* grand parent LBA -> all children and grandchildren LBA */
@ -1313,7 +1359,7 @@ void ReadAllPartitionTables(void)
if (InitKernelConfig.DLASortByDriveNo == 0)
{
/* printf("Drive Letter Assignment - DOS order\n"); */
if (InitKernelConfig.Verbose >= 1) printf("Drive Letter Assignment - DOS order\n");
/* Process primary partition table 1 partition only */
for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++)
@ -1342,13 +1388,13 @@ void ReadAllPartitionTables(void)
{
UBYTE bootdrv = peekb(0,0x5e0);
/* printf("Drive Letter Assignment - sorted by drive\n"); */
if (InitKernelConfig.Verbose >= 1) printf("Drive Letter Assignment - sorted by drive\n");
/* Process primary partition table 1 partition only */
for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++)
{
struct DriveParamS driveParam;
if (LBA_Get_Drive_Parameters(HardDrive, &driveParam) &&
if (LBA_Get_Drive_Parameters(HardDrive, &driveParam, 0) &&
driveParam.driveno == bootdrv)
{
foundPartitions[HardDrive] =
@ -1376,14 +1422,26 @@ void ReadAllPartitionTables(void)
ProcessDisk(SCAN_PRIMARY2, HardDrive, foundPartitions[HardDrive]);
}
}
if (InitKernelConfig.Verbose >= 0)
{
unsigned foundPartitionsCount = 0;
/* Tell user if no valid partitions found on any hard drive */
for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++)
{
foundPartitionsCount += foundPartitions[HardDrive];
}
/* printf("Found %i partitions\n", foundPartitionsCount); */
if (!foundPartitionsCount) printf("No supported partitions found.\n");
}
}
/* disk initialization: returns number of units */
COUNT dsk_init()
{
printf(" - InitDisk");
if (InitKernelConfig.Verbose >= 1) printf("\nInitDisk\n");
#ifdef DEBUG
#if defined(DEBUG) && !defined(DOSEMU) && !defined(DEBUG_PRINT_COMPORT)
{
iregs regs;
regs.a.x = 0x1112; /* select 43 line mode - more space for partinfo */

View File

@ -78,7 +78,7 @@ UWORD HMAFree BSS_INIT(0); /* first byte in HMA not yet used */
STATIC void InstallVDISK(void);
#ifdef DEBUG
#ifdef __TURBOC__
#if defined(__TURBOC__) || defined(__GNUC__)
#define int3() __int__(3);
#else
void int3()
@ -179,6 +179,7 @@ int MoveKernelToHMA()
return FALSE;
XMSDriverAddress = xms_addr;
XMS_Enable_Patch = 0x90; /* must be set after XMSDriverAddress */
#ifdef DEBUG
/* A) for debugging purpose, suppress this,
@ -304,6 +305,7 @@ VOID FAR * HMAalloc(COUNT bytesToAllocate)
unsigned CurrentKernelSegment = 0;
/* relocate segment with HMA_TEXT code group */
void MoveKernel(unsigned NewKernelSegment)
{
UBYTE FAR *HMADest;
@ -311,9 +313,11 @@ void MoveKernel(unsigned NewKernelSegment)
unsigned len;
unsigned jmpseg = CurrentKernelSegment;
/* if the first time called, initialize to end of HMA_TEXT code group segment */
if (CurrentKernelSegment == 0)
CurrentKernelSegment = FP_SEG(_HMATextEnd);
/* if already relocated into HMA, nothing to do */
if (CurrentKernelSegment == 0xffff)
return;
@ -323,6 +327,8 @@ void MoveKernel(unsigned NewKernelSegment)
len = (FP_OFF(_HMATextEnd) | 0x000f) - (FP_OFF(_HMATextStart) & 0xfff0);
/* HMA doesn't start until a paragraph into 0xffff segment */
/* HMA begins with VDISK header to mark area is used */
if (NewKernelSegment == 0xffff)
{
HMASource += HMAOFFSET;
@ -352,7 +358,8 @@ void MoveKernel(unsigned NewKernelSegment)
style table
*/
struct RelocationTable FAR *rp, rtemp;
struct RelocationTable FAR *rp;
struct RelocationTable rtemp;
/* verify, that all entries are valid */

View File

@ -31,9 +31,56 @@
%include "segs.inc"
%include "stacks.inc"
; macro to switch to an internal stack (if necessary), set DS == SS == DGROUP,
; and push the old SS:SP onto the internal stack
;
; destroys AX, SI, BP; turns on IRQs
;
; int2f does not really need to switch to a separate stack for MS-DOS
; compatibility; this is mainly to work around the C code's assumption
; that SS == DGROUP
;
; TODO: remove the need for this hackery -- tkchia
%macro SwitchToInt2fStack 0
mov ax,[cs:_DGROUP_]
mov ds,ax
mov si,ss
mov bp,sp
cmp ax,si
jz %%already
cli
mov ss,ax
extern int2f_stk_top
mov sp,int2f_stk_top
sti
%%already:
; well, GCC does not currently clobber function parameters passed on the
; stack; but just in case it decides to do that in the future, we push _two_
; copies of the old SS:SP:
; - the second copy can be passed as a pointer parameter to a C function
; - the first copy is used to actually restore the user stack later
push si
push bp
push si
push bp
%endmacro
; macro to switch back from an internal stack, i.e. undo SwitchToInt2fStack
;
; destroys BP; turns on IRQs -- tkchia
%macro DoneInt2fStack 0
pop bp
pop bp
pop bp
cli
pop ss
mov sp,bp
sti
%endmacro
segment HMA_TEXT
extern _cu_psp:wrt DGROUP
extern _HaltCpuWhileIdle:wrt DGROUP
extern _cu_psp
extern _HaltCpuWhileIdle
extern _syscall_MUX14
extern _DGROUP_
@ -75,10 +122,14 @@ WinIdle: ; only HLT if at haltlevel 2+
Int2f3: cmp ax,1680h ; Win "release time slice"
je WinIdle
cmp ah,16h
je FarTabRetn ; other Win Hook return fast
cmp ah,12h
je IntDosCal ; Dos Internal calls
cmp ah,13h
je IntDosCal ; Install Int13h Hook
cmp ah,16h
je IntDosCal ; Win (Multitasking) Hook
cmp ah,46h
je IntDosCal ; Win Hook to avoid MCB corruption
cmp ax,4a01h
je IntDosCal ; Dos Internal calls
@ -88,6 +139,9 @@ Int2f3: cmp ax,1680h ; Win "release time slice"
cmp ax,4a33h ; Check DOS version 7
jne Check4Share
xor ax,ax ; no undocumented shell strings
xor bx,bx ; RBIL undoc BX = ?? (0h)
; " DS:DX ASCIIZ shell exe name
; " DS:SI SHELL= line
iret
Check4Share:
%endif
@ -102,8 +156,9 @@ Int2f?14: ;; MUX-14 -- NLSFUNC API
push bp ; Preserve BP later on
Protect386Registers
PUSH$ALL
mov ds, [cs:_DGROUP_]
SwitchToInt2fStack
call _syscall_MUX14
DoneInt2fStack
pop bp ; Discard incoming AX
push ax ; Correct stack for POP$ALL
POP$ALL
@ -123,9 +178,9 @@ Int2f?iret:
; DRIVER.SYS calls - now only 0803.
DriverSysCal:
extern _Dyn:wrt DGROUP
extern _Dyn
cmp al, 3
jne Int2f?iret
jne IntDosCal ; pass other calls through
mov ds, [cs:_DGROUP_]
mov di, _Dyn+2
jmp short Int2f?iret
@ -135,7 +190,7 @@ DriverSysCal:
; internal dos calls INT2F/12xx and INT2F/4A01,4A02 - handled through C
;**********************************************************************
IntDosCal:
; set up register frame
; set up register structure
;struct int2f12regs
;{
; [space for 386 regs]
@ -165,9 +220,10 @@ IntDosCal:
%endif
%endif
mov ds,[cs:_DGROUP_]
SwitchToInt2fStack
extern _int2F_12_handler
call _int2F_12_handler
DoneInt2fStack
%if XCPU >= 386
%ifdef WATCOM
@ -194,6 +250,7 @@ IntDosCal:
SHARE_CHECK:
mov ax, 0x1000
int 0x2f
test ax, "US" ; Uninstallable SHARE signature
ret
; DOS calls this to see if it's okay to open the file.
@ -202,7 +259,7 @@ SHARE_CHECK:
; error. If < 0 is returned, it is the negated error return
; code, so DOS simply negates this value and returns it in
; AX.
; STATIC int share_open_check(char * filename,
; STATIC int share_open_check(const char FAR * filename,
; /* pointer to fully qualified filename */
; unsigned short pspseg,
; /* psp segment address of owner process */
@ -211,16 +268,17 @@ SHARE_CHECK:
; int sharemode) /* SHARE_COMPAT, etc... */
global SHARE_OPEN_CHECK
SHARE_OPEN_CHECK:
mov es, si ; save si
push ds
pop es ; save ds
mov di, si ; save si
pop ax ; return address
pop dx ; sharemode;
pop cx ; openmode;
pop bx ; pspseg;
pop si ; filename
popargs {ds,si},bx,cx,dx; filename,pspseg,openmode,sharemode;
push ax ; return address
mov ax, 0x10a0
int 0x2f ; returns ax
mov si, es ; restore si
mov si, di ; restore si
push es
pop ds ; restore ds
ret
; DOS calls this to record the fact that it has successfully
@ -261,12 +319,13 @@ share_common:
mov bp, sp
push si
push di
mov bx, [bp + 16] ; pspseg
mov cx, [bp + 14] ; fileno
mov si, [bp + 12] ; high word of ofs
mov di, [bp + 10] ; low word of ofs
les dx, [bp + 6] ; len
or ax, [bp + 4] ; allowcriter/unlock
arg pspseg, fileno, {ofs,4}, {len,4}, allowcriter
mov bx, [.pspseg] ; pspseg
mov cx, [.fileno] ; fileno
mov si, [.ofs+2] ; high word of ofs
mov di, [.ofs] ; low word of ofs
les dx, [.len] ; len
or ax, [.allowcriter] ; allowcriter/unlock
int 0x2f
pop di
pop si
@ -288,6 +347,25 @@ SHARE_LOCK_UNLOCK:
mov ax,0x10a4
jmp short share_common
; DOS calls this to see if share already has the file marked as open.
; Returns:
; 1 if open
; 0 if not
; STATIC WORD share_is_file_open(const char far *filename) /* pointer to fully qualified filename */
global SHARE_IS_FILE_OPEN
SHARE_IS_FILE_OPEN:
mov si, ds
mov es, si ; save ds
pop ax ; save return address
pop si ; filename
pop ds ; SEG filename
push ax ; restore return address
mov ax, 0x10a6
int 0x2f ; returns ax
mov si, es ; restore ds
mov ds, si
ret
; Int 2F Multipurpose Remote System Calls
;
; added by James Tabor jimtabor@infohwy.com
@ -323,10 +401,8 @@ remote_lock_unlock:
global NETWORK_REDIRECTOR_MX
NETWORK_REDIRECTOR_MX:
pop bx ; ret address
pop cx ; stack value (arg); cx in remote_rw
pop dx ; off s
pop es ; seg s
pop ax ; cmd (ax)
popargs ax,{es,dx},cx ; cmd (ax), seg:off s
; stack value (arg); cx in remote_rw
push bx ; ret address
call_int2f:
push bp
@ -352,6 +428,8 @@ call_int2f:
push cx ; arg
cmp al, 0ch
je remote_getfree
cmp al, 0xa3
je remote_getfree
cmp al, 1eh
je remote_print_doredir
cmp al, 1fh
@ -402,6 +480,7 @@ remote_getfree:
mov [di+2],bx
mov [di+4],cx
mov [di+6],dx
mov [di+8],si ; for REM_GETLARGEFREE, unused on REM_GETFREE
jmp short ret_set_ax_to_carry
remote_rw:
@ -431,7 +510,7 @@ int2f_restore_ds:
; extern UWORD ASMPASCAL call_nls(UWORD bp, UWORD FAR *buf,
; UWORD subfct, UWORD cp, UWORD cntry, UWORD bufsize);
extern _nlsInfo:wrt DGROUP
extern _nlsInfo
global CALL_NLS
CALL_NLS:
pop es ; ret addr
@ -497,7 +576,8 @@ FLOPPY_CHANGE:
segment INIT_TEXT
; int ASMPASCAL UMB_get_largest(void FAR * driverAddress,
; UCOUNT * seg, UCOUNT * size);
global UMB_GET_LARGEST
arg {driverAddress,4}, argseg, size
global UMB_GET_LARGEST
UMB_GET_LARGEST:
push bp
@ -505,7 +585,7 @@ UMB_GET_LARGEST:
mov dx,0xffff ; go for broke!
mov ax,1000h ; get the UMBs
call far [bp+8] ; Call the driver
call far [.driverAddress] ; Call the driver
;
; bl = 0xB0 and ax = 0 so do it again.
@ -517,7 +597,7 @@ UMB_GET_LARGEST:
je umbt_error
mov ax,1000h ; dx set with largest size
call far [bp+8] ; Call the driver
call far [.driverAddress] ; Call the driver
cmp ax,1
jne umbt_error
@ -525,10 +605,10 @@ UMB_GET_LARGEST:
; and the size
mov cx,bx ; *seg = segment
mov bx, [bp+6]
mov bx, [.argseg]
mov [bx],cx
mov bx, [bp+4] ; *size = size
mov bx, [.size] ; *size = size
mov [bx],dx
umbt_ret:

File diff suppressed because it is too large Load Diff

View File

@ -26,8 +26,9 @@
;
%include "segs.inc"
%include "stacks.inc"
%macro INTR 0
%macro INTR 1
push bp ; Standard C entry
mov bp,sp
@ -40,12 +41,18 @@
push es
%endif
push ds
pushf
mov ax, [bp+6] ; interrupt number
arg nr, {rp,%1}
mov ax, [.nr] ; interrupt number
mov [cs:%%intr_1-1], al
jmp short %%intr_2 ; flush the instruction cache
%%intr_2 mov bx, [bp+4] ; regpack structure
mov ax, [bx]
%%intr_2:
%if %1 == 4
lds bx, [.rp] ; regpack structure FAR
%else
mov bx, [.rp] ; regpack structure
%endif
mov cx, [bx+4]
mov dx, [bx+6]
mov si, [bx+8]
@ -53,6 +60,9 @@
mov bp, [bx+12]
push word [bx+14] ; ds
mov es, [bx+16]
mov ah, byte [bx+22] ; flags
sahf
mov ax, [bx]
mov bx, [bx+2]
pop ds
int 0
@ -62,23 +72,33 @@
push ds
push bx
mov bx, sp
mov ds, [ss:bx+6]
%if %1 == 4
%ifdef WATCOM
mov bx, [ss:bx+24] ; address of REGPACK
lds bx, [ss:bx+(14+8)+4] ; FAR address of REGPACK, pascal convention
%else
mov bx, [ss:bx+16] ; address of REGPACK
lds bx, [ss:bx+14+.rp-bp] ; FAR address of REGPACK, SP=BX + skip saved registers (14) +
%endif
%else
mov ds, [ss:bx+8]
%ifdef WATCOM
mov bx, [ss:bx+26] ; NEAR address of REGPACK, pascal convention
%else
mov bx, [ss:bx+14+.rp-bp] ; NEAR address of REGPACK
%endif
%endif
mov [bx], ax
pop word [bx+2]
pop word [bx+2] ; bx
mov [bx+4], cx
mov [bx+6], dx
mov [bx+8], si
mov [bx+10], di
mov [bx+12], bp
pop word [bx+14]
pop word [bx+14] ; ds
mov [bx+16], es
pop word [bx+22]
pop word [bx+22] ; flags
; restore all registers to values from INTR entry
popf
pop ds
%ifdef WATCOM
pop es
@ -89,18 +109,23 @@
pop di
pop si
pop bp
ret 4
%endmacro
segment HMA_TEXT
;
; void ASMPASCAL call_intr(WORD nr, struct REGPACK FAR *rp)
;
global CALL_INTR
CALL_INTR:
INTR 4 ; rp is far, DWORD argument
ret 6
;; COUNT ASMPASCAL res_DosExec(COUNT mode, exec_blk * ep, BYTE * lp)
global RES_DOSEXEC
RES_DOSEXEC:
pop es ; ret address
pop dx ; filename
pop bx ; exec block
pop ax ; mode
popargs ax,bx,dx ; mode, exec block, filename
push es ; ret address
mov ah, 4bh
push ds
@ -115,9 +140,7 @@ no_exec_error:
global RES_READ
RES_READ:
pop ax ; ret address
pop cx ; count
pop dx ; buf
pop bx ; fd
popargs bx,dx,cx ; fd, buf, count
push ax ; ret address
mov ah, 3fh
int 21h
@ -134,7 +157,8 @@ segment INIT_TEXT
;
global INIT_CALL_INTR
INIT_CALL_INTR:
INTR
INTR 2 ; rp is near, WORD argument
ret 4
;
; int init_call_XMScall( (WORD FAR * driverAddress)(), WORD AX, WORD DX)
@ -144,10 +168,7 @@ INIT_CALL_INTR:
global INIT_CALL_XMSCALL
INIT_CALL_XMSCALL:
pop bx ; ret address
pop dx
pop ax
pop cx ; driver address
pop es
popargs {es,cx},ax,dx
push cs ; ret address
push bx
@ -190,8 +211,7 @@ KEYCHECK:
INIT_DOSOPEN:
;; init calling DOS through ints:
pop bx ; ret address
pop ax ; flags
pop dx ; pathname
popargs dx,ax ; pathname, flags
push bx ; ret address
mov ah, 3dh
;; AX will have the file handle
@ -216,9 +236,7 @@ CLOSE:
global READ
READ:
pop ax ; ret address
pop cx ; count
pop dx ; buf
pop bx ; fd
popargs bx,dx,cx ; fd,buf,count
push ax ; ret address
mov ah, 3fh
jmp short common_int21
@ -227,8 +245,7 @@ READ:
global DUP2
DUP2:
pop ax ; ret address
pop cx ; newfd
pop bx ; oldfd
popargs bx,cx ; oldfd,newfd
push ax ; ret address
mov ah, 46h
jmp short common_int21
@ -239,9 +256,7 @@ DUP2:
global LSEEK
LSEEK:
pop ax ; ret address
pop dx ; position low
pop cx ; position high
pop bx ; fd
popargs bx,{cx,dx} ; fd, position high:low
push ax ; ret address
mov ax,4200h ; origin: start of file
int 21h
@ -265,9 +280,7 @@ INIT_PSPSET:
global INIT_DOSEXEC
INIT_DOSEXEC:
pop es ; ret address
pop dx ; filename
pop bx ; exec block
pop ax ; mode
popargs ax,bx,dx ; mode, exec block, filename
push es ; ret address
mov ah, 4bh
push ds
@ -313,8 +326,7 @@ ALLOCMEM:
global SET_DTA
SET_DTA:
pop ax ; ret address
pop bx ; seg(dta)
pop dx ; off(dta)
popargs {bx,dx} ; seg:off(dta)
push ax ; ret address
mov ah, 1ah
push ds

View File

@ -31,18 +31,18 @@
%include "segs.inc"
%include "stacks.inc"
extern ConTable:wrt LGROUP
extern LptTable:wrt LGROUP
extern ComTable:wrt LGROUP
extern uPrtNo:wrt LGROUP
extern CommonNdRdExit:wrt LGROUP
;!! extern _NumFloppies:wrt DGROUP
extern blk_stk_top:wrt DGROUP
extern clk_stk_top:wrt DGROUP
extern ConTable
extern LptTable
extern ComTable
extern uPrtNo
extern CommonNdRdExit
;!! extern _NumFloppies
extern blk_stk_top
extern clk_stk_top
extern _reloc_call_blk_driver
extern _reloc_call_clk_driver
extern _TEXT_DGROUP:wrt LGROUP
extern _TEXT_DGROUP
;---------------------------------------------------
;
@ -212,6 +212,7 @@ uUnitNumber dw 0
; at any time. The request is stored into memory in the one and only
; location available for that purpose.
;
global GenStrategy
GenStrategy:
mov word [cs:_ReqPktPtr],bx
mov word [cs:_ReqPktPtr+2],es
@ -500,12 +501,12 @@ GetUnitNum:
blk_driver_params:
dw blk_stk_top
dw _reloc_call_blk_driver
dw seg _reloc_call_blk_driver
dw DGROUP
clk_driver_params:
dw clk_stk_top
dw _reloc_call_clk_driver
dw seg _reloc_call_clk_driver
dw DGROUP
; clock device interrupt
clk_entry:

View File

@ -49,12 +49,12 @@
%define E_FAILURE 12 ; General Failure
extern _IOExit:wrt LGROUP
extern _IOSuccess:wrt LGROUP
extern _IOErrorExit:wrt LGROUP
extern _IOErrCnt:wrt LGROUP
extern _IODone:wrt LGROUP
extern _IOCommandError:wrt LGROUP
extern GetUnitNum:wrt LGROUP
extern _ReqPktPtr:wrt LGROUP
extern _IOExit
extern _IOSuccess
extern _IOErrorExit
extern _IOErrCnt
extern _IODone
extern _IOCommandError
extern GetUnitNum
extern _ReqPktPtr

View File

@ -114,10 +114,10 @@ int DosDevIOctl(lregs * r)
{
case 0x00:
/* Get the flags from the SFT */
r->AX = flags & 0xff;
if (flags & SFT_FDEVICE)
r->AX = (flags & 0xff) | (s->sft_dev->dh_attr & 0xff00);
else
r->AX = flags;
r->AX |= (s->sft_dev->dh_attr & 0xff00);
/* else: files/networks return 0 in AH/DH */
/* Undocumented result, Ax = Dx seen using Pcwatch */
r->DX = r->AX;
return SUCCESS;

View File

@ -29,12 +29,13 @@
;
%include "segs.inc"
%include "stacks.inc"
%include "ludivmul.inc"
segment PSP
extern _ReqPktPtr:wrt LGROUP
extern _ReqPktPtr
STACK_SIZE equ 384/2 ; stack allocated in words
@ -42,8 +43,11 @@ STACK_SIZE equ 384/2 ; stack allocated in words
; KERNEL BEGINS HERE, i.e. this is byte 0 of KERNEL.SYS
;************************************************************
%ifidn __OUTPUT_FORMAT__, obj
..start:
entry:
%endif
bootloadunit: ; (byte of short jump re-used)
entry:
jmp short realentry
;************************************************************
@ -53,6 +57,7 @@ entry:
;************************************************************
global _LowKernelConfig
_LowKernelConfig:
config_signature:
db 'CONFIG' ; constant
dw configend-configstart; size of config area
; to be checked !!!
@ -69,10 +74,26 @@ BootHarddiskSeconds db 0 ;
; The following VERSION resource must be keep in sync with VERSION.H
Version_OemID db 0xFD ; OEM_ID
Version_Major db 2
Version_Revision dw 41 ; REVISION_SEQ
Version_Revision dw 43 ; REVISION_SEQ
Version_Release dw 1 ; 0=release build, >0=svn#
CheckDebugger: db 0 ; 0 = no check, 1 = check, 2 = assume present
Verbose db 0 ; -1 = quiet, 0 = normal, 1 = verbose
PartitionMode db 0x1f ; bits 0-1: 01=GPT if found, 00=MBR if found, 11=Hybrid, GPT first then MBR, 10=Hybrid, MBR first then GPT
; in hybrid mode, EE partitions ignored, drives assigned by GPT or MBR first based on hybrid type
; bits 2-4: 001=mount ESP (usually FAT32) partition, 010=mount MS Basic partitions, 100=mount unknown partitions
; 111=attempt to mount all paritions, 110=attempt to mount all but ESP partitions
; bits 5-7: reserved, 0 else undefined behavior
configend:
kernel_config_size: equ configend - config_signature
; must be below-or-equal the size of struct _KernelConfig
; in the file kconfig.h !
times (32 - 4) - ($ - $$) db 0
bootloadstack: dd 0
;************************************************************
; KERNEL CONFIGURATION AREA END
@ -91,8 +112,21 @@ configend:
cpu 8086 ; (keep initial entry compatible)
global realentry
realentry: ; execution continues here
push cs
pop ds
xor di, di
mov byte [di + bootloadunit - $$], bl
push bp
mov word [di + bootloadstack - $$], sp
mov word [di + bootloadstack + 2 - $$], ss
jmp entry_common
times 0C0h - ($ - $$) nop ; magic offset (used by exeflat)
entry_common:
%ifndef QUIET
push ax
push bx
pushf
@ -102,13 +136,36 @@ realentry: ; execution continues here
popf
pop bx
pop ax
%endif
jmp far kernel_start
beyond_entry: resb 256-(beyond_entry-entry)
push cs
pop ds
jmp IGROUP:kernel_start
beyond_entry: times 256-(beyond_entry-entry) db 0
; scratch area for data (DOS_PSP)
_master_env equ $ - 128
global _master_env
segment INIT_TEXT
%ifdef TEST_FILL_INIT_TEXT
%macro step 0
%if _LFSR & 1
%assign _LFSR (_LFSR >> 1) ^ 0x80200003
%else
%assign _LFSR (_LFSR >> 1)
%endif
%endmacro
align 16
%assign _LFSR 1
%rep 1024 * 8
dd _LFSR
step
%endrep
%endif
extern _FreeDOSmain
extern _query_cpu
@ -116,7 +173,9 @@ segment INIT_TEXT
; kernel start-up
;
kernel_start:
cld
%ifndef QUIET
push bx
pushf
mov ax, 0e32h ; '2' Tracecode - kernel entered
@ -124,32 +183,78 @@ kernel_start:
int 010h
popf
pop bx
%endif
extern _kernel_command_line
; INP: ds => entry section, with CONFIG block
; and compressed entry help data
; (actually always used now)
initialise_command_line_buffer:
mov dx, I_GROUP
mov es, dx
mov bl, [bootloadunit]
lds si, [bootloadstack] ; -> original ss:sp - 2
lea ax, [si + 2] ; ax = original sp
mov si, word [si] ; si = original bp
; Note that the kernel command line buffer in
; the init data segment is pre-initialised to
; hold 0x00 0xFF in the first two bytes. This
; is used to indicate no command line present,
; as opposed to an empty command line which
; will hold 0x00 0x00.
; If any of the branches to .none are taken then
; the buffer is not modified so it retains the
; 0x00 0xFF contents.
cmp si, 114h ; buffer fits below ss:bp ?
jb .none ; no -->
cmp word [si - 14h], "CL" ; signature passed to us ?
jne .none ; no -->
lea si, [si - 114h] ; -> command line buffer
cmp ax, si ; stack top starts below-or-equal buffer ?
ja .none ; no -->
mov di, _kernel_command_line ; our buffer
mov cx, 255
xor ax, ax
push di
rep movsb ; copy up to 255 bytes
stosb ; truncate
pop di
mov ch, 1 ; cx = 256
repne scasb ; scan for terminator
rep stosb ; clear remainder of buffer
; (make sure we do not have 0x00 0xFF
; even if the command line given is
; actually the empty string)
.none:
mov ax,seg init_tos
cli
mov ss,ax
mov sp,init_tos
mov ss, dx
mov sp, init_tos
int 12h ; move init text+data to higher memory
mov cl,6
shl ax,cl ; convert kb to para
mov dx,15 + init_end wrt INIT_TEXT
mov dx,15 + INITSIZE
mov cl,4
shr dx,cl
sub ax,dx
mov es,ax
mov dx,__INIT_DATA_START wrt INIT_TEXT ; para aligned
mov dx,INITTEXTSIZE ; para aligned
shr dx,cl
add ax,dx
mov ss,ax ; set SS to init data segment
sti ; now enable them
mov ax,cs
mov dx,__InitTextStart wrt HMA_TEXT ; para aligned
mov dx,__HMATextEnd ; para aligned
shr dx,cl
%ifdef WATCOM
add ax,dx
%endif
mov ds,ax
mov si,-2 + init_end wrt INIT_TEXT ; word aligned
mov si,-2 + INITSIZE; word aligned
lea cx,[si+2]
mov di,si
shr cx,1
@ -163,7 +268,7 @@ kernel_start:
sub ax,dx
mov es,ax ; es = new HMA_TEXT
mov si,-2 + __InitTextStart wrt HMA_TEXT
mov si,-2 + __HMATextEnd
lea cx,[si+2]
mov di,si
shr cx,1
@ -182,6 +287,7 @@ cont: ; Now set up call frame
mov ds,[cs:_INIT_DGROUP]
mov bp,sp ; and set up stack frame for c
%ifndef QUIET
push bx
pushf
mov ax, 0e33h ; '3' Tracecode - kernel entered
@ -189,6 +295,7 @@ cont: ; Now set up call frame
int 010h
popf
pop bx
%endif
mov byte [_BootDrive],bl ; tell where we came from
@ -209,11 +316,43 @@ cont: ; Now set up call frame
cpu XCPU
%endif
mov [_CPULevel], al
mov ax,ss
mov ds,ax
mov es,ax
jmp _FreeDOSmain
initialise_kernel_config:
extern _InitKernelConfig
mov ax, ss ; => init data segment
mov si, 60h
mov ds, si ; => entry section
mov si, _LowKernelConfig ; -> our CONFIG block
mov es, ax ; => init data segment
mov di, _InitKernelConfig ; -> init's CONFIG block buffer
mov cx, kernel_config_size / 2 ; size that we support
rep movsw ; copy it over
%if kernel_config_size & 1
movsb ; allow odd size
%endif
mov ds, ax ; => init data segment
check_debugger_present:
extern _debugger_present
mov al, 1 ; assume debugger present
cmp byte [di - kernel_config_size + (CheckDebugger - config_signature)], 1
ja .skip_ints_00_06 ; 2 means assume present
jb .absent ; 0 means assume absent
clc ; 1 means check
int3 ; break to debugger
jc .skip_ints_00_06
; The debugger should set CY here to indicate its
; presence. The flag set is checked later to skip
; overwriting the interrupt vectors 00h, 01h, 03h,
; and 06h. This logic is taken from lDOS init.
.absent:
xor ax, ax ; no debugger present
.skip_ints_00_06:
mov byte [_debugger_present], al
jmp _FreeDOSmain
%if XCPU != 86
cpu 8086
@ -287,10 +426,9 @@ segment CONST
; NUL device strategy
;
global _nul_strtgy
extern GenStrategy
_nul_strtgy:
mov word [cs:_ReqPktPtr],bx ;save rq headr
mov word [cs:_ReqPktPtr+2],es
retf
jmp LGROUP:GenStrategy
;
; NUL device interrupt
@ -299,7 +437,9 @@ _nul_strtgy:
_nul_intr:
push es
push bx
les bx,[cs:_ReqPktPtr] ;es:bx--> rqheadr
mov bx,LGROUP
mov es,bx
les bx,[es:_ReqPktPtr] ;es:bx--> rqheadr
cmp byte [es:bx+2],4 ;if read, set 0 read
jne no_nul_read
mov word [es:bx+12h],0
@ -316,14 +456,22 @@ segment _LOWTEXT
global _intvec_table
_intvec_table: db 10h
dd 0
; used by int13 handler and get/set via int 2f/13h
global _BIOSInt13 ; BIOS provided disk handler
global _UserInt13 ; actual disk handler used by kernel
db 13h
dd 0
_BIOSInt13: dd 0
db 15h
dd 0
; used for cleanup on reboot
global _BIOSInt19
db 19h
dd 0
_BIOSInt19: dd 0
db 1Bh
dd 0
; default to using BIOS provided disk handler
db 13h
_UserInt13: dd 0
; floppy parameter table
global _int1e_table
@ -371,13 +519,13 @@ _first_mcb dw 0 ;-0002 Start of user memory
global MARK0026H
; A reference seems to indicate that this should start at offset 26h.
MARK0026H equ $
_DPBp dd 0 ; 0000 First drive Parameter Block
_DPBp dd -1 ; 0000 First drive Parameter Block
global _sfthead
_sfthead dd 0 ; 0004 System File Table head
global _clock
_clock dd 0 ; 0008 CLOCK$ device
global _syscon
_syscon dw _con_dev,seg _con_dev ; 000c console device
_syscon dw _con_dev,LGROUP ; 000c console device
global _maxsecsize
_maxsecsize dw 512 ; 0010 maximum bytes/sector of any block device
dd 0 ; 0012 pointer to buffers info structure
@ -393,8 +541,8 @@ _nblkdev db 0 ; 0020 number of block devices
_lastdrive db 0 ; 0021 value of last drive
global _nul_dev
_nul_dev: ; 0022 device chain root
extern _con_dev:wrt LGROUP
dw _con_dev, seg _con_dev
extern _con_dev
dw _con_dev, LGROUP
; next is con_dev at init time.
dw 8004h ; attributes = char device, NUL bit set
dw _nul_strtgy
@ -402,8 +550,9 @@ _nul_dev: ; 0022 device chain root
db 'NUL '
global _njoined
_njoined db 0 ; 0034 number of joined devices
dw 0 ; 0035 DOS 4 pointer to special names (always zero in DOS 5)
setverPtr dw 0,0 ; 0037 setver list
dw 0 ; 0035 DOS 4 near pointer to special names (always zero in DOS 5) [setver precursor]
global _setverPtr
_setverPtr dw 0,0 ; 0037 setver list (far pointer, set by setver driver)
dw 0 ; 003B cs offset for fix a20
dw 0 ; 003D psp of last umb exec
global _LoL_nbuffers
@ -472,13 +621,26 @@ _winStartupInfo:
dd 0 ; next startup info structure, 0:0h marks end
dd 0 ; far pointer to name virtual device file or 0:0h
dd 0 ; far pointer, reference data for virtual device driver
%ifnidni __OUTPUT_FORMAT__, elf
dw instance_table,seg instance_table ; array of instance data
%else
dw instance_table ; array of instance data
global _winseg1
_winseg1: dw 0
%endif
instance_table: ; should include stacks, Win may auto determine SDA region
; we simply include whole DOS data segment
dw 0, seg _DATASTART ; [SEG:OFF] address of region's base
dw markEndInstanceData wrt seg _DATASTART ; size in bytes
%ifnidni __OUTPUT_FORMAT__, elf
dw seg _DATASTART, 0 ; [SEG:OFF] address of region's base
dw _markEndInstanceData wrt seg _DATASTART ; size in bytes
%else
global _winseg2
_winseg2: dw 0
dw 0 ; [SEG:OFF] address of region's base
global _winseg3
_winseg3: dw 0 ; size in bytes
%endif
dd 0 ; 0 marks end of table
patch_bytes: ; mark end of array of offsets of critical section bytes to patch
dw 0 ; and 0 length for end of instance_table entry
global _winPatchTable
_winPatchTable: ; returns offsets to various internal variables
@ -487,11 +649,11 @@ _winPatchTable: ; returns offsets to various internal variables
dw save_BX ; where BX stored during int21h dispatch
dw _InDOS ; offset of InDOS flag
dw _MachineId ; offset to variable containing MachineID
dw patch_bytes ; offset of to array of offsets to patch
dw _CritPatch ; offset of to array of offsets to patch
; NOTE: this points to a null terminated
; array of offsets of critical section bytes
; to patch, for now we just point this to
; an empty table, purposely not _CritPatch
; to patch, for now we can just point this
; to an empty table
; ie we just point to a 0 word to mark end
dw _uppermem_root ; seg of last arena header in conv memory
; this matches MS DOS's location, but
@ -504,7 +666,9 @@ _winPatchTable: ; returns offsets to various internal variables
_firstsftt:
dd -1 ; link to next
dw 5 ; count
times 5*59 db 0 ; reserve space for the 5 sft entries
db 0 ; pad byte so next value on even boundary
; Some references seem to indicate that this data should start at 01fbh in
; order to maintain 100% MS-DOS compatibility.
times (01fbh - ($ - DATASTART)) db 0
@ -571,13 +735,15 @@ _net_name db ' ' ;-27 - 15 Character Network Name
global _return_code
global _internal_data
; ensure offset of critical patch table remains fixed, some programs hard code offset
times (0315h - ($ - DATASTART)) db 0
global _CritPatch
_CritPatch dw 0d0ch ;-11 zero list of patched critical
dw 0d0ch ; section variables
dw 0d0ch
dw 0d0ch
dw 0d0ch
db 0 ;-01 - unknown
_CritPatch dw 0 ;-11 zero list of patched critical
dw 0 ; section variables
dw 0 ; DOS puts 0d0ch here but some
dw 0 ; progs really write to that addr.
dw 0 ;-03 - critical patch list terminator
db 90h ;-01 - unused, NOP pad byte
_internal_data: ; <-- Address returned by INT21/5D06
_ErrorMode db 0 ; 00 - Critical Error Flag
_InDOS db 0 ; 01 - Indos Flag
@ -682,16 +848,23 @@ int24_esbp times 2 dw 0 ;260 - pointer to criticalerr DPB
global _user_r, int21regs_off, int21regs_seg
_user_r:
int21regs_off dw 0 ;264 - pointer to int21h stack frame
int21regs_seg dw 0
int21regs_seg dw 0 ; i.e. points stack frame (SS:SP) with user registers when int21h called
global critical_sp
critical_sp dw 0 ;268 - critical error internal stack
critical_sp dw 0 ;268 - critical error internal stack, store SP during int24h
global current_ddsc
current_ddsc times 2 dw 0
current_ddsc times 2 dw 0 ;26A - pointer to DPB for ???
diskbuf_seg dw 0 ;26E - segment of disk buffer
dd 0 ;270 - saving partial cluster number??? - see https://faydoc.tripod.com/structures/16/1690.htm
dw 0
dw 0 ;276 - temp word
db 0 ;278 - media id returned by AH=1Bh,1Ch
db 0 ;279 - unused
; Pad to 059ah
times (27ah - ($ - _internal_data)) db 0
global current_device
current_device times 2 dw 0 ;27A - 0??
current_device times 2 dw 0 ;27A - point to device header if filename is character device
global _lpCurSft
_lpCurSft times 2 dw 0 ;27e - Current SFT
global _current_ldt
@ -701,11 +874,14 @@ _sda_lpFcb times 2 dw 0 ;286 - pointer to callers FCB
global _current_sft_idx
_current_sft_idx dw 0 ;28A - SFT index for next open
; used by MS NET
dw 0 ;28C - temp file handler
dd 0 ;28E - pointer to JFT entry (for file being opened) in process handle table
; Pad to 05b2h
times (292h - ($ - _internal_data)) db 0
dw __PriPathBuffer ; 292 - "sda_WFP_START" offset in DOS DS of first filename argument
dw __SecPathBuffer ; 294 - "sda_REN_WFP" offset in DOS DS of second filename argument
dw 0ffffh ; 296 - 0xffff or offset of last component in filename
; Pad to 05ceh
times (2aeh - ($ - _internal_data)) db 0
@ -718,15 +894,15 @@ _current_filepos times 2 dw 0 ;2AE - current offset in file
;global _save_DS
save_BX dw 0 ;2CA - unused by FreeDOS, for Win3.x
save_DS dw 0 ; compatibility, match MS's positions
dw 0
dw 0 ; store DS,BX on entry to int21h (ie caller's values)
global _prev_user_r
global prev_int21regs_off
global prev_int21regs_seg
_prev_user_r:
prev_int21regs_off dw 0 ;2D0 - pointer to prev int 21 frame
prev_int21regs_off dw 0 ;2D0 - pointer to prev int 21 frame (see offset 264h)
prev_int21regs_seg dw 0
; Pad to 05fdh
; Pad to 05fdh, 2D4 through 2E4 used for int21h/ax=6C00h
times (2ddh - ($ - _internal_data)) db 0
global _ext_open_action
global _ext_open_attrib
@ -734,6 +910,7 @@ prev_int21regs_seg dw 0
_ext_open_action dw 0 ;2DD - extended open action
_ext_open_attrib dw 0 ;2DF - extended open attrib
_ext_open_mode dw 0 ;2E1 - extended open mode
open_filename dd 0 ;2E3 pointer to filename to open (see ax=6C00h)
; Pad to 0620h
times (300h - ($ - _internal_data)) db 0
@ -750,6 +927,7 @@ _SearchDir_ren: times 32 db 0x90 ;315 - 32 byte dir entry for rename
; stacks are made to initialize to no-ops so that high-water
; testing can be performed
times STACK_SIZE*2-($-apistk_bottom) db 0x90
; critical error stack 331 bytes?, disk stack 384 bytes, character i/o 384 bytes
;300 - Error Processing Stack
global _error_tos
_error_tos:
@ -760,13 +938,23 @@ _disk_api_tos:
global _char_api_tos
_char_api_tos:
apistk_top:
db 0 ; 780 ???
db 0 ;780 device driver look-ahead (printer), see ah=64h
_VolChange db 0 ;781 - volume change
_VirtOpen db 0 ;782 - virtual open flag
; 783h to 788h are fastseek drive, 1st cluster, logical cluster, returned logical cluster
; 78Ah dw ? temp location of SYSINIT
; controlled variables end at offset 78Ch so pad to end
times (78ch - ($ - _internal_data)) db 0
; MSDOS 7.1+ with FAT32 SDA extended
;78Ch - 47 bytes of ???
times (7bbh - ($ - _internal_data)) db 0
absrdwrflg db 0 ;7bbh - 0=int 25h/26h absolute read/write, 1=int 21h/ax=7305h
times 12 dw 0 ;7bch to 7d2h, high word of 32bit values, see offsets 0x 2a2, 29c, 2bc, 29a, 276, 244, & registers ebx,edx,edi,ecx
times 3 dw 0 ; ???
;
; end of controlled variables
;
@ -808,6 +996,11 @@ blk_stk_top:
times 128 dw 0
clk_stk_top:
; int2fh private stack
global int2f_stk_top
times 128 dw 0
int2f_stk_top:
; Dynamic data:
; member of the DOS DATA GROUP
; and marks definitive end of all used data in kernel data segment
@ -831,8 +1024,10 @@ segment DYN_DATA
global _Dyn
_Dyn:
DynAllocated dw 0
;times DynAllocated db ? ; allocated at runtime, need to add DynAllocated to _markEndInstanceData
markEndInstanceData: ; mark end of DOS data seg we say needs instancing
global _markEndInstanceData
_markEndInstanceData: ; mark end of DOS data seg we say needs instancing
segment ID_B
@ -884,9 +1079,32 @@ __U4D:
LDIVMODU
%endif
resb 0xd0 - ($-begin_hma)
%ifdef gcc
%macro ULONG_HELPERS 1
global %1udivsi3
%1udivsi3: call %1ldivmodu
ret 8
global %1umodsi3
%1umodsi3: call %1ldivmodu
mov dx, cx
mov ax, bx
ret 8
%1ldivmodu: LDIVMODU
global %1ashlsi3
%1ashlsi3: LSHLU
global %1lshrsi3
%1lshrsi3: LSHRU
%endmacro
ULONG_HELPERS ___
%endif
times 0xd0 - ($-begin_hma) db 0
; reserve space for far jump to cp/m routine
resb 5
times 5 db 0
;End of HMA segment
segment HMA_TEXT_END
@ -898,7 +1116,7 @@ __HMATextEnd: ; and c version
; The default stack (_TEXT:0) will overwrite the data area, so I create a dummy
; stack here to ease debugging. -- ror4
segment _STACK class=STACK stack
segment _STACK class(STACK) nobits stack
@ -1013,17 +1231,20 @@ __HMARelocationTableEnd:
; will be only ever called, if HMA (DOS=HIGH) is enabled.
; for obvious reasons it should be located at the relocation table
;
global _XMSDriverAddress
_XMSDriverAddress:
dw 0 ; XMS driver, if detected
dw 0
global _ENABLEA20
_ENABLEA20:
mov ah,5
UsingXMSdriver:
UsingXMSdriver:
global _XMS_Enable_Patch
_XMS_Enable_Patch: ; SMC: patch to nop (90h) to enable use of XMS
retf
push bx
call far [cs:_XMSDriverAddress]
call 0:0 ; (immediate far address patched)
global _XMSDriverAddress
_XMSDriverAddress: equ $ - 4 ; XMS driver, if detected
pop bx
retf
@ -1032,8 +1253,6 @@ _DISABLEA20:
mov ah,6
jmp short UsingXMSdriver
dslowmem dw 0
eshighmem dw 0ffffh
global forceEnableA20
forceEnableA20:
@ -1041,67 +1260,55 @@ forceEnableA20:
push ds
push es
push ax
forceEnableA20retry:
mov ds, [cs:dslowmem]
mov es, [cs:eshighmem]
mov ax, [ds:00000h]
cmp ax, [es:00010h]
jne forceEnableA20success
push si
push di
push cx
pushf
cld
mov ax, [ds:00002h]
cmp ax, [es:00012h]
jne forceEnableA20success
.retry:
xor si, si ; = 0000h
mov ds, si ; => low memory (IVT)
dec si ; = FFFFh
mov es, si ; => HMA at offset 10h
inc si ; back to 0, -> IVT entry 0 and 1
mov di, 10h ; -> HMA, or wrapping around to 0:0
mov cx, 4
repe cmpsw ; compare up to 4 words
je .enable
mov ax, [ds:00004h]
cmp ax, [es:00014h]
jne forceEnableA20success
mov ax, [ds:00006h]
cmp ax, [es:00016h]
jne forceEnableA20success
;
; ok, we have to enable A20 )at least seems so
;
call far _ENABLEA20
jmp short forceEnableA20retry
forceEnableA20success:
.success:
popf
pop cx
pop di
pop si
pop ax
pop es
pop ds
ret
;
retn
.enable:
; ok, we have to enable A20 (at least seems so)
push cs ; make far call stack frame
call _ENABLEA20
jmp short .retry
; global f*cking compatibility issues:
;
; very old brain dead software (PKLITE, copyright 1990)
; forces us to execute with A20 disabled
;
global _ExecUserDisableA20
global _ExecUserDisableA20
_ExecUserDisableA20:
cmp word [cs:_XMSDriverAddress], byte 0
jne NeedToDisable
cmp word [cs:_XMSDriverAddress+2], byte 0
je noNeedToDisable
NeedToDisable:
push ax
call far _DISABLEA20
push ax
push cs ; make far call stack frame
call _DISABLEA20 ; (no-op if not in HMA, patched otherwise)
pop ax
noNeedToDisable:
iret
iret
;
; Default Int 24h handler -- always returns fail
; so we have not to relocate it (now)
;
@ -1122,3 +1329,7 @@ _TEXT_DGROUP dw DGROUP
segment INIT_TEXT
global _INIT_DGROUP
_INIT_DGROUP dw DGROUP
%ifdef gcc
ULONG_HELPERS _init_
%endif

196
kernel/kernel.ld Executable file
View File

@ -0,0 +1,196 @@
/* Linker script for DOS executables with separate data and text segments.
Partly derived from dos-exe-small.ld in newlib-ia16 and elks-separate.ld. */
OUTPUT_FORMAT(binary)
DOS_PSP = 0x60;
MEMOFS = DOS_PSP * 16 - SIZEOF(.msdos_mz_hdr);
/* these GROUPs play the same role as GROUPS (segments) in OMF */
PGROUP = (MEMOFS + LOADADDR(.ptext)) / 16;
LGROUP = (MEMOFS + LOADADDR(.ltext)) / 16;
DGROUP = (MEMOFS + LOADADDR(.data)) / 16;
_DosDataSeg = DGROUP;
TGROUP = (MEMOFS + LOADADDR(.text)) / 16;
IGROUP = (MEMOFS + LOADADDR(.itext)) / 16;
I_GROUP = (MEMOFS + LOADADDR(.idata)) / 16;
INITSIZE = SIZEOF(.itext) + SIZEOF(.idata) + SIZEOF(.ibss);
SECTIONS
{
/* Fabricate a .exe header here. Although libbfd does have an
"i386msdos" back-end which produces an "MZ" exe header, it cannot do
certain things (yet). */
.msdos_mz_hdr : {
/* Signature. */
SHORT (0x5a4d)
/* Bytes in last 512-byte page. */
SHORT (LOADADDR (.ibss) % 512)
/* Total number of 512-byte pages. */
SHORT (ALIGN(LOADADDR (.ibss), 512) / 512)
/* Relocation entries. */
SHORT ((__msdos_mz_rel_end - __msdos_mz_rel_start) / 4)
/* Header size in paragraphs. */
SHORT (SIZEOF(.msdos_mz_hdr) / 16)
/* Minimum extra paragraphs. */
SHORT (ALIGN(SIZEOF (.ibss) + SIZEOF(.istack), 16) / 16)
/* Maximum extra paragraphs. */
SHORT (0xffff)
/* Initial %ss. */
SHORT (LOADADDR (.istack) / 16 )
/* Initial %sp. */
SHORT (LOADADDR (.istack) % 16 + SIZEOF(.istack))
/* Padding for Checksum (unused) and initial cs:ip (0:0) */
. = 0x18;
/* Relocation table offset. */
SHORT (. + 4)
/* Overlay number */
SHORT (0)
/* Relocations */
HIDDEN (__msdos_mz_rel_start = .);
*(.msdos_mz_reloc .msdos_mz_reloc.*)
HIDDEN (__msdos_mz_rel_end = .);
/* Padding */
. = ALIGN (16);
}
/* Target PSP section. */
.ptext 0 : AT (SIZEOF(.msdos_mz_hdr)) {
*(PSP)
}
/* Target low data+text sections. */
.ltext 0 : AT (LOADADDR(.ptext) + SIZEOF(.ptext)) {
*(_IRQTEXT)
*(_LOWTEXT)
*(_IO_TEXT)
*(_IO_FIXED_DATA)
}
/* Target data sections. */
.data 0 : AT (ALIGN(LOADADDR(.ltext) + SIZEOF(.ltext), 16)) {
*(_FIXED_DATA)
*(_BSS)
*(EXCLUDE_FILE (config.obj iasmsupt.obj *init*.obj iprf.obj main.obj) .bss)
*(_DATA)
*(EXCLUDE_FILE (config.obj iasmsupt.obj *init*.obj iprf.obj main.obj) .data)
*(_DATAEND)
*(CONST)
*(CONST2)
*(EXCLUDE_FILE (config.obj iasmsupt.obj *init*.obj iprf.obj main.obj) .rodata)
*(EXCLUDE_FILE (config.obj iasmsupt.obj *init*.obj iprf.obj main.obj) .rodata.*)
*(DYN_DATA)
ASSERT(. <= 0xfff8,
"Error: too large for a small-model .exe file.");
}
/* Target text sections. */
.text 0 : AT (ALIGN(LOADADDR(.data) + SIZEOF(.data), 16)) {
*(HMA_TEXT_START)
*(HMA_TEXT)
_call_intr = CALL_INTR;
_res_DosExec = RES_DOSEXEC;
_res_read = RES_READ;
_strlen = STRLEN;
_fstrlen = FSTRLEN;
_strlen = STRLEN;
_fstrcmp = FSTRCMP;
_strchr = STRCHR;
_fstrchr = FSTRCHR;
_fmemchr = FMEMCHR;
_strcpy = STRCPY;
_fmemcpy = FMEMCPY;
_fstrcpy = FSTRCPY;
_memcpy = MEMCPY;
_fmemset = FMEMSET;
_memset = MEMSET;
_memcmp = MEMCMP;
_fmemcmp = FMEMCMP;
_network_redirector_mx = NETWORK_REDIRECTOR_MX;
_execrh = EXECRH;
_share_check = SHARE_CHECK;
_share_open_check = SHARE_OPEN_CHECK;
_share_close_file = SHARE_CLOSE_FILE;
_share_access_check = SHARE_ACCESS_CHECK;
_share_lock_unlock = SHARE_LOCK_UNLOCK;
_share_is_file_open = SHARE_IS_FILE_OPEN;
_call_nls = CALL_NLS;
_fl_reset = FL_RESET;
_fl_diskchanged = FL_DISKCHANGED;
_fl_format = FL_FORMAT;
_fl_read = FL_READ;
_fl_write = FL_WRITE;
_fl_verify = FL_VERIFY;
_fl_setdisktype = FL_SETDISKTYPE;
_fl_setmediatype = FL_SETMEDIATYPE;
_fl_readkey = FL_READKEY;
_fl_lba_ReadWrite = FL_LBA_READWRITE;
_floppy_change = FLOPPY_CHANGE;
_ReadPCClock = READPCCLOCK;
_WritePCClock = WRITEPCCLOCK;
_WriteATClock = WRITEATCLOCK;
*(EXCLUDE_FILE (config.obj iasmsupt.obj *init*.obj iprf.obj main.obj) .text)
*(HMA_TEXT_END)
ASSERT(. <= 0x10000,
"Error: too large for a small-model .exe file.");
}
/* Target init text sections. */
.itext 0 : AT (LOADADDR(.text) + SIZEOF(.text)) {
*(INIT_TEXT_START)
*(INIT_TEXT)
_init_execrh = INIT_EXECRH;
_init_memset = INIT_MEMSET;
_init_fmemset = INIT_FMEMSET;
_init_memcmp = INIT_MEMCMP;
_init_fmemcmp = INIT_FMEMCMP;
_init_memcpy = INIT_MEMCPY;
_init_fmemcpy = INIT_FMEMCPY;
_init_strcpy = INIT_STRCPY;
_init_fstrcpy = INIT_FSTRCPY;
_init_strlen = INIT_STRLEN;
_init_fstrlen = INIT_FSTRLEN;
_init_strchr = INIT_STRCHR;
_UMB_get_largest = UMB_GET_LARGEST;
_init_call_intr = INIT_CALL_INTR;
_read = READ;
_init_DosOpen = INIT_DOSOPEN;
_close = CLOSE;
_dup2 = DUP2;
_lseek = LSEEK;
_allocmem = ALLOCMEM;
_init_PSPSet = INIT_PSPSET;
_init_DosExec = INIT_DOSEXEC;
_init_setdrive = INIT_SETDRIVE;
_init_switchar = INIT_SWITCHAR;
_keycheck = KEYCHECK;
_set_DTA = SET_DTA;
_DetectXMSDriver = DETECTXMSDRIVER;
_init_call_XMScall = INIT_CALL_XMSCALL;
__EnableA20 = _ENABLEA20;
__DisableA20 = _DISABLEA20;
*(.text)
*(INIT_TEXT_END)
ASSERT(. <= 0x10000,
"Error: too large for a small-model .exe file.");
}
/* Target init data sections. */
.idata 0 : AT (LOADADDR(.itext) + SIZEOF(.itext)) {
*(ID_B)
*(.data)
*(.rodata) *(.rodata.*)
*(ID_E)
}
.ibss (NOLOAD) : AT (LOADADDR(.idata) + SIZEOF(.idata)) {
*(IB_B)
*(.bss)
*(IB_E)
}
.istack 0 (NOLOAD) : AT (LOADADDR(.ibss) + SIZEOF(.ibss)) {
*(_STACK)
. = 0x1000;
}
/DISCARD/ : { *(.*) }
}

View File

@ -105,7 +105,7 @@ COUNT lfn_free_inode(COUNT handle)
* Return value.
* SUCCESS, LHE_INVLDHNDL
*/
COUNT lfn_setup_inode(COUNT handle, ULONG dirstart, UWORD diroff)
COUNT lfn_setup_inode(COUNT handle, ULONG dirstart, ULONG diroff)
{
f_node_ptr fnp = xlt_fd(handle);
if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL;

View File

@ -51,16 +51,25 @@
; destroys:
; flags
;
%ifdef STDCALL
push bp
mov bp, sp
mov ax, [bp+6]
mov dx, [bp+8]
mov bx, [bp+10]
mov cx, [bp+12]
pop bp
%endif
test cx, cx ; divisor > 2^32-1 ?
jnz %%big_divisor ; yes, divisor > 32^32-1
cmp dx, bx ; only one division needed ? (ecx = 0)
test cx, cx ; divisor > 2^16-1 ?
jnz %%big_divisor ; yes, divisor > 2^16-1
cmp dx, bx ; only one division needed ? (cx = 0)
jb %%one_div ; yes, one division sufficient
xchg cx, ax ; save dividend-lo in cx, ax=0
xchg ax, dx ; get dividend-hi in ax, dx=0
div bx ; quotient-hi in eax
div bx ; quotient-hi in ax
xchg ax, cx ; cx = quotient-hi, ax =dividend-lo
%%one_div:
@ -76,37 +85,57 @@
push dx ; save
push ax ; dividend
mov si, bx ; divisor now in
mov di, cx ; di:bx and cx:si
mov di, cx ; di:si and cx:bx
%%shift_loop:
shr dx, 1 ; shift both
rcr ax, 1 ; divisor and
shr di, 1 ; and dividend
rcr ax, 1 ; dividend
shr cx, 1 ; and divisor
rcr bx, 1 ; right by 1 bit
jnz %%shift_loop ; loop if di non-zero (rcr does not touch ZF)
mov di, cx ; restore original divisor (di:si)
div bx ; compute quotient
div bx ; compute quotient dx:ax>>x / cx:bx>>x (stored in ax; remainder in dx not used)
pop bx ; get dividend lo-word
mov cx, ax ; save quotient
mul di ; quotient * divisor hi-word (low only)
push di ; save divisor hi-word
xchg ax, di ; save in di
pop dx ; dividend high
sub dx,ax ; dividend high - divisor high * quotient, no overflow (carry/borrow) possible here
push dx ; save dividend high
mov ax, cx ; ax=quotient
mul si ; quotient * divisor lo-word
add dx, di ; dx:ax = quotient * divisor
pop di ; restore divisor hi-word
sub bx, ax ; dividend-lo - (quot.*divisor)-lo
sub bx, ax ; dividend-lo - (quot.*divisor-lo)-lo
mov ax, cx ; get quotient
pop cx ; restore dividend hi-word
sbb cx, dx ; subtract divisor * quot. from dividend
sbb cx, dx ; subtract (divisor-lo * quot.)-hi from dividend-hi
sbb dx, dx ; 0 if remainder > 0, else FFFFFFFFh
and si, dx ; nothing to add
and di, dx ; back if remainder positive
add bx, si ; correct remaider
adc cx, di ; and quotient if
add ax, dx ; necessary
xor dx, dx ; clear hi-word of quot (ax<=FFFFFFFFh)
and di, dx ; back if remainder positive di:si := di:si(cx:bx) & dx:dx
add bx, si ; correct remainder cx:bx += di:si
adc cx, di ; and
add ax, dx ; quotient if necessary ax += dx
xor dx, dx ; clear hi-word of quot (ax<=FFFFh) dx := 0
pop di ; restore temp
pop si ; variables
ret
%endmacro
%endmacro
%macro LSHLU 0
pop bx
popargs {dx,ax},cx
push bx
jcxz %%ret
%%loop: shl ax, 1
rcl dx, 1
loop %%loop
%%ret: ret
%endmacro
%macro LSHRU 0
pop bx
popargs {dx,ax},cx
push bx
jcxz %%ret
%%loop: shr dx, 1
rcr ax, 1
loop %%loop
%%ret: ret
%endmacro

View File

@ -32,20 +32,14 @@
#include "dyndata.h"
#include "debug.h"
#ifdef VERSION_STRINGS
static BYTE *mainRcsId =
"$Id: main.c 1699 2012-01-16 20:45:44Z perditionc $";
#endif
static char copyright[] =
"(C) Copyright 1995-2012 Pasquale J. Villani and The FreeDOS Project.\n"
"(C) Copyright 1995-2023 Pasquale J. Villani and The FreeDOS Project.\n"
"All Rights Reserved. This is free software and comes with ABSOLUTELY NO\n"
"WARRANTY; you can redistribute it and/or modify it under the terms of the\n"
"GNU General Public License as published by the Free Software Foundation;\n"
"either version 2, or (at your option) any later version.\n";
struct _KernelConfig InitKernelConfig BSS_INIT({0});
STATIC VOID InitIO(void);
STATIC VOID update_dcb(struct dhdr FAR *);
@ -70,10 +64,18 @@ __segment DosTextSeg = 0;
struct lol FAR *LoL = &DATASTART;
struct _KernelConfig ASM InitKernelConfig = { -1 };
char ASM kernel_command_line[256] = { 0, -1 }; /* special none value */
int kernel_command_line_length BSS_INIT(0);
UBYTE ASM debugger_present = 0xFF; /* initialised in kernel.asm
do NOT set 0 here or compiler may
move it into bss that we zero out */
VOID ASMCFUNC FreeDOSmain(void)
{
unsigned char drv;
unsigned char FAR *p;
char * pp;
#ifdef _MSC_VER
extern FAR prn_dev;
@ -92,17 +94,8 @@ VOID ASMCFUNC FreeDOSmain(void)
drv = LoL->BootDrive + 1;
p = MK_FP(0, 0x5e0);
if (fmemcmp(p+2,"CONFIG",6) == 0) /* UPX */
{
fmemcpy(&InitKernelConfig, p+2, sizeof(InitKernelConfig));
drv = *p + 1;
*(DWORD FAR *)(p+2) = 0;
}
else
{
*p = drv - 1;
fmemcpy(&InitKernelConfig, &LowKernelConfig, sizeof(InitKernelConfig));
*p = drv - 1; /* compatibility with older kernels */
}
if (drv >= 0x80)
@ -112,6 +105,23 @@ VOID ASMCFUNC FreeDOSmain(void)
/* install DOS API and other interrupt service routines, basic kernel functionality works */
setup_int_vectors();
#ifdef DEBUG
/* printf must go after setup_int_vectors call */
if (kernel_command_line[0] == 0 && kernel_command_line[1] == (char)-1) {
printf("\nKERNEL: Command line is not specified.\n");
} else {
printf("\nKERNEL: Command line is \"%s\"\n", kernel_command_line);
}
#endif
kernel_command_line_length = strlen(kernel_command_line);
for (pp = kernel_command_line; *pp; ++pp) {
if (*pp == ';') {
*pp = 0;
}
}
/* check if booting from floppy/CD */
CheckContinueBootFromHarddisk();
/* display copyright info and kernel emulation status */
@ -158,6 +168,7 @@ STATIC void PSPInit(void)
/* Clear out new psp first */
fmemset(p, 0, sizeof(psp));
/* high half is used as environment */
/* initialize all entries and exits */
/* CP/M-like exit point */
@ -200,6 +211,9 @@ STATIC void PSPInit(void)
/* open file table pointer */
p->ps_filetab = p->ps_files;
/* default system version for int21/ah=30 */
p->ps_retdosver = (LoL->os_setver_minor << 8) + LoL->os_setver_major;
/* first command line argument */
/* p->ps_fcb1.fcb_drive = 0; already set */
fmemset(p->ps_fcb1.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE);
@ -207,9 +221,7 @@ STATIC void PSPInit(void)
/* p->ps_fcb2.fcb_drive = 0; already set */
fmemset(p->ps_fcb2.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE);
/* local command line */
/* p->ps_cmd.ctCount = 0; command tail, already set */
p->ps_cmd.ctBuffer[0] = 0xd; /* command tail */
/* do not modify command line tail, used as environment */
}
#ifndef __WATCOMC__
@ -240,37 +252,41 @@ STATIC void setup_int_vectors(void)
} vectors[] =
{
/* all of these are in the DOS DS */
{ 0x0, FP_OFF(int0_handler) }, /* zero divide */
{ 0x1, FP_OFF(empty_handler) }, /* single step */
{ 0x3, FP_OFF(empty_handler) }, /* debug breakpoint */
{ 0x6, FP_OFF(int6_handler) }, /* invalid opcode */
{ 0x19, FP_OFF(int19_handler) },
{ 0x80 | 0x0, FP_OFF(int0_handler) }, /* zero divide */
{ 0x80 | 0x1, FP_OFF(empty_handler) }, /* single step */
{ 0x80 | 0x3, FP_OFF(empty_handler) }, /* debug breakpoint */
{ 0x80 | 0x6, FP_OFF(int6_handler) }, /* invalid opcode */
{ 0x19, FP_OFF(int19_handler) }, /* BIOS bootstrap loader, vdisk */
{ 0x20, FP_OFF(int20_handler) },
{ 0x21, FP_OFF(int21_handler) },
{ 0x21, FP_OFF(int21_handler) }, /* primary DOS API */
{ 0x22, FP_OFF(int22_handler) },
{ 0x24, FP_OFF(int24_handler) },
{ 0x25, FP_OFF(low_int25_handler) },
{ 0x25, FP_OFF(low_int25_handler) }, /* DOS abs read/write calls */
{ 0x26, FP_OFF(low_int26_handler) },
{ 0x27, FP_OFF(int27_handler) },
{ 0x28, FP_OFF(int28_handler) },
{ 0x2a, FP_OFF(int2a_handler) },
{ 0x2f, FP_OFF(int2f_handler) }
{ 0x2f, FP_OFF(int2f_handler) } /* multiplex int */
};
struct vec *pvec;
struct lowvec FAR *plvec;
int i;
for (plvec = intvec_table; plvec < intvec_table + 5; plvec++)
/* save current int vectors so can restore on reboot and call original directly */
for (plvec = intvec_table; plvec < intvec_table + 6; plvec++)
plvec->isv = getvec(plvec->intno);
/* install default handlers */
for (i = 0x23; i <= 0x3f; i++)
setvec(i, empty_handler);
setvec(i, empty_handler); /* note: int 31h segment should be DOS DS */
HaltCpuWhileIdle = 0;
for (pvec = vectors; pvec < vectors + (sizeof vectors/sizeof *pvec); pvec++)
setvec(pvec->intno, (intvec)MK_FP(FP_SEG(empty_handler), pvec->handleroff));
if ((pvec->intno & 0x80) == 0 || debugger_present == 0)
setvec(pvec->intno & 0x7F, (intvec)MK_FP(FP_SEG(empty_handler), pvec->handleroff));
pokeb(0, 0x30 * 4, 0xea);
pokel(0, 0x30 * 4 + 1, (ULONG)cpm_entry);
/* these two are in the device driver area LOWTEXT (0x70) */
/* handlers for int 0x1b and 0x29 are in the device driver area LOWTEXT (0x70) */
setvec(0x1b, got_cbreak);
setvec(0x29, int29_handler); /* required for printf! */
}
@ -285,7 +301,14 @@ STATIC void init_kernel(void)
/* Init oem hook - returns memory size in KB */
ram_top = init_oem();
/* move kernel to high conventional RAM, just below the init code */
/* Note: HMA_TEXT and init code already moved higher in
conventional memory by startup code, however, we still
need to adjust any references to new location. So use
current CS as that is where we were moved to and perform
any fixups needed. Note this will also re-copy the
HMA_TEXT segment, so be sure not to overwrite it prior
to the MoveKernel() call. Kernel moved to around 8F??:0000
*/
#ifdef __WATCOMC__
lpTop = MK_FP(_CS, 0);
#else
@ -313,6 +336,9 @@ STATIC void init_kernel(void)
LoL->lastdrive = 26;
/* init_device((struct dhdr FAR *)&blk_dev, NULL, 0, &ram_top); */
/* WARNING: dsk_init() must be called prior to update_dcb() to ensure
_Dyn (start of Dynamic memory block) is the start of drive data table (see getddt() in dsk.c)
*/
blk_dev.dh_name[0] = dsk_init();
PreConfig();
@ -410,7 +436,18 @@ STATIC VOID FsConfig(VOID)
STATIC VOID signon()
{
printf("\r%S"
if (InitKernelConfig.Verbose < 0)
{
#ifdef CUSTOM_BRANDING
printf("\n" CUSTOM_BRANDING "\n\n");
#else
printf("\n%S\n\n", MK_FP(FP_SEG(LoL), FP_OFF(LoL->os_release)));
#endif
} else {
#ifdef CUSTOM_BRANDING
printf("\n" CUSTOM_BRANDING "\n\n%s", copyright);
#else
printf("\n%S"
"Kernel compatibility %d.%d - "
#if defined(__BORLANDC__)
"BORLANDC"
@ -430,6 +467,8 @@ STATIC VOID signon()
" - 80386 CPU required"
#elif defined (I186)
" - 80186 CPU required"
#else
" - 808x compatible"
#endif
#ifdef WITHFAT32
@ -438,6 +477,8 @@ STATIC VOID signon()
"\n\n%s",
MK_FP(FP_SEG(LoL), FP_OFF(LoL->os_release)),
MAJOR_RELEASE, MINOR_RELEASE, copyright);
#endif
}
}
STATIC void kernel()
@ -445,8 +486,7 @@ STATIC void kernel()
CommandTail Cmd;
if (master_env[0] == '\0') /* some shells panic on empty master env. */
strcpy(master_env, "PATH=.");
fmemcpy(MK_FP(DOS_PSP + 8, 0), master_env, sizeof(master_env));
fmemcpy(master_env, "PATH=.\0\0\0\0", sizeof("PATH=.\0\0\0\0"));
/* process 0 */
/* Execute command.com from the drive we just booted from */
@ -500,20 +540,40 @@ STATIC VOID update_dcb(struct dhdr FAR * dhp)
COUNT nunits = dhp->dh_name[0];
struct dpb FAR *dpb;
if (LoL->nblkdev == 0)
dpb = LoL->DPBp;
else
{
for (dpb = LoL->DPBp; (ULONG) dpb->dpb_next != 0xffffffffl;
dpb = dpb->dpb_next)
;
dpb = dpb->dpb_next =
KernelAlloc(nunits * sizeof(struct dpb), 'E', Config.cfgDosDataUmb);
/* printf("nblkdev = %i\n", LoL->nblkdev); */
/* if no units, nothing to do, ensure at least 1 unit for rest of logic */
if (nunits == 0) return;
/* allocate memory for new device control blocks, insert into chain [at end], and update our pointer to new end */
if ( LoL->first_mcb ) {
dpb = (struct dpb FAR *)KernelAlloc(nunits * sizeof(struct dpb), 'E', Config.cfgDosDataUmb);
}
else {
dpb = DynAlloc("DPBp", blk_dev.dh_name[0], sizeof(struct dpb));
}
for (Index = 0; Index < nunits; Index++)
/* find end of dpb chain or initialize root if needed */
if (LoL->nblkdev == 0)
{
dpb->dpb_next = dpb + 1;
/* update root pointer to new end (our just allocated block) */
LoL->DPBp = dpb;
}
else
{
struct dpb FAR *tmp_dpb;
/* find current end of dpb chain by following next pointers to end */
for (tmp_dpb = LoL->DPBp; (ULONG) tmp_dpb->dpb_next != 0xffffffffl; tmp_dpb = tmp_dpb->dpb_next)
;
/* insert into chain [at end] */
tmp_dpb->dpb_next = dpb;
}
/* dpb points to last block, one just allocated */
for (Index = 0; Index < nunits; Index++)
{
/* printf("processing unit %i of %i nunits\n", Index, nunits); */
dpb->dpb_next = dpb + 1; /* memory allocated as array, so next is just next element */
dpb->dpb_unit = LoL->nblkdev;
dpb->dpb_subunit = Index;
dpb->dpb_device = dhp;
@ -523,10 +583,14 @@ STATIC VOID update_dcb(struct dhdr FAR * dhp)
LoL->CDSp[LoL->nblkdev].cdsDpb = dpb;
LoL->CDSp[LoL->nblkdev].cdsFlags = CDSPHYSDRV;
}
++dpb;
++dpb; /* dbp = dbp->dpb_next; */
++LoL->nblkdev;
}
/* note that always at least 1 valid dpb due to above early exit if nunits==0 */
(dpb - 1)->dpb_next = (void FAR *)0xFFFFFFFFl;
/* printf("processed %i nunits\n", nunits); */
}
/* If cmdLine is NULL, this is an internal driver */
@ -775,8 +839,12 @@ STATIC void CheckContinueBootFromHarddisk(void)
init_call_intr(0x13, &r);
{
#if __GNUC__
asm volatile("jmp $0,$0x7c00");
#else
void (far *reboot)(void) = (void (far*)(void)) MK_FP(0x0,0x7c00);
(*reboot)();
#endif
}
}

View File

@ -27,33 +27,40 @@ OBJS=$(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5) $(OBJS6) $(OBJS7) $(OBJS8)
# *Explicit Rules*
production: ../bin/$(TARGET).sys ../bin/country.sys
production: ../bin/$(TARGET).sys
../bin/$(TARGET).sys: kernel.sys
$(CP) kernel.sys ..$(DIRSEP)bin
$(CP) kernel.sys ..$(DIRSEP)bin$(DIRSEP)$(TARGET).sys
$(CP) kernel.map ..$(DIRSEP)bin$(DIRSEP)$(TARGET).map
# -S to avoid showing expected relocations
# 0x10 & 0x78 or 0x79 depending on compilation options
kernel.sys: kernel.exe ../utils/exeflat.exe
..$(DIRSEP)utils$(DIRSEP)exeflat.exe kernel.exe kernel.sys $(LOADSEG) -S0x10 -S0x78 -S0x79 $(UPXOPT) $(XUPX)
kernel.sys: kernel.exe ../utils/exeflat.exe ../utils/upxentry.bin ../utils/upxdevic.bin exeflat.rsp
..$(DIRSEP)utils$(DIRSEP)exeflat.exe kernel.exe kernel.sys $(LOADSEG) @exeflat.rsp
kernel.exe: $(TARGET).lnk $(OBJS) $(LIBS)
$(LINK) @$(TARGET).lnk;
../bin/country.sys: country.asm
$(NASM) -o $*.sys country.asm
clobber: clean
-$(RM) kernel.exe kernel.sys status.me
clean:
-$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod *.err *.lnk
-$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod *.err *.lnk *.rsp
# 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
# -S to avoid showing expected relocations
# 0x10 & 0x78 or 0x79 depending on compilation options
exeflat.rsp: makefile
-$(RM) exeflat.rsp
$(ECHOTO) exeflat.rsp -S0x10
$(ECHOTO) exeflat.rsp -S0x78
$(ECHOTO) exeflat.rsp -S0x79
$(ECHOTO) exeflat.rsp -E..$(DIRSEP)utils$(DIRSEP)upxentry.bin
$(ECHOTO) exeflat.rsp -D..$(DIRSEP)utils$(DIRSEP)upxdevic.bin
$(ECHOTO) exeflat.rsp $(UPXOPT)
$(ECHOTO) exeflat.rsp $(XUPX)
$(TARGET).lnk: turboc.cfg makefile ../mkfiles/generic.mak ../mkfiles/$(COMPILER).mak
-$(RM) *.lnk
$(ECHOTO) $(TARGET).lnk $(OBJS1)+
@ -90,7 +97,7 @@ serial.obj: serial.asm io.inc $(TARGET).lnk
HDRS=\
$(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)fat.h $(HDR)fcb.h $(HDR)tail.h $(HDR)dtime.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 dyndata.h
@ -158,7 +165,7 @@ initclk.obj: initclk.c $(INITHEADERS) $(TARGET).lnk
#the string functions for INIT_TEXT
iasmsupt.obj: asmsupt.asm $(TARGET).lnk
$(NASM) -D$(COMPILER) -D_INIT $(NASMFLAGS) -f obj -o iasmsupt.obj asmsupt.asm
$(NASM) -D$(COMPILER) -D_INIT -f obj $(NASMFLAGS) -o iasmsupt.obj asmsupt.asm
#the printf for INIT_TEXT - yet another special case, this file includes prf.c
iprf.obj: iprf.c prf.c $(HDR)portab.h $(TARGET).lnk

View File

@ -316,7 +316,7 @@ COUNT DosMemFree(UWORD para)
*/
COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize)
{
REG mcb FAR *p, FAR * q;
REG mcb FAR *p; mcb FAR * q;
/* Initialize */
p = para2far(para - 1); /* pointer to MCB */

View File

@ -25,13 +25,9 @@
/* Cambridge, MA 02139, USA. */
/****************************************************************/
#ifdef VERSION_STRINGS
static BYTE *mainRcsId =
"$Id: newstuff.c 1479 2009-07-07 13:33:24Z bartoldeman $";
#endif
#include "portab.h"
#include "globals.h"
#include "debug.h"
/*
TE-TODO: if called repeatedly by same process,
@ -104,9 +100,6 @@ long DosMkTmp(BYTE FAR * pathname, UWORD attr)
return rc;
}
#ifdef DEBUG
#define DEBUG_TRUENAME
#endif
#define drLetterToNr(dr) ((unsigned char)((dr) - 'A'))
/* Convert an uppercased drive letter into the drive index */
@ -185,7 +178,10 @@ long DosMkTmp(BYTE FAR * pathname, UWORD attr)
*/
#define PATH_ERROR goto errRet
#define PATH_ERROR() \
fstrchr(src, '/') == 0 && fstrchr(src, '\\') == 0 \
? DE_FILENOTFND \
: DE_PATHNOTFND
#define PATHLEN 128
@ -233,12 +229,6 @@ long DosMkTmp(BYTE FAR * pathname, UWORD attr)
*/
#ifdef DEBUG_TRUENAME
#define tn_printf(x) printf x
#else
#define tn_printf(x)
#endif
#define PNE_WILDCARD 1
#define PNE_DOT 2
@ -249,7 +239,7 @@ STATIC const char _DirChars[] = "\"[]:|<>+=;,";
#define addChar(c) \
{ \
if (p >= dest + SFTMAX) PATH_ERROR; /* path too long */ \
if (p >= dest + SFTMAX) return PATH_ERROR(); /* path too long */ \
*p++ = c; \
}
@ -304,17 +294,63 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode)
cdsEntry = get_cds(result);
if (cdsEntry == NULL)
{
/* workaround for a device prefixed with invalid drive (e.g. "@:NUL") */
/* (MS-DOS always return drive P: for invalid drive. Why P:?) */
if (dhp)
/* If opening a character device, DOS allows device name
to be prefixed by [invalid] drive letter and/or optionally
\DEV\ directory prefix, however, any other directory
including root (\) is an invalid path if drive is not
valid and returns such.
Whereas truename always fails for invalid drive.
*/
if (dhp && (mode & CDS_MODE_CHECK_DEV_PATH) && (result >= lastdrive))
{
/* Note: check for (result >= lastdrive) means invalid drive
was provided as otherwise we would have used default_drive
so we know src in the form of X:?
fail if anything other than no path or path is \DEV\
*/
const char FAR *s = src+2;
char c = *s;
if( c != '\\' && c != '/' ) c = '\0';
/* could be 1 letter devicename, don't go scanning random memory */
if (*(src+3) != '\0')
{
s = fstrchr(src+3, '\\'); /* ?is there \ or / other than immediately after drive: */
if (s == NULL) s = fstrchr(src+3, '/');
}
else
{
s = NULL;
}
if (c == '\0')
{
/* either X:devicename or X:path\devicename */
if (s != NULL) goto invalid_path;
}
else
{
/* either X:\devicename or X:\path\devicename
only X:\DEV\devicename is valid path
*/
if (s == NULL) goto invalid_path;
if (s != src+6) goto invalid_path;
if (fmemcmp(src+3, "DEV", 3) != 0) goto invalid_path;
s = fstrchr(src+7, '\\');
if (s == NULL) s = fstrchr(src+7, '/');
if (s != NULL) goto invalid_path;
}
/* use CDS of current drive (MS-DOS may return drive P: for invalid drive.) */
result = default_drive;
cdsEntry = get_cds(result);
if (cdsEntry == NULL)
return DE_PATHNOTFND;
if (cdsEntry == NULL) goto invalid_path;
}
else
return DE_PATHNOTFND;
{
invalid_path:
return DE_PATHNOTFND;
}
}
fmemcpy(&TempCDS, cdsEntry, sizeof(TempCDS));
@ -480,14 +516,18 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode)
if(*src == '.')
{
int dots = 1;
/* special directory component */
++src;
if (*src == '.') /* skip the second dot */
{
++src;
dots++;
}
if (*src == '/' || *src == '\\' || *src == '\0')
{
--p; /* backup the backslash */
if (src[-2] == '.')
if (dots == 2)
{
/* ".." entry */
/* remove last path component */
@ -499,12 +539,9 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode)
}
/* ill-formed .* or ..* entries => return error */
errRet:
/* The error is either PATHNOTFND or FILENOTFND
depending on if it is not the last component */
return fstrchr(src, '/') == 0 && fstrchr(src, '\\') == 0
? DE_FILENOTFND
: DE_PATHNOTFND;
return PATH_ERROR();
}
/* normal component */
@ -537,7 +574,7 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode)
if (c == '.')
{
if (state & PNE_DOT) /* multiple dots are ill-formed */
PATH_ERROR;
return PATH_ERROR();
/* strip trailing dot */
if (*src == '/' || *src == '\\' || *src == '\0')
break;
@ -549,7 +586,7 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode)
state |= PNE_WILDCARD;
if (i) { /* name length in limits */
--i;
if (!DirChar(c)) PATH_ERROR;
if (!DirChar(c)) return PATH_ERROR();
addChar(c);
}
}
@ -662,7 +699,7 @@ if exist report.out del report.out
cmdspy stop
cmdspy flush
cmdspy restart
int ax=0x6000 -buf ds:si="abcöflkgsxkf\0" -buf es:di="%256s" -int 0x21 -d es:di:128 >spy_int.out
int ax=0x6000 -buf ds:si="abcöflkgsxkf\0" -buf es:di="%256s" -int 0x21 -d es:di:128 >spy_int.out
cmdspy stop
cmdspy report report.out
more report.out
@ -682,11 +719,11 @@ more report.out
1123: IN: C:\TOOL\INT.COM [FAIL 0001]
1123: OUT: C:\INTRSPY\SPY_INT.OUT
1123: orig buffer: C:\TOOL\INT.COM
1123: IN: abcöflkgsxkf [FAIL 0001]
1123: IN: abcöflkgsxkf [FAIL 0001]
1123: OUT: C:\TOOL\INT.COM
1123: orig buffer: abcöflkgsxkf
1123: orig buffer: abcöflkgsxkf
1123: IN: C:\INTRSPY\SPY_INT.BAT [FAIL 0001]
1123: OUT: C:\INTRSPY\ABCÖFLKG
1123: OUT: C:\INTRSPY\ABCÖFLKG
1123: orig buffer: C:\INTRSPY\SPY_INT.BAT
1123: IN: cmdspy.??? [FAIL 0001]
1123: OUT: C:\INTRSPY
@ -708,7 +745,7 @@ DOSERR: 0000 (0)
*<es:di:128> {
43(C) 3A(:) 5C(\) 49(I) 4E(N) 54(T) 52(R) 53(S) 50(P) 59(Y) 5C(\) 41(A)
42(B) 43(C) 99(Ö) 46(F) 4C(L) 4B(K) 47(G) 00(.) 3D(=) 30(0) 30(0) 30(0)
42(B) 43(C) 99(Ö) 46(F) 4C(L) 4B(K) 47(G) 00(.) 3D(=) 30(0) 30(0) 30(0)
30(0) 20( ) 20( ) 20( ) 43(C) 58(X) 3D(=) 30(0) 30(0) 30(0) 30(0) 28(()
30(0) 29()) 20( ) 32(2) 38(8) 28(() 28(() 29()) 20( ) 33(3) 30(0) 28(()
30(0) 29()) 20( ) 32(2) 39(9) 28(() 29()) 29()) 20( ) 32(2) 30(0) 28(()

View File

@ -36,7 +36,7 @@
#include "portab.h"
#include "globals.h"
#include "pcb.h"
#include <nls.h>
#include "nls.h"
#ifdef VERSION_STRINGS
static BYTE *RcsId =
@ -66,8 +66,13 @@ struct nlsInfoBlock ASM nlsInfo = {
#ifdef NLS_REORDER_POINTERS
| NLS_CODE_REORDER_POINTERS
#endif
#ifdef __GNUC__
, {.seg=DosDataSeg, .off=&nlsPackageHardcoded} /* hardcoded first package */
, {.seg=DosDataSeg, .off=&nlsPackageHardcoded} /* first item in chain */
#else
, &nlsPackageHardcoded /* hardcoded first package */
, &nlsPackageHardcoded /* first item in chain */
#endif
};
/* getTableX return the pointer to the X'th table; X==subfct */
@ -93,6 +98,9 @@ struct nlsInfoBlock ASM nlsInfo = {
***** MUX calling functions ****************************************
********************************************************************/
#ifdef __GNUC__
#define call_nls(a,b,c,d,e,f) call_nls(f,e,d,c,b,a)
#endif
extern long ASMPASCAL call_nls(UWORD, VOID FAR *, UWORD, UWORD, UWORD, UWORD);
/*== DS:SI _always_ points to global NLS info structure <-> no
* subfct can use these registers for anything different. ==ska*/
@ -659,60 +667,54 @@ VOID FAR *DosGetDBCS(void)
Return value: AL register to be returned
if AL == 0, Carry must be cleared, otherwise set
*/
UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS)
UWORD ASMCFUNC syscall_MUX14(iregs FAR *pr)
{
struct nlsPackage FAR *nls; /* addressed NLS package */
UNREFERENCED_PARAMETER(flags);
UNREFERENCED_PARAMETER(cs);
UNREFERENCED_PARAMETER(ip);
UNREFERENCED_PARAMETER(ds);
UNREFERENCED_PARAMETER(es);
UNREFERENCED_PARAMETER(si);
log(("NLS: MUX14(): subfct=%x, cp=%u, cntry=%u\n", pr->AL, pr->BX, pr->DX));
log(("NLS: MUX14(): subfct=%x, cp=%u, cntry=%u\n", AL, BX, DX));
if ((nls = searchPackage(BX, DX)) == NULL)
if ((nls = searchPackage(pr->BX, pr->DX)) == NULL)
return DE_INVLDFUNC; /* no such package */
log(("NLS: MUX14(): NLS pkg found\n"));
switch (AL)
switch (pr->AL)
{
case NLSFUNC_INSTALL_CHECK:
BX = NLS_FREEDOS_NLSFUNC_ID;
pr->BX = NLS_FREEDOS_NLSFUNC_ID;
return SUCCESS; /* kernel just simulates default functions */
case NLSFUNC_DOS38:
return nlsGetData(nls, NLS_DOS_38, MK_FP(ES, DI), 34);
return nlsGetData(nls, NLS_DOS_38, MK_FP(pr->ES, pr->DI), 34);
case NLSFUNC_GETDATA:
return nlsGetData(nls, BP, MK_FP(ES, DI), CX);
return nlsGetData(nls, pr->BP, MK_FP(pr->ES, pr->DI), pr->CX);
case NLSFUNC_DRDOS_GETDATA:
/* Does not pass buffer length */
return nlsGetData(nls, CL, MK_FP(ES, DI), 512);
return nlsGetData(nls, pr->CL, MK_FP(pr->ES, pr->DI), 512);
case NLSFUNC_LOAD_PKG:
return nlsLoadPackage(nls);
case NLSFUNC_LOAD_PKG2:
return nlsSetPackage(nls);
case NLSFUNC_YESNO:
return nlsYesNo(nls, CX);
return nlsYesNo(nls, pr->CX);
case NLSFUNC_UPMEM:
nlsUpMem(nls, MK_FP(ES, DI), CX);
nlsUpMem(nls, MK_FP(pr->ES, pr->DI), pr->CX);
return SUCCESS;
case NLSFUNC_FILE_UPMEM:
#ifdef NLS_DEBUG
{
unsigned j;
BYTE FAR *p;
log(("NLS: MUX14(FILE_UPMEM): len=%u, %04x:%04x=\"", CX, ES, DI));
for (j = 0, p = MK_FP(ES, DI); j < CX; ++j)
log(("NLS: MUX14(FILE_UPMEM): len=%u, %04x:%04x=\"", pr->CX,
pr->ES, pr->DI));
for (j = 0, p = MK_FP(pr->ES, pr->DI); j < pr->CX; ++j)
printf("%c", p[j] > 32 ? p[j] : '.');
printf("\"\n");
}
#endif
nlsFUpMem(nls, MK_FP(ES, DI), CX);
nlsFUpMem(nls, MK_FP(pr->ES, pr->DI), pr->CX);
return SUCCESS;
}
log(("NLS: MUX14(): Invalid function %x\n", AL));
log(("NLS: MUX14(): Invalid function %x\n", pr->AL));
return DE_INVLDFUNC; /* no such function */
}

View File

@ -14,15 +14,15 @@ _nlsPackageHardcoded:
DB 000h, 000h, 000h, 000h, 001h, 000h, 0b5h, 001h
DB 00fh, 000h, 059h, 000h, 04eh, 000h, 006h, 000h
DB 002h
DW ?table2, SEG ?table2
DW ?table2, DGROUP
DB 004h
DW ?table4, SEG ?table4
DW ?table4, DGROUP
DB 005h
DW ?table5, SEG ?table5
DW ?table5, DGROUP
DB 006h
DW ?table6, SEG ?table6
DW ?table6, DGROUP
DB 007h
DW ?table7, SEG ?table7
DW ?table7, DGROUP
GLOBAL _nlsCountryInfoHardcoded
_nlsCountryInfoHardcoded:
DB 001h
@ -32,8 +32,8 @@ _nlsCntryInfoHardcoded:
DB 01ch, 000h, 001h, 000h, 0b5h, 001h, 000h, 000h
DB 024h, 000h, 000h, 000h, 000h, 02ch, 000h, 02eh
DB 000h, 02dh, 000h, 03ah, 000h, 000h, 002h, 000h
extern _CharMapSrvc:wrt DGROUP
DW _CharMapSrvc, SEG _CharMapSrvc
extern _CharMapSrvc
DW _CharMapSrvc, DGROUP
DB 02ch, 000h
GLOBAL _hcTablesStart
_hcTablesStart:

View File

@ -29,7 +29,11 @@
#include "portab.h"
#ifdef FORSYS
#ifdef __GNUC__
#include <unistd.h>
#else
#include <io.h>
#endif
#include <stdarg.h>
#endif
@ -69,6 +73,12 @@ void put_console(int c)
_DX = FP_OFF(buff);
_AX = 0x13;
__int__(0xe6);
#elif defined(__GNUC__)
asm volatile(
"int $0xe6\n"
: /* outputs */
: /* inputs */ "a"(0x13), "e"(FP_SEG(buff)), "d"(FP_OFF(buff))
);
#elif defined(I86)
asm
{
@ -89,7 +99,14 @@ void put_console(int c)
#else
#ifdef __WATCOMC__
void int29(char c);
#pragma aux int29 = "int 0x29" parm [al] modify exact [bx];
#pragma aux int29 = "int 0x29" __parm [__al] __modify __exact [__bx];
#ifdef DEBUG_PRINT_COMPORT
void fastComPrint(char c);
#pragma aux fastComPrint = \
"mov bx, 0xFD05" \
"int 0x29" __parm [__al] __modify __exact [__bx];
#endif
#endif
void put_console(int c)
@ -105,6 +122,11 @@ void put_console(int c)
__int__(0x29);
#elif defined(__WATCOMC__)
int29(c);
#if defined DEBUG_PRINT_COMPORT
fastComPrint(c);
#endif
#elif defined(__GNUC__)
asm volatile("int $0x29" : : "a"(c) : "bx");
#elif defined(I86)
__asm
{
@ -145,6 +167,11 @@ STATIC VOID handle_char(COUNT c)
if (charp == 0)
put_console(c);
else
#ifdef DEBUG_PRINT_COMPORT
if (charp == (BYTE SSFAR *)-1)
fastComPrint(c);
else
#endif
*charp++ = c;
}
@ -152,7 +179,8 @@ STATIC VOID handle_char(COUNT c)
STATIC void ltob(LONG n, BYTE SSFAR * s, COUNT base)
{
ULONG u;
BYTE SSFAR *p, SSFAR *q;
BYTE SSFAR *p;
BYTE SSFAR *q;
int c;
u = n;
@ -224,12 +252,25 @@ int VA_CDECL sprintf(char * buff, CONST char * fmt, ...)
return 0;
}
#ifdef DEBUG_PRINT_COMPORT
int dbgc_printf(CONST char * fmt, ...)
{
va_list arg;
va_start(arg, fmt);
charp = (BYTE SSFAR *)-1;
do_printf(fmt, arg);
handle_char('\0');
return 0;
}
#endif
STATIC void do_printf(CONST BYTE * fmt, va_list arg)
{
int base;
BYTE s[11], FAR * p;
int size;
unsigned char flags;
int base, size;
BYTE s[13]; /* long enough for a 32-bit octal number string with sign */
BYTE flags;
BYTE FAR *p;
for (;*fmt != '\0'; fmt++)
{
@ -387,7 +428,7 @@ void hexd(char *title, UBYTE FAR * p, COUNT numBytes)
{
put_unsigned(p[loop], 16, 2);
put_console(' ');
}
}
for (loop = start; loop < numBytes && loop < start+16;loop++)
put_console(p[loop] < 0x20 ? '.' : p[loop]);
put_console('\n');

View File

@ -31,10 +31,10 @@
%include "segs.inc"
extern _user_r:wrt DGROUP
extern _user_r
extern _break_flg:wrt DGROUP ; break detected flag
extern _int21_handler:wrt DGROUP ; far call system services
extern _break_flg ; break detected flag
extern _int21_handler ; far call system services
%include "stacks.inc"
@ -71,7 +71,7 @@ _exec_user:
;
POP$ALL
extern _ExecUserDisableA20
jmp far _ExecUserDisableA20
jmp DGROUP:_ExecUserDisableA20
do_iret:
extern _int21_iret
jmp _int21_iret
@ -263,7 +263,7 @@ _spawn_int23:
??int23_respawn:
pop bp ;; Restore the original register
jmp far _int21_handler
jmp DGROUP:_int21_handler
;
; interrupt enable and disable routines

View File

@ -54,7 +54,7 @@ unsigned char ctrl_break_pressed(void);
unsigned char check_handle_break(struct dhdr FAR **pdev);
void handle_break(struct dhdr FAR **pdev, int sft_out);
#ifdef __WATCOMC__
#pragma aux handle_break aborts;
#pragma aux handle_break __aborts;
#endif
/* chario.c */
@ -102,8 +102,8 @@ COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s);
COUNT DosChangeDir(BYTE FAR * s);
COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name);
COUNT DosFindNext(void);
COUNT DosGetFtime(COUNT hndl, date * dp, time * tp);
COUNT DosSetFtimeSft(int sft_idx, date dp, time tp);
COUNT DosGetFtime(COUNT hndl, ddate * dp, dtime * tp);
COUNT DosSetFtimeSft(int sft_idx, ddate dp, dtime tp);
#define DosSetFtime(hndl, dp, tp) DosSetFtimeSft(get_sft_idx(hndl), (dp), (tp))
COUNT DosGetFattr(BYTE FAR * name);
COUNT DosSetFattr(BYTE FAR * name, UWORD attrp);
@ -118,6 +118,7 @@ COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock);
int idx_to_sft_(int SftIndex);
sft FAR *idx_to_sft(int SftIndex);
int get_sft_idx(UCOUNT hndl);
struct cds FAR *get_cds_unvalidated(unsigned dsk);
struct cds FAR *get_cds(unsigned dsk);
struct cds FAR *get_cds1(unsigned dsk);
COUNT DosTruename(const char FAR * src, char FAR * dest);
@ -126,8 +127,8 @@ COUNT DosTruename(const char FAR * src, char FAR * dest);
VOID ASMCFUNC DosIdle_int(void);
VOID ASMCFUNC DosIdle_hlt(void);
#ifdef __WATCOMC__
#pragma aux (cdecl) DosIdle_int modify exact []
#pragma aux (cdecl) DosIdle_hlt modify exact []
#pragma aux (__cdecl) DosIdle_int __modify __exact []
#pragma aux (__cdecl) DosIdle_hlt __modify __exact []
#endif
/* error.c */
@ -157,8 +158,8 @@ COUNT dos_close(COUNT fd);
COUNT dos_delete(BYTE * path, int attrib);
COUNT dos_rmdir(BYTE * path);
COUNT dos_rename(BYTE * path1, BYTE * path2, int attrib);
date dos_getdate(void);
time dos_gettime(void);
ddate dos_getdate(void);
dtime dos_gettime(void);
COUNT dos_mkdir(BYTE * dir);
BOOL last_link(f_node_ptr fnp);
COUNT map_cluster(REG f_node_ptr fnp, COUNT mode);
@ -217,11 +218,13 @@ void FcbCloseAll(void);
UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First);
/* intr.asm */
UWORD ASMPASCAL call_intr(WORD nr, iregs FAR * rp);
COUNT ASMPASCAL res_DosExec(COUNT mode, exec_blk * ep, BYTE * lp);
UCOUNT ASMPASCAL res_read(int fd, void *buf, UCOUNT count);
#ifdef __WATCOMC__
#pragma aux (pascal) res_DosExec modify exact [ax bx dx es]
#pragma aux (pascal) res_read modify exact [ax bx cx dx]
#pragma aux (__pascal) call_intr __modify __exact [__ax]
#pragma aux (__pascal) res_DosExec __modify __exact [__ax __bx __dx __es]
#pragma aux (__pascal) res_read __modify __exact [__ax __bx __cx __dx]
#endif
/* ioctl.c */
@ -247,7 +250,7 @@ VOID mcb_print(mcb FAR * mcbp);
COUNT lfn_allocate_inode(VOID);
COUNT lfn_free_inode(COUNT handle);
COUNT lfn_setup_inode(COUNT handle, ULONG dirstart, UWORD diroff);
COUNT lfn_setup_inode(COUNT handle, ULONG dirstart, ULONG diroff);
COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip);
COUNT lfn_remove_entries(COUNT handle);
@ -276,7 +279,7 @@ COUNT DosSetCountry(UWORD cntry);
COUNT DosGetCodepage(UWORD * actCP, UWORD * sysCP);
COUNT DosSetCodepage(UWORD actCP, UWORD sysCP);
VOID FAR *DosGetDBCS(void);
UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS);
UWORD ASMCFUNC syscall_MUX14(iregs FAR *);
/* prf.c */
#ifdef DEBUG
@ -315,21 +318,21 @@ int /*ASMCFUNC*/ ASMPASCAL fmemcmp(const void FAR *m1, const void FAR *m2, size_
#ifdef __WATCOMC__
/* bx, cx, dx and es not used or clobbered for all asmsupt.asm functions except
(f)memchr/(f)strchr (which clobber dx) */
#pragma aux (pascal) pascal_ax modify exact [ax]
#pragma aux (__pascal) pascal_ax __modify __exact [__ax]
#pragma aux (pascal_ax) fmemcpy
#pragma aux (pascal_ax) memcpy
#pragma aux (pascal_ax) fmemset
#pragma aux (pascal_ax) memset
#pragma aux (pascal_ax) fmemcmp modify nomemory
#pragma aux (pascal_ax) memcmp modify nomemory
#pragma aux (pascal_ax) fmemcmp __modify __nomemory
#pragma aux (pascal_ax) memcmp __modify __nomemory
#pragma aux (pascal_ax) fstrcpy
#pragma aux (pascal_ax) strcpy
#pragma aux (pascal_ax) fstrlen modify nomemory
#pragma aux (pascal_ax) strlen modify nomemory
#pragma aux (pascal) memchr modify exact [ax dx] nomemory
#pragma aux (pascal) fmemchr modify exact [ax dx] nomemory
#pragma aux (pascal) strchr modify exact [ax dx] nomemory
#pragma aux (pascal) fstrchr modify exact [ax dx] nomemory
#pragma aux (pascal_ax) fstrlen __modify __nomemory
#pragma aux (pascal_ax) strlen __modify __nomemory
#pragma aux (__pascal) memchr __modify __exact [__ax __dx] __nomemory
#pragma aux (__pascal) fmemchr __modify __exact [__ax __dx] __nomemory
#pragma aux (__pascal) strchr __modify __exact [__ax __dx] __nomemory
#pragma aux (__pascal) fstrchr __modify __exact [__ax __dx] __nomemory
#endif
/* sysclk.c */
@ -374,6 +377,7 @@ int network_redirector_fp(unsigned cmd, void far *s);
long ASMPASCAL network_redirector_mx(unsigned cmd, void far *s, void *arg);
#define remote_rw(cmd,s,arg) network_redirector_mx(cmd, s, (void *)arg)
#define remote_getfree(s,d) (int)network_redirector_mx(REM_GETSPACE, s, d)
#define remote_getfree_11a3(s,d) (int)network_redirector_mx(REM_GETLARGESPACE, s, d)
#define remote_lseek(s,new_pos) network_redirector_mx(REM_LSEEK, s, &new_pos)
#define remote_setfattr(attr) (int)network_redirector_mx(REM_SETATTR, NULL, (void *)attr)
#define remote_printredir(dx,ax) (int)network_redirector_mx(REM_PRINTREDIR, MK_FP(0,dx),(void *)ax)

View File

@ -43,57 +43,81 @@ CPU XCPU
%define WATCOM
%endif
%ifidn __OUTPUT_FORMAT__, obj
group PGROUP PSP
group LGROUP _IRQTEXT _LOWTEXT _IO_TEXT _IO_FIXED_DATA _TEXT
group DGROUP _FIXED_DATA _BSS _DATA _DATAEND CONST CONST2 DCONST DYN_DATA
%ifdef WATCOM
group TGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END INIT_TEXT_START INIT_TEXT INIT_TEXT_END
%define IGROUP TGROUP
group I_GROUP ID_B I_DATA ICONST ICONST2 ID_E IB_B I_BSS IB_E
%else
group TGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END
group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END
group I_GROUP ID_B ID ID_E IC IDATA IB_B IB IB_E
%endif
%define class(x) class=x
%define nobits
%define exec
%define INITSIZE init_end wrt INIT_TEXT
%define INITTEXTSIZE __INIT_DATA_START wrt INIT_TEXT
segment PSP class=PSP
segment _IRQTEXT class=LCODE
segment _LOWTEXT class=LCODE
segment _IO_TEXT class=LCODE
segment _IO_FIXED_DATA class=LCODE align=2
segment _TEXT class=LCODE
segment _FIXED_DATA class=FDATA align=16
segment _BSS class=BSS align=2
segment _DATA class=DATA align=2
segment _DATAEND class=DATA align=1
%else ; using ELF
BITS 16
; groups are defined in the linker script kernel.ld
extern PGROUP
extern DGROUP
extern LGROUP
extern TGROUP
extern IGROUP
extern I_GROUP
%define class(x)
%define stack
extern INITSIZE
%define INITTEXTSIZE __InitTextEnd
%endif
segment PSP class(PSP)
segment _IRQTEXT class(LCODE) exec
segment _LOWTEXT class(LCODE) exec
segment _IO_TEXT class(LCODE) exec
segment _IO_FIXED_DATA class(LCODE) align=2
segment _TEXT class(LCODE) exec
segment _FIXED_DATA class(FDATA) align=16
segment _BSS class(BSS) align=2
segment _DATA class(DATA) align=2
segment _DATAEND class(DATA) align=1
;for WATCOM
segment CONST class=DATA align=2
segment CONST2 class=DATA align=2
segment CONST class(DATA) align=2
segment CONST2 class(DATA) align=2
;for MSC
segment DCONST class=DCONST align=2
segment DYN_DATA class=DYN_DATA
segment HMA_TEXT_START class=CODE align=16
segment HMA_TEXT class=CODE
segment HMA_TEXT_END class=CODE
segment INIT_TEXT_START class=CODE align=16
segment INIT_TEXT class=CODE
segment INIT_TEXT_END class=CODE
segment DCONST class(DCONST) align=2
segment DYN_DATA class(DYN_DATA)
segment HMA_TEXT_START class(CODE) align=16
segment HMA_TEXT class(CODE) exec
segment HMA_TEXT_END class(CODE) align=16
segment INIT_TEXT_START class(CODE) align=16
segment INIT_TEXT class(CODE) exec
segment INIT_TEXT_END class(CODE) align=16
%ifdef WATCOM
segment ID_B class=FAR_DATA align=16
segment I_DATA class=FAR_DATA align=2
segment ICONST class=FAR_DATA align=2
segment ICONST2 class=FAR_DATA align=2
segment ID_E class=FAR_DATA align=2
segment IB_B class=FAR_DATA align=2
segment I_BSS class=FAR_DATA align=2
segment IB_E class=FAR_DATA align=2
segment ID_B class(FAR_DATA) align=16
segment I_DATA class(FAR_DATA) align=2
segment ICONST class(FAR_DATA) align=2
segment ICONST2 class(FAR_DATA) align=2
segment ID_E class(FAR_DATA) align=2
segment IB_B class(FAR_DATA) align=2
segment I_BSS class(FAR_DATA) align=2
segment IB_E class(FAR_DATA) align=2
%else
segment ID_B class=ID align=16
segment ID class=ID align=2
segment IDATA class=ID align=2
segment ID_E class=ID align=2
segment IC class=IC align=2
segment IB_B class=IB align=2
segment IB class=IB align=2
segment IB_E class=IB align=2
segment ID_B class(ID) align=16
segment ID class(ID) align=2
segment IDATA class(ID) align=2
segment ID_E class(ID) align=2
segment IC class(IC) align=2
segment IB_B class(IB) align=2 nobits
segment IB class(IB) align=2 nobits
segment IB_E class(IB) align=2 nobits
%endif

View File

@ -50,7 +50,7 @@ ComTable db 0Ah
segment _IO_TEXT
extern CommonNdRdExit:wrt LGROUP
extern CommonNdRdExit
ComRead:
jcxz ComRd3

Some files were not shown because too many files have changed in this diff Show More