luckfox-pico-sdk/sysdrv/source/mcu/rt-thread/libcpu/blackfin/bf53x/cpuport.c
luckfox-eng29 8f34c2760d project:build.sh: Added fastboot support; custom modifications to U-Boot and kernel implemented using patches.
project:cfg:BoardConfig_IPC: Added fastboot BoardConfig file and firmware post-scripts, distinguishing between
the BoardConfigs for Luckfox Pico Pro and Luckfox Pico Max. project:app: Added fastboot_client and rk_smart_door
for quick boot applications; updated rkipc app to adapt to the latest media library. media:samples: Added more
usage examples. media:rockit: Fixed bugs; removed support for retrieving data frames from VPSS. media:isp:
Updated rkaiq library and related tools to support connection to RKISP_Tuner. sysdrv:Makefile: Added support for
compiling drv_ko on Luckfox Pico Ultra W using Ubuntu; added support for custom root filesystem.
sysdrv:tools:board: Updated Buildroot optional mirror sources, updated some software versions, and stored device
tree files and configuration files that undergo multiple modifications for U-Boot and kernel separately.
sysdrv:source:mcu: Used RISC-V MCU SDK with RT-Thread system, mainly for initializing camera AE during quick
boot. sysdrv:source:uboot: Added support for fastboot; added high baud rate DDR bin for serial firmware upgrades.
sysdrv:source:kernel: Upgraded to version 5.10.160; increased NPU frequency for RV1106G3; added support for
fastboot.

Signed-off-by: luckfox-eng29 <eng29@luckfox.com>
2024-10-14 09:47:04 +08:00

94 lines
3.9 KiB
C

/*
* File : cpuport.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2012, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2012-02-13 mojingxian first version
*/
#include <rtthread.h>
/* flag in interrupt handling */
rt_uint32_t rt_interrupt_from_thread;
rt_uint32_t rt_interrupt_to_thread;
rt_uint32_t rt_thread_switch_interrupt_flag;
/**
* initializes stack of thread
*/
rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
rt_uint8_t *stack_addr, void *texit)
{
unsigned char i;
unsigned long *stk;
stk = (unsigned long *)stack_addr; /* Load stack pointer */
/* Simulate a function call to the task with an argument */
stk -= 3; /* 3 words assigned for incoming args (R0, R1, R2) */
/* Now simulating vectoring to an ISR */
*--stk = (unsigned long)parameter; /* R0 value - caller's incoming argument #1 */
*--stk = (unsigned long)0; /* P1 value - value irrelevant */
*--stk = (unsigned long)texit; /* RETS value - NO task should return with RTS. */
/* however OS_CPU_Invalid_Task_Return is a safety */
/* catch-allfor tasks that return with an RTS */
*--stk = (unsigned long)parameter; /* R1 value - caller's incoming argument #2 */
/* (not relevant in current test example) */
*--stk = (unsigned long)parameter; /* R2 value - caller's incoming argument #3 */
/* (not relevant in current test example) */
*--stk = (unsigned long)0; /* P0 value - value irrelevant */
*--stk = (unsigned long)0; /* P2 value - value irrelevant */
*--stk = (unsigned long)0; /* ASTAT value - caller's ASTAT value - value */
/* irrelevant */
*--stk = (unsigned long)tentry; /* RETI value- pushing the start address of the task */
for (i = 0; i < 35; i++) /* remaining reg values - R7:3, P5:3, */
{ /* 4 words of A1:0(.W,.X), LT0, LT1, */
*--stk = (unsigned long)0; /* LC0, LC1, LB0, LB1,I3:0, M3:0, L3:0, B3:0, */
} /* All values irrelevant */
return (rt_uint8_t *)stk; /* Return top-of-stack */
}
void rt_hw_context_switch(rt_uint32_t from, rt_uint32_t to)
{
if (rt_thread_switch_interrupt_flag != 1)
{
rt_thread_switch_interrupt_flag = 1;
rt_interrupt_from_thread = from;
}
rt_interrupt_to_thread = to;
asm("raise 14;"); // Raise Interrupt 14 (trap)
}
void rt_hw_context_switch_interrupt(rt_uint32_t from, rt_uint32_t to)
{
if (rt_thread_switch_interrupt_flag != 1)
{
rt_thread_switch_interrupt_flag = 1;
rt_interrupt_from_thread = from;
}
rt_interrupt_to_thread = to;
asm("raise 14;"); // Raise Interrupt 14 (trap)
}
void rt_hw_context_switch_to(rt_uint32_t to)
{
rt_thread_switch_interrupt_flag = 1;
rt_interrupt_from_thread = 0;
rt_interrupt_to_thread = to;
asm("raise 14;"); // Raise Interrupt 14 (trap)
}