source: rtems/c/src/lib/librdbg/rdbg.c @ 981b99f

4.104.114.84.95
Last change on this file since 981b99f was 981b99f, checked in by Joel Sherrill <joel.sherrill@…>, on 08/10/99 at 16:41:44

Patch from Eric Valette <valette@…> and Emmanuel Raguet
<raguet@…>:

  • the dec21140 driver code has been hardened (various bug fixed) Emmanuel,
  • bug in the mcp750 init code have been fixed (interrupt stack/initial stack initialization), BSS correctly cleared (Eric V)
  • remote debugging over TCP/IP is nearly complete (berakpoints, backtrace, variables,...) (Eric V),
  • exception handling code has also been improved in order to fully support RDBG requirements (Eric V),
  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*
2 **************************************************************************
3 *
4 * Component =   
5 *
6 * Synopsis  =   rkdb/rkdb.c
7 *
8 * $Id$
9 *
10 **************************************************************************
11 */
12
13#include <assert.h>
14#include <errno.h>
15#include <rtems.h>
16#include <rtems/error.h>
17#include <rdbg/rdbg.h>
18#include <rdbg/servrpc.h>
19
20u_short  rtemsPort = RTEMS_PORT;
21int      BackPort = RTEMS_BACK_PORT;
22int      rtemsActive = 0;
23SVCXPRT* rtemsXprt;
24int      rtemsSock;
25char     ActName[] = "RTEMS";
26volatile int            ExitForSingleStep = 0 ;
27volatile int            Continue;
28volatile int            justSaveContext;
29volatile Objects_Id     currentTargetThread;
30volatile int            CannotRestart = 0;
31volatile int            TotalReboot = 0;
32int CONN_LIST_INC = 3;
33int PID_LIST_INC  = 1;
34int TSP_RETRIES   = 10;
35
36
37    int
38getId()
39{
40  rtems_id id;
41 
42  rtems_task_ident(RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &id);
43    return (int)(id) ;
44}
45
46    static int
47rdbgInit (void)
48{
49    int sock;
50    struct sockaddr_in addr;
51
52    sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
53    if (sock == -1) {
54        printf("%s: rkdbInit: cannot allocate socket\n", ActName);
55        return -1;
56    }
57
58    bzero( (void *)&addr, sizeof(struct sockaddr_in));
59    addr.sin_port = htons(rtemsPort);
60    if ((bind(sock, (struct sockaddr*) &addr, sizeof(addr))) == -1) {
61        printf("%s: rkdbInit: cannot bind socket\n", ActName);
62        return -2;
63    }
64    rtemsXprt = svcudp_create(sock);
65    if (svcudp_enablecache(rtemsXprt, 1) == 0) {
66        printf("%s: rkdbInit: cannot enable rpc cache\n", ActName);
67        return -3;
68    }
69    rtemsSock = sock;
70    return 0;
71}
72
73    rtems_task
74rdbgDaemon (rtems_task_argument argument)
75{
76  for (;;){
77
78    if (TotalReboot == 1){
79      rtemsReboot();
80    }
81
82    svc_processrequest( rtemsXprt, REMOTEDEB, REMOTEVERS, remotedeb_2);
83  }
84}
85
86    void
87rtems_rdbg_initialize (void)
88{
89  rtems_name        task_name;
90  rtems_id          tid;
91  rtems_status_code status;
92
93#ifdef DDEBUG
94        rdb_debug = 1;           /* DPRINTF now will display */
95#endif
96
97    DPRINTF (("%s init starting\n", ActName));
98
99    /* Print version string */
100#ifdef DDEBUG
101    printk ("RDBG v.%d built on [%s %s]\n", SERVER_VERS, __DATE__, __TIME__);
102#else
103    printk ("RDBG v.%d\n", SERVER_VERS);
104#endif
105
106    /* Create socket and init UDP RPC server */
107    if (rdbgInit() != 0) goto error;
108
109    Continue = 1;
110    justSaveContext = 0;
111    currentTargetThread = 0;
112   
113    task_name = rtems_build_name( 'R', 'D', 'B', 'G' );
114    if ((status = rtems_task_create( task_name, 5, 24576,
115                                     RTEMS_INTERRUPT_LEVEL(0),
116                                     RTEMS_DEFAULT_ATTRIBUTES | RTEMS_SYSTEM_TASK
117                                     , &tid ))
118        != RTEMS_SUCCESSFUL){
119      printf("status = %d\n",status);
120      rtems_panic ("Can't create task.\n");
121    }
122
123    status = rtems_task_start(tid, rdbgDaemon, 0);
124
125    return;
126
127error:
128    printf ("initialization failed.\n");
129}
130
131    void
132setErrno (int error)
133{
134    errno = error;
135}
136
137    int
138getErrno()
139{
140    return errno;
141}
Note: See TracBrowser for help on using the repository browser.