Ignore:
Timestamp:
Jan 29, 2018, 5:57:57 PM (6 years ago)
Author:
alain
Message:

bloup

File:
1 edited

Legend:

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

    r407 r425  
    2929#include <hal_irqmask.h>
    3030
     31#include <printk.h>
     32#include <thread.h>
     33
    3134///////////////////////////////////////////
    3235void hal_copy_from_uspace( void     * k_dst,
    3336                           void     * u_src,
    34                            uint32_t   size )
     37                           uint32_t   size ) 
    3538{
    3639    uint32_t save_sr;
     
    136139{
    137140    uint32_t save_sr;
    138 
    139141    uint32_t src = (uint32_t)u_src;
    140142    uint32_t dst = (uint32_t)k_dst;
     
    142144    hal_disable_irq( &save_sr );
    143145
    144     // loop on characters while ( (character != NUL) and (count < size )
     146    // loop on characters while ( (character != NUL) and (count < size ) )
    145147    asm volatile(
    146148        ".set noreorder             \n"
     
    148150        "move   $12,   %1           \n"   /* $12 <= u_src                   */
    149151        "move   $13,   %2           \n"   /* $13 <= k_dst                   */
    150         "mfc2   $15,   $1           \n"   /* $15 <= MMU_MODE                */
    151         "ori    $14,   $15,  0x7    \n"   /* $14 <= mode DTLB on            */
     152        "mfc2   $15,   $1           \n"   /* $15 <= mode DTLB and ITLB off  */
     153        "ori    $14,   $15,  0x4    \n"   /* $14 <= mode DTLB on            */
    152154        "1:                         \n"
    153155        "mtc2   $14,   $1                       \n"   /* MMU_MODE <= DTLB ON            */
    154156        "lb     $10,   0($12)       \n"   /* read char from user space      */
    155         "mtc2   $15,   $1                       \n"   /* restore MMU_MODE               */
     157        "mtc2   $15,   $1                       \n"   /* restore DTLB and ITLB off      */
    156158            "sb     $10,   0($13)       \n"   /* store char to kernel space     */
    157         "beq    $13,   $0,   2f     \n"   /* exit if char = 0               */
     159        "beq    $10,   $0,   2f     \n"   /* exit if char = 0               */
    158160        "addi   $11,   $11, -1      \n"   /* decrement count                */
    159161        "addi   $12,   $12,  1      \n"   /* increment u_src pointer        */
     
    178180{
    179181    uint32_t save_sr;
    180 
    181182    uint32_t src = (uint32_t)k_src;
    182183    uint32_t dst = (uint32_t)u_dst;
     
    190191        "move   $12,   %1           \n"   /* $12 <= k_src                   */
    191192        "move   $13,   %2           \n"   /* $13 <= u_dst                   */
    192         "mfc2   $15,   $1           \n"   /* $15 <= MMU_MODE                */
    193         "ori    $14,   $15,  0x7    \n"   /* $14 <= mode DTLB on            */
     193        "mfc2   $15,   $1           \n"   /* $15 <= mode DTLB and ITLB off  */
     194        "ori    $14,   $15,  0x4    \n"   /* $14 <= mode DTLB on            */
    194195        "1:                         \n"
    195196        "lb     $10,   0($12)       \n"   /* read char from kernel space    */
    196197        "mtc2   $14,   $1                       \n"   /* MMU_MODE <= DTLB ON            */
    197198            "sb     $10,   0($13)       \n"   /* store char to user space       */
    198         "mtc2   $15,   $1                       \n"   /* restore MMU_MODE               */
    199         "beq    $13,   $0,   2f     \n"   /* exit if char == 0              */
     199        "mtc2   $15,   $1                       \n"   /* restore DTLB and ITLB off      */
     200        "beq    $10,   $0,   2f     \n"   /* exit if char == 0              */
    200201        "addi   $11,   $11, -1      \n"   /* decrement count                */
    201202        "addi   $12,   $12,  1      \n"   /* increment k_src pointer        */
     
    219220    uint32_t save_sr;
    220221    uint32_t count = 0;
    221 
    222     uint32_t str = (uint32_t)u_str;
     222    uint32_t str   = (uint32_t)u_str;
    223223
    224224    hal_disable_irq( &save_sr );
     
    226226        asm volatile(
    227227        ".set noreorder             \n"
    228         "ori    $13,   %1,   0      \n"   /* $13 <= str                     */
    229         "mfc2   $15,   $1           \n"   /* $15 <= MMU_MODE                */
    230         "ori    $14,   $15,  0x7    \n"   /* $14 <= mode DTLB on            */
    231         "mtc2   $14,   $1                       \n"   /* MMU_MODE <= DTLB ON            */
     228        "move   $13,   %1           \n"   /* $13 <= str                     */
     229        "mfc2   $15,   $1           \n"   /* $15 <= DTLB and ITLB off       */
     230        "ori    $14,   $15,  0x4    \n"   /* $14 <= mode DTLB on            */
    232231        "1:                         \n"
     232        "mtc2   $14,   $1                       \n"   /* set DTLB on                    */
    233233        "lb         $12,   0($13)       \n"   /* read char from user space      */
     234        "mtc2   $15,   $1                       \n"   /* set DTLB off                   */
    234235        "addi   $13,   $13,  1      \n"   /* increment address              */
    235236        "bne    $12,   $0,   1b     \n"   /* loop until NUL found           */
    236237        "addi   %0,    %0,   1      \n"   /* increment count                */
    237         "mtc2   $15,   $1                       \n"   /* restore MMU_MODE               */
    238238        ".set reorder               \n"
    239239        : "+r"(count)
Note: See TracChangeset for help on using the changeset viewer.