Print this page
bcm2835: remove workaround for u-boot
Since we are not using u-boot, we don't need a work-around for it.
bcm2835: enable access to p10 and p11
When determining whether or not we are running on a supported processor, we
call arm_cpuid_vfpidreg. This function attempts to get the FPSID which
involves talking to p10. It however turns out that after a reset only p14
and p15 are accessible. So, before handing off control to _fakebop_start,
let's enable access to p10 and p11 (privileged mode only).
NOTE: qemu doesn't seem to behave the same - it lets us access p10 & p11
without us doing anything special.
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/armv6/bcm2835/ml/locore.s
+++ new/usr/src/uts/armv6/bcm2835/ml/locore.s
1 1 /*
2 2 * This file and its contents are supplied under the terms of the
3 3 * Common Development and Distribution License ("CDDL"), version 1.0.
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
4 4 * You may only use this file in accordance with the terms of version
5 5 * 1.0 of the CDDL.
6 6 *
7 7 * A full copy of the text of the CDDL should have accompanied this
8 8 * source. A copy of the CDDL is also available via the Internet at
9 9 * http://www.illumos.org/license/CDDL.
10 10 */
11 11
12 12 /*
13 13 * Copyright 2013 (c) Joyent, Inc. All rights reserved.
14 + * Copyright 2015 (c) Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
14 15 */
15 16
16 17 #include <sys/asm_linkage.h>
17 18 #include <sys/machparam.h>
18 19 #include <sys/cpu_asm.h>
19 20
20 21 /*
21 22 * Every story needs a beginning. This is ours.
22 23 */
23 24
24 25 /*
25 26 * We are in a primordial world here. The BMC2835 is going to come along and
26 27 * boot us at _start. Normally we would go ahead and use a main() function, but
27 28 * for now, we'll do that ourselves. As we've started the world, we also need to
28 29 * set up a few things about us, for example our stack pointer. To help us out,
29 30 * it's useful to remember the rough memory map. Remember, this is for physcial
30 31 * addresses. There is no virtual memory here. These sizes are often manipulated
31 32 * by the 'configuration' in the bootloader.
32 33 *
33 34 * +----------------+ <---- Max physical memory
34 35 * | |
35 36 * | |
36 37 * | |
37 38 * +----------------+
38 39 * | |
39 40 * | I/O |
40 41 * | Peripherals |
41 42 * | |
42 43 * +----------------+ <---- I/O base 0x20000000 (corresponds to 0x7E000000)
43 44 * | |
44 45 * | Main |
45 46 * | Memory |
46 47 * | |
47 48 * +----------------+ <---- Top of SDRAM
48 49 * | |
49 50 * | VC |
50 51 * | SDRAM |
51 52 * | |
52 53 * +----------------+ <---- Split determined by bootloader config
53 54 * | |
54 55 * | ARM |
55 56 * | SDRAM |
56 57 * | |
57 58 * +----------------+ <---- Bottom of physical memory 0x00000000
58 59 *
59 60 * With the Raspberry Pi Model B, we have 512 MB of SDRAM. That means we have a
60 61 * range of addresses from [0, 0x20000000). If we assume that the minimum amount
61 62 * of DRAM is given to the GPU - 32 MB, that means we really have the following
62 63 * range: [0, 0x1e000000).
63 64 *
64 65 * By default, this binary will be loaded into 0x8000. For now, that means we
65 66 * will set our initial stack to 0x10000000.
66 67 */
67 68
68 69 /*
69 70 * Recall that _start is the traditional entry point for an ELF binary.
70 71 */
71 72 ENTRY(_start)
72 73 ldr sp, =t0stack
73 74 ldr r4, =DEFAULTSTKSZ
74 75 add sp, r4
75 76 bic sp, sp, #0xff
76 77
77 78 /*
78 79 * establish bogus stacks for exceptional CPU states, our exception
79 80 * code should never make use of these, and we want loud and violent
80 81 * failure should we accidentally try.
81 82 */
82 83 cps #(CPU_MODE_UND)
83 84 mov sp, #-1
84 85 cps #(CPU_MODE_ABT)
85 86 mov sp, #-1
86 87 cps #(CPU_MODE_FIQ)
87 88 mov sp, #-1
88 89 cps #(CPU_MODE_IRQ)
89 90 mov sp, #-1
90 91 cps #(CPU_MODE_SVC)
91 92
92 93 /* Enable highvecs (moves the base of the exception vector) */
93 94 mrc p15, 0, r3, c1, c0, 0
↓ open down ↓ |
70 lines elided |
↑ open up ↑ |
94 95 mov r4, #1
95 96 lsl r4, r4, #13
96 97 orr r3, r3, r4
97 98 mcr p15, 0, r3, c1, c0, 0
98 99
99 100 /* Disable A (disables strict alignment checks) */
100 101 mrc p15, 0, r3, c1, c0, 0
101 102 bic r3, r3, #2
102 103 mcr p15, 0, r3, c1, c0, 0
103 104
104 - /*
105 - * XXX Currently we're using u-boot to allow us to make forward progress
106 - * while the .data section is a bit tumultuous. It loads that, but we
107 - * can say for certain that it does not correctly pass in the machid and
108 - * tagstart. Since we know what it is, we manually fix it up here.
109 - */
110 - mov r2,#0x100
105 + /* Enable access to p10 and p11 (privileged mode only) */
106 + mrc p15, 0, r0, c1, c0, 2
107 + orr r0, #0x00500000
108 + mcr p15, 0, r0, c1, c0, 2
109 +
111 110 bl _fakebop_start
112 111 SET_SIZE(_start)
113 112
114 113 ENTRY(arm_reg_read)
115 114 ldr r0, [r0]
116 115 bx lr
117 116 SET_SIZE(arm_reg_read)
118 117
119 118 ENTRY(arm_reg_write)
120 119 str r1, [r0]
121 120 bx lr
122 121 SET_SIZE(arm_reg_write)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX