/* Copyright Motorola, Inc. 1993, 1994 ALL RIGHTS RESERVED You are hereby granted a copyright license to use, modify, and distribute the SOFTWARE so long as this entire notice is retained without alteration in any modified and/or redistributed versions, and that such modified versions are clearly identified as such. No licenses are granted by implication, estoppel or otherwise under any patents or trademarks of Motorola, Inc. The SOFTWARE is provided on an "AS IS" basis and without warranty. To the maximum extent permitted by applicable law, MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED, INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE AND ANY WARRANTY AGAINST INFRINGEMENT WITH REGARD TO THE SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF) AND ANY ACCOMPANYING WRITTEN MATERIALS. To the maximum extent permitted by applicable law, IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE SOFTWARE. Motorola assumes no responsibility for the maintenance and support of the SOFTWARE. INTRODUCTION ----------------------------------------------------------------- This file can prove to be very very confusing so I will attempt to explain it as fully as possible here. DEFINITIONS ------------------------------------------------------------------ Token - A token is an integer value that represents a string. For example the string "hello" could be recognized by the tokenizer and a list could be searched to find the integer value that would represent that string. The token would be that integer value that was found. TOKEN DISCUSSION ------------------------------------------------------------ Every string in the system must have a unique integer number associated with it. With a system that contains many tokens (over 50) this becomes a problem. This file is one of a few header files designed to create unique tokens for every string that the tokenizer is required to interpret. Another factor is that different strings represent different types of actions. Just as there are verbs and nouns in english, there are specific grouping of words in this program. For example, all the commands that can be issued to the system would be a grouping, and all the registers that would be used would be another grouping. This grouping then follows at a lower level. There are different groupings withing the commands. For example, there are commands that deal with the registers and there are commands that deal with memory. These would be separate and distinct groupings. The same follows for the registers in the system. NOTE!!! Within any ONE grouping there is a maximum number of tokens. This maximum number must be known in order to provide for an accurate numbering scheme. For example there are only 3 register commands. In this case, a safe (and reasonable) maximum may be 16 (or 8, or 4) depending on possible expansions to the register functions in the future. A good heuristic is to choose a value that is a power of two and at least 2 or 3 times greater than the actual number of tokens needed. This will leave plenty of room for expansion yet it will not be an excessive number of unused token numbers. This heuristic may not be needed in certain situations. If the number of registers in a family of registers is not expected to change, then it may be reasonable to be more exact with the number of tokens to be allocated. NUMBERING METHOD ------------------------------------------------------------- Ok.. Here's how we are doing the numbering. Hold on tight... This will be fairly detailed and densely described. (There isn't any other way of doing this description) There are two basic groups of tokens. The commands and the registers. These each need a base token value to start with. These are named CMDS_BASE and REGS_BASE respectively. These are defined below. Within the commands there are several different families of commands. There are the memory commands (MEMCMDS), register commands (REGCMDS), breakpoint commands (BREAKCMDS), the execution commands (EXECCMDS), the alias commands (ALIASCMDS), the history commands (HISTCMDS), and finaly the miscellaneous commands (MISCCMDS). There are a maximum number of these commands in this system. The numbers were chosen using the heuristic described above (16 for all of them). These maximums were defined below and have the form #define MAX_xxxxxxxx 16 where "xxxxxxxxx" is the type of command family. For example, for the execution commands the define would look like this: #define MAX_EXECCMDS 16 This says that there are 16 possible execution commands. Yes, that may seem to be an exorbitant number but consider that an integer has 16 bits worth of tokens it can represent. The maximums are defined below. Next we start numbering the different families, MEM_CMDS_BASE starts at CMDS_BASE. The next is REG_CMDS_BASE and that will start immediately after the end of MEM_CMDS_BASE (MEM_CMDS_BASE + MAX_MEMCMDS_TOKENS + 1). The "+1" is to ensure that the last token of MEM_CMDS_BASE is not the same as the first token of REG_CMDS_BASE. This follows for the rest of the families. The same occurs for the register families. This is where the individual tokens can be created. This is best shown by example. Let's say that the MEMCMDS include "mapmemory". This is how the token would be defined. #define MAPMEMORY_TOK MEM_CMDS_BASE + 2 If CMDS_BASE was specified to be 1000, then MAPMEMORY_TOK would be 1000 + 2 or 1002. Consider the next example. Assume that a miscelaneous command was "altergenes". The definition of the token would be as follows : #define ALTERGENES_TOK MISC_CMDS_BASE + 3 The value of ALTERGENES_TOK would be 1000 + 16 + 1 + 16 + 1 + 16 + 1 + 16 + 1 + 16 + 1 + 16 + 1 + 3 or 1105. If the same method is used for all the tokens in the system we are guarenteed to be unique. */ #include "config.h" #ifdef IN_DINK_TOKS #define WHERE_DT #else #define WHERE_DT extern #endif /* we need to include the processor specific constants... So here they are. */ #include "cpu.h" #include "spr_loc.h" #include "tok_tb.h" #ifdef ON_BOARD #include "board.h" #endif /* this is the TOTAL number of tokens to be used by the DINK32 monitor. */ #define TOTAL_DINK_TOKS 60 /* here are the variables that we need to effectively run the system. */ /* here is the token translation list. */ WHERE_DT tok_trans_list ttl; /* here is the list of tokens that dink needs to run */ WHERE_DT tok_trans_list_element tok_lst[TOTAL_DINK_TOKS]; /* this is the only function in the module */ #ifndef IN_DINK_TOKS WHERE_DT dink_toks_initialize(); #endif /* this is for closure of the extern/internal conflict */ #undef WHERE /* these define the base numbers for the groups of tokens. One for the commands (CMDS_BASE) and one for the registers (REGS_BASE) */ #define CMDS_BASE 0x1000 #define REGS_BASE 0x2000 /* these are the maximum numbers for the command families. */ #ifdef BB_BE #define MAX_MEMCMDS_TOKENS 32 #else /*BB_BE*/ #define MAX_MEMCMDS_TOKENS 16 #endif /*BB_BE*/ #define MAX_REGCMDS_TOKENS 16 #define MAX_BREAKCMDS_TOKENS 16 #define MAX_EXECCMDS_TOKENS 16 #define MAX_MACCMDS_TOKENS 16 #define MAX_HELPCMDS_TOKENS 16 #define MAX_MISCCMDS_TOKENS 16 #define MAX_CONVCMDS_TOKENS 16 #define MAX_CODECMDS_TOKENS 16 #define MAX_SYMBOLS_TOKENS 32 #define SPRALL_TOK 1024 /* the maximum possible number of the different register types are found in "cpu.h" */ /* these become the base token values for the different commands in DINK32 */ #define MM_BASE (int) 20 #define BHWD_TOKEN_B MM_BASE + 1 #define BHWD_TOKEN_H MM_BASE + 2 #define BHWD_TOKEN_W MM_BASE + 3 #define BHWD_TOKEN_D MM_BASE + 4 #define CMD_MEM_BASE_TOK CMDS_BASE #define CMD_REG_BASE_TOK CMD_MEM_BASE_TOK + MAX_MEMCMDS_TOKENS + 1 #define CMD_BRKPT_BASE_TOK CMD_REG_BASE_TOK + MAX_REGCMDS_TOKENS + 1 #define CMD_EXEC_BASE_TOK CMD_BRKPT_BASE_TOK + MAX_BREAKCMDS_TOKENS + 1 #define CMD_MAC_BASE_TOK CMD_EXEC_BASE_TOK + MAX_EXECCMDS_TOKENS + 1 #define CMD_HELP_BASE_TOK CMD_MAC_BASE_TOK + MAX_MACCMDS_TOKENS + 1 #define CMD_MISC_BASE_TOK CMD_HELP_BASE_TOK + MAX_HELPCMDS_TOKENS + 1 #define CMD_CONV_BASE_TOK CMD_MISC_BASE_TOK + MAX_MISCCMDS_TOKENS + 1 #define CMD_CODE_BASE_TOK CMD_CONV_BASE_TOK + MAX_CONVCMDS_TOKENS + 1 #define SYMBOL_BASE_TOK CMD_CODE_BASE_TOK + MAX_CODECMDS_TOKENS + 1 #define PARAMETER_BASE_TOK SYMBOL_BASE_TOK + MAX_SYMBOLS_TOKENS + 1 /* these become the base token values for the different types of registers in the processor */ #define REG_GEN_BASE_TOK REGS_BASE #define REG_FP_BASE_TOK (REG_GEN_BASE_TOK + MAX_GENERAL_REG_TOKENS + 1) #define REG_V_BASE_TOK (REG_FP_BASE_TOK + MAX_FP_REG_TOKENS + 1) #define REG_SPR_BASE_TOK (REG_V_BASE_TOK + MAX_V_REG_TOKENS + 1) #define BK_TOK CMD_BRKPT_BASE_TOK + 1 /* cmd_brkpt1 - all breakpoint (LF) */ #define AS_TOK CMD_CODE_BASE_TOK + 1 /* cmd_code1 - assemble command (LF) **NI** */ #define DS_TOK CMD_CODE_BASE_TOK + 2 /* cmd_code2 - disassemble command (LF) **NI** */ #define SB_TOK CMD_CODE_BASE_TOK + 3 /* set baud command */ #define BT_TOK CMD_CODE_BASE_TOK + 4 /* branch table command */ #define BTCL_TOK CMD_CODE_BASE_TOK + 5 /* branch table clear flag */ #define FH_TOK CMD_CONV_BASE_TOK + 1 /* cmd_conv1 - convert float to hex (LF) **NI** */ #define HF_TOK CMD_CONV_BASE_TOK + 2 /* cmd_conv2 - convert hex to float (LF) **NI** */ #define HB_TOK CMD_CONV_BASE_TOK + 3 /* cmd_conv3 - convert hex to binary (LF) **NI** */ #define BH_TOK CMD_CONV_BASE_TOK + 4 /* cmd_conv4 - convert binary to hex(LF) **NI** */ #define DH_TOK CMD_CONV_BASE_TOK + 5 /* cmd_conv5 - convert decimal to hex (LF) **NI** */ #define HD_TOK CMD_CONV_BASE_TOK + 6 /* cmd_conv6 - convert hex to decimal (LF) **NI** */ #define GO_TOK CMD_EXEC_BASE_TOK + 1 /* cmd_exec1 - go (OF) */ #define TR_TOK CMD_EXEC_BASE_TOK + 2 /* cmd_exec2 - trace (SF) */ #define HE_TOK CMD_HELP_BASE_TOK + 1 /* cmd_help1 - help (SF) */ #define ME_TOK CMD_HELP_BASE_TOK + 2 /* cmd_help2 - menu command (LF) */ #define RA_TOK CMD_MAC_BASE_TOK + 1 /* cmd_mac1 - run alias (LF) **NI** */ #define DA_TOK CMD_MAC_BASE_TOK + 2 /* cmd_mac2 - define alias (LF) **NI** */ #define HI_TOK CMD_MAC_BASE_TOK + 3 /* cmd_mac3 - list history (LF) **NI** */ #define DO_TOK CMD_MAC_BASE_TOK + 4 /* cmd_mac4 - do history (OF) **NI** */ #define MF_TOK CMD_MEM_BASE_TOK + 1 /* cmd_mem1 - memory fill (LF) */ #define MV_TOK CMD_MEM_BASE_TOK + 2 /* cmd_mem2 - memory move (LF) */ #define MS_TOK CMD_MEM_BASE_TOK + 3 /* cmd_mem3 - memory search (LF) */ #define MD_TOK CMD_MEM_BASE_TOK + 4 /* cmd_mem4 - memory display (SF) */ #define MM_TOK CMD_MEM_BASE_TOK + 5 /* cmd_mem5 - memory modify (LF) */ #ifdef BB_BE #define MDB_TOK CMD_MEM_BASE_TOK +14 /* Memory Display Byte */ #define MDS_TOK CMD_MEM_BASE_TOK +15 /* Memory Display Short */ #define MDL_TOK CMD_MEM_BASE_TOK +16 /* Memory Display Long */ #define MEB_TOK CMD_MEM_BASE_TOK +17 /* Memory Edit Byte */ #define MES_TOK CMD_MEM_BASE_TOK +18 /* Memory Edit Short */ #define MEL_TOK CMD_MEM_BASE_TOK +19 /* Memory Edit Long */ #define MFB_TOK CMD_MEM_BASE_TOK +20 /* Memory Fill Byte */ #define MFS_TOK CMD_MEM_BASE_TOK +21 /* Memory Fill Short */ #define MFL_TOK CMD_MEM_BASE_TOK +22 /* Memory Fill Long */ #define MVB_TOK CMD_MEM_BASE_TOK +23 /* Memory Move Byte */ #define MVS_TOK CMD_MEM_BASE_TOK +24 /* Memory Move Short */ #define MVL_TOK CMD_MEM_BASE_TOK +25 /* Memory Move Long */ #endif /*BB_BE*/ #define COMMA_TOK SYMBOL_BASE_TOK + 1 /* symbol1 - the comma (,) symbol */ #define DASH_TOK SYMBOL_BASE_TOK + 2 /* symbol2 - the dash(-) symbol */ #define SEMI_TOK SYMBOL_BASE_TOK + 3 /* symbol3 - the semi-colon symbol */ #define EOL_TOK SYMBOL_BASE_TOK + 4 /* symbol4 - the end of line symbol */ #define PERIOD_TOK SYMBOL_BASE_TOK + 5 /* symbol5 - the period(.) symbol */ #define PLUS_TOK SYMBOL_BASE_TOK + 6 /* symbol6 - exit from memory modify */ #define EXIT_TOK SYMBOL_BASE_TOK + 7 /* symbol7 - exit from memory modify */ #define BOTH_TOK SYMBOL_BASE_TOK + 8 /* symbol8 - to select both serial ports */ #define HOST_TOK SYMBOL_BASE_TOK + 9 /* symbol9 - to select only the host port */ #define KEY_TOK SYMBOL_BASE_TOK + 10 /* symbol10 - to select only the keyboard port */ #define QUEST_TOK SYMBOL_BASE_TOK + 11 /* symbol11 - the question mark (?) symbol */ #define FL_TOK SYMBOL_BASE_TOK + 12 /* symbol12 - 'fl' for dl cmd (flash programming) */ #define OFFSET_TOK SYMBOL_BASE_TOK + 13 /* symbol13 - 'o' for dl cmd (flash programming offset */ #define ERASE_TOK SYMBOL_BASE_TOK + 14 /* symbol14 - 'e' for dl cmd (flash chip erase */ #define SECTOR_PROTECT_TOK SYMBOL_BASE_TOK + 15 /* symbol15 - 'sp' for sector protect */ #define SECTOR_UNPROTECT_TOK SYMBOL_BASE_TOK + 16 /* symbol16 - 'su' for sector unprotect */ #define SECTOR_ERASE_TOK SYMBOL_BASE_TOK + 17 /* symbol17 - 'se' for sector erase */ #define FLASH_COPY_TOK SYMBOL_BASE_TOK + 18 /* symbol18 - 'cp' for flash copy */ #define SECTOR_NUMBER_TOK SYMBOL_BASE_TOK + 19 /* symbol19 - 'n' for sector number */ #define SECTOR_DISPLAY_TOK SYMBOL_BASE_TOK + 20 /* symbol20 - 'dsi' for display sector information */ #define ADDR_TOK PARAMETER_BASE_TOK + 1 /* address parameter */ #define SPR_TOK PARAMETER_BASE_TOK + 2 /* spr list parameter */ #define MNEM_TOK PARAMETER_BASE_TOK + 3 /* mnemonic list parameter */ #define GPRX_TOK PARAMETER_BASE_TOK + 4 /* rx parameter */ #define FPRX_TOK PARAMETER_BASE_TOK + 5 /* fx parameter */ #define VRX_TOK PARAMETER_BASE_TOK + 6 /* vx parameter */ #define VERIFY_TOK PARAMETER_BASE_TOK + 7 /* v parameter */ #define LOOP_TOK PARAMETER_BASE_TOK + 8 /* l parameter */ #define QUICK_TOK PARAMETER_BASE_TOK + 9 /* q parameter */ #define ALL_TOK PARAMETER_BASE_TOK + 10 /* a parameter */ #define SET_TOK PARAMETER_BASE_TOK + 11 /* s parameter */ #define TIME_TOK PARAMETER_BASE_TOK + 12 /* t parameter */ #define INIT_TOK PARAMETER_BASE_TOK + 13 /* i parameter */ #define FPRALL_TOK REG_FP_BASE_TOK + 255 /* reg_fp255 - the whole floating point family */ #define VRALL_TOK REG_V_BASE_TOK + 511 /* reg_v255 - the whole vector family */ #define GPRALL_TOK REG_GEN_BASE_TOK + 255 /* reg_gen255 - the whole general purpose family */ #define MPC106_TOK 4 #define MPC107_TOK 5