Path: blob/master/arch/mips/cavium-octeon/executive/cvmx-boot-vector.c
26481 views
/*1* This file is subject to the terms and conditions of the GNU General Public2* License. See the file "COPYING" in the main directory of this archive3* for more details.4*5* Copyright (C) 2004-2017 Cavium, Inc.6*/789/*10We install this program at the bootvector:11------------------------------------12.set noreorder13.set nomacro14.set noat15reset_vector:16dmtc0 $k0, $31, 0 # Save $k0 to DESAVE17dmtc0 $k1, $31, 3 # Save $k1 to KScratch21819mfc0 $k0, $12, 0 # Status20mfc0 $k1, $15, 1 # Ebase2122ori $k0, 0x84 # Enable 64-bit addressing, set23# ERL (should already be set)24andi $k1, 0x3ff # mask out core ID2526mtc0 $k0, $12, 0 # Status27sll $k1, 52829lui $k0, 0xbfc030cache 17, 0($0) # Core-14345, clear L1 Dcache virtual31# tags if the core hit an NMI3233ld $k0, 0x78($k0) # k0 <- (bfc00078) pointer to the reset vector34synci 0($0) # Invalidate ICache to get coherent35# view of target code.3637daddu $k0, $k0, $k138nop3940ld $k0, 0($k0) # k0 <- core specific target address41dmfc0 $k1, $31, 3 # Restore $k1 from KScratch24243beqz $k0, wait_loop # Spin in wait loop44nop4546jr $k047nop4849nop # NOPs needed here to fill delay slots50nop # on endian reversal of previous instructions5152wait_loop:53wait54nop5556b wait_loop57nop5859nop60nop61------------------------------------62630000000000000000 <reset_vector>:640: 40baf800 dmtc0 k0,c0_desave654: 40bbf803 dmtc0 k1,c0_kscratch266678: 401a6000 mfc0 k0,c0_status68c: 401b7801 mfc0 k1,c0_ebase697010: 375a0084 ori k0,k0,0x847114: 337b03ff andi k1,k1,0x3ff727318: 409a6000 mtc0 k0,c0_status741c: 001bd940 sll k1,k1,0x5757620: 3c1abfc0 lui k0,0xbfc07724: bc110000 cache 0x11,0(zero)787928: df5a0078 ld k0,120(k0)802c: 041f0000 synci 0(zero)818230: 035bd02d daddu k0,k0,k18334: 00000000 nop848538: df5a0000 ld k0,0(k0)863c: 403bf803 dmfc0 k1,c0_kscratch2878840: 13400005 beqz k0,58 <wait_loop>8944: 00000000 nop909148: 03400008 jr k0924c: 00000000 nop939450: 00000000 nop9554: 00000000 nop96970000000000000058 <wait_loop>:9858: 42000020 wait995c: 00000000 nop10010160: 1000fffd b 58 <wait_loop>10264: 00000000 nop10310468: 00000000 nop1056c: 00000000 nop106107*/108109#include <asm/octeon/cvmx-boot-vector.h>110111static unsigned long long _cvmx_bootvector_data[16] = {1120x40baf80040bbf803ull, /* patch low order 8-bits if no KScratch*/1130x401a6000401b7801ull,1140x375a0084337b03ffull,1150x409a6000001bd940ull,1160x3c1abfc0bc110000ull,1170xdf5a0078041f0000ull,1180x035bd02d00000000ull,1190xdf5a0000403bf803ull, /* patch low order 8-bits if no KScratch*/1200x1340000500000000ull,1210x0340000800000000ull,1220x0000000000000000ull,1230x4200002000000000ull,1240x1000fffd00000000ull,1250x0000000000000000ull,126OCTEON_BOOT_MOVEABLE_MAGIC1,1270 /* To be filled in with address of vector block*/128};129130/* 2^10 CPUs */131#define VECTOR_TABLE_SIZE (1024 * sizeof(struct cvmx_boot_vector_element))132133static void cvmx_boot_vector_init(void *mem)134{135uint64_t kseg0_mem;136int i;137138memset(mem, 0, VECTOR_TABLE_SIZE);139kseg0_mem = cvmx_ptr_to_phys(mem) | 0x8000000000000000ull;140141for (i = 0; i < 15; i++) {142uint64_t v = _cvmx_bootvector_data[i];143144if (OCTEON_IS_OCTEON1PLUS() && (i == 0 || i == 7))145v &= 0xffffffff00000000ull; /* KScratch not available */146cvmx_write_csr(CVMX_MIO_BOOT_LOC_ADR, i * 8);147cvmx_write_csr(CVMX_MIO_BOOT_LOC_DAT, v);148}149cvmx_write_csr(CVMX_MIO_BOOT_LOC_ADR, 15 * 8);150cvmx_write_csr(CVMX_MIO_BOOT_LOC_DAT, kseg0_mem);151cvmx_write_csr(CVMX_MIO_BOOT_LOC_CFGX(0), 0x81fc0000);152}153154/**155* Get a pointer to the per-core table of reset vector pointers156*157*/158struct cvmx_boot_vector_element *cvmx_boot_vector_get(void)159{160struct cvmx_boot_vector_element *ret;161162ret = cvmx_bootmem_alloc_named_range_once(VECTOR_TABLE_SIZE, 0,163(1ull << 32) - 1, 8, "__boot_vector1__", cvmx_boot_vector_init);164return ret;165}166EXPORT_SYMBOL(cvmx_boot_vector_get);167168169