viMemAlloc/viMemAllocEx

NI-VISA

viMemAlloc/viMemAllocEx

Purpose

Allocates memory from a resource's memory region.

C Syntax

ViStatus viMemAlloc(ViSession vi, ViBusSize size, ViPBusAddress offset)

ViStatus viMemAllocEx(ViSession vi, ViBusSize size, ViPBusAddress64 offset)

Visual Basic Syntax

viMemAlloc&(ByVal vi&, ByVal size&, offset&)

Resource Classes

GPIB-VXI INSTR, PXI MEMACC, VXI INSTR

Parameters

Name Direction Description

vi

IN

Unique logical identifier to a session.

size

IN

Specifies the size of the allocation.

offset

OUT

Returns the offset of the allocated memory. For viMemAlloc(), this is a 32-bit value for 32-bit applications and a 64-bit value for 64-bit applications. For viMemAllocEx(), this is always a 64-bit value.

Return Values

Completion Codes Description

VI_SUCCESS

Operation completed successfully.

 

Error Codes Description

VI_ERROR_INV_OBJECT

The given session reference is invalid.

VI_ERROR_NSUP_OPER

The given vi does not support this operation.

VI_ERROR_RSRC_LOCKED

Specified operation could not be performed because the resource identified by vi has been locked for this kind of access.

VI_ERROR_INV_SIZE

Invalid size specified.

VI_ERROR_ALLOC

Unable to allocatte shared memory block of the requested size.

VI_ERROR_MEM_NSHARED

The device does not export any memory.

Description

The memory region referenced by the offset returned from viMemAlloc() can be accessed with the high-level operations viMoveInXX() and viMoveOutXX(), or mapped using viMapAddress(). When using viMemAllocEx(), the offset returned may be accessed by the viMoveInXXEx() and viMoveOutXXEx() operations, and mapped using viMapAddressEx(). Note that for viMemAllocEx(), the offset could be above the 4 GB boundary. If your device cannot access this memory, you should use viMemAlloc() instead.

VXI/GPIB-VXI INSTR Specific

Notice that the offset parameter to these operations for an INSTR Resource is the offset address relative to the device's allocated address base. The viMemAlloc() and viMemAllocEx() operations return an offset into a device's memory region allocated for use by this session. If the device to which the given vi refers is on the local interface card, the memory can be allocated either on the device itself or on the computer's system memory.

PXI/PCI MEMACC Specific

For a MEMACC Resource, the offset parameter specifies an absolute address. This is a physical address in system memory and can be used for device DMA.

Related Topics

INSTR Resource

viMapAddress/viMapAddressEx

viMemFree/viMemFreeEx

viMoveIn8/viMoveIn16/viMoveIn32/viMoveIn64, viMoveIn8Ex/viMoveIn16Ex/viMoveIn32Ex/viMoveIn64Ex

viMoveOut8/viMoveOut16/viMoveOut32/viMoveOut64, viMoveOut8Ex/viMoveOut16Ex/viMoveOut32Ex/viMoveOut64Ex