dbc.c

来自「基于nucleus操作系统的GPRS无线数据传输终端全套源文件。包括支持ARM7」· C语言 代码 · 共 1,633 行 · 第 1/5 页

C
1,633
字号
/************************************************************************
*                                                                       
*            Copyright (c) 1994 - 2001 Accelerated Technology, Inc.     
*                                                                       
* PROPRIETARY RIGHTS of Accelerated Technology are involved in the      
* subject matter of this material.  All manufacturing, reproduction,    
* use, and sales rights pertaining to this subject matter are governed  
* by the license agreement.  The recipient of this software implicitly  
* accepts the terms of the license.                                     
*                                                                       
*************************************************************************/
/*************************************************************************
*                                                                       
*   FILE NAME                                            VERSION          
*                                                                       
*       dbc.c                                           DBUG+  1.2       
*                                                                       
*   COMPONENT                                                             
*                                                                       
*       DEBUG - Nucleus DBUG+                                        
*                                                                       
*   DESCRIPTION                                                           
*                                                                       
*       This file contains the core debugger routines.                   
*                                                                       
*   DATA STRUCTURES                                                       
*                                                                       
*       DB_COMMAND_STRUCT       Stores a command string and id.
*                                                                       
*   FUNCTIONS                                                             
*                                                                       
*       DBC_Debug                           Main debugger routine        
*       DBC_Display_Status                  Main debugger routine        
*       DBC_Task_Fields                     Task fields routine          
*       DBC_Task_Infomation                 Task information routine     
*       DBC_Mailbox_Fields                  Mailbox fields routine       
*       DBC_Mailbox_Information             Mailbox Information routine  
*       DBC_Queue_Fields                    Queue field routine          
*       DBC_Queue_Information               Queue information routine    
*       DBC_Pipe_Fields                     Pipe field routine           
*       DBC_Pipe_Information                Pipe information routine     
*       DBC_Semaphore_Fields                semaphore field routine      
*       DBC_Semaphore_Information           semaphore information routine
*       DBC_Event_Fields                    Event field routine          
*       DBC_Event_Information               Event information routine    
*       DBC_Signal_Fields                   Signal field routine         
*       DBC_Signal_Information              Signal information routine   
*       DBC_Timer_Fields                    Timer field routine          
*       DBC_Timer_Information               Timer information routine    
*       DBC_Partition_Fields                Partition field routine      
*       DBC_Partition_Information           Partition information routine
*       DBC_Dynamic_Memory_Fields           Dynamic memory field routine 
*       DBC_Dynamic_Memory_Information      Dynamic memory infor routine 
*       DBC_Display_Memory                  Display memory               
*       DBC_Set_Memory                      Set memory                   
*       DBC_Resume_Task                     Resume task                  
*       DBC_Suspend_Task                    Suspend task                 
*       DBC_Terminate_Task                  Terminate task               
*       DBC_Reset_Task                      Reset task                   
*       DBC_Change_Priority                 Change task priority         
*       DBC_Broadcast_To_Mailbox            Broadcast to mailbox         
*       DBC_Receive_From_Mailbox            Receive from mailbox         
*       DBC_Reset_Mailbox                   Reset mailbox                
*       DBC_Send_To_Mailbox                 Send message to mailbox      
*       DBC_Broadcast_To_Queue              Broadcast to queue           
*       DBC_Receive_From_Queue              Receive from queue           
*       DBC_Reset_Queue                     Reset queue                  
*       DBC_Send_To_Front_Of_Queue          Send to the front of queue   
*       DBC_Send_To_Queue                   Send message to queue        
*       DBC_Broadcast_To_Pipe               Broadcast to a pipe          
*       DBC_Receive_From_Pipe               Receive from a pipe          
*       DBC_Reset_Pipe                      Reset pipe                   
*       DBC_Send_To_Front_Of_Pipe           Send to the front of pipe    
*       DBC_Send_To_Pipe                    Send message to pipe         
*       DBC_Obtain_Semaphore                Obtain semaphore             
*       DBC_Release_Semaphore               Release semaphore            
*       DBC_Reset_Semaphore                 Reset semaphore              
*       DBC_Retrieve_Events                 Retrieve events              
*       DBC_Set_Events                      Set events                   
*       DBC_Send_Signals                    Send signals                 
*       DBC_Control_Timer                   Control timer                
*       DBC_Reset_Timer                     Reset timer                  
*       DBC_Retrieve_Clock                  Retrieve system time         
*       DBC_Set_Clock                       Set system time              
*       DBC_Allocate_Partition              Allocate partition           
*       DBC_Deallocate_Partition            Deallocate partition         
*       DBC_Allocate_Memory                 Allocate memory              
*       DBC_Deallocate_Memory               Deallocate memory            
*       DBC_Build_List                      Build list                   
*       DBC_Print_Menu                      Print menu                   
*       DBC_Print_Status                    Print status                 
*       DBC_Input_Line                      Input line                   
*       DBC_Get_Name                        Get name                     
*       DBC_Name_Prompt                     Prompt user for name         
*       DBC_Get_Token                       Get token                    
*       DBC_Print_Line                      Print line                   
*       DBC_Check_For_Excess                Check for excess             
*       DBC_Items_Per_Width                 Items per width              
*       DBC_Items_Per_Height                Items per height             
*       DBC_Init_Buffer                     Initialize buffer            
*       DBC_Pause                           Screen pause                 
*                                                                        
*   DEPENDENCIES                                                          
*                                                                       
*       nucleus.h
*       externs.h
*       windat.h
*       n_ansi.h
*       tel_extr.h
*       nerrs.h
*       cs_defs.h
*       tc_defs.h
*       tm_defs.h
*       qu_defs.h
*       pi_defs.h
*       mb_extr.h
*       db_defs.h
*       db_extr.h
*       cs_extr.h
*       tc_extr.h
*       tm_extr.h
*       qu_extr.h
*       pi_extr.h
*                                                                       
*************************************************************************/
#include <stdio.h>
#include <string.h>
#include "plus/nucleus.h"
#include "plus/cs_defs.h"
#include "plus/tc_defs.h"
#include "plus/tm_defs.h"
#include "plus/qu_defs.h"
#include "plus/pi_defs.h"
#include "plus/mb_extr.h"
#include "net/target.h"
#include "net/inc/ncl.h"
#include "net/inc/externs.h"
#include "net/inc/nerrs.h"
#include "net/inc/tcp.h"
#include "demo/xprot/db_defs.h"
#include "demo/xprot/db_extr.h"
#include "telnet/inc/windat.h"
#include "telnet/inc/n_ansi.h"
#include "telnet/inc/tel_extr.h"

