DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Porting SVR5 NFB drivers to AIX 5L

Porting SVR5 NFB drivers to AIX 5L

Porting an NFB X server driver from SVR5 to the AIX 5L environment is very simple. With only a few #ifdef statements, the same code can compile on both platforms. Starting from existing source, it usually takes less than one hour to get a package-installable driver running on an AIX 5L system.


NOTE: The X Consortium code provides directives that can be used in code for different platforms:


#if defined(sco)
SCO OpenServer 5

#if defined(usl)
SVR5

#if defined(IBM_LFT)
AIX 5L
Most #ifdef usl sections of code are also valid for AIX 5L. Code that is only relevant to AIX 5L should be coded as #ifdef _IBM_LFT.

In almost all cases, code from one platform applies to the other environments. The major exception is that AIX 5L cannot handle the int10 accesses of Video BIOS and so must code adapter-specific information into the driver's C code that is handled through grafinfo files on SVR5 and SCO OpenServer 5.


To port your SVR5 NFB X server driver to AIX 5L:

  1. Add the following to your xxxInit.c file. This creates the AIX 5L specific functions nfbCreateAdapter( ) and nfbddxCloseScreen( ). These functions must be used in pairs in the xxxInit( ) and CloseScreen(D3nfb) routines. These functions handle the interface to the AIX layers that are required to initialize the kernel video adapter driver.
       #ifdef _IBM_LFT
       extern ddxScreenInfo xxxScreenInfo;
       ddxScreenInfo *
       xxxEntryFunc() {
               return (&xxxScreenInfo);
       }
       

    extern int nfbCreateAdapter( ScreenPtr pScreen, int argc, char **argv, grafData * ); extern Bool nfbddxCloseScreen(int num, ScreenPtr pScreen);

    #endif /* _IBM_LFT */

  2. Add the nfbCreateAdapter( ) call to the xxxInit( ) function:
              if (xxxGeneration != serverGeneration) {
                       xxxGeneration = serverGeneration;
                       xxxScreenPrivateIndex = AllocateScreenPrivateIndex();
                       if ( xxxScreenPrivateIndex < 0 )
                               return FALSE;
       #ifdef _IBM_LFT
                   if ( ! nfbCreateAdapter( pScreen, argc, argv, grafinfo ) ) {
                       return FALSE;
                   }
       #endif	/*	_IBM_LFT	*/
               }
    

  3. Call nfbddxCloseScreen( ) from the CloseScreen(D3nfb) function:
       void
       xxxCloseScreen(index, pScreen)
               int index;
               ScreenPtr pScreen;
       {
               xxxPrivatePtr xxxPriv = XXX_PRIVATE_DATA(pScreen);
       

    xfree(xxxPriv); #ifdef _IBM_LFT nfbddxCloseScreen(index, pScreen); #endif }

    The grafExec(D3nfb) function does not exist in AIX 5L, so you must eliminate those calls from the SetGraphics(D3nfb) and SetText(D3nfb) functions by enclosing them in #ifdndef _IBM_LFT sections. You must then provide all the code required to switch your card's mode to graphics and to text. You can access the grafinfo DATA items with the grafGetFunction(D3nfb), grafGetInt(D3nfb), grafGetString(D3nfb), and grafGetMemInfo(D3nfb) functions.
       void
       xxxSetGraphics(pScreen)
               ScreenPtr pScreen;
       {
           grafData *grafinfo = DDX_GRAFINFO(pScreen);
       

    #ifndef _IBM_LFT grafExec(grafinfo, "SetGraphics", NULL); #else /* Provide code to switch your video adapter to graphics mode */ #endif }

    void xxxSetText(pScreen) ScreenPtr pScreen; { grafData *grafinfo = DDX_GRAFINFO(pScreen);

    #ifndef _IBM_LFT grafExec(grafinfo, "SetText", NULL); #else /* Provide code to switch your video adapter to text mode */ #endif }

  4. AIX 5L provides a special mechanism for read-only access to the ROM code on the video adapter. To gain access and have the address in bios_ptr:
       #ifdef _IBM_LFT
           extern void nfbRomAccess(unsigned int *, unsigned int);
           unsigned char * bios_ptr;
       

    nfbRomAccess((unsigned int *)&bios_ptr, TRUE); #endif

    When finished, release access:

    #ifdef _IBM_LFT nfbRomAccess((unsigned int *)&bios_ptr, FALSE); bios_ptr = (unsigned char *) NULL; #endif

  5. AIX 5L does not provide inb( ) and outb( ) functions. All access to the I/O registers on the video card must be performed through the PCI bus memory-mapped I/O regions. Use the grafGetMemInfo(D3nfb) function to obtain the address of the registers: For example, the following code is used in the xxxInit( ) routine:
       	grafData *grafinfo = DDX_GRAFINFO(pScreen);
       	unsigned char *IOreg_ptr;
       	unsigned char *FrameBuffer_ptr;
       	
           	grafGetMemInfo(grafinfo, "REGS", NULL, NULL, &IOreg_ptr))
           	grafGetMemInfo(grafinfo, "APERTURE", NULL, NULL, &FrameBuffer_ptr))
    

  6. AIX 5L provides a special mechanism to read and write PCI configuration space:
       #ifdef _IBM_LFT
       	int offset;		/* offset into the PCI configuration space */
       	unsigned int size;	/* size is 1,2,3 or 4 to indicate the */
       	unsigned long data;	/* number of bytes in the data item	*/
       

    (void) nfbReadPCIConfig( offset, size, & data ); #endif

    To write a single value PCI configuration data

    #ifdef _IBM_LFT int offset; /* offset into the PCI configuration space */ unsigned int size; /* size is 1,2,3 or 4 to indicate the */ unsigned long data; /* number of bytes in the data item */

    data = <value to write>; (void) nfbWritePCIConfig( offset, size, data ); #endif


© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005