as_lw_att64 Kernel Service

Purpose

Allocates and maps a specified region in the current user address space. Part of the lightweight kernel service subsystem, which must be initialized with the as_lw_pool_init kernel service before it can be used.

Syntax

#include <sys/types.h>
#include <sys/errno.h>
#include <sysvmuser.h>
#include <sys/adspace.h>
#include <sys/mem.h>

int as_lw_att64 (dp, offset, length, addr)
xmem* dp;
size_t offset;
size_t length;
ptr64* addr;

Parameters

Item Description
dp Pointer to a cross memory descriptor that describes the virtual memory object that is being made addressable in the address space.
offset Specifies the byte offset in the virtual memory object.
length Specifies the number of bytes to map in the virtual memory object.
addr Pointer to the location where the address will be returned.

Description

The as_lw_att64 kernel service does the following:
  • Allocates a region from the process' address space for the mapping.
  • Maps the virtual memory object selected by the dp parameter.
  • Constructs the address of the offset specified by the offset parameter within the user-address space.
Note: The as_lw_att64 kernel service should be used with caution. Be sure to read the documentation for this and the other lightweight services (as_lw_det64 and as_lw_pool_init) carefully before doing so. There is a risk of illegal data access and cross-process data corruption if these services are not used correctly.

In order to use this service, the cross memory descriptor pointed to by the dp parameter must be initialized by using the xmattach kernel service with the LW_XMATTACH flag set. The lw_pool_init kernel service must also have been successfully called by the current process.

The service will map an area length bytes long into the caller's address space from the memory represented by the descriptor, starting at the number of bytes specified in the offset parameter. It is illegal for any thread other than the caller of this service to address the attached region.

This service will operate correctly only in 64-bit user address spaces. It will not work for kernel processes (kprocs).

Note: This service only operates on the current process's address space. It is not allowed to operate on another address space.

Execution Environment

The as_lw_att64 kernel service can be called from the process environment only.

Return Values

On successful completion, this service sets the value of addr to the address of the allocated region and returns 0.

Item Description
NULL An error occurred and errno indicates the cause.
EINVAL Cross memory descriptor is in an invalid state, length is zero or offset plus length goes past the end of the virtual memory object.
ENODEV The as_lw_pool_init kernel service has not been called to initialize the pool settings for this process.
ENOSYS Called by a 32-bit process.
ENOSPC Resources allocated to do lightweight services for this thread expended. Either the region to be attached is too large (the as_lw_pool_init kernel service was called with too small a pool_size) or there are outstanding attaches which need to release their lightweight resources using the as_lw_det64 kernel service before this attach can be completed.
EIO Indicates a failure of the lightweight subsystem, process should discontinue use of lightweight kernel services.
EPERM Called by a user thread that is not 1:1 with a kernel thread.
ENOMEM Could not allocate system resources for lightweight services for this thread.

Implementation Specifics

The as_lw_att64 kernel service is part of Base Operating System (BOS) Runtime.