Mistake on this page?
Report an issue in GitHub or email us
sch_int.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief Internal multi-protocol scheduler interface file.
6  *
7  * Copyright (c) 2013-2019 ARM Ltd. All Rights Reserved.
8  *
9  * Copyright (c) 2019 Packetcraft, Inc.
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23 /*************************************************************************************************/
24 
25 #ifndef SCH_INT_H
26 #define SCH_INT_H
27 
28 #include "sch_api.h"
29 #include "pal_bb.h"
30 #include "wsf_assert.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /**************************************************************************************************
37  Macros
38 **************************************************************************************************/
39 
40 /*! \brief Maximum span of scheduler elements. Half of the boundary time. */
41 #define SCH_MAX_SPAN ((BbGetBbTimerBoundaryUs() >> 1) + 1)
42 
43 /*! \brief Typical time needed for loading BOD. */
44 #define SCH_LOAD_DELAY_US 300
45 
46 /**************************************************************************************************
47  Constants
48 **************************************************************************************************/
49 
50 /*! \brief Scheduler states. */
51 typedef enum
52 {
53  SCH_STATE_IDLE, /*!< Scheduler idle. */
54  SCH_STATE_EXEC /*!< Scheduler executing BOD. */
55 } schState_t;
56 
57 /**************************************************************************************************
58  Data Types
59 **************************************************************************************************/
60 
61 /*! \brief Scheduler control block. */
62 typedef struct
63 {
64  schState_t state:8; /*!< Current scheduler state. */
65  uint8_t eventSetFlagCount; /*!< Scheduler event set count. */
66  wsfHandlerId_t handlerId; /*!< System event handler ID. */
67 
68  BbOpDesc_t *pHead; /*!< Head element of scheduled list of BOD. */
69  BbOpDesc_t *pTail; /*!< Tail element of scheduled list of BOD. */
70 
71  uint16_t schHandlerWatermarkUsec; /*!< Statistics: Handler duration watermark in microseconds. */
72  uint16_t delayLoadWatermarkCount; /*!< Statistics: Delay loading watermark count. */
73  uint16_t delayLoadCount; /*!< Statistics: Delay loading count. */
74  uint32_t delayLoadTotalCount; /*!< Statistics: Delay loading total count. */
75 } SchCtrlBlk_t;
76 
77 /**************************************************************************************************
78  Global Variables
79 **************************************************************************************************/
80 
81 extern SchCtrlBlk_t schCb;
82 
83 /**************************************************************************************************
84  Function Declarations
85 **************************************************************************************************/
86 
87 /* Load */
88 bool_t schTryCurTailLoadNext(void);
89 bool_t schTryLoadHead(void);
90 
91 /* List management */
92 void schRemoveHead(void);
93 
94 /*************************************************************************************************/
95 /*!
96  * \brief Is BOD due time in the future.
97  *
98  * \param pBod Target BOD.
99  *
100  * \return TRUE if BOD time is in the future, FALSE otherwise.
101  */
102 /*************************************************************************************************/
103 static inline bool_t schDueTimeInFuture(BbOpDesc_t *pBod)
104 {
105  const uint32_t curTime = PalBbGetCurrentTime();
106 
107  return (BbGetTargetTimeDelta(pBod->dueUsec, curTime) > 0);
108 }
109 
110 
111 /*************************************************************************************************/
112 /*!
113  * \brief Return the time between now and the BOD to be executed.
114  *
115  * \param pBod Target BOD.
116  *
117  * \return usec.
118  */
119 /*************************************************************************************************/
120 static inline uint32_t schGetTimeToExecBod(BbOpDesc_t *pBod)
121 {
122  uint32_t result = 0;
123 
124  const uint32_t curTime = PalBbGetCurrentTime();
125 
126  result = BbGetTargetTimeDelta(pBod->dueUsec, curTime);
127 
128  if (result >= SCH_LOAD_DELAY_US)
129  {
130  result -= SCH_LOAD_DELAY_US;
131  }
132  else
133  {
134  result = 0;
135  }
136 
137  return result;
138 }
139 
140 #ifdef __cplusplus
141 };
142 #endif
143 
144 #endif /* SCH_INT_H */
static bool_t schDueTimeInFuture(BbOpDesc_t *pBod)
Is BOD due time in the future.
Definition: sch_int.h:103
uint32_t PalBbGetCurrentTime(void)
Get the current BB clock value in microseconds.
uint32_t dueUsec
Definition: bb_api.h:154
static uint32_t schGetTimeToExecBod(BbOpDesc_t *pBod)
Return the time between now and the BOD to be executed.
Definition: sch_int.h:120
uint8_t eventSetFlagCount
Definition: sch_int.h:65
#define SCH_LOAD_DELAY_US
Typical time needed for loading BOD.
Definition: sch_int.h:44
uint32_t delayLoadTotalCount
Definition: sch_int.h:74
uint8_t wsfHandlerId_t
Event handler ID data type.
Definition: wsf_os.h:80
uint32_t BbGetTargetTimeDelta(uint32_t targetUsec, uint32_t refUsec)
Get Delta between target and reference time. Only valid if target time is in the future.
schState_t
Scheduler states.
Definition: sch_int.h:51
Assert macro.
uint16_t delayLoadCount
Definition: sch_int.h:73
Multi-protocol scheduler interface file.
Scheduler control block.
Definition: sch_int.h:62
uint16_t delayLoadWatermarkCount
Definition: sch_int.h:72
BbOpDesc_t * pHead
Definition: sch_int.h:68
Baseband operation descriptor (BOD).
Definition: bb_api.h:149
uint16_t schHandlerWatermarkUsec
Definition: sch_int.h:71
wsfHandlerId_t handlerId
Definition: sch_int.h:66
Baseband interface file.
BbOpDesc_t * pTail
Definition: sch_int.h:69
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.