Commit Graph

413 Commits

Author SHA1 Message Date
hujun5 f12996c851 sched: replace sync pause with async pause for nxsig_process
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-07 13:32:57 +08:00
hujun5 f132ed2edb signal: adjust the signal processing logic to remove the judgment
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-07 13:32:57 +08:00
hujun5 7eea4223ee arch: move sigdeliver to common code
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-07 13:32:57 +08:00
buxiasen a569eef6ba arch: cpu pause when sigaction only necessary if tcb running
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-07 13:32:57 +08:00
hujun5 eae57cb0e6 sched: replace sync pause with async pause for nxtask_terminate
reason:
In the kernel, we are planning to remove all occurrences of up_cpu_pause as one of the steps to
simplify the implementation of critical sections. The goal is to enable spin_lock_irqsave to encapsulate critical sections,
thereby facilitating the replacement of critical sections(big lock) with smaller spin_lock_irqsave(small lock)

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-06 09:26:56 +08:00
Ville Juven 30aa947b95 arm64_fpu: Remove fpu_regs from the TCB
Since FPU is now always saved into the current process stack location
upon exception entry, there is no need to keep fpu_regs (or saved_fpu_regs)
in the TCB.
2024-10-03 09:08:26 +08:00
Jouni Ukkonen 9ea098558a arch/arm64/src/imx9/imx9_usbdev.c: Clean up cache operations, add DEBUGASSERTS
Correct some of the cache operations:

- EP0 request length was handled incorrectly
- Received data cache invalidate was exceeding the received buffer
- writedtd is also called with no data (EP0 ACK/NACK). Don't touch cache in that case.

Fix trip wire handling to conform with the IMX93 reference manual

Also add DEBUGASSERTS for future to check the validity of pointers and sizes

Co-authored-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-10-03 08:55:13 +08:00
W-M-R eb2f661170 make/kasan: Added cmake toolchain compilation options about kasan for arm64 architecture
Signed-off-by: W-M-R <Mike_0528@163.com>
2024-10-02 21:09:31 +08:00
Ville Juven 24c931c220 arm64_task/pthread_start: Set sp_el0 upon starting user process
As the handling of sp_el0 was moved from the context switch routine
to exception entry/exit, we must set sp_el0 explicitly when the user
process is first started.
2024-10-02 14:09:22 +08:00
lipengfei28 8e200e69d4 Kernel build: enter exception save sp_sl0,exit exception restroe sp_el0
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2024-10-02 14:09:22 +08:00
ligd c3da7c29e8 arm64: simply the vectors
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-02 14:09:22 +08:00
ligd 007399dd75 arm64: save FPU regs every time
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-02 14:09:22 +08:00
cuiziwei 394a967263 nuttx/arch: Remove GCCVER and add compilation options directly.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-10-01 20:41:02 +08:00
hujun5 c039ea77ba arm64: fix use arch-timer in SMP
reason:
only one timer will be effective at a time.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-01 12:10:06 +08:00
hujun5 ea29217442 arm64: fix tickless mode in SMP
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-01 12:10:06 +08:00
xuxingliang 060ac93f82 arm64: allow to use custom up_timer_initialize
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-10-01 12:10:06 +08:00
guoshichao ff4ad07576 greenhills: add cmake support
1. refactor the ghs/gcc/clang/armclang toolchain management in CMake
2. unify the cmake toolchain naming style
3. support greenhills build procedure with CMake
4. add protect build for greenhills and gnu toolchain with CMake

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2024-10-01 11:48:09 +08:00
buxiasen b0e8193b7a qemu/arm64: add pm support
add arm64 qemu pm compatible for demo pm_idle in not smp & smp usage
demo, chip should based on demo to add more operation in pm_idle_handler

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-09-30 20:23:11 +08:00
Jukka Laitinen 429252152a arch/arm64/src/common/arm64_arch_timer.c: Remove clock drift from tick timer
This fixes two issues with the tick timer
1) Each tick was longer than the requested period. This is because setting
   the compare register was done by first reading the current time, and only
   after that setting the compare register. In addition, when handling the
   timer interrupts in arch_alarm.c / oneshot_callback, the current_tick is
   first read, all the tick handling is done and only after that the next tick
   is started. The whole tick processing time was added to the total tick time.

2) When the compare time is not aligned with tick period, and is drifting,
   eventually any call to ONESHOT_TICK_CURRENT would either return the current
   tick, or the next one, depending on the rounding of division by the
   cycle_per_tick. This again leads to oneshot_callback randomly handling
   two ticks at a time, which breaks all wdog based timers, causing them to
   randomly timeout too early.

The issues are fixed as follows:

Align the compare time register to be evenly divisible by cycle_per_tick.
This will lead arm64_tick_current always to return the currently ongoing tick,
fixing 2). Also calculating the next tick's start from the aligned current
count will fix 1), as there is no time drift in the start cycle.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-09-30 19:23:01 +08:00
yezhonghui 85591fc360 pci alloc mis irq support new interface
Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2024-09-30 15:41:28 +08:00
lipengfei28 6e746ed364 arm64 fork: FORK_REG_LR,FORK_REG_SP should save the func local stack
not the last func stack

Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2024-09-29 13:48:24 +08:00
hujun5 d4707646d5 arch: We can use an independent SIG interrupt to handle async pause,
which can save processing time.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-29 08:54:51 +08:00
hujun5 9de9f8168d sched: change the SMP scheduling policy from synchronous to asynchronous
reason:
Currently, if we need to schedule a task to another CPU, we have to completely halt the other CPU,
manipulate the scheduling linked list, and then resume the operation of that CPU. This process is both time-consuming and unnecessary.

During this process, both the current CPU and the target CPU are inevitably subjected to busyloop.

The improved strategy is to simply send a cross-core interrupt to the target CPU.
The current CPU continues to run while the target CPU responds to the interrupt, eliminating the certainty of a busyloop occurring.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-29 08:54:51 +08:00
hujun5 ba5091d2f7 arm64: remove the operation of clearing interrupts during GIC initialization
To align with the implementation of ARMv7-A, remove the operation of clearing
interrupts during GIC initialization to avoid losing interrupts during asynchronous startup.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-29 00:01:44 +08:00
hujun5 8f1a1006ec arm64:add busy wait flag
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-29 00:01:44 +08:00
hujun5 5e2eadacf7 arm64/smp: changing the startup of arm64 SMP from serial to parallel
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-29 00:01:44 +08:00
hujun5 4c69bb8cc7 arch: inline up_switch_context,in arm arm64
reason:
when a context switch occurs, up_switch_context is executed.
In order to reduce the time taken for context switching,
we inline the up_switch_context function.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-28 19:08:15 +08:00
yezhonghui f81c844685 arm64 support gicv2m for pci irq
Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2024-09-28 16:09:11 +08:00
lipengfei28 30be81add6 arm64 pci legacy irq do not support yet
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2024-09-28 13:34:33 +08:00
ligd 35c8c80a00 arch: change nxsched_suspend/resume_scheduler() called position
for the citimon stats:

thread 0:                     thread 1:
enter_critical (t0)
up_switch_context
note suspend thread0 (t1)

                              thread running
                              IRQ happen, in ISR:
                                post thread0
                                up_switch_context
                                note resume thread0 (t2)
                                ISR continue f1
                                ISR continue f2
                                ...
                                ISR continue fn

leave_critical (t3)

You will see, the thread 0, critical_section time is:
(t1 - t0) + (t3 - t2)

BUT, this result contains f1 f2 .. fn time spent, it is wrong
to tell user thead0 hold the critical lots of time but actually
not belong to it.

Resolve:
change the nxsched_suspend/resume_scheduler to real hanppends

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-27 09:53:33 +08:00
qinwei1 8ae35754e5 arm64: add arm64_current_el to obtain current EL
Summary
  Add a macro to obtain current execute level

Signed-off-by: qinwei1 <qinwei1@xiaomi.com>
2024-09-27 00:16:41 +08:00
qinwei1 c535fb1438 arm64: refine the fatal handler
Summary
  The original implement for exception handler is very simple and
