Skip to content

Commit 69d6249

Browse files
committed
tmp gic
1 parent 9b37d2d commit 69d6249

File tree

9 files changed

+2794
-1266
lines changed

9 files changed

+2794
-1266
lines changed

.gdbinit

Lines changed: 2387 additions & 0 deletions
Large diffs are not rendered by default.

bsp/qemu-vexpress-a9/.config

Lines changed: 9 additions & 1032 deletions
Large diffs are not rendered by default.

bsp/qemu-vexpress-a9/applications/main.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,42 @@
1111
#include <stdint.h>
1212
#include <stdio.h>
1313
#include <rtthread.h>
14+
#include <gic.h>
15+
16+
17+
1418

1519
int main(void)
1620
{
1721
rt_kprintf("Hello RT-Thread!\n");
22+
arm_gic_dump_type(0);
23+
24+
rt_uint32_t scr, cpsr;
25+
asm volatile("mrc p15, 0, %0, c1, c1, 0" : "=r"(scr));
26+
asm volatile("mrs %0, cpsr" : "=r"(cpsr));
27+
rt_kprintf("SCR = 0x%08x\n", scr);
28+
rt_kprintf("CPSR = 0x%08x\n", cpsr);
29+
30+
/* 根据 Table B4-29 Processor security state:
31+
* - SCR.NS = 0: 总是 Secure state
32+
* - SCR.NS = 1:
33+
* * Monitor mode (CPSR.M = 0x16): Secure state
34+
* * 其他模式: Non-secure state
35+
*/
36+
rt_uint32_t ns = scr & 0x1;
37+
rt_uint32_t mode = cpsr & 0x1f;
38+
rt_uint32_t is_monitor = (mode == 0x16);
39+
40+
if (ns == 0) {
41+
rt_kprintf("Current world: Secure (SCR.NS=0)\n");
42+
} else {
43+
if (is_monitor) {
44+
rt_kprintf("Current world: Secure (SCR.NS=1, Monitor mode)\n");
45+
} else {
46+
rt_kprintf("Current world: Non-Secure (SCR.NS=1, mode=0x%02x)\n", mode);
47+
}
48+
}
1849

50+
1951
return 0;
2052
}

bsp/qemu-vexpress-a9/drivers/board.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ rt_region_t init_page_region = {
5959
};
6060
#endif
6161

62+
63+
static void xxx_isr(int irqno, void *param)
64+
{
65+
rt_kprintf("xxx_isr irqno=%d param=%p\n", irqno, param);
66+
}
67+
6268
void rt_hw_board_init(void)
6369
{
6470
#ifdef RT_USING_SMART
@@ -91,6 +97,7 @@ void rt_hw_board_init(void)
9197
#ifdef RT_USING_SMP
9298
/* install IPI handle */
9399
rt_hw_ipi_handler_install(RT_SCHEDULE_IPI, rt_scheduler_ipi_handler);
100+
rt_hw_interrupt_install(1, xxx_isr, 0x123, "my_tets");
94101
#endif
95102
}
96103

bsp/qemu-vexpress-a9/drivers/secondary_cpu.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include <mmu.h>
2424
#endif
2525

26+
27+
2628
static void rt_hw_timer2_isr(int vector, void *param)
2729
{
2830
rt_tick_increase();
@@ -64,6 +66,15 @@ void rt_hw_secondary_cpu_bsp_start(void)
6466
timer_init(0, 10000);
6567
rt_hw_interrupt_install(IRQ_PBA8_TIMER0_1, rt_hw_timer2_isr, RT_NULL, "tick");
6668
rt_hw_interrupt_umask(IRQ_PBA8_TIMER0_1);
69+
70+
// rt_kprintf("rt_hw_secondary_cpu_bsp_start cpu_id=%d\n", rt_hw_cpu_id());
71+
72+
/* Send SGI 1 to CPU 0:
73+
* - filter_list = 0 (0b00): Use CPUTargetList to specify target CPUs
74+
* - target_list = 1 (bit 0 = 1): Send to CPU 0
75+
*/
76+
arm_gic_send_sgi(0, 1, 1, 0);
77+
6778
rt_system_scheduler_start();
6879
}
6980

bsp/qemu-vexpress-a9/qemu-nographic.bat

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,22 @@ if exist sd.bin goto run
33
qemu-img create -f raw sd.bin 64M
44

55
:run
6-
qemu-system-arm -M vexpress-a9 -kernel rtthread.elf -nographic -sd sd.bin
6+
if "%1"=="-d" goto debug
7+
qemu-system-arm ^
8+
-M vexpress-a9 ^
9+
-smp cpus=2 ^
10+
-kernel rtthread.bin ^
11+
-sd sd.bin ^
12+
-nographic
13+
goto end
14+
15+
:debug
16+
qemu-system-arm ^
17+
-M vexpress-a9 ^
18+
-smp cpus=2 ^
19+
-kernel rtthread.bin ^
20+
-sd sd.bin ^
21+
-nographic ^
22+
-S -s
23+
24+
:end

bsp/qemu-vexpress-a9/rtconfig.h

Lines changed: 5 additions & 203 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@
6262
/* end of rt_strnlen options */
6363
/* end of klibc options */
6464
#define RT_NAME_MAX 16
65-
#define RT_CPUS_NR 1
65+
#define RT_USING_SMP
66+
#define RT_CPUS_NR 2
6667
#define RT_ALIGN_SIZE 8
6768
#define RT_THREAD_PRIORITY_256
6869
#define RT_THREAD_PRIORITY_MAX 256
@@ -73,6 +74,7 @@
7374
#define RT_USING_IDLE_HOOK
7475
#define RT_IDLE_HOOK_LIST_SIZE 4
7576
#define IDLE_THREAD_STACK_SIZE 4096
77+
#define SYSTEM_THREAD_STACK_SIZE 4096
7678
#define RT_USING_TIMER_SOFT
7779
#define RT_TIMER_THREAD_PRIO 4
7880
#define RT_TIMER_THREAD_STACK_SIZE 4096
@@ -111,7 +113,7 @@
111113
#define RT_USING_CONSOLE
112114
#define RT_CONSOLEBUF_SIZE 256
113115
#define RT_CONSOLE_DEVICE_NAME "uart0"
114-
#define RT_VER_NUM 0x50201
116+
#define RT_VER_NUM 0x50300
115117
#define RT_BACKTRACE_LEVEL_MAX_NR 32
116118
/* end of RT-Thread Kernel */
117119
#define RT_USING_CACHE
@@ -204,6 +206,7 @@
204206
#define RT_MMCSD_THREAD_PRIORITY 22
205207
#define RT_MMCSD_MAX_PARTITION 16
206208
#define RT_USING_SPI
209+
#define RT_USING_SPI_ISR
207210
#define RT_USING_SPI_MSD
208211
#define RT_USING_SFUD
209212
#define RT_SFUD_USING_SFDP
@@ -297,207 +300,6 @@
297300

298301
/* end of RT-Thread Utestcases */
299302

300-
/* RT-Thread online packages */
301-
302-
/* IoT - internet of things */
303-
304-
305-
/* Wi-Fi */
306-
307-
/* Marvell WiFi */
308-
309-
/* end of Marvell WiFi */
310-
311-
/* Wiced WiFi */
312-
313-
/* end of Wiced WiFi */
314-
315-
/* CYW43012 WiFi */
316-
317-
/* end of CYW43012 WiFi */
318-
319-
/* BL808 WiFi */
320-
321-
/* end of BL808 WiFi */
322-
323-
/* CYW43439 WiFi */
324-
325-
/* end of CYW43439 WiFi */
326-
/* end of Wi-Fi */
327-
328-
/* IoT Cloud */
329-
330-
/* end of IoT Cloud */
331-
/* end of IoT - internet of things */
332-
333-
/* security packages */
334-
335-
/* end of security packages */
336-
337-
/* language packages */
338-
339-
/* JSON: JavaScript Object Notation, a lightweight data-interchange format */
340-
341-
/* end of JSON: JavaScript Object Notation, a lightweight data-interchange format */
342-
343-
/* XML: Extensible Markup Language */
344-
345-
/* end of XML: Extensible Markup Language */
346-
/* end of language packages */
347-
348-
/* multimedia packages */
349-
350-
/* LVGL: powerful and easy-to-use embedded GUI library */
351-
352-
/* end of LVGL: powerful and easy-to-use embedded GUI library */
353-
354-
/* u8g2: a monochrome graphic library */
355-
356-
/* end of u8g2: a monochrome graphic library */
357-
/* end of multimedia packages */
358-
359-
/* tools packages */
360-
361-
/* end of tools packages */
362-
363-
/* system packages */
364-
365-
/* enhanced kernel services */
366-
367-
/* end of enhanced kernel services */
368-
369-
/* acceleration: Assembly language or algorithmic acceleration packages */
370-
371-
/* end of acceleration: Assembly language or algorithmic acceleration packages */
372-
373-
/* CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */
374-
375-
/* end of CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */
376-
377-
/* Micrium: Micrium software products porting for RT-Thread */
378-
379-
/* end of Micrium: Micrium software products porting for RT-Thread */
380-
/* end of system packages */
381-
382-
/* peripheral libraries and drivers */
383-
384-
/* HAL & SDK Drivers */
385-
386-
/* STM32 HAL & SDK Drivers */
387-
388-
/* end of STM32 HAL & SDK Drivers */
389-
390-
/* Infineon HAL Packages */
391-
392-
/* end of Infineon HAL Packages */
393-
394-
/* Kendryte SDK */
395-
396-
/* end of Kendryte SDK */
397-
398-
/* WCH HAL & SDK Drivers */
399-
400-
/* end of WCH HAL & SDK Drivers */
401-
402-
/* AT32 HAL & SDK Drivers */
403-
404-
/* end of AT32 HAL & SDK Drivers */
405-
406-
/* HC32 DDL Drivers */
407-
408-
/* end of HC32 DDL Drivers */
409-
410-
/* NXP HAL & SDK Drivers */
411-
412-
/* end of NXP HAL & SDK Drivers */
413-
414-
/* NUVOTON Drivers */
415-
416-
/* end of NUVOTON Drivers */
417-
418-
/* GD32 Drivers */
419-
420-
/* end of GD32 Drivers */
421-
/* end of HAL & SDK Drivers */
422-
423-
/* sensors drivers */
424-
425-
/* end of sensors drivers */
426-
427-
/* touch drivers */
428-
429-
/* end of touch drivers */
430-
/* end of peripheral libraries and drivers */
431-
432-
/* AI packages */
433-
434-
/* end of AI packages */
435-
436-
/* Signal Processing and Control Algorithm Packages */
437-
438-
/* end of Signal Processing and Control Algorithm Packages */
439-
440-
/* miscellaneous packages */
441-
442-
/* project laboratory */
443-
444-
/* end of project laboratory */
445-
446-
/* samples: kernel and components samples */
447-
448-
/* end of samples: kernel and components samples */
449-
450-
/* entertainment: terminal games and other interesting software packages */
451-
452-
/* end of entertainment: terminal games and other interesting software packages */
453-
/* end of miscellaneous packages */
454-
455-
/* Arduino libraries */
456-
457-
458-
/* Projects and Demos */
459-
460-
/* end of Projects and Demos */
461-
462-
/* Sensors */
463-
464-
/* end of Sensors */
465-
466-
/* Display */
467-
468-
/* end of Display */
469-
470-
/* Timing */
471-
472-
/* end of Timing */
473-
474-
/* Data Processing */
475-
476-
/* end of Data Processing */
477-
478-
/* Data Storage */
479-
480-
/* Communication */
481-
482-
/* end of Communication */
483-
484-
/* Device Control */
485-
486-
/* end of Device Control */
487-
488-
/* Other */
489-
490-
/* end of Other */
491-
492-
/* Signal IO */
493-
494-
/* end of Signal IO */
495-
496-
/* Uncategorized */
497-
498-
/* end of Arduino libraries */
499-
/* end of RT-Thread online packages */
500-
501303
/* Hardware Drivers Config */
502304

503305
#define SOC_VEXPRESS_A9

0 commit comments

Comments
 (0)