Initial commit: TXW82x FPV v2.7.0.7-42229 SDK + project sources
This commit is contained in:
66
csky/csi_kernel/rhino/arch/csky/e804d/port_c.c
Normal file
66
csky/csi_kernel/rhino/arch/csky/e804d/port_c.c
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2016 YunOS Project. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <k_api.h>
|
||||
#include <core_804.h>
|
||||
|
||||
void *cpu_task_stack_init(cpu_stack_t *stack_base, size_t stack_size,
|
||||
void *arg, task_entry_t entry)
|
||||
{
|
||||
cpu_stack_t *stk;
|
||||
uint32_t temp = (uint32_t)(stack_base + stack_size);
|
||||
|
||||
temp &= 0xFFFFFFFCUL;
|
||||
|
||||
stk = (cpu_stack_t *)temp;
|
||||
|
||||
*(--stk) = (uint32_t)entry; /* entry point */
|
||||
*(--stk) = (uint32_t)0x80000340L; /* PSR */
|
||||
*(--stk) = (uint32_t)0x31313131L; /* R31 */
|
||||
*(--stk) = (uint32_t)0x30303030L; /* R30 */
|
||||
*(--stk) = (uint32_t)0x29292929L; /* R29 */
|
||||
*(--stk) = (uint32_t)0x28282828L; /* R28 */
|
||||
*(--stk) = (uint32_t)0x27272727L; /* R27 */
|
||||
*(--stk) = (uint32_t)0x26262626L; /* R26 */
|
||||
*(--stk) = (uint32_t)0x25252525L; /* R25 */
|
||||
*(--stk) = (uint32_t)0x24242424L; /* R24 */
|
||||
*(--stk) = (uint32_t)0x23232323L; /* R23 */
|
||||
*(--stk) = (uint32_t)0x22222222L; /* R22 */
|
||||
*(--stk) = (uint32_t)0x21212121L; /* R21 */
|
||||
*(--stk) = (uint32_t)0x20202020L; /* R20 */
|
||||
*(--stk) = (uint32_t)0x19191919L; /* R19 */
|
||||
*(--stk) = (uint32_t)0x18181818L; /* R18 */
|
||||
*(--stk) = (uint32_t)0x17171717L; /* R17 */
|
||||
*(--stk) = (uint32_t)0x16161616L; /* R16 */
|
||||
*(--stk) = (uint32_t)krhino_task_deathbed; /* R15 (LR) */
|
||||
*(--stk) = (uint32_t)0x13131313L; /* R13 */
|
||||
*(--stk) = (uint32_t)0x12121212L; /* R12 */
|
||||
*(--stk) = (uint32_t)0x11111111L; /* R11 */
|
||||
*(--stk) = (uint32_t)0x10101010L; /* R10 */
|
||||
*(--stk) = (uint32_t)0x09090909L; /* R9 */
|
||||
*(--stk) = (uint32_t)0x00000000L; /* R8 */
|
||||
*(--stk) = (uint32_t)0x07070707L; /* R7 */
|
||||
*(--stk) = (uint32_t)0x06060606L; /* R6 */
|
||||
*(--stk) = (uint32_t)0x05050505L; /* R5 */
|
||||
*(--stk) = (uint32_t)0x04040404L; /* R4 */
|
||||
*(--stk) = (uint32_t)0x03030303L; /* R3 */
|
||||
*(--stk) = (uint32_t)0x02020202L; /* R2 */
|
||||
*(--stk) = (uint32_t)0x01010101L; /* R1 */
|
||||
*(--stk) = (uint32_t)arg; /* R0 : argument */
|
||||
|
||||
return stk;
|
||||
}
|
||||
|
||||
153
csky/csi_kernel/rhino/arch/csky/e804d/port_s.S
Normal file
153
csky/csi_kernel/rhino/arch/csky/e804d/port_s.S
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright (C) 2016 YunOS Project. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <k_config.h>
|
||||
|
||||
#define VIC_TSPDR 0XE000EC08
|
||||
|
||||
.extern g_active_task
|
||||
.extern g_preferred_ready_task
|
||||
.extern krhino_task_sched_stats_get
|
||||
.extern krhino_stack_ovf_check
|
||||
/******************************************************************************
|
||||
* EXPORT FUNCTIONS
|
||||
******************************************************************************/
|
||||
|
||||
.global cpu_intrpt_save
|
||||
.global cpu_intrpt_restore
|
||||
.global cpu_task_switch
|
||||
.global cpu_intrpt_switch
|
||||
.global cpu_first_task_start
|
||||
.global tspend_handler
|
||||
|
||||
/******************************************************************************
|
||||
* EQUATES
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* CODE GENERATION DIRECTIVES
|
||||
******************************************************************************/
|
||||
|
||||
.text
|
||||
.align 2
|
||||
|
||||
/******************************************************************************
|
||||
* Functions:
|
||||
* size_t cpu_intrpt_save(void);
|
||||
* void cpu_intrpt_restore(size_t psr);
|
||||
******************************************************************************/
|
||||
|
||||
.type cpu_intrpt_save, %function
|
||||
cpu_intrpt_save:
|
||||
mfcr r0, psr
|
||||
psrclr ie
|
||||
rts
|
||||
|
||||
.type cpu_intrpt_restore, %function
|
||||
cpu_intrpt_restore:
|
||||
mtcr r0, psr
|
||||
rts
|
||||
|
||||
/******************************************************************************
|
||||
* Functions:
|
||||
* void cpu_intrpt_switch(void);
|
||||
* void cpu_task_switch(void);
|
||||
******************************************************************************/
|
||||
|
||||
.type cpu_task_switch, %function
|
||||
cpu_task_switch:
|
||||
lrw r0, VIC_TSPDR
|
||||
bgeni r1, 0
|
||||
stw r1, (r0)
|
||||
rts
|
||||
|
||||
.type cpu_intrpt_switch, %function
|
||||
cpu_intrpt_switch:
|
||||
lrw r0, VIC_TSPDR
|
||||
bgeni r1, 0
|
||||
stw r1, (r0)
|
||||
rts
|
||||
|
||||
/******************************************************************************
|
||||
* Functions:
|
||||
* void cpu_first_task_start(void);
|
||||
******************************************************************************/
|
||||
|
||||
.type cpu_first_task_start, %function
|
||||
cpu_first_task_start:
|
||||
psrclr ie
|
||||
jbr __tspend_handler_nosave
|
||||
|
||||
/******************************************************************************
|
||||
* Functions:
|
||||
* void __task_switch(void);
|
||||
******************************************************************************/
|
||||
|
||||
.type tspend_handler, %function
|
||||
tspend_handler:
|
||||
subi sp, 132
|
||||
stm r0-r13, (sp)
|
||||
stw r15, (sp, 56)
|
||||
addi r0, sp, 60
|
||||
stm r16-r31, (r0)
|
||||
mfcr r1, epsr
|
||||
stw r1, (r0, 64)
|
||||
mfcr r1, epc
|
||||
stw r1, (r0, 68)
|
||||
|
||||
lrw r2, g_active_task
|
||||
ldw r2, (r2)
|
||||
stw sp, (r2)
|
||||
|
||||
#if (RHINO_CONFIG_TASK_STACK_OVF_CHECK > 0)
|
||||
jbsr krhino_stack_ovf_check
|
||||
#endif
|
||||
|
||||
#if (RHINO_CONFIG_TASK_SCHED_STATS > 0)
|
||||
jbsr krhino_task_sched_stats_get
|
||||
#endif
|
||||
|
||||
__tspend_handler_nosave:
|
||||
lrw r4, g_active_task
|
||||
lrw r5, g_preferred_ready_task
|
||||
ldw r6, (r5)
|
||||
stw r6, (r4)
|
||||
|
||||
#ifdef CONFIG_STACK_GUARD
|
||||
jbsr csky_set_stackbound
|
||||
#endif
|
||||
|
||||
ldw sp, (r6)
|
||||
|
||||
#ifdef CONFIG_STACK_GUARD
|
||||
mfcr r3, cr<0, 4>
|
||||
bseti r3, 0
|
||||
bseti r3, 1
|
||||
mtcr r3, cr<0, 4>
|
||||
#endif
|
||||
|
||||
ldw r0, (sp, 128)
|
||||
mtcr r0, epc
|
||||
ldw r0, (sp, 124)
|
||||
mtcr r0, epsr
|
||||
|
||||
ldm r0-r13, (sp)
|
||||
ldw r15, (sp, 56)
|
||||
addi sp, 60
|
||||
ldm r16-r31, (sp)
|
||||
addi sp, 72
|
||||
|
||||
rte
|
||||
Reference in New Issue
Block a user