This is file: 12_95QA.TXT

This file contains questions asked of the Driver Development Support Center
(DDSC) and the answers given to that particular question.  Entries are
appended to the top, so the most recent entry is available first.

Each entry starts with a header line that has a KEY WORD (or words) included
to allow the reader to "search" on KEY WORDS of particular interest.  Each KEY
WORD starts with the exclamation point character (!).  This allows for search
arguments that will limit matches to the header lines.

The following KEY WORDS are supported in this file.

KEYWORD                      DEVICES/TYPES OF QUESTIONS
===========   ==========================================================
!BASE         Loader, Memory Management, Strategy/Architecture
!I/O          Serial/Parallel, Pointing Device, Trackball, Keyboard, Pen
!MULTIMEDIA   Motion, Sound
!NETWORK      LAN,
!OTHER        PCMCIA, APM, Miscellaneous
!PRINT        Printer, Scanner
!STORAGE      DASD, SCSI, Tape, CD-ROM, ASPI, IFS
!VIDEO        VGA, SVGA, XGA, 8514, Display
**********    Entry separator (10 *'s)
==============================================================================




!PRINT__________________________________**********
December 1, 1995
QUESTION: (Ref: IS0)
The MDRIVER sample that shipped on the 1.2 DDK fails when used with the
communications manager in GPI mode.  I became aware of this when my driver
(based on the MDRIVER sample) had a defect reported by a customer.  Using the
DEBUG version of the MDRIVER, I see an assertion failure at lines 112 and 120
of TEXT.C.  This is followed by the minidriver blitting a blank page.  The
Comm manager reports a PRINT ERROR that can only be solved by shutting down
the session.  There appears to be a return code of PM_ERR_BITMAPNOT_SELECTED.



ANSWER:
There were four lines that were added to the RESET_DC switch.  I have included
the old and new enable.c in this note.  You may want to take out the debug
lines.  We were able to print from CM/2 with these changes.


*******************NEW ENABLE.C**************************************
case RESET_DC:
    DBPRINTF (("RESET_DC(9); pddc=%x \n", p1 ));
    pddc = (PDDC)p1;

    DBPRINTF(("DeSelecting BitMap RESET_DC in ENABLE.C\n"));
    INT3;
    lWork = GreSelectBitmap( pddc->hdcShadow, 0 );
    assert( (HBITMAP)lWork != HBM_ERROR );

    lWork = GreSelectClipRegion( pddc->hdcShadow, (HRGN)0, &hrgnOld );
    assert( lWork != (LONG)RGN_ERROR );
    assert( hrgnOld ? hrgnOld == pddc->hrgnShadow : TRUE );

    fOK = GreResetDC( pddc->hdcShadow, 0 );
    assert( fOK );

    //lWork = GreSelectClipRegion( pddc->hdcShadow, pddc->hrgnShadow, &hrgnOld );
    //assert( lWork != (LONG)RGN_ERROR );
    //assert( hrgnOld == 0 );

    DBPRINTF(("Selecting BitMap RESET_DC in ENABLE.C\n"));
    INT3;
    lWork = GreSelectBitmap( pddc->hdcShadow, pddc->hbmShadow );
    assert( lWork == 0 );

    lWork = GreErasePS (pddc->hdcShadow) ;
    assert( lWork );

    // success result
    ulrc = 0;
    break;


****************************OLD ENABLE.C********************

 case RESET_DC:
    DBPRINTF (("RESET_DC(9); pddc=%x \n", p1 ));
    pddc = (PDDC)p1;

    // deselect the clip region for the shadow DC; otherwise, the engine will delete the region if selected
    lWork = GreSelectClipRegion( pddc->hdcShadow, (HRGN)0, &hrgnOld );
    assert( lWork != (LONG)RGN_ERROR );
    assert( hrgnOld ? hrgnOld == pddc->hrgnShadow : TRUE );

    // reset the shadow DC
    fOK = GreResetDC( pddc->hdcShadow, 0 );
    assert( fOK );

    // select the clip region for the shadow DC
    //lWork = GreSelectClipRegion( pddc->hdcShadow, pddc->hrgnShadow, &hrgnOld );
    //assert( lWork != (LONG)RGN_ERROR );
    //assert( hrgnOld == 0 );

    // success result
    ulrc = 0;
    break;





!OTHER_______**********
December 6, 1995
QUESTION: (Ref: IV4)
I am having trouble debugging the driver that I am writing.  The code to open
and read the driver is nearly identical to another driver that I had written
earlier.

The driver is a character device driver.  It initializes and DosOpen's without
any error indication at ring 0 or ring 3. When I do a DosRead and NO error
situation is present, DosRead correctly reports the number of characters read
and the information I expect is in the buffer I reference in the DosRead call.
Additionally, zero is returned by the function.  In a different situation,
when an inactivity timeout occurs (because a DevHelp_ProcBlock has timed out)
I return an error from my strategy routine.  Debugo let's me see that the
value I am returning is the one I have chosen.  It is the same as the one I
chose for an earlier driver that can have the same sort of thing happen.
However, with this driver the DosRead does not report the error code I pass
back from my strategy routine.  Instead it returns ERROR_ACCESS_DENIED (5).

Since the earlier driver and the new driver are written to behave the same
way, I am very puzzled.  I might have a better idea what the problem might be
if I new exactly what ERROR_ACCESS_DENIED means.  I looked at the online help
documentation, but it only says, "Access denied."  What is denied?  File
access?  Memory access?  What?

ANSWER:
Use the 16-bit DosRead API in your Device Driver :

DosRead (FileHandle,BufferArea,BufferLength,BytesRead)


FOLLOW-UP QUESTION
The response you gave still leaves me in the dark.  The recommendation was to
use the 16-bit API for the DosRead call.  Here are my problems with attempting
to do this.

I could not find what switch to set so that the Visual Age C++ compiler would
select the 16-bit API DosRead instead of the 32-bit one.  I was able to locate
a Dos16Read function in the os2286.lib that is included with the compiler.
So, I wrote the following declaration to try to access the function.

extern "C"
{
        USHORT _Far16 _Pascal Dos16Read(unsigned short hFile,
                                        char * _Seg16 pBuffer,
                                        unsigned short cbRead,
                                        unsigned short * _Seg16 pcbActual);
}



ANSWER:
This is a Bug and has been fixed in FixPack 13.  The APAR # is pj20229.
Please contact OS/2 Support for the FixPack.



!STORAGE_____________________**********
December 20, 1995
QUESTION: (Ref: IY1)

The filter section of the storage reference says, "...change the Unithandle...
of the target...  to a value assigned by the Filter Driver.

How does my filter driver construct this value?


ANSWER:
The Unithandle is a unique ID assigned by the filter driver.  A unit is fully
identified by the Unithandle.

Refer to the sample code available in DDK in the following directory :
FLT_Build_UnitCBs() routine in

      \DDKX86\SRC\DEV\DASD\CDROM\FILTER\FLTINIT.C
 for the steps described in Storage Device Driver Reference.
 This routine is used by the following filters :
     \DDKX86\SRC\DEV\DASD\CDROM\SONY,
     \DDKX86\SRC\DEV\DASD\CDROM\NEC,
     \DDKX86\SRC\DEV\DASD\CDROM\TOSHIBA,
     \DDKX86\SRC\DEV\DASD\CDROM\HITACHI.

One additonal note.  Refer to the RegisterDeviceClass devhelp call and further
down in the same routine, the Unithandle is assigned from the variable
NumCDROMDrives variable (Line 325 FLTINIT.C ,DevCon DDK 2 ). This variable is
defined in the other directories i.e., \SONY, \NEC, \TOSHIBA, HITACHI).