/* the following two MACROs is needed to adjust the size of output to match
the size of terminal of client */
#undef  COL
#undef  ROW
#define COL his_side.width
#define ROW his_side.rows

/* we need set the maximun row and column for global variables */
#define  MAXCOL  85
#define  MAXROW  25

INT16      telnet_socket=-1;

extern CHAR *server_ip, *server_name;

/* Define various Nucleus debugger static data structures.   */
CHAR            Input_Line[MAXCOL+1];          /* User input line          */
CHAR            Output_Line[MAXCOL+1];         /* User output line         */
CHAR            Token[MAXCOL+1];               /* Token from input line    */
CHAR            Prompt[] =  "\n\rDBUG+>";       /* Nucleus debugger prompt  */
CHAR            New_Line[] =  "\n\r";       /* New line equate          */
VOID            *DBC_List[MAX_ITEMS];           /* Pointers list for all    */
STATUS          DBC_Status;                     /* Status return value      */
UNSIGNED        total_items;                /* Total items in list      */
UNSIGNED        DBC_Size=0;                     /* Size of message          */

/* Define various error messages.  */
CHAR  Invalid_Name[] =        "\n\rNucleus DBUG+ ERROR: Name not found\n\n\r\r";
CHAR  Invalid_Name_Range[] =  "\n\rNucleus DBUG+ ERROR: Name size\n\n\r";
CHAR  Invalid_Address[] =   "\n\rNucleus DBUG+ ERROR: Not a HEX address\n\n\r";
CHAR  Excess_Chars[] =      "\n\rNucleus DBUG+ ERROR: Excess characters\n\n\r";

