Specifications

D
evice Driver Programming
9-22
offsets in all of its dealings with the rest of the kernel. This is the new off64_t type and
with it offsets, up to approximately 1 Terabyte, can be handled by drivers.
Having two offset types implicitly requires that the kernel provide two different DDI/DKI
interfaces to drivers. On the DKI side, the kernel must know what kind of driver it is deal-
ing with so that it can pass the correctly sized offset whenever it needs to invoke one of the
driver's DKI services. On the DDI side, when the driver calls a kernel-supplied routine
which expects an offset, the driver must call the version expecting the same type of offset
as is used by the driver.
Fortunately, for almost every driver these decisions can be handled automatically. Most
drivers can be compiled either as small or as large offset drivers without any change to
their source code. And most (maybe all) of the few remaining ones can be tweaked so that
they then can be compiled either as small or large offset drivers.
A driver compiled with _LARGEFILE64_SOURCE #defined gets the large offset
interface, otherwise, it gets the small offset interface.
By default _LARGEFILE64_SOURCE is #defined when drivers are built, so to build
small offset drivers, an #undef _LARGEFILE64_SOURCE must be added to the source
of the driver, and before any include statements. This is a departure from earlier revi-
sions of PowerMAX OS, where the default driver type was the small offset version.
The _LARGEFILE64_SOURCE definition has these effects on driver compilation:
- The uio_offset field of the uio(D4) data structure changes from
off_t to off64_t.
- The uio_limit field of the uio(D4) data structure changes from
daddr_t to size64_t.
- calls that the driver makes to the DDI routines physiock(D3), uio-
move(D3), ureadc(D3), and uwritec(D3) invoke the corresponding
large offset versions, instead of the traditional small offset versions.
- calls that the kernel makes to the drivers' DKI routines read(D2) and
write(D2) will pass in a universal uio structure which is binary com-
patible with both the small and large offset uio structures. The driver,
being compiled (or not) with _LARGEFILE64_SOURCE, will either see
and update the large offset uio structure fields, or the equivalant small off-
set fields (but not both). On return, the kernel notes which of the small or
large offset fields were updated and reacts accordingly.
- the flag D_AUTO will be set to D_OFF64 if _LARGEFIL64_SOURCE is
defined, or to D_OFF32, if it is not. If desired, the driver writer can use
this flag as part of the driver's devflag(D1) definition. The use of this
flag is desirable since the kernel can test it and then directly invoke the
appropriate small or large offset interface in its dealings with that driver,
without incurring the overhead of the autodetection as discussed in the pre-
vious paragraph.
This design was selected to preserve the ability of customers to install DDI/DKI conform-
ant driver packages built against earlier releases of PowerMAX OS. Although, few drivers
which are not fully conformant may require changes, it is expected that even most of these
will operate correctly in the new driver environment of PowerMAX OS.