/* * Test converting baud rate into an index */ void test_termios_baud2index(void) { int i; int index; puts( "\n" "Test termios_baud2index..." ); puts( "termios_baud_to_index(-2) - NOT OK" ); i = rtems_termios_baud_to_index( -2 ); rtems_test_assert( i == -1 ); puts( "termios_baud_to_index(572) - NOT OK" ); i = rtems_termios_baud_to_index( -2 ); rtems_test_assert( i == -1 ); if ( i != -1 ) for (i=0 ; baud_table[i].constant != -1 ; i++ ) { printf( "termios_baud_to_index(B%" PRIdrtems_termios_baud_t ") - OK\n", baud_table[i].baud ); index = rtems_termios_baud_to_index( baud_table[i].constant ); if ( index != i ) { printf( "ERROR - returned %d should be %d\n", index, i ); rtems_test_exit(0); } } }
MC68681_STATIC int mc68681_baud_rate( int minor, int baud, unsigned int *baud_mask_p, unsigned int *acr_bit_p, unsigned int *command ) { unsigned int baud_mask; unsigned int acr_bit; int status; int is_extended; int baud_requested; mc68681_baud_table_t *baud_tbl; baud_mask = 0; acr_bit = 0; status = 0; if (Console_Port_Tbl[minor]->ulDataPort & MC68681_DATA_BAUD_RATE_SET_2) { acr_bit = 1; } is_extended = 0; switch (Console_Port_Tbl[minor]->ulDataPort & MC68681_XBRG_MASK) { case MC68681_XBRG_IGNORED: *command = 0x00; break; case MC68681_XBRG_ENABLED: *command = 0x80; is_extended = 1; break; case MC68681_XBRG_DISABLED: *command = 0x90; break; } baud_requested = baud & CBAUD; if (!baud_requested) baud_requested = B9600; /* default to 9600 baud */ baud_requested = rtems_termios_baud_to_index( baud_requested ); baud_tbl = (mc68681_baud_table_t *) ((uintptr_t)Console_Port_Tbl[minor]->ulClock); if (!baud_tbl) rtems_fatal_error_occurred(RTEMS_INVALID_ADDRESS); if ( is_extended ) baud_mask = (unsigned int)baud_tbl[ acr_bit + 2 ][ baud_requested ]; else baud_mask = baud_tbl[ acr_bit ][ baud_requested ]; if ( baud_mask == MC68681_BAUD_NOT_VALID ) status = -1; /* * upper nibble is receiver and lower nibble is transmitter */ *baud_mask_p = (baud_mask << 4) | baud_mask; *acr_bit_p = acr_bit; return status; }