SYS/BIOS  7.00
Swi.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020, Texas Instruments Incorporated - https://www.ti.com
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
269 /*
270  * ======== Swi.h ========
271  */
272 
273 #ifndef ti_sysbios_knl_Swi__include
274 #define ti_sysbios_knl_Swi__include
275 
276 /* BIOS 6.x compatibility, use -Dxdc_std__include to disable */
278 #include <xdc/std.h>
281 #include <stdbool.h>
282 #include <stddef.h>
283 #include <stdint.h>
284 
285 #include <ti/sysbios/knl/Queue.h>
287 
288 /* @cond NODOC */
289 #define ti_sysbios_knl_Swi_long_names
290 #include "Swi_defs.h"
293 #ifdef __cplusplus
294 extern "C" {
295 #endif
296 
301 #define Swi_A_swiDisabled "cannot create a SWI when Swi is disabled"
302 
308 #define Swi_A_badPriority "invalid priority"
309 
310 typedef struct Swi_Struct Swi_Struct;
311 typedef struct Swi_Struct Swi_Object;
314 
323 typedef struct Swi_HookSet Swi_HookSet;
324 
325 typedef struct Swi_Params Swi_Params;
326 
328 typedef struct Swi_Module_State Swi_Module_State;
329 typedef Queue_Object Swi_Module_State__readyQ;
338 typedef void (*Swi_FuncPtr)(uintptr_t arg1, uintptr_t arg2);
339 
348 struct Swi_HookSet {
349  void (*registerFxn)(int arg1);
350  void (*createFxn)(Swi_Handle arg1, Error_Block* arg2);
351  void (*readyFxn)(Swi_Handle arg1);
352  void (*beginFxn)(Swi_Handle arg1);
353  void (*endFxn)(Swi_Handle arg1);
354  void (*deleteFxn)(Swi_Handle arg1);
355 };
356 
357 typedef struct { int length; const Swi_HookSet *elem; } Swi_Hook;
358 
360 typedef Swi_Struct Swi_Struct2;
361 
362 struct Swi_Module_State {
363  Queue_Struct objQ;
364  volatile bool locked;
365  unsigned int curSet;
366  unsigned int curTrigger;
367  Swi_Handle curSwi;
368  Queue_Handle curQ;
369  Queue_Handle readyQ;
370  Queue_Handle constructedSwis;
371  bool initDone;
372 };
373 
374 struct Swi_Struct {
375  Queue_Elem qElem;
376  Queue_Elem objElem;
380  char * name;
381  Swi_FuncPtr fxn;
389  uintptr_t arg0;
397  uintptr_t arg1;
410  unsigned int priority;
411  unsigned int mask;
412  bool posted;
413  unsigned int initTrigger;
427  unsigned int trigger;
428  Queue_Handle readyQ;
429  void * *hookEnv;
430 };
441 extern const unsigned int Swi_numPriorities;
442 
444 typedef unsigned int (*CT__Swi_taskDisable)(void);
445 extern const CT__Swi_taskDisable Swi_taskDisable;
446 
447 typedef void (*CT__Swi_taskRestore)(unsigned int arg1);
448 extern const CT__Swi_taskRestore Swi_taskRestore;
454 extern const Swi_Hook Swi_hooks;
455 
456 struct Swi_Params {
460  char * name;
468  uintptr_t arg0;
476  uintptr_t arg1;
489  unsigned int priority;
503  unsigned int trigger;
504 };
505 
507 extern void Swi_init(void);
508 
509 extern int Swi_Instance_init(Swi_Object *obj, Swi_FuncPtr swiFxn, const Swi_Params *prms, Error_Block *eb);
510 
511 extern void Swi_Instance_finalize(Swi_Object *obj, int ec);
551 extern Swi_Handle Swi_create(Swi_FuncPtr swiFxn, const Swi_Params *prms, Error_Block *eb);
552 
566 extern Swi_Handle Swi_construct(Swi_Struct *obj, Swi_FuncPtr swiFxn, const Swi_Params *prms, Error_Block *eb);
567 
576 extern void Swi_delete(Swi_Handle *swi);
577 
585 extern void Swi_destruct(Swi_Struct *obj);
586 
598 extern void Swi_Params_init(Swi_Params *prms);
599 
608 extern Swi_Handle Swi_Object_first(void);
609 
620 extern Swi_Handle Swi_Object_next(Swi_Handle swi);
621 
623 extern Swi_Handle Swi_construct2(Swi_Struct2 *swi, Swi_FuncPtr swiFxn, const Swi_Params *prms);
632 extern void Swi_startup(void);
633 
637 extern bool Swi_enabled(void);
638 
646 extern void Swi_unlockSched(void);
750 extern unsigned int Swi_disable(void);
751 
766 extern void Swi_enable(void);
806 extern void Swi_restore(unsigned int key);
807 
814 extern void Swi_restoreHwi(unsigned int key);
831 extern Swi_Handle Swi_self(void);
832 
858 extern unsigned int Swi_getTrigger(void);
859 
889 extern unsigned int Swi_raisePri(unsigned int priority);
914 extern void Swi_restorePri(unsigned int key);
957 extern void Swi_andn(Swi_Handle swi, unsigned int mask);
958 
989 extern void Swi_dec(Swi_Handle swi);
990 
1017 extern void * Swi_getHookContext(Swi_Handle swi, int id);
1018 
1044 extern void Swi_setHookContext(Swi_Handle swi, int id, void * hookContext);
1045 
1055 extern char * Swi_getName(Swi_Handle swi);
1056 
1066 extern unsigned int Swi_getPri(Swi_Handle swi);
1067 
1082 extern Swi_FuncPtr Swi_getFunc(Swi_Handle swi, uintptr_t *arg0, uintptr_t *arg1);
1083 
1104 extern void Swi_getAttrs(Swi_Handle swi, Swi_FuncPtr *swiFxn, Swi_Params *params);
1105 
1132 extern void Swi_setAttrs(Swi_Handle swi, Swi_FuncPtr swiFxn, Swi_Params *params);
1133 
1150 extern void Swi_setPri(Swi_Handle swi, unsigned int priority);
1151 
1178 extern void Swi_inc(Swi_Handle swi);
1179 
1211 extern void Swi_or(Swi_Handle swi, unsigned int mask);
1212 
1231 extern void Swi_post(Swi_Handle swi);
1232 
1234 extern void Swi_schedule(void);
1235 
1236 extern void Swi_runLoop(void);
1237 
1238 extern void Swi_run(Swi_Object *swi);
1239 
1240 extern int Swi_postInit(Swi_Object *swi, Error_Block *eb);
1241 
1242 extern void Swi_restoreSMP(void);
1243 
1244 extern Swi_Module_State Swi_Module_state;
1245 
1246 #define Swi_module ((Swi_Module_State *) &(Swi_Module_state))
1247 
1248 #define Swi_Object_heap() NULL
1249 
1250 static inline char * Swi_Handle_name(Swi_Handle obj)
1251 {
1252  return (obj->name);
1253 }
1254 
1255 static inline Swi_Handle Swi_handle(Swi_Struct *str)
1256 {
1257  return ((Swi_Handle)str);
1258 }
1259 
1260 static inline Swi_Struct * Swi_struct(Swi_Handle h)
1261 {
1262  return ((Swi_Struct *)h);
1263 }
1266 #ifdef __cplusplus
1267 }
1268 #endif
1269 #endif /* ti_sysbios_knl_Swi__include */
1270 
1271 /* @cond NODOC */
1272 #undef ti_sysbios_knl_Swi_long_names
1273 #include "Swi_defs.h"
struct Swi_Struct Swi_Struct
Definition: Swi.h:310
void(* createFxn)(Swi_Handle arg1, Error_Block *arg2)
Definition: Swi.h:350
Swi hook set type definition.
Definition: Swi.h:348
void(* readyFxn)(Swi_Handle arg1)
Definition: Swi.h:351
char * name
Optional name for the object. NULL by default.
Definition: Swi.h:460
void(* deleteFxn)(Swi_Handle arg1)
Definition: Swi.h:354
char * Swi_getName(Swi_Handle swi)
Return a Swi&#39;s name.
void(* endFxn)(Swi_Handle arg1)
Definition: Swi.h:353
Swi_FuncPtr Swi_getFunc(Swi_Handle swi, uintptr_t *arg0, uintptr_t *arg1)
Get Swi function and arguments.
Swi_Handle Swi_Object_first(void)
return handle of the first Swi on Swi list
unsigned int Swi_getTrigger(void)
Return the trigger value of the currently executing Swi.
Opaque queue element.
Definition: Queue.h:204
void Swi_or(Swi_Handle swi, unsigned int mask)
Or mask with value contained in Swi&#39;s trigger and post the Swi.
Swi_Struct * Swi_Handle
Definition: Swi.h:312
unsigned int Swi_disable(void)
Disable Swi Scheduling.
Runtime error manager.
struct Swi_Struct Swi_Object
Definition: Swi.h:311
void(* Swi_FuncPtr)(uintptr_t arg1, uintptr_t arg2)
Swi function type definition.
Definition: Swi.h:338
Swi_Handle Swi_self(void)
Return address of currently executing Swi object.
Swi_Handle Swi_Object_next(Swi_Handle swi)
return handle of the next Swi on Swi list
Queue Manager.
void(* registerFxn)(int arg1)
Definition: Swi.h:349
unsigned int trigger
Initial Swi trigger value.
Definition: Swi.h:503
void Swi_post(Swi_Handle swi)
Unconditionally post a software interrupt.
void Swi_restore(unsigned int key)
Restore Swi Scheduling state.
void Swi_dec(Swi_Handle swi)
Decrement Swi&#39;s trigger value; post if trigger becomes 0.
Error block.
Definition: Error.h:152
Definition: Swi.h:357
void Swi_setHookContext(Swi_Handle swi, int id, void *hookContext)
Set hook instance&#39;s context for a swi.
void Swi_inc(Swi_Handle swi)
Increment Swi&#39;s trigger value and post the Swi.
Swi_Handle Swi_construct(Swi_Struct *obj, Swi_FuncPtr swiFxn, const Swi_Params *prms, Error_Block *eb)
Construct a software interrupt.
uintptr_t arg0
Swi function argument 0.
Definition: Swi.h:468
const Swi_Hook Swi_hooks
const array to hold all HookSet objects.
int length
Definition: Swi.h:357
void Swi_destruct(Swi_Struct *obj)
Destruct a software interrupt.
uintptr_t arg1
Swi function argument 1.
Definition: Swi.h:476
Swi_Struct * Swi_Instance
Definition: Swi.h:313
void Swi_andn(Swi_Handle swi, unsigned int mask)
Clear bits in Swi&#39;s trigger; post if trigger becomes 0.
Definition: Swi.h:456
void Swi_getAttrs(Swi_Handle swi, Swi_FuncPtr *swiFxn, Swi_Params *params)
Retrieve attributes of an existing Swi object.
void Swi_delete(Swi_Handle *swi)
Delete a software interrupt.
unsigned int priority
Swi priority.
Definition: Swi.h:489
void Swi_setAttrs(Swi_Handle swi, Swi_FuncPtr swiFxn, Swi_Params *params)
Set the attributes of an existing Swi object.
Swi_Handle Swi_create(Swi_FuncPtr swiFxn, const Swi_Params *prms, Error_Block *eb)
Create a software interrupt.
void * Swi_getHookContext(Swi_Handle swi, int id)
Get hook instance&#39;s context pointer for a Swi.
void(* beginFxn)(Swi_Handle arg1)
Definition: Swi.h:352
unsigned int Swi_getPri(Swi_Handle swi)
Return a Swi&#39;s priority.
void Swi_Params_init(Swi_Params *prms)
Initialize the Swi_Params structure with default values.
const unsigned int Swi_numPriorities
Number of Swi priorities supported.
void Swi_setPri(Swi_Handle swi, unsigned int priority)
Set a Swi&#39;s priority.
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale