Writing Device Drivers

User avatar
Eugene Gorbunoff
Site Admin
Posts: 685
Joined: Sat Apr 09, 2005 11:18
Location: St.Petersburg, Russia

Writing Device Drivers

Postby Eugene Gorbunoff » Mon Aug 25, 2008 22:13

Nathan:

> > I've come to the realization that I really need to write a device
> > driver this time for one of my projects I've been working on for well
> > over 10 years.


e-co:

Welcome to DevCon: http://ecomstation.ru/projects/developer/?action=devdrv



Nathan:

eCo Software simple 32-bit driver --

Just like other things, it is very incomplete.

For one, what ever is supposed to be in \src\crcdrv directory does not exist. The directory itself is not there.

I've set all my environment variable as best that I could find them. If my system is set up properly, which is it, I shouldn't have to do all this tracking down to set them in the file. But still there are static ones somewhere.

I've spent the better part of 2 days now trying to get any example to compile. I'm not surprised that there are no new device driver writers.

Here is what I get when I run the make file........

Code: Select all

[H:\development\os2\pciac5\drvsample]set beginlibpath=H:\ibmcpp\runtime;H:\os2tk45\dll;H:\ibmcpp\dll;d:\comp\tk451\dll;d:\comp\icc\dll;d:\comp\icc\runtime;

[H:\development\os2\pciac5\drvsample]set beginlibpath=H:\ibmcpp\dll;H:\ibmcpp\runtime;H:\os2tk45\dll;d:\comp\tk451\dll;d:\comp\icc\dll;d:\comp\icc\runtime;

