Changeset 709 for soft/giet_vm/giet_drivers/tty_driver.c
- Timestamp:
- Oct 1, 2015, 4:20:46 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_drivers/tty_driver.c
r605 r709 19 19 20 20 //////////////////////////////////////////////////////////////////////////////////// 21 // extern variables 22 //////////////////////////////////////////////////////////////////////////////////// 23 24 // This variable is allocated in kernel_init.c file 25 extern static_scheduler_t* _schedulers[X_SIZE][Y_SIZE][NB_PROCS_MAX]; 26 27 //////////////////////////////////////////////////////////////////////////////////// 21 28 // global variables 22 29 //////////////////////////////////////////////////////////////////////////////////// 23 30 31 __attribute__((section(".kdata"))) 32 tty_fifo_t _tty_rx_fifo[NB_TTY_CHANNELS]; 33 34 /* 24 35 __attribute__((section(".kdata"))) 25 36 unsigned int _tty_rx_buf[NB_TTY_CHANNELS]; … … 27 38 __attribute__((section(".kdata"))) 28 39 unsigned int _tty_rx_full[NB_TTY_CHANNELS]; 40 41 __attribute__((section(".kdata"))) 42 unsigned int _tty_rx_trdid[NB_TTY_CHANNELS]; 43 */ 29 44 30 45 //////////////////////////////////////////////////////////////////////////////////// … … 52 67 void _tty_init( unsigned int channel ) 53 68 { 54 _tty_rx_full[channel] = 0; 69 _tty_rx_fifo[channel].sts = 0; 70 _tty_rx_fifo[channel].ptr = 0; 71 _tty_rx_fifo[channel].ptw = 0; 55 72 } 56 73 … … 60 77 unsigned int channel ) // TTY channel 61 78 { 62 // transfer character to kernel buffer and acknowledge TTY IRQ63 _tty_rx_buf[channel] = _tty_get_register( channel, TTY_READ );79 // get pointer on TTY_RX FIFO 80 tty_fifo_t* fifo = &_tty_rx_fifo[channel]; 64 81 65 // flush pending memory writes66 asm volatile( "sync" );82 // get character from TTY_RX channel and acknowledge IRQ 83 unsigned int data = _tty_get_register( channel, TTY_READ ); 67 84 68 // set kernel buffer status 69 _tty_rx_full[channel] = 1; 85 // transfer character to FIFO if not full 86 // discard incoming character if full 87 if ( fifo->sts < TTY_FIFO_DEPTH ) 88 { 89 // store data into FIFO 90 fifo->data[fifo->ptw] = (char)data; 70 91 71 #if GIET_DEBUG_IRQS // we don't take the TTY lock to avoid deadlock 72 unsigned int gpid = _get_procid(); 73 unsigned int cluster_xy = gpid >> P_WIDTH; 74 unsigned int x = cluster_xy >> Y_WIDTH; 75 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 76 unsigned int lpid = gpid & ((1<<P_WIDTH)-1); 77 _puts("\n[IRQS DEBUG] Processor["); 78 _putd(x ); 79 _puts(","); 80 _putd(y ); 81 _puts(","); 82 _putd(lpid ); 83 _puts("] enters _tty_rx_isr() at cycle "); 84 _putd(_get_proctime() ); 85 _puts("\n read byte = "); 86 _putx(_tty_rx_buf[channel] ); 87 _puts("\n"); 88 #endif 92 // avoid race 93 asm volatile( "sync" ); 89 94 95 // update FIFO state 96 fifo->ptw = (fifo->ptw + 1) % TTY_FIFO_DEPTH; 97 fifo->sts = fifo->sts + 1; 98 } 99 100 // get owner thread indexes 101 unsigned int trdid = fifo->trdid; 102 unsigned int x = (trdid >> 24) & 0xFF; 103 unsigned int y = (trdid >> 16) & 0xFF; 104 unsigned int p = (trdid >> 8) & 0xFF; 105 unsigned int ltid = (trdid ) & 0xFF; 106 107 // Reset NORUN_MASK_TTY bit 108 static_scheduler_t* psched = (static_scheduler_t*)_schedulers[x][y][p]; 109 unsigned int* ptr = &psched->context[ltid].slot[CTX_NORUN_ID]; 110 _atomic_and( ptr , ~NORUN_MASK_TTY ); 90 111 } 91 112 … … 95 116 unsigned int channel ) // TTY channel 96 117 { 97 _p uts("\n[GIET ERROR] the _tty_tx_isr() is not implemented\n");118 _printf("\n[GIET ERROR] the _tty_tx_isr() is not implemented\n"); 98 119 _exit(); 99 120 }
Note: See TracChangeset
for help on using the changeset viewer.