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

📄 messages.c

📁 gdb for adsp develop
💻 C
📖 第 1 页 / 共 3 页
字号:
static char _[] = "@(#)messages.c	5.20 93/08/02 13:23:58, Srini, AMD.";/****************************************************************************** * Copyright 1991 Advanced Micro Devices, Inc. * * This software is the property of Advanced Micro Devices, Inc  (AMD)  which * specifically  grants the user the right to modify, use and distribute this * software provided this notice is not removed or altered.  All other rights * are reserved by AMD. * * AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS * SOFTWARE.  IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL * DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR * USE OF THIS SOFTWARE. * * So that all may benefit from your experience, please report  any  problems * or  suggestions about this software to the 29K Technical Support Center at * 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131  in  the  UK,  or * 0031-11-1129 in Japan, toll free.  The direct dial number is 512-462-4118. * * Advanced Micro Devices, Inc. * 29K Support Products * Mail Stop 573 * 5900 E. Ben White Blvd. * Austin, TX 78741 * 800-292-9263 ***************************************************************************** *      Engineer: Srini Subramanian. ***************************************************************************** * This module contains the functions to build and unpack MiniMON29K messages. * It also defines the functions to send and receive messages from the * 29K target. An array defining the appropriate functions to use for * different targets is initialized. ***************************************************************************** *//*  * Definitions of functions that  * -initialize the Message System  * -send messages to the target * -receive messages from the target */#include <stdio.h>#include <ctype.h>#ifdef	MSDOS#include <stdlib.h>#endif#include <string.h>#include "messages.h"#include "memspcs.h"#include "tdfunc.h"#include "mtip.h"extern	FILE	*MsgFile;static	int	DebugCoreVersion;static 	INT32	target_index = 0;	/* Default EB29K */int	lpt_initialize=0;	/* global */int	use_parport=0;	/* global */static	union msg_t	*send_msg_buffer;static	union msg_t	*recv_msg_buffer;struct	target_dep_funcs { char	target_name[15]; INT32	(*msg_send)PARAMS((union msg_t *, INT32)); INT32	(*msg_recv)PARAMS((union msg_t *, INT32, INT32)); INT32	(*init_comm)PARAMS((INT32, INT32)); INT32	(*reset_comm)PARAMS((INT32, INT32)); INT32	(*exit_comm)PARAMS((INT32, INT32)); INT32	(*read_memory)PARAMS((INT32, ADDR32, BYTE *, INT32, INT32, INT32)); INT32	(*write_memory)PARAMS((INT32, ADDR32, BYTE *, INT32, INT32, INT32)); INT32	(*fill_memory)PARAMS((void)); INT32	PC_port_base; INT32	PC_mem_seg; void	(*go)PARAMS((INT32, INT32));} TDF[] = {"pceb", msg_send_pceb, msg_recv_pceb, init_comm_pceb,reset_comm_pceb, exit_comm_pceb, read_memory_pceb, write_memory_pceb, fill_memory_pceb, (INT32) 0x240, (INT32) 0xd000, go_pceb,#ifndef	MSDOS"pcserver", msg_send_serial, msg_recv_serial, init_comm_serial,reset_comm_pcserver, exit_comm_serial, read_memory_serial, write_memory_serial,fill_memory_serial, (INT32) -1 , (INT32) -1, go_serial,#endif#ifdef	MSDOS"paral_1", msg_send_parport, msg_recv_serial, init_comm_serial,reset_comm_serial, exit_comm_serial, read_memory_serial, write_memory_serial,fill_memory_serial, (INT32) -1 , (INT32) -1, go_serial,#endif"serial", msg_send_serial, msg_recv_serial, init_comm_serial,reset_comm_serial, exit_comm_serial, read_memory_serial, write_memory_serial,fill_memory_serial, (INT32) -1 , (INT32) -1, go_serial,"eb29030", msg_send_eb030, msg_recv_eb030, init_comm_eb030,reset_comm_eb030, exit_comm_eb030, read_memory_eb030, write_memory_eb030,fill_memory_eb030, (INT32) 0x208, (INT32) 0xd000, go_eb030,"eb030", msg_send_eb030, msg_recv_eb030, init_comm_eb030,reset_comm_eb030, exit_comm_eb030, read_memory_eb030, write_memory_eb030,fill_memory_eb030, (INT32) 0x208, (INT32) 0xd000, go_eb030,"eb29k", msg_send_eb29k, msg_recv_eb29k, init_comm_eb29k,reset_comm_eb29k, exit_comm_eb29k, read_memory_eb29k, write_memory_eb29k, fill_memory_eb29k, (INT32) 0x208, (INT32) 0xd000, go_eb29k,"yarcrev8", msg_send_eb29k, msg_recv_eb29k, init_comm_eb29k,reset_comm_eb29k, exit_comm_eb29k, read_memory_eb29k, write_memory_eb29k, fill_memory_eb29k, (INT32) 0x208, (INT32) 0xd000, go_eb29k,"lcb29k", msg_send_lcb29k, msg_recv_lcb29k, init_comm_lcb29k, reset_comm_lcb29k, exit_comm_lcb29k, read_memory_lcb29k, write_memory_lcb29k,fill_memory_lcb29k, (INT32) 0x208, (INT32) 0xd000, go_lcb29k,"\0"};void	print_msg PARAMS((union msg_t *msgptr, FILE *file));static	INT32	match_name PARAMS((char *targ_name));#ifdef MSDOSvoid	set_lpt PARAMS((void));void	unset_lpt PARAMS((void));void	set_lpt (){  TDF[target_index].msg_send = msg_send_parport;  use_parport = 1;}void	unset_lpt(){  TDF[target_index].msg_send = msg_send_serial;  use_parport = 0;}#endif/*** Miscellaneous */INT32 msg_length(code)INT32 code;{  /* for temporary compatibility between new and old r/w/copy msgs */INT32 rv;  if (code == WRITE_REQ)       rv = MSG_LENGTH(struct write_req_msg_t);  else  if (code == READ_REQ)       rv = MSG_LENGTH(struct read_req_msg_t);  else  if (code == COPY)       rv = MSG_LENGTH(struct copy_msg_t);  else return(-1);  /* if msg version < 0x10 use old format */  /* assumes config info this has been set up */  if (((tip_target_config.version >> 16) & 0xff) < 0x10) 	rv = rv - 4;		   return(rv);}/*** Target Dependent functions*/INT32Mini_msg_init(target_name)char	*target_name;{  INT32		temp;  /* Allocate buffers */  if ((send_msg_buffer = (union msg_t *) malloc (BUFFER_SIZE)) == NULL)    return(FAILURE);  if ((recv_msg_buffer = (union msg_t *) malloc (BUFFER_SIZE)) == NULL)    return(FAILURE);  /* Identify target */  if (strcmp (target_name, "paral_1") == 0) {    lpt_initialize = 1;    use_parport = 1;  }  if ((temp = match_name(target_name)) == FAILURE)    return(FAILURE);  /* Unrecognized target */  else    target_index = temp;  if (tip_config.PC_port_base == (INT32) -1) /* no -port opt given */     tip_config.PC_port_base = TDF[target_index].PC_port_base;  if (tip_config.PC_mem_seg == (INT32) -1) /* no -seg opt given */     tip_config.PC_mem_seg = TDF[target_index].PC_mem_seg;  /* Initialize communication with target */  return(Mini_init_comm());}intMini_alloc_msgbuf(size)int	size;{  if (size > (int) BUFFER_SIZE) {     (void) free(send_msg_buffer);     (void) free(recv_msg_buffer);     /* Re-Allocate buffers */     if ((send_msg_buffer = (union msg_t *) malloc (size)) == NULL)       return(FAILURE);     if ((recv_msg_buffer = (union msg_t *) malloc (size)) == NULL)       return(FAILURE);  }  return (SUCCESS);}voidMini_msg_exit(){  if (send_msg_buffer)    (void) free ((char *) send_msg_buffer);  if (recv_msg_buffer)    (void) free ((char *) recv_msg_buffer);  (void) Mini_reset_comm();  (void) Mini_exit_comm();}INT32Mini_msg_send(){  INT32	retval;  if (Msg_Logfile) {/* log the message */     fprintf(MsgFile, "\nSending:");     print_msg(send_msg_buffer, MsgFile);     fflush(MsgFile);  };  retval = (*TDF[target_index].msg_send)(send_msg_buffer,				       tip_config.PC_port_base);  /* retry once more */  if (retval == MSGRETRY)     retval = (*TDF[target_index].msg_send)(send_msg_buffer,				       tip_config.PC_port_base);  return (retval);}INT32Mini_msg_recv(RecvMode)INT32	RecvMode;	/* BLOCK or NONBLOCK */{  INT32	retval;  retval = (INT32) (*TDF[target_index].msg_recv)(recv_msg_buffer,				       tip_config.PC_port_base, RecvMode);  if (RecvMode == BLOCK)  /* we are expecting a response */  {     if (retval == MSGRETRY) {	Mini_msg_send();        retval = (INT32) (*TDF[target_index].msg_recv)(recv_msg_buffer,				       tip_config.PC_port_base, RecvMode);     }     if (Msg_Logfile && (retval != (INT32) -1)) { /* log the message */       fprintf(MsgFile, "\nReceived:");       print_msg(recv_msg_buffer, MsgFile);       fflush (MsgFile);     };     if (retval == MSGRETRY)	return (FAILURE);     else 	return (retval);  }  else 	/* non-block mode */  {     if (retval == MSGRETRY) {        retval = (INT32) (*TDF[target_index].msg_recv)(recv_msg_buffer,				       tip_config.PC_port_base, RecvMode);	if (retval == MSGRETRY)	  return (FAILURE);	else	  return (retval);     } else  {        if (Msg_Logfile && (retval != (INT32) -1)) { /* log the message */          fprintf(MsgFile, "\nReceived:");          print_msg(recv_msg_buffer, MsgFile);          fflush (MsgFile);        };        return (retval);     }  }}INT32Mini_init_comm(){ return((*TDF[target_index].init_comm)(tip_config.PC_port_base,				       tip_config.PC_mem_seg));}INT32Mini_reset_comm(){ return((*TDF[target_index].reset_comm)(tip_config.PC_port_base,					tip_config.PC_mem_seg));}INT32Mini_exit_comm(){ return((*TDF[target_index].exit_comm)(tip_config.PC_port_base,					tip_config.PC_mem_seg));}voidMini_go_target(){ (*TDF[target_index].go)(tip_config.PC_port_base,				 tip_config.PC_mem_seg);}INT32Mini_write_memory(m_space, address, byte_count, buffer)INT32	m_space;ADDR32	address;INT32	byte_count;BYTE	*buffer;{ return((*TDF[target_index].write_memory)(m_space, 					  address,					  buffer,					  byte_count,					  tip_config.PC_port_base,					  tip_config.PC_mem_seg));}INT32Mini_read_memory(m_space, address, byte_count, buffer)INT32	m_space;ADDR32	address;INT32	byte_count;BYTE	*buffer;{ return((*TDF[target_index].read_memory)(m_space,					  address,					  buffer,					  byte_count,					  tip_config.PC_port_base,					  tip_config.PC_mem_seg));}INT32Mini_fill_memory(){ return((*TDF[target_index].fill_memory)());}/* ** Functions to build msgs*/voidMini_build_reset_msg(){ send_msg_buffer->reset_msg.code = RESET; send_msg_buffer->reset_msg.length = (INT32) 0;/* Length always is zero */}voidMini_build_config_req_msg(){ send_msg_buffer->config_req_msg.code = CONFIG_REQ; send_msg_buffer->config_req_msg.length = (INT32) 0; /* Always zero */

⌨️ 快捷键说明

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