haven't framework for breakpoint/watchpoint routine or brk instruction.
  I refine the fatal handler and add framework for debug handler to
register or unregister. this is a prepare for watchpoint/breakpoint
implement

Signed-off-by: qinwei1 <qinwei1@xiaomi.com>
2024-09-27 00:16:41 +08:00
ligd 551e6ce3ab compile: add DEBUG_SYMBOLS_LEVEL allow custom the level
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-27 00:13:07 +08:00
anjiahao c76e83beaa Debug option:change -g to -g3, add macro information to elf
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-09-27 00:13:07 +08:00
ouyangxiangzhen f3973c7e46 imx8qm-mek: Fix early print
Function `arm64_lowputc` corrupted the x1 register which is used in function `boot_stage_puts`.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2024-09-27 00:09:50 +08:00
chao an 542e2ba625 CMake/preprocess: fix typo PREPROCES -> PREPROCESS
correct the marco define from PREPROCES to PREPROCESS

Signed-off-by: chao an <anchao@lixiang.com>
2024-09-25 11:55:06 +08:00
hujun5 b0f8b6e2ca arm64: g_current_regs is only used to determine if we are in irq,
with other functionalities removed.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-25 08:58:20 +08:00
hujun5 c9bdb598b7 irq: use up_interrupt_context to replace up_current_regs
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-25 08:58:20 +08:00
Xiang Xiao dc6eeba453 Revert "arm64: refine the fatal handler"
This reverts commit 291d5a2acc.
2024-09-24 10:21:42 -03:00
Xiang Xiao 9e8df3b3fa Revert "arm64: save FPU regs every time"
This reverts commit 3c4f3c1008.
2024-09-24 10:21:42 -03:00
Xiang Xiao f6f072ee1c Revert "arm64: add arm64_current_el to obtain current EL"
This reverts commit e38f2b2a6d.
2024-09-24 10:21:42 -03:00
Xiang Xiao 0a2a6dfa57 Revert "arm64: simply the vectors"
This reverts commit 370679c65b.
2024-09-24 10:21:42 -03:00
Xiang Xiao 24fba43591 Revert "Kernel build: enter exception save sp_sl0,exit exception restroe sp_el0"
This reverts commit 52a4fb6fab.
2024-09-24 10:21:42 -03:00
lipengfei28 52a4fb6fab Kernel build: enter exception save sp_sl0,exit exception restroe sp_el0
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2024-09-23 23:43:24 +08:00
ligd 370679c65b arm64: simply the vectors
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-23 23:43:24 +08:00
qinwei1 e38f2b2a6d arm64: add arm64_current_el to obtain current EL
Summary
  Add a macro to obtain current execute level

Signed-off-by: qinwei1 <qinwei1@xiaomi.com>
2024-09-23 23:43:24 +08:00
ligd 3c4f3c1008 arm64: save FPU regs every time
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-23 23:43:24 +08:00
qinwei1 291d5a2acc arm64: refine the fatal handler
Summary
  The original implement for exception handler is very simple and
haven't framework for breakpoint/watchpoint routine or brk instruction.
  I refine the fatal handler and add framework for debug handler to
register or unregister. this is a prepare for watchpoint/breakpoint
implement

Signed-off-by: qinwei1 <qinwei1@xiaomi.com>
2024-09-23 23:43:24 +08:00
Ville Juven 10b40abecc arm64_task/pthread_start: Convert the C / inline ASM code to assembly
The aforementioned functions can/will fail if the C compiler decides
to use the stack for the incoming entrypt/etc. parameters.

Fix this issue by converting the jump to user part into pure assembly,
ensuring the stack is NOT used for the parameters.
2024-09-21 23:24:02 +08:00
Ville Juven 6e15994f4c arm64_addrenv: Add support for 4 level MMU translations
The original code made the incorrect assumption that the amount of
translation levels is 3, but this is incorrect. The amount of levels is 4
and the amount of levels that are utilized / in use is set dynamically
from the amount of VA bits in use.
2024-09-21 08:36:23 -03:00