[cd58d82] | 1 | /* |
---|
| 2 | * This file contains the termios TTY driver for the Motorola MC68681. |
---|
| 3 | * |
---|
| 4 | * This part is available from a number of secondary sources. |
---|
| 5 | * In particular, we know about the following: |
---|
| 6 | * |
---|
| 7 | * + Exar 88c681 and 68c681 |
---|
| 8 | * |
---|
| 9 | * COPYRIGHT (c) 1989-1998. |
---|
| 10 | * On-Line Applications Research Corporation (OAR). |
---|
| 11 | * Copyright assigned to U.S. Government, 1994. |
---|
| 12 | * |
---|
| 13 | * The license and distribution terms for this file may be |
---|
| 14 | * found in the file LICENSE in this distribution or at |
---|
| 15 | * http://www.OARcorp.com/rtems/license.html. |
---|
| 16 | * |
---|
| 17 | * $Id$ |
---|
| 18 | */ |
---|
| 19 | |
---|
| 20 | #include <rtems.h> |
---|
| 21 | #include <rtems/libio.h> |
---|
| 22 | #include <stdlib.h> |
---|
| 23 | #include <ringbuf.h> |
---|
| 24 | |
---|
| 25 | #include <libchip/serial.h> |
---|
[2d8e51aa] | 26 | #include "sersupp.h" |
---|
[cd58d82] | 27 | #include "mc68681_p.h" |
---|
[ab2dbd7] | 28 | #include "mc68681.h" |
---|
[cd58d82] | 29 | |
---|
| 30 | /* |
---|
| 31 | * Flow control is only supported when using interrupts |
---|
| 32 | */ |
---|
[424e23ee] | 33 | |
---|
[cd58d82] | 34 | console_fns mc68681_fns = |
---|
| 35 | { |
---|
| 36 | mc68681_probe, /* deviceProbe */ |
---|
| 37 | mc68681_open, /* deviceFirstOpen */ |
---|
| 38 | mc68681_flush, /* deviceLastClose */ |
---|
| 39 | NULL, /* deviceRead */ |
---|
| 40 | mc68681_write_support_int, /* deviceWrite */ |
---|
| 41 | mc68681_initialize_interrupts, /* deviceInitialize */ |
---|
| 42 | mc68681_write_polled, /* deviceWritePolled */ |
---|
[25c3ff91] | 43 | mc68681_set_attributes, /* deviceSetAttributes */ |
---|
[cd58d82] | 44 | FALSE, /* deviceOutputUsesInterrupts */ |
---|
| 45 | }; |
---|
| 46 | |
---|
| 47 | console_fns mc68681_fns_polled = |
---|
| 48 | { |
---|
| 49 | mc68681_probe, /* deviceProbe */ |
---|
| 50 | mc68681_open, /* deviceFirstOpen */ |
---|
| 51 | mc68681_close, /* deviceLastClose */ |
---|
| 52 | mc68681_inbyte_nonblocking_polled, /* deviceRead */ |
---|
| 53 | mc68681_write_support_polled, /* deviceWrite */ |
---|
| 54 | mc68681_init, /* deviceInitialize */ |
---|
| 55 | mc68681_write_polled, /* deviceWritePolled */ |
---|
[25c3ff91] | 56 | mc68681_set_attributes, /* deviceSetAttributes */ |
---|
[cd58d82] | 57 | FALSE, /* deviceOutputUsesInterrupts */ |
---|
| 58 | }; |
---|
| 59 | |
---|
| 60 | extern void set_vector( rtems_isr_entry, rtems_vector_number, int ); |
---|
| 61 | |
---|
| 62 | /* |
---|
| 63 | * Console Device Driver Entry Points |
---|
| 64 | */ |
---|
[424e23ee] | 65 | |
---|
[beaaf49f] | 66 | /* |
---|
| 67 | * mc68681_probe |
---|
| 68 | * |
---|
| 69 | * Default probe routine which simply say the port is present. |
---|
| 70 | */ |
---|
| 71 | |
---|
[2d8e51aa] | 72 | MC68681_STATIC boolean mc68681_probe(int minor) |
---|
[cd58d82] | 73 | { |
---|
| 74 | /* |
---|
[ab2dbd7] | 75 | * If the configuration dependent probe has located the device then |
---|
[cd58d82] | 76 | * assume it is there |
---|
| 77 | */ |
---|
| 78 | return(TRUE); |
---|
| 79 | } |
---|
| 80 | |
---|
[beaaf49f] | 81 | /* |
---|
| 82 | * mc68681_baud_rate |
---|
| 83 | * |
---|
| 84 | * This routine returns the proper ACR bit and baud rate field values |
---|
| 85 | * based on the requested baud rate. The baud rate set to be used |
---|
| 86 | * must be configured by the user. |
---|
| 87 | */ |
---|
| 88 | |
---|
[2d8e51aa] | 89 | /* major index of 0 : ACR[7] = 0, X = 0 -- 68c681 only has these */ |
---|
| 90 | /* major index of 1 : ACR[7] = 1, X = 0 -- 68c681 only has these */ |
---|
| 91 | /* major index of 2 : ACR[7] = 0, X = 1 */ |
---|
| 92 | /* major index of 3 : ACR[7] = 1, X = 1 */ |
---|
| 93 | |
---|
| 94 | /* mc68681_baud_table_t mc68681_baud_rate_table[4] = { */ |
---|
| 95 | mc68681_baud_t mc68681_baud_rate_table[4][RTEMS_TERMIOS_NUMBER_BAUD_RATES] = { |
---|
| 96 | { /* ACR[7] = 0, X = 0 */ |
---|
| 97 | MC68681_BAUD_NOT_VALID, /* B0 */ |
---|
| 98 | 0x00, /* B50 */ |
---|
| 99 | MC68681_BAUD_NOT_VALID, /* B75 */ |
---|
| 100 | 0x01, /* B110 */ |
---|
| 101 | 0x02, /* B134 */ |
---|
| 102 | MC68681_BAUD_NOT_VALID, /* B150 */ |
---|
| 103 | 0x03, /* B200 */ |
---|
| 104 | 0x04, /* B300 */ |
---|
| 105 | 0x05, /* B600 */ |
---|
| 106 | 0x06, /* B1200 */ |
---|
| 107 | MC68681_BAUD_NOT_VALID, /* B1800 */ |
---|
| 108 | 0x08, /* B2400 */ |
---|
| 109 | 0x09, /* B4800 */ |
---|
| 110 | 0x0B, /* B9600 */ |
---|
| 111 | MC68681_BAUD_NOT_VALID, /* B19200 */ |
---|
| 112 | 0x0C, /* B38400 */ |
---|
| 113 | MC68681_BAUD_NOT_VALID, /* B57600 */ |
---|
| 114 | MC68681_BAUD_NOT_VALID, /* B115200 */ |
---|
| 115 | MC68681_BAUD_NOT_VALID, /* B230400 */ |
---|
| 116 | MC68681_BAUD_NOT_VALID /* B460800 */ |
---|
| 117 | }, |
---|
| 118 | { /* ACR[7] = 1, X = 0 */ |
---|
| 119 | MC68681_BAUD_NOT_VALID, /* B0 */ |
---|
| 120 | MC68681_BAUD_NOT_VALID, /* B50 */ |
---|
| 121 | 0x00, /* B75 */ |
---|
| 122 | 0x01, /* B110 */ |
---|
| 123 | 0x02, /* B134 */ |
---|
| 124 | 0x03, /* B150 */ |
---|
| 125 | MC68681_BAUD_NOT_VALID, /* B200 */ |
---|
| 126 | 0x04, /* B300 */ |
---|
| 127 | 0x05, /* B600 */ |
---|
| 128 | 0x06, /* B1200 */ |
---|
| 129 | 0x0A, /* B1800 */ |
---|
| 130 | 0x08, /* B2400 */ |
---|
| 131 | 0x09, /* B4800 */ |
---|
| 132 | 0x0B, /* B9600 */ |
---|
| 133 | 0x0C, /* B19200 */ |
---|
| 134 | MC68681_BAUD_NOT_VALID, /* B38400 */ |
---|
| 135 | MC68681_BAUD_NOT_VALID, /* B57600 */ |
---|
| 136 | MC68681_BAUD_NOT_VALID, /* B115200 */ |
---|
| 137 | MC68681_BAUD_NOT_VALID, /* B230400 */ |
---|
| 138 | MC68681_BAUD_NOT_VALID /* B460800 */ |
---|
| 139 | }, |
---|
| 140 | { /* ACR[7] = 0, X = 1 */ |
---|
| 141 | MC68681_BAUD_NOT_VALID, /* B0 */ |
---|
| 142 | MC68681_BAUD_NOT_VALID, /* B50 */ |
---|
| 143 | 0x00, /* B75 */ |
---|
| 144 | 0x01, /* B110 */ |
---|
| 145 | 0x02, /* B134 */ |
---|
| 146 | 0x03, /* B150 */ |
---|
| 147 | MC68681_BAUD_NOT_VALID, /* B200 */ |
---|
| 148 | MC68681_BAUD_NOT_VALID, /* B300 */ |
---|
| 149 | MC68681_BAUD_NOT_VALID, /* B600 */ |
---|
| 150 | MC68681_BAUD_NOT_VALID, /* B1200 */ |
---|
| 151 | 0x0A, /* B1800 */ |
---|
| 152 | MC68681_BAUD_NOT_VALID, /* B2400 */ |
---|
| 153 | 0x08, /* B4800 */ |
---|
| 154 | 0x0B, /* B9600 */ |
---|
| 155 | 0x0C, /* B19200 */ |
---|
| 156 | MC68681_BAUD_NOT_VALID, /* B38400 */ |
---|
| 157 | 0x07, /* B57600 */ |
---|
| 158 | 0x08, /* B115200 */ |
---|
| 159 | MC68681_BAUD_NOT_VALID, /* B230400 */ |
---|
| 160 | MC68681_BAUD_NOT_VALID /* B460800 */ |
---|
| 161 | }, |
---|
| 162 | { /* ACR[7] = 1, X = 1 */ |
---|
| 163 | MC68681_BAUD_NOT_VALID, /* B0 */ |
---|
| 164 | 0x00, /* B50 */ |
---|
| 165 | MC68681_BAUD_NOT_VALID, /* B75 */ |
---|
| 166 | 0x01, /* B110 */ |
---|
| 167 | 0x02, /* B134 */ |
---|
| 168 | MC68681_BAUD_NOT_VALID, /* B150 */ |
---|
| 169 | 0x03, /* B200 */ |
---|
| 170 | MC68681_BAUD_NOT_VALID, /* B300 */ |
---|
| 171 | MC68681_BAUD_NOT_VALID, /* B600 */ |
---|
| 172 | MC68681_BAUD_NOT_VALID, /* B1200 */ |
---|
| 173 | MC68681_BAUD_NOT_VALID, /* B1800 */ |
---|
| 174 | MC68681_BAUD_NOT_VALID, /* B2400 */ |
---|
| 175 | 0x09, /* B4800 */ |
---|
| 176 | 0x0B, /* B9600 */ |
---|
| 177 | MC68681_BAUD_NOT_VALID, /* B19200 */ |
---|
| 178 | 0x0C, /* B38400 */ |
---|
| 179 | 0x07, /* B57600 */ |
---|
| 180 | 0x08, /* B115200 */ |
---|
| 181 | MC68681_BAUD_NOT_VALID, /* B230400 */ |
---|
| 182 | MC68681_BAUD_NOT_VALID /* B460800 */ |
---|
| 183 | }, |
---|
| 184 | }; |
---|
| 185 | |
---|
| 186 | MC68681_STATIC int mc68681_baud_rate( |
---|
[25c3ff91] | 187 | int minor, |
---|
| 188 | int baud, |
---|
| 189 | unsigned int *baud_mask_p, |
---|
[2d8e51aa] | 190 | unsigned int *acr_bit_p, |
---|
| 191 | unsigned int *command |
---|
| 192 | ); |
---|
[25c3ff91] | 193 | |
---|
[beaaf49f] | 194 | /* |
---|
| 195 | * mc68681_set_attributes |
---|
| 196 | * |
---|
| 197 | * This function sets the DUART channel to reflect the requested termios |
---|
| 198 | * port settings. |
---|
| 199 | */ |
---|
| 200 | |
---|
[2d8e51aa] | 201 | MC68681_STATIC int mc68681_set_attributes( |
---|
[25c3ff91] | 202 | int minor, |
---|
| 203 | const struct termios *t |
---|
| 204 | ) |
---|
| 205 | { |
---|
| 206 | unsigned32 pMC68681_port; |
---|
| 207 | unsigned32 pMC68681; |
---|
| 208 | unsigned int mode1; |
---|
| 209 | unsigned int mode2; |
---|
| 210 | unsigned int baud_mask; |
---|
| 211 | unsigned int acr_bit; |
---|
[2d8e51aa] | 212 | unsigned int cmd; |
---|
[25c3ff91] | 213 | setRegister_f setReg; |
---|
| 214 | rtems_interrupt_level Irql; |
---|
[cd58d82] | 215 | |
---|
[4f0ffa57] | 216 | pMC68681 = Console_Port_Tbl[minor].ulCtrlPort1; |
---|
| 217 | pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2; |
---|
[7deeb16] | 218 | setReg = Console_Port_Tbl[minor].setRegister; |
---|
| 219 | |
---|
| 220 | /* |
---|
[25c3ff91] | 221 | * Set the baud rate |
---|
[7deeb16] | 222 | */ |
---|
| 223 | |
---|
[2d8e51aa] | 224 | if (mc68681_baud_rate( minor, t->c_cflag, &baud_mask, &acr_bit, &cmd ) == -1) |
---|
[25c3ff91] | 225 | return -1; |
---|
| 226 | |
---|
| 227 | baud_mask |= baud_mask << 4; |
---|
| 228 | acr_bit <<= 7; |
---|
[7deeb16] | 229 | |
---|
| 230 | /* |
---|
[25c3ff91] | 231 | * Parity |
---|
[7deeb16] | 232 | */ |
---|
| 233 | |
---|
[25c3ff91] | 234 | mode1 = 0; |
---|
| 235 | mode2 = 0; |
---|
[7deeb16] | 236 | |
---|
[25c3ff91] | 237 | if (t->c_cflag & PARENB) { |
---|
| 238 | if (t->c_cflag & PARODD) |
---|
| 239 | mode1 |= 0x04; |
---|
| 240 | else |
---|
| 241 | mode1 |= 0x04; |
---|
| 242 | } else { |
---|
| 243 | mode1 |= 0x10; |
---|
| 244 | } |
---|
[cd58d82] | 245 | |
---|
[25c3ff91] | 246 | /* |
---|
| 247 | * Character Size |
---|
[cd58d82] | 248 | */ |
---|
| 249 | |
---|
[25c3ff91] | 250 | if (t->c_cflag & CSIZE) { |
---|
| 251 | switch (t->c_cflag & CSIZE) { |
---|
| 252 | case CS5: break; |
---|
| 253 | case CS6: mode1 |= 0x01; break; |
---|
| 254 | case CS7: mode1 |= 0x02; break; |
---|
| 255 | case CS8: mode1 |= 0x03; break; |
---|
| 256 | } |
---|
| 257 | } else { |
---|
| 258 | mode1 |= 0x03; /* default to 9600,8,N,1 */ |
---|
| 259 | } |
---|
[cd58d82] | 260 | |
---|
[25c3ff91] | 261 | /* |
---|
| 262 | * Stop Bits |
---|
| 263 | */ |
---|
| 264 | |
---|
| 265 | if (t->c_cflag & CSTOPB) { |
---|
| 266 | mode2 |= 0x07; /* 2 stop bits */ |
---|
| 267 | } else { |
---|
| 268 | if ((t->c_cflag & CSIZE) == CS5) /* CS5 and 2 stop bits not supported */ |
---|
| 269 | return -1; |
---|
| 270 | mode2 |= 0x0F; /* 1 stop bit */ |
---|
| 271 | } |
---|
[cd58d82] | 272 | |
---|
[25c3ff91] | 273 | rtems_interrupt_disable(Irql); |
---|
| 274 | (*setReg)( pMC68681, MC68681_AUX_CTRL_REG, acr_bit ); |
---|
| 275 | (*setReg)( pMC68681_port, MC68681_CLOCK_SELECT, baud_mask ); |
---|
[2c5ea01] | 276 | if ( cmd ) { |
---|
| 277 | (*setReg)( pMC68681_port, MC68681_COMMAND, cmd ); /* RX */ |
---|
| 278 | (*setReg)( pMC68681_port, MC68681_COMMAND, cmd | 0x20 ); /* TX */ |
---|
| 279 | } |
---|
[25c3ff91] | 280 | (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_MR_PTR ); |
---|
| 281 | (*setReg)( pMC68681_port, MC68681_MODE, mode1 ); |
---|
| 282 | (*setReg)( pMC68681_port, MC68681_MODE, mode2 ); |
---|
| 283 | rtems_interrupt_enable(Irql); |
---|
| 284 | return 0; |
---|
| 285 | } |
---|
[cd58d82] | 286 | |
---|
[beaaf49f] | 287 | /* |
---|
| 288 | * mc68681_initialize_context |
---|
| 289 | * |
---|
| 290 | * This function sets the default values of the per port context structure. |
---|
| 291 | */ |
---|
| 292 | |
---|
[2d8e51aa] | 293 | MC68681_STATIC void mc68681_initialize_context( |
---|
[a5d0c7c] | 294 | int minor, |
---|
| 295 | mc68681_context *pmc68681Context |
---|
| 296 | ) |
---|
| 297 | { |
---|
| 298 | int port; |
---|
| 299 | unsigned int pMC68681; |
---|
| 300 | |
---|
| 301 | pMC68681 = Console_Port_Tbl[minor].ulCtrlPort1; |
---|
| 302 | |
---|
| 303 | pmc68681Context->mate = -1; |
---|
| 304 | |
---|
| 305 | for (port=0 ; port<Console_Port_Count ; port++ ) { |
---|
| 306 | if ( Console_Port_Tbl[port].ulCtrlPort1 == pMC68681 ) { |
---|
| 307 | pmc68681Context->mate = port; |
---|
| 308 | break; |
---|
| 309 | } |
---|
| 310 | } |
---|
| 311 | |
---|
| 312 | } |
---|
| 313 | |
---|
[beaaf49f] | 314 | /* |
---|
| 315 | * mc68681_build_imr |
---|
| 316 | * |
---|
| 317 | * This function returns the value for the interrupt mask register for this |
---|
| 318 | * DUART. Since this is a shared register, we must look at the other port |
---|
| 319 | * on this chip to determine whether or not it is using interrupts. |
---|
| 320 | */ |
---|
| 321 | |
---|
[2d8e51aa] | 322 | MC68681_STATIC unsigned int mc68681_build_imr( |
---|
[4f0ffa57] | 323 | int minor, |
---|
| 324 | int enable_flag |
---|
[a5d0c7c] | 325 | ) |
---|
| 326 | { |
---|
| 327 | int mate; |
---|
| 328 | unsigned int mask; |
---|
| 329 | unsigned int mate_mask; |
---|
| 330 | unsigned int pMC68681; |
---|
| 331 | unsigned int pMC68681_port; |
---|
| 332 | mc68681_context *pmc68681Context; |
---|
| 333 | |
---|
| 334 | pMC68681 = Console_Port_Tbl[minor].ulCtrlPort1; |
---|
| 335 | pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2; |
---|
| 336 | pmc68681Context = (mc68681_context *) Console_Port_Data[minor].pDeviceContext; |
---|
| 337 | mate = pmc68681Context->mate; |
---|
| 338 | |
---|
| 339 | mate_mask = 0; |
---|
| 340 | |
---|
| 341 | /* |
---|
| 342 | * Decide if the other port on this DUART is using interrupts |
---|
| 343 | */ |
---|
| 344 | |
---|
| 345 | if ( mate != -1 ) { |
---|
| 346 | if ( Console_Port_Tbl[mate].pDeviceFns->deviceOutputUsesInterrupts ) |
---|
| 347 | mate_mask = 0x03; |
---|
| 348 | |
---|
| 349 | /* |
---|
| 350 | * If equal, then minor is A so the mate must be B |
---|
| 351 | */ |
---|
| 352 | |
---|
| 353 | if ( pMC68681 == pMC68681_port ) |
---|
| 354 | mate_mask <<= 4; |
---|
| 355 | } |
---|
| 356 | |
---|
| 357 | /* |
---|
| 358 | * Add in minor's mask |
---|
| 359 | */ |
---|
| 360 | |
---|
| 361 | mask = 0; |
---|
[4f0ffa57] | 362 | if ( enable_flag ) { |
---|
| 363 | if ( Console_Port_Tbl[minor].pDeviceFns->deviceOutputUsesInterrupts ) { |
---|
| 364 | if ( pMC68681 == pMC68681_port ) |
---|
| 365 | mask = 0x03; |
---|
| 366 | else |
---|
| 367 | mask = 0x30; |
---|
| 368 | } |
---|
[a5d0c7c] | 369 | } |
---|
| 370 | |
---|
[2c5ea01] | 371 | #if 0 |
---|
[a5d0c7c] | 372 | return mask | mate_mask; |
---|
[2c5ea01] | 373 | #endif |
---|
| 374 | |
---|
| 375 | return 0; |
---|
[a5d0c7c] | 376 | } |
---|
| 377 | |
---|
[beaaf49f] | 378 | /* |
---|
| 379 | * mc68681_init |
---|
| 380 | * |
---|
| 381 | * This function initializes the DUART to a quiecsent state. |
---|
| 382 | */ |
---|
| 383 | |
---|
[2d8e51aa] | 384 | MC68681_STATIC void mc68681_init(int minor) |
---|
[25c3ff91] | 385 | { |
---|
| 386 | unsigned32 pMC68681_port; |
---|
| 387 | unsigned32 pMC68681; |
---|
| 388 | mc68681_context *pmc68681Context; |
---|
| 389 | setRegister_f setReg; |
---|
| 390 | getRegister_f getReg; |
---|
| 391 | |
---|
| 392 | pmc68681Context = (mc68681_context *) malloc(sizeof(mc68681_context)); |
---|
[cd58d82] | 393 | |
---|
[25c3ff91] | 394 | Console_Port_Data[minor].pDeviceContext = (void *)pmc68681Context; |
---|
[a5d0c7c] | 395 | |
---|
| 396 | mc68681_initialize_context( minor, pmc68681Context ); |
---|
[cd58d82] | 397 | |
---|
[4f0ffa57] | 398 | pMC68681 = Console_Port_Tbl[minor].ulCtrlPort1; |
---|
| 399 | pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2; |
---|
[25c3ff91] | 400 | setReg = Console_Port_Tbl[minor].setRegister; |
---|
| 401 | getReg = Console_Port_Tbl[minor].getRegister; |
---|
[cd58d82] | 402 | |
---|
| 403 | /* |
---|
[25c3ff91] | 404 | * Reset everything and leave this port disabled. |
---|
[cd58d82] | 405 | */ |
---|
| 406 | |
---|
[25c3ff91] | 407 | (*setReg)( pMC68681, MC68681_COMMAND, MC68681_MODE_REG_RESET_RX ); |
---|
| 408 | (*setReg)( pMC68681, MC68681_COMMAND, MC68681_MODE_REG_RESET_TX ); |
---|
| 409 | (*setReg)( pMC68681, MC68681_COMMAND, MC68681_MODE_REG_RESET_ERROR ); |
---|
| 410 | (*setReg)( pMC68681, MC68681_COMMAND, MC68681_MODE_REG_RESET_BREAK ); |
---|
| 411 | (*setReg)( pMC68681, MC68681_COMMAND, MC68681_MODE_REG_STOP_BREAK ); |
---|
| 412 | (*setReg)( pMC68681, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_TX ); |
---|
| 413 | (*setReg)( pMC68681, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_RX ); |
---|
[cd58d82] | 414 | |
---|
[25c3ff91] | 415 | |
---|
| 416 | (*setReg)( pMC68681, MC68681_MODE_REG_1A, 0x00 ); |
---|
| 417 | (*setReg)( pMC68681, MC68681_MODE_REG_2A, 0x02 ); |
---|
[4f0ffa57] | 418 | |
---|
| 419 | /* |
---|
| 420 | * Disable interrupts on RX and TX for this port |
---|
| 421 | */ |
---|
| 422 | |
---|
| 423 | (*setReg)( pMC68681, MC68681_INTERRUPT_MASK_REG, mc68681_build_imr(minor, 0)); |
---|
[cd58d82] | 424 | } |
---|
| 425 | |
---|
[25c3ff91] | 426 | /* |
---|
[beaaf49f] | 427 | * mc68681_open |
---|
| 428 | * |
---|
| 429 | * This function opens a port for communication. |
---|
| 430 | * |
---|
| 431 | * Default state is 9600 baud, 8 bits, No parity, and 1 stop bit. |
---|
[25c3ff91] | 432 | */ |
---|
| 433 | |
---|
[2d8e51aa] | 434 | MC68681_STATIC int mc68681_open( |
---|
[cd58d82] | 435 | int major, |
---|
| 436 | int minor, |
---|
[25c3ff91] | 437 | void *arg |
---|
[cd58d82] | 438 | ) |
---|
| 439 | { |
---|
[25c3ff91] | 440 | unsigned32 pMC68681; |
---|
| 441 | unsigned32 pMC68681_port; |
---|
| 442 | unsigned int baud; |
---|
| 443 | unsigned int acr; |
---|
| 444 | unsigned int vector; |
---|
[2d8e51aa] | 445 | unsigned int command; |
---|
[25c3ff91] | 446 | rtems_interrupt_level Irql; |
---|
| 447 | setRegister_f setReg; |
---|
| 448 | |
---|
| 449 | pMC68681 = Console_Port_Tbl[minor].ulCtrlPort1; |
---|
| 450 | pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2; |
---|
| 451 | setReg = Console_Port_Tbl[minor].setRegister; |
---|
| 452 | vector = Console_Port_Tbl[minor].ulIntVector; |
---|
| 453 | |
---|
[2d8e51aa] | 454 | (void) mc68681_baud_rate( minor, B9600, &baud, &acr, &command ); |
---|
[25c3ff91] | 455 | |
---|
[b7ebcea3] | 456 | /* |
---|
| 457 | * Set the DUART channel to a default useable state |
---|
| 458 | */ |
---|
| 459 | |
---|
[25c3ff91] | 460 | rtems_interrupt_disable(Irql); |
---|
[2c5ea01] | 461 | (*setReg)( pMC68681, MC68681_COMMAND, command ); |
---|
[25c3ff91] | 462 | (*setReg)( pMC68681, MC68681_AUX_CTRL_REG, acr ); |
---|
| 463 | (*setReg)( pMC68681_port, MC68681_CLOCK_SELECT, baud ); |
---|
| 464 | (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_MR_PTR ); |
---|
| 465 | (*setReg)( pMC68681_port, MC68681_MODE, 0x13 ); |
---|
| 466 | (*setReg)( pMC68681_port, MC68681_MODE, 0x07 ); |
---|
| 467 | rtems_interrupt_enable(Irql); |
---|
| 468 | |
---|
| 469 | (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_ENABLE_TX ); |
---|
| 470 | (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_ENABLE_RX ); |
---|
| 471 | |
---|
| 472 | (*setReg)( pMC68681, MC68681_INTERRUPT_VECTOR_REG, vector ); |
---|
| 473 | |
---|
[4f0ffa57] | 474 | return RTEMS_SUCCESSFUL; |
---|
[cd58d82] | 475 | } |
---|
| 476 | |
---|
[beaaf49f] | 477 | /* |
---|
| 478 | * mc68681_close |
---|
| 479 | * |
---|
| 480 | * This function shuts down the requested port. |
---|
| 481 | */ |
---|
| 482 | |
---|
[2d8e51aa] | 483 | MC68681_STATIC int mc68681_close( |
---|
[cd58d82] | 484 | int major, |
---|
| 485 | int minor, |
---|
[25c3ff91] | 486 | void *arg |
---|
[cd58d82] | 487 | ) |
---|
| 488 | { |
---|
[b7ebcea3] | 489 | unsigned32 pMC68681; |
---|
| 490 | unsigned32 pMC68681_port; |
---|
| 491 | setRegister_f setReg; |
---|
| 492 | |
---|
| 493 | pMC68681 = Console_Port_Tbl[minor].ulCtrlPort1; |
---|
| 494 | pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2; |
---|
| 495 | setReg = Console_Port_Tbl[minor].setRegister; |
---|
| 496 | |
---|
| 497 | /* |
---|
| 498 | * Disable interrupts from this channel and then disable it totally. |
---|
| 499 | */ |
---|
| 500 | |
---|
| 501 | (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_TX ); |
---|
| 502 | (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_RX ); |
---|
| 503 | |
---|
[cd58d82] | 504 | return(RTEMS_SUCCESSFUL); |
---|
| 505 | } |
---|
| 506 | |
---|
| 507 | /* |
---|
| 508 | * mc68681_write_polled |
---|
[beaaf49f] | 509 | * |
---|
| 510 | * This routine polls out the requested character. |
---|
[cd58d82] | 511 | */ |
---|
[424e23ee] | 512 | |
---|
[2d8e51aa] | 513 | MC68681_STATIC void mc68681_write_polled( |
---|
[cd58d82] | 514 | int minor, |
---|
| 515 | char cChar |
---|
| 516 | ) |
---|
| 517 | { |
---|
[25c3ff91] | 518 | unsigned32 pMC68681_port; |
---|
[cd58d82] | 519 | unsigned char ucLineStatus; |
---|
| 520 | int iTimeout; |
---|
| 521 | getRegister_f getReg; |
---|
[25c3ff91] | 522 | setRegister_f setReg; |
---|
[cd58d82] | 523 | |
---|
[25c3ff91] | 524 | pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2; |
---|
| 525 | getReg = Console_Port_Tbl[minor].getRegister; |
---|
| 526 | setReg = Console_Port_Tbl[minor].setRegister; |
---|
[cd58d82] | 527 | |
---|
| 528 | /* |
---|
| 529 | * wait for transmitter holding register to be empty |
---|
| 530 | */ |
---|
[ab2dbd7] | 531 | iTimeout = 1000; |
---|
[25c3ff91] | 532 | ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS); |
---|
[2c5ea01] | 533 | while ((ucLineStatus & (MC68681_TX_READY|MC68681_TX_EMPTY)) == 0) { |
---|
| 534 | |
---|
| 535 | if ((ucLineStatus & 0xF0)) |
---|
| 536 | (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_ERROR ); |
---|
[ab2dbd7] | 537 | |
---|
[cd58d82] | 538 | /* |
---|
| 539 | * Yield while we wait |
---|
| 540 | */ |
---|
[ab2dbd7] | 541 | |
---|
[cd58d82] | 542 | if(_System_state_Is_up(_System_state_Get())) { |
---|
| 543 | rtems_task_wake_after(RTEMS_YIELD_PROCESSOR); |
---|
| 544 | } |
---|
[25c3ff91] | 545 | ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS); |
---|
[cd58d82] | 546 | if(!--iTimeout) { |
---|
| 547 | break; |
---|
| 548 | } |
---|
| 549 | } |
---|
| 550 | |
---|
| 551 | /* |
---|
| 552 | * transmit character |
---|
| 553 | */ |
---|
[ab2dbd7] | 554 | |
---|
[25c3ff91] | 555 | (*setReg)(pMC68681_port, MC68681_TX_BUFFER, cChar); |
---|
[cd58d82] | 556 | } |
---|
| 557 | |
---|
| 558 | /* |
---|
[4f0ffa57] | 559 | * mc68681_process |
---|
[cd58d82] | 560 | * |
---|
[4f0ffa57] | 561 | * This routine is the per port console interrupt handler. |
---|
[cd58d82] | 562 | */ |
---|
| 563 | |
---|
[2d8e51aa] | 564 | MC68681_STATIC void mc68681_process( |
---|
[4f0ffa57] | 565 | int minor |
---|
[cd58d82] | 566 | ) |
---|
| 567 | { |
---|
| 568 | unsigned32 pMC68681; |
---|
[4f0ffa57] | 569 | unsigned32 pMC68681_port; |
---|
[cd58d82] | 570 | volatile unsigned8 ucLineStatus; |
---|
| 571 | char cChar; |
---|
| 572 | getRegister_f getReg; |
---|
| 573 | setRegister_f setReg; |
---|
| 574 | |
---|
[4f0ffa57] | 575 | pMC68681 = Console_Port_Tbl[minor].ulCtrlPort1; |
---|
| 576 | pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2; |
---|
| 577 | getReg = Console_Port_Tbl[minor].getRegister; |
---|
| 578 | setReg = Console_Port_Tbl[minor].setRegister; |
---|
[cd58d82] | 579 | |
---|
[4f0ffa57] | 580 | /* |
---|
| 581 | * Deal with any received characters |
---|
| 582 | */ |
---|
| 583 | while(TRUE) { |
---|
| 584 | ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS); |
---|
| 585 | if(!(ucLineStatus & MC68681_RX_READY)) { |
---|
| 586 | break; |
---|
| 587 | } |
---|
[cd58d82] | 588 | /* |
---|
[4f0ffa57] | 589 | * If there is a RX error, then dump all the data. |
---|
[cd58d82] | 590 | */ |
---|
[4f0ffa57] | 591 | if ( ucLineStatus & MC68681_RX_ERRORS ) { |
---|
| 592 | do { |
---|
| 593 | cChar = (*getReg)(pMC68681_port, MC68681_RX_BUFFER); |
---|
| 594 | ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS); |
---|
| 595 | } while ( ucLineStatus & MC68681_RX_READY ); |
---|
| 596 | continue; |
---|
[cd58d82] | 597 | } |
---|
[4f0ffa57] | 598 | cChar = (*getReg)(pMC68681_port, MC68681_RX_BUFFER); |
---|
| 599 | rtems_termios_enqueue_raw_characters( |
---|
| 600 | Console_Port_Data[minor].termios_data, |
---|
| 601 | &cChar, |
---|
| 602 | 1 |
---|
| 603 | ); |
---|
| 604 | } |
---|
[cd58d82] | 605 | |
---|
[4f0ffa57] | 606 | /* |
---|
| 607 | * Deal with the transmitter |
---|
| 608 | */ |
---|
[cd58d82] | 609 | |
---|
[4f0ffa57] | 610 | while(TRUE) { |
---|
| 611 | if(Ring_buffer_Is_empty(&Console_Port_Data[minor].TxBuffer)) { |
---|
| 612 | Console_Port_Data[minor].bActive = FALSE; |
---|
[cd58d82] | 613 | |
---|
[4f0ffa57] | 614 | /* |
---|
| 615 | * There is no data to transmit |
---|
| 616 | */ |
---|
| 617 | break; |
---|
| 618 | } |
---|
[cd58d82] | 619 | |
---|
[4f0ffa57] | 620 | ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS); |
---|
| 621 | if(!(ucLineStatus & (MC68681_TX_EMPTY|MC68681_TX_READY))) { |
---|
[cd58d82] | 622 | /* |
---|
[4f0ffa57] | 623 | * We'll get another interrupt when the TX can take another character. |
---|
[cd58d82] | 624 | */ |
---|
[4f0ffa57] | 625 | break; |
---|
[cd58d82] | 626 | } |
---|
| 627 | |
---|
[4f0ffa57] | 628 | Ring_buffer_Remove_character( &Console_Port_Data[minor].TxBuffer, cChar); |
---|
| 629 | /* |
---|
| 630 | * transmit character |
---|
| 631 | */ |
---|
| 632 | (*setReg)(pMC68681_port, MC68681_TX_BUFFER, cChar); |
---|
[cd58d82] | 633 | } |
---|
[4f0ffa57] | 634 | |
---|
[cd58d82] | 635 | } |
---|
| 636 | |
---|
[4f0ffa57] | 637 | /* |
---|
| 638 | * mc68681_isr |
---|
| 639 | * |
---|
| 640 | * This is the single interrupt entry point which parcels interrupts |
---|
| 641 | * out to the various ports. |
---|
| 642 | */ |
---|
| 643 | |
---|
[2d8e51aa] | 644 | MC68681_STATIC rtems_isr mc68681_isr( |
---|
[cd58d82] | 645 | rtems_vector_number vector |
---|
| 646 | ) |
---|
| 647 | { |
---|
| 648 | int minor; |
---|
| 649 | |
---|
[ab2dbd7] | 650 | for(minor=0 ; minor<Console_Port_Count ; minor++) { |
---|
| 651 | if(vector == Console_Port_Tbl[minor].ulIntVector) { |
---|
[cd58d82] | 652 | mc68681_process(minor); |
---|
| 653 | } |
---|
| 654 | } |
---|
| 655 | } |
---|
| 656 | |
---|
| 657 | /* |
---|
| 658 | * mc68681_flush |
---|
[beaaf49f] | 659 | * |
---|
| 660 | * This routine waits before all output is completed before closing |
---|
| 661 | * the requested port. |
---|
| 662 | * |
---|
| 663 | * NOTE: This is the "interrupt mode" close entry point. |
---|
[cd58d82] | 664 | */ |
---|
[ab2dbd7] | 665 | |
---|
[2d8e51aa] | 666 | MC68681_STATIC int mc68681_flush(int major, int minor, void *arg) |
---|
[cd58d82] | 667 | { |
---|
| 668 | while(!Ring_buffer_Is_empty(&Console_Port_Data[minor].TxBuffer)) { |
---|
| 669 | /* |
---|
| 670 | * Yield while we wait |
---|
| 671 | */ |
---|
| 672 | if(_System_state_Is_up(_System_state_Get())) { |
---|
| 673 | rtems_task_wake_after(RTEMS_YIELD_PROCESSOR); |
---|
| 674 | } |
---|
| 675 | } |
---|
| 676 | |
---|
| 677 | mc68681_close(major, minor, arg); |
---|
| 678 | |
---|
| 679 | return(RTEMS_SUCCESSFUL); |
---|
| 680 | } |
---|
| 681 | |
---|
| 682 | /* |
---|
[beaaf49f] | 683 | * mc68681_enable_interrupts |
---|
[cd58d82] | 684 | * |
---|
[beaaf49f] | 685 | * This function initializes the hardware for this port to use interrupts. |
---|
[cd58d82] | 686 | */ |
---|
| 687 | |
---|
[2d8e51aa] | 688 | MC68681_STATIC void mc68681_enable_interrupts( |
---|
[cd58d82] | 689 | int minor |
---|
| 690 | ) |
---|
| 691 | { |
---|
| 692 | unsigned32 pMC68681; |
---|
[ab2dbd7] | 693 | setRegister_f setReg; |
---|
[cd58d82] | 694 | |
---|
| 695 | pMC68681 = Console_Port_Tbl[minor].ulCtrlPort1; |
---|
| 696 | setReg = Console_Port_Tbl[minor].setRegister; |
---|
| 697 | |
---|
| 698 | /* |
---|
[a5d0c7c] | 699 | * Enable interrupts on RX and TX -- not break |
---|
[cd58d82] | 700 | */ |
---|
[a5d0c7c] | 701 | |
---|
[4f0ffa57] | 702 | (*setReg)( pMC68681, MC68681_INTERRUPT_MASK_REG, mc68681_build_imr(minor, 1)); |
---|
[cd58d82] | 703 | } |
---|
| 704 | |
---|
[beaaf49f] | 705 | /* |
---|
| 706 | * mc68681_initialize_interrupts |
---|
| 707 | * |
---|
| 708 | * This routine initializes the console's receive and transmit |
---|
| 709 | * ring buffers and loads the appropriate vectors to handle the interrupts. |
---|
| 710 | */ |
---|
| 711 | |
---|
[2d8e51aa] | 712 | MC68681_STATIC void mc68681_initialize_interrupts(int minor) |
---|
[cd58d82] | 713 | { |
---|
| 714 | mc68681_init(minor); |
---|
| 715 | |
---|
| 716 | Ring_buffer_Initialize(&Console_Port_Data[minor].TxBuffer); |
---|
| 717 | |
---|
| 718 | Console_Port_Data[minor].bActive = FALSE; |
---|
| 719 | |
---|
| 720 | set_vector(mc68681_isr, Console_Port_Tbl[minor].ulIntVector, 1); |
---|
| 721 | |
---|
| 722 | mc68681_enable_interrupts(minor); |
---|
| 723 | } |
---|
| 724 | |
---|
| 725 | /* |
---|
| 726 | * mc68681_write_support_int |
---|
| 727 | * |
---|
[beaaf49f] | 728 | * Console Termios output entry point when using interrupt driven output. |
---|
[cd58d82] | 729 | */ |
---|
[ab2dbd7] | 730 | |
---|
[2d8e51aa] | 731 | MC68681_STATIC int mc68681_write_support_int( |
---|
[cd58d82] | 732 | int minor, |
---|
| 733 | const char *buf, |
---|
| 734 | int len |
---|
| 735 | ) |
---|
| 736 | { |
---|
| 737 | int i; |
---|
| 738 | unsigned32 Irql; |
---|
| 739 | |
---|
[ab2dbd7] | 740 | for(i=0 ; i<len ;) { |
---|
[cd58d82] | 741 | if(Ring_buffer_Is_full(&Console_Port_Data[minor].TxBuffer)) { |
---|
| 742 | if(!Console_Port_Data[minor].bActive) { |
---|
| 743 | /* |
---|
| 744 | * Wake up the device |
---|
| 745 | */ |
---|
| 746 | rtems_interrupt_disable(Irql); |
---|
| 747 | Console_Port_Data[minor].bActive = TRUE; |
---|
| 748 | mc68681_process(minor); |
---|
| 749 | rtems_interrupt_enable(Irql); |
---|
| 750 | } else { |
---|
| 751 | /* |
---|
| 752 | * Yield |
---|
| 753 | */ |
---|
| 754 | rtems_task_wake_after(RTEMS_YIELD_PROCESSOR); |
---|
| 755 | } |
---|
| 756 | |
---|
| 757 | /* |
---|
| 758 | * Wait for ring buffer to empty |
---|
| 759 | */ |
---|
| 760 | continue; |
---|
| 761 | } |
---|
| 762 | else { |
---|
| 763 | Ring_buffer_Add_character( &Console_Port_Data[minor].TxBuffer, buf[i]); |
---|
| 764 | i++; |
---|
| 765 | } |
---|
| 766 | } |
---|
| 767 | |
---|
| 768 | /* |
---|
| 769 | * Ensure that characters are on the way |
---|
| 770 | */ |
---|
[ab2dbd7] | 771 | |
---|
[cd58d82] | 772 | if(!Console_Port_Data[minor].bActive) { |
---|
| 773 | /* |
---|
| 774 | * Wake up the device |
---|
| 775 | */ |
---|
| 776 | rtems_interrupt_disable(Irql); |
---|
| 777 | Console_Port_Data[minor].bActive = TRUE; |
---|
| 778 | mc68681_process(minor); |
---|
| 779 | rtems_interrupt_enable(Irql); |
---|
| 780 | } |
---|
| 781 | |
---|
| 782 | return (len); |
---|
| 783 | } |
---|
| 784 | |
---|
| 785 | /* |
---|
| 786 | * mc68681_write_support_polled |
---|
| 787 | * |
---|
[beaaf49f] | 788 | * Console Termios output entry point when using polled output. |
---|
[cd58d82] | 789 | * |
---|
| 790 | */ |
---|
[ab2dbd7] | 791 | |
---|
[2d8e51aa] | 792 | MC68681_STATIC int mc68681_write_support_polled( |
---|
[cd58d82] | 793 | int minor, |
---|
| 794 | const char *buf, |
---|
| 795 | int len |
---|
| 796 | ) |
---|
| 797 | { |
---|
| 798 | int nwrite = 0; |
---|
| 799 | |
---|
| 800 | /* |
---|
| 801 | * poll each byte in the string out of the port. |
---|
| 802 | */ |
---|
| 803 | while (nwrite < len) { |
---|
| 804 | /* |
---|
| 805 | * transmit character |
---|
| 806 | */ |
---|
| 807 | mc68681_write_polled(minor, *buf++); |
---|
| 808 | nwrite++; |
---|
| 809 | } |
---|
| 810 | |
---|
| 811 | /* |
---|
| 812 | * return the number of bytes written. |
---|
| 813 | */ |
---|
| 814 | return nwrite; |
---|
| 815 | } |
---|
| 816 | |
---|
| 817 | /* |
---|
| 818 | * mc68681_inbyte_nonblocking_polled |
---|
| 819 | * |
---|
| 820 | * Console Termios polling input entry point. |
---|
| 821 | */ |
---|
| 822 | |
---|
[2d8e51aa] | 823 | MC68681_STATIC int mc68681_inbyte_nonblocking_polled( |
---|
[cd58d82] | 824 | int minor |
---|
| 825 | ) |
---|
| 826 | { |
---|
[25c3ff91] | 827 | unsigned32 pMC68681_port; |
---|
[cd58d82] | 828 | unsigned char ucLineStatus; |
---|
[2c5ea01] | 829 | unsigned char cChar; |
---|
[cd58d82] | 830 | getRegister_f getReg; |
---|
| 831 | |
---|
[25c3ff91] | 832 | pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2; |
---|
| 833 | getReg = Console_Port_Tbl[minor].getRegister; |
---|
[cd58d82] | 834 | |
---|
[25c3ff91] | 835 | ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS); |
---|
[ab2dbd7] | 836 | if(ucLineStatus & MC68681_RX_READY) { |
---|
[25c3ff91] | 837 | cChar = (*getReg)(pMC68681_port, MC68681_RX_BUFFER); |
---|
[ab2dbd7] | 838 | return (int)cChar; |
---|
[cd58d82] | 839 | } else { |
---|
[25c3ff91] | 840 | return -1; |
---|
[cd58d82] | 841 | } |
---|
| 842 | } |
---|
[2d8e51aa] | 843 | |
---|
| 844 | MC68681_STATIC int mc68681_baud_rate( |
---|
| 845 | int minor, |
---|
| 846 | int baud, |
---|
| 847 | unsigned int *baud_mask_p, |
---|
| 848 | unsigned int *acr_bit_p, |
---|
| 849 | unsigned int *command |
---|
| 850 | ) |
---|
| 851 | { |
---|
| 852 | unsigned int baud_mask; |
---|
| 853 | unsigned int acr_bit; |
---|
| 854 | int status; |
---|
| 855 | int is_extended; |
---|
| 856 | int baud_requested; |
---|
| 857 | mc68681_baud_table_t *baud_tbl; |
---|
| 858 | |
---|
| 859 | baud_mask = 0; |
---|
| 860 | acr_bit = 0; |
---|
| 861 | status = 0; |
---|
| 862 | |
---|
| 863 | if ( !(Console_Port_Tbl[minor].ulDataPort & MC68681_DATA_BAUD_RATE_SET_1) ) |
---|
| 864 | acr_bit = 1; |
---|
| 865 | |
---|
| 866 | is_extended = 0; |
---|
| 867 | |
---|
| 868 | switch (Console_Port_Tbl[minor].ulDataPort & MC68681_XBRG_MASK) { |
---|
| 869 | case MC68681_XBRG_IGNORED: |
---|
| 870 | *command = 0x00; |
---|
| 871 | break; |
---|
| 872 | case MC68681_XBRG_ENABLED: |
---|
[2c5ea01] | 873 | *command = 0x80; |
---|
[2d8e51aa] | 874 | is_extended = 1; |
---|
| 875 | break; |
---|
| 876 | case MC68681_XBRG_DISABLED: |
---|
[2c5ea01] | 877 | *command = 0x90; |
---|
[2d8e51aa] | 878 | break; |
---|
| 879 | } |
---|
| 880 | |
---|
| 881 | baud_requested = baud & CBAUD; |
---|
| 882 | if (!baud_requested) |
---|
[2c5ea01] | 883 | baud_requested = B9600; /* default to 9600 baud */ |
---|
[2d8e51aa] | 884 | |
---|
| 885 | baud_requested = termios_baud_to_index( baud_requested ); |
---|
| 886 | |
---|
| 887 | baud_tbl = (mc68681_baud_table_t *) Console_Port_Tbl[minor].ulClock; |
---|
| 888 | if (!baud_tbl) |
---|
| 889 | baud_tbl = (mc68681_baud_table_t *)mc68681_baud_rate_table; |
---|
| 890 | |
---|
| 891 | if ( is_extended ) |
---|
| 892 | baud_mask = (unsigned int)baud_tbl[ acr_bit + 2 ][ baud_requested ]; |
---|
| 893 | else |
---|
| 894 | baud_mask = baud_tbl[ acr_bit ][ baud_requested ]; |
---|
| 895 | |
---|
| 896 | if ( baud_mask == MC68681_BAUD_NOT_VALID ) |
---|
| 897 | status = -1; |
---|
| 898 | |
---|
[2c5ea01] | 899 | /* |
---|
| 900 | * upper nibble is receiver and lower nibble is transmitter |
---|
| 901 | */ |
---|
| 902 | |
---|
| 903 | *baud_mask_p = (baud_mask << 4) | baud_mask; |
---|
[2d8e51aa] | 904 | *acr_bit_p = acr_bit; |
---|
| 905 | return status; |
---|
| 906 | } |
---|
| 907 | |
---|