NPA_Allocate_Memory

Allocates a block of system memory for local use of the module. The memory block is returnable to the system.

Requirements: This function cannot be called at interrupt level. If flag is set to Blocking, this function must be called in a blocking context.
Thread Context:Non-Blocking/Blocking (See flag below for details)

Syntax

    LONG NPA_Allocate_Memory (
       LONG   npaHandle,
       void **virtualPointer,
       void **physicalPointer,
       LONG   bufferSize,
       LONG   flag,
       LONG  *sleptFlag
       );
    
    

Parameters

npaHandle
(IN) The CDM's or HAM's handle for using the NPA APIs, assigned during NPA_Register_CDM_Module or NPA_Register_HAM_Module.
virtualPointer
(IN/OUT) Pointer to the memory location of the desired data type. Receives the starting virtual address of the allocated memory block from the OS.
physicalPointer
(IN/OUT) Pointer to the memory location of the desired data type. Receives the starting physical (absolute) address of the allocated memory block from the OS.
bufferSize
(IN) Size, in bytes, of the memory block being requested.
flag
(IN) Indicator telling NWPA the type of allocation being requested. Knowing the allocation type allows NWPA to track the memory resource. This parameter can have one of the following values:

Value

Description

0x00000000

Indicates a normal memory request.

0x00000001

Indicates a request for physically contiguous memory, for use as an I/O buffer.

0x00000002

Indicates a request for memory below 16 MB (supporting ISA adapters that can access only 16 MB).

0x00000004

Selects the Blocking version of this function. If this flag is set, this function can sleep (block) to allow a single additional attempt to allocate the requested memory. If it was required to sleep to allocate the memory, the sleptFlag parameter will be nonzero. Use of this flag requires the call to be made in a blocking context. If this flag is set on a NetWare 3.12 Server, it defaults to a normal memory request (0x00000000) and sleptFlag is ignored.

sleptFlag
(OUT) This parameter is used only if flag is set to Blocking. A nonzero value indicates that the function went to sleep to complete the allocation request. If flag is not set to Blocking, this parameter is not used and should be set to zero.

Return Values

The following table lists return values and descriptions.

zero

Successful

nonzero

Unsuccessful

Remarks

NPA_Allocate_Memory is used to allocate system memory required by a CDM/HAM, such as special data structures or buffers. This allocation is on paragraph (16-byte) boundaries. The CDM/HAM must provide the storage locations (virtualPointer and physicalPointer) for the outputs it receives during this call.

NPA_Allocate_Memory is passed the two pointer-to-pointer variables and a buffer size. It allocates a memory block of the requested size and assigns its starting virtual address to one of the pointer-to-pointer variables and assigns its starting physical address to the other variable. The virtual address is the logical NetWare address of the allocated memory block. The physical address is the absolute hardware address of the allocated memory block, and it is provided to support adapters using DMA.

The memory allocated by this function is not initialized to any value. The CDM/HAM is responsible for initializing allocated memory. Additionally, this function may be called during the context of any process, except a process within an interrupt level. Memory should not be allocated at the interrupt level. Memory is returned to the system pool using NPA_Return_Memory.

If the CDM allocates a memory buffer to be accessed by a HAM, it must allocate the memory as an I/O buffer.

NOTE:If the requested size is less than 3888 bytes, the resulting memory is physically contiguous (regardless of the flag setting).