Initial commit: TXW82x FPV v2.7.0.7-42229 SDK + project sources
This commit is contained in:
64
csky/csi_kernel/rhino/arch/riscv/e906/port_c.c
Normal file
64
csky/csi_kernel/rhino/arch/riscv/e906/port_c.c
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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>
|
||||
|
||||
void *cpu_task_stack_init(cpu_stack_t *stack_base, size_t stack_size,
|
||||
void *arg, task_entry_t entry)
|
||||
{
|
||||
cpu_stack_t *stk;
|
||||
register int *gp asm("x3");
|
||||
uint32_t temp = (uint32_t)(stack_base + stack_size);
|
||||
|
||||
temp &= 0xFFFFFFF8UL;
|
||||
|
||||
stk = (cpu_stack_t *)temp;
|
||||
|
||||
*(--stk) = (uint32_t)entry; /* PC */
|
||||
*(--stk) = (uint32_t)0x31313131L; /* X31 */
|
||||
*(--stk) = (uint32_t)0x30303030L; /* X30 */
|
||||
*(--stk) = (uint32_t)0x29292929L; /* X29 */
|
||||
*(--stk) = (uint32_t)0x28282828L; /* X28 */
|
||||
*(--stk) = (uint32_t)0x27272727L; /* X27 */
|
||||
*(--stk) = (uint32_t)0x26262626L; /* X26 */
|
||||
*(--stk) = (uint32_t)0x25252525L; /* X25 */
|
||||
*(--stk) = (uint32_t)0x24242424L; /* X24 */
|
||||
*(--stk) = (uint32_t)0x23232323L; /* X23 */
|
||||
*(--stk) = (uint32_t)0x22222222L; /* X22 */
|
||||
*(--stk) = (uint32_t)0x21212121L; /* X21 */
|
||||
*(--stk) = (uint32_t)0x20202020L; /* X20 */
|
||||
*(--stk) = (uint32_t)0x19191919L; /* X19 */
|
||||
*(--stk) = (uint32_t)0x18181818L; /* X18 */
|
||||
*(--stk) = (uint32_t)0x17171717L; /* X17 */
|
||||
*(--stk) = (uint32_t)0x16161616L; /* X16 */
|
||||
*(--stk) = (uint32_t)0x15151515L; /* X15 */
|
||||
*(--stk) = (uint32_t)0x14141414L; /* X14 */
|
||||
*(--stk) = (uint32_t)0x13131313L; /* X13 */
|
||||
*(--stk) = (uint32_t)0x12121212L; /* X12 */
|
||||
*(--stk) = (uint32_t)0x11111111L; /* X11 */
|
||||
*(--stk) = (uint32_t)arg; /* X10 */
|
||||
*(--stk) = (uint32_t)0x09090909L; /* X9 */
|
||||
*(--stk) = (uint32_t)0x08080808L; /* X8 */
|
||||
*(--stk) = (uint32_t)0x07070707L; /* X7 */
|
||||
*(--stk) = (uint32_t)0x06060606L; /* X6 */
|
||||
*(--stk) = (uint32_t)0x05050505L; /* X5 */
|
||||
*(--stk) = (uint32_t)0x04040404L; /* X4 */
|
||||
*(--stk) = (uint32_t)gp; /* X3 */
|
||||
*(--stk) = (uint32_t)krhino_task_deathbed; /* X1 */
|
||||
|
||||
return stk;
|
||||
}
|
||||
|
||||
172
csky/csi_kernel/rhino/arch/riscv/e906/port_s.S
Normal file
172
csky/csi_kernel/rhino/arch/riscv/e906/port_s.S
Normal file
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Enable interrupts when returning from the handler */
|
||||
#define MSTATUS_PRV1 0x1880
|
||||
|
||||
/******************************************************************************
|
||||
* Functions:
|
||||
* size_t cpu_intrpt_save(void);
|
||||
* void cpu_intrpt_restore(size_t psr);
|
||||
******************************************************************************/
|
||||
|
||||
.global cpu_intrpt_save
|
||||
.type cpu_intrpt_save, %function
|
||||
cpu_intrpt_save:
|
||||
csrr a0, mstatus
|
||||
csrc mstatus, 8
|
||||
ret
|
||||
|
||||
.global cpu_intrpt_restore
|
||||
.type cpu_intrpt_restore, %function
|
||||
cpu_intrpt_restore:
|
||||
csrw mstatus, a0
|
||||
ret
|
||||
|
||||
/******************************************************************************
|
||||
* Functions:
|
||||
* void cpu_intrpt_switch(void);
|
||||
* void cpu_task_switch(void);
|
||||
******************************************************************************/
|
||||
|
||||
.global cpu_task_switch
|
||||
.type cpu_task_switch, %function
|
||||
cpu_task_switch:
|
||||
li t0, 0xE080100C
|
||||
lb t1, (t0)
|
||||
li t2, 0x01
|
||||
or t1, t1, t2
|
||||
sb t1, (t0)
|
||||
|
||||
ret
|
||||
|
||||
.global cpu_intrpt_switch
|
||||
.type cpu_intrpt_switch, %function
|
||||
cpu_intrpt_switch:
|
||||
li t0, 0xE080100C
|
||||
lb t1, (t0)
|
||||
li t2, 0x01
|
||||
or t1, t1, t2
|
||||
sb t1, (t0)
|
||||
|
||||
ret
|
||||
|
||||
/******************************************************************************
|
||||
* Functions:
|
||||
* void cpu_first_task_start(void);
|
||||
******************************************************************************/
|
||||
.global cpu_first_task_start
|
||||
.type cpu_first_task_start, %function
|
||||
cpu_first_task_start:
|
||||
j __task_switch_nosave
|
||||
|
||||
/******************************************************************************
|
||||
* Functions:
|
||||
* void tspend_handler(void);
|
||||
******************************************************************************/
|
||||
|
||||
.global tspend_handler
|
||||
.type tspend_handler, %function
|
||||
tspend_handler:
|
||||
csrrw sp, mscratch, sp
|
||||
addi sp, sp, -124
|
||||
|
||||
sw x1, 0(sp)
|
||||
sw x3, 4(sp)
|
||||
sw x4, 8(sp)
|
||||
sw x5, 12(sp)
|
||||
sw x6, 16(sp)
|
||||
sw x7, 20(sp)
|
||||
sw x8, 24(sp)
|
||||
sw x9, 28(sp)
|
||||
sw x10, 32(sp)
|
||||
sw x11, 36(sp)
|
||||
sw x12, 40(sp)
|
||||
sw x13, 44(sp)
|
||||
sw x14, 48(sp)
|
||||
sw x15, 52(sp)
|
||||
sw x16, 56(sp)
|
||||
sw x17, 60(sp)
|
||||
sw x18, 64(sp)
|
||||
sw x19, 68(sp)
|
||||
sw x20, 72(sp)
|
||||
sw x21, 76(sp)
|
||||
sw x22, 80(sp)
|
||||
sw x23, 84(sp)
|
||||
sw x24, 88(sp)
|
||||
sw x25, 92(sp)
|
||||
sw x26, 96(sp)
|
||||
sw x27, 100(sp)
|
||||
sw x28, 104(sp)
|
||||
sw x29, 108(sp)
|
||||
sw x30, 112(sp)
|
||||
sw x31, 116(sp)
|
||||
csrr t0, mepc
|
||||
sw t0, 120(sp)
|
||||
|
||||
la a1, g_active_task
|
||||
lw a1, (a1)
|
||||
sw sp, (a1)
|
||||
|
||||
__task_switch_nosave:
|
||||
la a0, g_preferred_ready_task
|
||||
la a1, g_active_task
|
||||
lw a2, (a0)
|
||||
sw a2, (a1)
|
||||
|
||||
lw sp, (a2)
|
||||
|
||||
/* Run in machine mode */
|
||||
li t0, MSTATUS_PRV1
|
||||
csrs mstatus, t0
|
||||
|
||||
lw t0, 120(sp)
|
||||
csrw mepc, t0
|
||||
|
||||
lw x1, 0(sp)
|
||||
lw x3, 4(sp)
|
||||
lw x4, 8(sp)
|
||||
lw x5, 12(sp)
|
||||
lw x6, 16(sp)
|
||||
lw x7, 20(sp)
|
||||
lw x8, 24(sp)
|
||||
lw x9, 28(sp)
|
||||
lw x10, 32(sp)
|
||||
lw x11, 36(sp)
|
||||
lw x12, 40(sp)
|
||||
lw x13, 44(sp)
|
||||
lw x14, 48(sp)
|
||||
lw x15, 52(sp)
|
||||
lw x16, 56(sp)
|
||||
lw x17, 60(sp)
|
||||
lw x18, 64(sp)
|
||||
lw x19, 68(sp)
|
||||
lw x20, 72(sp)
|
||||
lw x21, 76(sp)
|
||||
lw x22, 80(sp)
|
||||
lw x23, 84(sp)
|
||||
lw x24, 88(sp)
|
||||
lw x25, 92(sp)
|
||||
lw x26, 96(sp)
|
||||
lw x27, 100(sp)
|
||||
lw x28, 104(sp)
|
||||
lw x29, 108(sp)
|
||||
lw x30, 112(sp)
|
||||
lw x31, 116(sp)
|
||||
|
||||
addi sp, sp, 124
|
||||
csrrw sp, mscratch, sp
|
||||
mret
|
||||
Reference in New Issue
Block a user