/* 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. */ /* 1 2 3 4 5 6 7 8 01234567890123456789012345678901234567890123456789012345678901234567890123456789 */ #include "errors.h" #ifdef ON_BOARD #include "config.h" #include "board.h" #endif /* this helps to clear up the external and internal references to the variables used in the DUART_TB */ #ifdef IN_DUART_TB #define WHERE #else #define WHERE extern #endif #ifndef ON_BOARD /* the buffer size needs to be chosen so that the pointers can be "ANDed" with the size and essentially modulo the value so the constraint could be stated as x mod size = x and size we are essentially dealing with a masking value here that will constrain the effective range of the long offsets into the buffers yet still make the comparason between the xx_in <= xx_out valid forever. What this means is the xx_out and xx_in indicies into the buffers will increment "forever" while the buffers can still be restricted to a manageable size. This simple constraint will allow for much easier programming later. See the source for get_char() if you are not convinced */ #define DUART_BUFFER_SIZE 0x3fff /* first lets define the keyboard buffer this should be the same size as the host buffer. We also need an input pointer and and output pointer for both. The host is defined next. */ WHERE char keyboard_buffer[DUART_BUFFER_SIZE]; WHERE unsigned long keyboard_ptr_in; WHERE unsigned long keyboard_ptr_out; WHERE char host_buffer[DUART_BUFFER_SIZE]; WHERE unsigned long host_ptr_in; WHERE unsigned long host_ptr_out; #define KEYBOARD 0x80000000 /* MC68681 DUART CHANNEL A */ #define HOST 0x80000040 /* MC68681 DUART CHANNEL B */ /* DUART REGISTER OFFSETS */ #define MR1X 0x0 /* mode register 1 */ #define MR2X 0x0 /* mode register 2 */ #define SRX 0x8 /* status register */ #define CSRX 0x8 /* clock-select register */ #define CRX 0x10 /* command register */ #define RBX 0x18 /* receive buffer */ #define TBX 0x18 /* transmitter buffer */ #define IPCR 0x20 /* input port change register */ #define ACR 0x20 /* auxillary contol register */ #define ISR 0x28 /* interrupt status register */ #define IMR 0x28 /* interrupt mask register */ #define CMSB 0x30 /* counter most significant byte */ #define CTUR 0x30 /* counter/timer upper register */ #define CLSB 0x38 /* counter least significant register */ #define CTLR 0x38 /* counter/timer lower register */ #define IVR 0x60 /* interrupt vector register */ #define IP 0x68 /* input port */ #define OPCR 0x68 /* output port configuration register */ #define STRC 0x70 /* start counter command */ #define BTST 0x70 /* bit set command */ #define STPC 0x78 /* stop counter command */ #define BTRST 0x78 /* bit reset command */ #endif WHERE unsigned long in_transparent_mode; /* this definition will tell DINK which configuration to use : 3 - both the keyboard and host ports 2 - only the host port 1 - only the keyboard port The defines will help in writing code... */ WHERE unsigned long duart_configuration; /* This tells us whether or not to echo characters out the host port. */ WHERE char logging_enabled; #define BOTH_PORTS 3 #define HOST_PORT 2 #define KEY_PORT 1 /* These are defines for setting the baud rate in bb.h to different rates... basically used as flags!! */ #ifdef ON_BOARD #define BAUD_2400 1 #define BAUD_4800 2 #define BAUD_9600 3 #define BAUD_19200 4 #define BAUD_28800 5 #define BAUD_38400 6 #define BAUD_57600 7 #endif /* these defines will allow the user to tell the get_char routine where to go to get the next character. The values of the defines are not important but they MUST ALWAYS be DIFFERENT */ /* here are the functions that we have to date */ #ifndef IN_DUART_TB WHERE char get_char(); WHERE void duart_initialize(); WHERE void get_a_line(); WHERE STATUS write_to_duart(); WHERE STATUS read_from_duart(); WHERE int is_char_in_duart(); WHERE STATUS transparant_mode(); #endif /* Matt added these for interrupt driven get_char and put_char routines... */ /* Buffer size for input/output buffers */ #ifdef ON_BOARD #define MAX_INTERRUPT_BUFFER 512 WHERE void mader_get_char_for_int(); WHERE int int_buf_key_index_fill; WHERE int int_buf_host_index_fill; WHERE int int_buf_key_index_empty; WHERE int int_buf_host_index_empty; #endif /* These are used as character definitions when I'm looking for specific characters (like escape chars) */ /* Define ^c. I look for this character to interrupt some process that running on the board and return to DINK. */ #define INT_CHAR 0x3 /* Define "esc". I look for this character to interrupt the transparent mode. When someone hits this, I return to the DINK main loop. */ #define TM_BREAK 0x1 /* ^a will exit from transparent mode */ #define TM_CTEST_EN 0x3 /* ^c will exit from transparent mode and enter the test suite. Another ^c will exit the test suite. */ /* this is used for closure of the external/internal definitions. */ #undef WHERE extern int CommGetChar(); extern STATUS put_ram_in_wt(); extern STATUS cache_inhibit(); extern void mem_write_long(); extern long mem_read_long(); extern void mem_write_char(); extern char mem_read_char();