As Pi 32
As Pi 32
Trademarks
Adaptec, the Adaptec logo, and AHA are trademarks of Adaptec, Inc. which may be registered in some
jurisdictions.
All other trademarks are owned by their respective owners.
Changes
The material in this document is for information only and is subject to change without notice. While reasonable
efforts have been made in the preparation of this document to assure its accuracy, Adaptec, Inc. assumes no
liability resulting from errors or omissions in this document, or from the use of the information contained herein.
Adaptec reserves the right to make changes in the product design without reservation and without notification
to its users.
THE ADAPTEC SOFTWARE IS PROVIDED "AS IS". THERE ARE NO WARRANTIES AND ADAPTEC
EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
PARTICULAR PURPOSE. Adaptec has no obligation to provide any modifications, improvements, updates,
training or support relating to the Adaptec Software. Any such matters, if applicable, shall be subject to mutual
written agreement between the parties.
For licensing information, please contact Adaptec's Diane McGee at (408) 957-4836 or
[email protected].
Before Beginning
Before you begin your ASPI for Win32 development effort, be sure that you have a solid understanding of the
SCSI specifications. Much of your success in developing an ASPI module is dependent on your understanding
of these specifications. Here are sources for the specifications:
In addition, it is highly recommended that you acquire the technical reference manuals for any SCSI hardware
which your ASPI module intends to support. These manuals can be obtained from the hardware manufacturer,
and they provide detailed information on which SCSI commands are supported and how they are implemented.
Unless otherwise noted, all multibyte fields follow Intel's byte order of low byte first and end with the high byte.
For example, if there is a 2-byte offset field, the first byte is the low byte of the offset while the second byte is the
high byte of the offset.
All structure fields marked reserved must be set to zero, and structures must be packed! Packed means that byte
alignment is used on all structure definitions. Microsoft compilers allow byte packing to be set through the use
of “#pragma pack(1)” while Borland compilers allow packing to be set with “#pragma option -a1”. See your
compiler documentation for more information. Failure to pack structures and zero reserved fields can cause
system instability, including crashes.
All ASPI for Win32 functions are exported from WNASPI32.DLL using the ‘C’ calling convention (specifically,
__cdecl as implemented by Microsoft’s compilers). With the ‘C’ calling convention the caller pushes the last
function argument on the stack first (the first argument has the lowest memory address), and the caller is
responsible for popping arguments from the stack.
Programming Guidelines
The following are some general guidelines to keep in mind while reading this specification and while writing
ASPI for Win32 applications:
• If you are using explicit dynamic linking, remember that the ASPI for Win32 DLL is named WNASPI32.DLL
and not WINASPI.DLL. Make sure to call LoadLibrary appropriately.
• ASPI for Win32 is fully re-entrant and permits overlapped, asynchronous I/O. ASPI modules can send
additional ASPI requests while others are pending completion. Be sure to use separate SRBs for each ASPI
request.
• For requests requiring data transfers, the direction bits in the SRB_Flags field must be set correctly.
Direction bits are no longer optional for data transfers. This means that SRB_DIR_SCSI is no longer a
valid setting. For requests not requiring data transfers, the direction bits are ignored.
• Be sure that buffers are aligned according to the buffer alignment mask returned by the SC_HA_INQUIRY
command.
• ASPI SCSI Request Blocks (SRBs) and data buffers do not need to be in page-locked memory. The ASPI
manager takes care of locking buffers and SRBs.
• If an error SS_BUFFER_TOO_BIG is returned by the SendASPI32Command routine, you should break
the transfer down into multiple 64KByte transfers or less. Another alternative is to use the
GetASPI32Buffer/FreeASPI32Buffer calls to allocate large transfer buffers.
• If you send an ASPI request with posting (callbacks) enabled, the post procedure will always be called.
In order to access these five functions, they must be resident in memory. Dynamic linking is the process by
which Windows loads dynamic-link libraries (DLLs) into memory and then resolves application references to
functions within those DLLs. There are two ways in which this load/resolve sequence is handled: explicitly or
implicitly.
At this point there should be a valid address for each of the five functions. If you have an old version of ASPI
then the last three function addresses will be NULL. This case should be handled by disabling all use of new
features in your ASPI module. It is also good practice to check pfnGetASPI32SupportInfo and
pfnSendASPI32Command for NULL as well. These variables will be NULL if there is an error accessing the DLL.
If either of these two functions have NULL addresses your application should cease its use of ASPI and unload
WNASPI32.DLL with a call to FreeLibrary.
Using the addresses returned from GetProcAddress is very simple. Just use the variable name wherever you
would normally use a function name. For example,
DWORD dwASPIStatus = pfnGetASPI32SupportInfo();
will call the GetASPI32SupportInfo and place the result in dwASPIStatus. Of course, if one of these
function pointers is NULL and you make a call to it, your application will crash.
Parameters
None.
Return Values
The DWORD return value is split into three pieces. The high order WORD is reserved and shall be set to 0. The
two low order bytes represent a status code (bits 15-8) and a host adapter count (bits 7-0).
If the call to GetASPI32SupportInfo is successful, then the status byte is set to either SS_COMP or
SS_NO_ADAPTERS. If set to SS_COMP then the host adapter status will be non-zero. An error code of
SS_NO_ADAPTERS indicates that ASPI initialized successfully, but that it could not find any SCSI host
adapters to manage.
If the function fails the status byte will be set to one of SS_ILLEGAL_MODE, SS_NO_ASPI,
SS_MISMATCHED_COMPONENTS, SS_INSUFFICIENT_RESOURCES, SS_FAILED_INIT. See the table
of ASPI errors at the end of this manual for more information on each of the errors.
Remarks
The number of host adapters returned represents the logical bus count, not the true physical adapter count. For
host adapters with a single bus, the host adapter count and logical bus count are identical.
Example
This example returns the current status of ASPI for Win32.
BYTE byHaCount;
BYTE byASPIStatus;
DWORD dwSupportInfo;
dwSupportInfo = GetASPI32SupportInfo();
byASPIStatus = HIBYTE(LOWORD(dwSupportInfo));
byHaCount = LOBYTE(LOWORD(dwSupportInfo));
Parameters
psrb
All SRBs have a standard header, and the header contains a command code which defines the exact type of
SCSI I/O being requested.
typedef struct
{
BYTE SRB_Cmd; // ASPI command code
BYTE SRB_Status; // ASPI command status byte
BYTE SRB_HaId; // ASPI host adapter number
BYTE SRB_Flags; // ASPI request flags
DWORD SRB_Hdr_Rsvd; // Reserved, MUST = 0
}
SRB_Header;
The SRB_Cmd field contains the command code for the desired SCSI I/O operation. This field can be set to
one of the following values.
The use of the remaining header fields varies according to the command type. Each of the commands along
with their associated SRBs are described in detail in the following sections.
Return Values
The above ASPI commands may be broken into two categories: synchronous and asynchronous. All of the
SRBs are synchronous except for SC_EXEC_SCSI_CMD and SC_RESET_DEV which are asynchronous.
Calls to SendASPI32Command with synchronous SRBs will not return until execution of that SRB is complete.
Upon return the SRB_Status field will be set to the same value which is returned from
SendASPI32Command.
Calls to SendASPI32Command with asynchronous SRBs may return control to the caller before the submitted
SRB has completed execution. In this case the return value from this function is SS_PENDING, and the caller
will have to use polling, posting, or event notification to wait for SRB completion. Once completed, the
SRB_Status field contains the true completion status. Remember that while waiting for SRB completion, it is
always safe to submit additional SRBs to ASPI for execution.
SRB Fields
SRB_Cmd (Input)
This field must contain SC_HA_INQUIRY (0x00).
SRB_Status (Output)
SC_HA_INQUIRY is a synchronous SRB. On return, this field is the same as the SendASPI32Command
return value and is set to either SS_COMP or SS_INVALID_HA.
SRB_HaId (Input)
This field specifies which installed host adapter the request is intended for. Host adapter numbers are
always assigned by the ASPI manager, beginning with zero. To determine the total number of host adapters
in the system set this field to 0 and then check the HA_Count value on return.
GetASPI32SupportInfo can also be used.
HA_Count (Output)
The number of host adapters detected by ASPI. For example, a return value of 2 indicates that host adapters
#0 and #1 are valid. The number of host adapters returned represents the logical bus count instead of the
true physical adapter count. For host adapters that support single bus only, the host adapter count and
logical bus count are identical. For host adapters that support multiple buses, the host adapter count
represents the total logical bus count.
HA_SCSI_ID (Output)
The SCSI ID of the host adapter on the SCSI bus. SCSI adapters usually use ID 7 as their SCSI ID.
HA_ManagerId (Output)
The ASCII string “ASPI for Win32”. The string is padded with spaces to the full width of the buffer, and it
is not null terminated.
HA_Identifier (Output)
An ASCII string describing the host adapter. The string is padded with spaces to the full width of the
buffer, and it is not null terminated.
Remarks
Residual byte length is the number of bytes not transferred to, or received from, the target SCSI device. For
example, if the ASPI buffer length for a SCSI INQUIRY command is set for 100 bytes, but the target only returns
36 bytes; the residual length is 64 bytes. If the ASPI buffer length for a SCSI WRITE command is set for 514
bytes b ut the target only takes 512 bytes, the residual length is 2 bytes. ASPI modules can determine if the ASPI
manager supports residual byte length by checking byte 1 of the HA_Unique field. See
SC_EXEC_SCSI_CMD for more information on enabling residual byte counting.
Example
This example sends an SC_HA_INQUIRY to host adapter #1, and, if successful, records the maximum transfer
length supported by the host adapter.
DWORD dwMaxTransferBytes;
SRB_HAInquiry srbHAInquiry;
SendASPI32Command( (LPSRB)&srbHAInquiry );
if( srbHAInquiry.SRB_Status != SS_COMP )
{
// Error in HAInquiry. Most likely SS_INVALID_HA.
Return FALSE;
}
SRB Fields
SRB_Cmd (Input)
This field must contain SC_GET_DEV_TYPE (0x01).
SRB_Status (Output)
SC_GET_DEV_TYPE is a synchronous SRB. On return, this field is the same as the
SendASPI32Command return value and is set to SS_COMP, SS_INVALID_HA, or SS_NO_DEVICE.
SRB_HaId (Input)
This field specifies which installed host adapter the request is intended for.
SRB_Target (Input)
SCSI ID of target device.
SRB_Lun (Input)
Logical Unit Number (LUN) of target device.
Example
This example scans the system for all CD-ROM drives (all targets must be at LUN #0). Please note that
MAX_HA_ID and MAX_TARGET_ID should be replaced with a host adapter count returned by
GetASPI32SupportInfo and a target count retrieved from a SC_HA_INQUIRY SRB performed within the
host adapter loop.
BYTE byHaId;
BYTE byTarget;
SRB_GDEVBlock srbGDEVBlock;
SendASPI32Command( (LPSRB)&srbGDEVBlock );
if( srbGDEVBlock.SRB_Status != SS_COMP ) continue;
SRB Fields
SRB_Cmd (Input)
This field must contain SC_EXEC_SCSI_CMD (0x02).
SRB_Status (Output)
SC_EXEC_SCSI_CMD is an asynchronous SRB. This field should not be examined until after the caller
has waited for proper completion of the SRB (see “Waiting for Completion”). Once completed, this field may
be set to a number of different values. The most common values are SS_COMP or SS_ERR. SS_COMP
indicates successful completion while SS_ERR indicates the caller should examine the SRB_HaStat and
SRB_TargStat fields for more information. See “ASPI for Win32 Error” for a complete description of
possible error codes.
SRB_HaId (Input)
This field specifies which installed host adapter the request is intended for. Host adapter numbers are
always assigned by the SCSI manager layer beginning with zero.
SRB_TargStat (Output)
Upon completion of the SCSI command, this field is set to the final SCSI target status. Do not examine this
status byte if SRB_Status is set to SS_COMP. It is only to be considered valid if there is unsuccessful
completion of the SRB. Note that the table below only covers the most common result codes. Check the
SCSI specification for more information on these and other status byte codes.
Symbol Value Description
STATUS_GOOD 0x00 No target status.
STATUS_CHKCOND 0x02 Check status (sense data is in SenseArea).
STATUS_BUSY 0x08 Specified Target/LUN is busy.
STATUS_RESCONF 0x18 Reservation conflict.
SRB_PostProc (Input)
If posting is enabled (SRB_POSTING) this field contains a pointer to a function. The ASPI manager calls
this function upon completion of the SRB. If event notification is enabled (SRB_EVENT_NOTIFY) this
field contains a handle to an event. The ASPI manager signals this event upon completion of the SRB. See
“Waiting for Completion” for more information.
CDBByte (Input)
This field contains the CDB as defined by the target's SCSI command set. The length of the SCSI CDB is
specified in the SRB_CDBLen field.
SenseArea (Output)
The SenseArea is filled with the sense data after a check condition (SRB_Status == SS_ERR and
SRB_TargStat == STATUS_CHKCOND). The maximum length of this field is specified in the
SRB_SenseLen field.
BYTE byInquiry[32];
DWORD dwASPIStatus;
HANDLE heventSRB;
SRB_ExecSCSICmd srbExec;
ResetEvent( hevenSRB );
dwASPIStatus = SendASPI32Command( (LPSRB)&srbExec );
if( dwASPIStatus == SS_PENDING )
{
WaitForSingleObject( heventSRB, INFINITE );
}
SRB Fields
SRB_Cmd (Input)
This field must contain SC_ABORT_SRB (0x03).
SRB_Status (Output)
SC_ABORT_SRB is a synchronous SRB. On return, this field is the same as the SendASPI32Command
return value and is set to SS_COMP, SS_INVALID_HA, or SS_INVALID_SRB. Remember that a return
of SS_COMP does not indicate that the SRB to be aborted has been halted. Instead, it indicates that an
attempt was made at aborting that SRB. If the SRB to be aborted completes with SS_ABORTED then there
is positive indication that the original SC_ABORT_SRB worked.
SRB_HaId (Input)
This field specifies which installed host adapter the request is intended for. Host adapter numbers are
always assigned by the ASPI manager layer beginning with zero.
SRB_ToAbort (Input)
This field contains a pointer to the SRB which is to be aborted. The actual failure or success of the abort
operation is indicated by the status eventually returned in this SRB.
Remarks
As stated above, the success of an SC_ABORT_SRB command is never guaranteed. As a matter of fact, the
situations in which ASPI is capable of aborting an SRB already sent to the system are few and far between.
The original use for SC_ABORT_SRB was to terminate I/O which had timed out under ASPI for DOS and ASPI
for Win16. The nature of SC_ABORT_SRB under Win32 greatly reduces its usefulness. It is recommended that
the SC_GETSET_TIMEOUTS SRB be used to manage SRB timeouts in all new ASPI mo dules.
SRB Fields
SRB_Cmd (Input)
This field must contain SC_RESET_DEV (0x04).
SRB_Status (Output)
SC_RESET_DEV is an asynchronous SRB. This field should not be examined until after the caller has
waited for proper completion of the SRB (see “Waiting for Completion”). Once completed, this field may be
set to a number of different values. The most common values are SS_COMP or SS_ERR. SS_COMP
indicates successful completion while SS_ERR indicates the caller should examine the SRB_HaStat and
SRB_TargStat fields for more information. See “ASPI for Win32 Error” for a complete description of
possible error codes.
SRB_HaId (Input)
This field specifies which installed host adapter the request is intended for. Host adapter numbers are
always assigned by the SCSI manager layer beginning with zero.
SRB_Target (Input)
SCSI ID of target device.
SRB_Lun (Input)
Logical Unit Number (LUN) of target device. This field is ignored by ASPI for Win32, since SCSI BUS
DEVICE RESET is done on a per-target basis only.
SRB_TargStat (Output)
Upon completion of the SCSI command, this field is set to the final SCSI target status. Do not examine this
status byte if SRB_Status is set to SS_COMP. It is only to be considered valid if there is unsuccessful
completion of the SRB. Note that the table below only covers the most common result codes. Check the
SCSI specification for more information on these and other status byte codes.
Symbol Value Description
STATUS_GOOD 0x00 No target status.
STATUS_CHKCOND 0x02 Check status (sense data is in SenseArea).
STATUS_BUSY 0x08 Specified Target/LUN is busy.
STATUS_RESCONF 0x18 Reservation conflict.
SRB_PostProc (Input)
If posting is enabled (SRB_POSTING) this field contains a pointer to a function. The ASPI manager calls
this function upon completion of the SRB. If event notification is enabled (SRB_EVENT_NOTIFY) this
field contains a handle to an event. The ASPI manager signals this event upon completion of the SRB. See
“Waiting for Completion” for more information.
Remarks
The Windows (98, ME, NT, 2000, XP (32-bit)) operating systems do not handle BUS DEVICE RESET properly at
the current time. For this reason, SC_RESET_DEV calls are not guaranteed to function properly. The command
is present mainly to keep older code ported from Win16 from failing.
Note: This command is not valid for Windows NT/2000/XP (32-bit), which does not use the Int 13 interface.
typedef struct
{
BYTE SRB_Cmd; // ASPI command code = SC_GET_DISK_INFO
BYTE SRB_Status; // ASPI command status byte
BYTE SRB_HaId; // ASPI host adapter number
BYTE SRB_Flags; // Reserved
DWORD SRB_Hdr_Rsvd; // Reserved
BYTE SRB_Target; // Target's SCSI ID
BYTE SRB_Lun; // Target's LUN number
BYTE SRB_DriveFlags; // Driver flags
BYTE SRB_Int13HDriveInfo; // Host Adapter Status
BYTE SRB_Heads; // Preferred number of heads translation
BYTE SRB_Sectors; // Preferred number of sectors translation
BYTE SRB_Rsvd1[10]; // Reserved
}
SRB_GetDiskInfo, *PSRB_GetDiskInfo;
SRB Fields
SRB_Cmd (Input)
This field must contain SC_GET_DISK_INFO (0x06).
SRB_Status (Output)
SC_GET_DISK_INFO is a synchronous SRB. On return, this field is the same as the
SendASPI32Command return value and is set to SS_COMP, SS_INVALID_HA, or SS_NO_DEVICE, or
SS_INVALID_SRB.
SRB_HaId (Input)
This field specifies which installed host adapter the request is intended for. Host adapter numbers are
always assigned by the ASPI manager layer beginning with zero.
SRB_Target (Input)
SCSI ID of target device.
SRB_Lun (Input)
Logical Unit Number (LUN) of target device.
Example
This example obtains disk information from device LUN 0, SCSI ID 2, attached to host adapter 0.
SRB_GetDiskInfo srbGetDiskInfo;
SendASPI32Command( (LPSRB)&srbGetDiskInfo );
if( srbGetDiskInfo.SRB_Status != SS_COMP )
{
// Error handling GetDiskInfo SRB. Error handling code goes here!
}
SRB Fields
SRB_Cmd (Input)
This field must contain SC_RESCAN_SCSI_BUS (0x07).
SRB_Status (Output)
SC_RESCAN_SCSI_BUS is a synchronous SRB. On return, this field is the same as the
SendASPI32Command return value and is set to SS_COMP, or SS_INVALID_HA.
SRB_HaId (Input)
This field specifies which installed host adapter the request is intended for. Host adapter numbers are
always assigned by the ASPI manager layer beginning with zero.
Remarks
Under Windows NT/2000/XP (32-bit), the I/O subsystem does not rescan devices/IDs it already knows about.
The impact of this is that it will detect new devices but will not detect removal of devices or exchanging of
devices.
Under Windows 98/ME, there can be a substantial delay between the time a rescan is initiated with this
command and the time at which new devices are added or old devices are removed from the device map. The
best way to deal with this is to rely on the Plug and Play messages in conjunction with
TranslateASPI32Address, or to simply perform your own refresh five or ten seconds after the rescan
command is issued.
There is no way to force a rescan of the entire system. It is up to the operating system to detect the arrival of
new host adapters (for example, PCMCIA) through Plug and Play, if it is available.
Example
The following example forces a rescan of the SCSI bus attached to host adapter #0:
SendASPI32Command( (LPSRB)&srbRescanPort );
if( srbRescanPort.SRB_Status != SS_COMP )
{
// Error issuing port rescan. Error handling code goes here.
}
SRB Fields
SRB_Cmd (Input)
This field must contain SC_GETSET_TIMEOUTS (0x08).
SRB_Status (Output)
SC_GETSET_TIMEOUTS is a synchronous SRB. On return, this field is the same as the
SendASPI32Command return value and is set to SS_COMP, SS_INVALID_HA, SS_NO_DEVICE, or
SS_INVALID_SRB (bad flags, invalid timeout, etc.).
SRB_HaId (Input)
This field specifies which installed host adapter the request is intended for If SRB_DIR_OUT is set in
SRB_Flags then this value may be a wildcard (0xFF) indicating that the SRB_Target/SRB_Lun
combination on ALL host adapters should get new a timeout.
SRB_Flags (Input)
May be set to one and only one of the following two constants:
Symbol Value Description
SRB_DIR_IN 0x08 SRB is being used to retrieve current timeout setting.
Wildcards are not allowed in the ASPI address fields
SRB_DIR_OUT 0x10 SRB is being used to change the current timeout setting.
Wildcards are valid in the ASPI address fields.
SRB_Target (Input)
This field indicates the SCSI ID of the target device. If SRB_DIR_OUT is set in SRB_Flags then this value
may be a wildcard (0xFF) indicating that ALL SCSI IDs of the passed SRB_HaId/SRB_Lun combination
should get a new timeout.
Remarks
Once a timeout is set for a target, that timeout will be used on all SRBs passed to SendASPI32Command with
SC_EXEC_SCSI_CMD. If one of these SRBs actually times out, then the SCSI bus will be reset (this is NOT a
bus device reset, but a full SCSI bus reset). This causes all of the SRBs executing on the bus to be cancelled,
and the miniport will set error codes in the SRBs as appropriate. It is up to the code which originally submitted
these SRBs to retry the commands as necessary (for example, if an ASPI request times out and the bus is reset, a
file system command to another target could be cancelled, and it is up to the file system to retry the command).
In addition, the result placed in the SRB which times out depends on the error codes which the miniport places in
the SRB. In the case of Adaptec controllers, the result code is SS_ABORT. In other miniports, the result may be
SS_ERR with a host adapter status set to HASTAT_TIMEOUT or HASTAT_COMMAND_TIMEOUT, or it may be
some new error result not yet encountered. Suffice it to say that the SRB which times out should return with an
error, and it is up to the higher level applications to perform retries of the SRB and any other SRB which may
have been affected by the associated bus reset.
When using event notification with timeouts, it is important to remember that the HEVENT used in the
SRB_PostProc field has an ENTIRELY SEPERATE timeout associated with it. In other words, the timeout
associated with an event is seperate from the timeout associated with an SRB. If you set a timeout on an SRB
and then set an infinite timeout in WaitForSingleObject on the SRB event, then the SRB will STILL
TIMEOUT and signal completion of the SRB. Conversely, if you set a 30 hour timeout on the SRB and a 5
second timeout on the event, the event will always go signaled before the SRB completes, and no cleanup of the
SRB on the bus will take place.
HA ID LN Device Affected
00 01 FF All of target 1's luns on host adapter 0.
FF 00 FF All luns on targets with ID 0 on any host adapter.
FF FF 00 Lun 0 of all targets on any host adapter.
FF FF FF All targets on any host adapter with any lun number (everything).
Next is an example in which all LUNs on target 5, host adapter 0 are set to 10 seconds:
SRB_GetSetTimeouts srbGetSetTimeouts;
SendASPI32Command( (LPSRB)&srbGetSetTimeouts );
if( srbGetSetTimeouts.SRB_Status != SS_COMP )
{
// Error setting timeouts. Put error handling code here.
}
Parameters
pab
Pointer to a filled out ASPI32BUFF structure.
typedef struct
{
LPBYTE AB_BufPointer; // Pointer to the ASPI allocated buffer
DWORD AB_BufLen; // Length in bytes of the buffer
DWORD AB_ZeroFill; // Flag set to 1 if buffer should be
zeroed
DWORD AB_Reserved; // Reserved, MUST = 0
}
ASPI32BUFF, *PASPI32BUFF;
AB_BufPointer (Output)
After a successful call (return value TRUE) this field contains the address of the large transfer buffer
which has been allocated for the application.
AB_BufLen (Input)
Set to the size, in bytes, desired for the transfer buffer. This must be less than or equal to 512KB and
should be greater than 64KB (although there are no requirements on the low end).
AB_ZeroFill (Input)
Set this flag to 1 if ASPI should clear the transfer buffer after allocation but before returning to the
caller. Leave the flag set to 0 if the memory can remain uninitialized.
Remarks
If you have experienced a failure to allocate a buffer, you may need to do one or all of the following:
1. Increase the non-paged pool size on your PC (allocate more RAM to non-paged pool),
2. Physically add mo re RAM to your PC.
3. Decrease the buffer size requested.
The first thing to do is to increase the non-paged pool size.
1) How to increase the non-paged pool size?
i. Run regedt32.exe ( click Start ØRun and type regedt32 ),
ii. Edit HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ Ã
SessionManager\MemoryManagement\NonPagedPoolSize
This parameter is a REG_DWORD (32 bits).
Tips
Set the NonPagedPoolSize to 0x00100000 for 1 MegaByte; 0x00200000 for 2 MegaBytes; etc.
See the Microsoft Developer Network (MSDN) article Q126402 (www.microsoft.com) for more information
regarding setting the non-paged pool size.
Return Values
This function returns TRUE if it successfully allocates a large transfer buffer, and FALSE otherwise. The caller
should assume that this call can fail, and should allow the code to work with smaller transfer buffers allocated
from VirtualAlloc (if at all possible).
Example
The following example allocates a 128KB buffer for use with ASPI.
ASPI32BUFF ab;
Parameters
pab
Pointer to a filled out ASPI32BUFF structure.
typedef struct
{
LPBYTE AB_BufPointer; // Pointer to the ASPI allocated buffer
DWORD AB_BufLen; // Length in bytes of the buffer
DWORD AB_ZeroFill; // Reserved, MUST = 0
DWORD AB_Reserved; // Reserved, MUST = 0
}
ASPI32BUFF, *PASPI32BUFF;
AB_BufPointer (Input)
Pointer to the buffer previously returned from a successful call to GetASPI32Buffer. The address
must match exactly for the free to occur.
AB_BufLen (Input)
Set to the original size, in bytes, of the buffer allocated by a call to GetASPI32Buffer. The size
must match exactly for the free to occur.
Return Values
This function returns TRUE if the memory allocated to the buffer has been released. FALSE is returned if there is
an error freeing the memory or if the passed in AB_BufPointer/AB_BufLen fields don’t match a those of a
previously allocated buffer.
Parameters
pdwPath (Input/Output)
Pointer to a ASPI address “path.” The path is simply a packed version of an ASPI address triple. Every
target address in ASPI consists of a host adapter identifier, a SCSI ID, and a SCSI LUN. Each of these
values consists of a BYTE, so an ASPI address “path” is a DWORD encoded as 0x00HHIILL where HH is
the host adapter identifier, II is the SCSI ID, and LL is the SCSI LUN. Note that if II and LL are both 0xFF
then the path represents a host adapter. This is necessary because host adapters have their own
DEVNODEs in the Plug and Play subsystem.
pdwDEVNODE (Input/Output)
Pointer to a DWORD which contains a Windows 98 DEVNODE ID. This parameter controls the direction of
translation. If the DWORD contains a 0 (note that this does not mean that pdwDEVNODE is NULL) then
translation is from the ASPI triple to the DEVNODE. If the DEVNODE is non-zero then translation is from
the DEVNODE to an ASPI triple.
Return Values
TRUE if there is a successful translation. FALSE is returned if the parameters are invalid or if there is no
translation between ASPI path and Windows 98 DEVNODE.
Remarks
In order for this scheme to work properly, applications should pay attention to WM_DEVICECHANGE messages
which utilize DBT_DEVTYP_DEVNODE device change data. The device change data type can be detected by
checking the dcbh_devicetype field in the DEV_BROADCAST_HEADER associated with device change events.
Review the Plug and Play documentation in Win32 for more information.
pDevnodeData = (PDEV_BROADCAST_DEVNODE)pHeader;
dwDEVNODE = pDevnodeData->dbcd_devnode;
return TRUE;
}
BYTE byInquiry[32];
DWORD dwASPIStatus;
HANDLE heventSRB;
SRB_ExecSCSICmd srbExec;
ResetEvent( hevenSRB );
dwASPIStatus = SendASPI32Command( (LPSRB)&srbExec );
if( dwASPIStatus == SS_PENDING )
{
WaitForSingleObject( heventSRB, INFINITE );
}
BYTE byInquiry[32];
SRB_ExecSCSICmd srbExec;
SendASPI32Command( (LPSRB)&srbExec );
. . .
/**
*** The code above is a separate thread of execution from
*** the code below which handles the inquiry callback. Note that
*** the callback usually signals the main thread of execution that
*** the an SRB it submitted has completed. In this case we aren’t
*** doing anything but checking for errors.
**/
BYTE byInquiry[32];
SRB_ExecSCSICmd srbExec;
SendASPI32Command( (LPSRB)&srbExec );
while( srbExec.SRB_Status == SS_PENDING );