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.
52 * Initialize a 16MB PTE to make the virtual and physical
53 * addresses where the kernel was loaded be identical.
55 #define PTE_BITS ( __HVM_PTE_R | __HVM_PTE_W | __HVM_PTE_X \
56 | __HEXAGON_C_WB_L2 << 6 \
62 r1 = and(r1,r2) /* round PC to 4MB boundary */
63 r2 = lsr(r1, #22) /* 4MB page number */
64 r2 = asl(r2, #2) /* times sizeof(PTE) (4bytes) */
65 r0 = add(r0,r2) /* r0 = address of correct PTE */
67 r1 = add(r1,r2) /* r1 = 4MB PTE for the first entry */
69 r2.l = #0x0000 /* 4MB */
77 * The subroutine wrapper around the virtual instruction touches
78 * no memory, so we should be able to use it even here.
82 /* Jump into virtual address range. */
84 r31.h = #hi(__head_s_vaddr_target)
85 r31.l = #lo(__head_s_vaddr_target)
88 /* Insert trippy space effects. */
90 __head_s_vaddr_target:
92 * Tear down VA=PA translation now that we are running
93 * in the desgnated kernel segments.
95 r0 = #__HVM_PDE_S_INVALID
106 /* Go ahead and install the trap0 return so angel calls work */
107 r0.h = #hi(_K_provisional_vec)
108 r0.l = #lo(_K_provisional_vec)
112 * OK, at this point we should start to be much more careful,
113 * we're going to enter C code and start touching memory
114 * in all sorts of places.
117 * Need to lock shared resources
118 * A bunch of other things that will cause
119 * all kinds of painful bugs
123 * Stack pointer should be pointed at the init task's
124 * thread stack, which should have been declared in arch/init_task.c.
126 * It's accessible via the init_thread_union, which is a union
127 * of a thread_info struct and a stack; of course, the top
128 * of the stack is not for you. The end of the stack
129 * is simply init_thread_union + THREAD_SIZE.
132 {r29.H = #HI(init_thread_union); r0.H = #HI(_THREAD_SIZE); }
133 {r29.L = #LO(init_thread_union); r0.L = #LO(_THREAD_SIZE); }
135 /* initialize the register used to point to current_thread_info */
136 /* Fixme: THREADINFO_REG can't be R2 because of that memset thing. */
137 {r29 = add(r29,r0); THREADINFO_REG = r29; }
139 /* Hack: zero bss; */
140 { r0.L = #LO(__bss_start); r1 = #0; r2.l = #LO(__bss_stop); }
141 { r0.H = #HI(__bss_start); r2.h = #HI(__bss_stop); }
146 /* Time to make the doughnuts. */
150 * Should not reach here.
156 ENTRY(external_cmdline_buffer)
161 ENTRY(empty_zero_page)