static XtransConnInfo TRANS(TLIOpenCLTSServer)(Xtransport *thistrans, char *protocol, char *host, char *port) { XtransConnInfo ciptr; int i; prmsg(2,"TLIOpenCLTSServer(%s,%s,%s)\n", protocol, host, port ); if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 ) { prmsg(1, "TLIOpenCLTSServer: Unable to determine device for %s\n", thistrans->TransName); return NULL; } if( (ciptr=TRANS(TLIOpen)(TLItrans2devtab[i].devcltsname)) == NULL ) { prmsg(1, "TLIOpenCLTSServer: Unable to open device for %s\n", thistrans->TransName); return NULL; } return ciptr; }
int ath_mem_config(void) { unsigned int type, reg32, *tap; extern uint32_t *ath_ddr_tap_cal(void); #if !defined(CONFIG_ATH_EMULATION) type = ath_ddr_initial_config(CFG_DDR_REFRESH_VAL); tap = ath_ddr_tap_cal(); prmsg("tap = 0x%p\n", tap); tap = (uint32_t *)0xbd007f10; prmsg("Tap (low, high) = (0x%x, 0x%x)\n", tap[0], tap[1]); tap = (uint32_t *)TAP_CONTROL_0_ADDRESS; prmsg("Tap values = (0x%x, 0x%x, 0x%x, 0x%x)\n", tap[0], tap[2], tap[2], tap[3]); /* Take WMAC out of reset */ reg32 = ath_reg_rd(RST_RESET_ADDRESS); reg32 = reg32 & ~RST_RESET_RTC_RESET_SET(1); ath_reg_wr_nf(RST_RESET_ADDRESS, reg32); ath_usb1_initial_config(); ath_usb2_initial_config(); ath_gpio_config(); #endif /* !defined(CONFIG_ATH_EMULATION) */ return ath_ddr_find_size(); }
static XtransConnInfo TRANS(TLIReopenCLTSServer)(Xtransport *thistrans, int fd, char *port) { XtransConnInfo ciptr; int i; prmsg(2,"TLIReopenCLTSServer(%d, %s)\n", fd, port); if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 ) { prmsg(1, "TLIReopenCLTSServer: Unable to determine device for %s\n", thistrans->TransName); return NULL; } if( (ciptr=TRANS(TLIReopen)( TLItrans2devtab[i].devcltsname, fd, port)) == NULL ) { prmsg(1, "TLIReopenCLTSServer: Unable to open device for %s\n", thistrans->TransName); return NULL; } ciptr->index = i; return ciptr; }
static XtransConnInfo TRANS(TLIReopenCOTSServer)(Xtransport *thistrans, int fd, char *port) { XtransConnInfo ciptr; int i; prmsg(2,"TLIReopenCOTSServer(%d, %s)\n", fd, port); if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 ) { prmsg(1, "TLIReopenCOTSServer: Unable to determine device for %s\n", thistrans->TransName); return NULL; } if( (ciptr=TRANS(TLIReopen)( TLItrans2devtab[i].devcotsname, fd, port)) == NULL ) { prmsg(1, "TLIReopenCOTSServer: Unable to open device for %s\n", thistrans->TransName); return NULL; } /* Save the TLIFamily for later use in TLIAddrToNetbuf() lookups */ ciptr->index = i; return ciptr; }
int TRANS(Received) (const char * protocol) { Xtransport *trans; int i = 0, ret = 0; prmsg (5, "Received(%s)\n", protocol); if ((trans = TRANS(SelectTransport)(protocol)) == NULL) { prmsg (1,"Received: unable to find transport: %s\n", protocol); return -1; } if (trans->flags & TRANS_ALIAS) { if (trans->nolisten) while (trans->nolisten[i]) { ret |= TRANS(Received)(trans->nolisten[i]); i++; } } trans->flags |= TRANS_RECEIVED; return ret; }
static int TRANS(TLIINETCreateListener)(XtransConnInfo ciptr, char *port, unsigned int flags) { char portbuf[PORTBUFSIZE]; struct t_bind *req; struct sockaddr_in *sinaddr; long tmpport; prmsg(2,"TLIINETCreateListener(%x->%d,%s)\n", ciptr, ciptr->fd, port ? port : "NULL" ); #ifdef X11_t /* * X has a well known port, that is transport dependent. It is easier * to handle it here, than try and come up with a transport independent * representation that can be passed in and resolved the usual way. * * The port that is passed here is really a string containing the idisplay * from ConnectDisplay(). */ if (is_numeric (port)) { tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10); sprintf(portbuf,"%u", tmpport); port = portbuf; } #endif if( (req=(struct t_bind *)t_alloc(ciptr->fd,T_BIND,T_ALL)) == NULL ) { prmsg(1, "TLIINETCreateListener: failed to allocate a t_bind\n"); return TRANS_CREATE_LISTENER_FAILED; } if( port && *port ) { if(TRANS(TLIAddrToNetbuf)(ciptr->index,HOST_SELF,port,&(req->addr)) < 0) { prmsg(1, "TLIINETCreateListener: can't resolve name:HOST_SELF.%s\n", port); t_free((char *)req,T_BIND); return TRANS_CREATE_LISTENER_FAILED; } } else { sinaddr=(struct sockaddr_in *) req->addr.buf; sinaddr->sin_family=AF_INET; sinaddr->sin_port=htons(0); sinaddr->sin_addr.s_addr=0; } /* Set the qlen */ req->qlen=1; return TRANS(TLICreateListener)(ciptr, req); }
static int TRANS(TLICreateListener)(XtransConnInfo ciptr, struct t_bind *req) { struct t_bind *ret; prmsg(2,"TLICreateListener(%x->%d,%x)\n", ciptr, ciptr->fd, req ); if( (ret=(struct t_bind *)t_alloc(ciptr->fd,T_BIND,T_ALL)) == NULL ) { prmsg(1, "TLICreateListener: failed to allocate a t_bind\n"); t_free((char *)req,T_BIND); return TRANS_CREATE_LISTENER_FAILED; } if( t_bind(ciptr->fd, req, ret) < 0 ) { prmsg(1, "TLICreateListener: t_bind failed\n"); t_free((char *)req,T_BIND); t_free((char *)ret,T_BIND); return TRANS_CREATE_LISTENER_FAILED; } if( memcmp(req->addr.buf,ret->addr.buf,req->addr.len) != 0 ) { prmsg(1, "TLICreateListener: unable to bind to %x\n", req); t_free((char *)req,T_BIND); t_free((char *)ret,T_BIND); return TRANS_ADDR_IN_USE; } /* * Everything looks good: fill in the XtransConnInfo structure. */ if( (ciptr->addr = malloc(ret->addr.len)) == NULL ) { prmsg(1, "TLICreateListener: Unable to allocate space for the address\n"); t_free((char *)req,T_BIND); t_free((char *)ret, T_BIND); return TRANS_CREATE_LISTENER_FAILED; } ciptr->addrlen=ret->addr.len; memcpy(ciptr->addr,ret->addr.buf,ret->addr.len); t_free((char *)req,T_BIND); t_free((char *)ret, T_BIND); return 0; }
static int TRANS(TLITLICreateListener)(XtransConnInfo ciptr, char *port, unsigned int flags) { struct t_bind *req; struct sockaddr_un *sunaddr; int ret_value; prmsg(2,"TLITLICreateListener(%x->%d,%s)\n", ciptr, ciptr->fd, port ? port : "NULL"); if( (req=(struct t_bind *)t_alloc(ciptr->fd,T_BIND,0)) == NULL ) { prmsg(1, "TLITLICreateListener: failed to allocate a t_bind\n"); return TRANS_CREATE_LISTENER_FAILED; } if( (sunaddr=(struct sockaddr_un *) malloc(sizeof(struct sockaddr_un))) == NULL ) { prmsg(1, "TLITLICreateListener: failed to allocate a sockaddr_un\n"); t_free((char *)req,T_BIND); return TRANS_CREATE_LISTENER_FAILED; } sunaddr->sun_family=AF_UNIX; if( port && *port ) { if( *port == '/' ) { /* A full pathname */ (void) strcpy(sunaddr->sun_path, port); } else { (void) sprintf(sunaddr->sun_path,"%s%s", TLINODENAME, port ); } } else { (void) sprintf(sunaddr->sun_path,"%s%d", TLINODENAME, getpid()); } req->addr.buf=(char *)sunaddr; req->addr.len=sizeof(*sunaddr); req->addr.maxlen=sizeof(*sunaddr); /* Set the qlen */ req->qlen=1; ret_value = TRANS(TLICreateListener)(ciptr, req); free((char *) sunaddr); return ret_value; }
static int TRANS(TLIAddrToNetbuf)(int tlifamily, char *host, char *port, struct netbuf *netbufp) { struct netconfig *netconfigp; struct nd_hostserv nd_hostserv; struct nd_addrlist *nd_addrlistp = NULL; void *handlep; long lport; prmsg(3,"TLIAddrToNetbuf(%d,%s,%s)\n", tlifamily, host, port ); if( (handlep=setnetconfig()) == NULL ) return -1; lport = strtol (port, (char**)NULL, 10); if (lport < 1024 || lport > USHRT_MAX) return -1; nd_hostserv.h_host = host; if( port && *port ) { nd_hostserv.h_serv = port; } else { nd_hostserv.h_serv = NULL; } while( (netconfigp=getnetconfig(handlep)) != NULL ) { if( strcmp(netconfigp->nc_protofmly, TLItrans2devtab[tlifamily].protofamily) != 0 ) continue; prmsg(5,"TLIAddrToNetbuf: Trying to resolve %s.%s for %s\n", host, port, TLItrans2devtab[tlifamily].protofamily ); if( netdir_getbyname(netconfigp,&nd_hostserv, &nd_addrlistp) == 0 ) { /* we have at least one address to use */ prmsg(5, "TLIAddrToNetbuf: found address for %s.%s\n", host, port); prmsg(5, "TLIAddrToNetbuf: %s\n",taddr2uaddr(netconfigp,nd_addrlistp->n_addrs)); memcpy(netbufp->buf,nd_addrlistp->n_addrs->buf, nd_addrlistp->n_addrs->len); netbufp->len=nd_addrlistp->n_addrs->len; endnetconfig(handlep); return 0; } } endnetconfig(handlep); return -1; }
static XtransConnInfo TRANS(TLIOpenCOTSClient)(Xtransport *thistrans, char *protocol, char *host, char *port) { XtransConnInfo ciptr; int i; prmsg(2,"TLIOpenCOTSClient(%s,%s,%s)\n", protocol, host, port ); if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 ) { prmsg(1,"TLIOpenCOTSClient: Unable to determine device for %s\n", thistrans->TransName); return NULL; } if( (ciptr=TRANS(TLIOpen)(TLItrans2devtab[i].devcotsname)) == NULL ) { prmsg(1,"TLIOpenCOTSClient: Unable to open device for %s\n", thistrans->TransName); return NULL; } if( TRANS(TLITLIBindLocal)(ciptr->fd,TLItrans2devtab[i].family,port) < 0 ) { prmsg(1, "TLIOpenCOTSClient: ...TLITLIBindLocal() failed: %d\n", errno); t_close(ciptr->fd); free(ciptr); return NULL; } if( TRANS(TLIGetAddr)(ciptr) < 0 ) { prmsg(1, "TLIOpenCOTSClient: ...TLIGetAddr() failed: %d\n", errno); t_close(ciptr->fd); free(ciptr); return NULL; } /* Save the TLIFamily for later use in TLIAddrToNetbuf() lookups */ ciptr->index = i; return ciptr; }
static Xtransport * TRANS(SelectTransport) (const char *protocol) { char protobuf[PROTOBUFSIZE]; int i; prmsg (3,"SelectTransport(%s)\n", protocol); /* * Force Protocol to be lowercase as a way of doing * a case insensitive match. */ strncpy (protobuf, protocol, PROTOBUFSIZE - 1); protobuf[PROTOBUFSIZE-1] = '\0'; for (i = 0; i < PROTOBUFSIZE && protobuf[i] != '\0'; i++) if (isupper ((unsigned char)protobuf[i])) protobuf[i] = tolower ((unsigned char)protobuf[i]); /* Look at all of the configured protocols */ for (i = 0; i < NUMTRANS; i++) { if (!strcmp (protobuf, Xtransports[i].transport->TransName)) return Xtransports[i].transport; } return NULL; }
int TRANS(NoListen) (const char * protocol) { Xtransport *trans; int i = 0, ret = 0; if ((trans = TRANS(SelectTransport)(protocol)) == NULL) { prmsg (1,"TransNoListen: unable to find transport: %s\n", protocol); return -1; } if (trans->flags & TRANS_ALIAS) { if (trans->nolisten) while (trans->nolisten[i]) { ret |= TRANS(NoListen)(trans->nolisten[i]); i++; } } trans->flags |= TRANS_NOLISTEN; return ret; }
XtransConnInfo TRANS(ReopenCLTSServer) (int trans_id, int fd, const char *port) { prmsg (2,"ReopenCLTSServer(%d, %d, %s)\n", trans_id, fd, port); return TRANS(Reopen) (XTRANS_OPEN_CLTS_SERVER, trans_id, fd, port); }
XtransConnInfo TRANS(OpenCLTSServer) (const char *address) { prmsg (2,"OpenCLTSServer(%s)\n", address); return TRANS(Open) (XTRANS_OPEN_CLTS_SERVER, address); }
XtransConnInfo TRANS(OpenCLTSClient) (const char *address) { prmsg (2,"OpenCLTSClient(%s)\n", address); return TRANS(Open) (XTRANS_OPEN_CLTS_CLIENT, address); }
static int TRANS(TLIWritev)(XtransConnInfo ciptr, struct iovec *buf, int size) { prmsg(2, "TLIWritev(%d,%x,%d)\n", ciptr->fd, buf, size ); return WRITEV(ciptr,buf,size); }
static int TRANS(TLIWrite)(XtransConnInfo ciptr, char *buf, int size) { prmsg(2, "TLIWrite(%d,%x,%d)\n", ciptr->fd, buf, size ); return write(ciptr->fd,buf,size); }
static int TRANS(TLIRead)(XtransConnInfo ciptr, char *buf, int size) { prmsg(2, "TLIRead(%d,%x,%d)\n", ciptr->fd, buf, size ); return read(ciptr->fd,buf,size); }
static int TRANS(TLISetOption)(XtransConnInfo ciptr, int option, int arg) { prmsg(2,"TLISetOption(%d,%d,%d)\n", ciptr->fd, option, arg ); return -1; }
static int TRANS(TLIReadv)(XtransConnInfo ciptr, struct iovec *buf, int size) { prmsg(2, "TLIReadv(%d,%x,%d)\n", ciptr->fd, buf, size ); return READV(ciptr,buf,size); }
static int TRANS(TLIConnect)(XtransConnInfo ciptr, struct t_call *sndcall ) { prmsg(2, "TLIConnect(%x->%d,%x)\n", ciptr, ciptr->fd, sndcall); if( t_connect(ciptr->fd,sndcall,NULL) < 0 ) { extern char *t_errlist[]; extern int t_errno; prmsg(1, "TLIConnect() t_connect() failed\n"); prmsg(1, "TLIConnect: %s\n", t_errlist[t_errno]); t_free((char *)sndcall,T_CALL); if (t_errno == TLOOK && t_look(ciptr->fd) == T_DISCONNECT) { t_rcvdis(ciptr->fd,NULL); return TRANS_TRY_CONNECT_AGAIN; } else return TRANS_CONNECT_FAILED; } t_free((char *)sndcall,T_CALL); /* * Sync up the address fields of ciptr. */ if( TRANS(TLIGetAddr)(ciptr) < 0 ) { prmsg(1, "TLIConnect: ...TLIGetAddr() failed: %d\n", errno); return TRANS_CONNECT_FAILED; } if( TRANS(TLIGetPeerAddr)(ciptr) < 0 ) { prmsg(1, "TLIConnect: ...TLIGetPeerAddr() failed: %d\n", errno); return TRANS_CONNECT_FAILED; } if( ioctl(ciptr->fd, I_POP,"timod") < 0 ) { prmsg(1, "TLIConnect() ioctl(I_POP,\"timod\") failed %d\n", errno); return TRANS_CONNECT_FAILED; } if( ioctl(ciptr->fd, I_PUSH,"tirdwr") < 0 ) { prmsg(1, "TLIConnect() ioctl(I_PUSH,\"tirdwr\") failed %d\n", errno); return TRANS_CONNECT_FAILED; } return 0; }
static int TRANS(TLITLIConnect)(XtransConnInfo ciptr, char *host, char *port) { struct t_call *sndcall; struct sockaddr_un *sunaddr; int ret_value; prmsg(2, "TLITLIConnect(%s,%s)\n", host, port); if( (sndcall=(struct t_call *)t_alloc(ciptr->fd,T_CALL,T_OPT|T_UDATA)) == NULL ) { prmsg(1, "TLITLIConnect() failed to allocate a t_call\n"); return TRANS_CONNECT_FAILED; } if( (sunaddr=(struct sockaddr_un *) malloc(sizeof(struct sockaddr_un))) == NULL ) { prmsg(1, "TLITLIConnect: failed to allocate a sockaddr_un\n"); t_free((char *)sndcall,T_CALL); return TRANS_CONNECT_FAILED; } sunaddr->sun_family=AF_UNIX; if( *port == '/' || strncmp (port, TLINODENAME, strlen (TLINODENAME)) == 0) { /* Use the port as is */ (void) strcpy(sunaddr->sun_path, port); } else { (void) sprintf(sunaddr->sun_path,"%s%s", TLINODENAME, port ); } sndcall->addr.buf=(char *)sunaddr; sndcall->addr.len=sizeof(*sunaddr); sndcall->addr.maxlen=sizeof(*sunaddr); ret_value = TRANS(TLIConnect)(ciptr, sndcall ); free((char *) sunaddr); return ret_value; }
static int TRANS(TLIINETConnect)(XtransConnInfo ciptr, char *host, char *port) { char portbuf[PORTBUFSIZE]; struct t_call *sndcall; long tmpport; prmsg(2, "TLIINETConnect(%s,%s)\n", host, port); #ifdef X11_t /* * X has a well known port, that is transport dependant. It is easier * to handle it here, than try and come up with a transport independent * representation that can be passed in and resolved the usual way. * * The port that is passed here is really a string containing the idisplay * from ConnectDisplay(). */ if (is_numeric (port)) { tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10); sprintf(portbuf,"%u", tmpport ); port = portbuf; } #endif if( (sndcall=(struct t_call *)t_alloc(ciptr->fd,T_CALL,T_ALL)) == NULL ) { prmsg(1, "TLIINETConnect() failed to allocate a t_call\n"); return TRANS_CONNECT_FAILED; } if( TRANS(TLIAddrToNetbuf)(ciptr->index, host, port, &(sndcall->addr) ) < 0 ) { prmsg(1, "TLIINETConnect() unable to resolve name:%s.%s\n", host, port); t_free((char *)sndcall,T_CALL); return TRANS_CONNECT_FAILED; } return TRANS(TLIConnect)(ciptr, sndcall ); }
static int TRANS(TLIClose)(XtransConnInfo ciptr) { prmsg(2, "TLIClose(%x->%d)\n", ciptr, ciptr->fd); t_unbind(ciptr->fd); return (t_close(ciptr->fd)); }
int TRANS(GetPeerAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp, Xtransaddr **addrp) { prmsg (2,"GetPeerAddr(%d)\n", ciptr->fd); *familyp = ciptr->family; *addrlenp = ciptr->peeraddrlen; if ((*addrp = malloc (ciptr->peeraddrlen)) == NULL) { prmsg (1,"GetPeerAddr: malloc failed\n"); return -1; } memcpy(*addrp, ciptr->peeraddr, ciptr->peeraddrlen); return 0; }
static int TRANS(TLIGetPeerAddr)(XtransConnInfo ciptr) { Xtransaddr sockname; struct netbuf netbuf; prmsg(3,"TLIGetPeerAddr(%x)\n", ciptr); netbuf.buf=(char *)&sockname; netbuf.len=sizeof(sockname); netbuf.maxlen=sizeof(sockname); if( t_getname(ciptr->fd,&netbuf,REMOTENAME) < 0 ) { prmsg(1,"TLIGetPeerAddr: t_getname(REMOTENAME) failed: %d\n", errno); return -1; } prmsg(4,"TLIGetPeerAddr: got family %d len %d\n", ((struct sockaddr *) &sockname)->sa_family ,netbuf.len); /* * Everything looks good: fill in the XtransConnInfo structure. */ if( ciptr->peeraddr ) free(ciptr->peeraddr); if( (ciptr->peeraddr = malloc(netbuf.len)) == NULL ) { prmsg(1, "TLIGetPeerAddr: Can't allocate space for the addr\n"); return -1; } ciptr->peeraddrlen=netbuf.len; memcpy(ciptr->peeraddr,&sockname,ciptr->peeraddrlen); return 0; }
static int TRANS(TLICloseForCloning)(XtransConnInfo ciptr) { /* * Don't unbind. */ prmsg(2, "TLICloseForCloning(%x->%d)\n", ciptr, ciptr->fd); return (t_close(ciptr->fd)); }
int checkboard(void) #endif { #ifdef COMPRESSED_UBOOT #if CONFIG_AP123 strcpy(s, "U-boot AP123\n"); #elif CONFIG_MI124 strcpy(s, "U-boot MI124\n"); #else strcpy(s, "U-boot DB120\n"); #endif #endif #if CONFIG_AP123 prmsg("U-boot AP123\n"); #elif CONFIG_MI124 prmsg("U-boot MI124\n"); #else prmsg("U-boot DB120\n"); #endif return 0; }
int TRANS(Connect) (XtransConnInfo ciptr, const char *address) { char *protocol; char *host; char *port; int ret; prmsg (2,"Connect(%d,%s)\n", ciptr->fd, address); if (TRANS(ParseAddress) (address, &protocol, &host, &port) == 0) { prmsg (1,"Connect: Unable to Parse address %s\n", address); return -1; } #ifdef HAVE_LAUNCHD if (!host) host=strdup(""); #endif if (!port || !*port) { prmsg (1,"Connect: Missing port specification in %s\n", address); if (protocol) free (protocol); if (host) free (host); return -1; } ret = ciptr->transptr->Connect (ciptr, host, port); if (protocol) free (protocol); if (host) free (host); if (port) free (port); return ret; }
static XtransConnInfo TRANS(TLIOpen)(char *device) { XtransConnInfo ciptr; prmsg(3,"TLIOpen(%s)\n", device); if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL ) { prmsg(1, "TLIOpen: calloc failed\n"); return NULL; } if( (ciptr->fd=t_open( device, O_RDWR, NULL )) < 0 ) { prmsg(1, "TLIOpen: t_open failed for %s\n", device); free(ciptr); return NULL; } return ciptr; }