Skip to content

Commit 3d87085

Browse files
author
ccj
committed
[linux_boot] 启动了linux但是还没有资源互斥
1 parent c4205f3 commit 3d87085

8 files changed

Lines changed: 750 additions & 13 deletions

File tree

bsp/qemu-virt64-aarch64/Image

21.6 MB
Binary file not shown.

bsp/qemu-virt64-aarch64/applications/SConscript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from building import *
22

33
cwd = GetCurrentDir()
4-
src = Glob('*.c') + Glob('*.cpp')
4+
src = Glob('*.c') + Glob('*.cpp') + Glob('*.S')
55
CPPPATH = [cwd]
66

77
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Boot the reserved CPU3 into the Linux Image loaded by xqemu.bat.
3+
*/
4+
5+
#include <rtthread.h>
6+
#include <cache.h>
7+
#include <cpuport.h>
8+
#include <hypercall.h>
9+
#include <mm_aspace.h>
10+
#include <mmu.h>
11+
#include <psci.h>
12+
13+
#define LINUX_CPU3_MPIDR 0x3UL
14+
#define LINUX_IMAGE_ENTRY 0x48200000UL
15+
#define LINUX_DTB_ADDRESS 0x4f000000UL
16+
17+
extern void linux_cpu3_trampoline(void);
18+
extern char linux_cpu3_trampoline_end[];
19+
20+
static int linux_boot(int argc, char **argv)
21+
{
22+
rt_uint32_t ret;
23+
rt_size_t trampoline_size;
24+
rt_ubase_t trampoline_pa;
25+
26+
RT_UNUSED(argc);
27+
RT_UNUSED(argv);
28+
29+
trampoline_size = (rt_ubase_t)linux_cpu3_trampoline_end - (rt_ubase_t)linux_cpu3_trampoline;
30+
trampoline_pa = (rt_ubase_t)rt_kmem_v2p((void *)linux_cpu3_trampoline);
31+
32+
if ((void *)trampoline_pa == ARCH_MAP_FAILED)
33+
{
34+
rt_kprintf("linux_boot: trampoline v2p failed\n");
35+
return -RT_ERROR;
36+
}
37+
38+
rt_hw_cpu_dcache_clean((void *)linux_cpu3_trampoline, trampoline_size);
39+
rt_hw_icache_invalidate_all();
40+
rt_hw_dsb();
41+
rt_hw_isb();
42+
43+
rt_kprintf("linux_boot: cpu3 mpidr=0x%lx trampoline=0x%lx image=0x%lx dtb=0x%lx\n",
44+
LINUX_CPU3_MPIDR, trampoline_pa, LINUX_IMAGE_ENTRY, LINUX_DTB_ADDRESS);
45+
46+
ret = rt_hv_cpu_on(LINUX_CPU3_MPIDR, trampoline_pa, 0);
47+
rt_kprintf("linux_boot: HYP CPU_ON returned %d\n", (int)ret);
48+
49+
return ret == PSCI_RET_SUCCESS ? RT_EOK : -RT_ERROR;
50+
}
51+
MSH_CMD_EXPORT(linux_boot, boot Linux on reserved CPU3);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Trampoline for booting a Linux Image on a reserved CPU.
3+
*/
4+
5+
#ifndef __ASSEMBLY__
6+
#define __ASSEMBLY__
7+
#endif
8+
9+
#define LINUX_IMAGE_ENTRY 0x48200000
10+
#define LINUX_DTB_ADDRESS 0x4f000000
11+
12+
.section ".text.linux_trampoline", "ax"
13+
.align 6
14+
.global linux_cpu3_trampoline
15+
linux_cpu3_trampoline:
16+
ldr x0, =LINUX_DTB_ADDRESS
17+
mov x1, xzr
18+
mov x2, xzr
19+
mov x3, xzr
20+
ldr x4, =LINUX_IMAGE_ENTRY
21+
br x4
22+
23+
.global linux_cpu3_trampoline_end
24+
linux_cpu3_trampoline_end:

bsp/qemu-virt64-aarch64/linux.dts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/dts-v1/;
2+
3+
/ {
4+
interrupt-parent = <0x8005>;
5+
dma-coherent;
6+
model = "linux,virt-isolated";
7+
compatible = "linux,dummy-virt";
8+
#address-cells = <0x02>;
9+
#size-cells = <0x02>;
10+
11+
psci {
12+
migrate = <0xc4000005>;
13+
cpu_on = <0xc4000003>;
14+
cpu_off = <0x84000002>;
15+
cpu_suspend = <0xc4000001>;
16+
method = "smc";
17+
compatible = "arm,psci-1.0", "arm,psci-0.2", "arm,psci";
18+
};
19+
20+
memory@48000000 {
21+
device_type = "memory";
22+
reg = <0x00 0x48000000 0x00 0x08000000>;
23+
};
24+
25+
virtio_mmio@a000000 {
26+
dma-coherent;
27+
interrupts = <0x00 0x10 0x01>;
28+
reg = <0x00 0xa000000 0x00 0x200>;
29+
compatible = "virtio,mmio";
30+
};
31+
32+
intc: intc@8000000 {
33+
phandle = <0x8005>;
34+
interrupts = <0x01 0x09 0x04>;
35+
reg = <0x00 0x8000000 0x00 0x10000 0x00 0x8010000 0x00 0x10000 0x00 0x8030000 0x00 0x10000 0x00 0x8040000 0x00 0x10000>;
36+
compatible = "arm,cortex-a15-gic";
37+
ranges;
38+
#size-cells = <0x02>;
39+
#address-cells = <0x02>;
40+
interrupt-controller;
41+
#interrupt-cells = <0x03>;
42+
};
43+
44+
cpus {
45+
#size-cells = <0x00>;
46+
#address-cells = <0x01>;
47+
48+
cpu-map {
49+
socket0 {
50+
cluster0 {
51+
core0 { cpu = <0x8001>; };
52+
};
53+
};
54+
};
55+
56+
cpu@3 {
57+
phandle = <0x8001>;
58+
reg = <0x03>;
59+
enable-method = "psci";
60+
compatible = "arm,cortex-a53";
61+
device_type = "cpu";
62+
};
63+
};
64+
65+
timer {
66+
interrupts = <0x01 0x0d 0xf04 0x01 0x0e 0xf04 0x01 0x0b 0xf04 0x01 0x0a 0xf04>;
67+
always-on;
68+
compatible = "arm,armv8-timer", "arm,armv7-timer";
69+
};
70+
71+
chosen {
72+
bootargs = "console=hvc0 maxcpus=1 nr_cpus=1 loglevel=8";
73+
};
74+
};

bsp/qemu-virt64-aarch64/rtt.dts

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/dts-v1/;
2+
3+
/ {
4+
interrupt-parent = <0x8005>;
5+
dma-coherent;
6+
model = "rtt,virt";
7+
compatible = "linux,dummy-virt";
8+
#address-cells = <0x02>;
9+
#size-cells = <0x02>;
10+
11+
psci {
12+
migrate = <0xc4000005>;
13+
cpu_on = <0xc4000003>;
14+
cpu_off = <0x84000002>;
15+
cpu_suspend = <0xc4000001>;
16+
method = "smc";
17+
compatible = "arm,psci-1.0", "arm,psci-0.2", "arm,psci";
18+
};
19+
20+
memory@40000000 {
21+
device_type = "memory";
22+
reg = <0x00 0x40000000 0x00 0x08000000>;
23+
};
24+
25+
pl011@9000000 {
26+
clock-names = "uartclk", "apb_pclk";
27+
clocks = <&apb_pclk &apb_pclk>;
28+
interrupts = <0x00 0x01 0x04>;
29+
reg = <0x00 0x9000000 0x00 0x1000>;
30+
compatible = "arm,pl011", "arm,primecell";
31+
};
32+
33+
intc: intc@8000000 {
34+
phandle = <0x8005>;
35+
interrupts = <0x01 0x09 0x04>;
36+
reg = <0x00 0x8000000 0x00 0x10000 0x00 0x8010000 0x00 0x10000 0x00 0x8030000 0x00 0x10000 0x00 0x8040000 0x00 0x10000>;
37+
compatible = "arm,cortex-a15-gic";
38+
ranges;
39+
#size-cells = <0x02>;
40+
#address-cells = <0x02>;
41+
interrupt-controller;
42+
#interrupt-cells = <0x03>;
43+
};
44+
45+
cpus {
46+
#size-cells = <0x00>;
47+
#address-cells = <0x01>;
48+
49+
cpu-map {
50+
socket0 {
51+
cluster0 {
52+
core0 { cpu = <0x8004>; };
53+
core1 { cpu = <0x8003>; };
54+
core2 { cpu = <0x8002>; };
55+
};
56+
};
57+
};
58+
59+
cpu@0 {
60+
phandle = <0x8004>;
61+
reg = <0x00>;
62+
enable-method = "psci";
63+
compatible = "arm,cortex-a53";
64+
device_type = "cpu";
65+
};
66+
67+
cpu@1 {
68+
phandle = <0x8003>;
69+
reg = <0x01>;
70+
enable-method = "psci";
71+
compatible = "arm,cortex-a53";
72+
device_type = "cpu";
73+
};
74+
75+
cpu@2 {
76+
phandle = <0x8002>;
77+
reg = <0x02>;
78+
enable-method = "psci";
79+
compatible = "arm,cortex-a53";
80+
device_type = "cpu";
81+
};
82+
};
83+
84+
timer {
85+
interrupts = <0x01 0x0d 0xf04 0x01 0x0e 0xf04 0x01 0x0b 0xf04 0x01 0x0a 0xf04>;
86+
always-on;
87+
compatible = "arm,armv8-timer", "arm,armv7-timer";
88+
};
89+
90+
apb_pclk: apb-pclk {
91+
clock-output-names = "clk24mhz";
92+
clock-frequency = <0x16e3600>;
93+
#clock-cells = <0x00>;
94+
compatible = "fixed-clock";
95+
};
96+
97+
aliases {
98+
serial0 = "/pl011@9000000";
99+
};
100+
101+
chosen {
102+
stdout-path = "/pl011@9000000";
103+
};
104+
};

0 commit comments

Comments
 (0)