[BACK]Return to srt0.S CVS log [TXT][DIR] Up to [local] / sys / arch / sparc / stand / common

Annotation of sys/arch/sparc/stand/common/srt0.S, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: srt0.S,v 1.2 2002/08/11 12:20:43 art Exp $    */
                      2: /*     $NetBSD: srt0.S,v 1.5.4.2 1996/07/17 01:51:46 jtc Exp $ */
                      3:
                      4: /*
                      5:  * Copyright (c) 1994 Paul Kranenburg
                      6:  * All rights reserved.
                      7:  *
                      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  * 1. Redistributions of source code must retain the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer.
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
                     16:  * 3. All advertising materials mentioning features or use of this software
                     17:  *    must display the following acknowledgement:
                     18:  *     This product includes software developed by Paul Kranenburg.
                     19:  * 4. The name of the author may not be used to endorse or promote products
                     20:  *    derived from this software without specific prior written permission.
                     21:  *
                     22:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     23:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     24:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     25:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     26:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     27:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     28:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     29:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     30:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     31:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     32:  */
                     33:
                     34: #include <machine/param.h>
                     35: #include <machine/psl.h>
                     36: #include <machine/asm.h>
                     37:
                     38: #define        CCFSZ   96
                     39:
                     40:        .file   "str0.s"
                     41:
                     42:        .data
                     43:        .global _C_LABEL(cputyp), _C_LABEL(nbpg), _C_LABEL(pgofset)
                     44:        .global _C_LABEL(pgshift)
                     45: _C_LABEL(cputyp):
                     46:        .word   1
                     47: _C_LABEL(nbpg):
                     48:        .word   1
                     49: _C_LABEL(pgofset):
                     50:        .word   1
                     51: _C_LABEL(pgshift):
                     52:        .word   1
                     53:
                     54:        .text
                     55:        .globl  start
                     56:
                     57: start:
                     58:        /*
                     59:         * Set up a stack.
                     60:         */
                     61:        set     start, %o1
                     62:        save    %o1, -CCFSZ, %sp
                     63:
                     64:        /*
                     65:         * Relocate.
                     66:         */
                     67: 1:     call    2f
                     68:         nop
                     69: 2:     add     %o7, (start-1b), %l0
                     70:        set     start, %l1
                     71:        set     _C_LABEL(end), %o0
                     72:        sub     %o0, %l1, %l2           ! length
                     73: 3:     ld      [%l0], %o0
                     74:        add     %l0, 4, %l0
                     75:        st      %o0, [%l1]
                     76:        subcc   %l2, 4, %l2
                     77:        bg      3b
                     78:         add    %l1, 4, %l1
                     79:
                     80:        set     4f, %g1
                     81:        jmp     %g1
                     82:         nop
                     83:
                     84: 4:
                     85: #ifdef notyet
                     86:        /*
                     87:         * Enable traps
                     88:         */
                     89:        wr      %g0, 0, %wim            ! make sure we can set psr
                     90:        nop; nop; nop
                     91:        wr      %g0, PSR_S|PSR_PS|PSR_PIL, %psr ! set initial psr
                     92:        nop; nop; nop
                     93:        wr      %g0, 2, %wim            ! set initial %wim (w1 invalid)
                     94:
                     95:        rd      %psr, %l0
                     96:        wr      %l0, PSR_ET, %psr
                     97:        nop; nop; nop
                     98: #endif
                     99:
                    100:        /*
                    101:         * Clear BSS
                    102:         */
                    103:        set     _C_LABEL(edata), %o0    ! bzero(edata, end - edata)
                    104:        set     _C_LABEL(end), %o1
                    105:        call    _C_LABEL(bzero)
                    106:         sub    %o1, %o0, %o1
                    107:
                    108:        /*
                    109:         * Enable interrupts, but only above level 11. This enables "L1-A",
                    110:         * but avoids spurious interrupt bites from most other devices.
                    111:         */
                    112:        rd      %psr, %o0
                    113:        andn    %o0, PSR_PIL, %o0
                    114:        wr      %o0, 0xb00, %psr        ! (11 << 8)
                    115:        nop; nop; nop
                    116:
                    117:        /*
                    118:         * Set CPU type that we are running on.
                    119:         */
                    120:        sethi   %hi(_C_LABEL(cputyp)), %o0
                    121:        set     0x4000, %g7
                    122:        cmp     %i0, %g7
                    123:        beq     5f
                    124:         nop
                    125:
                    126:        /*
                    127:         * Save address of PROM vector (passed in %i0).
                    128:         */
                    129:        sethi   %hi(_C_LABEL(promvec)), %o1
                    130:        st      %i0, [%o1 + %lo(_C_LABEL(promvec))]
                    131:
                    132:        mov     CPU_SUN4C, %g4
                    133:        mov     SUN4CM_PGSHIFT, %g5
                    134:        b,a     6f
                    135:
                    136: 5:
                    137:        mov     CPU_SUN4, %g4
                    138:        mov     SUN4_PGSHIFT, %g5
                    139:
                    140: 6:
                    141:        st      %g4, [%o0 + %lo(_C_LABEL(cputyp))]
                    142:        sethi   %hi(_C_LABEL(pgshift)), %o0     ! pgshift = log2(nbpg)
                    143:        st      %g5, [%o0 + %lo(_C_LABEL(pgshift))]
                    144:
                    145:        mov     1, %o0                          ! nbpg = 1 << pgshift
                    146:        sll     %o0, %g5, %g5
                    147:        sethi   %hi(_C_LABEL(nbpg)), %o0        ! nbpg = bytes in a page
                    148:        st      %g5, [%o0 + %lo(_C_LABEL(nbpg))]
                    149:
                    150:        sub     %g5, 1, %g5
                    151:        sethi   %hi(_C_LABEL(pgofset)), %o0     ! page offset = bytes in a page - 1
                    152:        st      %g5, [%o0 + %lo(_C_LABEL(pgofset))]
                    153:
                    154:        call    _C_LABEL(main)
                    155:         mov    %i0, %o0
                    156:
                    157:        ret
                    158:         restore
                    159:
                    160:
                    161: #ifdef TIGHT
                    162:
                    163: /*
                    164:  * XXX - Space saving .div & .rem routines (small & non-negative numbres only)
                    165:  */
                    166:        .align  4
                    167:        .global .div, .udiv
                    168: ! int n = 0; while (a >= b) { a -= b; n++; }; return n;
                    169: .div:
                    170: .udiv:
                    171:        cmp     %o0, %o1
                    172:        bl      2f
                    173:         mov    0, %o5
                    174: 1:
                    175:        sub     %o0, %o1, %o0
                    176:        cmp     %o0, %o1
                    177:        bge     1b
                    178:         add    %o5, 1, %o5
                    179: 2:
                    180:        retl
                    181:         mov    %o5, %o0
                    182:
                    183:        .align  4
                    184:        .global .rem, .urem
                    185: ! while (a>=b) a -= b; return a;
                    186: .rem:
                    187: .urem:
                    188:        cmp     %o0, %o1
                    189:        bl      2f
                    190:         nop
                    191:        sub     %o0, %o1, %o0
                    192: 1:
                    193:        cmp     %o0, %o1
                    194:        bge,a   1b
                    195:         sub    %o0, %o1, %o0
                    196: 2:
                    197:        retl
                    198:         nop
                    199:
                    200: #endif /* TIGHT */

CVSweb