cpu_startup.S revision 1.1
11.1Smacallan/* $NetBSD: cpu_startup.S,v 1.1 2016/01/29 01:54:14 macallan Exp $ */ 21.1Smacallan 31.1Smacallan/*- 41.1Smacallan * Copyright (c) 2015 Michael Lorenz 51.1Smacallan * All rights reserved. 61.1Smacallan * 71.1Smacallan * Redistribution and use in source and binary forms, with or without 81.1Smacallan * modification, are permitted provided that the following conditions 91.1Smacallan * are met: 101.1Smacallan * 1. Redistributions of source code must retain the above copyright 111.1Smacallan * notice, this list of conditions and the following disclaimer. 121.1Smacallan * 2. Redistributions in binary form must reproduce the above copyright 131.1Smacallan * notice, this list of conditions and the following disclaimer in the 141.1Smacallan * documentation and/or other materials provided with the distribution. 151.1Smacallan * 161.1Smacallan * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 171.1Smacallan * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 181.1Smacallan * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 191.1Smacallan * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 201.1Smacallan * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 211.1Smacallan * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 221.1Smacallan * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 231.1Smacallan * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 241.1Smacallan * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 251.1Smacallan * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 261.1Smacallan * POSSIBILITY OF SUCH DAMAGE. 271.1Smacallan */ 281.1Smacallan 291.1Smacallan#include "opt_cputype.h" 301.1Smacallan#include "opt_multiprocessor.h" 311.1Smacallan 321.1Smacallan#include <sys/cdefs.h> 331.1Smacallan#include <sys/endian.h> 341.1Smacallan 351.1Smacallan#include <mips/asm.h> 361.1SmacallanRCSID("$NetBSD: cpu_startup.S,v 1.1 2016/01/29 01:54:14 macallan Exp $"); 371.1Smacallan 381.1Smacallan#ifdef MULTIPROCESSOR 391.1Smacallan 401.1Smacallan#include <mips/cpuregs.h> 411.1Smacallan#include <mips/cache_r4k.h> 421.1Smacallan 431.1Smacallan#include "assym.h" 441.1Smacallan 451.1Smacallan#define CACHE_SIZE (32 * 1024) 461.1Smacallan#define CACHE_LINESIZE 32 471.1Smacallan 481.1SmacallanNESTED_NOPROFILE(ingenic_trampoline, 0, ra) 491.1Smacallan /* 501.1Smacallan * We act as the idle lwp so make it CURLWP. When know 511.1Smacallan * that the cpu_info is a KSEG0 address. 521.1Smacallan */ 531.1Smacallan move a0, a1 541.1Smacallan // Loop until idlelwp is filled in. 551.1Smacallan1: PTR_L MIPS_CURLWP, CPU_INFO_IDLELWP(a0) 561.1Smacallan nop 571.1Smacallan beqz MIPS_CURLWP, 1b 581.1Smacallan nop 591.1Smacallan PTR_S MIPS_CURLWP, CPU_INFO_CURLWP(a0) 601.1Smacallan 611.1Smacallan li v0, 0 621.1Smacallan mtc0 v0, MIPS_COP_0_STATUS # reset to known state 631.1Smacallan COP0_SYNC 641.1Smacallan 651.1Smacallan PTR_L sp, L_MD_UTF(MIPS_CURLWP) # fetch KSP 661.1Smacallan 671.1Smacallan /* 681.1Smacallan * Indicate that no one has called us. 691.1Smacallan */ 701.1Smacallan move ra, zero 711.1Smacallan REG_S ra, CALLFRAME_RA(sp) 721.1Smacallan 731.1Smacallan /* 741.1Smacallan * New execution constant needs GP to be loaded. 751.1Smacallan */ 761.1Smacallan PTR_LA gp, _C_LABEL(_gp) 771.1Smacallan 781.1Smacallan /* 791.1Smacallan * and off we go. 801.1Smacallan */ 811.1Smacallan j _C_LABEL(cpu_hatch) # does everything 821.1Smacallan nop 831.1SmacallanEND(ingenic_trampoline) 841.1Smacallan 851.1Smacallan 861.1Smacallan/* 871.1Smacallan * exception vector secondary CPUs take when started 881.1Smacallan */ 891.1Smacallan.p2align 16 901.1SmacallanVECTOR(ingenic_wakeup, unknown) 911.1Smacallan .set noat 921.1Smacallan 931.1Smacallan mtc0 zero, MIPS_COP_0_CAUSE 941.1Smacallan COP0_SYNC 951.1Smacallan 961.1Smacallan /* init caches */ 971.1Smacallan li t0, MIPS_KSEG0_START 981.1Smacallan ori t1, t0, CACHE_SIZE 991.1Smacallan mtc0 zero, MIPS_COP_0_TAG_LO, 0 1001.1Smacallan COP0_SYNC 1011.1Smacallan1: cache CACHEOP_R4K_INDEX_STORE_TAG | CACHE_R4K_I, 0(t0) 1021.1Smacallan cache CACHEOP_R4K_INDEX_STORE_TAG | CACHE_R4K_D, 0(t0) 1031.1Smacallan addiu t0, t0, CACHE_LINESIZE 1041.1Smacallan bne t0, t1, 1b 1051.1Smacallan nop 1061.1Smacallan 1071.1Smacallan /* kseg0 cache attribute */ 1081.1Smacallan mfc0 t0, MIPS_COP_0_CONFIG, 0 1091.1Smacallan ori t0, t0, MIPS3_TLB_ATTR_WB_NONCOHERENT 1101.1Smacallan mtc0 t0, MIPS_COP_0_CONFIG, 0 1111.1Smacallan COP0_SYNC 1121.1Smacallan 1131.1Smacallan /* pagemask */ 1141.1Smacallan mtc0 zero, MIPS_COP_0_TLB_PG_MASK, 0 1151.1Smacallan COP0_SYNC 1161.1Smacallan 1171.1Smacallan /* 1181.1Smacallan * - set a1 to corresponding cpu_info 1191.1Smacallan * - set sp to ci->ci_data.cpu_idlelwp->l_md.md_utf 1201.1Smacallan * - jump to cpu_trampoline 1211.1Smacallan */ 1221.1Smacallan PTR_L a1, _C_LABEL(startup_cpu_info) 1231.1Smacallan nop 1241.1Smacallan 1251.1Smacallan j ingenic_trampoline 1261.1Smacallan nop 1271.1Smacallan .set at 1281.1SmacallanVECTOR_END(ingenic_wakeup) 1291.1Smacallan 1301.1Smacallan#endif /* MULTIPROCESSOR */ 131