!STORAGE________________________________**********
December 17, 1996
QUESTION: (Ref: IZ5)

Is there any way to tell if ontrack has been installed on a hard disk under
dos an int 13 call can be used for this but this seems not to work from an
os/2 exe.  Is there a marker in the first 10 sectors on the hd which can be
used to identify it ?

2. Is the Conners equivalent of ontrack compatable with os/2 if so how do we
test for it being installed.  Under dos an int 13 would work.  We would like
an os/2 method of detection if appropriate ie a marker that can be tested for.



ANSWER:
The type of the partition is stored in the partition table.  The partition ID
can be obtained by reading this table.  Refer to Appendix B. "Boot Record
Architecture" in Storage Device Driver Reference for partition table,
partition ID details.The System Indicator should have a Fixed Partition ID of
50/51 if the Partition is owned by the OnTrack Disk Manger,

The Generic disk IOCtls can be used to read the Master Boot Record.  Refer to
Physical Device Driver Ref.  , Ch.  - Generic IOClt Commands, Category 08h
Logical Disk Control IOCtl Commands.

You will have to find out what the Conners Equivalent of Ontrack assigns as
the Fixed partition ID to detect this partition.




!OTHER__________________________________**********
December 20, 1995
QUESTION: (Ref: J00)
We are using PC's to control a laser marker.  The main feature to discuss here
is that we are controlling the laser by a special interface and a device
driver.  We made in the last time the experience, that compared to OS/2
version 1.3 the reaction to an interrupt is sometimes delayed.  The interrupt
frequency is up to 50kHz depending on the PC e.g.  a pentium 90MHz.  The
frequency is necessary to write for instance more than 200 characters per
second on integrated circuits housings.  The short delays cause halts of
movement of the laser beam and the result are holes in the laser track.  I
tried the priority command.  But I did not see an improvement.  Can you give
me some hints what we should try?  The task of marking is split in two parts:
An application - we call 'run time system'- is interpreting the user data and
preparing graphic primitives like lines, arcs and jumps into a buffer.  The
device driver gets these commands via IOCTL and does the interpolation to move
the laser beam.  We are using the PM.  In many markers serial communication
is running simutaneously.  We think the task switching is the reason, because
the delays are not related to special events.


