wdbRegLib.c
上传用户:nvosite88
上传日期:2007-01-17
资源大小:4983k
文件大小:3k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* wdbRegLib.c - register manipulation library for the wdb agent */
  2. /* Copyright 1984-1994 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01c,25may95,ms minor tweek.
  7. 01b,31jan95,ms  fixed wdbRegsGet routine for system registers.
  8. 01a,29oct94,ms  written.
  9. */
  10. /*
  11. DESCPRIPTION
  12. This library contains the RPCs to get and set a contexts registers.
  13. */
  14. #include "wdb/wdb.h"
  15. #include "wdb/wdbLibP.h"
  16. #include "wdb/wdbSvcLib.h"
  17. #include "wdb/wdbRtIfLib.h"
  18. #include "string.h"
  19. /* forward declarations */
  20. static UINT32 wdbRegGet (WDB_REG_READ_DESC *pRegRead, WDB_MEM_XFER *pMemXfer);
  21. static UINT32 wdbRegSet (WDB_REG_WRITE_DESC *pRegWrite);
  22. /******************************************************************************
  23. *
  24. * wdbRegsLibInit -
  25. */
  26. void wdbRegsLibInit (void)
  27.     {
  28.     wdbSvcAdd (WDB_REGS_GET, wdbRegGet, xdr_WDB_REG_READ_DESC, xdr_WDB_MEM_XFER);
  29.     wdbSvcAdd (WDB_REGS_SET, wdbRegSet, xdr_WDB_REG_WRITE_DESC, xdr_void);
  30.     }
  31. /******************************************************************************
  32. *
  33. * wdbRegGet - get a contexts registers.
  34. */
  35. static UINT32 wdbRegGet
  36.     (
  37.     WDB_REG_READ_DESC * pRegRead,
  38.     WDB_MEM_XFER * pMemXfer
  39.     )
  40.     {
  41.     int status;
  42.     char * pRegs;
  43.     /* use wdb call to get pointer to system registers */
  44.     if (pRegRead->context.contextType == WDB_CTX_SYSTEM)
  45.         {
  46. status = wdbExternRegsGet (pRegRead->regSetType, &pRegs);
  47.         }
  48.     /* use run-time callout to get pointer to task registers */
  49.     else
  50. {
  51. if (pWdbRtIf->taskRegsGet == NULL)
  52.     return (WDB_ERR_NO_RT_PROC);
  53. status = (*pWdbRtIf->taskRegsGet) (&pRegRead->context,
  54. pRegRead->regSetType,
  55. &pRegs);
  56. }
  57.     if (status == ERROR)
  58. return (WDB_ERR_INVALID_PARAMS);
  59.     pMemXfer->numBytes = pRegRead->memRegion.numBytes;
  60.     pMemXfer->source = &pRegs[(int)pRegRead->memRegion.baseAddr];
  61.     return (OK);
  62.     }
  63. /******************************************************************************
  64. *
  65. * wdbRegSet - set a contexts registers.
  66. */
  67. static UINT32 wdbRegSet
  68.     (
  69.     WDB_REG_WRITE_DESC * pRegWrite
  70.     )
  71.     {
  72.     int         status;
  73.     char * pRegs;
  74.     /* get old regs */
  75.     if (pRegWrite->context.contextType == WDB_CTX_SYSTEM)
  76.         {
  77. status = wdbExternRegsGet (pRegWrite->regSetType, &pRegs);
  78. }
  79.     else
  80. {
  81. if ((pWdbRtIf->taskRegsSet == NULL) || (pWdbRtIf->taskRegsGet == NULL))
  82.             return (WDB_ERR_NO_RT_PROC);
  83. status = (*pWdbRtIf->taskRegsGet) (&pRegWrite->context,
  84.                                         pRegWrite->regSetType,
  85.                                         &pRegs);
  86. }
  87.     if (status == ERROR)
  88.         return (WDB_ERR_INVALID_PARAMS);
  89.     /* overwrite some of the regs */
  90.     bcopy ((caddr_t)pRegWrite->memXfer.source,
  91.    (caddr_t)&pRegs[(int)pRegWrite->memXfer.destination],
  92.    pRegWrite->memXfer.numBytes);
  93.     /* set the regs */
  94.     if (pRegWrite->context.contextType == WDB_CTX_SYSTEM)
  95. {
  96. status = wdbExternRegsSet (pRegWrite->regSetType, pRegs);
  97. }
  98.     else
  99. {
  100. status = (*pWdbRtIf->taskRegsSet) (&pRegWrite->context,
  101.                                         pRegWrite->regSetType,
  102.                                         pRegs);
  103. }
  104.     if (status == ERROR)
  105.         return (WDB_ERR_INVALID_PARAMS);
  106.     return (OK);
  107.     }