Author Topic: Compiling an OS/2 Driver  (Read 2088 times)

Andreas Kohl

  • Full Member
  • ***
  • Thank You
  • -Given: 6
  • -Receive: 10
  • Posts: 246
    • View Profile
    • warpserver.de
Re: Compiling an OS/2 Driver
« Reply #15 on: January 03, 2018, 11:19:27 am »
The setting of environment seems to be incomplete. The output of SET INCLUDE or SET LIB would be more helpful. Additionally PATH should be adjusted properly.

I would check the installation of the C PDS. Which runtime libraries were created by the installation procedure? There's no matching entry inside INCLUDE btw. Simply read the product documentation. In "Microsoft C Advanced Programming Techniques" starting on page 343 (Part 4 OS/2 Support), for the compiler errors "Microsoft C Reference" or later MSDN information.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 267
  • -Receive: 50
  • Posts: 1757
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling an OS/2 Driver
« Reply #16 on: January 03, 2018, 05:20:52 pm »
Hi.

Yes, the .h files path was wrong. I notices I missed a lot from DDK.

It seems it compiles, a driver.sys file was generated.

Quote
   masm -Mx -e -t -l -N startup;
 Assembling: startup.asm
   cl -c -Asnw -Gs -G2 -Zl -Zp -Ox -Fadriver1.cod driver1.c
driver1.c
   link /nod /map /far startup.obj+driver1.obj,driver1.sys,driver1.map,dhcalls.lib+slibcep.lib+os2386.lib,driver1.def

Microsoft (R) Segmented-Executable Linker  Version 5.13
Copyright (C) Microsoft Corp 1984-1991.  All rights reserved.

   mapsym driver1.map


Operating System/2 Symbol File Generator

Version 4.00.000 Oct  4 2001

Copyright (C) IBM Corporation 1988-2001

Copyright (C) Microsoft Corp. 1988-1991.

All rights reserved.


No entry point, assume 0000:0100

It even worked at boot showing the sample text.



« Last Edit: January 03, 2018, 06:06:05 pm by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 267
  • -Receive: 50
  • Posts: 1757
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling an OS/2 Driver
« Reply #17 on: January 03, 2018, 10:52:33 pm »
Hi again.

As my next exercise on compiling drivers I would try like to try to compile the same driver with open/current tools.

Checking the make file I would like to hear your opinions on:
- Replacing NMAKE.EXE for GNU MAKE.EXE?
- Replacing link.exe for GNU Link.exe ?
- mapsym.exe? Is there a replacement for it?
- masm.exe? Would a different alternative compiler will produce a working driver?
- cl.exe? Would a different alternative compiler will produce a working driver?

I would check some GNU Make files to see if I can adapt the make file of this sample.

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Thank You
  • -Given: 8
  • -Receive: 93
  • Posts: 1216
    • View Profile
Re: Compiling an OS/2 Driver
« Reply #18 on: January 03, 2018, 11:58:34 pm »
I believe you will have to go with the OpenWatcom tool chain.
Wmake is close to nmake and IIRC, it has a compatibility mode.
Wlink can link OS/2 drivers, including mixing 16 bit and 32 bit I believe. GNU ld can't.
I believe there are Perl scripts that can do the same as mapsym and they are needed for creating sym files for OW..
Same with OW's compiler and assembler, they can produce 16 bit OS/2 code and are closer to the MS tools.

GCC and the rest of the toolchain just aren't capable of building OS/2 drivers or even 1.x programs and even for 32 bit binaries, really need to be used with an IBM linker or the OpenWatcom linker.

Note also that OpenWatcom comes with sample device driver code, namely a timer.sys and example code to test by the looks of it.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 267
  • -Receive: 50
  • Posts: 1757
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling an OS/2 Driver
« Reply #19 on: January 04, 2018, 12:24:48 pm »
Thanks for the suggestion Dave. I will look that way and try to compile the openwatcom sample.

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Thank You
  • -Given: 8
  • -Receive: 93
  • Posts: 1216
    • View Profile
Re: Compiling an OS/2 Driver
« Reply #20 on: January 04, 2018, 04:33:21 pm »
Steven's site has map2symw.pl for creating sym files from OW map files, http://home.earthlink.net/~steve53/os2diags/mapsymw-0.3-20120319.zip

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 267
  • -Receive: 50
  • Posts: 1757
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling an OS/2 Driver
« Reply #21 on: January 04, 2018, 10:04:32 pm »
Hi