/* Define constant portions of the Nucleus help menu.  */
CHAR *Help_Menu[] = 
{
    "ts [name]   Display Task Status  [task name]\n\r",
    "ms [name]   Display Mailbox Status [mailbox name]\n\r",
    "qs [name]   Display Queue Status [queue name]\n\r",
    "ps [name]   Display Pipe Status [pipe name]\n\r",
    "ss [name]   Display Semaphore Status [semaphore name]\n\r",
    "es [name]   Display Event Status [event group name]\n\r",
    "si [name]   Display Signal Status [task name]\n\r",
    "ti [name]   Display Timer Status [timer name]\n\r",
    "pm [name]   Display Partition Status [partition name]\n\r",
    "dm [name]   Display Dynamic Memory Status [memory pool name]\n\r",
    "m  [a]      Display Memory [(H) address]\n\r",
    "sm  a       Set Memory a = (H) address\n\r",
    "\n\r",
    "\n\r",
    "help        Display this menu again\n\r",
    "exit        exit from DBC_Debug() connection\n\r",
    "\n\r",
    "Available Nucleus Service Routines:\n\r",
    "\n\r",
    "NU_Resume_Task                  Resume a task\n\r",
    "NU_Suspend_Task                 Suspend a task\n\r",
    "NU_Terminate_Task               Terminate a task\n\r",
    "NU_Reset_Task                   Resets a task\n\r",
    "NU_Change_Priority              Change a task's priority\n\r",
    "NU_Broadcast_To_Mailbox         Broadcasts message to mailbox\n\r",
    "NU_Receive_From_Mailbox         Receives message from mailbox\n\r",
    "NU_Reset_Mailbox                Resets mailbox\n\r",
    "NU_Send_To_Mailbox              Sends message to mailbox\n\r",
    "NU_Broadcast_To_Queue           Broadcasts message to queue\n\r",
    "NU_Receive_From_Queue           Receives message from queue\n\r",
    "NU_Reset_Queue                  Resets queue\n\r",
    "NU_Send_To_Front_Of_Queue       Sends message to front of queue\n\r",
    "NU_Send_To_Queue                Sends message to queue\n\r",
    "NU_Broadcast_To_Pipe            Broadcasts message to pipe\n\r",
    "NU_Receive_From_Pipe            Receives message from pipe\n\r",
    "NU_Reset_Pipe                   Resets pipe\n\r",
    "NU_Send_To_Front_Of_Pipe        Sends message to front of pipe\n\r",
    "NU_Send_To_Pipe                 Sends message to pipe\n\r",
    "NU_Obtain_Semaphore             Obtains semaphore\n\r",
    "NU_Release_Semaphore            Releases semaphore\n\r",
    "NU_Reset_Semaphore              Reset semaphore\n\r",
    "NU_Retrieve_Events              Retrieves events from a group\n\r",
    "NU_Set_Events                   Sets events in a group\n\r",
    "NU_Receive_Signals              Receives signals\n\r",
    "NU_Send_Signals                 Send signals\n\r",
    "NU_Control_Timer                Controls timer\n\r",
    "NU_Reset_Timer                  Resets timer\n\r",
    "NU_Retrieve_Clock               Retrieve the current time\n\r",
    "NU_Set_Clock                    Set the Nucleus time\n\r",
    "NU_Allocate_Partition           Allocate a memory partition\n\r",
    "NU_Deallocate_Partition         Deallocate a memory partition\n\r",
    "NU_Allocate_Memory              Allocate dynamic memory\n\r",
    "NU_Deallocate_Memory            Deallocate dynamic memory\n\r",
    "\n\r",
    "use 'exit' to exit from DBC_Debug() connection\n\r",
    0
};
    
/* Define the list of valid commands.  */
struct DB_COMMAND_STRUCT
{
    CHAR  *string;                          /* ASCII command string     */
    INT   id;                               /* Command ID               */
};

