1+ #include "mm.h"
2+
3+ . section ".text.boot"
4+
5+ .globl _start
6+ _start:
7+ mrs x0 , mpidr_el1
8+ and x0 , x0 , # 0x3
9+ cbz x0 , init_bss
10+ / * If processor id is not 0 then pending lock processor
11+ * ( wait for `sev` instruction)
12+ * /
13+ wfe
14+ b master
15+
16+ proc_hang:
17+ b proc_hang
18+
19+ init_bss:
20+ adr x0 , bss_begin
21+ adr x1 , bss_end
22+ sub x1 , x1 , x0
23+ bl memzero
24+
25+ sev
26+
27+ / *********************************************************************** /
28+ / * Enable the other cores
29+ link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/arm64/booting.rst?h=v5. 3 #n255
30+
31+ The boot loader is expected to enter the kernel on each CPU in the
32+ following manner:
33+
34+ - The primary CPU must jump directly to the first instruction of the
35+ kernel image. The device tree blob passed by this CPU must contain
36+ an 'enable-method' property for each cpu node. The supported
37+ enable - methods are described below.
38+
39+ It is expected th at the bootloader will generate these device tree
40+ properties and insert them into the blob prior to kernel entry.
41+
42+ - CPUs with a "spin-table" enable - method must have a 'cpu-release-addr'
43+ property in their cpu node. This property identifies a
44+ naturally - aligned 64 - bit zero - initalised memory location.
45+
46+ These CPUs should spin outside of the kernel in a reserved area of
47+ memory (communicated to the kernel by a /memreserve/ region in the
48+ device tree) polling their cpu - release - addr location , which must be
49+ contained in the reserved region. A wfe instruction may be inserted
50+ to reduce the overhead of the busy - loop and a sev will be issued by
51+ the primary CPU . When a read of the location pointed to by the
52+ cpu - release - addr returns a non - zero value , the CPU must jump to this
53+ value. The value will be written as a single 64 - bit little - endian
54+ value , so CPUs must convert the read value to their native endianness
55+ before jumping to it.
56+
57+ - CPUs with a "psci" enable method should remain outside of
58+ the kernel (i.e. outside of the regions of memory described to the
59+ kernel in the memory node , or in a reserved area of memory described
60+ to the kernel by a /memreserve/ region in the device tree). The
61+ kernel will issue CPU_ON calls as described in ARM document number ARM
62+ DEN 0022A ("Power State Coordination Interface System Software on ARM
63+ processors") to bring CPUs into the kernel.
64+
65+ The device tree should contain a 'psci' node , as described in
66+ Documentation/devicetree/bindings/arm/psci.yaml.
67+
68+ - Secondary CPU general - purpose register settings
69+ x0 = 0 (reserved for future use)
70+ x1 = 0 (reserved for future use)
71+ x2 = 0 (reserved for future use)
72+ x3 = 0 (reserved for future use)
73+ * /
74+
75+ / * cpu0: cpu @ 0 {
76+ device_type = "cpu" ;
77+ compatible = "arm,cortex-a72" ;
78+ reg = < 0 > ;
79+ enable - method = "spin-table" ;
80+ cpu - release - addr = < 0x0 0x000000d8 > ;
81+ } ;
82+
83+ cpu1: cpu @ 1 {
84+ device_type = "cpu" ;
85+ compatible = "arm,cortex-a72" ;
86+ reg = < 1 > ;
87+ enable - method = "spin-table" ;
88+ cpu - release - addr = < 0x0 0x000000e0 > ;
89+ } ;
90+
91+ cpu2: cpu @ 2 {
92+ device_type = "cpu" ;
93+ compatible = "arm,cortex-a72" ;
94+ reg = < 2 > ;
95+ enable - method = "spin-table" ;
96+ cpu - release - addr = < 0x0 0x000000e8 > ;
97+ } ;
98+
99+ cpu3: cpu @ 3 {
100+ device_type = "cpu" ;
101+ compatible = "arm,cortex-a72" ;
102+ reg = < 3 > ;
103+ enable - method = "spin-table" ;
104+ cpu - release - addr = < 0x0 0x000000f0 > ;
105+ } ; */
106+ / **************************************************** /
107+ mov x0 , # 0
108+ adr x0 , master
109+
110+ mov x1 , # 0xe0
111+ str x0 , [ x1 ]
112+ mov x1 , # 0xe8
113+ str x0 , [ x1 ]
114+ mov x1 , # 0xf0
115+ str x0 , [ x1 ]
116+
117+ master:
118+ mrs x0 , mpidr_el1
119+ and x0 , x0 , # 0x3
120+
121+ mov x1 , #SECTION_SIZE
122+ mul x1 , x1 , x0
123+ add x1 , x1 , #LOW_MEMORY
124+ mov sp , x1
125+
126+ bl kernel_main
127+ b proc_hang
0 commit comments