usrVxFusion.c
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:5k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* usrVxFusion.c - VxFusion distributed objects initialization */
  2. /* Copyright 1999 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01d,01jun99,drm  Adding code to check for and extract the shared memory
  7.                  interface.
  8. 01c,19may99,drm  Changing vxfusion to vxfusion
  9. 01b,10mar99,drm  changing WindMP to VxFusion to reflect new product name
  10. 01a,01sep98,drm  written.
  11. */
  12. /*
  13. DESCRIPTION
  14. This file is used to initialize the VxFusion distributed object support.  
  15. This file is included by usrExtra.c which is in turn included by usrConfig.c.
  16. SEE ALSO: usrExtra.c
  17. NOMANUAL
  18. */
  19. #ifndef  __INCusrVxFusionc
  20. #define  __INCusrVxFusionc
  21. /* includes */
  22. #include "vxWorks.h"
  23. #include "vxfusion/distIfLib.h"
  24. #include "vxfusion/distLib.h"
  25. #include "drv/vxfusion/distIfUdp.h"
  26. /*******************************************************************************
  27. *
  28. * usrVxFusionInit - initialize VxFusion (distributed objects)
  29. * This function parses the boot string and then calls distInit() to initialize
  30. * VxFusion using the reference UDP adapter.  It uses the boot device name and 
  31. * unit number to determine the interface which is passed to the UDP adapter
  32. * as adapter-specific configuration data.
  33. *
  34. *
  35. * RETURNS: OK, or ERROR if unsuccessful.
  36. *
  37. * NOMANUAL
  38. */
  39. STATUS usrVxFusionInit 
  40.     (
  41.     char * bootString       /* boot parameter string */
  42.     )
  43.     {
  44.     STATUS rval;                            /* the return val from distInit() */
  45.     BOOT_PARAMS   params;                   /* boot paramters */
  46.     char ipStrAddr [INET_ADDR_LEN];         /* ip address portion of string */
  47.     u_long ipAddress;                       /* ipAddress in integer form */
  48.     char *pLoc;                             /* ptr to delimiting character */
  49.     char bootDevStr [BOOT_DEV_LEN];         /* boot device */
  50.     char interface [BOOT_DEV_LEN];          /* interface */
  51.     if (bootString == NULL)
  52.         bootString = BOOT_LINE_ADRS;
  53.     /* interpret boot command */
  54.     if (usrBootLineCrack (bootString, &params) != OK)
  55.         return (ERROR);
  56.     /* 
  57.      * Determine the booting network interface.  If the booting interface is
  58.      * a non-shared memory interface, assume it is an ethernet interface
  59.      * and use the ethernet internet address as the node id.  If the booting 
  60.      * interface is a shared memory interface, use the backplane internet
  61.      * address as the node id.  
  62.      *
  63.      * Once these values are determined, call distInit() filling in the rest
  64.      * of the parameters using the default values. 
  65.      */
  66.     strcpy (bootDevStr, params.bootDev);
  67.     if ( strncmp (bootDevStr, "sm=",3) == 0)
  68.         {
  69.         /* Shared memory */
  70.         pLoc = strchr (bootDevStr,'='); 
  71.         if (pLoc)
  72.             *pLoc = '';
  73.         sprintf (interface,"%s%d",bootDevStr, params.unitNum);
  74.         strncpy (ipStrAddr, params.bad, INET_ADDR_LEN);
  75.         ipStrAddr[INET_ADDR_LEN-1] = '';
  76.         pLoc = strchr (ipStrAddr,':'); /* Strip subnet mask */
  77.         if (pLoc)
  78.             *pLoc = '';
  79.         ipAddress = inet_network (ipStrAddr);
  80.         }
  81.     else
  82.         {
  83.         /* Not shared memory - assume an ethernet interface */
  84.         pLoc = strchr (bootDevStr,'(');
  85.         if (pLoc)
  86.             *pLoc = '';
  87.         sprintf (interface,"%s%d",bootDevStr, params.unitNum);
  88.         strncpy (ipStrAddr, params.ead, INET_ADDR_LEN);
  89.         ipStrAddr[INET_ADDR_LEN-1] = '';
  90.         pLoc = strchr (ipStrAddr,':'); /* Strip subnet mask */
  91.         if (pLoc)
  92.             *pLoc = '';
  93.         ipAddress = inet_network (ipStrAddr);
  94.         }
  95.     printf ("Initializing VxFusion with parameters: n");
  96.     printf ("  node id: 0x%lxn", ipAddress);
  97.     printf ("  interface: %sn", interface);
  98.     printf ("  max number of TBufs: %un", 1 << DIST_MAX_TBUFS_LOG2_DFLT);
  99.     printf ("  max number of nodes in node DB: %un", 
  100.             1 << DIST_MAX_NODES_LOG2_DFLT);
  101.     printf ("  max number of queues on this node: %un", 
  102.             1 << DIST_MAX_QUEUES_LOG2_DFLT);
  103.     printf ("  max number of groups in group DB: %un", 
  104.             1 << DIST_MAX_GROUPS_LOG2_DFLT);
  105.     printf ("  max number of entries in name DB: %un", 
  106.             1 << DIST_MAX_NAME_DB_ENTRIES_LOG2_DFLT);
  107.     printf ("  number of clock ticks to wait: ");
  108.     if (DIST_MAX_TICKS_TO_WAIT_DFLT < 0)
  109.        {
  110.        printf ("FOREVERn");
  111.        }
  112.     else 
  113.        { 
  114.        printf ("%dn", DIST_MAX_TICKS_TO_WAIT_DFLT); 
  115.        }
  116.     rval = distInit (ipAddress,
  117.                      distIfUdpInit,
  118.                      interface,
  119.                      DIST_MAX_TBUFS_LOG2_DFLT,
  120.                      DIST_MAX_NODES_LOG2_DFLT,
  121.                      DIST_MAX_QUEUES_LOG2_DFLT,
  122.                      DIST_MAX_GROUPS_LOG2_DFLT,
  123.                      DIST_MAX_NAME_DB_ENTRIES_LOG2_DFLT,
  124.                      DIST_MAX_TICKS_TO_WAIT_DFLT );
  125.     if (rval != OK)
  126.         {
  127.         printf ("Unable to initialize VxFusion.n");
  128.         return (ERROR);
  129.         }
  130.     printf ("VxFusion initialization successful.n");
  131.     return (OK);
  132.     }
  133. #endif /* __INCusrVxFusionc */