24.05.2014 Views

AIX Version 4.3 Differences Guide

AIX Version 4.3 Differences Guide

AIX Version 4.3 Differences Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3.2.4.2 Parameter Passing Examples<br />

For example, assume a device driver’s shipped header file has struct A, and a<br />

device driver supports an ioctl call whose arg parameter is the address of struct<br />

A:<br />

struct A {<br />

int aaa;<br />

char *bbb;<br />

char c;<br />

int *ddd;<br />

}<br />

For a 32-bit application using struct A as the arg parameter of an ioctl, the device<br />

driver can recast the arg parameter as struct A. However, if the device driver<br />

determines the caller is a 64-bit application (through a call to the IS64U kernel<br />

macro), then the device driver will have to recast struct A to a new struct A64<br />

defined as:<br />

struct A64 {<br />

int aaa;<br />

ptr64 bbb;<br />

char c;<br />

ptr64 ddd;<br />

}<br />

The code segment of the device driver for this ioctl is similar to this:<br />

.<br />

.<br />

.<br />

if (IS64U) {<br />

/* The caller is a 64-bit application */<br />

x = (struct A64 *) arg;<br />

.<br />

.<br />

.<br />

} else {<br />

/* The caller is a 32-bit application */<br />

x = (struct A *) arg;<br />

.<br />

.<br />

.<br />

}<br />

The following naming conventions are used to create the device driver’s 64-bit<br />

equivalent structure:<br />

• The 64-bit equivalent structure used by the device driver is included in the<br />

same shipped header file.<br />

• It has a comment indicating that this is used for device drivers only and not<br />

applications.<br />

• The name of the 64-bit equivalent structure is that of the original structure but<br />

with a 64 appended (for example, for sc_iocmd, it will be sc_iocmd64).<br />

For the device driver to manipulate the 64-bit addresses, new 64-bit kernel<br />

services are provided. These kernel services support 32-bit unremapped<br />

addresses as well as 32-bit remapped addresses and 64-bit addresses. Thus all<br />

50 <strong>AIX</strong> <strong>Version</strong> <strong>4.3</strong> <strong>Differences</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!