| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Device Driver Programming |
Johannes Stratmann wrote in a message to All:
JS> und ausserdem wollte ich noch einen Device Driver basteln,
JS> nur ein paar A/D Werte lesen und irgendwohin packen. Mit dem
JS> Buch von Mastrianni hab ich mich schon auseinandergesetzt
JS> und das mit dem serial-Treiber ausprobiert. Mutig mit Watcom
JS> bersetzt und jede Menge Fehler erhalten, zb.:
In my experience, you can consider the Watcom support for physical device
drivers to be totally broken in v10.0, but improved to almost totally
broken with the a-level patches.
In practice, you never really want to code the device driver header in C,
but in assembly language. One reason for this is that the strategy routine
needs to get the virtual address of the request packet somehow, which is
passed to you in the ES:BX registers. While it is possible to manipulate
the parameter passing conventions explicitly in Watcom with "#pragma
AUX ... PARM ..." and so on, this is not supported by any non-Watcom
compiler and really is not worth the trouble.
I always handle this manually using a small assembly language module that
defines segment ordering and alignment, includes the device driver header,
and includes the real top-level strategy entry point. This top-level
strategy entry point is responsible for pushing ES and BX onto the stack,
calling the C strategy dispatcher, and popping the stack to restore balance
before returning. The OBJ module made from this ASM code must always be
the first module defined to the linker.
For example, with Microsoft C 6.0:
.286p
include DEVHDR.INC
extrn _M_Strat1:near ; The cdecl strategy dispatcher
; NEVER change the order of the segments below
DGROUP group CONST, _BSS, _DATA, ENDBSS, c_common
StaticGroup group Code, _TEXT, ENDCODE
SwapGroup group SwapCode
_DATA segment dword public 'DATA'
_DATA ends
CONST segment dword public 'CONST'
CONST ends
_BSS segment dword public 'BSS'
_BSS ends
c_common segment dword public 'BSS'
c_common ends
ENDBSS segment dword public 'BSS'
public _DataEnd
align 4
_DataEnd dd ?
ENDBSS ends
_TEXT segment dword public 'CODE'
assume cs:_TEXT
align 4
_M_Strat1_asm proc near
enter 0004,00 ; allocate stack
push es
push bx
call _M_Strat1
leave ; restore stack
retf
_M_Strat1_asm endp
_TEXT ends
Code segment dword public 'CODE'
Code ends
ENDCODE segment dword public 'CODE'
assume cs:ENDCODE
public _CodeEnd
align 4
_CodeEnd proc near
_CodeEnd endp
ENDCODE ends
SwapCode segment dword public 'CODE'
SwapCode ends
; End of linker segment ordering directives
;*
;* Device driver headers
;*
_DATA segment
PUBLIC _Dev_header, _Dev_name
ALIGN 4
_Dev_header label word
dd -1 ; next device
dw DEV_CHAR_DEV OR DEVLEV_3 ; character DD, level 3
dw OFFSET _M_Strat1_asm ; entry point
dw 0 ; IDC entry point
_Dev_name db 'DRIVER$ ' ; device name or numberofunits
db 8 dup (0) ; reserved
dd DEV_IOCTL2 OR DEV_16MB OR DEV_INITCOMPLETE
; Capabilities
_DATA ends
end
JS> Tja, und zum Linken braucht man dann noch ne Mastrianni-Lib.
JS> Oder gibt es alternativen ?
I would recommend against using the Mastrianni library. First, it uses
non-standard names for the device helper functions. Second, it is not, as
far as I know, compatible with the Watcom compiler.
JS> Die Devcon (jetzt mit DD-Support) ist schon bestellt, aber
JS> ob das damit einfacher wird ?
The DHCALLS.LIB provided with the DevCon DDK is also incompatible with the
Watcom compiler. However, IBM's DHCALLS.LIB does come free on the DDK, has
full source code, and is considered quite solid and reliable since it is
used to build OS/2 itself.
JS> Gibt es jemanden im Raum GE/E der sich auch mit solchen
JS> Probs rumschl„gt ?
To begin with, you must get the following files:
WATCOM.TXT 4K 11-21-94 OS/2 Device Driver Kit: Information about Watcom C
being used in place of Microsoft C 6.0
WATDD01.ZIP 39K 10-09-94 OS/2 Device Driver Kit: Set of libraries for
developing PDD's using Watcom C++ V10. (Use -d
switch when UNZIPPING with DOS PKUNZIP.)
The above two files are available from a number of sources, including by
download or FReq from me, and by download from the IBM DDSC BBS
("DUDE"). If you have access to the Internet, I believe that
they are also available from FTP.WATCOM.ON.CA.
-- Mike
---
* Origin: N1BEE BBS +1 401 944 8498 V.34/V.FC/V.32bis/HST16.8 (1:323/107)SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407 SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809 @PATH: 323/107 150 3615/50 396/1 270/101 105/103 42 712/515 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.