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

VxWorks

开发平台:

C/C++

  1. /* wdbEnd.c - WDB END communication initialization library */
  2. /* Copyright 1998-2002 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01e,20mar02,jhw  Remove network initialization calls. (SPR 73517)
  7. 01d,27feb02,j_s  return error if end device table is empty (SPR 73604).
  8. 01c,21nov01,jhw  Get WDB END device from sysBootParams (SPR 71595).
  9. 01b,30jul99,pul  add NPT support
  10. 01a,18may98,dbt   written based on usrWdb.c ver 02t
  11. */
  12. /*
  13. DESCRIPTION
  14. Initializes the END network connection for the WDB agent.
  15. NOMANUAL
  16. */
  17. /* includes */
  18. #include "configNet.h"
  19. /* defines */
  20. #if WDB_MTU > WDB_END_PKT_MTU
  21. #undef WDB_MTU
  22. #define WDB_MTU WDB_END_PKT_MTU
  23. #endif /* WDB_MTU > WDB_END_PKT_MTU */
  24. /* externals */
  25. IMPORT END_TBL_ENTRY endDevTbl[];
  26. /******************************************************************************
  27. *
  28. * wdbCommDevInit - initialize the END connection
  29. *
  30. * This routine initializes the END connection used by the WDB agent.
  31. *
  32. * RETURNS :
  33. * OK or ERROR if the END connection can not be initialized.
  34. *
  35. * NOMANUAL
  36. */
  37. STATUS wdbCommDevInit
  38.     (
  39.     WDB_COMM_IF * pCommIf,
  40.     char **  ppWdbInBuf,
  41.     char ** ppWdbOutBuf
  42.     )
  43.     {
  44.     static WDB_END_PKT_DEV wdbEndPktDev; /* END packet device */
  45.     END_TBL_ENTRY * pDevTbl;
  46.     END_OBJ * pEnd = NULL;
  47.     char devName[END_NAME_MAX];
  48.     static uint_t wdbInBuf [WDB_MTU/4];
  49.     static uint_t wdbOutBuf [WDB_MTU/4];
  50.     /* update input & output buffer pointers */
  51.     *ppWdbInBuf = (char *) wdbInBuf;
  52.     *ppWdbOutBuf = (char *) wdbOutBuf;
  53.     /* update communication interface mtu */
  54.     wdbCommMtu = WDB_MTU;
  55.     /* find the END Device Table entry corresponding to the boot device */
  56.     
  57.     for(pDevTbl = endDevTbl; pDevTbl->endLoadFunc != NULL; pDevTbl++)
  58.      {
  59. /* get the name of the device by passing argument devName = '' */
  60.         bzero (devName, END_NAME_MAX);
  61.         if (pDevTbl->endLoadFunc(devName, NULL) != 0)
  62.             {
  63.             if (_func_logMsg != NULL)
  64.                 _func_logMsg ("could not get device name!n", 0, 0, 0,
  65.                               0, 0, 0);
  66.             return (ERROR);
  67.             }
  68. /* compare the name of the device to the boot device selected */
  69. if (strncmp (sysBootParams.bootDev, (const char *) devName,
  70.      strlen((const char *) devName)) == 0)
  71.     {
  72.     /* Verify that the device unit number matches */
  73.     if (pDevTbl->unit == sysBootParams.unitNum)
  74. break;
  75.     }
  76. }
  77.     /* if no END Device found, default to first valid table entry */
  78.     if (pDevTbl->endLoadFunc == NULL)
  79. {
  80. if (endDevTbl->endLoadFunc == NULL)
  81.     {
  82.             if (_func_logMsg != NULL)
  83.                 _func_logMsg ("no device in END device table!n", 0, 0, 0,
  84.                               0, 0, 0);
  85.             return (ERROR);
  86.     }
  87. else
  88.          pDevTbl = endDevTbl;
  89. }
  90.     /* Check END device initialization by netLibInit */ 
  91.     if (!pDevTbl->processed)
  92.         {
  93. if (_func_logMsg != NULL)
  94.     _func_logMsg ("Network END device not initialized!n",
  95.        0,0,0,0,0,0);
  96. return (ERROR);
  97. }
  98.     /* get the END_OBJ */
  99.     pEnd = endFindByName (devName, pDevTbl->unit);
  100.         
  101.     if (pEnd == NULL)
  102.         {
  103.         if (_func_logMsg != NULL)
  104.             _func_logMsg ("Could not find device %s unit %d!n",
  105.                           sysBootParams.bootDev, sysBootParams.unitNum,
  106.   0,0,0,0);
  107.         return (ERROR);
  108.         }
  109.     
  110.     if (wdbEndPktDevInit(&wdbEndPktDev, udpRcv,
  111.                      (char *)pEnd->devObject.name,
  112.                      pEnd->devObject.unit) == ERROR)
  113. return (ERROR);
  114.     if (udpCommIfInit(pCommIf, &wdbEndPktDev.wdbDrvIf) == ERROR)
  115. return (ERROR);
  116.     return (OK);
  117.     }