From 6408796e0dddf2de53aeb04c6944431388a30722 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Fri, 1 Dec 2023 01:12:02 +0500 Subject: [PATCH 1/5] kernel: move HMA fillers to HMA_TEXT_START This avoids the need for the kernel.o to be linked before other objects. It also wastes ~200 bytes of HMA, but we have no shortage of the HMA space. --- kernel/kernel.asm | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 95cb75a8..5e919ff2 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -735,6 +735,7 @@ segment DYN_DATA align 10h global _Dyn _Dyn: + times 10h db 0 ; guard space from prev sym markEndInstanceData: ; mark end of DOS data seg we say needs instancing @@ -759,21 +760,16 @@ _InitEnd: segment HMA_TEXT_START align 10h - times 10h db 0 ; guard space from prev sym - global __HMATextAvailable -__HMATextAvailable: global __HMATextStart __HMATextStart: + times 0xd0 db 0 ; filler [ffff:0..10000:c0] + ; reserve space for far jump to cp/m routine + times 5 db 0 + align 10h + global __HMATextAvailable +__HMATextAvailable: -; -; the HMA area is filled with 1eh+3(=sizeof VDISK) = 33 byte dummy data, -; so nothing will ever be below 0xffff:0031 -; segment HMA_TEXT -begin_hma: - times 10h db 0 ; filler [ffff:0..ffff:10] - times 20h db 0 - db 0 ; to minimize relocations global _DGROUP_ @@ -791,10 +787,6 @@ __U4D: LDIVMODU %endif - times 0xd0 - ($-begin_hma) db 0 - ; reserve space for far jump to cp/m routine - times 5 db 0 - ;End of HMA segment segment HMA_TEXT_END global __HMATextEnd From 55c27e4aaefd3e9a7466e39cd29034bc0b193adf Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Tue, 5 Dec 2023 21:37:02 +0500 Subject: [PATCH 2/5] rename time.h to dosctime.h Needed to avoid clash with the system header of the same name. --- hdr/{time.h => dosctime.h} | 0 kernel/globals.h | 2 +- kernel/init-mod.h | 2 +- kernel/systime.c | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename hdr/{time.h => dosctime.h} (100%) diff --git a/hdr/time.h b/hdr/dosctime.h similarity index 100% rename from hdr/time.h rename to hdr/dosctime.h diff --git a/kernel/globals.h b/kernel/globals.h index 0c82eaa1..a031106c 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -38,7 +38,7 @@ static BYTE *Globals_hRcsId = #include "mcb.h" #include "pcb.h" #include "date.h" -#include "time.h" +#include "dosctime.h" #include "fat.h" #include "fcb.h" #include "tail.h" diff --git a/kernel/init-mod.h b/kernel/init-mod.h index b4b8f403..1b3a6635 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -4,7 +4,7 @@ #if 0 #include "version.h" #include "date.h" -#include "time.h" +#include "dosctime.h" #include "mcb.h" #include "sft.h" #include "fat.h" diff --git a/kernel/systime.c b/kernel/systime.c index 3c983bdb..553add1d 100644 --- a/kernel/systime.c +++ b/kernel/systime.c @@ -27,7 +27,7 @@ /****************************************************************/ #include "portab.h" -#include "time.h" +#include "dosctime.h" #include "date.h" #include "globals.h" From 97f66cef067c4dbaa5a8de1f0b11aef4b44461df Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Wed, 6 Dec 2023 16:31:25 +0500 Subject: [PATCH 3/5] underscore min/max macros To not collide with the same in libstdc++. --- hdr/portab.h | 8 ++++---- kernel/config.c | 4 ++-- kernel/dsk.c | 2 +- kernel/fatfs.c | 8 ++++---- kernel/task.c | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/hdr/portab.h b/hdr/portab.h index f3e499a4..41c3ffb5 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -315,11 +315,11 @@ typedef WORD BOOL; /* Convienence defines */ /* */ #define FOREVER while(TRUE) -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) +#ifndef _max +#define _max(a,b) (((a) > (b)) ? (a) : (b)) #endif -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) +#ifndef _min +#define _min(a,b) (((a) < (b)) ? (a) : (b)) #endif #ifdef WITHFAT32 diff --git a/kernel/config.c b/kernel/config.c index a0bac861..f2c849de 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -1564,7 +1564,7 @@ STATIC VOID Files(char * pLine) } /* Got the value, assign either default or new value */ - Config.cfgFiles = max(Config.cfgFiles, nFiles); + Config.cfgFiles = _max(Config.cfgFiles, nFiles); Config.cfgFilesHigh = 0; } @@ -1950,7 +1950,7 @@ STATIC BOOL LoadCountryInfo(char *filenam, UWORD ctryCode, UWORD codePage) nlsPackageHardcoded.cntry = entry.country; nlsPackageHardcoded.cp = entry.codepage; subf_data.length = /* MS-DOS "CTYINFO" is up to 38 bytes */ - min(subf_data.length, sizeof(struct CountrySpecificInfo)); + _min(subf_data.length, sizeof(struct CountrySpecificInfo)); } if (hdr[i].id == 7) { diff --git a/kernel/dsk.c b/kernel/dsk.c index ec20cb5b..ddc81ca4 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -950,7 +950,7 @@ STATIC unsigned DMA_max_transfer(void FAR * buffer, unsigned count) 0xffff / maxsecsize : (UWORD)(-dma_off) / maxsecsize); - return min(count, sectors_to_dma_boundary); + return _min(count, sectors_to_dma_boundary); } /* diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 7675bbd7..272f7e38 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -1386,7 +1386,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) sectors_to_xfer = fnp->f_dpb->dpb_clsmask + 1 - sector; - sectors_to_xfer = min(sectors_to_xfer, sectors_wanted); + sectors_to_xfer = _min(sectors_to_xfer, sectors_wanted); fnp->f_offset += sectors_to_xfer * secsize; @@ -1401,7 +1401,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) sectors_to_xfer += fnp->f_dpb->dpb_clsmask + 1; - sectors_to_xfer = min(sectors_to_xfer, sectors_wanted); + sectors_to_xfer = _min(sectors_to_xfer, sectors_wanted); fnp->f_offset = startoffset + sectors_to_xfer * secsize; @@ -1455,9 +1455,9 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) /* requested transfer size, whichever is smaller. */ /* Then compare to what is left, since we can transfer */ /* a maximum of what is left. */ - xfr_cnt = min(to_xfer, secsize - boff); + xfr_cnt = _min(to_xfer, secsize - boff); if (mode == XFR_READ) - xfr_cnt = (UWORD) min(xfr_cnt, fnp->f_dir.dir_size - fnp->f_offset); + xfr_cnt = (UWORD) _min(xfr_cnt, fnp->f_dir.dir_size - fnp->f_offset); /* transfer a block */ /* Transfer size as either a full block size, or the */ diff --git a/kernel/task.c b/kernel/task.c index ffc735f3..5e476295 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -505,7 +505,7 @@ STATIC COUNT DosComLoader(const char FAR * namep, exec_blk FAR * exp, COUNT mode ULONG com_size_long = SftGetFsize(fd); /* maximally 64k - 256 bytes stack - 256 bytes psp */ - com_size = ((UWORD)min(com_size_long, 0xfe00u) >> 4) + 0x10; + com_size = ((UWORD)_min(com_size_long, 0xfe00u) >> 4) + 0x10; } if ((mode & 0x7f) != OVERLAY) From a4381011021b27d885be70004331b5df999d80d6 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Wed, 6 Dec 2023 21:26:12 +0500 Subject: [PATCH 4/5] fatfs: fix NULL deref in fat32 code setdstart() was checking ISFAT32(dpbp) before dpbp was initialized. This produced various crashes and inconsistencies. Just remove the check and store the full cluster count. On fat16 it shouldn't exceed 16 bits anyway. --- kernel/fatfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 272f7e38..df603d68 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -69,8 +69,7 @@ CLUSTER getdstart(struct dpb FAR *dpbp, struct dirent *dentry) void setdstart(struct dpb FAR *dpbp, struct dirent *dentry, CLUSTER value) { dentry->dir_start = (UWORD)value; - if (ISFAT32(dpbp)) - dentry->dir_start_high = (UWORD)(value >> 16); + dentry->dir_start_high = (UWORD)(value >> 16); } #endif From a999999163a65a1581dd818bdf5efa1ec6533732 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Tue, 28 Nov 2023 21:33:41 +0500 Subject: [PATCH 5/5] initial meson support [#146] --- fdpp/{ => kernel}/cdata.S | 2 +- fdpp/kernel/makefile | 12 +-- fdpp/kernel/meson.build | 85 +++++++++++++++++++++ fdpp/{ => kernel}/plt.S | 0 fdpp/kernel/toolchain.ini | 13 ++++ fdpp/loader/meson.build | 25 ++++++ fdpp/meson.build | 151 +++++++++++++++++++++++++++++++++++++ fdpp/parsers/mkasmdefs.sh | 2 + fdpp/parsers/mkfar.sh | 2 + fdpp/thunk_gen/meson.build | 16 ++++ fdpp/toolchain.ini | 2 + hdr/version.h | 5 +- 12 files changed, 308 insertions(+), 7 deletions(-) rename fdpp/{ => kernel}/cdata.S (96%) create mode 100644 fdpp/kernel/meson.build rename fdpp/{ => kernel}/plt.S (100%) create mode 100644 fdpp/kernel/toolchain.ini create mode 100644 fdpp/loader/meson.build create mode 100644 fdpp/meson.build create mode 100644 fdpp/thunk_gen/meson.build create mode 100644 fdpp/toolchain.ini diff --git a/fdpp/cdata.S b/fdpp/kernel/cdata.S similarity index 96% rename from fdpp/cdata.S rename to fdpp/kernel/cdata.S index 15df49fd..cfea82b3 100644 --- a/fdpp/cdata.S +++ b/fdpp/kernel/cdata.S @@ -17,7 +17,7 @@ */ %include "segs.inc" -#include "../hdr/version.h" +#include "version.h" segment CONST2 diff --git a/fdpp/kernel/makefile b/fdpp/kernel/makefile index 0e5c0a63..e5985785 100644 --- a/fdpp/kernel/makefile +++ b/fdpp/kernel/makefile @@ -13,6 +13,8 @@ PPINC = $(TOP)/include/fdpp AVER = $(shell echo FDPP_API_VER | cpp -include $(PPINC)/thunks.h - | tail -n 1) BVER = $(shell echo BPRM_VER | cpp -include $(PPINC)/bprm.h - | tail -n 1) TARGET=fdppkrnl.$(AVER).$(BVER) +VERSION = 1.7 +CPPFLAGS += -I$(TOP)/fdpp NASMFLAGS += -i$(SRC) -i$(HDR) -f elf32 @@ -94,15 +96,15 @@ $(PPOBJS): %.o: %.asm makefile plt.o: plt.asm plt.inc $(SRC)/segs.inc -plt.asm: $(srcdir)/$(T)/plt.S $(SRC)/glob_asm.h $(TOP)/include/fdpp/bprm.h \ +plt.asm: $(srcdir)/plt.S $(SRC)/glob_asm.h $(TOP)/include/fdpp/bprm.h \ $(srcdir)/$(T)/thunks_priv.h $(srcdir)/makefile - $(CPP) -iquote $(PPINC) -P $< >$@ || ($(RM) $@ ; false) + $(CPP) $(CPPFLAGS) -iquote $(PPINC) -P $< >$@ || ($(RM) $@ ; false) GIT_DESCRIBE := $(shell git describe) -cdata.asm: $(srcdir)/$(T)/cdata.S $(HDR)/version.h $(GIT_REV) $(srcdir)/makefile - $(CPP) $(CPPFLAGS) -DKERNEL_VERSION="$(VERSION) [GIT: $(GIT_DESCRIBE)]" \ - -P $< | sed 's/" "/","/g' >$@ +cdata.asm: $(srcdir)/cdata.S $(HDR)/version.h $(GIT_REV) $(srcdir)/makefile + $(CPP) -iquote $(HDR) -DKERNEL_VERSION="$(VERSION) [GIT: $(GIT_DESCRIBE)]" \ + -DCMA=, -P $< >$@ thunk_calls.tmp: $(SRC)/proto.h srcdir=$(srcdir)/$(T)/parsers CPP="$(CPP)" \ diff --git a/fdpp/kernel/meson.build b/fdpp/kernel/meson.build new file mode 100644 index 00000000..6d739e6c --- /dev/null +++ b/fdpp/kernel/meson.build @@ -0,0 +1,85 @@ +project('kernel', ['nasm', 'c'], version: '1.7') +TOP = '../..' +PD = TOP / 'fdpp/parsers/parse_decls.sh' +SRC = TOP / 'kernel' +DSRC = SRC / 'drivers' +kernel_ld = TOP / 'kernel.ld' +rel_inc = TOP / 'include/fdpp' +abs_inc = meson.current_source_dir() / rel_inc +incdir = include_directories(rel_inc) +cpp = meson.get_compiler('c') +AVER = cpp.get_define('FDPP_API_VER', + include_directories: incdir, + prefix: '#include "thunks.h"') +BVER = cpp.get_define('BPRM_VER', + include_directories: incdir, + prefix: '#include "bprm.h"') +FVER = AVER + '.' + BVER +TARGET = 'fdppkrnl.' + FVER +GIT_DESCRIBE = run_command('git', 'describe', check: true).stdout().strip() +hdr = [TOP / 'kernel', TOP / 'hdr', TOP / 'fdpp', rel_inc] +incdir2 = include_directories(hdr) +sfiles = cpp.preprocess(['cdata.S', 'plt.S'], + output : '@BASENAME@.asm', + include_directories: incdir2, + compile_args : [ + '-D__ASSEMBLER__', + '-DKERNEL_VERSION=' + meson.project_version() + + ' [GIT: ' + GIT_DESCRIBE + ']', + '-DCMA=,', '-P']) +env = environment() +env.set('CPP', 'cpp') +env.set('srcdir', meson.current_source_dir() / '../parsers') +tct = custom_target('thunk_calls.tmp', + output: 'thunk_calls.tmp', + input: SRC / 'proto.h', + env: env, + command: [PD, '1', '@INPUT@'], + capture: true) +plt_inc = custom_target('plt.inc', + output: 'plt.inc', + input: tct, + command: [PD, '3', '@INPUT@'], + capture: true) + +SRCS = [ + SRC/'console.asm', + SRC/'cpu.asm', + SRC/'dosidle.asm', + SRC/'entry.asm', + SRC/'execrh.asm', + SRC/'int2f.asm', + SRC/'intr.asm', + SRC/'io.asm', + SRC/'irqstack.asm', + SRC/'kernel.asm', + SRC/'nls_hc.asm', + SRC/'nlssupt.asm', + SRC/'printer.asm', + SRC/'procsupt.asm', + SRC/'serial.asm', + + DSRC/'floppy.asm', + DSRC/'rdpcclk.asm', + DSRC/'wrpcclk.asm', + DSRC/'wratclk.asm', +] + +nargs = ['-DXCPU=186', '-DWITHFAT32', '-DFDPP'] + +lib = static_library('dummy', + [SRCS, sfiles, plt_inc], + include_directories: incdir2, + nasm_args: nargs, + build_by_default: false) +nasm_ld = find_program(['i686-linux-gnu-ld', 'i386-elf-ld', 'x86_64-linux-gnu-ld', 'ld']) +custom_target(TARGET + '.elf', + output: [TARGET + '.elf', TARGET + '.map'], + input: lib.extract_all_objects(recursive: true), + command: [nasm_ld, '-melf_i386', '-static', + '-Map=@OUTPUT1@', '-o', '@OUTPUT0@', + '--emit-relocs', '-T' + kernel_ld, '@INPUT@'], + install: true, + install_dir: get_option('datadir') / 'fdpp', + install_mode: 'rw-r--r--', + build_by_default: true) diff --git a/fdpp/plt.S b/fdpp/kernel/plt.S similarity index 100% rename from fdpp/plt.S rename to fdpp/kernel/plt.S diff --git a/fdpp/kernel/toolchain.ini b/fdpp/kernel/toolchain.ini new file mode 100644 index 00000000..0ba25d6a --- /dev/null +++ b/fdpp/kernel/toolchain.ini @@ -0,0 +1,13 @@ +[binaries] +nasm = 'nasm-segelf' +c = 'gcc' +strip = 'llvm-strip' + +[constants] +arch = 'i386-linux-gnu' + +[host_machine] +system = 'linux' +cpu_family = 'x86' +cpu = 'i386' +endian = 'little' diff --git a/fdpp/loader/meson.build b/fdpp/loader/meson.build new file mode 100644 index 00000000..5e7846b2 --- /dev/null +++ b/fdpp/loader/meson.build @@ -0,0 +1,25 @@ +project('loader', 'c', version: '0.1') +TOP = '../..' +rel_inc = TOP / 'include/fdpp' +abs_inc = meson.current_source_dir() / rel_inc +lelf = dependency('libelf') +incdir = include_directories(rel_inc) +cpp = meson.get_compiler('c') +AVER = cpp.get_define('FDPP_API_VER', + include_directories: incdir, + prefix: '#include "thunks.h"') +BVER = cpp.get_define('BPRM_VER', + include_directories: incdir, + prefix: '#include "bprm.h"') +FVER = AVER + '.' + BVER +TARGET = 'fdppkrnl.' + FVER +shared_library('fdldr', 'elf.c', 'loader.c', + dependencies: lelf, include_directories: incdir, + version: FVER, + c_args: [ + '-DFDPPKRNLDIR=' + get_option('prefix') / get_option('datadir') / 'fdpp', + '-DKRNL_ELFNAME=' + TARGET + '.elf', + '-DKRNL_MAP_NAME=' + TARGET + '.map' + ], + install: true, + install_dir: get_option('libdir') / 'fdpp') diff --git a/fdpp/meson.build b/fdpp/meson.build new file mode 100644 index 00000000..09d22971 --- /dev/null +++ b/fdpp/meson.build @@ -0,0 +1,151 @@ +project('libfdpp', ['c', 'cpp'], version: '0.1') +TOP = '..' +MF = meson.current_source_dir() / 'parsers/mkfar.sh' +MA = meson.current_source_dir() / 'parsers/mkasmdefs.sh' +PD = meson.current_source_dir() / 'parsers/parse_decls.sh' +M4 = meson.current_source_dir() / 'parsers/thunks.m4' +TG = './thunk_gen/build/thunk_gen' +TFLAGS = ['-a', '2', '-p', '2'] +SRC = TOP / 'kernel' +rel_inc = TOP / 'include/fdpp' +abs_inc = meson.current_source_dir() / rel_inc +incdir = include_directories(rel_inc) +cpp = meson.get_compiler('c') +AVER = cpp.get_define('FDPP_API_VER', + include_directories: incdir, + prefix: '#include "thunks.h"') +BVER = cpp.get_define('BPRM_VER', + include_directories: incdir, + prefix: '#include "bprm.h"') +FVER = AVER + '.' + BVER +TARGET = 'fdppkrnl.' + FVER + +CFILES = [ + SRC / 'blockio.c', + SRC / 'break.c', + SRC / 'chario.c', + SRC / 'dosfns.c', + SRC / 'dsk.c', + SRC / 'error.c', + SRC / 'fatdir.c', + SRC / 'fatfs.c', + SRC / 'fattab.c', + SRC / 'fcbfns.c', + SRC / 'hmamgr.c', + SRC / 'inthndlr.c', + SRC / 'ioctl.c', + SRC / 'memmgr.c', + SRC / 'misc.c', + SRC / 'newstuff.c', + SRC / 'network.c', + SRC / 'nls.c', + SRC / 'strings.c', + SRC / 'sysclk.c', + SRC / 'systime.c', + SRC / 'task.c', + SRC / 'config.c', + SRC / 'initoem.c', + SRC / 'main.c', + SRC / 'inithma.c', + SRC / 'dyninit.c', + SRC / 'initdisk.c', + SRC / 'initclk.c', + SRC / 'prf.c', + SRC / 'share.c'] + +ccgen = generator(find_program(MF), + output: '@BASENAME@.cc', + arguments: '@INPUT@', + capture: true) +ccfiles = ccgen.process(CFILES) + +gad = custom_target('glob_asmdefs.h', + output: 'glob_asmdefs.h', + input: SRC / 'glob_asm.h', + command: [MA, '@INPUT@'], + capture: true) + +GEN_TMP = { '1':'thunk_calls.tmp', '2':'thunk_asms.tmp' } +GEN_H = { 'plt_asmc.h':'4', 'plt_asmp.h':'5' } + +env = environment() +env.set('CPP', 'cpp') +env.set('srcdir', meson.current_source_dir() / 'parsers') +pd = find_program(PD) +gtgen = generator(pd, + arguments: ['@EXTRA_ARGS@', '@INPUT@'], + output: '@BASENAME@.tmp', + capture: true) +gt = [] +foreach n: GEN_TMP.keys() + gt += gtgen.process(SRC / 'proto.h', + extra_args: n, + env: ['CPP=cpp', 'srcdir=' + meson.current_source_dir() / 'parsers']) +endforeach +GEN = { GEN_TMP['1']:gt[0], GEN_TMP['2']:gt[1] } +pac = custom_target('plt_asmc.h', + output: 'plt_asmc.h', + input: GEN['thunk_asms.tmp'], + command: [PD, GEN_H['plt_asmc.h'], '@INPUT@'], + env: env, + capture: true) +pap = custom_target('plt_asmp.h', + output: 'plt_asmp.h', + input: GEN['thunk_asms.tmp'], + command: [PD, GEN_H['plt_asmp.h'], '@INPUT@'], + env: env, + capture: true) + +tc = custom_target('thunk_calls.h', + output: 'thunk_calls.h', + input: GEN['thunk_calls.tmp'], + command: [TG, TFLAGS], + feed: true, + capture: true) + +ta1 = custom_target('thunk_asms1.h', + output: 'thunk_asms1.h', + input: GEN['thunk_asms.tmp'], + command: [TG, TFLAGS, '1'], + feed: true, + capture: true) + +ta2 = custom_target('thunk_asms2.h', + output: 'thunk_asms2.h', + input: GEN['thunk_asms.tmp'], + command: [TG, TFLAGS, '2'], + feed: true, + capture: true) + +find_program('autom4te') +ta = custom_target('thunk_asms.h', + output: 'thunk_asms.h', + input: [ta1, ta2], + command: ['sh', '-c', 'cat @INPUT0@ | sort | uniq | autom4te -l m4sugar ' + + M4 + ' - | cat - @INPUT1@'], + capture: true) + +FDPP_CFILES = ['smalloc.c', 'farhlp_sta.c'] +ccgen = generator(find_program('echo'), + arguments: ['#include', '"@INPUT@"'], + output: '@BASENAME@.cc', + capture: true) +ppccf = ccgen.process(FDPP_CFILES) + +FDPP_CCFILES = ['thunks.cc', 'thunks_c.cc', 'thunks_a.cc', 'thunks_p.cc', + 'dosobj.cc'] +CPPFILES = ['objhlp.cpp', 'ctors.cpp', 'farhlp.cpp', 'objtrace.cpp'] +hdr = [TOP / 'kernel', TOP / 'hdr', TOP / 'fdpp', rel_inc] +incdir2 = include_directories(hdr) +shared_library('fdpp', [ccfiles, ppccf, FDPP_CCFILES, CPPFILES], + include_directories: incdir2, + version: FVER, + sources: [gad, pac, pap, tc, ta], + cpp_args: ['-DFDPP', '-DDEBUG', '-DWITHFAT32', + '-fno-threadsafe-statics', + '-Werror=packed-non-pod', '-Wno-unknown-warning-option', + '-Wno-format-invalid-specifier', '-Wno-c99-designator' + ], + link_args: ['-Wl,-Bsymbolic'], + install: true, + install_dir: get_option('libdir') / 'fdpp') diff --git a/fdpp/parsers/mkasmdefs.sh b/fdpp/parsers/mkasmdefs.sh index 053ebeee..11c163e2 100755 --- a/fdpp/parsers/mkasmdefs.sh +++ b/fdpp/parsers/mkasmdefs.sh @@ -1,3 +1,5 @@ +#!/bin/sh + grep "__ASM(" $1 | grep -v '^/' | grep -v '#define' | \ sed -E 's/.+, (.+)\).*/#define \1 __ASYM\(__\1\)/' grep "__ASM_ARR(" $1 | grep -v '^/' | grep -v '#define' | \ diff --git a/fdpp/parsers/mkfar.sh b/fdpp/parsers/mkfar.sh index 18d53ccf..0b9da078 100755 --- a/fdpp/parsers/mkfar.sh +++ b/fdpp/parsers/mkfar.sh @@ -1,3 +1,5 @@ +#!/bin/sh + mkfar() { sed -E \ -e ':loop' \ diff --git a/fdpp/thunk_gen/meson.build b/fdpp/thunk_gen/meson.build new file mode 100644 index 00000000..dbaf0c71 --- /dev/null +++ b/fdpp/thunk_gen/meson.build @@ -0,0 +1,16 @@ +project('thunk_gen', 'c', version: '0.1') + +flex = find_program('flex', required: true) +bison = find_program('bison', required: true) + +lgen = generator(flex, + output : '@PLAINNAME@.yy.c', + arguments : ['-o', '@OUTPUT@', '@INPUT@']) +lfiles = lgen.process('thunk_gen.l') + +pgen = generator(bison, + output : ['@BASENAME@.tab.c', '@BASENAME@.tab.h'], + arguments : ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@']) +pfiles = pgen.process('thunk_gen.y') + +executable('thunk_gen', lfiles, pfiles) diff --git a/fdpp/toolchain.ini b/fdpp/toolchain.ini new file mode 100644 index 00000000..48ec5042 --- /dev/null +++ b/fdpp/toolchain.ini @@ -0,0 +1,2 @@ +[binaries] +cpp = 'clang++' diff --git a/hdr/version.h b/hdr/version.h index dc3bdc78..3ac23e74 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -45,6 +45,9 @@ #endif /* actual version string */ -#define KVS(v) "FDPP kernel " #v " (compiled " __DATE__ ")" +#ifndef CMA +#define CMA +#endif +#define KVS(v) "FDPP kernel " CMA #v CMA " (compiled " CMA __DATE__ CMA ")" #define xKVS(v) KVS(v) #define KERNEL_VERSION_STRING xKVS(KERNEL_VERSION)