Please post any updates, additions, or questions on the developer forums at
http://forum.sun.com
12. 64-bit Questions
12.1 What is different about
the 64-bit environment?
12.2 When should I begin developing
my 64-bit Solaris driver?
12.3 What documentation is available?
12.4 Which machines will run
the 64-bit kernel?
12.5 How do I boot the 64-bit
kernel?
12.6 Why won't the 64-bit Solaris
boot program boot my 2.6 kernel?
12.7 What kernel debugging support
is available?
12.8 Which compiler do I use
to build 64-bit applications?
12.9 Do I need to convert all
my drivers to 64-bits?
12.10 Can I build 64-bit drivers on a 32-bit
kernel?
12.11 Why do I get "/kernel/drv/sparcv9/mumble:
undefined symbol" when I try to load my 64-bit driver?
12.12 How can I tell which OS is running?
12.13 Where does the 64-bit stuff get installed?
12.14 Booting
12.15 Linting
12.16 Which option should I provide the compiler to generate 64-bit code? What is the difference between -xarch=v9, -xarch=v9a, and -xarch=v9b?
12.17 How do I convert from a 32-bit to 64-bit driver?
12.18 My 64-bit driver will load but won't attach on the Solaris 2.8 OS.
The same driver will load and attach under the Solaris 2.7 OS.
Questions and Answers
12.1 What is different about the 64-bit environment?
The long and pointer data types grow to 64-bits. This
is called the LP64 data model. The int type remains 32 bits
wide. Several derived types (time_t, dev_t, ..) change
size also.
12.2 When should I begin developing my
64-bit Solaris driver?
You should start right away. This developer site contains all the information
you need to develop a 64-bit driver.
12.3 What documentation is available?
- Notes
on 64-bit Drivers and STREAMS
This white paper provides information for both device driver writers and
STREAMS driver and modules writers regarding the 64-bit Solaris kernel.
- Writing Device Drivers: Making
a Device Driver 64-bit Ready
12.4 Which machines will run the 64-bit kernel?
Only the UltraSPARC (sun4u) machines.
12.5 How do I boot the 64-bit kernel?
boot kernel/sparcv9/unix.
12.6 Why won't the 64-bit Solaris boot program
boot my 2.6 kernel?
Changes made to bootops resulted in an incompatibility. 64-bit
Solaris systems require a 64-bit boot program. Sun software does
not support mismatched boot and kernels.
12.7 What kernel debugging support is
available?
If you need to do kernel debugging,
forthdebug
[PDF] and kadb are both available. You will need to
flash
your PROM to use these debugging tools.
At this time. an OpenBoot PROM flash upgrade is not required to
run 64-bit Solaris unless you need to do kernel debugging. However, this
situation may change when 64-Solaris is FCSed because bugs in the firmware
(versions less than desktop 3.11 and Enterprise Server versions less than
3.2.12) are difficult to workaround, and prevent important scalability
features from being implemented in 64-bit Solaris.
Back to Top
12.8 Which compiler do I use to build
64-bit applications?
Sun WorkShop 5.0 was the first compiler from Sun to generate 64-bit code.
The latest WorkShop compiler is now part of the Sun Studio line of developer tools.
12.9 Do I need to convert all my drivers
to 64-bits?
YES, if you want the driver to support 64-bit Solaris. 64-bit Solaris
requires 64-bit drivers.
12.10 Can I build 64-bit drivers on a
32-bit kernel?
Yes. The easiest way is to do it on the 32-bit version of the 64-bit
Solaris release. (as opposed to 2.6 or an earlier release). The 64-bit
capable compiler as well as the dynamic linker are still 32-bit programs,
they can generate either 32- or 64-bit objects.
12.11 Why do I get "/kernel/drv/sparcv9/mumble:
undefined symbol" when I try to load my 64-bit driver?
This problem was introduced in Solaris 7 and has been fixed in Solaris 8.
12.12 How can I tell which OS is running?
Use the isalist command to determine whether the machine is
running the 32-bit or 64-bit operating system. If you are running the 64-bit
operating system on an UltraSPARC machine, then isalist will list
sparcv9 first:
% isalist
sparcv9+vis sparcv9
sparcv8plus+vis sparcv8plus sparcv8 sparcv8-fsmuld
sparcv7 sparc
If you are running the 32-bit operating system on a SPARC machine,
then
isalist
will list sparcv7 or sparcv8 first:
% isalist
sparcv8plus+vis sparcv8plus
sparcv8 sparcv8-fsmuld sparcv7 sparc
12.13 Where does the 64-bit stuff get
installed?
In general, the 64-bit SPARC versions of everything get installed in
the sparcv9 subdirectory of the location where the 32-bit version
is installed on Solaris 2.6. Here are some examples:
| 32-bit Version |
64-bit Version |
| /bin/cat |
|
| /usr/bin/sparcv7/adb |
/usr/bin/sparcv9/adb |
| /usr/lib/libc.so.1 |
/usr/lib/sparcv9/libc.so.1 |
| /platform/sun4u/kernel/unix |
/platform/sun4u/kernel/sparcv9/unix |
| /platform/sun4u/kernel/drv/glm |
/platform/sun4u/kernel/drv/sparcv9/glm |
|
Back to Top
12. 14 Booting
To boot a 32-bit kernel, at the ok prompt type:
ok boot [disk or net] kernel/unix
To boot a 64-bit kernel (default), at the ok prompt
type:
ok boot [disk or net] kernel/sparcv9/unix
ok boot [disk or net]
12.15 Linting
The SC4.2 (or later) version of lint can be used to help find
potential 64-bit problems in your code. You can use the special "-errchk=longptr64"
option to request that lint to notify you anytime that you
try to put something big into something small, such as casting a
64-bit pointer into a 32-bit int.
This version of lint prints the line number of the offending
code, issues a warning message that describes the problem, and informs
you that a pointer was involved or gives the sizes of types involved. The
fact that a pointer is involved and the size of the types can be useful
in finding only the 64-bit problems and avoiding the pre-existing problems
between 32-bit and smaller types.
The warnings to look out for are of the form:
warning: conversion of pointer loses bits
warning: cast to pointer from -bit integer
warning: cast from -bit integer to -bit integer
warning: cast from -bit constant expression to -bit integer *
warning: assignment of -bit integer to -bit integer
warning: bigger-bit constant truncated to smaller bits by assignment
warning: passing bigger-bit integer arg, expecting smaller-bit integer:
routine name(arg (argument number))
warning: passing bigger-bit integer constant arg, expecting smaller-bit
integer: routine name(arg (argument number))
function argument ( number ) type inconsistent with format *printf
(arg (arg #)) type :: (format) type file(line)
function argument ( number ) type inconsistent with format *scanf (arg
(arg #)) type :: (format) type file(line)
12.16 Which option should I provide the compiler to generate 64-bit code?
What is the difference between -xarch=v9, -xarch=v9a, and -xarch=v9b?
Using the Forte (WorkShop) C compiler, you specify the instruction set architecture (ISA) using -xarch.
-
-xarch=v9 will generate 64-bit code.
-
-xarch=v9a adds the Visual Instruction
Set (VIS) and extensions specific to UltraSPARC processors to the SPARC-V9 ISA, and enables the compiler to
generate code for good performance on the V9 SPARC architecture.
-
-xarch=v9b adds UltraSPARC-III extensions and VIS
version 2.0 to the V9a version of the SPARC-V9 ISA. Compiling with this
option uses the best instruction set for good performance in a Solaris
UltraSPARC-III environment.
Consult the Forte (WorkShop) documentation for detailed information.
Warning: Code compiled with -xarch=v9b
will generate instructions unique to the UltraSPARC-III platform and thus
cause errors on the UltraSPARCII platform. The recommended option for generation
of a 64-bit driver is -xarch=v9.
Back to Top
12.17 How do I convert from a 32-bit to 64-bit driver?
This answer serves as a guide to help you start converting drivers
for 64-bit DDI functions.
Make the code 64-bit clean by running through lint with the
-errchk=longptr64 option.
Lint flags potential LP64 problems with the driver code.
Use uintptr_t as an integral type of pointer rather than using a
fundamental type like unsigned long.
Change the code that assumes that ints and pointers are same size.
For example:
{
char *p;
extern void test(int p);
-
-
test(p);
}
should be changed to:
extern void test( char *p)
Change all DDI common access function calls as follows:
ddi_getb() replaced by ddi_get8()
ddi_getw() replaced by ddi_get16()
ddi_getl() replaced by ddi_get32()
ddi_getll() replaced by ddi_get64()
ddi_putb() replaced by ddi_put8()
ddi_putw() replaced by ddi_put16()
ddi_putl() replaced by ddi_put32()
ddi_putll() replaced by ddi_put64()
Fix ioctl(), mmap(), and devmap() driver
entry points.
Driver entry points that accept the pointer arguments from user
applications must be changed to determine whether the argument came from a
user application using the same memory model as the kernel. If memory
models differ, adjust the 32-bit user application argument to fit into the
64-bit driver structure. The new DDI function ddi_model_convert_from()
helps make this conversion. ddi_model_convert_from() returns
DDI_MODEL_RETURN_ILP32 (convert from ILP32 application to ILP64 Kernel) or
DDI_MODEL_NODE (no conversion needed, ILP32 to ILP32 or LP64 to LP64). The macro
_MULTI_DATAMODEL can be used as shown in the following example of ioctl()
entry point to support both 32-bit and 64-bit applications:
struct passargs32 {
int len;
caddr32_t addr;
};
struct passargs {
int len;
caddr_t addr;
};
xxioctl(dev_t dev, int cmd, intptr_t arg, int mode,
cred_t *credp, int *rvalp) {
struct passargs pa;
#ifdef _MULTI_DATAMODEL
switch (ddi_model_convert_from(mode & FMODELS)) {
case DDI_MODEL_ILP32:
{
struct passargs32 pa32;
ddi_copyin(arg, &pa32, sizeof (struct passargs32),mode);
pa.len = pa32.len;
pa.address = pa32.address;
break;
}
case DDI_MODEL_NONE:
ddi_copyin(arg, &pa, sizeof (struct passargs), mode);
break;
}
#else /* _MULTI_DATAMODEL */
ddi_copyin(arg, &pa, sizeof (struct passargs), mode);
#endif /* _MULTI_DATAMODEL */
do_ioctl(&pa);
....
}
12.18 My 64-bit driver will load but won't attach on the Solaris 2.8 OS.
The same driver will load and attach under the Solaris 2.7 OS.
64-bit drivers must be installed in the sparcv9 hierarchy on
Solaris 2.8 and 2.9. On Solaris 2.7, although unsupported, 64-bit drivers
did load and attach, even when not installed in the sparcv9
hierarchy.
Back to Top
|