jtagsock.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define dJTAGSOCK_MAXHOSTNAME   40
#define dJTAGSOCK_NUM_CONNECTIONS   1

Functions

int fJTAGSOCK_Establish (unsigned short us_portnum)
int fJTAGSOCK_GetConnection (int i_socket)
int fJTAGSOCK_ReadByte (int i_socket, char *pc_byte)
int fJTAGSOCK_WriteByte (int i_socket, char c_byte)


Define Documentation

#define dJTAGSOCK_MAXHOSTNAME   40

Definition at line 53 of file jtagsock.h.

Referenced by fJTAGSOCK_Establish().

#define dJTAGSOCK_NUM_CONNECTIONS   1

Definition at line 52 of file jtagsock.h.

Referenced by fJTAGSOCK_Establish().


Function Documentation

int fJTAGSOCK_Establish ( unsigned short  us_portnum  ) 

Definition at line 60 of file jtagsock.c.

References dJTAGSOCK_MAXHOSTNAME, and dJTAGSOCK_NUM_CONNECTIONS.

Referenced by cmd_gdbserver().

00061 { 
00062   char                c_myname[dJTAGSOCK_MAXHOSTNAME+1];
00063   int                 i_socket;
00064   struct sockaddr_in  st_sa;
00065   struct hostent     *st_hp;
00066 
00067   // Clear the address structure
00068   memset(&st_sa, 0, sizeof(struct sockaddr_in));
00069 
00070   // Get our own machine name
00071   gethostname(c_myname, dJTAGSOCK_MAXHOSTNAME);
00072 
00073   // Retrieve our address information
00074   st_hp=gethostbyname(c_myname);
00075   if (st_hp == NULL) return(-1);        // Error condition
00076 
00077   st_sa.sin_family = st_hp->h_addrtype;    // Our host address
00078   st_sa.sin_port   = htons(us_portnum); // Our port number
00079 
00080   // Create the socket
00081   i_socket = socket(AF_INET, SOCK_STREAM, 0);
00082   if (i_socket < 0) return(-1);         // Failed to create socket
00083 
00084   // Bind to the socket to our port
00085   if (bind(i_socket, (struct sockaddr *)&st_sa, sizeof(struct sockaddr_in)) < 0) 
00086   {
00087     // Failed to bind
00088     close(i_socket);
00089     return(-1);
00090   }
00091 
00092   // Set listen for maximum number of connections to queue
00093   listen(i_socket, dJTAGSOCK_NUM_CONNECTIONS);
00094   return(i_socket);
00095 }

int fJTAGSOCK_GetConnection ( int  i_socket  ) 

Definition at line 102 of file jtagsock.c.

References config_gdbserver_quitgdb, and do_cmd().

Referenced by cmd_gdbserver().

00103 { 
00104   int i_newsocket; // Handle for new socket
00105 
00106   // Attempt to accept a connection
00107   do{
00108      int n;
00109      char buf[100];
00110   i_newsocket = accept(i_socket,NULL,NULL);
00111         ioctl(0,FIONREAD,&n);
00112         if(n)
00113         {
00114         read(0,buf,n);
00115         buf[n] = 0;
00116         do_cmd(buf);
00117         if(config_gdbserver_quitgdb)return -1;
00118         }
00119   }
00120   while(i_newsocket == -1);
00121 
00122   if (i_newsocket < 0) return(-1); // Failed to accept
00123 
00124   return(i_newsocket);
00125 }

Here is the call graph for this function:

int fJTAGSOCK_ReadByte ( int  i_socket,
char *  pc_byte 
)

Definition at line 132 of file jtagsock.c.

Referenced by fGDBRDP_Handler().

00133 { 
00134   return(read(i_socket, pc_byte, 0x01));
00135 }

int fJTAGSOCK_WriteByte ( int  i_socket,
char  c_byte 
)

Definition at line 142 of file jtagsock.c.

Referenced by fGDBRDP_InputHandler(), and fGDBRDP_SendToGDB().

00143 {
00144         #if 1
00145   while(write(i_socket, &c_byte, 0x01) != 0x01);
00146         #else
00147         volatile int test=0;
00148         printf("haha-1\n");
00149         test = write(i_socket, &c_byte, 0x01);
00150         printf("haha-2 : test : %d\n",test);
00151         while(test != 0x01)
00152         {
00153                 printf("haha-3\n");     
00154                 test = write(i_socket, &c_byte, 0x01); 
00155                 printf("haha-4 test : %d\n",test);      
00156         }
00157 #endif
00158   return(1);
00159 }


Generated on Fri Nov 5 07:24:47 2010 for ejtag debug tools for loongson 232 cpu by  doxygen 1.5.6