[H:\development\os2\pciac5\drvsample]set beginlibpath=H:\os2tk45\dll;H:\ibmcpp\dll;H:\ibmcpp\runtime;d:\comp\tk451\dll;d:\comp\icc\dll;d:\comp\icc\runtime;
Entering directory: .\src
Entering directory: .\src\crcdrv
icc /Q+ /O3 /Os- /Op- /Ms /Rn /C /Ss /Sp8 /W3 /Gi+ /Gf+ /Gs+ /Fa+ /G5 /qtune=pentium /qarch=pentium /DMJVER= /DMNVER= /FoH:\development\os2\pciac5\drvsample\obj\mydrv\Drv1\command.obj /FaH:\development\os2\pciac5\drvsample\obj\mydrv\Drv1\command.lst command.c
warning EDC1020: Excess text 3 ignored on /o option.
warning EDC1004: Option "/S8" is not recognized.
warning EDC1020: Excess text tune=pentium ignored on /q option.
warning EDC1020: Excess text arch=pentium ignored on /q option.
H:\development\os2\pciac5\drvsample\src\common\include\debug.h(1:6) : error EDC0160: Object _cdecl cannot be declared as type void.
H:\development\os2\pciac5\drvsample\src\common\include\debug.h(1:6) : error EDC0166: Definition of function _cdecl requires parentheses.
command.c(28:10) : error EDC0296: #include file <psd.h> not found.
command.c(29:10) : error EDC0296: #include file <acpi.h> not found.
command.c(30:10) : error EDC0296: #include file <acpiapi.h> not found.
command.c(31:10) : error EDC0296: #include file <ipdc.h> not found.
command.c(32:10) : error EDC0296: #include file <acpifun.h> not found.
H:\development\os2\pciac5\drvsample\src\common\include\debug.h(1:13) : error EDC0276: Syntax error: possible missing '{'?
command.c(54:24) : error EDC0045: Undeclared identifier pkt.
command.c(55:5) : warning EDC0304: No function prototype given for 'PrintDevCall'.
command.c(56:5) : warning EDC0304: No function prototype given for 'SayDebug'.
command.c(77:5) : warning EDC0304: No function prototype given for 'PrintDevCall'.
command.c(78:5) : warning EDC0304: No function prototype given for 'SayDebug'.
command.c(117:33) : warning EDC0304: No function prototype given for 'CopyToUser'.
command.c(142:5) : warning EDC0304: No function prototype given for 'SayDebug'.
command.c(143:5) : warning EDC0304: No function prototype given for 'SayDebug'.
command.c(158:5) : warning EDC0304: No function prototype given for 'PrintDevCall'.
command.c(159:5) : warning EDC0304: No function prototype given for 'SayDebug'.
command.c(208:1) : error EDC0166: Definition of function PACPIFUNCTION requires parentheses.
command.c(208:15) : error EDC0276: Syntax error: possible missing '{'?
command.c(225:21) : error EDC0045: Undeclared identifier pkt.
command.c(230:9) : warning EDC0304: No function prototype given for 'SayDebug'.
command.c(232:9) : warning EDC0304: No function prototype given for 'SayDebug'.
command.c(236:5) : warning EDC0304: No function prototype given for 'PrintDevCall'.
command.c(241:9) : warning EDC0304: No function prototype given for 'SayDebug'.
command.c(246:75) : error EDC0045: Undeclared identifier DebugAddr.
command.c(247:5) : warning EDC0304: No function prototype given for 'SayDebug'.
command.c(251:9) : warning EDC0304: No function prototype given for 'SayDebug'.
command.c(257:11) : error EDC0045: Undeclared identifier PACPIFUNCTION.
command.c(257:5) : error EDC0045: Undeclared identifier PSD.
command.c(257:26) : error EDC0277: Syntax error: possible missing ';' or ','?
command.c(261:28) : warning EDC0304: No function prototype given for 'GetESP'.
command.c(261:5) : warning EDC0304: No function prototype given for 'SayDebug'.
command.c(273:5) : warning EDC0304: No function prototype given for 'PrintDevCall'.
command.c(285:5) : warning EDC0304: No function prototype given for 'PrintDevCall'.
command.c(292:5) : warning EDC0304: No function prototype given for 'PutCom'.
command.c(293:1) : warning EDC0304: No function prototype given for 'PutToRead'.
command.c(307:1) : error EDC0343: Redeclaration of CopyToUser differs from previous declaration on line 117 of "command.c".
command.c(307:1) : informational EDC0050: Return type "unsigned long" in redeclaration is not compatible with the previous return type "int".
command.c(335:19) : error EDC0045: Undeclared identifier DebugAddr.
command.c(348:1) : error EDC0343: Redeclaration of PutToRead differs from previous declaration on line 293 of "command.c".
command.c(348:1) : informational EDC0050: Return type "void" in redeclaration is not compatible with the previous return type "int".
command.c(354:9) : error EDC0045: Undeclared identifier DebugAddr.
command.c(475:30) : error EDC0046: Syntax error.
command.c(475:27) : error EDC0098: Missing argument(s).
command.c(476:24) : error EDC0275: Unexpected text ')' encountered.
command.c(476:38) : error EDC0045: Undeclared identifier UINT64.
command.c(476:47) : error EDC0277: Syntax error: possible missing ',' or ')'?
command.c(516:6) : error EDC0160: Object _cdecl cannot be declared as type void.
command.c(516:6) : error EDC0166: Definition of function _cdecl requires parentheses.
command.c(516:13) : error EDC0276: Syntax error: possible missing '{'?
command.c(518:28) : error EDC0045: Undeclared identifier fmt.
command.c(518:13) : error EDC0045: Undeclared identifier fmt.
command.c(520:6) : error EDC0160: Object _cdecl cannot be declared as type void.
command.c(520:6) : error EDC0166: Definition of function _cdecl requires parentheses.
command.c(520:13) : error EDC0276: Syntax error: possible missing '{'?
command.c(522:2) : warning EDC0304: No function prototype given for 'PrintfDev'.
command.c(523:25) : error EDC0045: Undeclared identifier fmt.
command.c(523:10) : error EDC0045: Undeclared identifier fmt.
command.c(526:1) : error EDC0343: Redeclaration of PrintDevCall differs from previous declaration on line 55 of "command.c".
command.c(526:1) : informational EDC0050: Return type "void" in redeclaration is not compatible with the previous return type "int".
command.c(531:5) : warning EDC0304: No function prototype given for 'SayDebug'.
command.c(532:5) : warning EDC0304: No function prototype given for 'SayDebug'.
command.c(533:5) : warning EDC0304: No function prototype given for 'SayDebug'.
command.c(534:5) : warning EDC0304: No function prototype given for 'SayDebug'.
command.c(535:5) : warning EDC0304: No function prototype given for 'SayDebug'.
command.c(536:5) : warning EDC0304: No function prototype given for 'SayDebug'.
command.c(537:5) : warning EDC0304: No function prototype given for 'SayDebug'.

Operating System/2 Program Maintenance Utility

Version 4.00.000 May 12 1999

Copyright (C) IBM Corporation 1988-1999

Copyright (C) Microsoft Corp. 1988-1991

All rights reserved.



Lorne:

When you compiling a device driver with C you have to use the 16 bit C compiler that comes with the device driver kit. It is in the msc60.zip
file that was on the old IBM DDK site.

You can also use the Watcom C compiler that was open sourced and maintained by the Scitech people for a while.



Nathan:

Still, there is no device driver example on the internet that when download will compile for OS/2. Nowhere does any example describe the environment need to get it to compile.

I spent all weekend fiddling with compilers and toolkits to get any example to compile and failed at all of them.

