Changeset 647
- Timestamp:
- Oct 22, 2019, 1:48:51 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 38 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile
r633 r647 46 46 user/idbg/build/idbg.elf \ 47 47 user/sort/build/sort.elf \ 48 user/fft/build/fft.elf 48 user/fft/build/fft.elf \ 49 user/display/build/display.elf \ 50 user/convol/build/convol.elf \ 51 user/transpose/build/transpose.elf 52 49 53 50 54 # Virtual disk path … … 61 65 # when the corresponding sources files have been modified or destroyed. 62 66 # The "home" directory on the virtual disk is not modified 63 compile: dirs \ 64 hard_config.h \ 65 build_libs \ 66 $(BOOTLOADER_PATH)/build/boot.elf \ 67 kernel/build/kernel.elf \ 68 user/init/build/init.elf \ 69 user/ksh/build/ksh.elf \ 70 user/pgcd/build/pgcd.elf \ 71 user/idbg/build/idbg.elf \ 72 user/sort/build/sort.elf \ 73 user/fft/build/fft.elf \ 67 compile: dirs \ 68 hard_config.h \ 69 build_libs \ 70 $(BOOTLOADER_PATH)/build/boot.elf \ 71 kernel/build/kernel.elf \ 72 user/init/build/init.elf \ 73 user/ksh/build/ksh.elf \ 74 user/pgcd/build/pgcd.elf \ 75 user/idbg/build/idbg.elf \ 76 user/sort/build/sort.elf \ 77 user/fft/build/fft.elf \ 78 user/display/build/display.elf \ 79 user/convol/build/convol.elf \ 80 user/transpose/build/transpose.elf \ 74 81 list 75 82 … … 107 114 $(MAKE) -C user/idbg clean 108 115 $(MAKE) -C user/fft clean 116 $(MAKE) -C user/display clean 117 $(MAKE) -C user/convol clean 118 $(MAKE) -C user/transpose clean 109 119 $(MAKE) -C $(HAL_ARCH) clean 110 120 … … 119 129 dd if=$(DISK_IMAGE) of=temp.dmg count=65536 120 130 mv temp.dmg $(DISK_IMAGE) 121 mmd -o -i $(DISK_IMAGE) ::/bin || true 122 mmd -o -i $(DISK_IMAGE) ::/bin/kernel || true 123 mmd -o -i $(DISK_IMAGE) ::/bin/user || true 124 mmd -o -i $(DISK_IMAGE) ::/home || true 131 mmd -o -i $(DISK_IMAGE) ::/bin || true 132 mmd -o -i $(DISK_IMAGE) ::/bin/kernel || true 133 mmd -o -i $(DISK_IMAGE) ::/bin/user || true 134 mmd -o -i $(DISK_IMAGE) ::/home || true 135 mmd -o -i $(DISK_IMAGE) ::/misc || true 136 mcopy -o -i $(DISK_IMAGE) images/lena_256.raw ::/misc || true 137 mcopy -o -i $(DISK_IMAGE) images/images_128.raw ::/misc || true 138 mcopy -o -i $(DISK_IMAGE) images/philips_1024.raw ::/misc || true 125 139 mdir -/ -b -i $(DISK_IMAGE) ::/ 126 140 … … 194 208 $(MAKE) -C user/fft 195 209 mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user 210 user/display/build/display.elf: build_libs 211 $(MAKE) -C user/display 212 mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user 213 user/convol/build/convol.elf: build_libs 214 $(MAKE) -C user/convol 215 mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user 216 user/transpose/build/transpose.elf: build_libs 217 $(MAKE) -C user/transpose 218 mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user -
trunk/hal/generic/hal_drivers.h
r346 r647 25 25 #include <chdev.h> 26 26 27 void hal_drivers_txt_init( chdev_t *txt, uint32_t impl);27 void hal_drivers_txt_init( chdev_t * txt ); 28 28 29 void hal_drivers_pic_init( chdev_t *pic, uint32_t impl);29 void hal_drivers_pic_init( chdev_t * pic ); 30 30 31 void hal_drivers_iob_init( chdev_t *iob, uint32_t impl);31 void hal_drivers_iob_init( chdev_t * iob ); 32 32 33 void hal_drivers_ioc_init( chdev_t *ioc, uint32_t impl);33 void hal_drivers_ioc_init( chdev_t * ioc ); 34 34 35 void hal_drivers_mmc_init( chdev_t *mmc, uint32_t impl);35 void hal_drivers_mmc_init( chdev_t * mmc ); 36 36 37 void hal_drivers_nic_init( chdev_t *nic, uint32_t impl);37 void hal_drivers_nic_init( chdev_t * nic ); 38 38 39 void hal_drivers_dma_init(chdev_t *dma, uint32_t impl); 39 void hal_drivers_dma_init( chdev_t * dma ); 40 41 void hal_drivers_fbf_init( chdev_t * fbf ); 40 42 41 43 #endif /* HAL_DRIVERS_H_ */ -
trunk/hal/tsar_mips32/Makefile
r570 r647 24 24 $(HAL_ARCH)/build/drivers/soclib_dma.o \ 25 25 $(HAL_ARCH)/build/drivers/soclib_mmc.o \ 26 $(HAL_ARCH)/build/drivers/soclib_fbf.o \ 26 27 $(HAL_ARCH)/build/drivers/soclib_iob.o 27 28 -
trunk/hal/tsar_mips32/core/hal_context.c
r640 r647 221 221 222 222 // get base and ppn of remote child process GPT PT1 223 child_gpt_ptr = hal_remote_l 32( XPTR(child_cxy , &child_process->vmm.gpt.ptr) );223 child_gpt_ptr = hal_remote_lpt( XPTR(child_cxy , &child_process->vmm.gpt.ptr) ); 224 224 child_gpt_ppn = ppm_base2ppn( XPTR( child_cxy , child_gpt_ptr ) ); 225 225 -
trunk/hal/tsar_mips32/core/hal_drivers.c
r570 r647 34 34 #include <soclib_nic.h> 35 35 #include <soclib_dma.h> 36 #include <soclib_fbf.h> 36 37 37 38 #include <dev_txt.h> … … 46 47 /////////////////////////////////////////////////////////////////////////////// 47 48 48 ////////////////////////////////////////// 49 void hal_drivers_txt_init( chdev_t * txt, 50 uint32_t impl ) 49 /////////////////////////////////////////// 50 void hal_drivers_txt_init( chdev_t * txt ) 51 51 { 52 uint32_t impl = txt->impl; 53 52 54 if( impl == IMPL_TXT_TTY ) 53 55 { … … 68 70 /////////////////////////////////////////////////////////////////////////////// 69 71 70 ////////////////////////////////////////// 71 void hal_drivers_pic_init( chdev_t * pic, 72 uint32_t impl ) 72 /////////////////////////////////////////// 73 void hal_drivers_pic_init( chdev_t * pic ) 73 74 { 75 uint32_t impl = pic->impl; 76 74 77 assert( (impl == IMPL_PIC_SCL), "undefined implementation" ); 75 78 … … 91 94 /////////////////////////////////////////////////////////////////////////////// 92 95 93 ////////////////////////////////////////// 94 void hal_drivers_iob_init( chdev_t * iob, 95 uint32_t impl ) 96 /////////////////////////////////////////// 97 void hal_drivers_iob_init( chdev_t * iob ) 96 98 { 99 uint32_t impl = iob->impl; 100 97 101 assert( (impl == IMPL_IOB_TSR), "undefined implementation" ); 98 102 … … 112 116 /////////////////////////////////////////////////////////////////////////////// 113 117 114 ////////////////////////////////////////// 115 void hal_drivers_ioc_init( chdev_t * ioc, 116 uint32_t impl ) 118 /////////////////////////////////////////// 119 void hal_drivers_ioc_init( chdev_t * ioc ) 117 120 { 121 uint32_t impl = ioc->impl; 122 118 123 if (impl == IMPL_IOC_BDV) 119 124 { … … 138 143 /////////////////////////////////////////////////////////////////////////////// 139 144 140 ////////////////////////////////////////// 141 void hal_drivers_mmc_init( chdev_t * mmc, 142 uint32_t impl ) 145 /////////////////////////////////////////// 146 void hal_drivers_mmc_init( chdev_t * mmc ) 143 147 { 148 uint32_t impl = mmc->impl; 149 144 150 assert( (impl == IMPL_MMC_TSR), "undefined implementation" ); 145 151 … … 151 157 /////////////////////////////////////////////////////////////////////////////// 152 158 153 ////////////////////////////////////////// 154 void hal_drivers_nic_init( chdev_t * nic, 155 uint32_t impl ) 159 /////////////////////////////////////////// 160 void hal_drivers_nic_init( chdev_t * nic ) 156 161 { 162 uint32_t impl = nic->impl; 163 157 164 assert( (impl == IMPL_NIC_CBF), "undefined implementation" ); 158 165 … … 164 171 /////////////////////////////////////////////////////////////////////////////// 165 172 166 ////////////////////////////////////////// 167 void hal_drivers_dma_init( chdev_t * dma, 168 uint32_t impl ) 173 /////////////////////////////////////////// 174 void hal_drivers_dma_init( chdev_t * dma ) 169 175 { 176 uint32_t impl = dma->impl; 177 170 178 assert( (impl == IMPL_DMA_SCL), "undefined implementation" ); 171 179 … … 173 181 } 174 182 183 /////////////////////////////////////////////////////////////////////////////// 184 // FBF 185 /////////////////////////////////////////////////////////////////////////////// 186 187 /////////////////////////////////////////// 188 void hal_drivers_fbf_init( chdev_t * fbf ) 189 { 190 uint32_t impl = fbf->impl; 191 192 assert( (impl == IMPL_FBF_SCL), "undefined implementation" ); 193 194 soclib_fbf_init( fbf ); 195 } 196 -
trunk/hal/tsar_mips32/core/hal_gpt.c
r640 r647 24 24 #include <hal_kernel_types.h> 25 25 #include <hal_gpt.h> 26 #include <hal_vmm.h> 26 27 #include <hal_special.h> 27 28 #include <hal_irqmask.h> … … 291 292 uint32_t cycle = (uint32_t)hal_get_cycles(); 292 293 // if( DEBUG_HAL_GPT_LOCK_PTE < cycle ) 293 if( (vpn == 0x 3600) && (gpt_cxy == 0x11) )294 if( (vpn == 0xc1fff) && (gpt_cxy == 0x1) ) 294 295 printk("\n[%s] thread[%x,%x] enters / vpn %x in cluster %x / cycle %d\n", 295 296 __FUNCTION__, this->process->pid, this->trdid, vpn, gpt_cxy, cycle ); … … 360 361 #if DEBUG_HAL_GPT_LOCK_PTE 361 362 // if( DEBUG_HAL_GPT_LOCK_PTE < cycle ) 362 if( (vpn == 0x 3600) && (gpt_cxy == 0x11) )363 if( (vpn == 0xc1fff) && (gpt_cxy == 0x1) ) 363 364 printk("\n[%s] PTE1 unmapped : winner thread[%x,%x] allocates a PT2 for vpn %x in cluster %x\n", 364 365 __FUNCTION__, this->process->pid, this->trdid, vpn, gpt_cxy ); … … 371 372 #if DEBUG_HAL_GPT_LOCK_PTE 372 373 // if( DEBUG_HAL_GPT_LOCK_PTE < cycle ) 373 if( (vpn == 0x 3600) && (gpt_cxy == 0x11) )374 if( (vpn == 0xc1fff) && (gpt_cxy == 0x1) ) 374 375 printk("\n[%s] PTE1 unmapped : loser thread[%x,%x] wait PTE1 for vpn %x in cluster %x\n", 375 376 __FUNCTION__, this->process->pid, this->trdid, vpn, gpt_cxy ); … … 412 413 #if DEBUG_HAL_GPT_LOCK_PTE 413 414 // if( DEBUG_HAL_GPT_LOCK_PTE < cycle ) 414 if( (vpn == 0x 3600) && (gpt_cxy == 0x11) )415 if( (vpn == 0xc1fff) && (gpt_cxy == 0x1) ) 415 416 printk("\n[%s] PTE1 unmapped : loser thread[%x,%x] get PTE1 for vpn %x in cluster %x\n", 416 417 __FUNCTION__, this->process->pid, this->trdid, vpn, gpt_cxy ); … … 426 427 #if DEBUG_HAL_GPT_LOCK_PTE 427 428 // if( DEBUG_HAL_GPT_LOCK_PTE < cycle ) 428 if( (vpn == 0x 3600) && (gpt_cxy == 0x11) )429 if( (vpn == 0xc1fff) && (gpt_cxy == 0x1) ) 429 430 printk("\n[%s] thread[%x,%x] get pte1 %x for vpn %x in cluster %x\n", 430 431 __FUNCTION__, this->process->pid, this->trdid, pte1, vpn, gpt_cxy ); … … 494 495 cycle = (uint32_t)hal_get_cycles(); 495 496 // if( DEBUG_HAL_GPT_LOCK_PTE < cycle ) 496 if( (vpn == 0x 3600) && (gpt_cxy == 0x11) )497 if( (vpn == 0xc1fff) && (gpt_cxy == 0x1) ) 497 498 printk("\n[%s] thread[%x,%x] success / vpn %x in cluster %x / attr %x / ppn %x / cycle %d\n", 498 499 __FUNCTION__, this->process->pid, this->trdid, vpn, gpt_cxy, pte2_attr, pte2_ppn, cycle ); -
trunk/hal/tsar_mips32/core/hal_remote.c
r625 r647 220 220 "mtc2 %4, $24 \n" /* PADDR_EXT <= cxy */ 221 221 "or $8, $0, %3 \n" /* $8 <= new */ 222 "ll $3, 0(%1) \n" /* $3 <= *p addr*/222 "ll $3, 0(%1) \n" /* $3 <= *ptr */ 223 223 "bne $3, %2, 1f \n" /* if ($3 != old) */ 224 224 "li $7, 0 \n" /* $7 <= 0 */ 225 "sc $8, (%1) \n" /* *p addr <= new*/225 "sc $8, (%1) \n" /* *ptr <= new */ 226 226 "or $7, $8, $0 \n" /* $7 <= atomic */ 227 227 "sync \n" -
trunk/hal/tsar_mips32/core/hal_uspace.c
r637 r647 142 142 // If the two buffers are aligned on a word boundary, it moves the data word per word 143 143 // in a first loop, and moves byte per byte the remaining bytes in a second loop. 144 // If the buffers are not aligned, it moves all data byte per byte.144 // If the buffers are not word aligned, it moves all data byte per byte. 145 145 /////////////////////////////////////////////////////////////////////////////////////// 146 146 // @ u_dst_ptr : pointer on destination user buffer -
trunk/hal/tsar_mips32/drivers/soclib_bdv.c
r626 r647 33 33 void soclib_bdv_init( chdev_t * chdev ) 34 34 { 35 // get extended pointer on SOCLIB_BDV peripheral base 36 xptr_t bdv_xp = chdev->base; 37 38 // set driver specific fields 35 // set driver specific fields in IOC chdev 39 36 chdev->cmd = &soclib_bdv_cmd; 40 37 chdev->isr = &soclib_bdv_isr; 41 38 39 // get extended pointer on SOCLIB_BDV peripheral base 40 xptr_t base_xp = chdev->base; 41 42 42 // get hardware device cluster and local pointer 43 cxy_t b dv_cxy = GET_CXY( bdv_xp );44 uint32_t * b dv_ptr = (uint32_t *)GET_PTR( bdv_xp );43 cxy_t base_cxy = GET_CXY( base_xp ); 44 uint32_t * base_ptr = GET_PTR( base_xp ); 45 45 46 46 // get block_size and block_count 47 uint32_t block_size = hal_remote_l32( XPTR( bdv_cxy , bdv_ptr + BDV_BLOCK_SIZE_REG ) );48 uint32_t block_count = hal_remote_l32( XPTR( b dv_cxy , bdv_ptr + BDV_SIZE_REG ) );49 50 // set IOC device descriptor extension47 uint32_t block_size = hal_remote_l32( XPTR( base_cxy , base_ptr + BDV_BLOCK_SIZE_REG ) ); 48 uint32_t block_count = hal_remote_l32( XPTR( base_cxy , base_ptr + BDV_SIZE_REG ) ); 49 50 // set IOC chdev extension fields 51 51 chdev->ext.ioc.size = block_size; 52 52 chdev->ext.ioc.count = block_count; … … 91 91 else assert( false , "illegal command" ); 92 92 93 // get IOC device cluster and local pointer93 // get cluster and local pointer on IOC chdev 94 94 cxy_t ioc_cxy = GET_CXY( ioc_xp ); 95 95 chdev_t * ioc_ptr = GET_PTR( ioc_xp ); … … 131 131 // waiting policy depends on the command type 132 132 // - for IOC_READ / IOC_WRITE commands, this function is called by the server thread 133 // that blocks and deschedules after launching the I/O transfer. 134 // The I/O operation status is reported in the command by the ISR. 135 // - for IOC_SYNC_READ / IOC_SYNC_WRITE command, this function is called by the client 136 // thread that polls the BDV status register until I/O transfer completion. 133 // => block and deschedule after launching the I/O transfer. 134 // The I/O operation status is reported in the command by the ISR, and the 135 // server thread is re-activated by the ISR. 136 // - for IOC_SYNC_READ / IOC_SYNC_WRITE, this function is called by the client thread 137 // => mask the IOC IRQ and poll the BDV status register until I/O transfer completion, 138 // and report status in the command. 137 139 138 140 if( (cmd_type == IOC_SYNC_READ) || (cmd_type == IOC_SYNC_WRITE) ) // polling policy 139 141 { 142 // get core handling the IOC IRQ 143 thread_t * server = (thread_t *)hal_remote_lpt( XPTR( ioc_cxy , &ioc_ptr->server ) ); 144 core_t * core = (core_t *)hal_remote_lpt( XPTR( ioc_cxy , &server->core ) ); 145 lid_t lid = (lid_t)hal_remote_l32( XPTR( ioc_cxy , &core->lid ) ); 146 147 // mask the IOC IRQ 148 dev_pic_disable_irq( lid , ioc_xp ); 149 140 150 // launch I/O operation on BDV device 141 151 hal_remote_s32( XPTR( seg_cxy , seg_ptr + BDV_OP_REG ) , op ); … … 149 159 (status == BDV_WRITE_SUCCESS) ) // successfully completed 150 160 { 161 // unmask IOC IRQ 162 dev_pic_enable_irq( lid , ioc_xp ); 163 164 // report success in command 151 165 hal_remote_s32( XPTR( th_cxy , &th_ptr->ioc_cmd.error ) , 0 ); 152 166 … … 154 168 cycle = (uint32_t)hal_get_cycles(); 155 169 if( (DEBUG_HAL_IOC_RX < cycle) && (cmd_type == IOC_SYNC_READ) ) 156 printk("\n[%s] thread[%x,%x] exit after SYNC_READfor client thread[%x,%x] / cycle %d\n",170 printk("\n[%s] thread[%x,%x] SYNC_READ success for client thread[%x,%x] / cycle %d\n", 157 171 __FUNCTION__, this->process->pid, this->trdid, client_pid, client_trdid, cycle ); 158 172 #endif … … 161 175 cycle = (uint32_t)hal_get_cycles(); 162 176 if( (DEBUG_HAL_IOC_TX < cycle) && (cmd_type == IOC_SYNC_WRITE) ) 163 printk("\n[%s] thread[%x,%x] exit after SYNC_WRITEfor client thread[%x,%x] / cycle %d\n",177 printk("\n[%s] thread[%x,%x] SYNC_WRITE success for client thread[%x,%x] / cycle %d\n", 164 178 __FUNCTION__, this->process->pid, this->trdid, client_pid, client_trdid, cycle ); 165 179 #endif … … 172 186 else // error reported 173 187 { 188 // unmask IOC IRQ 189 dev_pic_enable_irq( lid , ioc_xp ); 190 191 // report failure in command 174 192 hal_remote_s32( XPTR( th_cxy , &th_ptr->ioc_cmd.error ) , 1 ); 193 194 #if DEBUG_HAL_IOC_RX 195 cycle = (uint32_t)hal_get_cycles(); 196 if( (DEBUG_HAL_IOC_RX < cycle) && (cmd_type == IOC_SYNC_READ) ) 197 printk("\n[%s] thread[%x,%x] SYNC_READ failure for client thread[%x,%x] / cycle %d\n", 198 __FUNCTION__, this->process->pid, this->trdid, client_pid, client_trdid, cycle ); 199 #endif 200 201 #if DEBUG_HAL_IOC_TX 202 cycle = (uint32_t)hal_get_cycles(); 203 if( (DEBUG_HAL_IOC_TX < cycle) && (cmd_type == IOC_SYNC_WRITE) ) 204 printk("\n[%s] thread[%x,%x] SYNC_WRITE failure for client thread[%x,%x] / cycle %d\n", 205 __FUNCTION__, this->process->pid, this->trdid, client_pid, client_trdid, cycle ); 206 #endif 175 207 break; 176 208 } -
trunk/hal/tsar_mips32/drivers/soclib_fbf.c
r75 r647 2 2 * soclib_fbf.c - soclib frame-buffer driver implementation. 3 3 * 4 * Author Alain greiner (2016 )4 * Author Alain greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 22 22 */ 23 23 24 #include <soclib_fbf.h> 25 #include <hal_kernel_types.h> 26 #include <hal_uspace.h> 27 #include <chdev.h> 28 #include <dev_fbf.h> 29 #include <printk.h> 30 #include <thread.h> 31 32 /////////////////////////////////////// 33 void soclib_fbf_init( chdev_t * chdev ) 34 { 35 // set driver specific fields in FBF chdev 36 chdev->cmd = &soclib_fbf_cmd; 37 chdev->isr = NULL; 38 39 // get extended pointer on SOCLIB_FBF peripheral segment base 40 xptr_t base_xp = chdev->base; 41 42 // get cluster and local pointer for the SOCLIB_FBF peripheral segment 43 cxy_t base_cxy = GET_CXY( base_xp ); 44 uint32_t * base_ptr = GET_PTR( base_xp ); 45 46 // get frame buffer width, height, and type 47 uint32_t width = hal_remote_l32( XPTR( base_cxy , base_ptr + FBF_WIDTH_REG ) ); 48 uint32_t height = hal_remote_l32( XPTR( base_cxy , base_ptr + FBF_HEIGHT_REG ) ); 49 uint32_t type = hal_remote_l32( XPTR( base_cxy , base_ptr + FBF_SUBSAMPLING_REG ) ); 50 51 // set FBF chdev extension fields 52 chdev->ext.fbf.width = width; 53 chdev->ext.fbf.height = height; 54 chdev->ext.fbf.subsampling = type; 55 56 } // end soclib_fbf_init() 57 58 ///////////////////////////////////////////////////////////////// 59 void __attribute__((noinline)) soclib_fbf_cmd( xptr_t thread_xp ) 60 { 61 uint32_t cmd_type; // READ / WRITE / SYNC_READ / SYNC_WRITE 62 uint32_t offset; 63 uint32_t length; 64 void * buffer; // pointer on memory buffer in user space 65 xptr_t fbf_xp; 66 uint32_t status; // I/0 operation status (from BDV) 67 68 // get client thread cluster and local pointer 69 cxy_t th_cxy = GET_CXY( thread_xp ); 70 thread_t * th_ptr = GET_PTR( thread_xp ); 71 72 #if (DEBUG_HAL_FBF|| DEBUG_HAL_FBF) 73 uint32_t cycle = (uint32_t)hal_get_cycles(); 74 thread_t * this = CURRENT_THREAD; 75 process_t * process = hal_remote_lpt( XPTR( th_cxy , &th_ptr->process ) ); 76 pid_t client_pid = hal_remote_l32( XPTR( th_cxy , &process->pid ) ); 77 trdid_t client_trdid = hal_remote_l32( XPTR( th_cxy , &th_ptr->trdid ) ); 78 #endif 79 80 // get command arguments 81 cmd_type = hal_remote_l32( XPTR( th_cxy , &th_ptr->fbf_cmd.type ) ); 82 offset = hal_remote_l32( XPTR( th_cxy , &th_ptr->fbf_cmd.offset ) ); 83 length = hal_remote_l32( XPTR( th_cxy , &th_ptr->fbf_cmd.length ) ); 84 buffer = hal_remote_lpt( XPTR( th_cxy , &th_ptr->fbf_cmd.buffer ) ); 85 fbf_xp = (xptr_t)hal_remote_l64( XPTR( th_cxy , &th_ptr->fbf_cmd.dev_xp ) ); 86 87 // get cluster and local pointer on FBF chdev 88 cxy_t fbf_cxy = GET_CXY( fbf_xp ); 89 chdev_t * fbf_ptr = GET_PTR( fbf_xp ); 90 91 // get extended pointer on SOCLIB_FBF peripheral segment base 92 xptr_t base_xp = (xptr_t)hal_remote_l64( XPTR( fbf_cxy , &fbf_ptr->base ) ); 93 94 // execute command 95 if( cmd_type == FBF_READ ) // use a (kernel -> user) memcpy 96 { 97 98 #if DEBUG_HAL_FBF 99 if( DEBUG_HAL_FBF < cycle ) 100 printk("\n[%s] thread[%x,%x] / client[%x,%x] / READ / offset / length / buffer %x / cycle %d\n", 101 __FUNCTION__ , this->process->pid, this->trdid, client_pid, client_trdid, 102 offset, length, buffer, cycle ); 103 #endif 104 hal_copy_to_uspace( buffer, 105 base_xp + offset, 106 length ); 107 108 } 109 else // cmd_type == FBF_WRITE => use a (user -> kernel) memcpy 110 { 111 112 #if DEBUG_HAL_FBF 113 if( DEBUG_HAL_FBF < cycle ) 114 printk("\n[%s] thread[%x,%x] / client[%x,%x] / WRITE / offset / length / buffer %x / cycle %d\n", 115 __FUNCTION__ , this->process->pid, this->trdid, client_pid, client_trdid, 116 offset, length, buffer, cycle ); 117 #endif 118 hal_copy_from_uspace( base_xp + offset, 119 buffer, 120 length ); 121 } 122 123 // set success in command 124 hal_remote_s32( XPTR( th_cxy , &th_ptr->fbf_cmd.error ) , 0 ); 125 126 } // end soclib_fbf_cmd() 127 -
trunk/hal/tsar_mips32/drivers/soclib_fbf.h
r75 r647 1 1 /* 2 * soclib_fbf.h - soclib frame-buffer driver definition .2 * soclib_fbf.h - soclib frame-buffer driver definition (used in TSAR_IOB architecture). 3 3 * 4 * Author Alain greiner (2016 )4 * Author Alain greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 22 22 */ 23 23 24 #ifndef _SOCLIB_FB _H_25 #define _SOCLIB_FB _H_24 #ifndef _SOCLIB_FBF_H_ 25 #define _SOCLIB_FBF_H_ 26 26 27 #include <chdev.h> 28 #include <hal_kernel_types.h> 29 30 /**************************************************************************************** 31 * This driver supports the vci_fbf_tsar component. 32 * 33 * This hardware component supports both a frame buffer, and a set of addressable 34 * configuration status registers. 35 ***************************************************************************************/ 36 37 /**************************************************************************************** 38 * SOCLIB_FBF registers offsets 39 * The three addressables registers are on top of the 4 Mbytes allocated 40 * to the frame buffer itself. 41 ***************************************************************************************/ 42 43 enum SoclibFrameBufferRegisters 44 { 45 FBF_WIDTH_REG = 0x100000, 46 FBF_HEIGHT_REG = 0x100001, 47 FBF_SUBSAMPLING_REG = 0x100002, 48 }; 49 50 /**************************************************************************************** 51 * This function access the SOCLIB_FBF hardware registers, to get the frame buffer 52 * size and type, and update the FBF device extension. 53 **************************************************************************************** 54 * @ chdev : pointer on the FBF chdev descriptor. 55 ***************************************************************************************/ 56 void soclib_fbf_init( chdev_t * chdev ); 57 58 /**************************************************************************************** 59 * This function implements the FBF_READ and FBF_WRITE commands registered in the client 60 * thread descriptor identified by the <thread_xp> argument. 61 * It is called directly by the client thread. 62 * ************************************************************************************** 63 * @ thread_xp : extended pointer on client thread descriptor. 64 ***************************************************************************************/ 65 extern void soclib_fbf_cmd( xptr_t thread_xp ); 27 66 28 67 #endif -
trunk/kernel/Makefile
r641 r647 19 19 $(HAL_ARCH)/build/drivers/soclib_nic.o \ 20 20 $(HAL_ARCH)/build/drivers/soclib_dma.o \ 21 $(HAL_ARCH)/build/drivers/soclib_fbf.o \ 21 22 $(HAL_ARCH)/build/drivers/soclib_iob.o 22 23 … … 190 191 build/syscalls/sys_get_best_core.o \ 191 192 build/syscalls/sys_get_nb_cores.o \ 192 build/syscalls/sys_get_thread_info.o 193 build/syscalls/sys_get_thread_info.o \ 194 build/syscalls/sys_fbf.o 193 195 194 196 VFS_OBJS = build/fs/vfs.o \ … … 231 233 232 234 233 ############################## 235 ###################################### 234 236 # rules to compile the drivers and hal 235 237 $(HAL_ARCH)/build/%: -
trunk/kernel/devices/dev_dma.c
r637 r647 41 41 void dev_dma_init( chdev_t * dma ) 42 42 { 43 // get implementation & channel from DMA dma descriptor 44 uint32_t impl = dma->impl; 43 // get channel from chdev descriptor 45 44 uint32_t channel = dma->channel; 46 45 … … 49 48 50 49 // call driver init function 51 hal_drivers_dma_init( dma , impl);50 hal_drivers_dma_init( dma ); 52 51 53 52 // bind IRQ to the core defined by the DMA channel … … 104 103 xptr_t dev_xp = chdev_dir.dma[channel]; 105 104 106 assert( (dev_xp != XPTR_NULL) , "undefined DMA chdev descriptor" ); 105 // check DMA chdev definition 106 assert( (dev_xp != XPTR_NULL) , "undefined DMA chdev descriptor" ); 107 107 108 108 // register command in calling thread descriptor -
trunk/kernel/devices/dev_dma.h
r565 r647 36 36 * to/from remote clusters. The burst size is defined by the cache line size. 37 37 * Each DMA channel is described by a specific chdev descriptor, handling its private 38 * waiting threads queue. 39 * It implement one single command : move data from a (remote) source buffer 40 * to a (remote) destination buffer. 38 * waiting threads queue. It implement one single command : move data from a (remote) 39 * source buffer to a (remote) destination buffer. 41 40 ****************************************************************************************/ 42 41 -
trunk/kernel/devices/dev_fbf.c
r565 r647 1 1 /* 2 * dev_fbf.c - FBF ( Block Device Controler) generic device API implementation.2 * dev_fbf.c - FBF (Frame Buffer) generic device API implementation. 3 3 * 4 * Author Alain Greiner (2016,2017,2018 )4 * Author Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 25 25 #include <hal_kernel_types.h> 26 26 #include <hal_gpt.h> 27 #include <hal_drivers.h> 27 28 #include <thread.h> 28 29 #include <printk.h> … … 37 38 extern chdev_directory_t chdev_dir; // allocated in kernel_init.c 38 39 40 /////////////////////////////////////////// 41 char * dev_fbf_cmd_str( uint32_t cmd_type ) 42 { 43 if ( cmd_type == FBF_READ ) return "READ"; 44 else if( cmd_type == FBF_WRITE ) return "WRITE"; 45 else if( cmd_type == FBF_GET_CONFIG ) return "GET_CONFIG"; 46 else return "undefined"; 47 } 48 39 49 //////////////////////////////////// 40 void dev_fbf_init( chdev_t * chdev)50 void dev_fbf_init( chdev_t * fbf ) 41 51 { 42 // set FBF chdev extension fields43 // TODO this should be done in the implementation44 // TODO specific part, as these parameters must be obtained from the hardware.45 chdev->ext.fbf.width = CONFIG_FBF_WIDTH;46 chdev->ext.fbf.height = CONFIG_FBF_HEIGHT;47 48 // get implementation49 uint32_t impl = chdev->impl;50 51 52 // set chdev name 52 strcpy( chdev->name, "fbf" );53 strcpy( fbf->name, "fbf" ); 53 54 54 55 // call driver init function 55 if( impl == IMPL_FBF_SCL ) 56 { 57 printk("\n[WARNING] Soclib FBF driver not implemented yet\n"); 58 } 59 else 60 { 61 assert( false , "undefined FBF device implementation" ); 62 } 56 hal_drivers_fbf_init( fbf ); 63 57 64 58 } // end dev_fbf_init() 65 59 66 ///////////////////////////////////////// 67 void dev_fbf_get_size( uint32_t * width, 68 uint32_t * height ) 60 ////////////////////////////////////////// 61 void dev_fbf_get_config( uint32_t * width, 62 uint32_t * height, 63 uint32_t * type ) 69 64 { 70 65 // get extended pointer on FBF chdev descriptor … … 80 75 *width = hal_remote_l32( XPTR( dev_cxy , &dev_ptr->ext.fbf.width ) ); 81 76 *height = hal_remote_l32( XPTR( dev_cxy , &dev_ptr->ext.fbf.height ) ); 77 *type = hal_remote_l32( XPTR( dev_cxy , &dev_ptr->ext.fbf.subsampling ) ); 82 78 83 } // end dev_fbf_get_ size()79 } // end dev_fbf_get_config() 84 80 85 ///////////////////////////// 86 error_t dev_fbf_alloc( void ) 81 ///////////////////////////////////////////////////// 82 error_t dev_fbf_move_data( uint32_t cmd_type, 83 void * user_buffer, 84 uint32_t length, 85 uint32_t offset ) 87 86 { 88 // get extended pointer on FBF chdev descriptor89 // xptr_t dev_xp = chdev_dir.fbf[0];87 // get pointer on calling thread 88 thread_t * this = CURRENT_THREAD; 90 89 91 // assert( (dev_xp != XPTR_NULL) , "undefined FBF chdev descriptor" ); 90 #if DEBUG_DEV_FBF 91 uint32_t cycle = (uint32_t)hal_get_cycles(); 92 if( DEBUG_DEV_FBF < cycle ) 93 printk("\n[%s] thread[%x,%x] : %s / buffer %x / length %d / offset %x / cycle %d\n", 94 __FUNCTION__ , this->process->pid, this->trdid, 95 dev_fbf_cmd_str(cmd_type), user_buffer, length, offset, cycle ); 96 #endif 92 97 93 // get FBF chdev cluster and local pointer 94 // cxy_t dev_cxy = GET_CXY( dev_xp ); 95 // chdev_t * dev_ptr = GET_PTR( dev_xp ); 98 // get pointers on FBF chdev 99 xptr_t fbf_xp = chdev_dir.fbf[0]; 100 cxy_t fbf_cxy = GET_CXY( fbf_xp ); 101 chdev_t * fbf_ptr = GET_PTR( fbf_xp ); 96 102 97 // try to get FBF ownership 103 // check fbf_xp definition 104 assert( (fbf_xp != XPTR_NULL) , "undefined FBF chdev descriptor" ); 98 105 99 assert( false , "not implemented yet" ); 100 101 } // end dev_fbf_alloc() 102 103 ///////////////////////// 104 void dev_fbf_free( void ) 105 { 106 // get extended pointer on FBF chdev descriptor 107 // xptr_t dev_xp = chdev_dir.fbf[0]; 108 109 // assert( (dev_xp != XPTR_NULL) , "undefined FBF chdev descriptor" ); 110 111 // get FBF chdev cluster and local pointer 112 // cxy_t dev_cxy = GET_CXY( dev_xp ); 113 // chdev_t * dev_ptr = (GET_PTR( dev_xp ); 114 115 // release FBF ownership 116 117 assert( false , "not implemented yet" ); 118 119 } // end dev_fbf_free() 120 121 ////////////////////////////////////////////////////////////////////////////////// 122 // This static function is called by dev_fbf_read() & dev_fbf_write() functions. 123 // It builds and registers the command in the calling thread descriptor. 124 // Then, it registers the calling thread in the relevant DMA chdev waiting queue. 125 // Finally it blocks on the THREAD_BLOCKED_DEV condition and deschedule. 126 ////////////////////////////////////i///////////////////////////////////////////// 127 static error_t dev_fbf_access( bool_t to_fbf, 128 char * buffer, 129 uint32_t length, 130 uint32_t offset ) 131 { 132 133 // get extended pointer on FBF chdev descriptor 134 xptr_t fbf_xp = chdev_dir.fbf[0]; 135 136 assert( (fbf_xp != XPTR_NULL) , "undefined FBF chdev descriptor" ); 137 138 // get FBF chdev cluster and local pointer 139 cxy_t fbf_cxy = GET_CXY( fbf_xp ); 140 chdev_t * fbf_ptr = (chdev_t *)GET_PTR( fbf_xp ); 141 142 // get frame buffer base address, width and height 143 xptr_t base = hal_remote_l64( XPTR( fbf_cxy , &fbf_ptr->base ) ); 106 // get frame buffer width and height 144 107 uint32_t width = hal_remote_l32 ( XPTR( fbf_cxy , &fbf_ptr->ext.fbf.width ) ); 145 108 uint32_t height = hal_remote_l32 ( XPTR( fbf_cxy , &fbf_ptr->ext.fbf.height ) ); 146 109 147 148 149 110 // check offset and length versus FBF size 111 assert( ((offset + length) <= (width * height)) , 112 "offset %d / length %d / width %d / height %d\n", offset, length, width, height ); 150 113 151 // compute extended pointers on frame buffer and memory buffer 152 xptr_t mem_buf_xp = XPTR( local_cxy , buffer ); 153 xptr_t fbf_buf_xp = base + offset; 114 // register command in calling thread descriptor 115 this->fbf_cmd.dev_xp = fbf_xp; 116 this->fbf_cmd.type = cmd_type; 117 this->fbf_cmd.buffer = user_buffer; 118 this->fbf_cmd.offset = offset; 119 this->fbf_cmd.length = length; 154 120 155 // register command in DMA chdev 156 if( to_fbf ) dev_dma_remote_memcpy( fbf_buf_xp , mem_buf_xp , length ); 157 else dev_dma_remote_memcpy( mem_buf_xp , fbf_buf_xp , length ); 121 // get driver command function 122 dev_cmd_t * cmd = (dev_cmd_t *)hal_remote_lpt( XPTR( fbf_cxy , &fbf_ptr->cmd ) ); 158 123 159 return 0; 124 // call driver 125 cmd( XPTR( local_cxy , this ) ); 160 126 161 } // end dev_fbf_access() 127 error_t error = this->fbf_cmd.error; 162 128 163 //////////////////////////////////////////// 164 error_t dev_fbf_read( char * buffer, 165 uint32_t length, 166 uint32_t offset ) 167 { 168 169 #if DEBUG_DEV_FBF_RX 170 uint32_t cycle = (uint32_t)hal_get_cycles(); 171 if( DEBUG_DEV_FBF_RX < cycle ) 172 printk("\n[DBG] %s : thread %x enter / process %x / vaddr %x / size %x\n", 173 __FUNCTION__ , this, this->process->pid , buffer , buf_paddr ); 129 #if DEBUG_DEV_FBF 130 cycle = (uint32_t)hal_get_cycles(); 131 if( DEBUG_DEV_FBF < cycle ) 132 printk("\n[%s] thread[%x,%x] completes %s / error = %d / cycle %d\n", 133 __FUNCTION__ , this->process->pid, this->trdid, 134 dev_fbf_cmd_str(cmd_type), error , cycle ); 174 135 #endif 175 136 176 return dev_fbf_access( false , buffer , length , offset ); 137 // return I/O operation status 138 return error; 177 139 178 #if DEBUG_DEV_FBF_RX 179 cycle = (uint32_t)hal_get_cycles(); 180 if( DEBUG_DEV_FBF_RX < cycle ) 181 printk("\n[DBG] %s : thread %x exit / process %x / vaddr %x / size %x\n", 182 __FUNCTION__ , this, this->process->pid , buffer , buf_paddr ); 183 #endif 184 185 } 186 187 //////////////////////////////////////////// 188 error_t dev_fbf_write( char * buffer, 189 uint32_t length, 190 uint32_t offset ) 191 { 192 193 #if DEBUG_DEV_FBF_TX 194 uint32_t cycle = (uint32_t)hal_get_cycles(); 195 if( DEBUG_DEV_FBF_TX < cycle ) 196 printk("\n[DBG] %s : thread %x enter / process %x / vaddr %x / size %x\n", 197 __FUNCTION__ , this, this->process->pid , buffer , buf_paddr ); 198 #endif 199 200 return dev_fbf_access( true , buffer , length , offset ); 201 202 #if DEBUG_DEV_FBF_RX 203 cycle = (uint32_t)hal_get_cycles(); 204 if( DEBUG_DEV_FBF_RX < cycle ) 205 printk("\n[DBG] %s : thread %x exit / process %x / vaddr %x / size %x\n", 206 __FUNCTION__ , this, this->process->pid , buffer , buf_paddr ); 207 #endif 208 209 } 140 } // end dev_fbf_move_data() -
trunk/kernel/devices/dev_fbf.h
r483 r647 2 2 * dev_fbf.h - FBF (Block Device Controler) generic device API definition. 3 3 * 4 * Author Alain Greiner (2016 )4 * Author Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 26 26 27 27 #include <hal_kernel_types.h> 28 #include <shared_fbf.h> 28 29 29 30 /**** Forward declarations ****/ … … 36 37 * This device provide access to an external graphic display, that is seen 37 38 * as a fixed size frame buffer, mapped in the kernel address space. 38 * Each pixel takes one byte defining 256 levels of gray.39 * The supported pixel encoding types are defined in the <shared_fbf.h> file. 39 40 * 40 * It supports five command types: 41 * - SIZE : return the Frame buffer width and height. 42 * - ALLOC : give exclusive ownership of the frame buffer to the requesting process. 43 * - FREE : release the exclusive ownership to the kernel. 44 * - READ : move a given number of bytes from the frame buffer to a memory buffer. 45 * - WRITE : move a given number of bytes from a memory buffer to the frame buffer. 41 * It supports three command types: 42 * GET_CONFIG : return frame buffer size and type. 43 * READ : move bytes from frame buffer to memory / deschedule the calling thread. 44 * WRITE : move bytes from memory to frame buffer / deschedule the calling thread. 46 45 * 47 * It does not creates the associated server thread. 48 * - The SIZE, ALLOC, FREE commands are directly handled by the FBF device. 49 * - The READ & WRITE commands are actually registered in the DMA device waiting queue, 50 * using the local DMA channel defined by the calling core lid. 46 * The READ and WRITE operations do not use the FBF device waiting queue, 47 * the server thread, and the IOC IRQ. The client thread does not deschedule: 48 * it registers the command in the thread descriptor, and calls directly the FBF driver. 49 * that makes a (user <-> kernel) memcpy. 50 * 51 * Note: As we don't use any external DMA to move data, but a purely software approach, 52 * there is no L2/L3 coherence issue. 51 53 *****************************************************************************************/ 52 54 … … 57 59 typedef struct fbf_extend_s 58 60 { 59 uint32_t width; /*! number of pixels per line. */ 60 uint32_t height; /*! total number of lines. */ 61 uint32_t width; /*! number of pixels per line. */ 62 uint32_t height; /*! total number of lines. */ 63 uint32_t subsampling; /*! pixel encoding type. */ 61 64 } 62 65 fbf_extend_t; … … 71 74 IMPL_FBF_SCL = 0, 72 75 IMPL_FBF_I86 = 1, 73 } 76 } 74 77 fbf_impl_t; 75 76 /******************************************************************************************77 * This defines the (implementation independant) command passed to the driver.78 *****************************************************************************************/79 78 80 79 typedef struct fbf_command_s 81 80 { 82 xptr_t dev_xp; /*! extended pointer on device descriptor*/83 uint32_t t o_fbf; /*! requested operation type.*/84 uint32_t length; /*! number of bytes.*/85 uint32_t offset; /*! offset in frame buffer (bytes)*/86 xptr_t buf_xp; /*! extended pointer on memory buffer*/87 uint32_t error; /*! operation status (0 if success)*/81 xptr_t dev_xp; /*! extended pointer on device descriptor */ 82 uint32_t type; /*! requested operation type. */ 83 uint32_t length; /*! number of bytes. */ 84 uint32_t offset; /*! offset in frame buffer (bytes) */ 85 void * buffer; /*! pointer on memory buffer in user space */ 86 uint32_t error; /*! operation status (0 if success) */ 88 87 } 89 88 fbf_command_t; 89 90 91 /****************************************************************************************** 92 * This function returns a printable string for a given FBF command <cmd_type>. 93 ****************************************************************************************** 94 * @ cmd_type : FBF command type (defined in shared_fbf.h file). 95 * @ returns a string pointer. 96 *****************************************************************************************/ 97 char * dev_fbf_cmd_str( uint32_t cmd_type ); 90 98 91 99 /****************************************************************************************** 92 100 * This function completes the FBF chdev descriptor initialisation. 93 101 * It calls the specific driver initialisation function, to initialise the hardware 94 * device and the specific data structures when required by the implementation. 95 * It must be called by a local thread. 96 * 97 * TODO In this first approach, the "width" and "height" parameters are defined 98 * by the CONFIG_FBF_WIDTH & CONFIG_FBF_HEIGHT in the kernel_config.h file. 99 * These parameters should be provided by the driver, accessing dedicated 100 * adressable registers in the FBF controler. 102 * device and the chdev extension. It must be called by a local thread. 101 103 ****************************************************************************************** 102 104 * @ chdev : pointer on FBF chdev descriptor. … … 105 107 106 108 /****************************************************************************************** 107 * This function returns the fixed size frame buffer features. 109 * This function returns the frame buffer size and type. 110 * It does NOT access the hardware, as the size and type have been registered 111 * in the chdev descriptor extension. 108 112 ****************************************************************************************** 109 * @ width : number of pixels (bytes) per line. 110 * @ heigth : total number of lines. 113 * @ width : [out] number of pixels per line. 114 * @ height : [out] total number of lines. 115 * @ type : [out] pixel encoding type. 111 116 *****************************************************************************************/ 112 void dev_fbf_get_size( uint32_t * width, 113 uint32_t * height ); 117 void dev_fbf_get_config( uint32_t * width, 118 uint32_t * height, 119 uint32_t * type ); 114 120 115 121 /****************************************************************************************** 116 * This function try to get the exclusive ownership of the frame buffer. 122 * This blocking function moves <length> bytes between the frame buffer, starting from 123 * byte defined by <offset>, and an user buffer defined by the <user_buffer> argument. 124 * It can be called by a client thread running in any cluster. 125 * The transfer direction are defined by the <cmd_type> argument. 126 * The request is registered in the client thread descriptor, but the client thread is 127 * not descheduled, and calls directly the FBF driver. 117 128 ****************************************************************************************** 118 * @ return 0 if success / return EINVAL if frame buffer already allocated. 119 *****************************************************************************************/ 120 error_t dev_fbf_alloc( void ); 121 122 /****************************************************************************************** 123 * This function releases the exclusive ownership of the frame buffer. 124 *****************************************************************************************/ 125 void dev_fbf_free( void ); 126 127 /****************************************************************************************** 128 * This blocking function try to tranfer <length> bytes from the frame buffer, starting 129 * from <offset>, to the memory buffer defined by <buffer> argument. 130 * The corresponding request is actually registered in the local DMA device waiting 131 * queue that has the same index as the calling core. The calling thread is descheduled, 132 * waiting on transfer completion. It will be resumed by the DMA IRQ signaling completion. 133 ****************************************************************************************** 134 * @ buffer : local pointer on target buffer in memory. 135 * @ length : number of bytes. 136 * @ offset : first byte in frame buffer. 129 * @ cmd_type : FBF_READ / FBF_WRITE / FBF_SYNC_READ / FBF_SYN_WRITE. 130 * @ user_buffer : pointer on memory buffer in user space. 131 * @ length : number of bytes. 132 * @ offset : first byte in frame buffer. 137 133 * @ returns 0 if success / returns EINVAL if error. 138 134 *****************************************************************************************/ 139 error_t dev_fbf_read( char * buffer, 140 uint32_t length, 141 uint32_t offset ); 142 143 /****************************************************************************************** 144 * This blocking function try to tranfer <length> bytes from a memory buffer defined 145 * by <buffer> argument, to the frame buffer, starting from <offset>. 146 * The corresponding request is actually registered in the local DMA device waiting 147 * queue, that has the same index as the calling core. The calling thread is descheduled, 148 * waiting on transfer completion. It will be resumed by the DMA IRQ signaling completion. 149 ****************************************************************************************** 150 * @ buffer : local pointer on source buffer in memory. 151 * @ length : number of bytes. 152 * @ offset : first byte in frame buffer. 153 * @ returns 0 if success / returns EINVAL if error. 154 *****************************************************************************************/ 155 error_t dev_fbf_write( char * buffer, 156 uint32_t length, 157 uint32_t offset ); 135 error_t dev_fbf_move_data( uint32_t cmd_type, 136 void * user_buffer, 137 uint32_t length, 138 uint32_t offset ); 158 139 159 140 #endif /* _DEV_FBF_H */ -
trunk/kernel/devices/dev_iob.c
r565 r647 35 35 void dev_iob_init( chdev_t * chdev ) 36 36 { 37 // get implementation38 uint32_t impl = chdev->impl;39 40 37 // set chdev name 41 38 strcpy( chdev->name , "iob" ); 42 39 43 40 // call driver init function 44 hal_drivers_iob_init( chdev , impl);41 hal_drivers_iob_init( chdev ); 45 42 } 46 43 -
trunk/kernel/devices/dev_ioc.c
r637 r647 50 50 void dev_ioc_init( chdev_t * ioc ) 51 51 { 52 // the PIC chdev must be initialized before the IOC chdev, because 53 // the IOC chdev initialisation requires the routing of an external IRQ 54 xptr_t pic_xp = chdev_dir.pic; 55 56 assert( (pic_xp != XPTR_NULL) , "PIC not initialised before IOC" ); 57 58 // get implementation and channel from chdev descriptor 59 uint32_t impl = ioc->impl; 52 // get channel from chdev descriptor 60 53 uint32_t channel = ioc->channel; 61 54 … … 64 57 65 58 // call driver init function 66 hal_drivers_ioc_init( ioc , impl);59 hal_drivers_ioc_init( ioc ); 67 60 68 61 // select a core to execute the IOC server thread … … 90 83 ioc->server = new_thread; 91 84 92 // set "chdev field in thread descriptor85 // set "chdev" field in thread descriptor 93 86 new_thread->chdev = ioc; 94 87 … … 98 91 } // end dev_ioc_init() 99 92 100 ////////////////////////////////////////////////////////////////////////////////// 101 // This static function is called by dev_ioc_read() & dev_ioc_write() functions. 102 // It builds and registers the command in the calling thread descriptor. 103 // Then, it registers the calling thead in IOC chdev waiting queue. 104 // Finally it blocks on the THREAD_BLOCKED_IO condition and deschedule. 105 ////////////////////////////////////i///////////////////////////////////////////// 106 static error_t dev_ioc_access( uint32_t cmd_type, 107 uint8_t * buffer, 108 uint32_t lba, 109 uint32_t count ) 93 /////////////////////////////////////////////// 94 error_t dev_ioc_move_data( uint32_t cmd_type, 95 xptr_t buffer_xp, 96 uint32_t lba, 97 uint32_t count ) 110 98 { 111 99 thread_t * this = CURRENT_THREAD; // pointer on client thread 112 100 113 #if ( DE V_IOC_RX ||DEV_IOC_TX )101 #if ( DEBUG_DEV_IOC_RX || DEBUG_DEV_IOC_TX ) 114 102 uint32_t cycle = (uint32_t)hal_get_cycles(); 115 103 #endif … … 118 106 if( chdev_dir.iob ) 119 107 { 120 if (cmd_type == IOC_READ) dev_mmc_inval( XPTR( local_cxy , buffer ) , count<<9 ); 121 else dev_mmc_sync ( XPTR( local_cxy , buffer ) , count<<9 ); 108 if( (cmd_type == IOC_SYNC_READ) || (cmd_type == IOC_READ) ) 109 { 110 dev_mmc_inval( buffer_xp , count<<9 ); 111 } 112 else // (cmd_type == IOC_SYNC_WRITE) or (cmd_type == IOC_WRITE) 113 { 114 dev_mmc_sync ( buffer_xp , count<<9 ); 115 } 122 116 } 123 117 124 118 // get extended pointer on IOC chdev descriptor 125 xptr_t dev_xp= chdev_dir.ioc[0];119 xptr_t ioc_xp = chdev_dir.ioc[0]; 126 120 127 121 // check dev_xp 128 assert( (dev_xp != XPTR_NULL) , "undefined IOC chdev descriptor" );129 130 // register command in calling thread descriptor131 this->ioc_cmd.dev_xp = dev_xp;132 this->ioc_cmd.type = cmd_type;133 this->ioc_cmd.buf_xp = XPTR( local_cxy , buffer );134 this->ioc_cmd.lba = lba;135 this->ioc_cmd.count = count;136 137 // register client thread in IOC chdev waiting queue, activate server thread,138 // block client thread on THREAD_BLOCKED_IO and deschedule.139 // it is re-activated by the ISR signaling IO operation completion.140 chdev_register_command( dev_xp );141 142 #if(DEV_IOC_RX & 1)143 if( (DEV_IOC_RX < cycle) && (cmd_type != IOC_WRITE) )144 printk("\n[%s] thread[%x,%x] resumes for RX\n",145 __FUNCTION__, this->process->pid , this->trdid )146 #endif147 148 #if(DEV_IOC_TX & 1)149 if( (DEV_IOC_RX < cycle) && (cmd_type == IOC_WRITE) )150 printk("\n[%s] thread[%x,%x] resumes for TX\n",151 __FUNCTION__, this->process->pid , this->trdid )152 #endif153 154 // return I/O operation status155 return this->ioc_cmd.error;156 157 } // end dev_ioc_access()158 159 ////////////////////////////////////////////160 error_t dev_ioc_read( uint8_t * buffer,161 uint32_t lba,162 uint32_t count )163 {164 165 #if DEBUG_DEV_IOC_RX166 uint32_t cycle = (uint32_t)hal_get_cycles();167 thread_t * this = CURRENT_THREAD;168 if( DEBUG_DEV_IOC_RX < cycle )169 printk("\n[%s] thread[%x,%x] enters / lba %x / buffer %x / cycle %d\n",170 __FUNCTION__ , this->process->pid, this->trdid, lba, buffer, cycle );171 #endif172 173 return dev_ioc_access( IOC_READ , buffer , lba , count );174 }175 176 ////////////////////////////////////////////177 error_t dev_ioc_write( uint8_t * buffer,178 uint32_t lba,179 uint32_t count )180 {181 182 #if DEBUG_DEV_IOC_TX183 uint32_t cycle = (uint32_t)hal_get_cycles();184 thread_t * this = CURRENT_THREAD;185 if( DEBUG_DEV_IOC_TX < cycle )186 printk("\n[%s] thread[%x,%x] enters / lba %x / buffer %x / cycle %d\n",187 __FUNCTION__ , this->process->pid, this->trdid, lba, buffer, cycle );188 #endif189 190 return dev_ioc_access( IOC_WRITE , buffer , lba , count );191 }192 193 194 195 196 197 //////////////////////////////////////////////////////////////////////////////////198 // This static function is called by dev_ioc_sync_read() & dev_ioc_sync_write().199 // It builds and registers the command in the calling thread descriptor, and200 // calls directly the blocking IOC driver command, that returns only when the201 // IO operation is completed.202 ////////////////////////////////////i/////////////////////////////////////////////203 error_t dev_ioc_sync_access( uint32_t cmd_type,204 xptr_t buffer_xp,205 uint32_t lba,206 uint32_t count )207 {208 // get pointer on calling thread209 thread_t * this = CURRENT_THREAD;210 211 // software L2/L3 cache coherence for memory buffer212 if( chdev_dir.iob )213 {214 if (cmd_type == IOC_SYNC_READ) dev_mmc_inval( buffer_xp , count<<9 );215 else dev_mmc_sync ( buffer_xp , count<<9 );216 }217 218 // get extended pointer on IOC[0] chdev219 xptr_t ioc_xp = chdev_dir.ioc[0];220 221 // check ioc_xp222 122 assert( (ioc_xp != XPTR_NULL) , "undefined IOC chdev descriptor" ); 223 123 … … 229 129 this->ioc_cmd.count = count; 230 130 231 // get driver command function 232 cxy_t ioc_cxy = GET_CXY( ioc_xp ); 233 chdev_t * ioc_ptr = GET_PTR( ioc_xp ); 234 dev_cmd_t * cmd = (dev_cmd_t *)hal_remote_lpt( XPTR( ioc_cxy , &ioc_ptr->cmd ) ); 235 236 // get core local index for the core handling the IOC IRQ 237 thread_t * server = (thread_t *)hal_remote_lpt( XPTR( ioc_cxy , &ioc_ptr->server ) ); 238 core_t * core = (core_t *)hal_remote_lpt( XPTR( ioc_cxy , &server->core ) ); 239 lid_t lid = (lid_t)hal_remote_l32( XPTR( ioc_cxy , &core->lid ) ); 240 241 // mask the IRQ 242 dev_pic_disable_irq( lid , ioc_xp ); 243 244 // call driver function 245 cmd( XPTR( local_cxy , this ) ); 246 247 // unmask the IRQ 248 dev_pic_enable_irq( lid , ioc_xp ); 249 250 // return I/O operation status from calling thread descriptor 131 // for a synchronous acces, the driver is directly called by the client thread 132 if( (cmd_type == IOC_SYNC_READ) || (cmd_type == IOC_SYNC_WRITE) ) 133 { 134 135 #if DEBUG_DEV_IOC_RX 136 uint32_t cycle = (uint32_t)hal_get_cycles(); 137 if( (DEBUG_DEV_IOC_RX < cycle) && (cmd_type == IOC_SYNC_READ) ) 138 printk("\n[%s] thread[%x,%x] enters for SYNC_READ / lba %x / buffer[%x,%x] / cycle %d\n", 139 __FUNCTION__ , this->process->pid, this->trdid, lba, 140 GET_CXY(buffer_xp), GET_PTR(buffer_xp), cycle ); 141 #endif 142 143 #if DEBUG_DEV_IOC_TX 144 uint32_t cycle = (uint32_t)hal_get_cycles(); 145 if( (DEBUG_DEV_IOC_TX < cycle) && (cmd_type == IOC_SYNC_WRITE) ) 146 printk("\n[%s] thread[%x,%x] enters for SYNC_WRITE / lba %x / buffer[%x,%x] / cycle %d\n", 147 __FUNCTION__ , this->process->pid, this->trdid, lba, 148 GET_CXY(buffer_xp), GET_PTR(buffer_xp), cycle ); 149 #endif 150 // get driver command function 151 cxy_t ioc_cxy = GET_CXY( ioc_xp ); 152 chdev_t * ioc_ptr = GET_PTR( ioc_xp ); 153 dev_cmd_t * cmd = (dev_cmd_t *)hal_remote_lpt( XPTR( ioc_cxy , &ioc_ptr->cmd ) ); 154 155 // call driver function 156 cmd( XPTR( local_cxy , this ) ); 157 158 #if DEBUG_DEV_IOC_RX 159 if( (DEBUG_DEV_IOC_RX < cycle) && (cmd_type == IOC_SYNC_READ) ) 160 printk("\n[%s] thread[%x,%x] resumes for IOC_SYNC_READ\n", 161 __FUNCTION__, this->process->pid , this->trdid ) 162 #endif 163 164 #if DEBUG_DEV_IOC_TX 165 if( (DEBUG_DEV_IOC_RX < cycle) && (cmd_type == IOC_SYNC_WRITE) ) 166 printk("\n[%s] thread[%x,%x] resumes for IOC_SYNC_WRITE\n", 167 __FUNCTION__, this->process->pid , this->trdid ) 168 #endif 169 170 } 171 // for an asynchronous access, the client thread registers in the chdev waiting queue, 172 // activates server thread, blocks on THREAD_BLOCKED_IO and deschedules. 173 // It is re-activated by the server thread after IO operation completion. 174 else // (cmd_type == IOC_READ) || (cmd_type == IOC_WRITE) 175 { 176 177 #if DEBUG_DEV_IOC_RX 178 uint32_t cycle = (uint32_t)hal_get_cycles(); 179 if( (DEBUG_DEV_IOC_RX < cycle) && (cmd_type == IOC_READ) ) 180 printk("\n[%s] thread[%x,%x] enters for READ / lba %x / buffer[%x,%x] / cycle %d\n", 181 __FUNCTION__ , this->process->pid, this->trdid, lba, 182 GET_CXY(buffer_xp), GET_PTR(buffer_xp), cycle ); 183 #endif 184 185 #if DEBUG_DEV_IOC_TX 186 uint32_t cycle = (uint32_t)hal_get_cycles(); 187 if( (DEBUG_DEV_IOC_TX < cycle) && (cmd_type == IOC_WRITE) ) 188 printk("\n[%s] thread[%x,%x] enters for WRITE / lba %x / buffer[%x,%x] / cycle %d\n", 189 __FUNCTION__ , this->process->pid, this->trdid, lba, 190 GET_CXY(buffer_xp), GET_PTR(buffer_xp), cycle ); 191 #endif 192 chdev_register_command( ioc_xp ); 193 194 #if(DEBUG_DEV_IOC_RX ) 195 if( (DEBUG_DEV_IOC_RX < cycle) && (cmd_type == IOC_READ) ) 196 printk("\n[%s] thread[%x,%x] resumes for IOC_READ\n", 197 __FUNCTION__, this->process->pid , this->trdid ) 198 #endif 199 200 #if(DEBUG_DEV_IOC_TX & 1) 201 if( (DEBUG_DEV_IOC_RX < cycle) && (cmd_type == IOC_WRITE) ) 202 printk("\n[%s] thread[%x,%x] resumes for IOC_WRITE\n", 203 __FUNCTION__, this->process->pid , this->trdid ) 204 #endif 205 206 } 207 208 // return I/O operation status 251 209 return this->ioc_cmd.error; 252 210 253 } // end dev_ioc_sync_access() 254 255 //////////////////////////////////////////////// 256 error_t dev_ioc_sync_read( xptr_t buffer_xp, 257 uint32_t lba, 258 uint32_t count ) 259 { 260 261 #if DEBUG_DEV_IOC_RX 262 thread_t * this = CURRENT_THREAD; 263 uint32_t cycle = (uint32_t)hal_get_cycles(); 264 if( DEBUG_DEV_IOC_RX < cycle ) 265 printk("\n[%s] thread[%x,%x] : lba %x / buffer(%x,%x) / count %d / cycle %d\n", 266 __FUNCTION__ , this->process->pid, this->trdid, 267 lba, GET_CXY(buffer_xp), GET_PTR(buffer_xp), count, cycle ); 268 #endif 269 270 return dev_ioc_sync_access( IOC_SYNC_READ , buffer_xp , lba , count ); 271 } 272 273 ///////////////////////////////////////////////// 274 error_t dev_ioc_sync_write( xptr_t buffer_xp, 275 uint32_t lba, 276 uint32_t count ) 277 { 278 279 #if DEBUG_DEV_IOC_TX 280 thread_t * this = CURRENT_THREAD; 281 uint32_t cycle = (uint32_t)hal_get_cycles(); 282 if( DEBUG_DEV_IOC_TX < cycle ) 283 printk("\n[%s] thread[%x,%x] : lba %x / buffer(%x,%x) / count %d / cycle %d\n", 284 __FUNCTION__ , this->process->pid, this->trdid, 285 lba, GET_CXY(buffer_xp), GET_PTR(buffer_xp), count, cycle ); 286 #endif 287 288 return dev_ioc_sync_access( IOC_SYNC_WRITE , buffer_xp , lba , count ); 289 } 290 211 } // end dev_ioc_move_data() 212 213 -
trunk/kernel/devices/dev_ioc.h
r627 r647 38 38 * magnetic hard disk or a SD card, that can store blocks of data in a linear array 39 39 * of sectors indexed by a simple lba (logic block address). 40 * 40 41 * It supports four command types: 41 42 * - READ : move blocks from device to memory, with a descheduling policy. … … 43 44 * - SYNC_READ : move blocks from device to memory, with a busy waiting policy. 44 45 * - SYNC_WRITE : move blocks from memory to device, with a busy waiting policy. 45 46 * The READ or WRITE operations require dynamic ressource allocation. The calling thread 47 * is descheduled, and the work is done by the server thread associated to IOC device. 48 * The general scenario is detailed below. 49 * A) the client thread start the I/O operation, by calling the dev_ioc_read() 50 * or the dev_ioc_write() kernel functions that perform the following actions: 51 * 1) it get a free WTI mailbox from the client cluster WTI allocator. 52 * 2) it enables the WTI IRQ on the client cluster ICU and update interrupt vector. 53 * 3) it access the PIC to link the WTI mailbox to the IOC IRQ. 54 * 4) it builds the command descriptor. 55 * 5) it registers in the IOC device waiting queue. 56 * 6) itblock on the THREAD_BLOCKED_IO condition and deschedule. 57 * B) The server thread attached to the IOC device descriptor handles the commands 58 * registered in the waiting queue, calling the IOC driver function. 59 * Most hardware implementation have a DMA capability, but some implementations, 60 * such as the RDK (Ram Disk) implementation does not use DMA. 61 * C) The ISR signaling the I/O operation completion reactivates the client thread, 62 * that releases the allocated resources: 63 * 1) access the PIC to unlink the IOC IRQ. 64 * 2) disable the WTI IRQ in the client cluster ICU and update interrupt vector. 65 * 3) release the WTI mailbox to the client cluster WTI allocator. 46 * 47 * For the he READ or WRITE operations, the client thread is descheduled, and the work 48 * is done by the server thread associated to the IOC device: 49 * The client thread calls the dev_ioc_move_data() kernel functions that (i) registers 50 * the command in the client thread descriptor, (ii) registers the client thread 51 * in the IOC device waiting queue, and (iii) blocks on the THREAD_BLOCKED_IO condition 52 * and deschedules. 53 * The server thread attached to the IOC device descriptor handles the commands 54 * registered in the waiting queue, calling the IOC driver function. 55 * Most IOC device implementations have a DMA capability, but some implementations, 56 * such as the RDK (Ram Disk) implementation does not use DMA. 57 * When the server thread completes an I/O operation, it reactivates the client thread. 66 58 * 67 59 * The SYNC_READ and SYNC_WRITE operations are used by the kernel in the initialisation 68 60 * phase, to update the FAT (both the FAT mapper and the FAT on IOC device), or to update 69 61 * a directory on IOC device when a new file is created. 70 * -These synchronous operations do not not use the IOC device waiting queue,71 * the server thread, and the IOC IRQ, but implement a busy-waiting policy72 * for the calling thread.73 * - As the work62 * These synchronous operations do not not use the IOC device waiting queue, 63 * the server thread, and the IOC IRQ. The client thread does not deschedules: 64 * it registers the command in the thread descriptor, calls directly the IOC driver, 65 * and uses a busy-waiting policy to poll the IOC device status. 74 66 *****************************************************************************************/ 75 67 … … 116 108 { 117 109 xptr_t dev_xp; /*! extended pointer on IOC device descriptor */ 118 uint32_t type; /*! IOC_READ / IOC_WRITE / IOC_SYNC_READ*/110 uint32_t type; /*! command type above */ 119 111 uint32_t lba; /*! first block index */ 120 112 uint32_t count; /*! number of blocks */ … … 146 138 147 139 /****************************************************************************************** 148 * This blocking function moves one or several contiguous blocks of data 149 * from the block device to a local memory buffer. The corresponding request is actually 150 * registered in the device pending request queue, and the calling thread is descheduled, 151 * waiting on transfer completion. It will be resumed by the IRQ signaling completion. 152 * It must be called by a local thread. 140 * This blocking function moves <count> contiguous blocks of data between the block device 141 * starting from block defined by the <lba> argument and a kernel memory buffer, defined 142 * by the <buffer_xp> argument. The transfer direction and mode are defined by the 143 * <cmd_type> argument. The request is always registered in the calling thread descriptor. 144 * - In synchronous mode, the calling thread is not descheduled, and directly calls the 145 * IOC driver, polling the IOC status to detect transfer completion. 146 * - In asynchronous mode, the calling thread blocks and deschedules, and the IOC driver 147 * is called by the server thread associated to the IOC device. 153 148 ****************************************************************************************** 154 * @ buffer : local pointer on target buffer in memory (must be block aligned). 149 * @ cmd_type : IOC_READ / IOC_WRITE / IOC_SYNC_READ / IOC_SYN_WRITE. 150 * @ buffer_xp : extended pointer on kernel buffer in memory (must be block aligned). 155 151 * @ lba : first block index on device. 156 152 * @ count : number of blocks to transfer. 157 153 * @ returns 0 if success / returns -1 if error. 158 154 *****************************************************************************************/ 159 error_t dev_ioc_read( uint8_t * buffer, 160 uint32_t lba, 161 uint32_t count ); 162 163 /****************************************************************************************** 164 * This blocking function moves one or several contiguous blocks of data 165 * from a local memory buffer to the block device. The corresponding request is actually 166 * registered in the device pending request queue, and the calling thread is descheduled, 167 * waiting on transfer completion. It will be resumed by the IRQ signaling completion. 168 * It must be called by a local thread. 169 ****************************************************************************************** 170 * @ buffer : local pointer on source buffer in memory (must be block aligned). 171 * @ lba : first block index on device. 172 * @ count : number of blocks to transfer. 173 * @ returns 0 if success / returns -1 if error. 174 *****************************************************************************************/ 175 error_t dev_ioc_write( uint8_t * buffer, 176 uint32_t lba, 177 uint32_t count ); 178 179 /****************************************************************************************** 180 * This blocking function moves one or several contiguous blocks of data 181 * from the block device to a - possibly remote - memory buffer. 182 * It uses an extended pointer, because the target buffer is generally a remote mapper. 183 * It does not uses the IOC device waiting queue and server thread, and does not use 184 * the IOC IRQ, but call directly the relevant IOC driver, implementing a busy-waiting 185 * policy for the calling thread. 186 * It can be called by a thread running in any cluster. 187 ****************************************************************************************** 188 * @ buffer_xp : extended pointer on target buffer in memory (must be block aligned). 189 * @ lba : first block index on device. 190 * @ count : number of blocks to transfer. 191 * @ returns 0 if success / returns -1 if error. 192 *****************************************************************************************/ 193 error_t dev_ioc_sync_read( xptr_t buffer_xp, 194 uint32_t lba, 195 uint32_t count ); 196 197 /****************************************************************************************** 198 * This blocking function moves one or several contiguous blocks of data 199 * from a - possibly remote - memory buffer to the block device. 200 * It uses an extended pointer, because the target buffer is generally a remote mapper. 201 * It does not uses the IOC device waiting queue and server thread, and does not use 202 * the IOC IRQ, but call directly the relevant IOC driver, implementing a busy-waiting 203 * policy for the calling thread. 204 * It can be called by a thread running in any cluster. 205 ****************************************************************************************** 206 * @ buffer_xp : extended pointer on source buffer in memory (must be block aligned). 207 * @ lba : first block index on device. 208 * @ count : number of blocks to transfer. 209 * @ returns 0 if success / returns -1 if error. 210 *****************************************************************************************/ 211 error_t dev_ioc_sync_write( xptr_t buffer_xp, 212 uint32_t lba, 213 uint32_t count ); 155 error_t dev_ioc_move_data( uint32_t cmd_type, 156 xptr_t buffer_xp, 157 uint32_t lba, 158 uint32_t count ); 214 159 215 160 #endif /* _DEV_IOC_H */ -
trunk/kernel/devices/dev_mmc.c
r626 r647 40 40 void dev_mmc_init( chdev_t * mmc ) 41 41 { 42 // get implementation from device descriptor43 uint32_t impl = mmc->impl;44 45 42 // set mmc name 46 43 snprintf( mmc->name , 16 , "mmc_%x" , local_cxy ); 47 44 48 45 // call driver init function 49 hal_drivers_mmc_init( mmc , impl);46 hal_drivers_mmc_init( mmc ); 50 47 51 48 // bind IRQ to CP0 -
trunk/kernel/devices/dev_nic.c
r637 r647 39 39 void dev_nic_init( chdev_t * nic ) 40 40 { 41 // the PIC chdev must be initialized before the NIC chdev, because 42 // the NIC chdev initialisation requires the routing of an external IRQ. 43 xptr_t pic_xp = chdev_dir.pic; 44 45 assert( (pic_xp != XPTR_NULL) , "ICU not initialised before NIC" ); 46 47 // get "impl" , "channel" , "is_rx" fields from chdev descriptor 48 uint32_t impl = nic->impl; 41 // get "channel" & "is_rx" fields from chdev descriptor 49 42 uint32_t channel = nic->channel; 50 43 bool_t is_rx = nic->is_rx; … … 55 48 56 49 // call driver init function 57 hal_drivers_nic_init( nic , impl);50 hal_drivers_nic_init( nic ); 58 51 59 52 // select a core to execute the NIC server thread -
trunk/kernel/devices/dev_pic.c
r565 r647 43 43 void dev_pic_init( chdev_t * pic ) 44 44 { 45 // get implementation46 uint32_t impl = pic->impl;47 48 45 // set chdev name 49 46 strcpy( pic->name , "pic" ); 50 47 51 48 // call the implementation-specific PIC driver 52 hal_drivers_pic_init( pic, impl);49 hal_drivers_pic_init( pic ); 53 50 } 54 51 -
trunk/kernel/devices/dev_txt.c
r637 r647 87 87 88 88 // call driver init function 89 hal_drivers_txt_init( txt, impl);89 hal_drivers_txt_init( txt ); 90 90 91 91 // no server thread and no IRQ routing for TXT0 -
trunk/kernel/fs/fatfs.c
r635 r647 575 575 576 576 // update the FS_INFO sector on IOC device 577 return dev_ioc_ sync_write(fs_info_buffer_xp , fs_info_lba , 1 );577 return dev_ioc_move_data( IOC_SYNC_WRITE , fs_info_buffer_xp , fs_info_lba , 1 ); 578 578 579 579 } // end fatfs_update_ioc_fsinfo() … … 1115 1115 1116 1116 // load the BOOT record from device 1117 error = dev_ioc_ sync_read(buffer_xp , 0 , 1 );1117 error = dev_ioc_move_data( IOC_SYNC_READ , buffer_xp , 0 , 1 ); 1118 1118 1119 1119 if ( error ) … … 1175 1175 1176 1176 // load the FS_INFO record from device 1177 error = dev_ioc_ sync_read(buffer_xp , fs_info_lba , 1 );1177 error = dev_ioc_move_data( IOC_SYNC_READ , buffer_xp , fs_info_lba , 1 ); 1178 1178 1179 1179 if ( error ) … … 2394 2394 2395 2395 // copy FS_INFO sector from IOC to local buffer 2396 error = dev_ioc_ sync_read(tmp_buf_xp , fs_info_lba , 1 );2396 error = dev_ioc_move_data( IOC_SYNC_READ , tmp_buf_xp , fs_info_lba , 1 ); 2397 2397 2398 2398 if ( error ) … … 2431 2431 2432 2432 // update the FS_INFO sector on IOC device 2433 error = dev_ioc_ sync_write(fs_info_buffer_xp , fs_info_lba , 1 );2433 error = dev_ioc_move_data( IOC_SYNC_WRITE , fs_info_buffer_xp , fs_info_lba , 1 ); 2434 2434 2435 2435 if ( error ) … … 2750 2750 // get page base address 2751 2751 xptr_t buffer_xp = ppm_page2base( page_xp ); 2752 uint8_t * buffer_ptr = (uint8_t *)GET_PTR( buffer_xp );2753 2752 2754 2753 // get inode pointer from mapper … … 2759 2758 printk("\n[%s] thread[%x,%x] enters : %s / cxy %x / mapper %x / inode %x / page %x\n", 2760 2759 __FUNCTION__, this->process->pid, this->trdid, 2761 dev_ioc_cmd_str( cmd_type ), page_cxy, mapper_ptr, inode_ptr, buffer_ptr);2760 dev_ioc_cmd_str( cmd_type ), page_cxy, mapper_ptr, inode_ptr, GET_PTR(buffer_xp) ); 2762 2761 #endif 2763 2762 … … 2768 2767 uint32_t lba = fatfs_ctx->fat_begin_lba + (page_id << 3); 2769 2768 2770 // access device 2771 if (cmd_type == IOC_SYNC_READ ) error = dev_ioc_sync_read ( buffer_xp , lba , 8 ); 2772 else if(cmd_type == IOC_SYNC_WRITE) error = dev_ioc_sync_write( buffer_xp , lba , 8 ); 2773 else if(cmd_type == IOC_READ ) error = dev_ioc_read ( buffer_ptr , lba , 8 ); 2774 else if(cmd_type == IOC_WRITE ) error = dev_ioc_write ( buffer_ptr , lba , 8 ); 2775 else error = -1; 2769 // access IOC device 2770 error = dev_ioc_move_data( cmd_type , buffer_xp , lba , 8 ); 2776 2771 2777 2772 if( error ) … … 2831 2826 uint32_t lba = fatfs_lba_from_cluster( fatfs_ctx , searched_cluster ); 2832 2827 2833 // access device 2834 if (cmd_type == IOC_SYNC_READ ) error = dev_ioc_sync_read ( buffer_xp , lba , 8 ); 2835 else if(cmd_type == IOC_SYNC_WRITE) error = dev_ioc_sync_write( buffer_xp , lba , 8 ); 2836 else if(cmd_type == IOC_READ ) error = dev_ioc_read ( buffer_ptr , lba , 8 ); 2837 else if(cmd_type == IOC_WRITE ) error = dev_ioc_write ( buffer_ptr , lba , 8 ); 2838 else error = -1; 2828 // access IOC device 2829 error = dev_ioc_move_data( cmd_type , buffer_xp , lba , 8 ); 2839 2830 2840 2831 if( error ) -
trunk/kernel/fs/vfs.c
r635 r647 681 681 process_t * process = this->process; 682 682 683 #if DEBUG_VFS_OPEN684 uint32_t cycle = (uint32_t)hal_get_cycles();685 if( DEBUG_VFS_OPEN < cycle )686 printk("\n[%s] thread[%x,%x] enter for <%s> / root_inode (%x,%x) / cycle %d\n",687 __FUNCTION__, process->pid, this->trdid, path, GET_CXY(root_xp), GET_PTR(root_xp), cycle );688 #endif689 690 683 // compute lookup working mode 691 684 lookup_mode = VFS_LOOKUP_OPEN; … … 694 687 if( (flags & O_EXCL ) ) lookup_mode |= VFS_LOOKUP_EXCL; 695 688 689 #if DEBUG_VFS_OPEN 690 uint32_t cycle = (uint32_t)hal_get_cycles(); 691 if( DEBUG_VFS_OPEN < cycle ) 692 printk("\n[%s] thread[%x,%x] enter for <%s> / root_inode (%x,%x) / cycle %d\n", 693 __FUNCTION__, process->pid, this->trdid, path, GET_CXY(root_xp), GET_PTR(root_xp), cycle ); 694 #endif 695 696 696 // compute attributes for the created file 697 697 file_attr = 0; -
trunk/kernel/kern/do_syscall.c
r641 r647 111 111 sys_get_nb_cores, // 54 112 112 sys_get_thread_info, // 55 113 sys_fbf, // 56 113 114 }; 114 115 … … 179 180 case SYS_GET_NB_CORES: return "GET_NB_CORES"; // 54 180 181 case SYS_GET_THREAD_INFO: return "GET_THREAD_INFO"; // 55 182 case SYS_FBF: return "FBF"; // 56 181 183 182 184 default: return "undefined"; -
trunk/kernel/kern/kernel_init.c
r640 r647 561 561 if( target_cxy == local_cxy ) 562 562 { 563 564 #if( DEBUG_KERNEL_INIT & 0x3 ) 565 if( hal_time_stamp() > DEBUG_KERNEL_INIT ) 566 printk("\n[%s] : found chdev %s / channel = %d / rx = %d / cluster %x\n", 567 __FUNCTION__ , chdev_func_str( func ), channel , rx , local_cxy ); 568 #endif 563 569 chdev = chdev_create( func, 564 570 impl, … … 608 614 } 609 615 610 #if( DEBUG_KERNEL_INIT & 0x 1)616 #if( DEBUG_KERNEL_INIT & 0x3 ) 611 617 if( hal_time_stamp() > DEBUG_KERNEL_INIT ) 612 printk("\n[%s] : create chdev %s / channel = %d / rx = %d / cluster %x / chdev = %x\n",618 printk("\n[%s] : created chdev %s / channel = %d / rx = %d / cluster %x / chdev = %x\n", 613 619 __FUNCTION__ , chdev_func_str( func ), channel , rx , local_cxy , chdev ); 614 620 #endif -
trunk/kernel/kern/thread.c
r641 r647 942 942 uint32_t global_one = global_nr ? (global_cost / global_nr) : 0; 943 943 944 printk("\n***** thread[%x,%x] page -faults\n"944 printk("\n***** thread[%x,%x] page faults\n" 945 945 " - false : %d events / cost %d cycles / max %d cycles\n" 946 946 " - local : %d events / cost %d cycles / max %d cycles\n" -
trunk/kernel/kern/thread.h
r641 r647 183 183 mmc_command_t mmc_cmd; /*! MMC device generic command */ 184 184 dma_command_t dma_cmd; /*! DMA device generic command */ 185 fbf_command_t fbf_cmd; /*! FBF device generic command */ 185 186 186 187 xptr_t rpc_client_xp; /*! client thread (for a RPC thread only) */ -
trunk/kernel/kernel_config.h
r641 r647 56 56 #define DEBUG_DEV_NIC_RX 0 57 57 #define DEBUG_DEV_NIC_RX 0 58 #define DEBUG_DEV_FBF_RX 0 59 #define DEBUG_DEV_FBF_TX 0 58 #define DEBUG_DEV_FBF 1 60 59 #define DEBUG_DEV_DMA 0 61 60 #define DEBUG_DEV_MMC 0 … … 105 104 #define DEBUG_HAL_TXT_RX 0 106 105 #define DEBUG_HAL_TXT_TX 0 106 #define DEBUG_HAL_FBF 1 107 107 #define DEBUG_HAL_USPACE 0 108 108 #define DEBUG_HAL_VMM 0 … … 134 134 #define DEBUG_PROCESS_GET_LOCAL_COPY 0 135 135 #define DEBUG_PROCESS_INIT_CREATE 0 136 #define DEBUG_PROCESS_MAKE_EXEC 0137 #define DEBUG_PROCESS_MAKE_FORK 0136 #define DEBUG_PROCESS_MAKE_EXEC 1 137 #define DEBUG_PROCESS_MAKE_FORK 1 138 138 #define DEBUG_PROCESS_REFERENCE_INIT 0 139 139 #define DEBUG_PROCESS_SIGACTION 0 … … 184 184 #define DEBUG_SYS_CONDVAR 0 185 185 #define DEBUG_SYS_DISPLAY 0 186 #define DEBUG_SYS_EXEC 0186 #define DEBUG_SYS_EXEC 2 187 187 #define DEBUG_SYS_EXIT 0 188 #define DEBUG_SYS_FBF 0 188 189 #define DEBUG_SYS_FG 0 189 #define DEBUG_SYS_FORK 0190 #define DEBUG_SYS_FORK 2 190 191 #define DEBUG_SYS_GET_CONFIG 0 191 192 #define DEBUG_SYS_GETCWD 0 -
trunk/kernel/syscalls/sys_fbf.c
r642 r647 173 173 #if DEBUG_SYS_FBF 174 174 if( DEBUG_SYS_FBF < tm_end ) 175 printk("\n[ DBG] %s : thread %x in process %xexit for %s / cost = %d / cycle %d\n",176 __FUNCTION__, this->trdid, process->pid, dev_fbf_cmd_str( operation ),175 printk("\n[%s] thread[%x,%x] exit for %s / cost = %d / cycle %d\n", 176 __FUNCTION__, process->pid, this->trdid, dev_fbf_cmd_str( operation ), 177 177 (uint32_t)(tm_end - tm_start), (uint32_t)tm_end ); 178 178 #endif -
trunk/libs/libalmosmkh/almosmkh.c
r643 r647 1456 1456 ///////////////////////////////////////////////////////////////////////////////////////// 1457 1457 1458 ///////////////////////////////// 1459 int fbf_get_config( int * width,1460 int * height,1461 int * type )1458 ///////////////////////////////////////// 1459 int fbf_get_config( unsigned int * width, 1460 unsigned int * height, 1461 unsigned int * type ) 1462 1462 { 1463 1463 return hal_user_syscall( SYS_FBF, … … 1468 1468 } 1469 1469 1470 //////////////////////////// 1471 int fbf_read( void * buffer,1472 intlength,1473 intoffset )1470 //////////////////////////////////// 1471 int fbf_read( void * buffer, 1472 unsigned int length, 1473 unsigned int offset ) 1474 1474 { 1475 1475 return hal_user_syscall( SYS_FBF, … … 1480 1480 } 1481 1481 1482 //////////////////////////// 1483 int fbf_write( void * buffer,1484 intlength,1485 intoffset )1482 ///////////////////////////////////// 1483 int fbf_write( void * buffer, 1484 unsigned int length, 1485 unsigned int offset ) 1486 1486 { 1487 1487 return hal_user_syscall( SYS_FBF, -
trunk/libs/libalmosmkh/almosmkh.h
r643 r647 538 538 * @ returns 0 if success / returns -1 if error. 539 539 ****************************************************************************************/ 540 int fbf_get_config( int * width,541 int * height,542 int * type );540 int fbf_get_config( unsigned int * width, 541 unsigned int * height, 542 unsigned int * type ); 543 543 544 544 /***************************************************************************************** … … 551 551 * @ returns 0 if success / returns -1 if error. 552 552 ****************************************************************************************/ 553 int fbf_read( void * buffer,554 intlength,555 intoffset );553 int fbf_read( void * buffer, 554 unsigned int length, 555 unsigned int offset ); 556 556 557 557 /***************************************************************************************** … … 564 564 * @ returns 0 if success / returns -1 if error. 565 565 ****************************************************************************************/ 566 int fbf_write( void * buffer,567 intlength,568 intoffset );566 int fbf_write( void * buffer, 567 unsigned int length, 568 unsigned int offset ); 569 569 570 570 #endif /* _LIBALMOSMKH_H_ */ -
trunk/libs/libpthread/pthread.h
r640 r647 32 32 33 33 /********************************************************************************************* 34 * This function creates a new user thread. The < user_attr> argument is a pointer34 * This function creates a new user thread. The <attr> argument is a pointer 35 35 * on a structure containing the thread attributes, defined in the shared_pthread.h file. 36 * The thread entry point is defined by the <start_func> and <start_args> arguments. 36 37 ********************************************************************************************* 37 38 * @ trdid : [out] buffer for created thread identifier in process. -
trunk/libs/mini-libc/stdio.c
r643 r647 412 412 413 413 // compute nbytes 414 unsignedint nbytes = size * nitems;414 int nbytes = size * nitems; 415 415 416 416 if( hal_user_syscall( SYS_READ, … … 435 435 436 436 // compute nbytes 437 unsignedint nbytes = size * nitems;437 int nbytes = size * nitems; 438 438 439 439 if( hal_user_syscall( SYS_WRITE, … … 444 444 445 445 } // end fwrite() 446 447 ////////////////////////////////////////// 448 unsigned int fseek( FILE * stream, 449 unsigned int offset, 450 int whence ) 451 { 452 // check stream valid 453 if( stream->key != VALID_OPEN_FILE ) return -1; 454 455 // get file descriptor from stream pointer 456 int fd = stream->fd; 457 458 return( hal_user_syscall( SYS_LSEEK, 459 (reg_t)fd, 460 (reg_t)offset, 461 (reg_t)whence, 0 ) ); 462 } // end fseek() 446 463 447 464 ///////////////////////////////// -
trunk/libs/mini-libc/stdio.h
r643 r647 146 146 * It can be a regular file or a character oriented input device. 147 147 ********************************************************************************************* 148 * @ buffer : pointer on user buffer. 149 * @ size : item size in bytes. 150 * @ nitems : number of items. 148 151 * @ stream : pointer on a stream. 149 * @ format : formated string.150 152 * @ returns actual number of items read if success / returns 0 if failure. 151 153 ********************************************************************************************/ … … 160 162 * It can be a regular file or a character oriented input device. 161 163 ********************************************************************************************* 164 * @ buffer : pointer on user buffer. 165 * @ size : item size in bytes. 166 * @ nitems : number of items. 162 167 * @ stream : pointer on a stream. 163 * @ format : formated string.164 168 * @ returns actual number of written items if success / returns 0 if failure. 165 169 ********************************************************************************************/ … … 169 173 FILE * stream ); 170 174 175 /********************************************************************************************* 176 * This function moves <nitems> oblects, each <size> bytes long, from an input stream 177 * identified by <stream>, to the user buffer identified by the <buffer> argument. 178 * It can be a regular file or a character oriented input device. 179 ********************************************************************************************* 180 * @ stream : pointer on a stream. 181 * @ offset : used to compute new offset value. 182 * @ whence : operation type (SEEK_SET / SEEK_CUR / SEEK_END) 183 * @ return 0 if success / returns -1 if failure. 184 ********************************************************************************************/ 185 unsigned int fseek( FILE * stream, 186 unsigned int offset, 187 int whence ); 188 189 171 190 #endif // _STDIO_H_ -
trunk/params-hard.mk
r641 r647 2 2 3 3 ARCH = /Users/alain/soc/tsar-trunk-svn-2013/platforms/tsar_generic_iob 4 X_SIZE = 45 Y_SIZE = 26 NB_PROCS = 44 X_SIZE = 1 5 Y_SIZE = 1 6 NB_PROCS = 1 7 7 NB_TTYS = 2 8 8 IOC_TYPE = IOC_BDV -
trunk/user/ksh/ksh.c
r644 r647 1226 1226 1227 1227 1228 / /1. first direct command1228 /* 1. first direct command 1229 1229 if( sem_wait( &semaphore ) ) 1230 1230 { … … 1238 1238 execute( cmd ); 1239 1239 } 1240 //1240 */ 1241 1241 1242 1242
Note: See TracChangeset
for help on using the changeset viewer.