ANSWER:
You could declare your application thread as a time critical thread.  In your
driver you can yield control only to the time critical threads by calling
TCYield Devhelp.

Add the following lines to your CONFIG.SYS :
PRIORITY = ABSOLUTE
PRIORITY_DISK_IO = NO



!OTHER__________________________________**********
December 5, 1995
QUESTION: (Ref: J07)
Subject: OS2 Warp Connect & NDIS 2.0 pcmcia device driver...

I have OS2 Warp Connect installed on two machines:
 - Thinkpad 755 CSE
 - Garage shop clone with Swap Box 2 slot pcmcia hardware installed.

I have a working NDIS 2.0 device driver for OS2 for ISA bus cards, PCMCIA dos
and windows, but I can't get any satisfaction when I try to bring up the OS2
PCMCIA device driver.

 - I can process the CmdInit ok.
 - The driver links to CS successfully and can make CS calls.
 - The driver cannot successfully obtain any resources when
   it attempts to process the CmdInitComplete command.
   (Any attempt to request resources from CS causes an "Out
   of Resource" status code to be returned to my driver.)  I can't
    successfully request any; io base, memory window, or irq.
 - So the driver fails the init process.

Under OS2 2.2 I seem to remember three other drivers had to be loaded for our
NDIS 2.0 pcmcia network adapter to run.  pcmcia.sys provided card services; a
socket services driver loaded, and on a ThinkPad 750 a resource manager was
loaded too.  (I think it was icrmu01.sys or something pretty close to that.)
The resource manager ran before card services and "sniffed" the sytem to
determine what was availaboe for card services to dole out.

There doesn't appear to be a resource manager under OS2 Warp Connect.  (Maybe
it's the AutoDrv2.sys stuff?)

I think the driver is pretty sound, but I'm up against a configuration problem
with OS2 Warp Connect.

Any help in this matter would be greatly appreciated.  Phone numbers,
references to documentation, on this bboard, in the Version 8 developer
connection CD-ROM's, on the OS2 Warp Connect distribution disk...



ANSWER:
The latest card services corrects this problem.




!OTHER___________________________________**********
December 22, 1995
QUESTION: (Ref: J13)
Can you tell us how we can obtain a spec.  for the interface that DOS device
drivers should use for power management?  We have the documentation for the
OS/2 interface to APM.SYS (described in the Input-Ouput Device Driver
Reference), and a BIOS spec.  for APM, but I guess what we really need is a
description of the interface to POWER.EXE.


ANSWER:
The interfaces for DOS power management are defined in the DOS Technical
Reference manual.  I believe that power management was added into DOS in\
version 5.0.


Check out the following Web Site :
http://www.intel.com/IAL/powermgm/powermgm.html APM 1.1 BIOS Specification is
available in the following Web Site :
http://www.intel.com/IAL/powermgm/apmovr.html Hope this helps




!OTHER__________________________________**********
December 15, 1995
QUESTION: (Ref: J14)
The driver supports an IOCtl function call to return status information to the
application.  The information is returned by the driver to the application
through the IOCtl data buffer.

To move the data to the IOCtl data buffer, the driver performs the following
operations:

1) Call DevHelp_VerifyAccess to insure that application has access to the
   to passed buffer.
