Changeset 469 for trunk/hal


Ignore:
Timestamp:
Aug 20, 2018, 1:04:16 PM (6 years ago)
Author:
alain
Message:

1) Introduce the libsemaphore library.
2) Introduce a small libmath library, required by the "fft" application..
3) Introduce the multithreaded "fft" application.
4) Fix a bad synchronisation bug in the Copy-On-Write mechanism.

Location:
trunk/hal/tsar_mips32/core
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/tsar_mips32/core/hal_exception.c

    r459 r469  
    146146
    147147            // restore FPU registers from requesting thread context
    148                 hal_fpu_context_restore( this->fpu_context );
     148                hal_fpu_context_restore( this );
    149149
    150150            // attach the FPU to the requesting thread
     
    155155    {
    156156        // restore FPU registers from requesting thread context
    157             hal_fpu_context_restore( this->fpu_context );
     157            hal_fpu_context_restore( this );
    158158
    159159        // attach the FPU to the requesting thread
     
    218218if( DEBUG_HAL_EXCEPTIONS < cycle )
    219219printk("\n[DBG] %s : thread %x in process %x enter / is_ins %d / %s / vaddr %x / cycle %d\n",
    220 __FUNCTION__, this->trdid, process->pid, is_ins, hal_mmu_exception_str(excp_code), bad_vaddr, cycle);
     220__FUNCTION__, this->trdid, process->pid,
     221is_ins, hal_mmu_exception_str(excp_code), bad_vaddr, cycle);
    221222#endif
    222223
     
    235236            if( error )   
    236237            {
    237                 printk("\n[ERROR] in %s for thread %x : cannot map vaddr = %x\n",
    238                 __FUNCTION__ , this->trdid , bad_vaddr );
     238                printk("\n[USER ERROR] in %s for thread %x in process %x\n"
     239                "   cannot map vaddr = %x / is_ins %d / epc %x\n",
     240                __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC );
    239241
    240242                        return EXCP_USER_ERROR;
     
    256258        case MMU_READ_PRIVILEGE_VIOLATION:
    257259        {
    258             printk("\n[ERROR] in %s for thread %x : illegal user access to vaddr = %x\n",
    259             __FUNCTION__ , this->trdid , bad_vaddr );
     260            printk("\n[USER ERROR] in %s for thread %x in process %x\n"
     261            "   illegal user access to vaddr = %x / is_ins %d / epc %x\n",
     262            __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC );
    260263
    261264            return EXCP_USER_ERROR;
     
    275278                if( error )
    276279                {
    277                     printk("\n[ERROR] in %s for thread %x : cannot cow vaddr = %x\n",
    278                     __FUNCTION__ , this->trdid , bad_vaddr );
     280                    printk("\n[USER ERROR] in %s for thread %x in process %x\n"
     281                    "   cannot cow vaddr = %x / is_ins %d / epc %x\n",
     282                    __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC );
    279283
    280284                            return EXCP_USER_ERROR;
     
    295299            else                             // non writable user error
    296300            {
    297                 printk("\n[ERROR] in %s for thread %x : non-writable vaddr = %x\n",
    298                 __FUNCTION__ , this->trdid , bad_vaddr );
     301                printk("\n[USER ERROR] in %s for thread %x in process %x\n"
     302                "   non-writable vaddr = %x / is_ins %d / epc %x\n",
     303                __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC );
    299304
    300305                return EXCP_USER_ERROR;
     
    303308        case MMU_READ_EXEC_VIOLATION:        // user error
    304309        {
    305             printk("\n[ERROR] in %s for thread %x : read to non-executable vaddr = %x\n",
    306             __FUNCTION__ , this->trdid , bad_vaddr );
     310            printk("\n[USER_ERROR] in %s for thread %x in process %x\n"
     311            "   non-executable vaddr = %x / is_ins %d / epc %x\n",
     312            __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC );
    307313
    308314            return EXCP_USER_ERROR;
    309315        }
    310         default:                             // this is a kernel error => panic    
    311         {
    312             assert( false , __FUNCTION__ ,
    313             "thread %x in process %x / epc %x / badvaddr %x / cycle %d\n",
    314             this->trdid, this->process->pid, excPC, bad_vaddr, (uint32_t)hal_get_cycles() );
     316        default:                             // this is a kernel error    
     317        {
     318            printk("\n[KERNEL ERROR] in %s for thread %x in process %x\n"
     319            "  epc %x / badvaddr %x / is_ins %d\n",
     320            __FUNCTION__, this->trdid, this->process->pid, excPC, bad_vaddr, is_ins );
    315321
    316322            return EXCP_KERNEL_PANIC;
     
    353359    else
    354360    {
    355         nolock_printk("\n=== KERNEL PANIC / trdid %x / pid %x / core[%x,%d] / cycle %d ===\n",
     361        nolock_printk("\n=== KERNEL ERROR / trdid %x / pid %x / core[%x,%d] / cycle %d ===\n",
    356362        this->trdid, process->pid, local_cxy, core->lid , (uint32_t)hal_get_cycles() );
    357363    }
     
    415421        switch(excCode)
    416422        {
    417         case XCODE_DBE:     // can be non fatal
     423        case XCODE_DBE:     // Data Bus Error : can be non fatal if page fault
    418424        {
    419425                    error = hal_mmu_exception( this , excPC , false );  // data MMU exception
    420426            break;
    421427        }
    422             case XCODE_IBE:     // can be non fatal
     428            case XCODE_IBE:     // Instruction Bus Error : can be non fatal if page fault
    423429        {
    424430                    error = hal_mmu_exception( this , excPC , true );   // ins MMU exception
    425431                    break;
    426432        }
    427             case XCODE_CPU:    // can be non fatal
    428         {
    429             if( ((uzone[UZ_CR] >> 28) & 0x3) == 1 ) // FPU
     433            case XCODE_CPU:    // Coprocessor unavailable : can be non fatal if FPU
     434        {
     435            if( ((uzone[UZ_CR] >> 28) & 0x3) == 1 )             // FPU
    430436            {
    431                 error = hal_fpu_exception( this );              // FPU exception
     437                error = hal_fpu_exception( this );
    432438            }
    433             else
     439            else                                                // undefined coprocessor
    434440            {
     441                printk("\n[USER_ERROR] in %s for thread %x in process %x\n"
     442                "   undefined coprocessor / epc %x\n",
     443                __FUNCTION__, this->trdid, this->process->pid, excPC );
     444
    435445                        error = EXCP_USER_ERROR;
    436446            }
    437447                    break;
    438448        }
    439         case XCODE_OVR:    // user fatal error
    440         case XCODE_RI:     // user fatal error
     449        case XCODE_OVR:    // Arithmetic Overflow : user fatal error
     450        {
     451            printk("\n[USER_ERROR] in %s for thread %x in process %x\n"
     452            "   arithmetic overflow / epc %x\n",
     453            __FUNCTION__, this->trdid, this->process->pid, excPC );
     454
     455                    error = EXCP_USER_ERROR;
     456                break;
     457        }
     458        case XCODE_RI:     // Reserved Instruction : user fatal error
     459        {
     460            printk("\n[USER_ERROR] in %s for thread %x in process %x\n"
     461            "   reserved instruction / epc %x\n",
     462            __FUNCTION__, this->trdid, this->process->pid, excPC );
     463
     464                    error = EXCP_USER_ERROR;
     465                break;
     466        }
    441467        case XCODE_ADEL:   // user fatal error
    442         case XCODE_ADES:   // user fatal error
    443         {
     468        {
     469            printk("\n[USER_ERROR] in %s for thread %x in process %x\n"
     470            "   illegal data load address / epc %x\n",
     471            __FUNCTION__, this->trdid, this->process->pid, excPC );
     472
     473                    error = EXCP_USER_ERROR;
     474                break;
     475        }
     476        case XCODE_ADES:   //   user fatal error
     477        {
     478            printk("\n[USER_ERROR] in %s for thread %x in process %x\n"
     479            "   illegal data store address / epc %x\n",
     480            __FUNCTION__, this->trdid, this->process->pid, excPC );
     481
    444482                    error = EXCP_USER_ERROR;
    445483                break;
     
    462500        hal_exception_dump( this , uzone , error );
    463501
    464         assert( false , __FUNCTION__ , "thread %x in process %x on core [%x,%d]",
    465         this , this->process->pid , local_cxy , this->core->lid );
     502        assert( false , __FUNCTION__ , "core[%x,%d] blocked\n", local_cxy, this->core->lid );
    466503    }
    467504
Note: See TracChangeset for help on using the changeset viewer.