📄 udip2mm.c
字号:
/******************************************************************************* * The process and all routines contained herein are the* property and trade secrets of AMD Inc. * * Except as provided for by licence agreement, this code * shall not be duplicated, used or disclosed for any * purpose or reason, in whole or part, without the express * written consent of AMD.* * Copyright AMD Inc. 1991************************************************************************ MODULE* * $NAME @(#)udip2mm.c 1.2 91/06/12* AUTHORS Daniel Mann* * This module implements the UDI-P interface.********************************************************************** HISTORY****************************************************************** INCLUDE FILES*/#include <stdio.h>#include "udiproc.h"#include "dbg_core.h"#include "error.h"/* local type decs. and macro defs. not in a .h file ************* MACRO/TYPE*/#define BUFER_SIZE 2048typedef struct msgheader_str{ INT32 class; INT32 length; UINT32 param[BUFER_SIZE];} msgheader_t;static msgheader_t msg_rbuf;static msgheader_t msg_sbuf;int (*msg_send)();int (*msg_recv)();/* local dec/defs. which are not in a .h file *************** LOCAL DEC/DEFS*/static INT8 SpaceMap_udi2mm[/* DRAMSpace IOSpace CPSpace0 CPSpace1 IROMSpace */ D_MEM, I_O, -1 ,-1 I_ROM,/* IRAMSpace LocalRegs GlobalRegs RealRegs SpecialRegs */ I_MEM, LOCAL_REG, GLOBAL_REG, GLOBAL_REG, SPECIAL_REG,/* TLBRegs ACCRegs ICacheSpace Am29027Regs PC */ TLB_REG, SPECIAL_REG, I_CACHE, COPROC_REG, SPECIAL_REG/* DCacheSpace */ D_CACHE ];static INT8 SpaceMap_mm2udi[/* LOCAL_REG GLOBAL_REG SPECIAL_REG TLB_REG COPROC_REG */ LocalRegs, GlobalRegs, SpecialRegs, TLBRegs, Am29029Regs,/* I_MEM D_MEM I_ROM D_ROM I_O */ IRAMSpace, DRAMSpace, IROMSpace, -1, IOSpace, /* I_CACHE D_CACHE */ ICacheSpace, DCacheSpace ];UDIPID default_pid; /* requested PID */ typedef struct bkpt_entry_str{ UDIResource addr; INT32 passcount; UDIBreakType type;} bkpt_entry_t;#define MAX_BKPT 20bkpt_entry_t bkpt_table[MAX_BKPT];/****************************************************************** PROCEDURES*//*********************************************************** UDI_GET_ERROR_MSG Errors above the value ERRUDI_TIP indicate that the TIP was not able to complete the request for some target specific reason. 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)UINT32 error_code; /* in */UDIHostMemPtr msg; /* out -- text of msg */{ if(error_code <= 0 || error_code > EMBAUD) return EMUSAGE; bcopy(error_msg[error_code], (char*) msg, strlen(error_msg[error_code]); return 0;}/*************************************************************** UDI_TERMINATE UDITerminate() is used to tell the TIP that the DFE is finished.*/UDITerminate(){}/******************************************************* UDI_GET_TARGET_CONFIG UDIGetTargetConfig() gets information about the target. I_mem_start/size defines the start address and length of instruction RAM memory. D_mem_start/size defines the start address and length of instruction Data memory. IR_mem_start/size defines the start address and length of instruction ROM memory. coprocessor de- fines the type of coprocessor present in the target if any. max_breakpoints defines the maximum number of breakpoints which the target can handle. max_steps defines the maximum number of stepcount that can be used in the UDIStep command.*/UDIError UDIGetTargetConfig(I_mem_start, I_mem_size, D_mem_start, D_mem_size, R_mem_start, R_mem_size, cpu_prl, copro_prl)UDIOffset *I_mem_start;/* out */UDIOffset *I_mem_size; /* out */UDIOffset *D_mem_start;/* out */UDIOffset *D_mem_size; /* out */UDIOffset *R_mem_start;/* out */UDIOffset *R_mem_size; /* out */UINT32 *cpu_prl; /* out */UINT32 *copro_prl; /* out */{ UDIError errno_mm = 0; msg_sbuf.class = CODE_CONFIG_REQ; msg_sbuf.length = 0; (*msg_send)(&msg_sbuf); /* send MiniMON message */ while( (*msg_recv)(&msg_rbuf) ); /* wait for reply */ if(msg_rbuf.class == CONFIG) { *I_mem_start = msg_rbuf.param[2]; *I_mem_size = msg_rbuf.param[3]; *D_mem_start = msg_rbuf.param[4]; *D_mem_size = msg_rbuf.param[5]; *R_mem_start = msg_rbuf.param[6]; *R_mem_size = msg_rbuf.param[7]; *cpu_prl = msg_rbuf.param[0]; *copro_prl = msg_rbuf.param[10]; } else { errno_mm = EMBADMSG; if(msg_rbuf.class == ERROR) errno_mm = msg_rbuf.param[0]; } return errno_mm;}/********************************************************** 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 */{ UDIError errno_mm = 0; *pid = 1; /* OSboot sets user PID=1 */ return errno_mm;}/********************************************************** UDI_SET_DEFALUT_PID UDISetDefaultPid uses a pid supplied by UDICreateProcess and sets it as the default for all udi calls until a new default is set. A user of a single-process OS would only have to use this once.*/UDIError UDISetDefaultPid(pid)UDIPID pid; /* in */{ UDIError errno_mm = 0; default_pid = pid; return errno_mm;}/********************************************************* UDI_DESTROY_PROCESS UDIDestroyProcess() frees a process resource pre- viously created by UDICreateProcess().*/UDIError UDIDestroyProcess(pid)UDIPID pid; /* in */{ UDIError errno_mm = 0; return errno_mm;}/****************************************************** UDI_INITIALIZE_PROCESS UDIInitializeProcess() is called after the code for a process has been loaded. The pid used is the one set by UDISetDfaultPid. The parameter text_addr defines the lowest and highest text ad- dresses used by the process. The parameter data_addr defines the lowest and highest data ad- dresses used by the process. The paramter entry_point defines the entry point of the process. The parameters mem_stack_size and reg_stack size define the sizes of the memory and register stacks required by the process. The special value UDI_DEFAULT implies that the default stack sizes for the target OS should be used. The parameter argstring defines a character string that will get parsed into the argv array for the process. The target OS will use the supplied information to set up the heaps and stacks and the program arguments if any. On return; the PC will be set to the entry point of the process.*/UDIError UDIInitializeProcess( text_addr, data_addr, entry_point, mem_stack_size, reg_stack_size, argstring)UDIRange text_addr; /* in--lowest and highest text addrs */UDIRange data_addr; /* in--lowest and highest data addrs */UDIResource entry_point; /* in--process entry point */CPUSizeT mem_stack_size; /* in--memory stack size */CPUSizeT reg_stack_size; /* in--register stack size */char* argstring; /* in--argument string used to */{ UDIError errno_mm = 0; msg_sbuf.class = CODE_INIT; msg_sbuf.length = 8*4; msg_sbuf.param[0] = text_addr.low; msg_sbuf.param[1] = text_addr.high; msg_sbuf.param[2] = data_start.low; msg_sbuf.param[3] = data_end.hich; msg_sbuf.param[4] = entry_point.Offset; msg_sbuf.param[5] = mem_stack_size; msg_sbuf.param[6] = reg_stack_size; msg_sbuf.param[7] = argstring; (*msg_send)(&msg_sbuf); /* send MiniMON message */ while( (*msg_recv)(&msg_rbuf) ); /* wait for reply */ if(msg_rbuf.class == ERROR) errno_mm = msg_rbuf.param[0]; else if(msg_rbuf.class != INIT_ACK) errno_mm = EMINIT; return errno_mm;}/****************************************************************** UDI_READ UDIRead() reads a block of objects from a target address+space to host space. The parameter struc- ture "from" specifies the address space and offset of the source. The parameter "to" specifies the destination address in the DFE on the host. The parameter count specifies the number of objects to be transferred and "size" specifies the size of each object. The size parameter is used by the TIP to perform byte-swapping if the target is not the same endian as the host. On completion; the output parameter count_done is set to the number of ob- jects successfully transferred.*/UDIError UDIRead (from, to, count, size, count_done, host_endian)UDIResource from; /* in - source address on target */UDIVoidPtr to; /* out - destination address on host */UDICount count; /* in -- count of objects to be transferred */UDISize size; /* in -- size of each object */UDICount *count_done; /* out - count actually transferred */UDIBool host_endian; /* in -- flag for endian information */{ UDIError errno_mm = 0; msg_sbuf.class = CODE_READ_REQ; msg_sbuf.length = 3*4; msg_sbuf.param[0] = MapSpace_udi2mm[from.Space]; /* space */ msg_sbuf.param[1] = from.Offset; /* address */ msg_sbuf.param[2] = size*count /* byte_count */ (*msg_send)(&msg_sbuf); /* send MiniMON message */ while( (*msg_recv)(&msg_rbuf) ); /* wait for reply */ if(msg_rbuf.class == READ_ACK) { *count_done = msg_rbuf.param[2]/size; bcopy((char*)&(msg_sbuf.param[3])), (char*)to, size*count); } else { errno_mm = EMREAD; *count_done = 0; if(msg_rbuf.class == ERROR) errno_mm = msg_rbuf.param[0]; } return errno_mm;}/****************************************************************** UDI_WRITE UDIWrite() writes a block of objects from host space to a target address+space The parameter "from" specifies the source address in the DFE on the host. The parameter structure "to" specifies the address space and offset of the destination on the target. The parameter count specifies the number of objects to be transferred and "size" specifies the size of each object. The size parameter is used by the TIP to perform byte-swapping if the target is not the same endian as the host. On completion; the output parameter count_done is set to the number of objects successfully transferred.*/UDIError UDIWrite( from, to, count, size, count_done, HostEndian )UDIVoidPtr from; /* in -- destination address on host */UDIResource to; /* in -- source address on target */UDICount count; /* in -- count of objects to be transferred */UDISize size; /* in -- size of each object */UDICount *count_done; /* out - count actually transferred */UDIBool HostEndian; /* in -- flag for endian information */{ UDIError errno_mm = 0; msg_sbuf.class = CODE_WRITE_REQ; msg_sbuf.length = 3*4 + size*count; msg_sbuf.param[0] = MapSpace_udi2mm[to.Space]; /* space */ msg_sbuf.param[1] = to.Offset; /* address */ msg_sbuf.param[2] = size*count /* byte_count */ bcopy((char*)from, (char*)msg_sbuf.param[3]), size*count); (*msg_send)(&msg_sbuf); /* send MiniMON message */ while( (*msg_recv)(&msg_rbuf) ); /* wait for reply */ if(msg_rbuf.class == WRITE_ACK) *count_done = msg_rbuf.param[2]/size; else { errno_mm = EMWRITE; *count_done = 0; if(msg_rbuf.class == ERROR) errno_mm = msg_rbuf.param[0]; } return errno_mm;}/******************************************************************** UDI_COPY UDICopy() copies a block of objects from one tar- get address/space to another target address/space. If the source and destination overlap; the copy is implemented as if a temporary buffer was used. The parameter structure "from" specifies the address space and offset of the destination on the target. The parameter structure "to" specifies the address space and offset of the destination on the target. The parameter count specifies the number of objects to be transferred and "size" specifies the size of each object. On completion; the output parameter count_done is set to the number of objects success- fully transferred.*/UDIError UDICopy(from, to, count, size, count_done, direction )UDIResource from; /* in -- destination address on target */UDIResource to; /* in -- source address on target */UDICount count; /* in -- count of objects to be transferred */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -