Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

New kernel compression methods - fdkernpl (Announce)

posted by ecm Homepage E-mail, Düsseldorf, Germany, 14.04.2020, 17:05

> Thanks! I guess I will need to look at the lzd.asm code --- and, if
> necessary, the fdkernpl.asm code --- to see how to stitch everything
> together.

Your best bet is to look at the mak.sh file in the lDebug repo or its sister in the RxDOS 7.2x repo. (They share most of their code.) In particular, there's this lzip run and this code which builds a compressed kernel. Adapting that to a non-EXE-mode FreeDOS kernel build gives us:

mkdir -p tmp/LZ \
&& nasm path/to/ldosboot/fdkernpl.asm -f bin \
-I path/to/lmacros/ \
-D_PAYLOAD_FILE="'path/to/kernel.sys'" \
-o tmp/FDKERNEL.BIN \
&& lzip -9vvfkc tmp/FDKERNEL.BIN > tmp/LZ/FDKERNEL.LZ \
&& nasm path/to/inicomp/inicomp.asm \
-I path/to/lmacros/ \
-I path/to/inicomp/ -D_LZD \
-o tmp/LZ/FDKERNEL.BIN \
-D_PAYLOAD_FILE="'tmp/LZ/FDKERNEL.LZ'" -D_EXEC_OFFSET=0 \
-D_IMAGE_EXE=0 \
&& nasm path/to/ldosboot/iniload.asm -f bin \
-I path/to/lmacros/ \
-I path/to/ldosboot/ \
-I path/to/scanptab/ \
-D_INILOAD_SIGNATURE="'FD'" \
-o tmp/LZ/FDKERNEL.SYS \
-D_PAYLOAD_FILE="'tmp/LZ/FDKERNEL.BIN'" -D_EXEC_OFFSET=0 \
-D_IMAGE_EXE=0


Note that you need the ldosboot, inicomp, scanptab, and lmacros repos. All of those are found on my bitbucket (legacy, hg support being dropped later this year) or my partner's hgweb server. You need lzip to compress the payload, and then you have to pass -D_LZD to the inicomp.asm build. The _PAYLOAD_FILE defines need to be wrapped in twofold quotemarks for bash, so as to pass literal quotemarks to NASM. I set the _INILOAD_SIGNATURE define to the string "FD" here, to indicate a FreeDOS kernel. The "build decomp test" step is only relevant for _IMAGE_EXE=1 kernels so I skipped all of that here.

Here's a test run doing all this, from the ldosboot subdirectory of an RxDOS 7.2x repo (this has all the needed repos as subrepos). The file kernel.sys holds the FreeDOS kernel to pack into our loader. tmp/LZ/FDKERNEL.SYS is the final kernel. I checked (in qemu) that it runs as expected.

rxdos/ldosboot$ hg id
408cd08cb836 tip
rxdos/ldosboot$ hg -R .. id
3f6090716e42 tip
rxdos/ldosboot$ mkdir -p tmp/LZ
rxdos/ldosboot$ nasm fdkernpl.asm -f bin -I ../lmacros/ -D_PAYLOAD_FILE="'kernel.sys'" -o tmp/FDKERNEL.BIN
rxdos/ldosboot$ lzip -9vvfkc tmp/FDKERNEL.BIN > tmp/LZ/FDKERNEL.LZ
  tmp/FDKERNEL.BIN:  1.886:1, 53.02% ratio, 46.98% saved, 80048 in, 42441 out.
rxdos/ldosboot$ nasm ../inicomp/inicomp.asm -I ../lmacros/ -I ../inicomp/ -D_LZD -o tmp/LZ/FDKERNEL.BIN -D_PAYLOAD_FILE="'tmp/LZ/FDKERNEL.LZ'" -D_EXEC_OFFSET=0 -D_IMAGE_EXE=0
../inicomp/lzd.asm:627: warning: localvariables has 14704 bytes [-w+user]
../inicomp/inicomp.asm:866: warning: inilz: 2736 bytes used for depacker [-w+user]
rxdos/ldosboot$ nasm ../ldosboot/iniload.asm -f bin -I ../lmacros/ -I ../ldosboot/ -I ../scanptab/ -D_INILOAD_SIGNATURE="'FD'" -o tmp/LZ/FDKERNEL.SYS -D_PAYLOAD_FILE="'tmp/LZ/FDKERNEL.BIN'" -D_EXEC_OFFSET=0 -D_IMAGE_EXE=0
../ldosboot/iniload.asm:743: warning: 0 bytes in front of ms7_entry [-w+user]
../ldosboot/iniload.asm:1138: warning: 3 bytes in front of ldos_entry [-w+user]
../ldosboot/iniload.asm:1526: warning: 15 bytes in front of end [-w+user]
../ldosboot/iniload.asm:1598: warning: 431 bytes in front of end2 [-w+user]
rxdos/ldosboot$


Here's the result:

rxdos/ldosboot$ ls -lgG kernel.sys tmp/ tmp/LZ/
-rw-r--r-- 1 79880 Sep 22  2017 kernel.sys

tmp/:
total 84
-rw-r--r-- 1 80048 Apr 14 15:57 FDKERNEL.BIN
drwxr-xr-x 2  4096 Apr 14 15:45 LZ

tmp/LZ/:
total 140
-rw-r--r-- 1 45184 Apr 14 15:58 FDKERNEL.BIN
-rw-r--r-- 1 42441 Apr 14 15:57 FDKERNEL.LZ
-rw-r--r-- 1 49120 Apr 14 15:58 FDKERNEL.SYS
rxdos/ldosboot$

---
l

 

Complete thread:

Back to the forum
Board view  Mix view
22632 Postings in 2109 Threads, 402 registered users, 396 users online (0 registered, 396 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum