Ronald G. Minnich | e0e784a | 2014-11-26 19:25:47 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Early initialization code for aarch64 (a.k.a. armv8) |
| 3 | * |
| 4 | * Copyright 2013Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; version 2 of |
| 9 | * the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 19 | * MA 02111-1307 USA |
| 20 | */ |
| 21 | // See LICENSE for license details. relating to the _start code in this file. |
| 22 | #include <arch/encoding.h> |
| 23 | |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame^] | 24 | .section ".text._start", "ax", %progbits |
Ronald G. Minnich | e0e784a | 2014-11-26 19:25:47 +0000 | [diff] [blame] | 25 | // Maybe there's a better way. |
| 26 | .space 0x2000 |
| 27 | .globl _start |
| 28 | _start: |
| 29 | |
| 30 | // pending figuring out this f-ing toolchain. Hardcode what we know works. |
| 31 | la sp, 0x4ef0 // .stacktop |
| 32 | // la a0, trap_entry |
| 33 | // la gp, _gp |
| 34 | // csrw evec, a0 |
| 35 | |
| 36 | # clear any pending interrupts |
| 37 | csrwi clear_ipi, 0 |
| 38 | |
| 39 | li a0, SR_S | SR_PS | SR_EI | SR_S64 | SR_U64 |
| 40 | or a1, a0, SR_EF | SR_EA |
| 41 | csrw status, a1 |
| 42 | csrr a1, status |
| 43 | csrw status, a0 |
| 44 | |
| 45 | // and a2, a1, SR_EF |
| 46 | // sw a2, have_fp, t0 |
| 47 | |
| 48 | // and a2, a1, SR_EA |
| 49 | // sw a2, have_accelerator, t0 |
| 50 | call main |
| 51 | .=0x4000 |
| 52 | .stack: |
| 53 | .align 8 |
| 54 | .space 0xf00 |
| 55 | .stacktop: |
| 56 | .quad 0 |
| 57 | .align 3 |
| 58 | .stack_size: |
| 59 | .quad 0xf00 |
| 60 | |
| 61 | .globl _cbfs_master_header |
| 62 | _cbfs_master_header: |
| 63 | .balignl 16,0xdeadbeef |
| 64 | .align 8 |
| 65 | // this assembler SUCKS |
| 66 | .long 0x4F524243 |
| 67 | .long 0xdeadbeef |
| 68 | .long 0xdeadbeef |
| 69 | .long 0xdeadbeef |
| 70 | .long 0xdeadbeef |
| 71 | .long 0xdeadbeef |
| 72 | .long 0xdeadbeef |
| 73 | /* The CBFS master header is inserted by cbfstool at the first |
| 74 | * aligned offset after the above anchor string is found. |
| 75 | * Hence, we leave some space for it. |
| 76 | * Assumes 64-byte alignment. |
| 77 | */ |
| 78 | .space 128 |
| 79 | |
| 80 | reset: |
| 81 | init_stack_loop: |
| 82 | |
| 83 | .word CONFIG_STACK_SIZE |
| 84 | .section ".id", "a", %progbits |
| 85 | |
| 86 | .section ".id", "a", @progbits |
| 87 | |
| 88 | .globl __id_start |
| 89 | // fix this bs later. What's wrong with the riscv gcc? |
| 90 | __id_start: |
| 91 | ver: |
| 92 | .asciz "1" //COREBOOT_VERSION |
| 93 | vendor: |
| 94 | .asciz "ucb" //CONFIG_MAINBOARD_VENDOR |
| 95 | part: |
| 96 | .asciz "1" //CONFIG_MAINBOARD_PART_NUMBER |
| 97 | .long __id_end + CONFIG_ID_SECTION_OFFSET - ver /* Reverse offset to the vendor id */ |
| 98 | .long __id_end + CONFIG_ID_SECTION_OFFSET - vendor /* Reverse offset to the vendor id */ |
| 99 | .long __id_end + CONFIG_ID_SECTION_OFFSET - part /* Reverse offset to the part number */ |
| 100 | .long CONFIG_ROM_SIZE /* Size of this romimage */ |
| 101 | .globl __id_end |
| 102 | |
| 103 | __id_end: |
| 104 | .previous |