Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ppc32/src/asm.S

    rb60c582 rda52547  
    1 #
    2 # Copyright (c) 2005 Martin Decky
    3 # All rights reserved.
    4 #
    5 # Redistribution and use in source and binary forms, with or without
    6 # modification, are permitted provided that the following conditions
    7 # are met:
    8 #
    9 # - Redistributions of source code must retain the above copyright
    10 #   notice, this list of conditions and the following disclaimer.
    11 # - Redistributions in binary form must reproduce the above copyright
    12 #   notice, this list of conditions and the following disclaimer in the
    13 #   documentation and/or other materials provided with the distribution.
    14 # - The name of the author may not be used to endorse or promote products
    15 #   derived from this software without specific prior written permission.
    16 #
    17 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    18 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    19 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    20 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
    21 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    22 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    26 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    27 #
     1/*
     2 * Copyright (c) 2005 Martin Decky
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
    2828
    2929#include <arch/asm/regname.h>
     30#include <arch/cpu.h>
    3031
    3132.text
     
    4142.global memcpy_from_uspace_failover_address
    4243.global memcpy_to_uspace_failover_address
     44.global early_putchar
    4345
    4446userspace_asm:
    45 
    46         # r3 = uspace_uarg
    47         # r4 = stack
    48         # r5 = entry
    49        
    50         # disable interrupts
    51 
     47       
     48        /*
     49         * r3 = uspace_uarg
     50         * r4 = stack
     51         * r5 = entry
     52         */
     53       
     54        /* Disable interrupts */
     55       
    5256        mfmsr r31
    5357        rlwinm r31, r31, 0, 17, 15
    5458        mtmsr r31
    5559       
    56         # set entry point
     60        /* Set entry point */
    5761       
    5862        mtsrr0 r5
    5963       
    60         # set problem state, enable interrupts
    61        
    62         ori r31, r31, msr_pr
    63         ori r31, r31, msr_ee
     64        /* Set problem state, enable interrupts */
     65       
     66        ori r31, r31, MSR_PR
     67        ori r31, r31, MSR_EE
    6468        mtsrr1 r31
    6569       
    66         # set stack
     70        /* Set stack */
    6771       
    6872        mr sp, r4
    69 
    70         # %r6 is defined to hold pcb_ptr - set it to 0
    71 
     73       
     74        /* %r6 is defined to hold pcb_ptr - set it to 0 */
     75       
    7276        xor r6, r6, r6
    7377       
    74         # jump to userspace
     78        /* Jump to userspace */
    7579       
    7680        rfi
     
    7882iret:
    7983       
    80         # disable interrupts
     84        /* Disable interrupts */
    8185       
    8286        mfmsr r31
     
    140144iret_syscall:
    141145       
    142         # reset decrementer
    143 
     146        /* Reset decrementer */
     147       
    144148        li r31, 1000
    145149        mtdec r31
    146150       
    147         # disable interrupts
     151        /* Disable interrupts */
    148152       
    149153        mfmsr r31
     
    201205        lwz r12, 156(sp)
    202206        lwz sp, 160(sp)
    203 
     207       
    204208        rfi
    205209
     
    213217memcpy_from_uspace:
    214218memcpy_to_uspace:
    215 
     219       
    216220        srwi. r7, r5, 3
    217221        addi r6, r3, -4
    218222        addi r4, r4, -4
    219         beq     2f
     223        beq 2f
    220224       
    221225        andi. r0, r6, 3
     
    225229        1:
    226230       
    227         lwz r7, 4(r4)
    228         lwzu r8, 8(r4)
    229         stw r7, 4(r6)
    230         stwu r8, 8(r6)
    231         bdnz 1b
    232        
    233         andi. r5, r5, 7
     231                lwz r7, 4(r4)
     232                lwzu r8, 8(r4)
     233                stw r7, 4(r6)
     234                stwu r8, 8(r6)
     235                bdnz 1b
     236               
     237                andi. r5, r5, 7
    234238       
    235239        2:
    236240       
    237         cmplwi 0, r5, 4
    238         blt 3f
    239        
    240         lwzu r0, 4(r4)
    241         addi r5, r5, -4
    242         stwu r0, 4(r6)
     241                cmplwi 0, r5, 4
     242                blt 3f
     243               
     244                lwzu r0, 4(r4)
     245                addi r5, r5, -4
     246                stwu r0, 4(r6)
    243247       
    244248        3:
    245249       
    246         cmpwi 0, r5, 0
    247         beqlr
    248         mtctr r5
    249         addi r4, r4, 3
    250         addi r6, r6, 3
     250                cmpwi 0, r5, 0
     251                beqlr
     252                mtctr r5
     253                addi r4, r4, 3
     254                addi r6, r6, 3
    251255       
    252256        4:
    253257       
    254         lbzu r0, 1(r4)
    255         stbu r0, 1(r6)
    256         bdnz 4b
    257         blr
     258                lbzu r0, 1(r4)
     259                stbu r0, 1(r6)
     260                bdnz 4b
     261                blr
    258262       
    259263        5:
    260264       
    261         subfic r0, r0, 4
    262         mtctr r0
     265                subfic r0, r0, 4
     266                mtctr r0
    263267       
    264268        6:
    265269       
    266         lbz r7, 4(r4)
    267         addi r4, r4, 1
    268         stb r7, 4(r6)
    269         addi r6, r6, 1
    270         bdnz 6b
    271         subf r5, r0, r5
    272         rlwinm. r7, r5, 32-3, 3, 31
    273         beq 2b
    274         mtctr r7
    275         b 1b
     270                lbz r7, 4(r4)
     271                addi r4, r4, 1
     272                stb r7, 4(r6)
     273                addi r6, r6, 1
     274                bdnz 6b
     275                subf r5, r0, r5
     276                rlwinm. r7, r5, 32-3, 3, 31
     277                beq 2b
     278                mtctr r7
     279                b 1b
    276280
    277281memcpy_from_uspace_failover_address:
    278282memcpy_to_uspace_failover_address:
    279         # return zero, failure
     283        /* Return zero, failure */
    280284        xor r3, r3, r3
    281285        blr
     286
     287early_putchar:
     288        blr
Note: See TracChangeset for help on using the changeset viewer.