[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Kernel and Subsystems, Volume 1

get64bitparm Kernel Service

Purpose

Obtains the value of a 64-bit parameter passed by a 64-bit process when it invokes a system call provided by a 32-bit kernel extension.

Syntax

#include <sys/remap.h>

unsigned long long get64bitparm (parm, position)
unsigned long parm;
int position;

Parameters

parm Specifies the system call parameter whose 64-bit value is desired. The value of parm must be the low-order 32 bits of the system call argument used by the 64-bit caller.
position Specifies the 0-based parameter number of the desired system call parameter.

Description

In the 32-bit kernel, pointers and longs are 32-bit types. In 64-bit programs, pointers and longs are 64-bit types. When a 64-bit program invokes a system call and passes 64-bit values, there is no direct way for a kernel extension to obtain the full 64-bit value, because the kernel extension is running in 32-bit mode.

To allow 64-bit values to be passed to a system call, the system call handler saves the high-order word of the 8 parameter registers. Then parameters are truncated to 32-bit values before the system call function is invoked. The full 64-bit value can be retrieved by calling get64bitparm(), passing the original 32-bit parameter and the 0-based parameter number as arguments.

Return Values

The full 64-bit argument value is returned as a long long. If called from a 32-bit process, the returned value is unpredictable. If position is less than 0 or greater than 7, the panic kernel service is called.

Examples

  1. Suppose a subroutine takes 2 parameters, a number and a pointer. The subroutine could be written as follows:
    #include <sys/remap.h>
    my_syscall(int count, void *user_data)
    {
    	__ptr64 user_ptr;
    
    	if (IS64U)
    		user_ptr = (__ptr64)get64bitparm((unsigned long)user_data, 1);
    	else
    		user_ptr = (__ptr64)user_data;
    	...
    }
    

    When my_syscall is called from a 64-bit process, user_data will have been truncated to 32 bits, if the caller is a 64-bit process. The get64bitparm kernel service allows the full 64-bit value to be obtained. When my_syscall is called from a 32-bit process, the user_data pointer can be used directly. The count parameter can be used directly whether the current process is 32-bit or 64-bit, since the size of an int is the same in both 32-bit mode and 64-bit mode.

    The get64bitparm kernel service is not needed when the 64-bit kernel is running, because a pointer parameter is already a 64-bit value. To allow for common code, the get64bitparm kernel service is defined as a macro that returns its first argument, when a kernel extension is compiled in 64-bit mode.

Execution Environment

This kernel service can only be called from the process environment when the current process is in 64-bit mode.

Implementation Specifics

The get64bitparm kernel service is only available on the 32-bit PowerPC kernel.

Related Information

The saveretval64 kernel service, as_remap64 kernel service.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]