Ignore:
Timestamp:
Jul 27, 2017, 12:23:29 AM (7 years ago)
Author:
alain
Message:

1) Introduce independant command fields for the various devices in the thread descriptor.
2) Introduce a new dev_pic_enable_ipi() function in the generic PIC device
3) Fix two bugs identified by Maxime in the scheduler initialisation, and in the sched_select().
4) fix several bugs in the TSAR hal_kentry.S.
5) Introduce a third kgiet segment (besides kdata and kcode) in the TSAR bootloader.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/tsar_mips32/core/hal_kentry.S

    r121 r279  
    11/*
    2  * hal_kentry.S - exception/interrupt/syscall kernel entry point for MIPS32
     2 * hal_kentry.S - Interrupt / Exception / Syscall kernel entry point for MIPS32
    33 *
    44 * AUthors   Ghassan Almaless (2007,2008,2009,2010,2011,2012)
     
    3030# or syscall for the TSAR_MIPS32 architecture. 
    3131#
    32 # - If the core is in user mode:
    33 #   . we desactivate the MMU.
    34 #   . we save the context in the uzone of the calling thread descriptor.
    35 #   . we increment the cores_in_kernel variable.
    36 #   . we call the relevant exception/interrupt/syscall handler
     32# When we enter the kernel, we test the ststus register:
     33# - If the core is in user mode, we desactivate the MMU, and we save
     34#   the core context in the uzone of the calling thread descriptor.
     35# - If the core is already in kernel mode (in case of interrupt),
     36#   we save the context in the kernel stack.
     37# - In both cases, we increment the cores_in_kernel variable,
     38#   and we call the relevant exception/interrupt/syscall handler
    3739#
    38 # - If the core is already in kernel mode:
    39 #   . we save the context in the kernel stack
    40 #   . we call the relevant exception/interrupt/syscall handler
    41 #
    42 # - In both cases, when the handler returns:
    43 #   . we restore the context
    44 #   . we reactivate the MMU ??? TODO
     40# When we exit the kernel after handler execution:
     41# - we restore the core context from the uzone
    4542#---------------------------------------------------------------------------------
    4643
    47         .section   .kentry,"ax",@progbits
    48         .extern    cpu_do_interrupt
    49         .extern    cpu_do_exception
    50         .extern    cpu_do_syscall
    51         .extern    cpu_kentry
    52         .extern    cpu_kexit
     44        .section   .kgiet, "ax", @progbits
     45
     46        .extern    hal_do_interrupt
     47        .extern    hal_do_exception
     48        .extern    hal_do_syscall
     49        .extern    cluster_core_kernel_enter
     50        .extern    cluster_core_kernel_exit
     51
    5352        .org       0x180
    54         .ent       kentry
    55         .global    kentry
    56         .global    kentry_load
     53        .ent       kernel_enter
     54        .global    kernel_enter
     55
    5756        .set       noat
    5857        .set       noreorder
     
    6766
    6867#---------------------------------------------------------------------------------
    69 # Kernel Entry point
     68# Kernel Entry point for Interrupt / Exception / Syscall
    7069#---------------------------------------------------------------------------------
    7170
    72 kentry:
     71kernel_enter:
    7372        mfc0    $26,    $12                 # read SR to test user/kernel mode
    7473        andi    $26,    $26,  0x10          # User Mode bitmask
     
    101100#---------------------------------------------------------------------------------------       
    102101# this code is executed when the core is in kernel mode:
    103 # - we use an uzone allocated in kernel stack.
     102# - we use an uzone dynamically allocated in kernel stack.
    104103# - we set the MMU off, set the MMU data_paddr extension to local_cxy,
    105104#   and save the CP2_MODE and CP2_DEXT to uzone.
     
    141140
    142141#--------------------------------------------------------------------------------------
    143 # this code is executed in both modes, with the two following assumptions:
    144 # - $27 contains the pointer on uzone to save the cpu registers
     142# This code is executed in both modes, and saves the core context,
     143# with the two following assumptions:
     144# - $27 contains the pointer on uzone to save the core registers
    145145# - $29 contains the kernel stack pointer
    146146
     
    186186        sw      $17,    (UZ_CR*4)($27)          # Save CR
    187187
    188         srl         $3,     $18,  5                 # put SR in kernel mode, IRQ disabled, clear exl
     188    # put SR in kernel mode, IRQ disabled, clear exl
     189        srl         $3,     $18,  5
    189190        sll     $3,         $3,   5     
    190191        mtc0    $3,         $12                         # Set new SR
    191192
    192         andi    $1,     $17,  0x3F          # $1 <= XCODE (from CR)
    193 
    194193        # signal that core enters kernel
    195         jal         cluster_core_kernel_enter
     194        la      $1,     cluster_core_kernel_enter
     195        jal         $1
    196196    nop
    197197
    198198#---------------------------------------------------------------------------------------
    199 # Depending on XCODE (in $1) , call the apropriate handler. The three called
    200 # functions take the same two arguments: thread pointer and uzone pointer.
     199# This code call the relevant Interrupt / Exception / Syscall handler,
     200# depending on XCODE in CP0_CR, with the two following assumptions:
     201# - $27 contains the pointer on uzone containing to save the core registers
     202# - $29 contains the kernel stack pointer
     203# The three handlers take the same two arguments: thread pointer and uzone pointer.
     204# The uzone pointer is saved in $19 to be used by kernel_exit.
     205
     206        mfc0    $17,    $13                 # $1 <= CR
     207        andi    $1,     $1,   0x3F          # $1 <= XCODE
    201208
    202209        mfc0    $4,     $4,   2             # $4 <= thread pointer (first arg)
    203210        or          $5,     $0,   $27               # $5 <= uzone pointer (second arg)
    204         or          $19,    $0,   $27           # $19 <= &uzone (for kentry_exit)
     211        or          $19,    $0,   $27           # $19 <= &uzone (for kernel_exit)
    205212
    206213        ori         $8,     $0,   0x20          # $8 <= cause syscall
     
    215222        addiu   $29,    $29,  -8                # hal_do_exception has 2 args
    216223        addiu   $29,    $29,  8
    217         j       kentry_exit                 # jump to kentry_exit
     224        j       kernel_exit                 # jump to kernel_exit
    218225    nop
    219226
     
    223230        addiu   $29,    $29,  -8            # hal_do_syscall has 2 args
    224231        addiu   $29,    $29,  8
    225         j           kentry_exit                 # jump to kentry_exit
    226         or          $19,        $0,   $2
     232        j           kernel_exit                 # jump to kernel_exit
     233        nop
    227234       
    228235cause_int:
     
    233240
    234241# -----------------------------------------------------------------------------------
    235 # Kentry exit
     242# Kernel exit
     243# The pointer on uzone is supposed to be stored in $19
    236244# -----------------------------------------------------------------------------------
    237 kentry_exit:
     245kernel_exit:
    238246
    239247        # signal that core exit kernel
    240     jal     cluster_core_kernel_exit
     248    la      $1,     cluster_core_kernel_exit
     249    jalr    $1
     250    nop
    241251
    242252        # restore context from uzone
     
    286296        lw          $31,        (UZ_RA*4)($27)
    287297
    288 
    289298        lw          $26,    (UZ_DEXT*4)($27)
    290299        mtc2    $26,    $24                             # restore CP2_DEXT from uzone
    291300
    292     #TODO: optimize
    293         lw          $26,    (UZ_MODE*4)($27)    # get saved CP2_MODE from uzone
    294         andi    $26,    $26,    0xc         # keep only the TLBs controling bits
    295         beq     $26,    $0,         out_mmu_3   # both MSB are 0 (the first two LSB are always set)
    296         andi    $26,    $26,    0x8
    297         beq     $26,    $0,         out_mmu_7   # first MSB is 0 (bit 2 is set)
    298 
    299 # Possible value for MMU_MODE
    300 # In kernel mode : 0x7/0x3
    301 # In user mode   : 0xF
    302 
    303 # DP_EXT can either be local or remote
    304 # Once these register set we can no longuer
    305 # access global data
    306 
    307 out_mmu_F:
    308         ori         $26,        $0,        0xF
    309         mtc2    $26,    $1                              # CP2_MODE <= 0xF
    310         j           out_kentry
    311         nop
    312 
    313 out_mmu_7:
    314         ori         $26,    $0,    0x7 
    315         mtc2    $26,    $1                              # CP2_MODE <= 0x7
    316         j       out_kentry
    317         nop
    318 
    319 out_mmu_3:
    320         ori     $26,    $0,        0x3
    321         mtc2    $26,    $1                              # CP2_MODE <= 0x3
    322 
    323 out_kentry:
     301        lw          $26,    (UZ_MODE*4)($27)   
     302    mtc2    $26,    $1                  # restore CP2_MODE from uzone
     303
    324304        nop
    325305    eret
    326306
    327     .end kentry
     307    .end kernel_enter
    328308    .set reorder
    329309    .set at
    330310
    331         .ent kentry_load
    332 kentry_load:
    333         # theses nops are required to load the eret instruction
    334         # while we are in virtual mode (processor pipeline) ?
    335         mtc2     $26,    $1            # set MMU MODE
    336         nop                     
    337         nop
    338     eret
    339     .end kentry_load
    340 
    341311#-------------------------------------------------------------------------------
    342312
Note: See TracChangeset for help on using the changeset viewer.