Changeset 188 for trunk/kernel/devices/dev_txt.c
- Timestamp:
- Jul 12, 2017, 8:12:41 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/devices/dev_txt.c
r101 r188 38 38 extern chdev_directory_t chdev_dir; // allocated in kernel_init.c 39 39 40 extern chdev_pic_input_t chdev_pic_input; // allocated in kernel_init.c 40 ////////////////////////////////// 41 void dev_txt_init( chdev_t * txt ) 42 { 43 // For all TXT channels other than the TXT0 (kernel terminal), 44 // the PIC chdev must be initialized before the TXT chdev, because 45 // the TXT chdev initialization requires the routing of an external IRQ 41 46 42 //////////////////////////////////// 43 void dev_txt_init( chdev_t * chdev ) 44 { 45 // the local ICU chdev must be initialized before the TXT chdev, because 46 // the TXT chdev initialization requires allocation of a WTI from local ICU 47 xptr_t icu_xp = chdev_dir.icu[local_cxy]; 48 assert( (icu_xp != XPTR_NULL) , __FUNCTION__ , "ICU not initialised before TXT" ); 47 xptr_t pic_xp = chdev_dir.pic; 48 uint32_t channel = txt->channel; 49 uint32_t impl = txt->impl; 49 50 50 // get implementation and channel index 51 uint32_t impl = chdev->impl; 52 uint32_t channel = chdev->channel; 51 assert( (pic_xp != XPTR_NULL) || (channel == 0) , __FUNCTION__ , 52 "PIC not initialised before TXT" ); 53 53 54 54 // set chdev name 55 snprintf( chdev->name , 16 , "txt_%d" , chdev->channel );55 snprintf( txt->name , 16 , "txt_%d" , channel ); 56 56 57 57 // set fields "cmd", "isr", and call driver init function 58 58 if( impl == IMPL_TXT_TTY ) 59 59 { 60 chdev->cmd = &soclib_tty_cmd;61 chdev->isr = &soclib_tty_isr;62 soclib_tty_init( chdev);60 txt->cmd = &soclib_tty_cmd; 61 txt->isr = &soclib_tty_isr; 62 soclib_tty_init( txt ); 63 63 } 64 64 else … … 67 67 } 68 68 69 // get a WTI mailbox from local ICU 70 uint32_t wti_id = dev_icu_wti_alloc(); 69 // no server thread and no IRQ routing for TXT0 70 if( channel != 0 ) 71 { 72 // select a core to execute the TXT server thread 73 lid_t lid = cluster_select_local_core(); 71 74 72 assert( (wti_id != -1) , __FUNCTION__ , "cannot allocate WTI mailbox" ); 75 // bind TXT IRQ to the selected core 76 dev_pic_bind_irq( lid , txt ); 73 77 74 // select a core75 lid_t lid = cluster_select_local_core();78 // enable TXT IRQ 79 dev_pic_enable_irq( lid , txt ); 76 80 77 // enable WTI IRQ and update WTI interrupt vector 78 dev_icu_enable_irq( lid , WTI_TYPE , wti_id , chdev ); 81 // create server thread 82 thread_t * new_thread; 83 error_t error; 79 84 80 // link IOC IRQ to WTI mailbox in PIC component 81 uint32_t irq_id = chdev_pic_input.txt[channel]; 82 dev_pic_bind_irq( irq_id , local_cxy , wti_id ); 85 error = thread_kernel_create( &new_thread, 86 THREAD_DEV, 87 &chdev_sequencial_server, 88 txt, 89 lid ); 83 90 84 // create server thread 85 thread_t * new_thread; 86 error_t error; 91 assert( (error == 0) , __FUNCTION__ , "cannot create server thread" ); 87 92 88 error = thread_kernel_create( &new_thread, 89 THREAD_DEV, 90 &chdev_sequencial_server, 91 chdev, 92 lid ); 93 assert( (error == 0) , __FUNCTION__ , "cannot create server thread" ); 93 // set "server" field in chdev descriptor 94 txt->server = new_thread; 94 95 95 // set "server" field in chdev descriptor 96 chdev->server = new_thread; 97 98 // start server thread 99 thread_unblock( XPTR( local_cxy , new_thread ) , THREAD_BLOCKED_GLOBAL ); 96 // start server thread 97 thread_unblock( XPTR( local_cxy , new_thread ) , THREAD_BLOCKED_GLOBAL ); 98 } 100 99 } 101 100
Note: See TracChangeset
for help on using the changeset viewer.