Thanks for the support.
I had wrote down my experience on the EDM/2 wiki: Compiling a Driver Sample with IBM DDK on ArcaOS 5.0.1. (Spellcheck is always welcome)

Now I had installed OpenWatcom and see if I can play with the make file to change the compilation tools on the same sample.

Regards
« Last Edit: January 04, 2018, 10:06:08 pm by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Thank You
  • -Given: 8
  • -Receive: 93
  • Posts: 1216
    • View Profile
Re: Compiling an OS/2 Driver
« Reply #22 on: January 05, 2018, 01:53:29 am »
Looks good Martin.
I did some minor editing.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 267
  • -Receive: 50
  • Posts: 1757
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling an OS/2 Driver
« Reply #23 on: January 05, 2018, 12:58:49 pm »
Thanks Dave. I look at your changes and I really needed those (sometimes I skip words while writing).

I'm have a different question now. I had installed OpenWatcom (Version 1.90 Installer for C/C++) and I noticed it sets several include files on the path. Those files conflict with the OS/2 Toolkit .h files (like os2.h and several others). What are the recommended one to use? Or if I'm going to use the OpenWatcom compilers I should use the ones bundled with it?

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Thank You
  • -Given: 8
  • -Receive: 93
  • Posts: 1216
    • View Profile
Re: Compiling an OS/2 Driver
« Reply #24 on: January 05, 2018, 06:15:39 pm »
I've never done driver development, but for 32 bit applications, while in config.sys I have the toolkit stuff in front of the OW stuff, I have a setenv.cmd that puts the OW stuff in front of the toolkit. It is easy to experiment using a setenv.cmd.
For building Doodles Screen Saver I ended up with,
setenv.cmd,
Code: [Select]
call owsetenv
call tkenv
call start-sdk

owsetenv.cmd,
Code: [Select]
@echo off
echo Open Watcom Build Environment
SET PATH=g:\WATCOM\BINP;g:\WATCOM\BINW;%PATH%
SET BEGINLIBPATH=g:\WATCOM\BINP\DLL;%BEGINLIBPATH%
SET INCLUDE=g:\WATCOM\H;g:\WATCOM\H\OS2;%INCLUDE%
SET WATCOM=g:\WATCOM
SET EDPATH=g:\WATCOM\EDDAT
SET WIPFC=g:\WATCOM\WIPFC

tkenv.cmd
Code: [Select]
ECHO OFF
set os2tk=G:\OS2TK45
set BEGINLIBPATH=%OS2TK%\DLL;%BEGINLIBPATH%
set PATH=%OS2TK%\BIN;%PATH%
SET DPATH=%OS2TK%\MSG;%DPATH%
SET HELP=%OS2TK%\HELP;%HELP%
SET BOOKSHELF=%OS2TK%\BOOK;%BOOKSHELF%
SET NLSPATH=%OS2TK%\MSG\%N;%NLSPATH%
SET IPFC=%OS2TK%\IPFC;%IPFC%

For the SNAP sdk, only needed for DSS,
start-sdk.cmd
Code: [Select]
@echo off
rem Batch file to create the initial setup for using the SciTech MGL
rem Graphics Library, using the selected default compiler.

rem Setup the default path environment variable

set OLDPATH=%PATH%
set DEFPATH=C:\OS2;C:\OS2\MDOS
PATH %DEFPATH%

rem Initialise the default compile time environment

call C:\SCITECH\bin-os2\set-vars.cmd
set DEFPATH=%SCITECH%\redist\release;%DEFPATH%
rem call C:\SCITECH\bin-os2\wc11-o32.cmd
call C:\SCITECH\bin-os2\ow10-o32.cmd

rem Change to the directory containing all the MGL sample code

cd %SCITECH%\EXAMPLES\SNAP\GRAPHICS

rem restore old path
set PATH=%PATH%;%OLDPATH%

Andreas Kohl

  • Full Member
  • ***
  • Thank You
  • -Given: 6
  • -Receive: 10
  • Posts: 246
    • View Profile
    • warpserver.de
Re: Compiling an OS/2 Driver
« Reply #25 on: January 05, 2018, 06:38:56 pm »
Watcom uses different includes for 16-bit OS/2. That should be mentioned in the README or in more detail Tools Guide. For physical device driver information simply read chapter 39 Developing an OS/2 Physical Device Driver from the Watcom C/C++ Programmer's Guide. At least everything works as usual under Open Watcom 1.8. The later 1.9 may have some issues.