Path: blob/master/arch/m32r/boot/compressed/head.S
10818 views
/*1* linux/arch/m32r/boot/compressed/head.S2*3* Copyright (c) 2001-2003 Hiroyuki Kondo, Hirokazu Takata,4* Hitoshi Yamamoto, Takeo Takahashi5* Copyright (c) 2004 Hirokazu Takata6*/78.text9#include <linux/linkage.h>10#include <asm/addrspace.h>11#include <asm/page.h>12#include <asm/assembler.h>1314/*15* This code can be loaded anywhere, as long as output will not16* overlap it.17*18* NOTE: This head.S should *NOT* be compiled with -fpic.19*20*/2122.global startup23.global __bss_start, _ebss, end, zimage_data, zimage_len24__ALIGN25startup:26ldi r0, #0x0000 /* SPI, disable EI */27mvtc r0, psw2829ldi r12, #-830bl 1f31.fillinsn321:33seth r1, #high(CONFIG_MEMORY_START + 0x00400000) /* Start address */34add r12, r14 /* Real address */35sub r12, r1 /* difference */3637.global got_len38seth r3, #high(_GLOBAL_OFFSET_TABLE_+8)39or3 r3, r3, #low(_GLOBAL_OFFSET_TABLE_+12)40add r3, r144142/* Update the contents of global offset table */43ldi r1, #low(got_len)44srli r1, #245beqz r1, 2f46.fillinsn471:48ld r2, @r349add r2, r1250st r2, @r351addi r3, #452addi r1, #-153bnez r1, 1b54.fillinsn552:56/* XXX: resolve plt */5758/*59* Clear BSS first so that there are no surprises...60*/61#ifdef CONFIG_ISA_DUAL_ISSUE62seth r2, #high(__bss_start)63or3 r2, r2, #low(__bss_start)64add r2, r1265seth r3, #high(_ebss)66or3 r3, r3, #low(_ebss)67add r3, r1268sub r3, r26970; R4 = BSS size in longwords (rounded down)71mv r4, r3 || ldi r1, #072srli r4, #4 || addi r2, #-473beqz r4, .Lendloop174.Lloop1:75#ifndef CONFIG_CHIP_M3231076; Touch memory for the no-write-allocating cache.77ld r0, @(4,r2)78#endif79st r1, @+r2 || addi r4, #-180st r1, @+r281st r1, @+r282st r1, @+r2 || cmpeq r1, r4 ; R4 = 0?83bnc .Lloop184.Lendloop1:85and3 r4, r3, #1586addi r2, #487beqz r4, .Lendloop288.Lloop2:89stb r1, @r2 || addi r4, #-190addi r2, #191bnez r4, .Lloop292.Lendloop2:9394#else /* not CONFIG_ISA_DUAL_ISSUE */95seth r2, #high(__bss_start)96or3 r2, r2, #low(__bss_start)97add r2, r1298seth r3, #high(_ebss)99or3 r3, r3, #low(_ebss)100add r3, r12101sub r3, r2102mv r4, r3103srli r4, #2 ; R4 = BSS size in longwords (rounded down)104ldi r1, #0 ; clear R1 for longwords store105addi r2, #-4 ; account for pre-inc store106beqz r4, .Lendloop1 ; any more to go?107.Lloop1:108st r1, @+r2 ; yep, zero out another longword109addi r4, #-1 ; decrement count110bnez r4, .Lloop1 ; go do some more111.Lendloop1:112113#endif /* not CONFIG_ISA_DUAL_ISSUE */114115seth r1, #high(end)116or3 r1, r1, #low(end)117add r1, r12118mv sp, r1119120/*121* decompress the kernel122*/123mv r0, sp124srli r0, 31 /* MMU is ON or OFF */125seth r1, #high(zimage_data)126or3 r1, r1, #low(zimage_data)127add r1, r12128seth r2, #high(zimage_len)129or3 r2, r2, #low(zimage_len)130mv r3, sp131132bl decompress_kernel133134#if defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_OPSP) || defined(CONFIG_CHIP_VDEC2)135/* Cache flush */136ldi r0, -1137ldi r1, 0xd0 ; invalidate i-cache, copy back d-cache138stb r1, @r0139#elif defined(CONFIG_CHIP_M32102)140/* Cache flush */141ldi r0, -2142ldi r1, 0x0100 ; invalidate143stb r1, @r0144#elif defined(CONFIG_CHIP_M32104)145/* Cache flush */146ldi r0, -2147ldi r1, 0x0700 ; invalidate i-cache, copy back d-cache148sth r1, @r0149#else150#error "put your cache flush function, please"151#endif152153mv r0, sp154srli r0, 31 /* MMU is ON or OFF */155slli r0, 31156or3 r0, r0, #0x2000157seth r1, #high(CONFIG_MEMORY_START)158or r0, r1159jmp r0160161.balign 512162fake_headers_as_bzImage:163.short 0164.ascii "HdrS"165.short 0x0202166.short 0167.short 0168.byte 0x00, 0x10169.short 0170.byte 0171.byte 1172.byte 0x00, 0x80173.long 0174.long 0175176177178