2 * Early kernel startup code for Hexagon
4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 and
9 * only version 2 as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 #include <linux/linkage.h>
23 #include <linux/init.h>
24 #include <asm/asm-offsets.h>
25 #include <asm/mem-layout.h>
26 #include <asm/vm_mmu.h>
32 * VMM will already have set up true vector page, MMU, etc.
33 * To set up initial kernel identity map, we have to pass
34 * the VMM a pointer to some canonical page tables. In
35 * this implementation, we're assuming that we've got
36 * them precompiled. Generate value in R24, as we'll need
39 r24.L = #LO(swapper_pg_dir)
40 r24.H = #HI(swapper_pg_dir)
43 * Symbol is kernel segment address, but we need
44 * the logical/physical address.
49 r25 = and(r2,r25); /* R25 holds PHYS_OFFSET now */
50 r1.h = #HI(PAGE_OFFSET);
51 r1.l = #LO(PAGE_OFFSET);
52 r24 = sub(r24,r1); /* swapper_pg_dir - PAGE_OFFSET */
53 r24 = add(r24,r25); /* + PHYS_OFFSET */
55 r0 = r24; /* aka __pa(swapper_pg_dir) */
58 * Initialize page dir to make the virtual and physical
59 * addresses where the kernel was loaded be identical.
62 #define PTE_BITS ( __HVM_PTE_R | __HVM_PTE_W | __HVM_PTE_X \
63 | __HEXAGON_C_WB_L2 << 6 \
69 r1 = and(r1,r2) /* round PC to 4MB boundary */
70 r2 = lsr(r1, #22) /* 4MB page number */
71 r2 = asl(r2, #2) /* times sizeof(PTE) (4bytes) */
72 r0 = add(r0,r2) /* r0 = address of correct PTE */
74 r1 = add(r1,r2) /* r1 = 4MB PTE for the first entry */
76 r2.l = #0x0000 /* 4MB */
84 * The subroutine wrapper around the virtual instruction touches
85 * no memory, so we should be able to use it even here.
89 /* Jump into virtual address range. */
91 r31.h = #hi(__head_s_vaddr_target)
92 r31.l = #lo(__head_s_vaddr_target)
95 /* Insert trippy space effects. */
97 __head_s_vaddr_target:
99 * Tear down VA=PA translation now that we are running
100 * in the desgnated kernel segments.
102 r0 = #__HVM_PDE_S_INVALID
113 /* Go ahead and install the trap0 return so angel calls work */
114 r0.h = #hi(_K_provisional_vec)
115 r0.l = #lo(_K_provisional_vec)
119 * OK, at this point we should start to be much more careful,
120 * we're going to enter C code and start touching memory
121 * in all sorts of places.
124 * Need to lock shared resources
125 * A bunch of other things that will cause
126 * all kinds of painful bugs
130 * Stack pointer should be pointed at the init task's
131 * thread stack, which should have been declared in arch/init_task.c.
133 * It's accessible via the init_thread_union, which is a union
134 * of a thread_info struct and a stack; of course, the top
135 * of the stack is not for you. The end of the stack
136 * is simply init_thread_union + THREAD_SIZE.
139 {r29.H = #HI(init_thread_union); r0.H = #HI(_THREAD_SIZE); }
140 {r29.L = #LO(init_thread_union); r0.L = #LO(_THREAD_SIZE); }
142 /* initialize the register used to point to current_thread_info */
143 /* Fixme: THREADINFO_REG can't be R2 because of that memset thing. */
144 {r29 = add(r29,r0); THREADINFO_REG = r29; }
146 /* Hack: zero bss; */
147 { r0.L = #LO(__bss_start); r1 = #0; r2.l = #LO(__bss_stop); }
148 { r0.H = #HI(__bss_start); r2.h = #HI(__bss_stop); }
153 /* Set PHYS_OFFSET; should still be in R25 */
154 #ifdef CONFIG_HEXAGON_PHYS_OFFSET
155 r0.l = #LO(__phys_offset);
156 r0.h = #HI(__phys_offset);
160 /* Time to make the doughnuts. */
164 * Should not reach here.
170 ENTRY(external_cmdline_buffer)
175 ENTRY(empty_zero_page)