All I need is a simple read and write to memory on a PCI card. I have no problem writing the device driver once I can finally find an example that will compile and run.


Andy Willis:

The only ones I have worked with are non-trivial to setup but both have fairly good write-ups on how to setup... they may or may not help for this. Uniaud is easy to setup and build, though non-trivial in nature to determine how it works. Win32k.sys, though not a device driver in that there is not device, is still an example... again it still is non-trivial and the setup is a bit harder than uniaud.

Uniaud uses OpenWatcom 1.7 (1.6 doesn't work correctly, though it does build the driver there is a bug of some sort that fails to produce sound). Win32k.sys is built with VAC 3.08 (I've built it with VAC 3.65 but it would not load correctly).

I've only built them and made minor changes so I don't know anything about actual driver development to tell you anything about creating them.

User avatar
Eugene Gorbunoff
Site Admin
Posts: 685
Joined: Sat Apr 09, 2005 11:18
Location: St.Petersburg, Russia

Re: Writing Device Drivers

Postby Eugene Gorbunoff » Mon Aug 25, 2008 23:14

Frank Beythien

Try Openwatcom which comes with a PDD example:

http://www.openwatcom.org/index.php/Download



Nathan

I wish that was true, but again.... NOPE.....

I downloaded Open Watcom and installed it to my C: drive. I rebooted and then went to C:\watcom\samples\os2\pdd.

I typed in: WMAKE<enter> and got this.......

Code: Select all

Open Watcom Make Version 1.7

Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved.

Source code is available under the Sybase Open Watcom Public License.

See http://www.openwatcom.org/ for details.

wasm devsegs.asm

Open Watcom Assembler Version 1.7

Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.

Source code is available under the Sybase Open Watcom Public License.

See http://www.openwatcom.org/ for details.

devsegs.asm: 73 lines, 0 warnings, 0 errors

wcc -i=C:\WATCOM\h\os21x -bt=os2 -ms -5 -omi -s -zdp -zff -zgf -zu -zl -zq -wx strategy.c

C:\IBMCPP\INCLUDE\conio.h(94): Warning! W138: No newline at end of file

strategy.c(103): Warning! W131: No prototype found for function 'outp'

strategy.c(104): Warning! W131: No prototype found for function 'inp'

wcc -i=C:\WATCOM\h\os21x -bt=os2 -ms -5 -omi -s -zdp -zff -zgf -zu -zl -zq -wx stratini.c

C:\IBMCPP\INCLUDE\conio.h(94): Warning! W138: No newline at end of file

stratini.c(54): Warning! W131: No prototype found for function 'outp'

wcc -i=C:\WATCOM\h\os21x -bt=os2 -ms -5 -omi -s -zdp -zff -zgf -zu -zl -zq -wx header.c

wlink @hrtimer.lnk

Error! E2028: outp_ is an undefined reference

Error! E2028: inp_ is an undefined reference

file strategy.obj(C:\watcom\samples\os2\pdd\strategy.c): undefined symbol outp_

file strategy.obj(C:\watcom\samples\os2\pdd\strategy.c): undefined symbol inp_

file stratini.obj(C:\watcom\samples\os2\pdd\stratini.c): undefined symbol outp_


Try it yourself. It doesnt' work. I don't want to have to spend another 2 days trying to debug someone else's examples.


David

I just went to my OW pdd directory and typed WMAKE and it compiled successfully with no errors. Your "no prototype" and "undefined references" are because you still have old includes and libs in your paths before the open watcom ones. You need to cleanup your config.sys. Specifically INCLUDE= and LIB=. You should also make sure no other older watcom tools are in the PATH before the OW ones. (This could also be your problem with trying to compile other drivers.)


Nathan Woodruff

Instead of managing several hard drives each with installs of OS/2 and different flavors of compilers and toolkits, I decided it would be faster to manage one hard drive with different config.sys files.

I cleaned out a config.sys file and installed watcom and then the toolkit. The Physical Device Driver sample compiled!!!!

I made a few quick hacks to the program and I was able to hardcode write to the PCI card's memory!

Now comes the fun/hard part, developing an actuall device driver for the card that can be called from a program.

I have several device drivers that I want to write now, one is a barcode reader from worthington data systems, http://www.barcodehq.com/, another is for the FM radio card that I have and the last is for this OPTO-22 pci-ac5 card,

http://www.opto22.com/site/pr_details.a ... 011,,,1,3&

That I got for $28 bucks,

http://cgi.ebay.com/ws/eBayISAPI.dll?Vi ... :IT&ih=018

Thanks everyone for your help in pointing me in the right direction.


Return to “Developers / Разработчики”

Who is online

Users browsing this forum: No registered users and 2 guests

cron