2) Call DevHelp_VirtToLin to convert the virtual IOCtl buffer address to
   a linear address.
3) Call DevHelp_VMLock to lock the virtual buffer into memory until the
   data is copied.  Note: the flags to the DevHelp_VMLock call are
   (VMDHL_NOBLOCK ! VMDHL_WRITE ! VMDHL_LONG).
5) Copy the data to IOCtl data buffer.
6) Call DevHelp_VMUnLock to unlock IOCtl data buffer.

Typically this works just fine, but intermittently the application gets an
error from the driver indicating that the driver failed the VMLock call.  The
documentation on DevHelp_VMLock says that the lock will fail if the lock would
put the amount of free memory below a predetermined minimum.  There is no
other indication of what might cause the lock to fail.  Since the application
is large and OS/2 uses so much memory, I suppose this could be happening,
although the buffer I am trying to lock is small (48 bytes).

My questions are:

1) Would it help to remove the VMDHL_NOBLOCK flag so that the call will block
until memory is available?  What is the maximum time the call will block
waiting for memory to become available?  Is there a possibility of hanging the
system because memory never becomes available?

2) If changing the blocking flag does not fix the problem, what else can I do?
Does the application need to lock this memory itself prior to the IOCtl call
to prevent it from being swapped?  If so, how is this done?







ANSWER:
1) If Bit 0 of the Action Flags of VMLock DevHelp call is clear, the call will
block until the pages are available.If the memory never becomes available the
system will hang.You can check in your system that you have enough memory
available.  This depends on the number of drivers loaded and the memory
allocated by them, tasks running and the memory of the machine.

2) The application could lock discardable segment using DosLockSeg API call.
But the discardable segments are used for holding objects that are accessed
for short periods of time.  Refer section "DosLockSeg", chapter "Control
Program Function calls" in OS/2 Programming Reference.

3) If you require only small amount of memory, you could allocate it in your
driver at Init time using Devhelp_VMAlloc marking it as Fixed.  Then you could
use DevHelp_VMGlobalToProcess and pass the process address to the application
using IOCtl call.



!OTHER__________________________________**********
December 4, 1995
QUESTION: (Ref: J22)

Accessing the file in RAM takes twice as long (on average )as accessing the
network file server's disk drive.

I am asking if you can detect where/why RAM access in my IFS is so SLOW..
especially on cache hits.  Times for cache hits were like 14 milliseconds at
best to three or four SECONDS on cache misses.

Layout:
(code removed by the DDSC)


ANSWER:
We don't SEE anything OBVIOUS in the code, so it must be some combination of
race condition and thread timing.  I suggest that you start by placing some
appropriate printfs in the daemon around critical function, printing out the
milliseconds since ipl values.  This will give steps of 31ms.

This should help them start to narrow down the area of conflict.

We 'suspect' code trying to reconnect to the server is the cause but we can't
see it in this logic




!STORAGE________________________________*********
December 13, 1995
QUESTION: (Ref: J33)
I wanted to find out the status of Enhanced IDE support in the drivers
provided by IBM (ST506, etc.).  I heard a while back that IBM *might* add DMA
support to the IDE support currently in the base ST506/IDE driver supplied
with Warp.

Could you update me on what sort of EIDE support is currently, or soon will
be, provided with OS/2?

