Annotation of qemu/roms/SLOF/board-qemu/llfw/startup.S, revision 1.1.1.2

1.1       root        1: /******************************************************************************
                      2:  * Copyright (c) 2004, 2011 IBM Corporation
                      3:  * All rights reserved.
                      4:  * This program and the accompanying materials
                      5:  * are made available under the terms of the BSD License
                      6:  * which accompanies this distribution, and is available at
                      7:  * http://www.opensource.org/licenses/bsd-license.php
                      8:  *
                      9:  * Contributors:
                     10:  *     IBM Corporation - initial implementation
                     11:  *****************************************************************************/
                     12: 
                     13: /* SLOF for QEMU -- boot code.
                     14:  * Initial entry point
                     15:  */
                     16: 
                     17: #include <xvect.h>
                     18: #include <cpu.h>
                     19: #include <macros.h>
                     20: 
1.1.1.2 ! root       21: .global print_version_done
        !            22: 
1.1       root       23:        /* qemu entry:
                     24:         *
                     25:         * __start loaded at 0x100
                     26:         *
                     27:         * CPU 0 starts at 0 with GPR3 pointing to the flat devtree
                     28:         *
                     29:         * All other CPUs are held in stopped state by qemu and are
                     30:         * started via RTAS
                     31:         */
                     32:        .text
                     33:        .globl __start
                     34: __start:
                     35:        b       _start
                     36:        .long 0xDEADBEE0
                     37:        .long 0x0       /* size */ 
                     38:        .long 0x0       /* crc  */
                     39:        .long relTag - __start
                     40: 
                     41:        /* Some exception vectors
                     42:         *      
                     43:         * FIXME: Also need 0280, 0380, 0f20, etc.
                     44:         */
                     45: 
                     46:        .irp i, 0x0100,0x0180,0x0200,0x0280,0x0300,0x0380,0x0400,0x0500, \
                     47:                0x0600,0x0700,0x0800,0x0900,0x0a00,0x0b00,0x0c00,0x0d00, \
                     48:                0x0e00,0x0f00,0x1000,0x1100,0x1200,0x1300,0x1400,0x1500, \
                     49:                0x1600,0x1700, \
                     50:                0x1800,0x1900,0x1a00,0x1b00,0x1c00,0x1d00,0x1e00,0x1f00, \
                     51:                0x2000,0x2100,0x2200,0x2300,0x2400,0x2500,0x2600,0x2700, \
                     52:                0x2800,0x2900,0x2a00,0x2b00,0x2c00,0x2d00,0x2e00
                     53:        . = \i
                     54: 
                     55:        /* enable this if you get exceptions before the console works    */
                     56:        /* this will allow using the hardware debugger to see where      */
                     57:        /* it traps, and with what register values etc.                  */
                     58:        // b    $
                     59: 
                     60:        mtsprg  0,r0
                     61:        mfctr   r0
                     62:        mtsprg  2,r0
                     63:        mflr    r0
                     64: // 10
                     65:        mtsprg  3,r0
                     66:        ld      r0, (\i + 0x160)(0)
                     67:        mtctr   r0
                     68:        li      r0, \i + 0x100
                     69: // 20
                     70:        bctr
                     71: 
                     72:        . = \i + 0x60
                     73:        .quad   intHandler2C
                     74:        .endr
                     75: 
                     76:        . = XVECT_M_HANDLER - 0x100
                     77:        .quad   0x00
                     78:        .text
                     79: 
                     80:        /* Here's the startup code for the master CPU */
                     81:        .org 0x4000 - 0x100
                     82: _start:
                     83:        /* Save device-tree pointer */
                     84:        mr      r31,r3
                     85: 
                     86:        /* Switch to 64-bit mode with 64-bit exceptions */
                     87: #define MSR_SF_LG      63              /* Enable 64 bit mode */
                     88: #define MSR_ISF_LG     61              /* Interrupt 64b mode valid on 630 */
                     89: #define __MASK(X)      (1<<(X))
                     90: #define MSR_SF         __MASK(MSR_SF_LG)       /* Enable 64 bit mode */
                     91: #define MSR_ISF                __MASK(MSR_ISF_LG)      /* Interrupt 64b mode */
                     92:        mfmsr   r11                     /* grab the current MSR */
                     93:        li      r12,(MSR_SF | MSR_ISF)@highest
                     94:        sldi    r12,r12,48
                     95:        or      r11,r11,r12
                     96:        mtmsrd  r11
                     97:        isync
                     98: 
                     99:        /* Early greet */
                    100:        li      r3,10
                    101:        bl      putc
                    102:        li      r3,13
                    103:        bl      putc
                    104:        li      r3,10
                    105:        bl      putc
                    106:        li      r3,'S'
                    107:        bl      putc
                    108: 
                    109:        li      r3,'L'
                    110:        bl      putc
                    111:        li      r3,'O'
                    112:        bl      putc
                    113:        li      r3,'F'
                    114:        bl      putc
                    115: 
1.1.1.2 ! root      116:        bl      print_version
        !           117: print_version_done:
1.1       root      118: 
                    119:        /* go! */
                    120:        li      r3,__startC@l
                    121:        mtctr   r3
                    122:        bctrl
                    123:        
                    124:        /* write a character to the HV console */
                    125: putc:  sldi    r6,r3,(24+32)
                    126:        li      r3,0x58
                    127:        li      r4,0
                    128:        li      r5,1
                    129:        .long   0x44000022
                    130:        blr
                    131: 
                    132: relTag:
                    133:        .ascii  RELEASE
                    134:        .ascii  "\0"
                    135:        .align  2
                    136: 
                    137: C_ENTRY(proceedInterrupt)
                    138: 
                    139:        ld      r3,exception_stack_frame@got(r2)
                    140:        ld      r1,0(r3)
                    141: 
                    142:        .irp i, 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16, \
                    143:                17, 18, 19, 20, 21, 22, 23, 24, 25, 26, \
                    144:                27, 28, 29, 30, 31
                    145:        ld      r\i, 0x30+\i*8 (r1)
                    146:        .endr
                    147: 
                    148:        ld      r14,0x138(r1);
                    149:        mtsrr0  r14
                    150: 
                    151:        ld      r14,0x140(r1);
                    152:        mtsrr1  r14
                    153: 
                    154:        ld      r14,0x148(r1);
                    155:        mtcr    r14
                    156: 
                    157:        ld      0,XVECT_M_HANDLER(0)
                    158:        mtctr   0
                    159: 
                    160:        ld      r0,0x30(r1); # restore vector number
                    161:        ld      r1,0x38(r1);
                    162: 
                    163:        bctr
                    164: 
                    165: intHandler2C:
                    166:        mtctr   r1 # save old stack pointer
                    167:        lis     r1,0x4
                    168:        stdu    r1, -0x160(r1)
                    169:        .irp i, 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16, \
                    170:                17, 18, 19, 20, 21, 22, 23, 24, 25, 26, \
                    171:                27, 28, 29, 30, 31
                    172:        std     r\i, 0x30+\i*8 (r1)
                    173:        .endr
                    174: 
                    175:        std     r0,0x30(r1);  # save vector number
                    176: 
                    177:        mfctr   r14
                    178:        std     r14,0x38(r1); # save old r1
                    179: 
                    180:        mfsrr0  r14
                    181:        std     r14,0x138(r1);
                    182: 
                    183:        mfsrr1  r14
                    184:        std     r14,0x140(r1);
                    185: 
                    186:        mfcr    r14
                    187:        std     r14,0x148(r1);
                    188: 
                    189:        mfxer   r14
                    190:        std     r14,0x150(r1);
                    191: 
                    192:        bl      toc_init
                    193: 
                    194:        ld      r3,exception_stack_frame@got(r2)
                    195:        std     r1,0(r3)
                    196: 
                    197: 
                    198:        mr      r3,r0
                    199:        bl      .c_interrupt
                    200: 
                    201:        ld      r14,0x138(r1);
                    202:        mtsrr0  r14
                    203: 
                    204:        ld      r14,0x140(r1);
                    205:        mtsrr1  r14
                    206: 
                    207:        ld      r14,0x148(r1);
                    208:        mtcr    r14
                    209: 
                    210:        ld      r14,0x150(r1);
                    211:        mtxer   r14
                    212: 
                    213: 
                    214:        .irp i, 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16, \
                    215:                17, 18, 19, 20, 21, 22, 23, 24, 25, 26, \
                    216:                27, 28, 29, 30, 31
                    217:        ld      r\i, 0x30+\i*8 (r1)
                    218:        .endr
                    219: 
                    220:        ld      r1,0x38(r1);
                    221: 
                    222:        mfsprg  r0,2
                    223:        mtctr   r0
                    224:        mfsprg  r0,3
                    225:        mtlr    r0
                    226:        mfsprg  r0,0
                    227:        rfid
                    228: 
                    229: /* Set exception handler for given exception vector.  
                    230:        r3:     exception vector offset
                    231:        r4:     exception handler
                    232: */
                    233:        .globl .set_exception
                    234: .set_exception:
                    235:        .globl set_exception
                    236: set_exception:
                    237:        ld r4,0x0(r4)
                    238:        .globl .set_exception_asm
                    239: .set_exception_asm:
                    240:        .globl set_exception_asm
                    241: set_exception_asm:
                    242:        std     r4, 0x60(r3)    # fixme diff 1f - 0b
                    243:        blr

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.