struct DB_COMMAND_STRUCT  DB_Commands[] =  {
    {"ts",                          TS},
    {"TS",                          TS},
    {"ms",                          MS},
    {"MS",                          MS},
    {"qs",                          QS},
    {"QS",                          QS},
    {"ps",                          PS},
    {"PS",                          PS},
    {"ss",                          SS},
    {"SS",                          SS},
    {"es",                          ES},
    {"ES",                          ES},
    {"si",                          SI},
    {"SI",                          SI},
    {"ti",                          TI},
    {"TI",                          TI},
    {"pm",                          PM},
    {"PM",                          PM},
    {"dm",                          DM},
    {"DM",                          DM},
    {"m",                           M},
    {"M",                           M},
    {"sm",                          SM},
    {"SM",                          SM},
    {"help",                        HELP},
    {"HELP",                        HELP},
    {"NU_Resume_Task",              NU_RESUME_TASK},
    {"NU_Suspend_Task",             NU_SUSPEND_TASK},
    {"NU_Terminate_Task",           NU_TERMINATE_TASK},
    {"NU_Reset_Task",               NU_RESET_TASK},
    {"NU_Change_Priority",          NU_CHANGE_PRIORITY},
    {"NU_Broadcast_To_Mailbox",     NU_BROADCAST_TO_MAILBOX},
    {"NU_Receive_From_Mailbox",     NU_RECEIVE_FROM_MAILBOX},
    {"NU_Reset_Mailbox",            NU_RESET_MAILBOX}, 
    {"NU_Send_To_Mailbox",          NU_SEND_TO_MAILBOX},
    {"NU_Broadcast_To_Queue",       NU_BROADCAST_TO_QUEUE},
    {"NU_Receive_From_Queue",       NU_RECEIVE_FROM_QUEUE},
    {"NU_Reset_Queue",              NU_RESET_QUEUE},
    {"NU_Send_To_Front_Of_Queue",   NU_SEND_TO_FRONT_OF_QUEUE},
    {"NU_Send_To_Queue",            NU_SEND_TO_QUEUE},
    {"NU_Broadcast_To_Pipe",        NU_BROADCAST_TO_PIPE},
    {"NU_Receive_From_Pipe",        NU_RECEIVE_FROM_PIPE},
    {"NU_Reset_Pipe",               NU_RESET_PIPE},
    {"NU_Send_To_Front_Of_Pipe",    NU_SEND_TO_FRONT_OF_PIPE},
    {"NU_Send_To_Pipe",             NU_SEND_TO_PIPE},
    {"NU_Obtain_Semaphore",         NU_OBTAIN_SEMAPHORE},
    {"NU_Release_Semaphore",        NU_RELEASE_SEMAPHORE},
    {"NU_Reset_Semaphore",          NU_RESET_SEMAPHORE},
    {"NU_Retrieve_Events",          NU_RETRIEVE_EVENTS},
    {"NU_Set_Events",               NU_SET_EVENTS},
    {"NU_Send_Signals",             NU_SEND_SIGNALS},
    {"NU_Control_Timer",            NU_CONTROL_TIMER},
    {"NU_Reset_Timer",              NU_RESET_TIMER},
    {"NU_Retrieve_Clock",           NU_RETRIEVE_CLOCK},
    {"NU_Set_Clock",                NU_SET_CLOCK},
    {"NU_Allocate_Partition",       NU_ALLOCATE_PARTITION},
    {"NU_Deallocate_Partition",     NU_DEALLOCATE_PARTITION},
    {"NU_Allocate_Memory",          NU_ALLOCATE_MEMORY},
    {"NU_Deallocate_Memory",        NU_DEALLOCATE_MEMORY},
    {0, -1}};
    
/* Define the Nucleus Display buffer.  This is used to facilitate the column
display of Nucleus information.  */
CHAR  Output_Buffer[(MAXCOL+1) * MAXROW];
CHAR  *Line_Pointers[MAXROW];

/* Define the Nucleus Data buffer.  This buffer contains a copy of a
Nucleus data structure or the contents of a queue item to be sent
or received by the debugger.  */   
CHAR  Data_Buffer[DB_BUFFER_SIZE];

/* Define the variable that contains the last HEX address displayed.  */
unsigned long *DBC_Address;
static UNSIGNED DBC_Limit_Items(UNSIGNED unbounded);

/************************************************************************
*                                                                       
*   FUNCTION                                
*
*       DBC_Debug                                                      
*                                                                       

⌨️ 快捷键说明

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