ANSWER:
ST506 will support ATA-2 in a future DDK Release.  Do not have any time frame
at the moment.

ATA-2 supports fast PIO & DMA modes.

ATA-2 will support the Identify Drive Command which allows the drive to tell
the software exactly what its characteristics are-this is useful for
Plug-N-Play.

ATA-2 will use the LBA Addressing Mode.



!DISPLAY________________________________**********
December 1, 1995
QUESTION: (Ref: J35)
I'm using the new model of OS/2 Presentation Driver that supports
QueryDeviceSurface.  According to the Presentation Device Driver Reference,
under the section "Graphics Engine/Presentation Driver Design Changes";
subsection "Mandatory Functions now handled by OS/2 Graphics Engine", it says
that the GRE create and manage bit maps.  It will support all standard
bitcounts (1, 4, 8, 16(future) and 24).  Does it mean that the GRE has yet to
be able to support device of 16 bitsperpel?


ANSWER:
The GRE supports 16bpp.  The error in the Presentation Driver Ref.  will be
fixed in the next release.  Defect # 146858 has been open to fix this error.




!NETWORK________________________________**********
December 12, 1995
QUESTION: (Ref:J39)
We now have our NDIS/MAC driver working reasonably robustly with TCP/IP, IPX,
and NetBIOS.  However, the performance simply isn't what it should be.

First, are there any performance measurement/profiling tools available to the
PDD writer?  Currently, I am just calling the timer and reporting deltas.  I
would prefer a PC histogram kind of mechanism.

If not, is there a timer available with greater than 1 millisecond
granularity?  Currently, I'm using the timer values in the global segment
variable.  I need microsecond granularity and would like nanosecond
granularity.  Naturally, I don't need interrupts at this rate, just having a
register that I could read occasionally would be good enough.

One thing that we noticed in particular is a performance anomoly with the
Netware Client.  Doing a DIR command in a command window works just fine.
Reading and writing files works fine also.  However, the performance while
navigating the PM folders and ICONS is painfully slow, on the order of a
minute to display the information when you use the GUI interface to open a
structure.

Is there something in particular that the Netware client does that would
affect this?


ANSWER:
1. SPM/2 2.0 allows you to register and update performance hooks.  You can
then collect them with SPM/2 and generate reports.  You can use this for
debugging, where you code the hooks during your development and remove them
before shipping.  For example, you could use this as a profiling tool to count
the number of times a procedure gets executed, or the amount of time spent in
a procedure.  You could also define a set of hooks that would be useful to
your customer, for example hooks to measure response time.  You could then
ship these hooks in your code and tell your customers that your product is
enabled with SPM performance hooks.

** SPM/2 is the IBM System Performance Monitor/2

2. A high resolution timer device driver (timer.sys) is available.  There was
an article about it in the fall '91 issue of "IBM Personal Systems Developer"
by Derek Williams.  It accesses the 8253/8254 counters and can record timer
ticks down to 840 nanoseconds.  You can read from the Timer Device driver via
DosRead's.Source listing of the driver is available in the above mentioned
Journal.  This has the risk of, other applications trying to use the same
channel.

Another high resolution timer with granularity of 1ms is available in DDK 3.

Also refer DevCon News Vol-8, article "An Accurate Software Delay for OS/2
Device Drivers" by Frank Schroeder and Allen Wynn.

3.Currently there is no way of getting Microsecond/nanosecond resolution with
the OS/2 timer.  The only way to get timer interrupts faster than
32milliseconds is the use a hardware timer card that supplies interrupts at a
faster rate, and provide a physical device driver to field the interrupts
through DevHelp_SetIrq.

4. You could make sure that the Netware Client does not have too many threads
and time critical threads active.



!OTHER___________________________________**********
December 12, 1995
QUESTION: (Ref: J40)
I am working on a project for a client that needs to perform flash BIOS
upgrades on diskless workstations running OS/2.  They would like me to port
their current DOS application which does these upgrades.  The DOS application
puts the CPU in "Real BIG mode" and accesses the appropriate memory directly
with absolute 32 bit addresses.  I have a few questions about the best way of
leveraging the current code and how OS/2 will deal with this.

1) Is there an easy way to simulate "real big mode" via some GDT that maps the
entire physical memory?

2) Whether I can do real big mode or not, I'll definately need to access
physical blocks bigger than 64k.  Is there an easy way to do this inside the
driver?  I know VMAlloc can map more than 64k, but how do I access that inside
the driver?  I'm assuming 386 instructions which use 32 bit offsets don't work
at driver task time's 286 protected mode.  Would the alternative of mapping
the space in the driver and letting the application do the access of RAM save
me time?

3) Are there any core parts of the system which use the BIOS?  This program
will run and then reboot the system, but it at least needs to be able to run
to completion.  Some things which may need to be done to program the flash
part are:  enabling a memory mapping to the flash part which can be in low
(conventional) memory or extremely high memory, disabling rom shadowing,
disabling cpu caching, and obviously, overwriting the BIOS.  Will any of these
interfere with OS/2's operation to the point that the application will be
unable to complete?

I know this is all dangerous and goes against everything that OS/2's memory
protection was designed for, but that's the job at hand.  I don't have any
choice.  Hopefully there are ways to do these things.




ANSWER:
1) Device drivers CAN use 32 bit instructions, but cannot be COMPILED as 32
bit executables.  you CAN access >64k linear segments from the DD and do what
you need.  The 'trick' is finding the linear kernel segment value.

PUCHAR work;
PULONG work1;
    if(DevHelp_GetDOSVar( 10,0,(PPVOID)&work) )
    {
      // handle devhelp failure

    } /* end if */
        else {
              work+=(*(work)*sizeof(ULONG))+sizeof(UCHAR)+sizeof(UCHAR);
              work1=(PULONG)work;
              work1+=10;
              FlatDS=(USHORT)(*work1);
             } /* end else */

basically, devhelp_getdosvar(10) points to a table 1 byte count of following
ulongs n ulongs 1 byte count of following ulongs n ulongs

This code gets to the start of the second list,the 10th entry is the kernel
flat DS value.  For the Flat CS Values use the index 9 in DevHlp_GetDosVar

The other alternative would be to use the DOS32FLATDS as in some of the sample
codes avalable in the DDK.

2) There are core parts of the system which use BIOS.  Early in the boot
process, while the system is in real mode, the kernel/boot loader call BIOS in
real mode.  The int 13 (dasd) adapter driver (.add) also calls BIOS in real
mode.  The APM and PCMCIA drivers call BIOS in protect mode.  There may be
other drivers which depend upon BIOS and/or BIOS data areas.  The printer,
mouse, diskette, harddisk and COM Port BIOS interrupts are emulated by the
respective virtual device drivers.  The keyboard virtual device driver
emulates Int 09H but does not emulate Int 16H.  This could interfere with
OS/2's operartion.  Refer sections"BIOS Hardware Interrupt Support" and "BIOS
Software Interrupt Support" , chapter" VDD Architecture and Operations" and
chapter "Base Virtual Device Drivers" in Virtual Device Driver Reference for
more info.



QUESTION:
Once I execute the code you included to get the selector for the 4GB address
space, how can I tell OS/2 to stop using a given area of memory.  For instance
if I wanted to use the area of memory between 10MB and 11MB, how do I tell
OS/2 to stop using that area so I don't stomp on top of the application's
memory space?


ANSWER:
You can't exclude a memory area.  You could just allocate some memory, maybe
at a fixed location (DevHelp_VMAlloc(map_phys,,,)) Assuming this memory is NOT
in the general system memory pool (more like adapter ram).




!MULTIMEDIA______________________________**********
December 15, 1995
QUESTIONS: (Ref: J43)
I want to get information about VSD (Vendor specific driver).

Can you give me Book references about making an audio VSD.

So I could order such a book to IBM.

ANSWER:
The source code of Audio & Video VSD is available on the DDK.  Documentation
is available in the MMPM/2 Device Driver Ref.,Ch.- Audio Sample for Vendor
Specific Drivers Pub # :  S71G-3678-02 This is also available on-line in the
DDK.
