Changeset 440 for trunk/hal/tsar_mips32


Ignore:
Timestamp:
May 3, 2018, 5:51:22 PM (6 years ago)
Author:
alain
Message:

1/ Fix a bug in the Multithreaded "sort" applicationr:
The pthread_create() arguments must be declared as global variables.
2/ The exit syscall can be called by any thread of a process..

Location:
trunk/hal/tsar_mips32
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/tsar_mips32/Makefile

    r439 r440  
    2626
    2727CORE_OBJS    = $(HAL_ARCH)/build/core/hal_special.o      \
    28               $(HAL_ARCH)/build/core/hal_context.o      \
    29               $(HAL_ARCH)/build/core/hal_atomic.o       \
    30               $(HAL_ARCH)/build/core/hal_remote.o       \
    31               $(HAL_ARCH)/build/core/hal_uspace.o       \
    32               $(HAL_ARCH)/build/core/hal_irqmask.o      \
    33               $(HAL_ARCH)/build/core/hal_gpt.o          \
    34               $(HAL_ARCH)/build/core/hal_ppm.o          \
    35               $(HAL_ARCH)/build/core/hal_vmm.o          \
    36               $(HAL_ARCH)/build/core/hal_exception.o    \
    37               $(HAL_ARCH)/build/core/hal_interrupt.o    \
    38               $(HAL_ARCH)/build/core/hal_syscall.o      \
    39               $(HAL_ARCH)/build/core/hal_drivers.o      \
    40               $(HAL_ARCH)/build/core/hal_kentry.o       \
    41               $(HAL_ARCH)/build/core/hal_switch.o       \
    42               $(HAL_ARCH)/build/core/hal_user.o
     28               $(HAL_ARCH)/build/core/hal_context.o      \
     29               $(HAL_ARCH)/build/core/hal_atomic.o       \
     30               $(HAL_ARCH)/build/core/hal_remote.o       \
     31               $(HAL_ARCH)/build/core/hal_uspace.o       \
     32               $(HAL_ARCH)/build/core/hal_irqmask.o      \
     33               $(HAL_ARCH)/build/core/hal_gpt.o          \
     34               $(HAL_ARCH)/build/core/hal_ppm.o          \
     35               $(HAL_ARCH)/build/core/hal_vmm.o          \
     36               $(HAL_ARCH)/build/core/hal_exception.o    \
     37               $(HAL_ARCH)/build/core/hal_interrupt.o    \
     38               $(HAL_ARCH)/build/core/hal_syscall.o      \
     39               $(HAL_ARCH)/build/core/hal_drivers.o      \
     40               $(HAL_ARCH)/build/core/hal_kentry.o       \
     41               $(HAL_ARCH)/build/core/hal_switch.o       \
     42               $(HAL_ARCH)/build/core/hal_user.o
    4343
    44 HAL_INCLUDE =     -I$(KERNEL) \
    45                  -I$(HAL_ARCH)/drivers \
    46                  -I$(HAL)/generic             \
    47                  -I$(HAL_ARCH)/core    \
    48                  -I../../tools/arch_info         \
    49                  -I$(KERNEL)/kern \
    50                  -I$(KERNEL)/mm   \
    51                  -I$(KERNEL)/fs   \
    52                  -I$(KERNEL)/syscalls   \
    53                  -I$(KERNEL)/devices    \
     44HAL_INCLUDE =    -I$(KERNEL)            \
     45                 -I$(HAL_ARCH)/drivers   \
     46                 -I$(HAL)/generic        \
     47                 -I$(HAL_ARCH)/core      \
     48                 -I../../tools/arch_info \
     49                 -I$(KERNEL)/kern        \
     50                 -I$(KERNEL)/mm          \
     51                 -I$(KERNEL)/fs          \
     52                 -I$(KERNEL)/syscalls    \
     53                 -I$(KERNEL)/devices     \
    5454                 -I$(KERNEL)/libk
    5555
     56##############################
    5657# Rule to generate .o for HAL.
    5758compile: dirs $(CORE_OBJS) $(DRIVERS_OBJS)
    5859
     60########################################
    5961# Rule to create the build directories.
    6062dirs:
     
    6668##############################
    6769# rules to compile the drivers
    68 $(HAL_ARCH)/build/drivers/%.o:       $(HAL_ARCH)/drivers/%.c \
    69                                 $(HAL_ARCH)/drivers/%.h \
    70                                 $(KERNEL)/kernel_config.h             \
     70$(HAL_ARCH)/build/drivers/%.o:  $(HAL_ARCH)/drivers/%.c      \
     71                                $(HAL_ARCH)/drivers/%.h      \
     72                                $(KERNEL)/kernel_config.h    \
    7173                                $(HAL_ARCH)/core/hal_types.h
    7274        $(CC) $(HAL_INCLUDE) $(CFLAGS)  -c -o $@ $<
     
    7476######################################
    7577# Rules to generate kernel/hal objects
    76 $(HAL_ARCH)/build/core/%.o:           $(HAL_ARCH)/core/%.c    \
    77                                 $(HAL)/generic/%.h             \
    78                                 $(KERNEL)/kernel_config.h             \
     78$(HAL_ARCH)/build/core/%.o:     $(HAL_ARCH)/core/%.c         \
     79                                $(HAL)/generic/%.h           \
     80                                $(KERNEL)/kernel_config.h    \
    7981                                $(HAL_ARCH)/core/hal_types.h
    8082        $(CC) $(HAL_INCLUDE) $(CFLAGS) -c -o $@ $<
    8183
    8284$(HAL_ARCH)/build/core/hal_kentry.o:  $(HAL_ARCH)/core/hal_kentry.S \
    83                                 $(HAL_ARCH)/core/hal_kentry.h \
    84                                 $(KERNEL)/kernel_config.h                   \
    85                                 $(HAL_ARCH)/core/hal_types.h
     85                                      $(HAL_ARCH)/core/hal_kentry.h \
     86                                      $(KERNEL)/kernel_config.h     \
     87                                      $(HAL_ARCH)/core/hal_types.h
    8688        $(CC) $(HAL_INCLUDE) $(CFLAGS) -c -o $@ $<
    8789
    8890$(HAL_ARCH)/build/core/hal_switch.o:  $(HAL_ARCH)/core/hal_switch.S \
    89                                 $(HAL)/generic/hal_switch.h
     91                                      $(HAL)/generic/hal_switch.h
    9092        $(CC) $(HAL_INCLUDE) $(CFLAGS) -c -o $@ $<
    9193        $(DU) -D $@ > $@.txt
  • trunk/hal/tsar_mips32/core/hal_exception.c

    r438 r440  
    3434#include <core.h>
    3535#include <syscalls.h>
     36#include <shared_syscalls.h>
    3637#include <remote_spinlock.h>
    3738#include <hal_kentry.h>
     
    163164//////////////////////////////////////////////////////////////////////////////////////////
    164165// @ this     : pointer on faulty thread descriptor.
     166// @ excPC    :
    165167// @ is_ins   : IBE if true / DBE if false.
    166168// @ return EXCP_NON_FATAL / EXCP_USER_ERROR / EXCP_KERNEL_PANIC
     
    218220            // try to map the unmapped PTE
    219221            error = vmm_handle_page_fault( process,
    220                                            bad_vaddr >> CONFIG_PPM_PAGE_SHIFT );  // vpn
     222                                           bad_vaddr >> CONFIG_PPM_PAGE_SHIFT,  // vpn
     223                                           false );                             // not a COW
    221224            if( error )   
    222225            {
     
    256259            {
    257260                // try to allocate and copy the page
    258                 error = vmm_handle_cow( process,
    259                                         bad_vaddr >> CONFIG_PPM_PAGE_SHIFT ); 
     261                error = vmm_handle_page_fault( process,
     262                                               bad_vaddr >> CONFIG_PPM_PAGE_SHIFT,  // vpn
     263                                               true );                              // COW
    260264                if( error )
    261265                {
     
    295299        default:                             // this is a kernel error => panic   
    296300        {
    297             assert( false , __FUNCTION__ , "thread %x / epc %x / %s / vaddr = %x\n",
    298             this, excPC, hal_mmu_exception_str(excp_code) , bad_vaddr );
     301            assert( false , __FUNCTION__ ,
     302            "thread %x / core[%x,%d] / epc %x / vaddr %x / cycle %d\n",
     303            this, local_cxy, this->core->lid, excPC, bad_vaddr, (uint32_t)hal_get_cycles() );
    299304
    300305            return EXCP_KERNEL_PANIC;
     
    440445        hal_exception_dump( this , uzone , error );
    441446
    442         sys_kill( this->process->pid , SIGKILL );
     447        sys_exit( EXIT_FAILURE );
    443448        }
    444449    else if( error == EXCP_KERNEL_PANIC )   // kernel error => kernel panic
     
    447452
    448453        assert( false , __FUNCTION__ , "thread %x in process %x on core [%x,%d]",
    449         this->trdid , this->process->pid , local_cxy , this->core->lid );
     454        this , this->process->pid , local_cxy , this->core->lid );
    450455    }
    451456
  • trunk/hal/tsar_mips32/core/hal_gpt.c

    r438 r440  
    141141    // check page size
    142142    assert( (CONFIG_PPM_PAGE_SIZE == 4096) , __FUNCTION__ ,
    143     "for TSAR, the page must be 4 Kbytes\n" );
     143    "for TSAR, the page size must be 4 Kbytes\n" );
    144144
    145145    // allocates 2 physical pages for PT1
  • trunk/hal/tsar_mips32/drivers/soclib_bdv.c

    r438 r440  
    6666    // get client thread cluster and local pointer
    6767    cxy_t      th_cxy = GET_CXY( th_xp );
    68     thread_t * th_ptr = (thread_t *)GET_PTR( th_xp );
     68    thread_t * th_ptr = GET_PTR( th_xp );
    6969
    7070    // get command arguments and extended pointer on IOC device
     
    9191    // get IOC device cluster and local pointer
    9292    cxy_t      ioc_cxy = GET_CXY( ioc_xp );
    93     chdev_t  * ioc_ptr = (chdev_t *)GET_PTR( ioc_xp );
    94 
    95     // get extended pointer on SOCLIB-BDV peripheral
    96     xptr_t     bdv_xp = hal_remote_lw( XPTR( ioc_cxy , &ioc_ptr->base ) );
    97 
    98     // get SOCLIB_BDV device cluster and local pointer
    99     cxy_t      bdv_cxy = GET_CXY( bdv_xp );
    100     uint32_t * bdv_ptr = (uint32_t *)GET_PTR( bdv_xp );
     93    chdev_t  * ioc_ptr = GET_PTR( ioc_xp );
     94
     95    // get cluster and pointers for SOCLIB-BDV peripheral segment base
     96    xptr_t     seg_xp  = (xptr_t)hal_remote_lwd( XPTR( ioc_cxy , &ioc_ptr->base ) );
     97    cxy_t      seg_cxy = GET_CXY( seg_xp );
     98    uint32_t * seg_ptr = GET_PTR( seg_xp );
    10199
    102100    // split buffer address in two 32 bits words
     
    110108
    111109    // set SOCLIB_BDV registers to start one I/O operation
    112     hal_remote_sw( XPTR( bdv_cxy , bdv_ptr + BDV_IRQ_ENABLE_REG ) , 1       );
    113     hal_remote_sw( XPTR( bdv_cxy , bdv_ptr + BDV_BUFFER_REG     ) , buf_lsb );
    114     hal_remote_sw( XPTR( bdv_cxy , bdv_ptr + BDV_BUFFER_EXT_REG ) , buf_msb );
    115     hal_remote_sw( XPTR( bdv_cxy , bdv_ptr + BDV_LBA_REG        ) , lba     );
    116     hal_remote_sw( XPTR( bdv_cxy , bdv_ptr + BDV_COUNT_REG      ) , count   );
    117     hal_remote_sw( XPTR( bdv_cxy , bdv_ptr + BDV_OP_REG         ) , op      );
     110    hal_remote_sw( XPTR( seg_cxy , seg_ptr + BDV_IRQ_ENABLE_REG ) , 1       );
     111    hal_remote_sw( XPTR( seg_cxy , seg_ptr + BDV_BUFFER_REG     ) , buf_lsb );
     112    hal_remote_sw( XPTR( seg_cxy , seg_ptr + BDV_BUFFER_EXT_REG ) , buf_msb );
     113    hal_remote_sw( XPTR( seg_cxy , seg_ptr + BDV_LBA_REG        ) , lba     );
     114    hal_remote_sw( XPTR( seg_cxy , seg_ptr + BDV_COUNT_REG      ) , count   );
     115    hal_remote_sw( XPTR( seg_cxy , seg_ptr + BDV_OP_REG         ) , op      );
    118116
    119117    // waiting policy  depends on the command type
     
    126124        while (1)
    127125        {
    128             status = hal_remote_lw( XPTR( bdv_cxy , bdv_ptr + BDV_STATUS_REG ) );
     126            status = hal_remote_lw( XPTR( seg_cxy , seg_ptr + BDV_STATUS_REG ) );
    129127
    130128            if( status == BDV_READ_SUCCESS ) // successfully completed
  • trunk/hal/tsar_mips32/drivers/soclib_hba.c

    r437 r440  
    104104    // get client thread cluster and local pointer
    105105    cxy_t      th_cxy = GET_CXY( th_xp );
    106     thread_t * th_ptr = (thread_t *)GET_PTR( th_xp );
     106    thread_t * th_ptr = GET_PTR( th_xp );
    107107
    108108    // get command arguments and extended pointer on IOC device
     
    115115    // get IOC device cluster and local pointer
    116116    cxy_t     dev_cxy = GET_CXY( dev_xp );
    117     chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
    118 
    119     // get extended pointer on SOCLIB-HBA peripheral
    120     xptr_t     hba_xp = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->base ) );
    121 
    122     // get SOCLIB_HBA device cluster and local pointer
     117    chdev_t * dev_ptr = GET_PTR( dev_xp );
     118
     119    // get cluster and pointers for SOCLIB-HBA peripheral segment base
     120    xptr_t     hba_xp  = (xptr_t)hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );
    123121    cxy_t      hba_cxy = GET_CXY( hba_xp );
    124     uint32_t * hba_ptr = (uint32_t *)GET_PTR( hba_xp );
     122    uint32_t * hba_ptr = GET_PTR( hba_xp );
    125123
    126124    // try to register the I/O operation in a free slot
  • trunk/hal/tsar_mips32/drivers/soclib_mmc.c

    r279 r440  
    5252    xptr_t     dev_xp;       // extended pointer on MMC device
    5353    uint32_t   type;         // MMC command : type
    54     uint64_t   buf_paddr;    // MMC command : buffer physical address
     54    void     * buf_ptr;      // MMC command : buffer pointer
    5555    uint32_t   buf_size;     // MMC command : buffer size
    5656    uint32_t   reg_index;    // MMC command : register index in MMC peripheral
     
    5959    // get client thread cluster and local pointer
    6060    cxy_t      th_cxy = GET_CXY( th_xp );
    61     thread_t * th_ptr = (thread_t *)GET_PTR( th_xp );
     61    thread_t * th_ptr = GET_PTR( th_xp );
    6262
    6363    // get command type and extended pointer on MMC device
     
    6767    // get MMC device cluster and local pointer
    6868    cxy_t     dev_cxy = GET_CXY( dev_xp );
    69     chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
     69    chdev_t * dev_ptr = GET_PTR( dev_xp );
    7070
    71     // get extended pointer on SOCLIB-MMC peripheral
    72     xptr_t     mmc_xp = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->base ) );
    73 
    74     // get SOCLIB_MMC peripheral cluster and local pointer
    75     cxy_t      mmc_cxy = GET_CXY( mmc_xp );
    76     uint32_t * mmc_ptr = (uint32_t *)GET_PTR( mmc_xp );
     71    // get cluster and pointers for SOCLIB_MMC peripheral segment base
     72    xptr_t     seg_xp = (xptr_t)hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );
     73    cxy_t      seg_cxy = GET_CXY( seg_xp );
     74    uint32_t * seg_ptr = GET_PTR( seg_xp );
    7775
    7876    if( (type == MMC_CC_INVAL) || (type == MMC_CC_SYNC) )
    7977    {
    80         // get buffer paddr
    81         buf_paddr = hal_remote_lwd( XPTR( th_cxy , &th_ptr->mmc_cmd.buf_paddr ) );
     78        // get buffer pointer and size
     79        buf_ptr  = hal_remote_lpt( XPTR( th_cxy , &th_ptr->mmc_cmd.buf_ptr ) );
     80        buf_size = hal_remote_lw ( XPTR( th_cxy , &th_ptr->mmc_cmd.buf_size ) );
    8281
    83         // split buffer paddr in two 32 bits words
    84         uint32_t   buf_lo = (uint32_t)( buf_paddr );
    85         uint32_t   buf_hi = (uint32_t)( buf_paddr>>32 );
    86 
    87         // get buffer size
    88         buf_size   = hal_remote_lw( XPTR( th_cxy , &th_ptr->mmc_cmd.buf_size ) );
    89 
    90         // get command type
    91         uint32_t cc_cmd;
     82        // set command type
     83        uint32_t   cc_cmd;
    9284        if( type == MMC_CC_INVAL )  cc_cmd = SOCLIB_MMC_CC_INVAL;
    9385        else                        cc_cmd = SOCLIB_MMC_CC_SYNC;
    9486
    9587        // set SOCLIB_MMC registers to start INVAL/SYNC operation
    96         hal_remote_sw( XPTR( mmc_cxy , mmc_ptr + SOCLIB_MMC_ADDR_LO    ) , buf_lo );
    97         hal_remote_sw( XPTR( mmc_cxy , mmc_ptr + SOCLIB_MMC_ADDR_HI    ) , buf_hi );
    98         hal_remote_sw( XPTR( mmc_cxy , mmc_ptr + SOCLIB_MMC_BUF_LENGTH ) , buf_size );
    99         hal_remote_sw( XPTR( mmc_cxy , mmc_ptr + SOCLIB_MMC_CMD_TYPE   ) , cc_cmd );
     88        hal_remote_sw( XPTR( seg_cxy , seg_ptr + SOCLIB_MMC_ADDR_LO    ) , (uint32_t)buf_ptr );
     89        hal_remote_sw( XPTR( seg_cxy , seg_ptr + SOCLIB_MMC_ADDR_HI    ) , (uint32_t)dev_cxy );
     90        hal_remote_sw( XPTR( seg_cxy , seg_ptr + SOCLIB_MMC_BUF_LENGTH ) , buf_size );
     91        hal_remote_sw( XPTR( seg_cxy , seg_ptr + SOCLIB_MMC_CMD_TYPE   ) , cc_cmd );
    10092    }
    10193    else  // (type == MMC_GET_ERROR) or (type == MMC_GET_ERROR) pr (type == MMC_GET_INSTRU )
     
    108100        if( (type == MMC_GET_ERROR) || (type == MMC_GET_INSTRU) )
    109101        {
    110             *reg_ptr =  hal_remote_lw( XPTR( mmc_cxy , mmc_ptr + reg_index ) );
     102            *reg_ptr =  hal_remote_lw( XPTR( seg_cxy , seg_ptr + reg_index ) );
    111103        }
    112104        else  // type == MMC_SET_ERROR
    113105        {
    114             hal_remote_sw( XPTR( mmc_cxy , mmc_ptr + reg_index ) , *reg_ptr );
     106            hal_remote_sw( XPTR( seg_cxy , seg_ptr + reg_index ) , *reg_ptr );
    115107        }
    116108    }
  • trunk/hal/tsar_mips32/drivers/soclib_pic.c

    r438 r440  
    483483        // in TSAR : XCU output [4*lid] is connected to core [lid]
    484484        hal_remote_sw( XPTR( src_chdev_cxy ,
    485                        &seg_xcu_ptr[ (XCU_MSK_HWI_ENABLE << 5) | (lid<<4) ] ) , (1 << irq_id) );
     485                       &seg_xcu_ptr[ (XCU_MSK_HWI_ENABLE << 5) | (lid<<2) ] ) , (1 << irq_id) );
    486486    }
    487487    else if( irq_type == SOCLIB_TYPE_WTI )
     
    490490        // in TSAR : XCU output [4*lid] is connected to core [lid]
    491491        hal_remote_sw( XPTR( src_chdev_cxy ,
    492                        &seg_xcu_ptr[ (XCU_MSK_WTI_ENABLE << 5) | (lid<<4) ] ) , (1 << irq_id) );
     492                       &seg_xcu_ptr[ (XCU_MSK_WTI_ENABLE << 5) | (lid<<2) ] ) , (1 << irq_id) );
    493493    }
    494494    else
     
    525525        // in TSAR : XCU output [4*lid] is connected to core [lid]
    526526        hal_remote_sw( XPTR( src_chdev_cxy ,
    527                        &seg_xcu_ptr[(XCU_MSK_WTI_DISABLE << 5) | (lid<<4) ] ) , (1 << irq_id) );
     527                       &seg_xcu_ptr[(XCU_MSK_WTI_DISABLE << 5) | (lid<<2) ] ) , (1 << irq_id) );
    528528    }
    529529    else
  • trunk/hal/tsar_mips32/drivers/soclib_tty.c

    r438 r440  
    137137#endif
    138138
    139     // get TXT device pointers
    140     xptr_t    dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->txt_cmd.dev_xp ) );
    141     cxy_t     dev_cxy = GET_CXY( dev_xp );
    142     chdev_t * dev_ptr = GET_PTR( dev_xp );
    143 
    144     // get extended pointer on SOCLIB_TTY base segment
    145     xptr_t tty_xp = (xptr_t)hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );
    146 
    147     // get SOCLIB_TTY base segment cluster and local pointer
     139    // get TXT device cluster and pointers
     140    xptr_t     dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->txt_cmd.dev_xp ) );
     141    cxy_t      dev_cxy = GET_CXY( dev_xp );
     142    chdev_t  * dev_ptr = GET_PTR( dev_xp );
     143
     144    // get cluster and pointers for SOCLIB_TTY peripheral base segment
     145    xptr_t     tty_xp = (xptr_t)hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );
    148146    cxy_t      tty_cxy = GET_CXY( tty_xp );
    149147    uint32_t * tty_ptr = GET_PTR( tty_xp );
     
    346344                owner_pid = hal_remote_lw( XPTR( owner_cxy , &owner_ptr->pid ) );
    347345
    348                 // block owner process only if it is not a KSH
     346                // block owner process only if it is not INIT or KSH
    349347                if( process_get_ppid( owner_xp ) > 1 )
    350348                {
     
    362360            if( byte == 0x03 )
    363361            {
    364                 // get pointers on TXT owner process in owner cluster
     362                // get pointer on TXT owner process in owner cluster
    365363                owner_xp  = process_txt_get_owner( channel );
    366364
     
    380378                    process_txt_detach( owner_xp );
    381379
    382                     // mark for delete all processes in all clusters, but the main
     380                    // mark for delete all thread in all clusters, but the main
    383381                    process_sigaction( owner_pid , DELETE_ALL_THREADS );
    384382               
Note: See TracChangeset for help on using the changeset viewer.