MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


Kernel Functions for Drivers           ddimodelconvertfrom(9F)



NAME
     ddimodelconvertfrom - determine data model type mismatch

SYNOPSIS
     #include 
     #include 

      uinttddimodelconvertfrom(uintt model);


INTERFACE LEVEL
     Solaris DI specific (Solaris DI).

PARAMETERS
     model     The data model type of the current thread.


DESCRIPTION
     ddimodelconvertfrom() is used to determine if the current
     thread  uses a different C Language Type Model than the dev-
     ice driver. The 64-bit version of  Solaris  will  require  a
     64-bit  kernel  to  support both 64-bit and 32-bit user mode
     programs. The difference between a 32-bit program and a  64-
     bit  program  is in its C Language Type Model: a 32-bit pro-
     gram is ILP32 (integer, longs, and pointers are 32-bit)  and
     a  64-bit  program  is LP64 (longs and pointers are 64-bit).
     There are a number of driver entry points such as  ioctl(9E)
     and  mmap(9E)  where  it  is  necessary  to  identify  the C
     Language Type Model of the user-mode originator of an kernel
     event. For example any data which flows between programs and
     the device driver or vice versa need to be identical in for-
     mat. A 64-bit device driver may need to modify the format of
     the  data  before  sending  it  to  a  32-bit   application.
     ddimodelconvertfrom()  is  used to determine if data that
     is passed between the  device  driver  and  the  application
     requires reformatting to any non-native data model.

RETURN VALUES
     DIMODELILP32     A conversion to/from ILP32 is necessary.


     DIMODELNONE      No  conversion  is  necessary.   Current
                         thread  and  driver  use  the  same data
                         model.


CONTEXT
     ddimodelconvertfrom() can be called from any context.

EXAMPLES
     Example 1 : Using ddimodelconvertfrom()  in  the  ioctl()
     entry point to support both 32-bit and 64-bit applications.



SunOS 5.11           Last change: 8 Feb 2001                    1






Kernel Functions for Drivers           ddimodelconvertfrom(9F)



     The    following    is    an    example    how    to     use
     ddimodelconvertfrom()  in the ioctl() entry point to sup-
     port both 32-bit and 64-bit applications.


       struct passargs32 {
               int len;
               caddr32t addr;
       };

       struct passargs {
               int len;
               caddrt addr;
       };
       xxioctl(devt dev, int cmd, intptrt arg, int mode,
           credt *credp, int *rvalp) {
               struct passargs pa;

               switch (ddimodelconvertfrom(mode & FMODELS)) {
                   case DIMODELILP32:
                   {
                       struct passargs32 pa32;

                       ddicopyin(arg, &pa32, sizeof (struct passargs32), mode);
                       pa.len = pa32.len;
                       pa.address = pa32.address;
                       break;
                   }
                   case DIMODELNONE:
                       ddicopyin(arg, &pa, sizeof (struct passargs), mode);
                       break;
               }

               doioctl(&pa);
               ....
       }


SEE ALSO
     ioctl(9E), mmap(9E), ddimmapgetmodel(9F)


     Writing Device Drivers












SunOS 5.11           Last change: 8 Feb 2001                    2



OpenSolaris man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™