Changeset 49 for trunk/kernel/devices/dev_txt.c
- Timestamp:
- Jun 26, 2017, 1:40:02 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/devices/dev_txt.c
r23 r49 1 1 /* 2 2 * dev_txt.c - TXT (Text Terminal) generic device API implementation. 3 * 3 * 4 4 * Author Alain Greiner (2016) 5 5 * … … 43 43 { 44 44 // the local ICU chdev must be initialized before the TXT chdev, because 45 // the TXT chdev initiali sation requires allocation of a WTI from local ICU45 // the TXT chdev initialization requires allocation of a WTI from local ICU 46 46 xptr_t icu_xp = chdev_dir.icu[local_cxy]; 47 47 assert( (icu_xp != XPTR_NULL) , __FUNCTION__ , "ICU not initialised before TXT" ); … … 77 77 dev_icu_enable_irq( lid , WTI_TYPE , wti_id , chdev ); 78 78 79 // link IOC IRQ to WTI mailbox in PIC component 79 // link IOC IRQ to WTI mailbox in PIC component 80 80 uint32_t irq_id = chdev_pic_input.txt[channel]; 81 81 dev_pic_bind_irq( irq_id , local_cxy , wti_id ); … … 89 89 &chdev_sequencial_server, 90 90 chdev, 91 lid ); 91 lid ); 92 92 assert( (error == 0) , __FUNCTION__ , "cannot create server thread" ); 93 93 94 94 // set "server" field in chdev descriptor 95 95 chdev->server = new_thread; 96 96 97 97 // start server thread 98 98 thread_unblock( XPTR( local_cxy , new_thread ) , THREAD_BLOCKED_GLOBAL ); 99 100 } // end dev_txt_init() 101 99 } 102 100 103 101 ////////////////////////////////////////////////////////////////////////////////// … … 111 109 thread_t * this = CURRENT_THREAD; 112 110 113 txt_dmsg("\n[INFO] in %s : thread %x in process %x enters\n", 111 txt_dmsg("\n[INFO] in %s : thread %x in process %x enters\n", 114 112 __FUNCTION__ , this->trdid , this->process->pid ); 115 113 … … 133 131 chdev_register_command( dev_xp , this ); 134 132 135 txt_dmsg("\n[INFO] in %s : thread %x in process %x completes / error = %d\n", 133 txt_dmsg("\n[INFO] in %s : thread %x in process %x completes / error = %d\n", 136 134 __FUNCTION__ , this->trdid , this->process->pid , this->command.txt.error ); 137 135 138 136 // return I/O operation status from calling thread descriptor 139 return this->command.txt.error; 140 141 } // end dev_txt_access() 137 return this->command.txt.error; 138 } 142 139 143 140 ///////////////////////////////////////// … … 148 145 return dev_txt_access( TXT_WRITE , channel , buffer , count ); 149 146 } 150 147 151 148 ///////////////////////////////////////// 152 149 error_t dev_txt_read( uint32_t channel, … … 161 158 uint32_t count ) 162 159 { 163 // get pointer on calling thread 160 // get pointer on calling thread 164 161 thread_t * this = CURRENT_THREAD; 165 162 166 // get extended pointer on TXT[0] chdev 163 // get extended pointer on TXT[0] chdev 167 164 xptr_t dev_xp = chdev_dir.txt[channel]; 168 165 169 166 assert( (dev_xp != XPTR_NULL) , __FUNCTION__ , "undefined TXT0 chdev descriptor" ); 170 167 171 // register command in calling thread 168 // register command in calling thread 172 169 this->command.txt.dev_xp = dev_xp; 173 170 this->command.txt.type = TXT_SYNC_WRITE; … … 175 172 this->command.txt.count = count; 176 173 177 // get driver command function 174 // get driver command function 178 175 cxy_t dev_cxy = GET_CXY( dev_xp ); 179 176 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 180 177 dev_cmd_t * cmd = (dev_cmd_t *)hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->cmd ) ); 181 178 182 // call directly driver command 179 // call directly driver command 183 180 cmd( XPTR( local_cxy , this ) ); 184 181 185 182 // return I/O operation status from calling thread descriptor 186 183 return this->command.txt.error; 187 188 } // end dev_txt_sync_write() 184 } 189 185
Note: See TracChangeset
for help on using the changeset viewer.