diff --git a/CMakeLists.txt b/CMakeLists.txt index ae434cd..483fe2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,14 +82,27 @@ if(MARS_NWE_BUILD_DOSUTILS) ) add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/kern.obj" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ipx.obj" COMMAND "${CMAKE_COMMAND}" -E env ${OPENWATCOM_ENV} "${OPENWATCOM_WASM}" -q -zq - -fo="${CMAKE_CURRENT_BINARY_DIR}/kern.obj" - "${CMAKE_CURRENT_SOURCE_DIR}/kern_wasm.asm" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/kern_wasm.asm" + -fo="${CMAKE_CURRENT_BINARY_DIR}/ipx.obj" + "${CMAKE_CURRENT_SOURCE_DIR}/ipx.asm" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/ipx.asm" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + VERBATIM + ) + + add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ncpcall_asm.obj" + COMMAND "${CMAKE_COMMAND}" -E env ${OPENWATCOM_ENV} + "${OPENWATCOM_WASM}" + -q + -zq + -fo="${CMAKE_CURRENT_BINARY_DIR}/ncpcall_asm.obj" + "${CMAKE_CURRENT_SOURCE_DIR}/ncpcall.asm" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/ncpcall.asm" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" VERBATIM ) @@ -121,7 +134,8 @@ if(MARS_NWE_BUILD_DOSUTILS) DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${src}" "${CMAKE_CURRENT_SOURCE_DIR}/net.h" - "${CMAKE_CURRENT_SOURCE_DIR}/kern.h" + "${CMAKE_CURRENT_SOURCE_DIR}/ipx.h" + "${CMAKE_CURRENT_SOURCE_DIR}/ncpcall.h" "${CMAKE_CURRENT_SOURCE_DIR}/ncpapi.h" "${CMAKE_CURRENT_SOURCE_DIR}/nwcrypt.h" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" @@ -141,10 +155,12 @@ if(MARS_NWE_BUILD_DOSUTILS) -k32768 -fe="${CMAKE_CURRENT_BINARY_DIR}/net.exe" ${DOSUTILS_OBJECTS} - "${CMAKE_CURRENT_BINARY_DIR}/kern.obj" + "${CMAKE_CURRENT_BINARY_DIR}/ipx.obj" + "${CMAKE_CURRENT_BINARY_DIR}/ncpcall_asm.obj" DEPENDS ${DOSUTILS_OBJECTS} - "${CMAKE_CURRENT_BINARY_DIR}/kern.obj" + "${CMAKE_CURRENT_BINARY_DIR}/ipx.obj" + "${CMAKE_CURRENT_BINARY_DIR}/ncpcall_asm.obj" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" VERBATIM ) diff --git a/README.md b/README.md index 948a866..ebe8d96 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ The modern Client32 path is implemented through a small reusable helper layer: - `ncpapi.c` - `ncpapi.h` -- Client32 assembly entry points in `kern_wasm.asm` +- Client32 assembly entry points in `ncpcall.asm` The working sequence is: @@ -628,7 +628,7 @@ cmake --build build The CMake build: -- assembles `kern_wasm.asm` with `wasm` +- assembles `ipx.asm` and `ncpcall.asm` with `wasm` - compiles each C file to a binary-directory `.obj` - links `net.exe` from those binary-directory objects - keeps `.obj`/`.o` intermediate files out of the source directory @@ -676,7 +676,7 @@ They also install selected copies such as `login.exe`, `map.exe`, and `slist.exe ## Development notes -- `kern_wasm.asm` is the 16-bit Open Watcom assembly implementation used by the modern build. +- `ipx.asm` and `ncpcall.asm` are the split 16-bit Open Watcom assembly implementations used by the modern build. - `kern.c` was an experimental C-side test wrapper and is no longer required by the current Client32 FLAG/FLAGDIR path. - `ncpapi.c` and `ncpapi.h` contain reusable Client32 NCP helper functions for DOS tools. - `trustee.c` and `trustee.h` contain shared code for `GRANT`, `REVOKE`, and `REMOVE`. diff --git a/ipx.asm b/ipx.asm new file mode 100644 index 0000000..5df3791 --- /dev/null +++ b/ipx.asm @@ -0,0 +1,210 @@ +; +; mars-nwe-dosutils - NetWare/DOS utility tools. +; +; Copyright (C) 2026 Mario Fetka +; Copyright (C) 1993,1996 Martin Stover, Marburg, Germany +; +; This program is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version 2 +; of the License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this program; if not, see . + +; Purpose: Open Watcom WASM/MASM-syntax IPX and far-memory helper glue. +; Depends on: ipx.h declarations, netcall.c callers and net.h shared types. +; + + + +; ipx.asm +; +; Open Watcom WASM/MASM-syntax port of the IPX and xmemmove parts of +; the old TASM IDEAL kern.asm. +; Intended for 16-bit DOS large memory model builds on Linux with Open Watcom v2. +; +; Keep doc/kern.asm as the historical TASM source and use this split file for +; the reproducible Open Watcom build. + +.286 +.model large + +.data +enterIPX dd 0 + +.code + +public _IPXinit +public _IPXopen_socket +public _IPXclose_socket +public _IPXlisten +public _xmemmove +_IPXinit proc far + push bp + mov bp, sp + push ds + push si + push di + + mov ax, 7A00h + int 2Fh + cmp al, 0FFh + jne ipxinit_done + + mov cx, @data + mov ds, cx + mov word ptr enterIPX, di + mov ax, es + mov word ptr enterIPX+2, ax + mov al, 1 + +ipxinit_done: + mov ah, 0 + + pop di + pop si + pop ds + pop bp + ret +_IPXinit endp + +_xmemmove proc far + push bp + mov bp, sp + + ; far procedure stack layout, large model: + ; [bp+0] old bp + ; [bp+2] return offset + ; [bp+4] return segment + ; [bp+6] z offset + ; [bp+8] z segment + ; [bp+10] q offset + ; [bp+12] q segment + ; [bp+14] nmbr + + cli + mov cx, [bp+14] + or cx, cx + jz xmem_done + + push ds + push si + push di + pushf + + lds si, dword ptr [bp+10] + les di, dword ptr [bp+6] + cmp di, si + jl xmem_forward + + std + dec cx + add di, cx + add si, cx + inc cx + jmp xmem_copy + +xmem_forward: + cld + +xmem_copy: + rep movsb + + popf + pop di + pop si + pop ds + +xmem_done: + pop bp + sti + ret +_xmemmove endp + +_IPXopen_socket proc far + push bp + mov bp, sp + push ds + push si + push di + + ; int IPXopen_socket(UI sock, int live) + mov ax, [bp+8] ; live + mov dx, [bp+6] ; sock + mov bx, @data + mov ds, bx + mov bx, 0 + call dword ptr enterIPX + + cmp al, 0FFh + jne ipxopen_not_already + mov ax, -1 ; socket already open + jmp ipxopen_done + +ipxopen_not_already: + cmp al, 0FEh + jne ipxopen_ok + mov ax, -2 ; socket table full + jmp ipxopen_done + +ipxopen_ok: + mov ax, dx + +ipxopen_done: + pop di + pop si + pop ds + pop bp + ret +_IPXopen_socket endp + +_IPXclose_socket proc far + push bp + mov bp, sp + push ds + push si + push di + + ; void IPXclose_socket(UI sock) + mov dx, [bp+6] + mov bx, @data + mov ds, bx + mov bx, 1 + call dword ptr enterIPX + + pop di + pop si + pop ds + pop bp + ret +_IPXclose_socket endp + +_IPXlisten proc far + push bp + mov bp, sp + push ds + push si + push di + + ; int IPXlisten(ECB *ecb) + les si, dword ptr [bp+6] + mov bx, @data + mov ds, bx + mov bx, 4 + call dword ptr enterIPX + + pop di + pop si + pop ds + pop bp + mov ah, 0 + ret +_IPXlisten endp + +end diff --git a/ipx.h b/ipx.h new file mode 100644 index 0000000..c735ac9 --- /dev/null +++ b/ipx.h @@ -0,0 +1,73 @@ +/* + * mars-nwe-dosutils - NetWare/DOS utility tools. + * + * Copyright (C) 2026 Mario Fetka + * Copyright (C) 1993,1996 Martin Stover, Marburg, Germany + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +/* + * Purpose: C declarations for IPX packet structures and low-level IPX/far-memory assembly glue. + * Depends on: ipx.asm for Open Watcom builds, doc/kern.asm for the historical TASM source, and net.h for shared types. + */ + +#ifndef IPX_H +#define IPX_H + +#if defined(__WATCOMC__) +#define IPX_CALL _Cdecl +#else +#define IPX_CALL +#endif + +typedef struct { + uint8 checksum[2]; + uint16 packetlen; + uint8 tcontrol; + uint8 ptype; + uint8 dest_net[4]; + uint8 dest_node[6]; + uint16 dest_sock; /* HI LOW */ + uint8 source_net[4]; + uint8 source_node[6]; + uint16 source_sock; /* HI LOW */ +} IPX_HEADER; + +typedef struct { + uint8 *link_address; + FUNC_VOID esr_routine; + uint8 in_use_flag; + uint8 completition_code; + uint16 socket; /* HI LOW */ + uint8 ipx_workspace[4]; /* interner Gebrauch */ + uint8 drv_workspace[4]; /* interner Gebrauch */ + uint8 immediate_address[6]; /* HI LOW Node Address */ + uint16 fragment_count; /* Anzahl Fragment Buffers */ + uint8 *fragment_1; + uint16 fragment_1_size; + /* Können auch mehr sein */ +} ECB; + +extern int IPX_CALL IPXinit(void); +extern int IPX_CALL IPXopen_socket(UI sock, int live); +extern void IPX_CALL IPXclose_socket(UI sock); +extern int IPX_CALL IPXlisten(ECB *ecb); +extern void asm_esr_routine(void); +extern void esr_routine(ECB *ecb); +extern void IPX_CALL xmemmove(void *ziel, void *quelle, UI anz); + +#undef IPX_CALL + +#endif /* IPX_H */ diff --git a/kern.h b/kern.h deleted file mode 100644 index fc1bc51..0000000 --- a/kern.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * mars-nwe-dosutils - NetWare/DOS utility tools. - * - * Copyright (C) 2026 Mario Fetka - * Copyright (C) 1993,1996 Martin Stover, Marburg, Germany - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ - -/* - * Purpose: C declarations for the low-level DOS, IPX, NetWare requester and Client32 assembly glue. - * Depends on: kern_wasm.asm for Open Watcom builds, doc/kern.asm for the historical TASM source, and net.h for shared types. - */ - -#if defined(__WATCOMC__) -#define KERN_CALL _Cdecl -#else -#define KERN_CALL - - -#endif - -extern int KERN_CALL IPXinit(void); -extern int KERN_CALL IPXopen_socket(UI sock, int live); -extern void KERN_CALL IPXclose_socket(UI sock); -extern int KERN_CALL IPXlisten(ECB *ecb); -extern void asm_esr_routine(void); -extern void esr_routine(ECB *ecb); -extern void KERN_CALL xmemmove(void *ziel, void *quelle, UI anz); -extern int KERN_CALL Net_Call(UI func, void *req, void *repl); -extern int KERN_CALL ncp_mapvar_request(UI specLen, UI flag, void *outbuf); -extern int KERN_CALL ncp_openref_request(UI refLo, UI refHi, void *outbuf); -extern int KERN_CALL ncp_raw_request(UI connLo, UI connHi, - void *hdr, UI hdrLen, - void *path, UI pathLen, - void *rep0, UI rep0Len, - void *rep1, UI rep1Len, - void *outbuf); -#undef KERN_CALL - - diff --git a/map.c b/map.c index c990bf5..46416de 100644 --- a/map.c +++ b/map.c @@ -20,7 +20,7 @@ /* * Purpose: MAP and PATH command implementation for NetWare drive/search-drive mappings. - * Depends on: net.h, netcall.c requester helpers, tools.c shared utility routines, kern_wasm.asm/kern.asm low-level Net_Call glue. + * Depends on: net.h, netcall.c requester helpers, tools.c shared utility routines, ncpcall.asm/doc/kern.asm low-level Net_Call glue. */ #include "net.h" diff --git a/kern_wasm.asm b/ncpcall.asm similarity index 84% rename from kern_wasm.asm rename to ncpcall.asm index a59ffd2..bcec7a5 100644 --- a/kern_wasm.asm +++ b/ncpcall.asm @@ -17,198 +17,27 @@ ; You should have received a copy of the GNU General Public License ; along with this program; if not, see . -; Purpose: Open Watcom WASM/MASM-syntax port of the low-level DOS, IPX, NetWare requester and Client32 glue. -; Depends on: kern.h declarations, netcall.c and ncpapi.c callers, net.h shared types. +; Purpose: Open Watcom WASM/MASM-syntax NetWare requester and Client32 transport glue. +; Depends on: ncpcall.h declarations, ncpcall.c transport helpers and ncpapi.c API wrappers. ; -; kern_wasm.asm +; ncpcall.asm ; -; Open Watcom WASM/MASM-syntax port of the old TASM IDEAL kern.asm. -; Intended for 16-bit DOS large memory model builds on Linux with Open Watcom v2. -; -; Keep kern.asm as the historical TASM source and use this file for the -; reproducible Open Watcom build. +; Low-level INT 21h Net_Call and Client32 requester entry points used by the +; DOS NCP transport helpers. This file is split from the former combined +; kern_wasm.asm so IPX glue can stay in ipx.asm. .286 .model large -.data -enterIPX dd 0 - .code -public _IPXinit -public _IPXopen_socket -public _IPXclose_socket -public _IPXlisten -public _xmemmove public _Net_Call public _ncp_raw_request public _ncp_openref_request public _ncp_mapvar_request -_IPXinit proc far - push bp - mov bp, sp - push ds - push si - push di - - mov ax, 7A00h - int 2Fh - cmp al, 0FFh - jne ipxinit_done - - mov cx, @data - mov ds, cx - mov word ptr enterIPX, di - mov ax, es - mov word ptr enterIPX+2, ax - mov al, 1 - -ipxinit_done: - mov ah, 0 - - pop di - pop si - pop ds - pop bp - ret -_IPXinit endp - -_xmemmove proc far - push bp - mov bp, sp - - ; far procedure stack layout, large model: - ; [bp+0] old bp - ; [bp+2] return offset - ; [bp+4] return segment - ; [bp+6] z offset - ; [bp+8] z segment - ; [bp+10] q offset - ; [bp+12] q segment - ; [bp+14] nmbr - - cli - mov cx, [bp+14] - or cx, cx - jz xmem_done - - push ds - push si - push di - pushf - - lds si, dword ptr [bp+10] - les di, dword ptr [bp+6] - cmp di, si - jl xmem_forward - - std - dec cx - add di, cx - add si, cx - inc cx - jmp xmem_copy - -xmem_forward: - cld - -xmem_copy: - rep movsb - - popf - pop di - pop si - pop ds - -xmem_done: - pop bp - sti - ret -_xmemmove endp - -_IPXopen_socket proc far - push bp - mov bp, sp - push ds - push si - push di - - ; int IPXopen_socket(UI sock, int live) - mov ax, [bp+8] ; live - mov dx, [bp+6] ; sock - mov bx, @data - mov ds, bx - mov bx, 0 - call dword ptr enterIPX - - cmp al, 0FFh - jne ipxopen_not_already - mov ax, -1 ; socket already open - jmp ipxopen_done - -ipxopen_not_already: - cmp al, 0FEh - jne ipxopen_ok - mov ax, -2 ; socket table full - jmp ipxopen_done - -ipxopen_ok: - mov ax, dx - -ipxopen_done: - pop di - pop si - pop ds - pop bp - ret -_IPXopen_socket endp - -_IPXclose_socket proc far - push bp - mov bp, sp - push ds - push si - push di - - ; void IPXclose_socket(UI sock) - mov dx, [bp+6] - mov bx, @data - mov ds, bx - mov bx, 1 - call dword ptr enterIPX - - pop di - pop si - pop ds - pop bp - ret -_IPXclose_socket endp - -_IPXlisten proc far - push bp - mov bp, sp - push ds - push si - push di - - ; int IPXlisten(ECB *ecb) - les si, dword ptr [bp+6] - mov bx, @data - mov ds, bx - mov bx, 4 - call dword ptr enterIPX - - pop di - pop si - pop ds - pop bp - mov ah, 0 - ret -_IPXlisten endp _Net_Call proc far push bp @@ -985,5 +814,4 @@ raw_name db 'COMPATNcpRequestReply',0 _ncp_raw_request endp - end diff --git a/ncpcall.c b/ncpcall.c index 9ed97f2..cbf3c06 100644 --- a/ncpcall.c +++ b/ncpcall.c @@ -20,7 +20,7 @@ /* * Purpose: Low-level NCP requester and Client32 transport helpers for the NetWare DOS tools. - * Depends on: net.h, ncpapi.h, netcall.c requester glue, and kern_wasm.asm/kern.asm Net_Call/Client32 request entry points. + * Depends on: net.h, ncpapi.h, netcall.c requester glue, and ncpcall.asm/doc/kern.asm Net_Call/Client32 request entry points. * * The public ncpXX_YY_* protocol wrappers live in ncpapi.c, which is planned * to become ncpapi.c. This file keeps the lower-level requester/transport diff --git a/ncpcall.h b/ncpcall.h new file mode 100644 index 0000000..1547bd4 --- /dev/null +++ b/ncpcall.h @@ -0,0 +1,47 @@ +/* + * mars-nwe-dosutils - NetWare/DOS utility tools. + * + * Copyright (C) 2026 Mario Fetka + * Copyright (C) 1993,1996 Martin Stover, Marburg, Germany + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +/* + * Purpose: C declarations for low-level NetWare requester and Client32 transport assembly glue. + * Depends on: ncpcall.asm for Open Watcom builds, ncpcall.c transport helpers, and net.h for shared types. + */ + +#ifndef NCPCALL_H +#define NCPCALL_H + +#if defined(__WATCOMC__) +#define NCP_CALL _Cdecl +#else +#define NCP_CALL +#endif + +extern int NCP_CALL Net_Call(UI func, void *req, void *repl); +extern int NCP_CALL ncp_mapvar_request(UI specLen, UI flag, void *outbuf); +extern int NCP_CALL ncp_openref_request(UI refLo, UI refHi, void *outbuf); +extern int NCP_CALL ncp_raw_request(UI connLo, UI connHi, + void *hdr, UI hdrLen, + void *path, UI pathLen, + void *rep0, UI rep0Len, + void *rep1, UI rep1Len, + void *outbuf); + +#undef NCP_CALL + +#endif /* NCPCALL_H */ diff --git a/net.h b/net.h index 599f3ad..5940785 100644 --- a/net.h +++ b/net.h @@ -20,7 +20,7 @@ /* * Purpose: Shared public header for the DOS utility collection: types, prototypes and common structures. - * Depends on: kern.h, all command modules, netcall.c, ncpcall.c, tools.c and ncpapi.c. + * Depends on: ipx.h, ncpcall.h, all command modules, netcall.c, ncpcall.c, tools.c and ncpapi.c. */ #include @@ -53,35 +53,9 @@ typedef void (*FUNC_VOID)(); typedef int (*FUNC_INT)(); -typedef struct { - uint8 checksum[2]; - uint16 packetlen; - uint8 tcontrol; - uint8 ptype; - uint8 dest_net[4]; - uint8 dest_node[6]; - uint16 dest_sock; /* HI LOW */ - uint8 source_net[4]; - uint8 source_node[6]; - uint16 source_sock; /* HI LOW */ -} IPX_HEADER; +#include "ipx.h" +#include "ncpcall.h" -typedef struct { - uint8 *link_address; - FUNC_VOID esr_routine; - uint8 in_use_flag; - uint8 completition_code; - uint16 socket; /* HI LOW */ - uint8 ipx_workspace[4]; /* interner Gebrauch */ - uint8 drv_workspace[4]; /* interner Gebrauch */ - uint8 immediate_address[6]; /* HI LOW Node Address */ - uint16 fragment_count; /* Anzahl Fragment Buffers */ - uint8 *fragment_1; - uint16 fragment_1_size; - /* K�nnen auch mehr sein */ -} ECB; - -#include "kern.h" #define UI2NET(i) ( ( (i) << 8) | ( ((i)>>8) & 0xFF) ) #define NET2UI(i) ( ( (i) << 8) | ( ((i)>>8) & 0xFF) ) diff --git a/netcall.c b/netcall.c index 6dca2aa..e5bd926 100644 --- a/netcall.c +++ b/netcall.c @@ -20,7 +20,7 @@ /* * Purpose: DOS/NetWare requester wrapper layer and environment helpers used by the utilities. - * Depends on: net.h, kern_wasm.asm/kern.asm low-level Net_Call/IPX glue, ncpcall.c high-level NCP helpers, tools.c shared utility routines. + * Depends on: net.h, ipx.asm/ncpcall.asm low-level IPX and Net_Call glue, ncpcall.c high-level NCP helpers, tools.c shared utility routines. */ #include "net.h"