• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Hunan OpenValley Digital Industry Development Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "los_context.h"
17 #include "los_arch_context.h"
18 #include "los_arch_interrupt.h"
19 #include "los_arch_regs.h"
20 #include "los_arch_timer.h"
21 #include "los_debug.h"
22 #include "los_interrupt.h"
23 #include "los_sched.h"
24 #include "los_task.h"
25 #include "los_timer.h"
26 #include "securec.h"
27 
28 UINT64 OsTickCount = 0;
29 
ArchInit(VOID)30 LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
31 {
32 }
33 
ArchSysTickLock()34 static VOID ArchSysTickLock()
35 {
36 }
37 
ArchSysTickUnlock()38 static VOID ArchSysTickUnlock()
39 {
40 }
41 
ArchSysExit(VOID)42 LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
43 {
44     PRINTK("ArchSysExit");
45     LOS_IntLock();
46     while (1) {
47         ;
48     }
49 }
50 
ArchTskStackInit(UINT32 taskID,UINT32 stackSize,VOID * topStack)51 LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
52 {
53     vPortStoreTaskSettings((void *)topStack, stackSize, taskID);
54     return (void *)pxPortInitialiseStack((uint8_t *)topStack + stackSize - 1,
55                                          ((void (*)(void *))OsTaskEntry), (void *)taskID, 0);
56 }
57 
ArchSignalContextInit(VOID * stackPointer,VOID * stackTop,UINTPTR sigHandler,UINT32 param)58 LITE_OS_SEC_TEXT_INIT VOID *ArchSignalContextInit(VOID *stackPointer, VOID *stackTop,
59                                                   UINTPTR sigHandler, UINT32 param)
60 {
61     (VOID) stackTop;
62     (VOID) sigHandler;
63     (VOID) param;
64     return (void *)stackPointer;
65 }
66 
xPortSysTickHandler(void)67 void xPortSysTickHandler(void)
68 {
69     OsTickCount++;
70     OsTickHandler();
71 }
72 
ArchTickStart(void * handler)73 static UINT32 ArchTickStart(void *handler)
74 {
75     OsTickCount = 0;
76     return LOS_OK;
77 }
78 
ArchGetTickCycle(UINT32 * period)79 static UINT64 ArchGetTickCycle(UINT32 *period)
80 {
81     return (UINT64)OsTickCount * (OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND);
82 }
83 
ArchStartSchedule(VOID)84 UINT32 ArchStartSchedule(VOID)
85 {
86     ArchIntLock();
87     OsSchedStart();
88     xPortStartScheduler();
89     return LOS_OK;
90 }
91 
ArchTaskSchedule(VOID)92 VOID ArchTaskSchedule(VOID)
93 {
94     if (OS_INT_ACTIVE) {
95         _frxt_setup_switch();
96         return;
97     }
98     vPortYield();
99     return;
100 }
101 
ArchSysTickReload(UINT64 nextResponseTime)102 static VOID ArchSysTickReload(UINT64 nextResponseTime)
103 {
104 }
105 
ArchEnterSleep(VOID)106 UINT32 ArchEnterSleep(VOID)
107 {
108     __asm__ volatile("dsync\n waiti 0"
109                      :
110                      :
111                      : "memory");
112     return LOS_OK;
113 }
114 
115 STATIC ArchTickTimer g_archTickTimer = {
116     .freq = OS_SYS_CLOCK,
117     .irqNum = OS_TICK_INT_NUM,
118     .init = ArchTickStart,
119     .getCycle = ArchGetTickCycle,
120     .reload = ArchSysTickReload,
121     .lock = ArchSysTickLock,
122     .unlock = ArchSysTickUnlock,
123     .tickHandler = NULL,
124 };
125 
ArchSysTickTimerGet(VOID)126 ArchTickTimer *ArchSysTickTimerGet(VOID)
127 {
128     return &g_archTickTimer;
129 }
130