blob: 9cc442263939750c94b8d55c96cea067668fa9c5 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright (C) Paul Mackerras 1997.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *
9 * NOTE: this code runs in 32 bit mode and is packaged as ELF32.
10 */
11
Olaf Heringdecd3002005-08-08 13:24:38 +100012#include "ppc_asm.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
14 .text
Olaf Hering67a1b682005-10-28 17:46:49 -070015 .globl _zimage_start
16_zimage_start:
Olaf Heringa4497232005-10-28 17:46:48 -070017 bl reloc_offset
18
19reloc_offset:
20 mflr r0
21 lis r9,reloc_offset@ha
22 addi r9,r9,reloc_offset@l
23 subf. r0,r9,r0
24 beq clear_caches
25
26reloc_got2:
27 lis r9,__got2_start@ha
28 addi r9,r9,__got2_start@l
29 lis r8,__got2_end@ha
30 addi r8,r8,__got2_end@l
31 subf. r8,r9,r8
32 beq clear_caches
33 srwi. r8,r8,2
34 mtctr r8
35 add r9,r0,r9
36reloc_got2_loop:
37 lwz r8,0(r9)
38 add r8,r8,r0
39 stw r8,0(r9)
40 addi r9,r9,4
41 bdnz reloc_got2_loop
42
43clear_caches:
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 lis r9,_start@h
Olaf Heringa4497232005-10-28 17:46:48 -070045 add r9,r0,r9
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 lis r8,_etext@ha
47 addi r8,r8,_etext@l
Olaf Heringa4497232005-10-28 17:46:48 -070048 add r8,r0,r8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491: dcbf r0,r9
50 icbi r0,r9
51 addi r9,r9,0x20
52 cmplwi 0,r9,8
53 blt 1b
54 sync
55 isync
56
Olaf Hering7e658112005-10-28 17:46:50 -070057 mr r6,r1
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 b start
59