Changeset 274fa77 in rtems
- Timestamp:
- Feb 28, 2002, 11:10:39 PM (19 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- a9106e1
- Parents:
- 098cdaf6
- Location:
- c/src/lib/libbsp/m68k/mrm332
- Files:
-
- 4 added
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/m68k/mrm332/ChangeLog
r098cdaf6 r274fa77 1 2002-02-28 Mike Panetta <ahuitzot@mindspring.com> 2 3 * console/sci.c, console/sci.h, 4 console/console.c: Added new SCI driver. 5 * start/start.c: Removed file. 6 * start/start.S: New file, the asm portion of the updated start code. 7 * start/configure.am: Added start.S, removed start.c 8 * startup/start_c.c: New file, the C portion of the updated start code. Contains most of the code that was in the old start.c. 9 * startup/configure.am: Added start_c.c to C_FILES. 10 * include/bsp.h: Added include <rtems/bspIo.h> 11 1 12 2001-11-30 Ralf Corsepius <corsepiu@faw.uni-ulm.de> 2 13 -
c/src/lib/libbsp/m68k/mrm332/console/Makefile.am
r098cdaf6 r274fa77 7 7 PGM = $(ARCH)/console.rel 8 8 9 C_FILES = console.c 9 C_FILES = console.c sci.c 10 10 C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o) 11 12 H_FILES = sci.h 11 13 12 14 OBJS = $(C_O_FILES) -
c/src/lib/libbsp/m68k/mrm332/console/console.c
r098cdaf6 r274fa77 1 1 /* 2 * This file contains the mrm console IO package. 2 * This file contains the generic console driver shell used 3 * by all console drivers using libchip. 3 4 * 4 * COPYRIGHT (c) 1989-1999. 5 * This driver uses the termios pseudo driver. 6 * 7 * COPYRIGHT (c) 1989-1997. 5 8 * On-Line Applications Research Corporation (OAR). 9 * Copyright assigned to U.S. Government, 1994. 6 10 * 7 11 * The license and distribution terms for this file may be … … 12 16 */ 13 17 14 #include <stdlib.h>15 18 #include <bsp.h> 16 19 #include <rtems/libio.h> 20 #include <termios.h> 21 #include "sci.h" 22 //#include "../../../../../../rtems/c/src/lib/libbsp/m68k/opti/console/duart.h" 23 //#include "../../../../../../rtems/c/src/lib/libc/libio_.h" 17 24 18 /* BUFFER_LENGTH must be 2^n for n=1, 2, 3, .... */ 19 #define BUFFER_LENGTH 256 20 #define RTS_STOP_SIZE BUFFER_LENGTH-64 21 #define RTS_START_SIZE 16 22 23 char xmt_buf[BUFFER_LENGTH]; 24 char rcv_buf[BUFFER_LENGTH]; 25 /* in: last entry into the buffer; always on a valid character */ 26 /* out: points to the next character to be pull from the buffer */ 27 /* in+1=out => buffer empty */ 28 /* in+2=out => buffer full */ 29 struct UART_buf { 30 char *offset; 31 char *in; 32 char *out; 33 }; 34 static volatile struct UART_buf xmt = { xmt_buf, (char *)0, (char *)1}; 35 static volatile struct UART_buf rcv = { rcv_buf, (char *)0, (char *)1}; 36 static volatile char _debug_flag = 0; 37 38 #if 0 39 #define SET_RTS(a) {*PORTF0 = (*PORTF0 & ~0x4) | ( (a)? 0 : 0x4); } 40 #define GET_CTS (!(*PORTF0 & 0x2)) 41 #else 42 #define SET_RTS(a) {;} 43 #define GET_CTS 1 44 #endif 45 46 /* _catchSCIint, _catchCTSint, and _catchSPURIOUSint are the 47 interrupt front-ends */ 48 extern void _catchSCIint(); 49 asm(" .text 50 .align 2 51 .globl _catchSCIint 52 _catchSCIint: 53 moveml %d0-%d7/%a0-%a6,%sp@- /* save registers */ 54 jbsr uart_interrupt 55 moveml %sp@+,%d0-%d7/%a0-%a6 56 rts 57 "); 58 59 extern void _catchCTSint(); 60 asm(" .text 61 .align 2 62 .globl _catchCTSint 63 _catchCTSint: 64 moveml %d0-%d7/%a0-%a6,%sp@- /* save registers */ 65 jbsr cts_interrupt 66 moveml %sp@+,%d0-%d7/%a0-%a6 67 rts 68 "); 69 70 extern void _catchSPURIOUSint(); 71 asm(" .text 72 .align 2 73 .globl _catchSPURIOUSint 74 _catchSPURIOUSint: 75 moveml %d0-%d7/%a0-%a6,%sp@- /* save registers */ 76 jbsr spurious_interrupt 77 moveml %sp@+,%d0-%d7/%a0-%a6 78 rts 79 "); 80 81 int _spurious_int_counter=0; 82 83 /* note: cts uses int1. If it "bounces", a spurious interrupt is generated */ 84 void spurious_interrupt(void) { 85 _spurious_int_counter++; /* there should never be alot of these */ 86 } 87 88 /* _fake_trap_1 will continue the UART interrupt (%sr *still* 89 UART_ISR_LEVEL) as a trap #1 to enter the debugger */ 90 91 /* *****fix me; this is for 68000 w/jsr ram exception table ******* */ 92 asm(" .text 93 .align 2 94 _fake_trap_1: 95 unlk %a6 /* clear interrupt frame */ 96 lea %sp@(4),%sp /* remove jbsr instruction */ 97 moveml %sp@+,%d0-%d7/%a0-%a6 /* pop registers */ 98 jmp (33*6-12) /* jump exception 1 */ 99 "); 100 101 /* dispatch UART interrupt */ 102 void xmit_interrupt(void); 103 void rcvr_interrupt(void); 104 void _fake_trap_1(void); 105 106 void uart_interrupt(void) { 107 /* receiver status bits are cleared by a SCSR read followed 108 by a SCDR read. transmitter status bits are cleared by 109 a SCSR read followed by a SCDR write. */ 110 if ((*SCSR) & (TDRE | TC)) 111 xmit_interrupt(); 112 113 if ((*SCSR) & (RDRF)) 114 rcvr_interrupt(); 115 116 if (_debug_flag) { 117 _debug_flag = 0; /* reset the flag */ 118 _fake_trap_1(); /* fake a trap #1 */ 119 } 120 } 121 122 /* transfer received character to the buffer */ 123 void rcvr_interrupt(void) { 124 register char *a, c; 125 register int length; 126 127 while((*SCSR) & (RDRF)) { 128 if ((c=*SCDR) == 0x1a) /* use ctl-z to reboot */ 129 reboot(); 130 /* else if (c == 0x03) { */ /* use ctl-c to enter debugger */ 131 /* _debug_flag = 1; */ 132 /* continue; */ 133 /* } */ 134 135 *(char *)((int)rcv.offset +(int) 136 (a=(char *)(((int)rcv.in+1) & ((int)BUFFER_LENGTH-1)))) = c; 137 if ((char *)(((int)rcv.in+2) & ((int)BUFFER_LENGTH-1)) != rcv.out) 138 rcv.in=a; 139 }; 140 141 length = (BUFFER_LENGTH -1) & ( 142 ( ((int)rcv.out <= (int)rcv.in) ? 0 : BUFFER_LENGTH) - (int)rcv.out 143 + (int)rcv.in + 1); 144 if (length >= RTS_STOP_SIZE) 145 SET_RTS(0); 146 } 147 148 /* tranfer buffered characters to the UART */ 149 void xmit_interrupt(void) { 150 register short int oldsr; 151 152 _CPU_ISR_Disable( oldsr ); /* for when outbyte or flush calls */ 153 while ((*SCSR) & (TDRE)) { 154 if ((char *)(((int)xmt.in+1) & ((int)BUFFER_LENGTH-1)) != xmt.out) 155 /* xmit buffer not empty */ 156 if (GET_CTS) { 157 /* send next char */ 158 *SCDR=*(char *)((int)xmt.offset+(int)xmt.out); 159 xmt.out= (char *)(((int)xmt.out+1) & ((int)BUFFER_LENGTH-1)); 160 *SCCR1 = (*SCCR1 & ~(TIE | TCIE)) | (TIE); 161 } 162 else { 163 /* configue CTS interrupt and shutdown xmit interrupts */ 164 *SCCR1 &= ~(TIE | TCIE); 165 *PFPAR |= 0x2; 166 break; 167 } 168 else { 169 /* xmit buffer empty; shutdown interrupts */ 170 *SCCR1 &= ~(TIE | TCIE); 171 break; 172 } 173 } 174 _CPU_ISR_Enable( oldsr ); 175 } 176 177 void cts_interrupt(void) { 178 register short int oldsr; 179 180 _CPU_ISR_Disable( oldsr ); /* for when outbyte calls */ 181 182 *PFPAR &= ~0x2; 183 *SCCR1 = (*SCCR1 & ~(TIE | TCIE)) | (TIE); 184 185 _CPU_ISR_Enable( oldsr ); 186 } 187 188 189 190 /* transfer character from the buffer */ 191 char inbyte(void) { 192 register char a; 193 register int length; 194 195 while ((char *)(((int)rcv.in+1) & ((int)BUFFER_LENGTH-1))== rcv.out); 196 a=*(char *)((int)rcv.offset+(int)rcv.out); 197 rcv.out= (char *)(((int)rcv.out+1) & ((int)BUFFER_LENGTH-1)); 198 length = (BUFFER_LENGTH -1) & ( 199 ( ((int)rcv.out <= (int)rcv.in) ? 0 : BUFFER_LENGTH) - (int)rcv.out 200 + (int)rcv.in + 1); 201 if (length < RTS_START_SIZE) 202 SET_RTS(1); 203 return (a); 204 } 205 206 /* once room is avaliable in the buffer, transfer 207 the character into the buffer and enable 208 the xmtr interrupt */ 209 void outbyte(char c) { 210 register char *a; 211 212 while ((char *)(((int)xmt.in+2) & ((int)BUFFER_LENGTH-1)) == xmt.out); 213 *(char *)((int)xmt.offset+(int) 214 (a=(char *)(((int)xmt.in+1) & ((int)BUFFER_LENGTH-1))))=c; 215 xmt.in=a; 216 217 if (!(*SCCR1 & (TIE | TCIE)) && (!(*PFPAR & 0x2)) ) 218 /* if neither interrupts are running, */ 219 xmit_interrupt(); /* we need to restart the xmiter */ 220 } 221 222 void _UART_flush(void) { 223 /* loop till xmt buffer empty. Works with interrupts disabled */ 224 while ((char *)(((int)xmt.in+1) & ((int)BUFFER_LENGTH-1)) != xmt.out) 225 xmit_interrupt(); 226 /* loop till UART buffer empty */ 227 while ( (*SCSR & TC) == 0 ); 228 } 229 230 /* console_initialize 25 /*PAGE 231 26 * 232 * This routine initializes the console IO driver.27 * console_open 233 28 * 234 * Input parameters: NONE29 * open a port as a termios console. 235 30 * 236 * Output parameters: NONE31 * the console is opened in bsp_postdriver_hook() in bsppost.c 237 32 * 238 * Return values:239 */240 241 void console_init()242 {243 *QSMCR = ( SAM(QSM_IARB,0,IARB) );244 *QILR = ( SAM(ISRL_QSPI,4,ILQSPI) | SAM(ISRL_SCI,0,ILSCI) );245 *QIVR = ( SAM(EFI_QIVR,0,INTV) );246 247 *SCCR0 = ( (int)( SYS_CLOCK/SCI_BAUD/32.0+0.5 ) & 0x1fff );248 *SCCR1 = ( RIE | TE | RE );249 250 set_vector(_catchSPURIOUSint, EFI_SPINT, 1);251 set_vector(_catchSCIint, EFI_QIVR, 1);252 /* set_vector(_catchCTSint, EFI_INT1, 1); */253 }254 255 rtems_device_driver console_initialize(256 rtems_device_major_number major,257 rtems_device_minor_number minor,258 void *arg259 )260 {261 rtems_status_code status;262 263 status = rtems_io_register_name(264 "/dev/console",265 major,266 (rtems_device_minor_number) 0267 );268 269 if (status != RTEMS_SUCCESSFUL)270 rtems_fatal_error_occurred(status);271 272 return RTEMS_SUCCESSFUL;273 }274 275 /* is_character_ready276 *277 * This routine returns TRUE if a character is available.278 *279 * Input parameters: NONE280 *281 * Output parameters: NONE282 *283 * Return values:284 33 */ 285 34 286 rtems_boolean is_character_ready(287 char *ch288 )289 {290 if ((char *)(((int)rcv.in+1) & ((int)BUFFER_LENGTH-1))== rcv.out)291 return(FALSE);292 else293 return(TRUE);294 }295 296 /*297 * Open entry point298 */299 300 35 rtems_device_driver console_open( 301 36 rtems_device_major_number major, … … 304 39 ) 305 40 { 306 return RTEMS_SUCCESSFUL; 41 rtems_status_code status; 42 43 /* the console is opened three times at startup */ 44 /* for standard input, output, and error */ 45 46 /* Get correct callback structure for the device */ 47 48 /* argument of FALSE gives us interrupt driven serial io */ 49 /* argument of TRUE gives us polling based serial io */ 50 51 /* SCI internal uart */ 52 53 status = rtems_termios_open( major, minor, arg, SciGetTermiosHandlers( TRUE ) ); 54 55 return status; 307 56 } 308 57 309 /* 310 * Close entry point 58 /*PAGE 59 * 60 * console_close 61 * 62 * This routine closes a port that has been opened as console. 311 63 */ 312 64 313 65 rtems_device_driver console_close( 314 66 rtems_device_major_number major, … … 317 69 ) 318 70 { 319 return RTEMS_SUCCESSFUL;71 return rtems_termios_close (arg); 320 72 } 321 73 322 /* 323 * read bytes from the serial port. We only have stdin. 74 /*PAGE 75 * 76 * console_read 77 * 78 * This routine uses the termios driver to read a character. 324 79 */ 325 80 326 81 rtems_device_driver console_read( 327 82 rtems_device_major_number major, … … 330 85 ) 331 86 { 332 rtems_libio_rw_args_t *rw_args; 333 char *buffer; 334 int maximum; 335 int count; 336 337 rw_args = (rtems_libio_rw_args_t *) arg; 338 339 buffer = rw_args->buffer; 340 maximum = rw_args->count; 341 342 for (count = 0; count < maximum; count++) { 343 buffer[ count ] = inbyte(); 344 if (buffer[ count ] == '\n' || buffer[ count ] == '\r') { 345 buffer[ count++ ] = '\n'; 346 break; 347 } 348 } 349 350 rw_args->bytes_moved = count; 351 return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED; 87 return rtems_termios_read (arg); 352 88 } 353 89 354 /* 355 * write bytes to the serial port. Stdout and stderr are the same. 90 /*PAGE 91 * 92 * console_write 93 * 94 * this routine uses the termios driver to write a character. 356 95 */ 357 96 358 97 rtems_device_driver console_write( 359 98 rtems_device_major_number major, … … 362 101 ) 363 102 { 364 int count; 365 int maximum; 366 rtems_libio_rw_args_t *rw_args; 367 char *buffer; 368 369 rw_args = (rtems_libio_rw_args_t *) arg; 370 371 buffer = rw_args->buffer; 372 maximum = rw_args->count; 373 374 for (count = 0; count < maximum; count++) { 375 if ( buffer[ count ] == '\n') { 376 outbyte('\r'); 377 } 378 outbyte( buffer[ count ] ); 379 } 380 381 rw_args->bytes_moved = maximum; 382 return 0; 103 return rtems_termios_write (arg); 383 104 } 384 105 385 /* 386 * IO Control entry point 106 /*PAGE 107 * 108 * console_control 109 * 110 * this routine uses the termios driver to process io 387 111 */ 388 112 389 113 rtems_device_driver console_control( 390 114 rtems_device_major_number major, … … 393 117 ) 394 118 { 119 return rtems_termios_ioctl (arg); 120 } 121 122 /*PAGE 123 * 124 * console_initialize 125 * 126 * Routine called to initialize the console device driver. 127 */ 128 129 rtems_device_driver console_initialize( 130 rtems_device_major_number major, 131 rtems_device_minor_number minor_arg, 132 void *arg 133 ) 134 { 135 rtems_status_code status; 136 137 /* 138 * initialize the termio interface. 139 */ 140 rtems_termios_initialize(); 141 142 143 /* 144 * register the SCI device name for termios 145 * do this over in the sci driver init routine? 146 */ 147 148 status = rtems_io_register_name( "/dev/sci", major, 0 ); 149 150 if (status != RTEMS_SUCCESSFUL) 151 { 152 rtems_fatal_error_occurred(status); 153 } 154 155 156 /* 157 * Link the uart device to the console device 158 */ 159 160 #if 1 161 status = rtems_io_register_name( "/dev/console", major, 0 ); 162 163 if (status != RTEMS_SUCCESSFUL) 164 { 165 rtems_fatal_error_occurred(status); 166 } 167 #else 168 if ( link( "/dev/sci", "/dev/console") < 0 ) 169 { 170 rtems_fatal_error_occurred( RTEMS_IO_ERROR ); 171 } 172 #endif 173 174 /* 175 * Console Initialize Succesful 176 */ 177 395 178 return RTEMS_SUCCESSFUL; 396 179 } 397 180 181 -
c/src/lib/libbsp/m68k/mrm332/include/bsp.h
r098cdaf6 r274fa77 23 23 24 24 #include <rtems.h> 25 #include <rtems/bspIo.h> 25 26 #include <clockdrv.h> 26 27 #include <console.h> … … 36 37 */ 37 38 39 #define CONSOLE_SCI 38 40 /* #define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 2 */ 39 41 /* #define CONFIGURE_INTERRUPT_STACK_MEMORY (TBD * 1024) */ … … 103 105 #define RAW_PUTS(str) \ 104 106 { register char *ptr = str; \ 105 while (*ptr) outbyte(*ptr++); \107 while (*ptr) SCI_output_char(*ptr++); \ 106 108 } 107 109 … … 112 114 for (i=28;i>=0;i -= 4) { \ 113 115 j = (n>>i) & 0xf; \ 114 outbyte( (j>9 ? j-10+'a' : j+'0') ); \116 SCI_output_char( (j>9 ? j-10+'a' : j+'0') ); \ 115 117 } \ 116 118 } -
c/src/lib/libbsp/m68k/mrm332/include/mrm332.h
r098cdaf6 r274fa77 34 34 #define XTAL 32768.0 /* crystal frequency in Hz */ 35 35 36 #if 036 #if 1 37 37 /* Default MRM clock rate (8.388688 MHz) set by CPU32: */ 38 38 #define MRM_W 0 /* system clock parameters */ … … 48 48 #endif 49 49 50 #if 150 #if 0 51 51 /* 25.16582 MHz: */ 52 52 #define MRM_W 1 /* system clock parameters */ … … 61 61 /* macros/functions */ 62 62 63 #ifndef ASM 64 63 65 /* 64 66 * This prototype really should have the noreturn attribute but … … 69 71 __inline__ static void reboot() {asm("trap #15; .word 0x0063");} 70 72 73 #endif /* ASM */ 74 71 75 #endif /* _MRM_H_ */ -
c/src/lib/libbsp/m68k/mrm332/spurious/spinit.c
r098cdaf6 r274fa77 34 34 ) 35 35 { 36 int sp = 0;36 //int sp = 0; 37 37 const char * const VectDescrip[] = { 38 38 _Spurious_Error_[0], _Spurious_Error_[0], _Spurious_Error_[1], … … 59 59 _Spurious_Error_[27], _Spurious_Error_[28]}; 60 60 61 asm volatile ( "movea.l %%sp,%0 " : "=a" (sp) : "0" (sp) );61 //asm volatile ( "movea.l %%sp,%0 " : "=a" (sp) : "0" (sp) ); 62 62 63 63 _CPU_ISR_Set_level( 7 ); 64 _UART_flush();65 64 //_UART_flush(); 65 #if 0 66 66 RAW_PUTS("\n\rRTEMS: Spurious interrupt: "); 67 67 RAW_PUTS((char *)VectDescrip[( (vector>64) ? 64 : vector )]); … … 71 71 RAW_PUTI(sp); 72 72 RAW_PUTS("\n\r"); 73 73 #endif 74 74 bsp_cleanup(); 75 75 -
c/src/lib/libbsp/m68k/mrm332/start/Makefile.am
r098cdaf6 r274fa77 7 7 PGM = $(ARCH)/start.o 8 8 9 C_FILES = start.c 10 C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o)9 S_FILES = start.S 10 S_O_FILES = $(S_FILES:%.S=$(ARCH)/%.o) 11 11 12 OBJS = $( C_O_FILES)12 OBJS = $(S_O_FILES) 13 13 14 14 include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg … … 29 29 .PRECIOUS: $(PGM) 30 30 31 EXTRA_DIST = start. c31 EXTRA_DIST = start.S 32 32 33 33 include $(top_srcdir)/../../../../../../automake/local.am -
c/src/lib/libbsp/m68k/mrm332/startup/Makefile.am
r098cdaf6 r274fa77 9 9 PGM = $(ARCH)/startup.rel 10 10 11 C_FILES = bsplibc.c bsppost.c bspstart.c bspclean.c bootcard.c \11 C_FILES = start_c.c bsplibc.c bsppost.c bspstart.c bspclean.c bootcard.c \ 12 12 m68kpretaskinghook.c main.c sbrk.c setvec.c gnatinstallhandler.c 13 13 C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o) -
c/src/lib/libbsp/m68k/mrm332/startup/bspclean.c
r098cdaf6 r274fa77 24 24 /* interrupt driven stdio must be flushed */ 25 25 _CPU_ISR_Set_level( 7 ); 26 _UART_flush();26 //_UART_flush(); 27 27 } -
c/src/lib/libbsp/m68k/mrm332/startup/linkcmds
r098cdaf6 r274fa77 35 35 */ 36 36 _RamBase = DEFINED(_RamBase) ? _RamBase : 0x03000; 37 _RamSize = DEFINED(_RamSize) ? _RamSize : 0x 80000;37 _RamSize = DEFINED(_RamSize) ? _RamSize : 0x7d000; 38 38 _RamEnd = _RamBase + _RamSize; 39 39 _HeapSize = DEFINED(_HeapSize) ? _HeapSize : 0x10000; 40 _StackSize = DEFINED(_StackSize) ? _StackSize : 0x 1000;40 _StackSize = DEFINED(_StackSize) ? _StackSize : 0x2000; 41 41 42 42 MEMORY
Note: See TracChangeset
for help on using the changeset viewer.