Changeset 49 for trunk/kernel
- Timestamp:
- Jun 26, 2017, 1:40:02 PM (7 years ago)
- Location:
- trunk/kernel/devices
- Files:
-
- 2 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 -
trunk/kernel/devices/dev_txt.h
r23 r49 1 1 /* 2 2 * dev_txt.h - TXT (Text Terminal) generic device API definition. 3 * 3 * 4 4 * Author Alain Greiner (2016) 5 5 * … … 35 35 * Generic Text Terminal device definition. 36 36 * 37 * This multi-channels generic TXT device provide access to a text terminal.37 * This multi-channels generic TXT device provides access to a text terminal. 38 38 * It supports three operation types : 39 39 * - TXT_READ : read a single character from the text terminal identified by its channel … … 42 42 * index, using a descheduling strategy for the calling thread. 43 43 * - TXT_SYNC_WRITE : write a character string to the terminal identified by its channel 44 * index, using a busy waiting strategy for the calling thread. 44 * index, using a busy waiting strategy for the calling thread. 45 45 *****************************************************************************************/ 46 46 … … 52 52 enum txt_impl_e 53 53 { 54 IMPL_TXT_TTY = 0, 55 IMPL_TXT_X86 = 1, 54 IMPL_TXT_TTY = 0, 55 IMPL_TXT_X86 = 1, 56 56 } 57 57 txt_impl_t; 58 58 59 59 /****************************************************************************************** 60 * This defines the (implementation independ ant) command passed to the driver.60 * This defines the (implementation independent) command passed to the driver. 61 61 *****************************************************************************************/ 62 62 … … 80 80 /****************************************************************************************** 81 81 * This function completes the TXT chdev descriptor initialisation, 82 i* namely the link with the implementation specific driver.82 * namely the link with the implementation specific driver. 83 83 * The func, impl, channel, is_rxt, base fields have been previously initialised. 84 84 * It calls the specific driver initialisation function, to initialise the hardware … … 92 92 93 93 /****************************************************************************************** 94 * This blocking function read a single character from the terminal identified94 * This blocking function reads a single character from the terminal identified 95 95 * by the "channel" argument. The corresponding request is actually registered in the 96 96 * chdev requests queue, and the calling thread is descheduled, blocked until … … 106 106 107 107 /****************************************************************************************** 108 * This blocking function writes 108 * This blocking function writes characters on the terminal identified 109 109 * by the "channel" argument. The corresponding request is actually registered in the 110 110 * chdev requests queue, and the calling thread is descheduled, blocked until … … 121 121 uint32_t count ); 122 122 123 124 * This low-level blocking function is used by the kernel to display one string on a 125 * given TXT channel without descheduling the calling thread, without registering it126 * in the TXT device waiting queue, and without using the TXT irq. 123 /*************************************************************************************** 124 * This low-level blocking function is used by the kernel to display one string on a 125 * given TXT channel without descheduling the calling thread, without registering it 126 * in the TXT device waiting queue, and without using the TXT irq. 127 127 **************************************************************************************** 128 128 * @ channel : TXT channel index. … … 135 135 uint32_t count ); 136 136 137 138 137 #endif /* _DEV_TXT_H_ */
Note: See TracChangeset
for help on using the changeset viewer.