OS/2 Parallel port sharing example code
Joe Nord

Example OS/2 PDD code demonstrating how to negociate access to PC parallel port via IDC.

You can use this IDC demonstrating code for what ever you want including commercial products with no
restriction on use or royalty.  If you find it useful, I would appreciate it if you give me a plug in the source
and drop me a note to let me know where you are using the code.

For feedback, send email to "joe" at this domain.

The basic game is inter-device driver communciation between your device driver and the OS/2 shipped parallel port device driver.  You may only touch the parallel port hardware after the PRINT0X.sys device driver says "okay".

The IDC support in the OS/2 parallel port device driver has been part of the OS since OS/2 2.11.   It was not present in OS/2 2.1.   This was a big concren when I coded what follows, but 10 years later, the code below should be "enhanced" to actually watch the return code as running on OS/2 2.1 isn't a big requirement anymore.  The example code "pushes on" in cases where no communication can be established with the parallel port device driver.

Example source:

The "inc" file - LPTIDC.INC
The "asm" file - LPTIDC.ASM  (This is the code that does the real work)

The important parts:
The strategy open logic -
                push    LPTIDC_REQUEST_ACCESS   ; Ask OS/2 printer DD for
                call    LPTIDC_IDCAccess        ; permission to use the
                or      ax, ax                  ; parallel port.
                jnz     IDCFailed

The strategy close logic
                push    LPTIDC_RELEASE_ACCESS   ; Return ownership to OS/2
                call    LPTIDC_IDCAccess        ; Ignore errors

global data
                LPTIDC_DD_INFO  IDC_DD_INFOTYPE <>      ; For AttachDD, IDC communication

init data
                szLPTn          db      "LPTn   ", 0    ; Name of OS/2 printer PDD ( "n" should be filled in at init )

init code
                mov     al, '1'                ; Perhaps - could be 2 or 3
                mov     szLPTn+3, al    ; Fill in "n" of parallel port device driver name LPTn

                mov     bx, offset szLPTn
                mov     di, offset LPTIDC_DD_INFO
                mov     dl, DevHlp_AttachDD
                call    [Device_Help]

                ; Regardless of success/fail, return success
                ; to our caller.  If the OS/2 printer PDD doesn't
                ; support IDC, we will do our best to get along.

                mov     bx, LPTIDC_DD_INFO.ProtModeOfs
                mov     ax, LPTIDC_DD_INFO.ProtModeSel
                mov     word ptr pLPTIDCEntry+0, bx     ; Offset
                mov     word ptr pLPTIDCEntry+2, ax     ; Selector 

                ; ...