source: rtems/c/src/librdbg/src/rdbg.c @ 0da0dea

4.104.114.84.95
Last change on this file since 0da0dea was 1c2388c6, checked in by Joel Sherrill <joel.sherrill@…>, on 06/29/00 at 15:48:59

Patch from Eric Valette <valette@…> to make librdbg work
with the new RPC code.

  • Property mode set to 100644
File size: 3.0 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#include <rtems/rtems_bsdnet.h>
20#include <rpc/pmap_clnt.h>
21#include <sys/socket.h>
22#include <netinet/in.h>
23
24u_short  rtemsPort = RTEMS_PORT;
25int      BackPort = RTEMS_BACK_PORT;
26int      rtemsActive = 0;
27SVCXPRT* rtemsXprt;
28int      rtemsSock;
29char     ActName[] = "RTEMS";
30volatile int            ExitForSingleStep = 0 ;
31volatile int            Continue;
32volatile int            justSaveContext;
33volatile Objects_Id     currentTargetThread;
34volatile int            CannotRestart = 0;
35volatile int            TotalReboot = 0;
36int CONN_LIST_INC = 3;
37int PID_LIST_INC  = 1;
38int TSP_RETRIES   = 10;
39
40
41    int
42getId()
43{
44  rtems_id id;
45 
46  rtems_task_ident(RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &id);
47    return (int)(id) ;
48}
49
50    static int
51rdbgInit (void)
52{
53    int sock;
54    struct sockaddr_in addr;
55
56    sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
57    if (sock == -1) {
58        printf("%s: rkdbInit: cannot allocate socket\n", ActName);
59        return -1;
60    }
61
62    bzero( (void *)&addr, sizeof(struct sockaddr_in));
63    addr.sin_port = htons(rtemsPort);
64    if ((bind(sock, (struct sockaddr*) &addr, sizeof(addr))) == -1) {
65        printf("%s: rkdbInit: cannot bind socket\n", ActName);
66        return -2;
67    }
68    rtemsXprt = svcudp_create(sock);
69    if (svcudp_enablecache(rtemsXprt, 1) == 0) {
70        printf("%s: rkdbInit: cannot enable rpc cache\n", ActName);
71        return -3;
72    }
73    rtemsSock = sock;
74    if (!svc_register(rtemsXprt, REMOTEDEB, REMOTEVERS, remotedeb_2, 0)) {
75        printf(stderr, "unable to register (REMOTEDEB, REMOTEVERS, udp).");
76        return -4;
77    }
78
79    return 0;
80}
81
82    rtems_task
83rdbgDaemon (rtems_task_argument argument)
84{
85  svc_run();
86}
87
88    void
89rtems_rdbg_initialize (void)
90{
91  rtems_name        task_name;
92  rtems_id          tid;
93  rtems_status_code status;
94
95#ifdef DDEBUG
96        rdb_debug = 1;           /* DPRINTF now will display */
97#endif
98
99    DPRINTF (("%s init starting\n", ActName));
100
101    /* Print version string */
102#ifdef DDEBUG
103    printk ("RDBG v.%d built on [%s %s]\n", SERVER_VERS, __DATE__, __TIME__);
104#else
105    printk ("RDBG v.%d\n", SERVER_VERS);
106#endif
107
108    /* Create socket and init UDP RPC server */
109    if (rdbgInit() != 0) goto error;
110
111    Continue = 1;
112    justSaveContext = 0;
113    currentTargetThread = 0;
114   
115    task_name = rtems_build_name( 'R', 'D', 'B', 'G' );
116    if ((status = rtems_task_create( task_name, 5, 24576,
117                                     RTEMS_INTERRUPT_LEVEL(0),
118                                     RTEMS_DEFAULT_ATTRIBUTES | RTEMS_SYSTEM_TASK
119                                     , &tid ))
120        != RTEMS_SUCCESSFUL){
121      printf("status = %d\n",status);
122      rtems_panic ("Can't create task.\n");
123    }
124
125    status = rtems_task_start(tid, rdbgDaemon, 0);
126
127    return;
128
129error:
130    printf ("initialization failed.\n");
131}
132
133    void
134setErrno (int error)
135{
136    errno = error;
137}
138
139    int
140getErrno()
141{
142    return errno;
143}
Note: See TracBrowser for help on using the repository browser.