Path: blob/master/arch/sh/boot/compressed/head_64.S
10819 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* arch/shmedia/boot/compressed/head.S6*7* Copied from8* arch/shmedia/kernel/head.S9* which carried the copyright:10* Copyright (C) 2000, 2001 Paolo Alberelli11*12* Modification for compressed loader:13* Copyright (C) 2002 Stuart Menefy ([email protected])14*/15#include <asm/cache.h>16#include <asm/tlb.h>17#include <cpu/mmu_context.h>18#include <cpu/registers.h>1920/*21* Fixed TLB entries to identity map the beginning of RAM22*/23#define MMUIR_TEXT_H 0x0000000000000003 | CONFIG_MEMORY_START24/* Enabled, Shared, ASID 0, Eff. Add. 0xA0000000 */25#define MMUIR_TEXT_L 0x000000000000009a | CONFIG_MEMORY_START26/* 512 Mb, Cacheable (Write-back), execute, Not User, Ph. Add. */2728#define MMUDR_CACHED_H 0x0000000000000003 | CONFIG_MEMORY_START29/* Enabled, Shared, ASID 0, Eff. Add. 0xA0000000 */30#define MMUDR_CACHED_L 0x000000000000015a | CONFIG_MEMORY_START31/* 512 Mb, Cacheable (Write-back), read/write, Not User, Ph. Add. */3233#define ICCR0_INIT_VAL ICCR0_ON | ICCR0_ICI /* ICE + ICI */34#define ICCR1_INIT_VAL ICCR1_NOLOCK /* No locking */3536#define OCCR0_INIT_VAL OCCR0_ON | OCCR0_OCI | OCCR0_WB /* OCE + OCI + WB */37#define OCCR1_INIT_VAL OCCR1_NOLOCK /* No locking */3839.text4041.global startup42startup:43/*44* Prevent speculative fetch on device memory due to45* uninitialized target registers.46* This must be executed before the first branch.47*/48ptabs/u r63, tr049ptabs/u r63, tr150ptabs/u r63, tr251ptabs/u r63, tr352ptabs/u r63, tr453ptabs/u r63, tr554ptabs/u r63, tr655ptabs/u r63, tr756synci5758/*59* Set initial TLB entries for cached and uncached regions.60* Note: PTA/BLINK is PIC code, PTABS/BLINK isn't !61*/62/* Clear ITLBs */63pta 1f, tr164movi ITLB_FIXED, r2165movi ITLB_LAST_VAR_UNRESTRICTED+TLB_STEP, r22661: putcfg r21, 0, r63 /* Clear MMUIR[n].PTEH.V */67addi r21, TLB_STEP, r2168bne r21, r22, tr16970/* Clear DTLBs */71pta 1f, tr172movi DTLB_FIXED, r2173movi DTLB_LAST_VAR_UNRESTRICTED+TLB_STEP, r22741: putcfg r21, 0, r63 /* Clear MMUDR[n].PTEH.V */75addi r21, TLB_STEP, r2176bne r21, r22, tr17778/* Map one big (512Mb) page for ITLB */79movi ITLB_FIXED, r2180movi MMUIR_TEXT_L, r22 /* PTEL first */81putcfg r21, 1, r22 /* Set MMUIR[0].PTEL */82movi MMUIR_TEXT_H, r22 /* PTEH last */83putcfg r21, 0, r22 /* Set MMUIR[0].PTEH */8485/* Map one big CACHED (512Mb) page for DTLB */86movi DTLB_FIXED, r2187movi MMUDR_CACHED_L, r22 /* PTEL first */88putcfg r21, 1, r22 /* Set MMUDR[0].PTEL */89movi MMUDR_CACHED_H, r22 /* PTEH last */90putcfg r21, 0, r22 /* Set MMUDR[0].PTEH */9192/* ICache */93movi ICCR_BASE, r2194movi ICCR0_INIT_VAL, r2295movi ICCR1_INIT_VAL, r2396putcfg r21, ICCR_REG0, r2297putcfg r21, ICCR_REG1, r2398synci99100/* OCache */101movi OCCR_BASE, r21102movi OCCR0_INIT_VAL, r22103movi OCCR1_INIT_VAL, r23104putcfg r21, OCCR_REG0, r22105putcfg r21, OCCR_REG1, r23106synco107108/*109* Enable the MMU.110* From here-on code can be non-PIC.111*/112movi SR_HARMLESS | SR_ENABLE_MMU, r22113putcon r22, SSR114movi 1f, r22115putcon r22, SPC116synco117rte /* And now go into the hyperspace ... */1181: /* ... that's the next instruction ! */119120/* Set initial stack pointer */121movi datalabel stack_start, r0122ld.l r0, 0, r15123124/*125* Clear bss126*/127pt 1f, tr1128movi datalabel __bss_start, r22129movi datalabel _end, r231301: st.l r22, 0, r63131addi r22, 4, r22132bne r22, r23, tr1133134/*135* Decompress the kernel.136*/137pt decompress_kernel, tr0138blink tr0, r18139140/*141* Disable the MMU.142*/143movi SR_HARMLESS, r22144putcon r22, SSR145movi 1f, r22146putcon r22, SPC147synco148rte /* And now go into the hyperspace ... */1491: /* ... that's the next instruction ! */150151/* Jump into the decompressed kernel */152movi datalabel (CONFIG_MEMORY_START + 0x2000)+1, r19153ptabs r19, tr0154blink tr0, r18155156/* Shouldn't return here, but just in case, loop forever */157pt 1f, tr01581: blink tr0, r63159160161