FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
rt-thread/src/cpu_up.c at master · RT-Thread/rt-thread · GitHub
RT-Thread
/
rt-thread
Public
Notifications
You must be signed in to change notification settings
Fork
5.5k
Star
12.2k
Code
Issues
359
Pull requests
133
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
rt-thread
/
src
/
cpu_up.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
126 lines (116 loc) · 3.1 KB
Breadcrumbs
rt-thread
/
src
/
cpu_up.c
Copy path
File metadata and controls
126 lines (116 loc) · 3.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
* Copyright (c) 2006-2024, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2024-04-19 Shell Fixup UP irq spinlock
* 2024-05-22 Shell Add UP cpu object and
* maintain the rt_current_thread inside it
*/
#include
<rthw.h>
#include
<rtthread.h>
static
struct
rt_cpu
_cpu
;
/**
* @addtogroup group_thread_comm
*
* @cond
*
* @{
*/
/**
* @brief Initialize a static spinlock object.
*
* @param lock is a pointer to the spinlock to initialize.
*/
void
rt_spin_lock_init
(
struct
rt_spinlock
*
lock
)
{
RT_UNUSED
(
lock
);
}
/**
* @brief This function will lock the spinlock, will lock the thread scheduler.
*
* @note If the spinlock is locked, the current CPU will keep polling the spinlock state
* until the spinlock is unlocked.
*
* @param lock is a pointer to the spinlock.
*/
void
rt_spin_lock
(
struct
rt_spinlock
*
lock
)
{
rt_enter_critical
();
RT_SPIN_LOCK_DEBUG
(
lock
);
}
/**
* @brief This function will unlock the spinlock, will unlock the thread scheduler.
*
* @note If the scheduling function is called before unlocking, it will be scheduled in this function.
*
* @param lock is a pointer to the spinlock.
*/
void
rt_spin_unlock
(
struct
rt_spinlock
*
lock
)
{
rt_base_t
critical_level
;
RT_SPIN_UNLOCK_DEBUG
(
lock
,
critical_level
);
rt_exit_critical_safe
(
critical_level
);
}
/**
* @brief This function will disable the local interrupt and then lock the spinlock, will lock the thread scheduler.
*
* @note If the spinlock is locked, the current CPU will keep polling the spinlock state
* until the spinlock is unlocked.
*
* @param lock is a pointer to the spinlock.
*
* @return Return current cpu interrupt status.
*/
rt_base_t
rt_spin_lock_irqsave
(
struct
rt_spinlock
*
lock
)
{
rt_base_t
level
;
RT_UNUSED
(
lock
);
level
=
rt_hw_interrupt_disable
();
rt_enter_critical
();
RT_SPIN_LOCK_DEBUG
(
lock
);
return
level
;
}
/**
* @brief This function will unlock the spinlock and then restore current cpu interrupt status, will unlock the thread scheduler.
*
* @note If the scheduling function is called before unlocking, it will be scheduled in this function.
*
* @param lock is a pointer to the spinlock.
*
* @param level is interrupt status returned by rt_spin_lock_irqsave().
*/
void
rt_spin_unlock_irqrestore
(
struct
rt_spinlock
*
lock
,
rt_base_t
level
)
{
rt_base_t
critical_level
;
RT_SPIN_UNLOCK_DEBUG
(
lock
,
critical_level
);
rt_exit_critical_safe
(
critical_level
);
rt_hw_interrupt_enable
(
level
);
}
/**
* @brief This fucntion will return current cpu object.
*
* @return Return a pointer to the current cpu object.
*/
struct
rt_cpu
*
rt_cpu_self
(
void
)
{
return
&
_cpu
;
}
/**
* @brief This fucntion will return the cpu object corresponding to index.
*
* @param index is the index of target cpu object.
*
* @return Return a pointer to the cpu object corresponding to index.
*/
struct
rt_cpu
*
rt_cpu_index
(
int
index
)
{
return
index
==
0
?
&
_cpu
:
RT_NULL
;
}
/**
* @}
*
* @endcond
*/
Back
|
FazBrowse Home
|
New Git URL