⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 udip2soc.c

📁 gdb是linux下的一个远程调试环境.能让你很方便地调试linux下的代码.
💻 C
📖 第 1 页 / 共 3 页
字号:
	sprintf(dfe_errmsg," SessionId not valid (%d)", Session);	return UDIErrorNoSuchConfiguration;    }    udr_errno = 0;    udrs->udr_op = UDR_ENCODE;		/* send all "in" parameters */    udr_UDIInt32(udrs, &service_id);    udr_UDISessionId(udrs, &session[Session].tip_id);    udr_UDIBool(udrs, &Terminate);    udr_sendnow(udrs);    session[Session].in_use = FALSE;	/* session id is now free */    for (cnt=0; cnt < MAX_SESSIONS; cnt++)        if(session[cnt].in_use	&& session[cnt].soc_con_p == session[Session].soc_con_p		) break;    if(cnt >= MAX_SESSIONS)	/* test if socket not multiplexed */        if(shutdown(session[Session].soc_con_p->dfe_sd, 2))        {   errmsg_m;     	    sprintf(dfe_errmsg, "DFE-ipc WARNING: socket shutdown failed");	    return UDIErrorIPCInternal;        }    udrs->udr_op = UDR_DECODE;		/* receive all "out" parameters */    udr_UDIError(udrs, &dfe_errno);	/* get any TIP error */    return dfe_errno;}/******************************************************************** UDI_KILL* UDIKill() is used to send a signal to the TIP.* This is a private IPC call.*/UDIError UDIKill(Session,  Signal)UDISessionId	Session;UDIInt32	Signal;{    int	cnt;    UDIInt32	service_id = UDIKill_c;    if(Session < 0 || Session > MAX_SESSIONS)    {	errmsg_m;	sprintf(dfe_errmsg," SessionId not valid (%d)", Session);	return UDIErrorNoSuchConfiguration;    }    udr_errno = 0;    udrs->udr_op = UDR_ENCODE;		/* send all "in" parameters */    udr_UDIInt32(udrs, &service_id);    udr_UDISessionId(udrs, &session[Session].tip_id);    udr_UDIInt32(udrs, &Signal);    udr_sendnow(udrs);    session[Session].in_use = FALSE;	/* session id is now free */    for (cnt=0; cnt < MAX_SESSIONS; cnt++)        if(session[cnt].in_use	&& session[cnt].soc_con_p == session[Session].soc_con_p		) break;    if(cnt < MAX_SESSIONS)	/* test if socket not multiplexed */        if(shutdown(session[Session].soc_con_p->dfe_sd, 2))        {   errmsg_m;     	    sprintf(dfe_errmsg, "DFE-ipc WARNING: socket shutdown failed");	    return UDIErrorIPCInternal;        }    udrs->udr_op = UDR_DECODE;		/* receive all "out" parameters */    udr_UDIError(udrs, &dfe_errno);	/* get any TIP error */    return dfe_errno;}/************************************************** UDI_Set_Current_Connection* If you are connected to multiple TIPs, you can change* TIPs using UDISetCurrentConnection().*/UDIError UDISetCurrentConnection(Session)UDISessionId	Session;{    UDIInt32	service_id = UDISetCurrentConnection_c;    if(Session < 0 || Session > MAX_SESSIONS)	return UDIErrorNoSuchConfiguration;    if(!session[Session].in_use) 		/* test if not in use yet */	return UDIErrorNoSuchConnection;    current = Session;    /* change socket or multiplex the same socket  */    udrs->sd = session[Session].soc_con_p->dfe_sd;    udr_errno = 0;    udrs->udr_op = UDR_ENCODE;		/* send all "in" parameters */    udr_UDIInt32(udrs, &service_id);    udr_UDISessionId(udrs, &session[Session].tip_id);    udr_sendnow(udrs);    if(udr_errno) return udr_errno;    udrs->udr_op = UDR_DECODE;		/* receive all "out" parameters */    udr_UDIError(udrs, &dfe_errno);	/* get any TIP error */    return dfe_errno;}/************************************************************ UDI_Capabilities* The DFE uses UDICapabilities() to both inform the TIP* of what services the DFE offers and to inquire of the* TIP what services the TIP offers.*/UDIError UDICapabilities(TIPId, TargetId, DFEId, DFE, TIP, DFEIPCId,		TIPIPCId, TIPString)UDIUInt32	*TIPId;		/* out */UDIUInt32	*TargetId;	/* out */UDIUInt32	DFEId;		/* in */UDIUInt32	DFE;		/* in */UDIUInt32	*TIP;		/* out */UDIUInt32	*DFEIPCId;	/* out */UDIUInt32	*TIPIPCId;	/* out */char		*TIPString;	/* out */{    UDIInt32	service_id = UDICapabilities_c;    int		size;    udr_errno = 0;    udrs->udr_op = UDR_ENCODE;		/* send all "in" parameters */    udr_UDIInt32(udrs, &service_id);    udr_UDIInt32(udrs, &DFEId);    udr_UDIInt32(udrs, &DFE);    udr_sendnow(udrs);    if(udr_errno) return udr_errno;    udrs->udr_op = UDR_DECODE;		/* receive all "out" paramters */    udr_UDIInt32(udrs, TIPId);    udr_UDIInt32(udrs, TargetId);    udr_UDIInt32(udrs, TIP);    udr_UDIInt32(udrs, DFEIPCId);    *DFEIPCId = (company_c << 16) + (product_c << 12) + version_c;    udr_UDIInt32(udrs, TIPIPCId);    udr_string(udrs, sbuf);    udr_UDIError(udrs, &dfe_errno);	/* get any TIP error */    size = strlen(sbuf);    if(size +1 > 80) return -1;		/* test if sufficient space */    strcpy(TIPString, sbuf);    return dfe_errno;}/********************************************************** UDI_Enumerate_TIPs* Used by the DFE to enquire about available TIP* connections.*/UDIError UDIEnumerateTIPs(UDIETCallback)  int (*UDIETCallback)();		/* In -- function to callback */{    FILE	*fp;    fp = fopen(config_file, "r");    if(fp == NULL)	return UDIErrorCantOpenConfigFile;    while(fgets( sbuf, SBUF_SIZE, fp))	if(UDIETCallback( sbuf) == UDITerminateEnumeration)	    break;    fclose( fp);    return UDINoError;			/* return success */}/*********************************************************** UDI_GET_ERROR_MSG* Some errors are target specific. They are indicated* by a negative error return value. The DFE uses* UDIGetErrorMsg() to get the descriptive text for* the error message which can then  be  displayed  to* the user.*/UDIError UDIGetErrorMsg(error_code, msg_len, msg, CountDone)UDIError	error_code;		/* In */UDISizeT	msg_len;		/* In  -- allowed message space */char*		msg;			/* Out -- length of message*/UDISizeT	*CountDone;		/* Out -- number of characters */{    UDIInt32	service_id = UDIGetErrorMsg_c;    int		size;    udr_errno = 0;    udrs->udr_op = UDR_ENCODE;		/* send all "in" parameters */    udr_UDIInt32(udrs, &service_id);    udr_UDIError(udrs, &error_code);    udr_UDISizeT(udrs, &msg_len);    udr_sendnow(udrs);    if(udr_errno) return udr_errno;    udrs->udr_op = UDR_DECODE;		/* receive all "out" parameters */    udr_string(udrs, sbuf);    udr_UDISizeT(udrs, CountDone);    udr_UDIError(udrs, &dfe_errno);	/* get any TIP error */    size = strlen(sbuf);    if(size +1 > msg_len) return -1;	/* test if sufficient space */    strcpy(msg, sbuf);    return dfe_errno;}/******************************************************* UDI_GET_TARGET_CONFIG* UDIGetTargetConfig() gets information about the target.*/UDIError UDIGetTargetConfig(KnownMemory, NumberOfRanges, ChipVersions,		NumberOfChips)UDIMemoryRange	KnownMemory[];		/* Out */UDIInt		*NumberOfRanges;	/* In and Out */UDIUInt32	ChipVersions[];		/* Out */UDIInt		*NumberOfChips;		/* In and Out */{    UDIInt32	service_id = UDIGetTargetConfig_c;    int		cnt;    int		MaxOfRanges = *NumberOfRanges;    udr_errno = 0;    udrs->udr_op = UDR_ENCODE;		/* send all "in" parameters */    udr_UDIInt32(udrs, &service_id);    udr_UDIInt(udrs, NumberOfRanges);    udr_UDIInt(udrs, NumberOfChips);    udr_sendnow(udrs);    if(udr_errno) return udr_errno;    udrs->udr_op = UDR_DECODE;		/* receive all "out" paramters */    for(cnt=1; cnt <= MaxOfRanges; cnt++)    	udr_UDIMemoryRange(udrs, &KnownMemory[cnt-1]);    udr_UDIInt(udrs, NumberOfRanges);    udr_UDIInt(udrs, NumberOfChips);    for(cnt=1; cnt <= *NumberOfChips; cnt++)    	udr_UDIUInt32(udrs, &ChipVersions[cnt -1]);    udr_UDIError(udrs, &dfe_errno);	/* get any TIP error */    return dfe_errno;}/********************************************************** UDI_CREATE_PRCOESS* UDICreateProcess() tells the  target  OS  that  a* process is to be created and gets a PID back unless* there is some error.*/UDIError UDICreateProcess(pid)UDIPId	*pid;	/* out */{    UDIInt32	service_id = UDICreateProcess_c;    udr_errno = 0;    udrs->udr_op = UDR_ENCODE;		/* send all "in" parameters */    udr_UDIInt32(udrs, &service_id);    udr_sendnow(udrs);    if(udr_errno) return udr_errno;    udrs->udr_op = UDR_DECODE;		/* receive all "out" parameters */    udr_UDIPId(udrs, pid);    udr_UDIError(udrs, &dfe_errno);	/* get any TIP error */    return dfe_errno;}/***************************************************** UDI_Set_Current_Process* UDISetCurrentProcess  uses   a   pid   supplied   by* UDICreateProcess  and  sets it as the default for all* udi calls until a new one is set.  A user of  a*/UDIError UDISetCurrentProcess (pid)UDIPId	pid;			/* In */{    UDIInt32	service_id = UDISetCurrentProcess_c;    udr_errno = 0;    udrs->udr_op = UDR_ENCODE;		/* send all "in" parameters */    udr_UDIInt32(udrs, &service_id);    udr_UDIPId(udrs, &pid);    udr_sendnow(udrs);    if(udr_errno) return udr_errno;    udrs->udr_op = UDR_DECODE;		/* receive all "out" parameters */    udr_UDIError(udrs, &dfe_errno);	/* get any TIP error */    return dfe_errno;}/****************************************************** UDI_INITIALISE_PROCESS* UDIInitializeProcess() prepare process for* execution. (Reset processor if process os processor).*/UDIError UDIInitializeProcess( ProcessMemory, NumberOfRanges, EntryPoint,		StackSizes, NumberOfStacks, ArgString)UDIMemoryRange	ProcessMemory[];	/* In */UDIInt		NumberOfRanges;		/* In */UDIResource	EntryPoint;		/* In */CPUSizeT	*StackSizes;		/* In */UDIInt		NumberOfStacks;		/* In */char		*ArgString;		/* In */{    UDIInt32	service_id = UDIInitializeProcess_c;    int		cnt;    udr_errno = 0;    udrs->udr_op = UDR_ENCODE;		/* send all "in" parameters */    udr_UDIInt32(udrs, &service_id);    udr_UDIInt(udrs, &NumberOfRanges);    for(cnt = 0; cnt < NumberOfRanges; cnt++)	udr_UDIMemoryRange(udrs, &ProcessMemory[cnt] );    udr_UDIResource(udrs, &EntryPoint);    udr_UDIInt(udrs, &NumberOfStacks);    for(cnt = 0; cnt < NumberOfStacks; cnt++)	udr_CPUSizeT(udrs, &StackSizes[cnt]);    udr_string(udrs, ArgString);    udr_sendnow(udrs);    if(udr_errno) return udr_errno;    udrs->udr_op = UDR_DECODE;		/* receive all "out" parameters */    udr_UDIError(udrs, &dfe_errno);	/* get any TIP error */    return dfe_errno;}/********************************************************* UDI_DESTROY_PROCESS* UDIDestroyProcess() frees a process resource* previously created by UDICreateProcess().*/UDIError UDIDestroyProcess(pid)UDIPId   pid;	/* in */{    UDIInt32	service_id = UDIDestroyProcess_c;    udr_errno = 0;    udrs->udr_op = UDR_ENCODE;		/* send all "in" parameters */    udr_UDIInt32(udrs, &service_id);    udr_UDIPId(udrs, &pid);    udr_sendnow(udrs);    if(udr_errno) return udr_errno;    udrs->udr_op = UDR_DECODE;		/* receive all "out" parameters */    udr_UDIError(udrs, &dfe_errno);	/* get any TIP error */    return dfe_errno;}/****************************************************************** UDI_READ* UDIRead() reads a block of objects from  a  target* address space  to host space.*/UDIError UDIRead (from, to, count, size, count_done, host_endian)UDIResource	from;		/* in - source address on target */UDIHostMemPtr	to;		/* out - destination address on host */UDICount	count;		/* in -- count of objects to be transferred */UDISizeT	size;		/* in -- size of each object */UDICount	*count_done;	/* out - count actually transferred */UDIBool		host_endian;	/* in -- flag for endian information */{    UDIInt32	service_id = UDIRead_c;    int		byte_count;    udr_errno = 0;    udrs->udr_op = UDR_ENCODE;		/* send all "in" parameters */    udr_UDIInt32(udrs, &service_id);    udr_UDIResource(udrs, &from);    udr_UDICount(udrs, &count);    udr_UDISizeT(udrs, &size);    udr_UDIBool(udrs, &host_endian);    udr_sendnow(udrs);    if(udr_errno) return udr_errno;    udrs->udr_op = UDR_DECODE;		/* receive all "out" paramters */    udr_UDICount(udrs, count_done);    byte_count = (*count_done) * size;    if(*count_done > 0 && *count_done <= count)        udr_bytes(udrs, to, byte_count);    if(udr_errno) return udr_errno;    udr_UDIError(udrs, &dfe_errno);	/* get any TIP error */    return dfe_errno;}/****************************************************************** UDI_WRITE* UDIWrite() writes a block  of  objects  from  host* space  to  a  target  address+space.*/UDIError UDIWrite( from, to, count, size, count_done, host_endian )UDIHostMemPtr	from;		/* in -- source address on host */UDIResource	to;		/* in -- destination address on target */UDICount	count;		/* in -- count of objects to be transferred */UDISizeT	size;		/* in -- size of each object */UDICount	*count_done;	/* out - count actually transferred */UDIBool		host_endian;	/* in -- flag for endian information */{    UDIInt32	service_id = UDIWrite_c;    int		byte_count = count * size;    udr_errno = 0;    udrs->udr_op = UDR_ENCODE;		/* send all "in" parameters */    udr_UDIInt32(udrs, &service_id);    udr_UDIResource(udrs, &to);    udr_UDICount(udrs, &count);    udr_UDISizeT(udrs, &size);    udr_UDIBool(udrs, &host_endian);    udr_bytes(udrs, from, byte_count);    udr_sendnow(udrs);    if(udr_errno) return udr_errno;    udrs->udr_op = UDR_DECODE;		/* receive all "out" paramters */    udr_UDICount(udrs, count_done);    udr_UDIError(udrs, &dfe_errno);	/* get any TIP error */    return dfe_errno;}/******************************************************************** UDI_COPY* UDICopy() copies a block of objects from one  target* get  address/space to another target address/space.*/UDIError UDICopy(from, to, count, size, count_done, direction )UDIResource	from;		/* in -- destination address on target */UDIResource	to;		/* in -- source address on target */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -