hexsha
stringlengths
40
40
repo
stringlengths
5
105
path
stringlengths
3
173
license
sequence
language
stringclasses
1 value
identifier
stringlengths
1
438
return_type
stringlengths
1
106
original_string
stringlengths
21
40.7k
original_docstring
stringlengths
18
13.4k
docstring
stringlengths
11
3.24k
docstring_tokens
sequence
code
stringlengths
14
20.4k
code_tokens
sequence
short_docstring
stringlengths
0
4.36k
short_docstring_tokens
sequence
comment
sequence
parameters
list
docstring_params
dict
c9c90e054895abd01206151668043cf5747366f6
akivawerner/XscHelp
src/base/Help.c
[ "MIT" ]
C
_createDisplayAndScreenRecords
void
static void _createDisplayAndScreenRecords( Widget obj ) { XscDisplay htk_display; XscScreen htk_screen; /*------------------------------------------ -- Determine if a display structure exists ------------------------------------------*/ htk_display = _XscDisplayDeriveFromWidget( obj ); if (!htk_display) { htk_display = _XscDisplayCreate( obj ); } /*---------------------------------------- -- Determine if a screen structure exist ----------------------------------------*/ htk_screen = _XscScreenDeriveFromWidget( obj ); if (!htk_screen) { htk_screen = _XscScreenCreate( obj ); } }
/*------------------------------------------------------------------------------ -- This function creates the display/screen structures (if necessary) -- associated with a given widget/gadget ------------------------------------------------------------------------------*/
This function creates the display/screen structures (if necessary) associated with a given widget/gadget
[ "This", "function", "creates", "the", "display", "/", "screen", "structures", "(", "if", "necessary", ")", "associated", "with", "a", "given", "widget", "/", "gadget" ]
static void _createDisplayAndScreenRecords( Widget obj ) { XscDisplay htk_display; XscScreen htk_screen; htk_display = _XscDisplayDeriveFromWidget( obj ); if (!htk_display) { htk_display = _XscDisplayCreate( obj ); } htk_screen = _XscScreenDeriveFromWidget( obj ); if (!htk_screen) { htk_screen = _XscScreenCreate( obj ); } }
[ "static", "void", "_createDisplayAndScreenRecords", "(", "Widget", "obj", ")", "{", "XscDisplay", "htk_display", ";", "XscScreen", "htk_screen", ";", "htk_display", "=", "_XscDisplayDeriveFromWidget", "(", "obj", ")", ";", "if", "(", "!", "htk_display", ")", "{", "htk_display", "=", "_XscDisplayCreate", "(", "obj", ")", ";", "}", "htk_screen", "=", "_XscScreenDeriveFromWidget", "(", "obj", ")", ";", "if", "(", "!", "htk_screen", ")", "{", "htk_screen", "=", "_XscScreenCreate", "(", "obj", ")", ";", "}", "}" ]
This function creates the display/screen structures (if necessary) associated with a given widget/gadget
[ "This", "function", "creates", "the", "display", "/", "screen", "structures", "(", "if", "necessary", ")", "associated", "with", "a", "given", "widget", "/", "gadget" ]
[ "/*------------------------------------------\n -- Determine if a display structure exists\n ------------------------------------------*/", "/*----------------------------------------\n -- Determine if a screen structure exist\n ----------------------------------------*/" ]
[ { "param": "obj", "type": "Widget" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "obj", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c9c90e054895abd01206151668043cf5747366f6
akivawerner/XscHelp
src/base/Help.c
[ "MIT" ]
C
_XscHelpInstallOnWidget
void
void _XscHelpInstallOnWidget( Widget obj ) { assert( obj ); /*----------------------------------------------------------- -- Do not install the library on the tip widgets themselves -----------------------------------------------------------*/ if (strncmp( XtName( obj ), "xsc _ ", sizeof( "xsc _ " )-1 ) == 0) return; /*------------------------------------------------------------------ -- All Motif-based widgets have a context sensitive help callback. -- A callback is usually only added when context-sensitive help -- is available; when help on a widget is requested, Motif then -- calls the widget (or it closest ancestor) that has a help -- callback defined. However, there is no way for Motif to know -- if there is Help ToolKit context sensitive help available, so -- a callback is added to every widget and Help ToolKit does the -- ancestor searching. ------------------------------------------------------------------*/ if (XtHasCallbacks( obj, XmNhelpCallback ) != XtCallbackNoList) { XtAddCallback( obj, XmNhelpCallback, _XscHelpContextHelpCB, NULL ); } /*----------------------------------------------------------------------- -- Shell widgets cannot have tips, hints, etc. However, this is a good -- place to create the display/screen data structures (if not already -- created. -----------------------------------------------------------------------*/ if (XtIsShell( obj )) { /*-------------------------------------------------------------- -- If there is no screen structure, there may not be a display -- structure as well. --------------------------------------------------------------*/ XscScreen htk_screen = _XscScreenDeriveFromWidget( obj ); if (!htk_screen) { _createDisplayAndScreenRecords( obj ); } /*----------------------------------------------------------------- -- Make sure a shell record is created for this shell. This used -- to only be needed if Hints were used. It is now _always_ -- needed because Tips and Cues can be disabled on a per -- shell basis -----------------------------------------------------------------*/ _XscShellCreate( obj ); } else { /*------------------------------------------------------- -- Make sure this widget does not already have a record -------------------------------------------------------*/ XscObject htk_object = _XscObjectDeriveFromWidget( obj ); if (!htk_object) { Widget _parent = XtParent( obj ); XscObject _parentObject = _XscObjectDeriveFromWidget( _parent ); /*--------------------------------------------------------- -- If the parent of this widget has already been seen by -- the toolkit, then it is safe to create this one too. -- If the parent has not yet been seen, then don't create -- this kid yet. Wait until the parent's creation is -- finished and then do the kids. This avoids some nasty -- problems of inheritance, because otherwise the kid -- has no htk records from which to inherit. ---------------------------------------------------------*/ if (_parentObject || XtIsShell( _parent )) { _XscObjectCreate( obj ); /*---------------------------------------------------------- -- If it is a composite, there may be some children that -- were "created" -- but not registered -- earlier ----------------------------------------------------------*/ if (XtIsComposite( obj )) { CompositeRec* _cr = (CompositeRec*) obj; if (((int) _cr->composite.num_children) > 0) { int i; for (i = 0; i < _cr->composite.num_children; i++) { Widget _kid = _cr->composite.children[ i ]; _XscObjectCreate( _kid ); } } } } } } }
/*------------------------------------------------------------------------------ -- This method attaches the Help ToolKit to a widget or gadget ------------------------------------------------------------------------------*/
This method attaches the Help ToolKit to a widget or gadget
[ "This", "method", "attaches", "the", "Help", "ToolKit", "to", "a", "widget", "or", "gadget" ]
void _XscHelpInstallOnWidget( Widget obj ) { assert( obj ); if (strncmp( XtName( obj ), "xsc _ ", sizeof( "xsc _ " )-1 ) == 0) return; if (XtHasCallbacks( obj, XmNhelpCallback ) != XtCallbackNoList) { XtAddCallback( obj, XmNhelpCallback, _XscHelpContextHelpCB, NULL ); } if (XtIsShell( obj )) { XscScreen htk_screen = _XscScreenDeriveFromWidget( obj ); if (!htk_screen) { _createDisplayAndScreenRecords( obj ); } _XscShellCreate( obj ); } else { XscObject htk_object = _XscObjectDeriveFromWidget( obj ); if (!htk_object) { Widget _parent = XtParent( obj ); XscObject _parentObject = _XscObjectDeriveFromWidget( _parent ); if (_parentObject || XtIsShell( _parent )) { _XscObjectCreate( obj ); if (XtIsComposite( obj )) { CompositeRec* _cr = (CompositeRec*) obj; if (((int) _cr->composite.num_children) > 0) { int i; for (i = 0; i < _cr->composite.num_children; i++) { Widget _kid = _cr->composite.children[ i ]; _XscObjectCreate( _kid ); } } } } } } }
[ "void", "_XscHelpInstallOnWidget", "(", "Widget", "obj", ")", "{", "assert", "(", "obj", ")", ";", "if", "(", "strncmp", "(", "XtName", "(", "obj", ")", ",", "\"", "\"", ",", "sizeof", "(", "\"", "\"", ")", "-", "1", ")", "==", "0", ")", "return", ";", "if", "(", "XtHasCallbacks", "(", "obj", ",", "XmNhelpCallback", ")", "!=", "XtCallbackNoList", ")", "{", "XtAddCallback", "(", "obj", ",", "XmNhelpCallback", ",", "_XscHelpContextHelpCB", ",", "NULL", ")", ";", "}", "if", "(", "XtIsShell", "(", "obj", ")", ")", "{", "XscScreen", "htk_screen", "=", "_XscScreenDeriveFromWidget", "(", "obj", ")", ";", "if", "(", "!", "htk_screen", ")", "{", "_createDisplayAndScreenRecords", "(", "obj", ")", ";", "}", "_XscShellCreate", "(", "obj", ")", ";", "}", "else", "{", "XscObject", "htk_object", "=", "_XscObjectDeriveFromWidget", "(", "obj", ")", ";", "if", "(", "!", "htk_object", ")", "{", "Widget", "_parent", "=", "XtParent", "(", "obj", ")", ";", "XscObject", "_parentObject", "=", "_XscObjectDeriveFromWidget", "(", "_parent", ")", ";", "if", "(", "_parentObject", "||", "XtIsShell", "(", "_parent", ")", ")", "{", "_XscObjectCreate", "(", "obj", ")", ";", "if", "(", "XtIsComposite", "(", "obj", ")", ")", "{", "CompositeRec", "*", "_cr", "=", "(", "CompositeRec", "*", ")", "obj", ";", "if", "(", "(", "(", "int", ")", "_cr", "->", "composite", ".", "num_children", ")", ">", "0", ")", "{", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "_cr", "->", "composite", ".", "num_children", ";", "i", "++", ")", "{", "Widget", "_kid", "=", "_cr", "->", "composite", ".", "children", "[", "i", "]", ";", "_XscObjectCreate", "(", "_kid", ")", ";", "}", "}", "}", "}", "}", "}", "}" ]
This method attaches the Help ToolKit to a widget or gadget
[ "This", "method", "attaches", "the", "Help", "ToolKit", "to", "a", "widget", "or", "gadget" ]
[ "/*-----------------------------------------------------------\n -- Do not install the library on the tip widgets themselves\n -----------------------------------------------------------*/", "/*------------------------------------------------------------------\n -- All Motif-based widgets have a context sensitive help callback.\n -- A callback is usually only added when context-sensitive help\n -- is available; when help on a widget is requested, Motif then\n -- calls the widget (or it closest ancestor) that has a help\n -- callback defined. However, there is no way for Motif to know\n -- if there is Help ToolKit context sensitive help available, so\n -- a callback is added to every widget and Help ToolKit does the\n -- ancestor searching.\n ------------------------------------------------------------------*/", "/*-----------------------------------------------------------------------\n -- Shell widgets cannot have tips, hints, etc. However, this is a good\n -- place to create the display/screen data structures (if not already\n -- created.\n -----------------------------------------------------------------------*/", "/*--------------------------------------------------------------\n -- If there is no screen structure, there may not be a display\n -- structure as well.\n --------------------------------------------------------------*/", "/*-----------------------------------------------------------------\n -- Make sure a shell record is created for this shell. This used\n -- to only be needed if Hints were used. It is now _always_\n -- needed because Tips and Cues can be disabled on a per\n -- shell basis\n -----------------------------------------------------------------*/", "/*-------------------------------------------------------\n -- Make sure this widget does not already have a record\n -------------------------------------------------------*/", "/*---------------------------------------------------------\n\t -- If the parent of this widget has already been seen by\n\t -- the toolkit, then it is safe to create this one too.\n\t -- If the parent has not yet been seen, then don't create\n\t -- this kid yet. Wait until the parent's creation is\n\t -- finished and then do the kids. This avoids some nasty\n\t -- problems of inheritance, because otherwise the kid\n\t -- has no htk records from which to inherit.\n\t ---------------------------------------------------------*/", "/*----------------------------------------------------------\n\t -- If it is a composite, there may be some children that\n\t -- were \"created\" -- but not registered -- earlier\n\t ----------------------------------------------------------*/" ]
[ { "param": "obj", "type": "Widget" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "obj", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c9c90e054895abd01206151668043cf5747366f6
akivawerner/XscHelp
src/base/Help.c
[ "MIT" ]
C
_XscHelpGetGadgetChild
Widget
Widget _XscHelpGetGadgetChild( Widget obj, int x, int y ) { Widget gadget = NULL; /*---------------------------------------------- -- Gadgets can only be children of a Composite ----------------------------------------------*/ if (XtIsComposite( obj )) { CompositeWidget mgr = (CompositeWidget) obj; int i; /*------------------------------------------------------------------- -- Search all the children.... Some may think this is a poor -- implementation since I use the widget internals directly. -- Well, my view is that this is far more efficient (there could be -- a lot of gadgets) and, lets face it, although private, this -- internal widget structure is not going to change. -------------------------------------------------------------------*/ for (i = mgr->composite.num_children - 1; i >= 0; i--) { Widget child = mgr->composite.children[ i ]; /*-------------------- -- For each child... --------------------*/ if (child) { /*--------------------------------------- -- Make sure it is not a widget, and... ---------------------------------------*/ if (!XtIsWidget( child )) { /*--------------------------------------------------- -- Make sure it is a rect object; must be a gadget! ---------------------------------------------------*/ if (XtIsRectObj( child )) { /*------------------------------------------- -- Make sure it is managed (or else it will -- not be displayed) -------------------------------------------*/ if (XtIsManaged( child )) { /*---------------------------------------------- -- See if the (x,y) values are within the area -- defined by the gadget ----------------------------------------------*/ if ((x >= child->core.x ) && (x < child->core.x + child->core.width ) && (y >= child->core.y ) && (y < child->core.y + child->core.height)) { gadget = child; break; } } } } } } } return gadget; }
/*------------------------------------------------------------------------------ -- This function is used to determine if the pointer is on top of a gadget ------------------------------------------------------------------------------*/
This function is used to determine if the pointer is on top of a gadget
[ "This", "function", "is", "used", "to", "determine", "if", "the", "pointer", "is", "on", "top", "of", "a", "gadget" ]
Widget _XscHelpGetGadgetChild( Widget obj, int x, int y ) { Widget gadget = NULL; if (XtIsComposite( obj )) { CompositeWidget mgr = (CompositeWidget) obj; int i; for (i = mgr->composite.num_children - 1; i >= 0; i--) { Widget child = mgr->composite.children[ i ]; if (child) { if (!XtIsWidget( child )) { if (XtIsRectObj( child )) { if (XtIsManaged( child )) { if ((x >= child->core.x ) && (x < child->core.x + child->core.width ) && (y >= child->core.y ) && (y < child->core.y + child->core.height)) { gadget = child; break; } } } } } } } return gadget; }
[ "Widget", "_XscHelpGetGadgetChild", "(", "Widget", "obj", ",", "int", "x", ",", "int", "y", ")", "{", "Widget", "gadget", "=", "NULL", ";", "if", "(", "XtIsComposite", "(", "obj", ")", ")", "{", "CompositeWidget", "mgr", "=", "(", "CompositeWidget", ")", "obj", ";", "int", "i", ";", "for", "(", "i", "=", "mgr", "->", "composite", ".", "num_children", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "Widget", "child", "=", "mgr", "->", "composite", ".", "children", "[", "i", "]", ";", "if", "(", "child", ")", "{", "if", "(", "!", "XtIsWidget", "(", "child", ")", ")", "{", "if", "(", "XtIsRectObj", "(", "child", ")", ")", "{", "if", "(", "XtIsManaged", "(", "child", ")", ")", "{", "if", "(", "(", "x", ">=", "child", "->", "core", ".", "x", ")", "&&", "(", "x", "<", "child", "->", "core", ".", "x", "+", "child", "->", "core", ".", "width", ")", "&&", "(", "y", ">=", "child", "->", "core", ".", "y", ")", "&&", "(", "y", "<", "child", "->", "core", ".", "y", "+", "child", "->", "core", ".", "height", ")", ")", "{", "gadget", "=", "child", ";", "break", ";", "}", "}", "}", "}", "}", "}", "}", "return", "gadget", ";", "}" ]
This function is used to determine if the pointer is on top of a gadget
[ "This", "function", "is", "used", "to", "determine", "if", "the", "pointer", "is", "on", "top", "of", "a", "gadget" ]
[ "/*----------------------------------------------\n -- Gadgets can only be children of a Composite\n ----------------------------------------------*/", "/*-------------------------------------------------------------------\n -- Search all the children.... Some may think this is a poor\n -- implementation since I use the widget internals directly.\n -- Well, my view is that this is far more efficient (there could be\n -- a lot of gadgets) and, lets face it, although private, this\n -- internal widget structure is not going to change.\n -------------------------------------------------------------------*/", "/*--------------------\n -- For each child...\n --------------------*/", "/*---------------------------------------\n\t -- Make sure it is not a widget, and...\n\t ---------------------------------------*/", "/*---------------------------------------------------\n -- Make sure it is a rect object; must be a gadget!\n ---------------------------------------------------*/", "/*-------------------------------------------\n -- Make sure it is managed (or else it will \n -- not be displayed)\n -------------------------------------------*/", "/*----------------------------------------------\n \t -- See if the (x,y) values are within the area \n \t -- defined by the gadget\n \t ----------------------------------------------*/" ]
[ { "param": "obj", "type": "Widget" }, { "param": "x", "type": "int" }, { "param": "y", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "obj", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c9c90e054895abd01206151668043cf5747366f6
akivawerner/XscHelp
src/base/Help.c
[ "MIT" ]
C
XscHelpHintInstall
void
void XscHelpHintInstall( Widget w ) { /*---------------------------------------------------------- -- The hint display widget must not be a gadget or a shell ----------------------------------------------------------*/ if (XtIsWidget( w )) { if (!XtIsShell( w )) { /*--------------------------------------------------- -- Get the shell record associated with this widget ---------------------------------------------------*/ XscShell htk_shell = _XscShellDeriveFromWidget( w ); if (!htk_shell) { /*------------------------------------------------------- -- If the record does not exist, then make one! -------------------------------------------------------*/ htk_shell = _XscShellCreate( w ); } /*-------------------------- -- Install the hint widget --------------------------*/ _XscShellInstallHint( htk_shell, w ); } } }
/*------------------------------------------------------------------------------ -- This function is used to activate hint processing for the descendants -- of a shell. ------------------------------------------------------------------------------*/
This function is used to activate hint processing for the descendants of a shell.
[ "This", "function", "is", "used", "to", "activate", "hint", "processing", "for", "the", "descendants", "of", "a", "shell", "." ]
void XscHelpHintInstall( Widget w ) { if (XtIsWidget( w )) { if (!XtIsShell( w )) { XscShell htk_shell = _XscShellDeriveFromWidget( w ); if (!htk_shell) { htk_shell = _XscShellCreate( w ); } _XscShellInstallHint( htk_shell, w ); } } }
[ "void", "XscHelpHintInstall", "(", "Widget", "w", ")", "{", "if", "(", "XtIsWidget", "(", "w", ")", ")", "{", "if", "(", "!", "XtIsShell", "(", "w", ")", ")", "{", "XscShell", "htk_shell", "=", "_XscShellDeriveFromWidget", "(", "w", ")", ";", "if", "(", "!", "htk_shell", ")", "{", "htk_shell", "=", "_XscShellCreate", "(", "w", ")", ";", "}", "_XscShellInstallHint", "(", "htk_shell", ",", "w", ")", ";", "}", "}", "}" ]
This function is used to activate hint processing for the descendants of a shell.
[ "This", "function", "is", "used", "to", "activate", "hint", "processing", "for", "the", "descendants", "of", "a", "shell", "." ]
[ "/*----------------------------------------------------------\n -- The hint display widget must not be a gadget or a shell\n ----------------------------------------------------------*/", "/*---------------------------------------------------\n -- Get the shell record associated with this widget\n ---------------------------------------------------*/", "/*-------------------------------------------------------\n -- If the record does not exist, then make one! \n -------------------------------------------------------*/", "/*--------------------------\n -- Install the hint widget\n --------------------------*/" ]
[ { "param": "w", "type": "Widget" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "w", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c9c90e054895abd01206151668043cf5747366f6
akivawerner/XscHelp
src/base/Help.c
[ "MIT" ]
C
XscHelpInstall
void
void XscHelpInstall( Widget shell ) { static Boolean initialized = False; /*------------------------------------------------------------------- -- Make sure the Help ToolKit Composite extension record identifier -- is properly initalized -------------------------------------------------------------------*/ if (initialized == False) { static String cue_position_name[] = { "xsc_cue_position_pointer", "xsc_cue_position_top_left", "xsc_cue_position_top_right", "xsc_cue_position_bottom_left", "xsc_cue_position_bottom_right", "xsc_cue_position_top_beginning", "xsc_cue_position_top_end", "xsc_cue_position_bottom_beginning", "xsc_cue_position_bottom_end" }; static unsigned char cue_position_value[] = { (unsigned char) XmXSC_CUE_POSITION_SHELL, (unsigned char) XmXSC_CUE_POSITION_TOP_LEFT, (unsigned char) XmXSC_CUE_POSITION_TOP_RIGHT, (unsigned char) XmXSC_CUE_POSITION_BOTTOM_LEFT, (unsigned char) XmXSC_CUE_POSITION_BOTTOM_RIGHT, (unsigned char) XmXSC_CUE_POSITION_TOP_BEGINNING, (unsigned char) XmXSC_CUE_POSITION_TOP_END, (unsigned char) XmXSC_CUE_POSITION_BOTTOM_BEGINNING, (unsigned char) XmXSC_CUE_POSITION_BOTTOM_END }; static String tip_position_name[] = { "xsc_tip_position_pointer", "xsc_tip_position_top_left", "xsc_tip_position_top_right", "xsc_tip_position_bottom_left", "xsc_tip_position_bottom_right", "xsc_tip_position_top_beginning", "xsc_tip_position_top_end", "xsc_tip_position_bottom_beginning", "xsc_tip_position_bottom_end" }; static unsigned char tip_position_value[] = { (unsigned char) XmXSC_TIP_POSITION_POINTER, (unsigned char) XmXSC_TIP_POSITION_TOP_LEFT, (unsigned char) XmXSC_TIP_POSITION_TOP_RIGHT, (unsigned char) XmXSC_TIP_POSITION_BOTTOM_LEFT, (unsigned char) XmXSC_TIP_POSITION_BOTTOM_RIGHT, (unsigned char) XmXSC_TIP_POSITION_TOP_BEGINNING, (unsigned char) XmXSC_TIP_POSITION_TOP_END, (unsigned char) XmXSC_TIP_POSITION_BOTTOM_BEGINNING, (unsigned char) XmXSC_TIP_POSITION_BOTTOM_END }; static String string_conversion_name[] = { "xsc_string_converter_standard", "xsc_string_converter_font_tag", "xsc_string_converter_segmented" }; static unsigned char string_conversion_value[] = { (unsigned char) XmXSC_STRING_CONVERTER_STANDARD, (unsigned char) XmXSC_STRING_CONVERTER_FONT_TAG, (unsigned char) XmXSC_STRING_CONVERTER_SEGMENTED }; static String tip_group_name[] = { "xsc_tip_group_null", "xsc_tip_group_self", "xsc_tip_group_parent" }; static unsigned char tip_group_value[] = { (unsigned char) XmXSC_TIP_GROUP_NULL, (unsigned char) XmXSC_TIP_GROUP_SELF, (unsigned char) XmXSC_TIP_GROUP_PARENT }; static String show_name_name[] = { "xsc_show_name_none", "xsc_show_name_self", "xsc_show_name_shell", "xsc_show_name_all" }; static unsigned char show_name_value[] = { (unsigned char) XmXSC_SHOW_NAME_NONE, (unsigned char) XmXSC_SHOW_NAME_SELF, (unsigned char) XmXSC_SHOW_NAME_SHELL, (unsigned char) XmXSC_SHOW_NAME_ALL }; initialized = True; _CROffset = _XscCROffset; { XContext context = XUniqueContext(); _XscDisplayInitialize( context ); _XscScreenInitialize ( context ); _XscShellInitialize ( context ); _XscObjectInitialize( XUniqueContext() ); } if (XmRepTypeGetId( XmRXscCuePosition ) == XmREP_TYPE_INVALID) { XmRepTypeRegister( XmRXscCuePosition, cue_position_name, cue_position_value, XtNumber( cue_position_value ) ); } else { char* param = XmRXscCuePosition; Cardinal num_params = 1; XtErrorMsg( "repTypRegister", "alreadyRegistered", "XscHelp", "The enumeration \"%s\" defined by the XscHelp library " "was already registered.", &param, &num_params ); } if (XmRepTypeGetId( XmRXscTipPosition ) == XmREP_TYPE_INVALID) { XmRepTypeRegister( XmRXscTipPosition, tip_position_name, tip_position_value, XtNumber( tip_position_value ) ); } else { char* param = XmRXscTipPosition; Cardinal num_params = 1; XtErrorMsg( "repTypRegister", "alreadyRegistered", "XscHelp", "The enumeration \"%s\" defined by the XscHelp library " "was already registered.", &param, &num_params ); } if (XmRepTypeGetId( XmRXscStringConverter ) == XmREP_TYPE_INVALID) { XmRepTypeRegister( XmRXscStringConverter, string_conversion_name, string_conversion_value, XtNumber( string_conversion_value ) ); } else { char* param = XmRXscStringConverter; Cardinal num_params = 1; XtErrorMsg( "repTypRegister", "alreadyRegistered", "XscHelp", "The enumeration \"%s\" defined by the XscHelp library " "was already registered.", &param, &num_params ); } if (XmRepTypeGetId( XmRXscTipGroup ) == XmREP_TYPE_INVALID) { XmRepTypeRegister( XmRXscTipGroup, tip_group_name, tip_group_value, XtNumber( tip_group_value ) ); } else { char* param = XmRXscTipGroup; Cardinal num_params = 1; XtErrorMsg( "repTypRegister", "alreadyRegistered", "XscHelp", "The enumeration \"%s\" defined by the XscHelp library " "was already registered.", &param, &num_params ); } if (XmRepTypeGetId( XmRXscShowName ) == XmREP_TYPE_INVALID) { XmRepTypeRegister( XmRXscShowName, show_name_name, show_name_value, XtNumber( show_name_value ) ); } else { char* param = XmRXscShowName; Cardinal num_params = 1; XtErrorMsg( "repTypRegister", "alreadyRegistered", "XscHelp", "The enumeration \"%s\" defined by the XscHelp library " "was already registered.", &param, &num_params ); } } if (shell) { /*-------------------------------------------------- -- Do not install a display that is already known! --------------------------------------------------*/ XscDisplay htk_display = _XscDisplayDeriveFromWidget( shell ); if (!htk_display) { /*--------------------------------------------------------- -- This is technically a bug since it assumes that this -- is the only application context that will be used. :-( ---------------------------------------------------------*/ XtAppSetTypeConverter( XtWidgetToApplicationContext( shell ), XtRString, XmRXscTipGroupId, XscCvtStringToTipGroupId, NULL, (Cardinal) 0, XtCacheAll, NULL ); _XscHooksInstall( shell ); _XscHelpInstallOnWidget( shell ); } } }
/*------------------------------------------------------------------------------ -- This function installs the Help ToolKit on a specific widget. -- It is typically used to infect the session/application shells that -- have no parents ------------------------------------------------------------------------------*/
This function installs the Help ToolKit on a specific widget. It is typically used to infect the session/application shells that have no parents
[ "This", "function", "installs", "the", "Help", "ToolKit", "on", "a", "specific", "widget", ".", "It", "is", "typically", "used", "to", "infect", "the", "session", "/", "application", "shells", "that", "have", "no", "parents" ]
void XscHelpInstall( Widget shell ) { static Boolean initialized = False; if (initialized == False) { static String cue_position_name[] = { "xsc_cue_position_pointer", "xsc_cue_position_top_left", "xsc_cue_position_top_right", "xsc_cue_position_bottom_left", "xsc_cue_position_bottom_right", "xsc_cue_position_top_beginning", "xsc_cue_position_top_end", "xsc_cue_position_bottom_beginning", "xsc_cue_position_bottom_end" }; static unsigned char cue_position_value[] = { (unsigned char) XmXSC_CUE_POSITION_SHELL, (unsigned char) XmXSC_CUE_POSITION_TOP_LEFT, (unsigned char) XmXSC_CUE_POSITION_TOP_RIGHT, (unsigned char) XmXSC_CUE_POSITION_BOTTOM_LEFT, (unsigned char) XmXSC_CUE_POSITION_BOTTOM_RIGHT, (unsigned char) XmXSC_CUE_POSITION_TOP_BEGINNING, (unsigned char) XmXSC_CUE_POSITION_TOP_END, (unsigned char) XmXSC_CUE_POSITION_BOTTOM_BEGINNING, (unsigned char) XmXSC_CUE_POSITION_BOTTOM_END }; static String tip_position_name[] = { "xsc_tip_position_pointer", "xsc_tip_position_top_left", "xsc_tip_position_top_right", "xsc_tip_position_bottom_left", "xsc_tip_position_bottom_right", "xsc_tip_position_top_beginning", "xsc_tip_position_top_end", "xsc_tip_position_bottom_beginning", "xsc_tip_position_bottom_end" }; static unsigned char tip_position_value[] = { (unsigned char) XmXSC_TIP_POSITION_POINTER, (unsigned char) XmXSC_TIP_POSITION_TOP_LEFT, (unsigned char) XmXSC_TIP_POSITION_TOP_RIGHT, (unsigned char) XmXSC_TIP_POSITION_BOTTOM_LEFT, (unsigned char) XmXSC_TIP_POSITION_BOTTOM_RIGHT, (unsigned char) XmXSC_TIP_POSITION_TOP_BEGINNING, (unsigned char) XmXSC_TIP_POSITION_TOP_END, (unsigned char) XmXSC_TIP_POSITION_BOTTOM_BEGINNING, (unsigned char) XmXSC_TIP_POSITION_BOTTOM_END }; static String string_conversion_name[] = { "xsc_string_converter_standard", "xsc_string_converter_font_tag", "xsc_string_converter_segmented" }; static unsigned char string_conversion_value[] = { (unsigned char) XmXSC_STRING_CONVERTER_STANDARD, (unsigned char) XmXSC_STRING_CONVERTER_FONT_TAG, (unsigned char) XmXSC_STRING_CONVERTER_SEGMENTED }; static String tip_group_name[] = { "xsc_tip_group_null", "xsc_tip_group_self", "xsc_tip_group_parent" }; static unsigned char tip_group_value[] = { (unsigned char) XmXSC_TIP_GROUP_NULL, (unsigned char) XmXSC_TIP_GROUP_SELF, (unsigned char) XmXSC_TIP_GROUP_PARENT }; static String show_name_name[] = { "xsc_show_name_none", "xsc_show_name_self", "xsc_show_name_shell", "xsc_show_name_all" }; static unsigned char show_name_value[] = { (unsigned char) XmXSC_SHOW_NAME_NONE, (unsigned char) XmXSC_SHOW_NAME_SELF, (unsigned char) XmXSC_SHOW_NAME_SHELL, (unsigned char) XmXSC_SHOW_NAME_ALL }; initialized = True; _CROffset = _XscCROffset; { XContext context = XUniqueContext(); _XscDisplayInitialize( context ); _XscScreenInitialize ( context ); _XscShellInitialize ( context ); _XscObjectInitialize( XUniqueContext() ); } if (XmRepTypeGetId( XmRXscCuePosition ) == XmREP_TYPE_INVALID) { XmRepTypeRegister( XmRXscCuePosition, cue_position_name, cue_position_value, XtNumber( cue_position_value ) ); } else { char* param = XmRXscCuePosition; Cardinal num_params = 1; XtErrorMsg( "repTypRegister", "alreadyRegistered", "XscHelp", "The enumeration \"%s\" defined by the XscHelp library " "was already registered.", &param, &num_params ); } if (XmRepTypeGetId( XmRXscTipPosition ) == XmREP_TYPE_INVALID) { XmRepTypeRegister( XmRXscTipPosition, tip_position_name, tip_position_value, XtNumber( tip_position_value ) ); } else { char* param = XmRXscTipPosition; Cardinal num_params = 1; XtErrorMsg( "repTypRegister", "alreadyRegistered", "XscHelp", "The enumeration \"%s\" defined by the XscHelp library " "was already registered.", &param, &num_params ); } if (XmRepTypeGetId( XmRXscStringConverter ) == XmREP_TYPE_INVALID) { XmRepTypeRegister( XmRXscStringConverter, string_conversion_name, string_conversion_value, XtNumber( string_conversion_value ) ); } else { char* param = XmRXscStringConverter; Cardinal num_params = 1; XtErrorMsg( "repTypRegister", "alreadyRegistered", "XscHelp", "The enumeration \"%s\" defined by the XscHelp library " "was already registered.", &param, &num_params ); } if (XmRepTypeGetId( XmRXscTipGroup ) == XmREP_TYPE_INVALID) { XmRepTypeRegister( XmRXscTipGroup, tip_group_name, tip_group_value, XtNumber( tip_group_value ) ); } else { char* param = XmRXscTipGroup; Cardinal num_params = 1; XtErrorMsg( "repTypRegister", "alreadyRegistered", "XscHelp", "The enumeration \"%s\" defined by the XscHelp library " "was already registered.", &param, &num_params ); } if (XmRepTypeGetId( XmRXscShowName ) == XmREP_TYPE_INVALID) { XmRepTypeRegister( XmRXscShowName, show_name_name, show_name_value, XtNumber( show_name_value ) ); } else { char* param = XmRXscShowName; Cardinal num_params = 1; XtErrorMsg( "repTypRegister", "alreadyRegistered", "XscHelp", "The enumeration \"%s\" defined by the XscHelp library " "was already registered.", &param, &num_params ); } } if (shell) { XscDisplay htk_display = _XscDisplayDeriveFromWidget( shell ); if (!htk_display) { XtAppSetTypeConverter( XtWidgetToApplicationContext( shell ), XtRString, XmRXscTipGroupId, XscCvtStringToTipGroupId, NULL, (Cardinal) 0, XtCacheAll, NULL ); _XscHooksInstall( shell ); _XscHelpInstallOnWidget( shell ); } } }
[ "void", "XscHelpInstall", "(", "Widget", "shell", ")", "{", "static", "Boolean", "initialized", "=", "False", ";", "if", "(", "initialized", "==", "False", ")", "{", "static", "String", "cue_position_name", "[", "]", "=", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ";", "static", "unsigned", "char", "cue_position_value", "[", "]", "=", "{", "(", "unsigned", "char", ")", "XmXSC_CUE_POSITION_SHELL", ",", "(", "unsigned", "char", ")", "XmXSC_CUE_POSITION_TOP_LEFT", ",", "(", "unsigned", "char", ")", "XmXSC_CUE_POSITION_TOP_RIGHT", ",", "(", "unsigned", "char", ")", "XmXSC_CUE_POSITION_BOTTOM_LEFT", ",", "(", "unsigned", "char", ")", "XmXSC_CUE_POSITION_BOTTOM_RIGHT", ",", "(", "unsigned", "char", ")", "XmXSC_CUE_POSITION_TOP_BEGINNING", ",", "(", "unsigned", "char", ")", "XmXSC_CUE_POSITION_TOP_END", ",", "(", "unsigned", "char", ")", "XmXSC_CUE_POSITION_BOTTOM_BEGINNING", ",", "(", "unsigned", "char", ")", "XmXSC_CUE_POSITION_BOTTOM_END", "}", ";", "static", "String", "tip_position_name", "[", "]", "=", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ";", "static", "unsigned", "char", "tip_position_value", "[", "]", "=", "{", "(", "unsigned", "char", ")", "XmXSC_TIP_POSITION_POINTER", ",", "(", "unsigned", "char", ")", "XmXSC_TIP_POSITION_TOP_LEFT", ",", "(", "unsigned", "char", ")", "XmXSC_TIP_POSITION_TOP_RIGHT", ",", "(", "unsigned", "char", ")", "XmXSC_TIP_POSITION_BOTTOM_LEFT", ",", "(", "unsigned", "char", ")", "XmXSC_TIP_POSITION_BOTTOM_RIGHT", ",", "(", "unsigned", "char", ")", "XmXSC_TIP_POSITION_TOP_BEGINNING", ",", "(", "unsigned", "char", ")", "XmXSC_TIP_POSITION_TOP_END", ",", "(", "unsigned", "char", ")", "XmXSC_TIP_POSITION_BOTTOM_BEGINNING", ",", "(", "unsigned", "char", ")", "XmXSC_TIP_POSITION_BOTTOM_END", "}", ";", "static", "String", "string_conversion_name", "[", "]", "=", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ";", "static", "unsigned", "char", "string_conversion_value", "[", "]", "=", "{", "(", "unsigned", "char", ")", "XmXSC_STRING_CONVERTER_STANDARD", ",", "(", "unsigned", "char", ")", "XmXSC_STRING_CONVERTER_FONT_TAG", ",", "(", "unsigned", "char", ")", "XmXSC_STRING_CONVERTER_SEGMENTED", "}", ";", "static", "String", "tip_group_name", "[", "]", "=", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ";", "static", "unsigned", "char", "tip_group_value", "[", "]", "=", "{", "(", "unsigned", "char", ")", "XmXSC_TIP_GROUP_NULL", ",", "(", "unsigned", "char", ")", "XmXSC_TIP_GROUP_SELF", ",", "(", "unsigned", "char", ")", "XmXSC_TIP_GROUP_PARENT", "}", ";", "static", "String", "show_name_name", "[", "]", "=", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ";", "static", "unsigned", "char", "show_name_value", "[", "]", "=", "{", "(", "unsigned", "char", ")", "XmXSC_SHOW_NAME_NONE", ",", "(", "unsigned", "char", ")", "XmXSC_SHOW_NAME_SELF", ",", "(", "unsigned", "char", ")", "XmXSC_SHOW_NAME_SHELL", ",", "(", "unsigned", "char", ")", "XmXSC_SHOW_NAME_ALL", "}", ";", "initialized", "=", "True", ";", "_CROffset", "=", "_XscCROffset", ";", "{", "XContext", "context", "=", "XUniqueContext", "(", ")", ";", "_XscDisplayInitialize", "(", "context", ")", ";", "_XscScreenInitialize", "(", "context", ")", ";", "_XscShellInitialize", "(", "context", ")", ";", "_XscObjectInitialize", "(", "XUniqueContext", "(", ")", ")", ";", "}", "if", "(", "XmRepTypeGetId", "(", "XmRXscCuePosition", ")", "==", "XmREP_TYPE_INVALID", ")", "{", "XmRepTypeRegister", "(", "XmRXscCuePosition", ",", "cue_position_name", ",", "cue_position_value", ",", "XtNumber", "(", "cue_position_value", ")", ")", ";", "}", "else", "{", "char", "*", "param", "=", "XmRXscCuePosition", ";", "Cardinal", "num_params", "=", "1", ";", "XtErrorMsg", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\\\"", "\\\"", "\"", "\"", "\"", ",", "&", "param", ",", "&", "num_params", ")", ";", "}", "if", "(", "XmRepTypeGetId", "(", "XmRXscTipPosition", ")", "==", "XmREP_TYPE_INVALID", ")", "{", "XmRepTypeRegister", "(", "XmRXscTipPosition", ",", "tip_position_name", ",", "tip_position_value", ",", "XtNumber", "(", "tip_position_value", ")", ")", ";", "}", "else", "{", "char", "*", "param", "=", "XmRXscTipPosition", ";", "Cardinal", "num_params", "=", "1", ";", "XtErrorMsg", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\\\"", "\\\"", "\"", "\"", "\"", ",", "&", "param", ",", "&", "num_params", ")", ";", "}", "if", "(", "XmRepTypeGetId", "(", "XmRXscStringConverter", ")", "==", "XmREP_TYPE_INVALID", ")", "{", "XmRepTypeRegister", "(", "XmRXscStringConverter", ",", "string_conversion_name", ",", "string_conversion_value", ",", "XtNumber", "(", "string_conversion_value", ")", ")", ";", "}", "else", "{", "char", "*", "param", "=", "XmRXscStringConverter", ";", "Cardinal", "num_params", "=", "1", ";", "XtErrorMsg", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\\\"", "\\\"", "\"", "\"", "\"", ",", "&", "param", ",", "&", "num_params", ")", ";", "}", "if", "(", "XmRepTypeGetId", "(", "XmRXscTipGroup", ")", "==", "XmREP_TYPE_INVALID", ")", "{", "XmRepTypeRegister", "(", "XmRXscTipGroup", ",", "tip_group_name", ",", "tip_group_value", ",", "XtNumber", "(", "tip_group_value", ")", ")", ";", "}", "else", "{", "char", "*", "param", "=", "XmRXscTipGroup", ";", "Cardinal", "num_params", "=", "1", ";", "XtErrorMsg", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\\\"", "\\\"", "\"", "\"", "\"", ",", "&", "param", ",", "&", "num_params", ")", ";", "}", "if", "(", "XmRepTypeGetId", "(", "XmRXscShowName", ")", "==", "XmREP_TYPE_INVALID", ")", "{", "XmRepTypeRegister", "(", "XmRXscShowName", ",", "show_name_name", ",", "show_name_value", ",", "XtNumber", "(", "show_name_value", ")", ")", ";", "}", "else", "{", "char", "*", "param", "=", "XmRXscShowName", ";", "Cardinal", "num_params", "=", "1", ";", "XtErrorMsg", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\\\"", "\\\"", "\"", "\"", "\"", ",", "&", "param", ",", "&", "num_params", ")", ";", "}", "}", "if", "(", "shell", ")", "{", "XscDisplay", "htk_display", "=", "_XscDisplayDeriveFromWidget", "(", "shell", ")", ";", "if", "(", "!", "htk_display", ")", "{", "XtAppSetTypeConverter", "(", "XtWidgetToApplicationContext", "(", "shell", ")", ",", "XtRString", ",", "XmRXscTipGroupId", ",", "XscCvtStringToTipGroupId", ",", "NULL", ",", "(", "Cardinal", ")", "0", ",", "XtCacheAll", ",", "NULL", ")", ";", "_XscHooksInstall", "(", "shell", ")", ";", "_XscHelpInstallOnWidget", "(", "shell", ")", ";", "}", "}", "}" ]
This function installs the Help ToolKit on a specific widget.
[ "This", "function", "installs", "the", "Help", "ToolKit", "on", "a", "specific", "widget", "." ]
[ "/*-------------------------------------------------------------------\n -- Make sure the Help ToolKit Composite extension record identifier\n -- is properly initalized\n -------------------------------------------------------------------*/", "/*--------------------------------------------------\n -- Do not install a display that is already known!\n --------------------------------------------------*/", "/*---------------------------------------------------------\n \t -- This is technically a bug since it assumes that this\n\t -- is the only application context that will be used. :-(\n\t ---------------------------------------------------------*/" ]
[ { "param": "shell", "type": "Widget" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "shell", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c9c90e054895abd01206151668043cf5747366f6
akivawerner/XscHelp
src/base/Help.c
[ "MIT" ]
C
XscHelpLoadTopics
int
int XscHelpLoadTopics( Display* theDisplay, const char* theFilename ) { int _result = 0; FILE* _file = fopen( theFilename, "r" ); if (_file) { char _specifier [ 256 ]; char _lineBuffer[ 1024 ]; char* _ptr; char* _topicBuffer = NULL; int _topicBufferSize = 0; int _topicLen = 0; char* _topicEnd = NULL; XrmDatabase _db = XrmGetDatabase( theDisplay ); Boolean _inTopic = False; _topicBufferSize = sizeof( _lineBuffer ); _topicBuffer = XtMalloc( _topicBufferSize ); _topicLen = 0; _topicEnd = _topicBuffer; *_topicBuffer = '\0'; while (!feof( _file )) { _ptr = fgets( _lineBuffer, sizeof( _lineBuffer ), _file ); if (_ptr) { if (strncmp( _ptr, ".TEXT[", 6 ) == 0) { char* _walk; char* _end; _ptr += 6; _walk = _ptr; while (*_walk) { if (!isspace( *_walk )) break; _ptr++; _walk++; } _end = NULL; while (*_walk) { if (isspace( *_walk )) { _end = _walk; } else if (*_walk == ']') { if (_end == NULL) _end = _walk; break; } else { _end = NULL; } _walk++; } *_end = '\0'; if (_inTopic) { if (_topicLen) { _topicEnd--; if (*_topicEnd == '\n') *_topicEnd = '\0'; } XrmPutStringResource( &_db, _specifier, _topicBuffer ); *_topicBuffer = '\0'; _topicEnd = _topicBuffer; _topicLen = 0; } sprintf( _specifier, "_xscHelp.topic.%s", _ptr ); _inTopic = True; } else if (strncmp( _ptr, ".END", 4 ) == 0) { if (_topicLen) { _topicEnd--; if (*_topicEnd == '\n') *_topicEnd = '\0'; } XrmPutStringResource( &_db, _specifier, _topicBuffer ); _inTopic = False; *_topicBuffer = '\0'; _topicEnd = _topicBuffer; _topicLen = 0; } else { if (_inTopic) { int _lineLen = strlen( _ptr ); if (_topicLen + _lineLen >= _topicBufferSize) { _topicBufferSize = _topicLen + _lineLen + 1024; _topicBuffer = XtRealloc( _topicBuffer, _topicBufferSize ); _topicEnd = _topicBuffer + _topicLen; } strcpy( _topicEnd, _ptr ); _topicEnd += _lineLen; _topicLen += _lineLen; } } } } XtFree( _topicBuffer ); fclose( _file ); } else { _result = errno; } return _result; }
/*------------------------------------------------------------------------------ -- This function loads "global" topics into the resource database. There is -- a very simple parsing rule ------------------------------------------------------------------------------*/
This function loads "global" topics into the resource database. There is a very simple parsing rule
[ "This", "function", "loads", "\"", "global", "\"", "topics", "into", "the", "resource", "database", ".", "There", "is", "a", "very", "simple", "parsing", "rule" ]
int XscHelpLoadTopics( Display* theDisplay, const char* theFilename ) { int _result = 0; FILE* _file = fopen( theFilename, "r" ); if (_file) { char _specifier [ 256 ]; char _lineBuffer[ 1024 ]; char* _ptr; char* _topicBuffer = NULL; int _topicBufferSize = 0; int _topicLen = 0; char* _topicEnd = NULL; XrmDatabase _db = XrmGetDatabase( theDisplay ); Boolean _inTopic = False; _topicBufferSize = sizeof( _lineBuffer ); _topicBuffer = XtMalloc( _topicBufferSize ); _topicLen = 0; _topicEnd = _topicBuffer; *_topicBuffer = '\0'; while (!feof( _file )) { _ptr = fgets( _lineBuffer, sizeof( _lineBuffer ), _file ); if (_ptr) { if (strncmp( _ptr, ".TEXT[", 6 ) == 0) { char* _walk; char* _end; _ptr += 6; _walk = _ptr; while (*_walk) { if (!isspace( *_walk )) break; _ptr++; _walk++; } _end = NULL; while (*_walk) { if (isspace( *_walk )) { _end = _walk; } else if (*_walk == ']') { if (_end == NULL) _end = _walk; break; } else { _end = NULL; } _walk++; } *_end = '\0'; if (_inTopic) { if (_topicLen) { _topicEnd--; if (*_topicEnd == '\n') *_topicEnd = '\0'; } XrmPutStringResource( &_db, _specifier, _topicBuffer ); *_topicBuffer = '\0'; _topicEnd = _topicBuffer; _topicLen = 0; } sprintf( _specifier, "_xscHelp.topic.%s", _ptr ); _inTopic = True; } else if (strncmp( _ptr, ".END", 4 ) == 0) { if (_topicLen) { _topicEnd--; if (*_topicEnd == '\n') *_topicEnd = '\0'; } XrmPutStringResource( &_db, _specifier, _topicBuffer ); _inTopic = False; *_topicBuffer = '\0'; _topicEnd = _topicBuffer; _topicLen = 0; } else { if (_inTopic) { int _lineLen = strlen( _ptr ); if (_topicLen + _lineLen >= _topicBufferSize) { _topicBufferSize = _topicLen + _lineLen + 1024; _topicBuffer = XtRealloc( _topicBuffer, _topicBufferSize ); _topicEnd = _topicBuffer + _topicLen; } strcpy( _topicEnd, _ptr ); _topicEnd += _lineLen; _topicLen += _lineLen; } } } } XtFree( _topicBuffer ); fclose( _file ); } else { _result = errno; } return _result; }
[ "int", "XscHelpLoadTopics", "(", "Display", "*", "theDisplay", ",", "const", "char", "*", "theFilename", ")", "{", "int", "_result", "=", "0", ";", "FILE", "*", "_file", "=", "fopen", "(", "theFilename", ",", "\"", "\"", ")", ";", "if", "(", "_file", ")", "{", "char", "_specifier", "[", "256", "]", ";", "char", "_lineBuffer", "[", "1024", "]", ";", "char", "*", "_ptr", ";", "char", "*", "_topicBuffer", "=", "NULL", ";", "int", "_topicBufferSize", "=", "0", ";", "int", "_topicLen", "=", "0", ";", "char", "*", "_topicEnd", "=", "NULL", ";", "XrmDatabase", "_db", "=", "XrmGetDatabase", "(", "theDisplay", ")", ";", "Boolean", "_inTopic", "=", "False", ";", "_topicBufferSize", "=", "sizeof", "(", "_lineBuffer", ")", ";", "_topicBuffer", "=", "XtMalloc", "(", "_topicBufferSize", ")", ";", "_topicLen", "=", "0", ";", "_topicEnd", "=", "_topicBuffer", ";", "*", "_topicBuffer", "=", "'", "\\0", "'", ";", "while", "(", "!", "feof", "(", "_file", ")", ")", "{", "_ptr", "=", "fgets", "(", "_lineBuffer", ",", "sizeof", "(", "_lineBuffer", ")", ",", "_file", ")", ";", "if", "(", "_ptr", ")", "{", "if", "(", "strncmp", "(", "_ptr", ",", "\"", "\"", ",", "6", ")", "==", "0", ")", "{", "char", "*", "_walk", ";", "char", "*", "_end", ";", "_ptr", "+=", "6", ";", "_walk", "=", "_ptr", ";", "while", "(", "*", "_walk", ")", "{", "if", "(", "!", "isspace", "(", "*", "_walk", ")", ")", "break", ";", "_ptr", "++", ";", "_walk", "++", ";", "}", "_end", "=", "NULL", ";", "while", "(", "*", "_walk", ")", "{", "if", "(", "isspace", "(", "*", "_walk", ")", ")", "{", "_end", "=", "_walk", ";", "}", "else", "if", "(", "*", "_walk", "==", "'", "'", ")", "{", "if", "(", "_end", "==", "NULL", ")", "_end", "=", "_walk", ";", "break", ";", "}", "else", "{", "_end", "=", "NULL", ";", "}", "_walk", "++", ";", "}", "*", "_end", "=", "'", "\\0", "'", ";", "if", "(", "_inTopic", ")", "{", "if", "(", "_topicLen", ")", "{", "_topicEnd", "--", ";", "if", "(", "*", "_topicEnd", "==", "'", "\\n", "'", ")", "*", "_topicEnd", "=", "'", "\\0", "'", ";", "}", "XrmPutStringResource", "(", "&", "_db", ",", "_specifier", ",", "_topicBuffer", ")", ";", "*", "_topicBuffer", "=", "'", "\\0", "'", ";", "_topicEnd", "=", "_topicBuffer", ";", "_topicLen", "=", "0", ";", "}", "sprintf", "(", "_specifier", ",", "\"", "\"", ",", "_ptr", ")", ";", "_inTopic", "=", "True", ";", "}", "else", "if", "(", "strncmp", "(", "_ptr", ",", "\"", "\"", ",", "4", ")", "==", "0", ")", "{", "if", "(", "_topicLen", ")", "{", "_topicEnd", "--", ";", "if", "(", "*", "_topicEnd", "==", "'", "\\n", "'", ")", "*", "_topicEnd", "=", "'", "\\0", "'", ";", "}", "XrmPutStringResource", "(", "&", "_db", ",", "_specifier", ",", "_topicBuffer", ")", ";", "_inTopic", "=", "False", ";", "*", "_topicBuffer", "=", "'", "\\0", "'", ";", "_topicEnd", "=", "_topicBuffer", ";", "_topicLen", "=", "0", ";", "}", "else", "{", "if", "(", "_inTopic", ")", "{", "int", "_lineLen", "=", "strlen", "(", "_ptr", ")", ";", "if", "(", "_topicLen", "+", "_lineLen", ">=", "_topicBufferSize", ")", "{", "_topicBufferSize", "=", "_topicLen", "+", "_lineLen", "+", "1024", ";", "_topicBuffer", "=", "XtRealloc", "(", "_topicBuffer", ",", "_topicBufferSize", ")", ";", "_topicEnd", "=", "_topicBuffer", "+", "_topicLen", ";", "}", "strcpy", "(", "_topicEnd", ",", "_ptr", ")", ";", "_topicEnd", "+=", "_lineLen", ";", "_topicLen", "+=", "_lineLen", ";", "}", "}", "}", "}", "XtFree", "(", "_topicBuffer", ")", ";", "fclose", "(", "_file", ")", ";", "}", "else", "{", "_result", "=", "errno", ";", "}", "return", "_result", ";", "}" ]
This function loads "global" topics into the resource database.
[ "This", "function", "loads", "\"", "global", "\"", "topics", "into", "the", "resource", "database", "." ]
[]
[ { "param": "theDisplay", "type": "Display" }, { "param": "theFilename", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "theDisplay", "type": "Display", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "theFilename", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
191510d2dc6f6758cb96fca933576216b048b989
akivawerner/XscHelp
src/base/Tip.c
[ "MIT" ]
C
_XscTipPopdown
void
void _XscTipPopdown( XscTip self ) { Widget object_widget = _XscObjectGetWidget( self->object ); XscDisplay xsc_display = _XscDisplayDeriveFromWidget( object_widget ); XscScreen xsc_screen = _XscScreenDeriveFromWidget ( object_widget ); /*----------------------------------------------------------------------- -- Verify that this object is the object recorded in the display record -----------------------------------------------------------------------*/ if (self->object == _XscDisplayGetActiveTip( xsc_display )) { /*------------------------------------------------------ -- Stop all the (potential) timers and popdown the tip ------------------------------------------------------*/ _XscDisplayCancelTimerTipPopup ( xsc_display ); _XscDisplayCancelTimerTipPopdown( xsc_display ); _XscDisplayCancelTimerSelectName( xsc_display ); _XscScreenPopdownTip( xsc_screen ); _XscDisplaySetActiveTip( xsc_display, NULL ); self->_selected = False; } }
/*------------------------------------------------------------------------------ -- This function forces a tip to pop-down ------------------------------------------------------------------------------*/
This function forces a tip to pop-down
[ "This", "function", "forces", "a", "tip", "to", "pop", "-", "down" ]
void _XscTipPopdown( XscTip self ) { Widget object_widget = _XscObjectGetWidget( self->object ); XscDisplay xsc_display = _XscDisplayDeriveFromWidget( object_widget ); XscScreen xsc_screen = _XscScreenDeriveFromWidget ( object_widget ); if (self->object == _XscDisplayGetActiveTip( xsc_display )) { _XscDisplayCancelTimerTipPopup ( xsc_display ); _XscDisplayCancelTimerTipPopdown( xsc_display ); _XscDisplayCancelTimerSelectName( xsc_display ); _XscScreenPopdownTip( xsc_screen ); _XscDisplaySetActiveTip( xsc_display, NULL ); self->_selected = False; } }
[ "void", "_XscTipPopdown", "(", "XscTip", "self", ")", "{", "Widget", "object_widget", "=", "_XscObjectGetWidget", "(", "self", "->", "object", ")", ";", "XscDisplay", "xsc_display", "=", "_XscDisplayDeriveFromWidget", "(", "object_widget", ")", ";", "XscScreen", "xsc_screen", "=", "_XscScreenDeriveFromWidget", "(", "object_widget", ")", ";", "if", "(", "self", "->", "object", "==", "_XscDisplayGetActiveTip", "(", "xsc_display", ")", ")", "{", "_XscDisplayCancelTimerTipPopup", "(", "xsc_display", ")", ";", "_XscDisplayCancelTimerTipPopdown", "(", "xsc_display", ")", ";", "_XscDisplayCancelTimerSelectName", "(", "xsc_display", ")", ";", "_XscScreenPopdownTip", "(", "xsc_screen", ")", ";", "_XscDisplaySetActiveTip", "(", "xsc_display", ",", "NULL", ")", ";", "self", "->", "_selected", "=", "False", ";", "}", "}" ]
This function forces a tip to pop-down
[ "This", "function", "forces", "a", "tip", "to", "pop", "-", "down" ]
[ "/*-----------------------------------------------------------------------\n -- Verify that this object is the object recorded in the display record\n -----------------------------------------------------------------------*/", "/*------------------------------------------------------\n -- Stop all the (potential) timers and popdown the tip\n ------------------------------------------------------*/" ]
[ { "param": "self", "type": "XscTip" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": "XscTip", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
191510d2dc6f6758cb96fca933576216b048b989
akivawerner/XscHelp
src/base/Tip.c
[ "MIT" ]
C
_XscTipPopup
void
void _XscTipPopup( XscTip self ) { Widget object_widget = _XscObjectGetWidget( self->object ); XscDisplay htk_display = _XscDisplayDeriveFromWidget( object_widget ); XscScreen htk_screen = _XscScreenDeriveFromWidget( object_widget ); Bool bool; Window root_window, child_window; int root_x, root_y, win_x, win_y; unsigned int keys_buttons; Screen* screen; assert( htk_screen ); screen = XtScreenOfObject( object_widget ); bool = XQueryPointer( XtDisplayOfObject( object_widget ), RootWindowOfScreen( screen ), &root_window, &child_window, &root_x, &root_y, &win_x, &win_y, &keys_buttons ); if (bool) { self->_rootX = root_x; self->_rootY = root_y; } else { Position root_pos_x, root_pos_y; int w_border, w_height, w_width; XtTranslateCoords( object_widget, 0, 0, &root_pos_x, &root_pos_y ); w_border = object_widget->core.border_width; w_height = object_widget->core.height; w_width = object_widget->core.width; self->_rootX = root_pos_x + (w_border * 2 + w_width ) / 2; self->_rootY = root_pos_y + (w_border * 2 + w_height) / 2; } if (XscTipHasValidTopic( self )) { _XscTipUpdate( self ); /*-------------- -- Map the tip --------------*/ _XscScreenPopupTip( htk_screen ); /*--------------------------------------------- -- If needed, install the auto pop-down timer ---------------------------------------------*/ if (self->popdownInterval) { _XscDisplayStartTimerTipPopdown( htk_display, self->object ); } if (_XscTextHasWidgetName( self->text )) { _XscDisplayStartTimerSelectName( htk_display, self->object ); } } }
/*------------------------------------------------------------------------------ -- This function handles the geometry managment and pop-up of a tip ------------------------------------------------------------------------------*/
This function handles the geometry managment and pop-up of a tip
[ "This", "function", "handles", "the", "geometry", "managment", "and", "pop", "-", "up", "of", "a", "tip" ]
void _XscTipPopup( XscTip self ) { Widget object_widget = _XscObjectGetWidget( self->object ); XscDisplay htk_display = _XscDisplayDeriveFromWidget( object_widget ); XscScreen htk_screen = _XscScreenDeriveFromWidget( object_widget ); Bool bool; Window root_window, child_window; int root_x, root_y, win_x, win_y; unsigned int keys_buttons; Screen* screen; assert( htk_screen ); screen = XtScreenOfObject( object_widget ); bool = XQueryPointer( XtDisplayOfObject( object_widget ), RootWindowOfScreen( screen ), &root_window, &child_window, &root_x, &root_y, &win_x, &win_y, &keys_buttons ); if (bool) { self->_rootX = root_x; self->_rootY = root_y; } else { Position root_pos_x, root_pos_y; int w_border, w_height, w_width; XtTranslateCoords( object_widget, 0, 0, &root_pos_x, &root_pos_y ); w_border = object_widget->core.border_width; w_height = object_widget->core.height; w_width = object_widget->core.width; self->_rootX = root_pos_x + (w_border * 2 + w_width ) / 2; self->_rootY = root_pos_y + (w_border * 2 + w_height) / 2; } if (XscTipHasValidTopic( self )) { _XscTipUpdate( self ); _XscScreenPopupTip( htk_screen ); if (self->popdownInterval) { _XscDisplayStartTimerTipPopdown( htk_display, self->object ); } if (_XscTextHasWidgetName( self->text )) { _XscDisplayStartTimerSelectName( htk_display, self->object ); } } }
[ "void", "_XscTipPopup", "(", "XscTip", "self", ")", "{", "Widget", "object_widget", "=", "_XscObjectGetWidget", "(", "self", "->", "object", ")", ";", "XscDisplay", "htk_display", "=", "_XscDisplayDeriveFromWidget", "(", "object_widget", ")", ";", "XscScreen", "htk_screen", "=", "_XscScreenDeriveFromWidget", "(", "object_widget", ")", ";", "Bool", "bool", ";", "Window", "root_window", ",", "child_window", ";", "int", "root_x", ",", "root_y", ",", "win_x", ",", "win_y", ";", "unsigned", "int", "keys_buttons", ";", "Screen", "*", "screen", ";", "assert", "(", "htk_screen", ")", ";", "screen", "=", "XtScreenOfObject", "(", "object_widget", ")", ";", "bool", "", "=", "XQueryPointer", "(", "XtDisplayOfObject", "(", "object_widget", ")", ",", "RootWindowOfScreen", "(", "screen", ")", ",", "&", "root_window", ",", "&", "child_window", ",", "&", "root_x", ",", "&", "root_y", ",", "&", "win_x", ",", "&", "win_y", ",", "&", "keys_buttons", ")", ";", "if", "(", "bool", ")", "{", "self", "->", "_rootX", "=", "root_x", ";", "self", "->", "_rootY", "=", "root_y", ";", "}", "else", "{", "Position", "root_pos_x", ",", "root_pos_y", ";", "int", "w_border", ",", "w_height", ",", "w_width", ";", "XtTranslateCoords", "(", "object_widget", ",", "0", ",", "0", ",", "&", "root_pos_x", ",", "&", "root_pos_y", ")", ";", "w_border", "=", "object_widget", "->", "core", ".", "border_width", ";", "w_height", "=", "object_widget", "->", "core", ".", "height", ";", "w_width", "=", "object_widget", "->", "core", ".", "width", ";", "self", "->", "_rootX", "=", "root_pos_x", "+", "(", "w_border", "*", "2", "+", "w_width", ")", "/", "2", ";", "self", "->", "_rootY", "=", "root_pos_y", "+", "(", "w_border", "*", "2", "+", "w_height", ")", "/", "2", ";", "}", "if", "(", "XscTipHasValidTopic", "(", "self", ")", ")", "{", "_XscTipUpdate", "(", "self", ")", ";", "_XscScreenPopupTip", "(", "htk_screen", ")", ";", "if", "(", "self", "->", "popdownInterval", ")", "{", "_XscDisplayStartTimerTipPopdown", "(", "htk_display", ",", "self", "->", "object", ")", ";", "}", "if", "(", "_XscTextHasWidgetName", "(", "self", "->", "text", ")", ")", "{", "_XscDisplayStartTimerSelectName", "(", "htk_display", ",", "self", "->", "object", ")", ";", "}", "}", "}" ]
This function handles the geometry managment and pop-up of a tip
[ "This", "function", "handles", "the", "geometry", "managment", "and", "pop", "-", "up", "of", "a", "tip" ]
[ "/*--------------\n -- Map the tip\n --------------*/", "/*---------------------------------------------\n -- If needed, install the auto pop-down timer\n ---------------------------------------------*/" ]
[ { "param": "self", "type": "XscTip" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": "XscTip", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f93fbc11f617d04088abc4b491ff21e299dee750
akivawerner/XscHelp
src/base/Context.c
[ "MIT" ]
C
_helpOnWidget
void
static void _helpOnWidget( Widget w, XtPointer cbd, int reason ) { /*-------------------------------------------------------------------- -- Don't bother doing anything if these basic, required context-help -- records are not defined --------------------------------------------------------------------*/ if (_helpBufferSize && _numHelpResources && _contextHelpProc) { /*-------------------------------------------------------------- -- Create a buffer to store the data; depth starts at 0 and is -- incremented each time a parent is examined for help. --------------------------------------------------------------*/ char* data = XtMalloc( _helpBufferSize ); int depth = 0; Boolean data_found = False; while (w) { XtPointer help_check; /*------------------------------------------ -- Try to find the context-help attributes ------------------------------------------*/ XtGetApplicationResources( w, (XtPointer) data, _helpResources, _numHelpResources, NULL, (Cardinal) 0 ); /*------------------------------------------------------------ -- Verify that the guaranteed pointer is, in fact, defined. -- If the pointer at this offset is equal to NULL, then, by -- definition, there is no context-sensitive help defined at -- this level and the search continues with the parent. ------------------------------------------------------------*/ help_check = (XtPointer)(data + _helpCheckOffset); if (*((char**)help_check) == NULL) { w = XtParent( w ); depth++; } else { data_found = True; break; } } /*------------------------------------------ -- Prepare and call the callback function! ------------------------------------------*/ if (w) { XscHelpContextCallbackStruct cb_data; cb_data.reason = reason; if (cbd) { XmAnyCallbackStruct* all_cb_data = (XmAnyCallbackStruct*) cbd; cb_data.event = all_cb_data->event; } else { cb_data.event = NULL; } cb_data.depth = depth; if (data_found) { cb_data.data = data; } else { cb_data.data = NULL; } _contextHelpProc( w, _contextHelpClientData, (XtPointer) &cb_data ); } XtFree( data ); } }
/*------------------------------------------------------------------------------ -- This function finds the best context-sensitive help associated with -- a widget and calls the Help ToolKit context-help callback function. ------------------------------------------------------------------------------*/
This function finds the best context-sensitive help associated with a widget and calls the Help ToolKit context-help callback function.
[ "This", "function", "finds", "the", "best", "context", "-", "sensitive", "help", "associated", "with", "a", "widget", "and", "calls", "the", "Help", "ToolKit", "context", "-", "help", "callback", "function", "." ]
static void _helpOnWidget( Widget w, XtPointer cbd, int reason ) { if (_helpBufferSize && _numHelpResources && _contextHelpProc) { char* data = XtMalloc( _helpBufferSize ); int depth = 0; Boolean data_found = False; while (w) { XtPointer help_check; XtGetApplicationResources( w, (XtPointer) data, _helpResources, _numHelpResources, NULL, (Cardinal) 0 ); help_check = (XtPointer)(data + _helpCheckOffset); if (*((char**)help_check) == NULL) { w = XtParent( w ); depth++; } else { data_found = True; break; } } if (w) { XscHelpContextCallbackStruct cb_data; cb_data.reason = reason; if (cbd) { XmAnyCallbackStruct* all_cb_data = (XmAnyCallbackStruct*) cbd; cb_data.event = all_cb_data->event; } else { cb_data.event = NULL; } cb_data.depth = depth; if (data_found) { cb_data.data = data; } else { cb_data.data = NULL; } _contextHelpProc( w, _contextHelpClientData, (XtPointer) &cb_data ); } XtFree( data ); } }
[ "static", "void", "_helpOnWidget", "(", "Widget", "w", ",", "XtPointer", "cbd", ",", "int", "reason", ")", "{", "if", "(", "_helpBufferSize", "&&", "_numHelpResources", "&&", "_contextHelpProc", ")", "{", "char", "*", "data", "=", "XtMalloc", "(", "_helpBufferSize", ")", ";", "int", "depth", "=", "0", ";", "Boolean", "data_found", "=", "False", ";", "while", "(", "w", ")", "{", "XtPointer", "help_check", ";", "XtGetApplicationResources", "(", "w", ",", "(", "XtPointer", ")", "data", ",", "_helpResources", ",", "_numHelpResources", ",", "NULL", ",", "(", "Cardinal", ")", "0", ")", ";", "help_check", "=", "(", "XtPointer", ")", "(", "data", "+", "_helpCheckOffset", ")", ";", "if", "(", "*", "(", "(", "char", "*", "*", ")", "help_check", ")", "==", "NULL", ")", "{", "w", "=", "XtParent", "(", "w", ")", ";", "depth", "++", ";", "}", "else", "{", "data_found", "=", "True", ";", "break", ";", "}", "}", "if", "(", "w", ")", "{", "XscHelpContextCallbackStruct", "cb_data", ";", "cb_data", ".", "reason", "=", "reason", ";", "if", "(", "cbd", ")", "{", "XmAnyCallbackStruct", "*", "all_cb_data", "=", "(", "XmAnyCallbackStruct", "*", ")", "cbd", ";", "cb_data", ".", "event", "=", "all_cb_data", "->", "event", ";", "}", "else", "{", "cb_data", ".", "event", "=", "NULL", ";", "}", "cb_data", ".", "depth", "=", "depth", ";", "if", "(", "data_found", ")", "{", "cb_data", ".", "data", "=", "data", ";", "}", "else", "{", "cb_data", ".", "data", "=", "NULL", ";", "}", "_contextHelpProc", "(", "w", ",", "_contextHelpClientData", ",", "(", "XtPointer", ")", "&", "cb_data", ")", ";", "}", "XtFree", "(", "data", ")", ";", "}", "}" ]
This function finds the best context-sensitive help associated with a widget and calls the Help ToolKit context-help callback function.
[ "This", "function", "finds", "the", "best", "context", "-", "sensitive", "help", "associated", "with", "a", "widget", "and", "calls", "the", "Help", "ToolKit", "context", "-", "help", "callback", "function", "." ]
[ "/*--------------------------------------------------------------------\n -- Don't bother doing anything if these basic, required context-help \n -- records are not defined\n --------------------------------------------------------------------*/", "/*--------------------------------------------------------------\n -- Create a buffer to store the data; depth starts at 0 and is \n -- incremented each time a parent is examined for help.\n --------------------------------------------------------------*/", "/*------------------------------------------\n -- Try to find the context-help attributes\n ------------------------------------------*/", "/*------------------------------------------------------------\n -- Verify that the guaranteed pointer is, in fact, defined.\n -- If the pointer at this offset is equal to NULL, then, by\n -- definition, there is no context-sensitive help defined at\n -- this level and the search continues with the parent.\n ------------------------------------------------------------*/", "/*------------------------------------------\n -- Prepare and call the callback function!\n ------------------------------------------*/" ]
[ { "param": "w", "type": "Widget" }, { "param": "cbd", "type": "XtPointer" }, { "param": "reason", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "w", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cbd", "type": "XtPointer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reason", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f93fbc11f617d04088abc4b491ff21e299dee750
akivawerner/XscHelp
src/base/Context.c
[ "MIT" ]
C
XscHelpContextInstall
void
void XscHelpContextInstall( XtResourceList resource_list, Cardinal num_resources, int size_of_help_struct, XtCallbackProc context_help_proc, XtPointer client_data ) { _helpBufferSize = size_of_help_struct; _helpResources = resource_list; _numHelpResources = num_resources; _contextHelpProc = context_help_proc; _contextHelpClientData = client_data; if (num_resources) { _helpCheckOffset = resource_list[ 0 ].resource_offset; } }
/*------------------------------------------------------------------------------ -- This function saves all the attributes needed to perform context-sensitive -- help lookups. ------------------------------------------------------------------------------*/
This function saves all the attributes needed to perform context-sensitive help lookups.
[ "This", "function", "saves", "all", "the", "attributes", "needed", "to", "perform", "context", "-", "sensitive", "help", "lookups", "." ]
void XscHelpContextInstall( XtResourceList resource_list, Cardinal num_resources, int size_of_help_struct, XtCallbackProc context_help_proc, XtPointer client_data ) { _helpBufferSize = size_of_help_struct; _helpResources = resource_list; _numHelpResources = num_resources; _contextHelpProc = context_help_proc; _contextHelpClientData = client_data; if (num_resources) { _helpCheckOffset = resource_list[ 0 ].resource_offset; } }
[ "void", "XscHelpContextInstall", "(", "XtResourceList", "resource_list", ",", "Cardinal", "num_resources", ",", "int", "size_of_help_struct", ",", "XtCallbackProc", "context_help_proc", ",", "XtPointer", "client_data", ")", "{", "_helpBufferSize", "=", "size_of_help_struct", ";", "_helpResources", "=", "resource_list", ";", "_numHelpResources", "=", "num_resources", ";", "_contextHelpProc", "=", "context_help_proc", ";", "_contextHelpClientData", "=", "client_data", ";", "if", "(", "num_resources", ")", "{", "_helpCheckOffset", "=", "resource_list", "[", "0", "]", ".", "resource_offset", ";", "}", "}" ]
This function saves all the attributes needed to perform context-sensitive help lookups.
[ "This", "function", "saves", "all", "the", "attributes", "needed", "to", "perform", "context", "-", "sensitive", "help", "lookups", "." ]
[]
[ { "param": "resource_list", "type": "XtResourceList" }, { "param": "num_resources", "type": "Cardinal" }, { "param": "size_of_help_struct", "type": "int" }, { "param": "context_help_proc", "type": "XtCallbackProc" }, { "param": "client_data", "type": "XtPointer" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "resource_list", "type": "XtResourceList", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "num_resources", "type": "Cardinal", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size_of_help_struct", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "context_help_proc", "type": "XtCallbackProc", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "client_data", "type": "XtPointer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f93fbc11f617d04088abc4b491ff21e299dee750
akivawerner/XscHelp
src/base/Context.c
[ "MIT" ]
C
XscHelpContextPickAndActivate
void
void XscHelpContextPickAndActivate( Widget widget, Cursor cursor, Boolean confine_to ) { XtAppContext app_context; Time event_time; Widget choosen_widget = NULL; event_time = XtLastTimestampProcessed( XtDisplayOfObject( widget ) ); /*------------------------------------ -- Grab the keyboard and the pointer ------------------------------------*/ XtGrabPointer( widget, False, ButtonPressMask, GrabModeAsync, GrabModeAsync, confine_to ? XtWindow( widget ) : None, cursor, event_time ); XtGrabKeyboard( widget, False, GrabModeAsync, GrabModeAsync, event_time ); app_context = XtWidgetToApplicationContext( widget ); while (True) { XEvent event; /*--------------------- -- Get the next event ---------------------*/ XtAppNextEvent( app_context, &event ); /*--------------------------------------------- -- Watch for button press and key press events ----------------------------------------------*/ if (event.type == ButtonPress || event.type == ButtonRelease) { /*------------------------------------------------ -- Determine if the button press was on a gadget ------------------------------------------------*/ choosen_widget = _XscHelpGetGadgetChild( widget, event.xbutton.x, event.xbutton.y ); if (!choosen_widget) { choosen_widget = widget; } event_time = event.xbutton.time; break; } else if (event.type == KeyPress || event.type == KeyRelease) { KeySym key_sym; /*---------------------------------------------------- -- If the key pressed was the Ecape key, then do not -- cancel the request without assigning a widget ----------------------------------------------------*/ key_sym = XLookupKeysym( &event.xkey, 0 ); if (key_sym != XK_Escape) { /*--------------------------------------------- -- Determine if the key press was on a gadget ---------------------------------------------*/ choosen_widget = _XscHelpGetGadgetChild( widget,event.xbutton.x,event.xbutton.y ); if (!choosen_widget) { choosen_widget = widget; } } event_time = event.xkey.time; break; } else { XtDispatchEvent( &event ); } } XtUngrabPointer ( widget, event_time ); XtUngrabKeyboard( widget, event_time ); /*------------------------------------------------- -- Request help on the specified widget or gadget -------------------------------------------------*/ if (choosen_widget) { _helpOnWidget( choosen_widget, NULL, XmCR_XSC_HELP_CONTEXT_GRAB_SELECT ); } }
/*------------------------------------------------------------------------------ -- This function allows an end-user to request context-sensitive help on a -- specific screen object. ------------------------------------------------------------------------------*/
This function allows an end-user to request context-sensitive help on a specific screen object.
[ "This", "function", "allows", "an", "end", "-", "user", "to", "request", "context", "-", "sensitive", "help", "on", "a", "specific", "screen", "object", "." ]
void XscHelpContextPickAndActivate( Widget widget, Cursor cursor, Boolean confine_to ) { XtAppContext app_context; Time event_time; Widget choosen_widget = NULL; event_time = XtLastTimestampProcessed( XtDisplayOfObject( widget ) ); XtGrabPointer( widget, False, ButtonPressMask, GrabModeAsync, GrabModeAsync, confine_to ? XtWindow( widget ) : None, cursor, event_time ); XtGrabKeyboard( widget, False, GrabModeAsync, GrabModeAsync, event_time ); app_context = XtWidgetToApplicationContext( widget ); while (True) { XEvent event; XtAppNextEvent( app_context, &event ); if (event.type == ButtonPress || event.type == ButtonRelease) { choosen_widget = _XscHelpGetGadgetChild( widget, event.xbutton.x, event.xbutton.y ); if (!choosen_widget) { choosen_widget = widget; } event_time = event.xbutton.time; break; } else if (event.type == KeyPress || event.type == KeyRelease) { KeySym key_sym; key_sym = XLookupKeysym( &event.xkey, 0 ); if (key_sym != XK_Escape) { choosen_widget = _XscHelpGetGadgetChild( widget,event.xbutton.x,event.xbutton.y ); if (!choosen_widget) { choosen_widget = widget; } } event_time = event.xkey.time; break; } else { XtDispatchEvent( &event ); } } XtUngrabPointer ( widget, event_time ); XtUngrabKeyboard( widget, event_time ); if (choosen_widget) { _helpOnWidget( choosen_widget, NULL, XmCR_XSC_HELP_CONTEXT_GRAB_SELECT ); } }
[ "void", "XscHelpContextPickAndActivate", "(", "Widget", "widget", ",", "Cursor", "cursor", ",", "Boolean", "confine_to", ")", "{", "XtAppContext", "app_context", ";", "Time", "event_time", ";", "Widget", "choosen_widget", "=", "NULL", ";", "event_time", "=", "XtLastTimestampProcessed", "(", "XtDisplayOfObject", "(", "widget", ")", ")", ";", "XtGrabPointer", "(", "widget", ",", "False", ",", "ButtonPressMask", ",", "GrabModeAsync", ",", "GrabModeAsync", ",", "confine_to", "?", "XtWindow", "(", "widget", ")", ":", "None", ",", "cursor", ",", "event_time", ")", ";", "XtGrabKeyboard", "(", "widget", ",", "False", ",", "GrabModeAsync", ",", "GrabModeAsync", ",", "event_time", ")", ";", "app_context", "=", "XtWidgetToApplicationContext", "(", "widget", ")", ";", "while", "(", "True", ")", "{", "XEvent", "event", ";", "XtAppNextEvent", "(", "app_context", ",", "&", "event", ")", ";", "if", "(", "event", ".", "type", "==", "ButtonPress", "||", "event", ".", "type", "==", "ButtonRelease", ")", "{", "choosen_widget", "=", "_XscHelpGetGadgetChild", "(", "widget", ",", "event", ".", "xbutton", ".", "x", ",", "event", ".", "xbutton", ".", "y", ")", ";", "if", "(", "!", "choosen_widget", ")", "{", "choosen_widget", "=", "widget", ";", "}", "event_time", "=", "event", ".", "xbutton", ".", "time", ";", "break", ";", "}", "else", "if", "(", "event", ".", "type", "==", "KeyPress", "||", "event", ".", "type", "==", "KeyRelease", ")", "{", "KeySym", "key_sym", ";", "key_sym", "=", "XLookupKeysym", "(", "&", "event", ".", "xkey", ",", "0", ")", ";", "if", "(", "key_sym", "!=", "XK_Escape", ")", "{", "choosen_widget", "=", "_XscHelpGetGadgetChild", "(", "widget", ",", "event", ".", "xbutton", ".", "x", ",", "event", ".", "xbutton", ".", "y", ")", ";", "if", "(", "!", "choosen_widget", ")", "{", "choosen_widget", "=", "widget", ";", "}", "}", "event_time", "=", "event", ".", "xkey", ".", "time", ";", "break", ";", "}", "else", "{", "XtDispatchEvent", "(", "&", "event", ")", ";", "}", "}", "XtUngrabPointer", "(", "widget", ",", "event_time", ")", ";", "XtUngrabKeyboard", "(", "widget", ",", "event_time", ")", ";", "if", "(", "choosen_widget", ")", "{", "_helpOnWidget", "(", "choosen_widget", ",", "NULL", ",", "XmCR_XSC_HELP_CONTEXT_GRAB_SELECT", ")", ";", "}", "}" ]
This function allows an end-user to request context-sensitive help on a specific screen object.
[ "This", "function", "allows", "an", "end", "-", "user", "to", "request", "context", "-", "sensitive", "help", "on", "a", "specific", "screen", "object", "." ]
[ "/*------------------------------------\n -- Grab the keyboard and the pointer\n ------------------------------------*/", "/*---------------------\n -- Get the next event\n ---------------------*/", "/*---------------------------------------------\n -- Watch for button press and key press events\n ----------------------------------------------*/", "/*------------------------------------------------\n -- Determine if the button press was on a gadget\n ------------------------------------------------*/", "/*----------------------------------------------------\n \t -- If the key pressed was the Ecape key, then do not\n \t -- cancel the request without assigning a widget\n \t ----------------------------------------------------*/", "/*---------------------------------------------\n -- Determine if the key press was on a gadget\n ---------------------------------------------*/", "/*-------------------------------------------------\n -- Request help on the specified widget or gadget\n -------------------------------------------------*/" ]
[ { "param": "widget", "type": "Widget" }, { "param": "cursor", "type": "Cursor" }, { "param": "confine_to", "type": "Boolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "widget", "type": "Widget", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cursor", "type": "Cursor", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "confine_to", "type": "Boolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
cb18beb563045f00f3de209beb5e1497a82bc576
nanovms/nanos
src/gdb/gdbutil.c
[ "Apache-2.0" ]
C
mem2hex
boolean
boolean mem2hex (string b, void *mem, int count) { int i; unsigned char ch; if (!validate_virtual(mem, count)) { rprintf ("validation failed\n"); return false; } for (i = 0; i < count; i++) { ch = *(unsigned char *)(mem++); print_number(b, (u64)ch, 16, 2); } return (true); }
/* convert the memory pointed to by mem into hex, placing result in buf */ /* return a pointer to the last char put in buf (null) */ /* If MAY_FAULT is non-zero, then we should set mem_err in response to a fault; if zero treat a fault like any other fault in the stub. */
convert the memory pointed to by mem into hex, placing result in buf return a pointer to the last char put in buf (null) If MAY_FAULT is non-zero, then we should set mem_err in response to a fault; if zero treat a fault like any other fault in the stub.
[ "convert", "the", "memory", "pointed", "to", "by", "mem", "into", "hex", "placing", "result", "in", "buf", "return", "a", "pointer", "to", "the", "last", "char", "put", "in", "buf", "(", "null", ")", "If", "MAY_FAULT", "is", "non", "-", "zero", "then", "we", "should", "set", "mem_err", "in", "response", "to", "a", "fault", ";", "if", "zero", "treat", "a", "fault", "like", "any", "other", "fault", "in", "the", "stub", "." ]
boolean mem2hex (string b, void *mem, int count) { int i; unsigned char ch; if (!validate_virtual(mem, count)) { rprintf ("validation failed\n"); return false; } for (i = 0; i < count; i++) { ch = *(unsigned char *)(mem++); print_number(b, (u64)ch, 16, 2); } return (true); }
[ "boolean", "mem2hex", "(", "string", "b", ",", "void", "*", "mem", ",", "int", "count", ")", "{", "int", "i", ";", "unsigned", "char", "ch", ";", "if", "(", "!", "validate_virtual", "(", "mem", ",", "count", ")", ")", "{", "rprintf", "(", "\"", "\\n", "\"", ")", ";", "return", "false", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "{", "ch", "=", "*", "(", "unsigned", "char", "*", ")", "(", "mem", "++", ")", ";", "print_number", "(", "b", ",", "(", "u64", ")", "ch", ",", "16", ",", "2", ")", ";", "}", "return", "(", "true", ")", ";", "}" ]
convert the memory pointed to by mem into hex, placing result in buf return a pointer to the last char put in buf (null) If MAY_FAULT is non-zero, then we should set mem_err in response to a fault; if zero treat a fault like any other fault in the stub.
[ "convert", "the", "memory", "pointed", "to", "by", "mem", "into", "hex", "placing", "result", "in", "buf", "return", "a", "pointer", "to", "the", "last", "char", "put", "in", "buf", "(", "null", ")", "If", "MAY_FAULT", "is", "non", "-", "zero", "then", "we", "should", "set", "mem_err", "in", "response", "to", "a", "fault", ";", "if", "zero", "treat", "a", "fault", "like", "any", "other", "fault", "in", "the", "stub", "." ]
[]
[ { "param": "b", "type": "string" }, { "param": "mem", "type": "void" }, { "param": "count", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "b", "type": "string", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mem", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "count", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8b4faf8b60c3ddc1f2015340777b264ce59b1b57
nanovms/nanos
src/aarch64/machine.h
[ "Apache-2.0" ]
C
__bswap16
u16
static inline __attribute__((always_inline)) u16 __bswap16(u16 _x) { return (u16)(_x << 8 | _x >> 8); }
/* These are defined as functions to avoid multiple evaluation of x. */
These are defined as functions to avoid multiple evaluation of x.
[ "These", "are", "defined", "as", "functions", "to", "avoid", "multiple", "evaluation", "of", "x", "." ]
static inline __attribute__((always_inline)) u16 __bswap16(u16 _x) { return (u16)(_x << 8 | _x >> 8); }
[ "static", "inline", "__attribute__", "(", "(", "always_inline", ")", ")", "u16", "__bswap16", "(", "u16", "_x", ")", "{", "return", "(", "u16", ")", "(", "_x", "<<", "8", "|", "_x", ">>", "8", ")", ";", "}" ]
These are defined as functions to avoid multiple evaluation of x.
[ "These", "are", "defined", "as", "functions", "to", "avoid", "multiple", "evaluation", "of", "x", "." ]
[]
[ { "param": "_x", "type": "u16" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "_x", "type": "u16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f5092300a3bdc25ac041249510895b0377ff8fff
nanovms/nanos
src/net/net.c
[ "Apache-2.0" ]
C
ifflags_to_netif
boolean
boolean ifflags_to_netif(struct netif *netif, u16 flags) { lwip_lock(); u16 diff = ifflags_from_netif(netif) ^ flags; if (diff & ~(IFF_UP | IFF_RUNNING)) { /* attempt to modify read-only flags */ lwip_unlock(); return false; } if (flags & IFF_UP) netif_set_up(netif); else netif_set_down(netif); if (flags & IFF_RUNNING) netif_set_link_up(netif); else netif_set_link_down(netif); lwip_unlock(); return true; }
/* do not call with lwIP lock held */
do not call with lwIP lock held
[ "do", "not", "call", "with", "lwIP", "lock", "held" ]
boolean ifflags_to_netif(struct netif *netif, u16 flags) { lwip_lock(); u16 diff = ifflags_from_netif(netif) ^ flags; if (diff & ~(IFF_UP | IFF_RUNNING)) { lwip_unlock(); return false; } if (flags & IFF_UP) netif_set_up(netif); else netif_set_down(netif); if (flags & IFF_RUNNING) netif_set_link_up(netif); else netif_set_link_down(netif); lwip_unlock(); return true; }
[ "boolean", "ifflags_to_netif", "(", "struct", "netif", "*", "netif", ",", "u16", "flags", ")", "{", "lwip_lock", "(", ")", ";", "u16", "diff", "=", "ifflags_from_netif", "(", "netif", ")", "^", "flags", ";", "if", "(", "diff", "&", "~", "(", "IFF_UP", "|", "IFF_RUNNING", ")", ")", "{", "lwip_unlock", "(", ")", ";", "return", "false", ";", "}", "if", "(", "flags", "&", "IFF_UP", ")", "netif_set_up", "(", "netif", ")", ";", "else", "netif_set_down", "(", "netif", ")", ";", "if", "(", "flags", "&", "IFF_RUNNING", ")", "netif_set_link_up", "(", "netif", ")", ";", "else", "netif_set_link_down", "(", "netif", ")", ";", "lwip_unlock", "(", ")", ";", "return", "true", ";", "}" ]
do not call with lwIP lock held
[ "do", "not", "call", "with", "lwIP", "lock", "held" ]
[ "/* attempt to modify read-only flags */" ]
[ { "param": "netif", "type": "struct netif" }, { "param": "flags", "type": "u16" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "netif", "type": "struct netif", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "flags", "type": "u16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6a24b3b783c0c23e5c9e5bb32b487be406bd7952
nanovms/nanos
src/unix/unix_internal.h
[ "Apache-2.0" ]
C
validate_user_memory
boolean
static inline boolean validate_user_memory(const void *p, bytes length, boolean write) { u64 v = u64_from_pointer(p); /* no zero page access */ if (v < PAGESIZE) return false; if (length >= USER_LIMIT) return false; return v < USER_LIMIT - length; }
/* This "validation" is just a simple limit check right now, but this could optionally expand to do more rigorous validation (e.g. vmap lookup or page table walk). We may also want to place attributes on user pointer arguments for use with a static analysis tool like Sparse. */
This "validation" is just a simple limit check right now, but this could optionally expand to do more rigorous validation . We may also want to place attributes on user pointer arguments for use with a static analysis tool like Sparse.
[ "This", "\"", "validation", "\"", "is", "just", "a", "simple", "limit", "check", "right", "now", "but", "this", "could", "optionally", "expand", "to", "do", "more", "rigorous", "validation", ".", "We", "may", "also", "want", "to", "place", "attributes", "on", "user", "pointer", "arguments", "for", "use", "with", "a", "static", "analysis", "tool", "like", "Sparse", "." ]
static inline boolean validate_user_memory(const void *p, bytes length, boolean write) { u64 v = u64_from_pointer(p); if (v < PAGESIZE) return false; if (length >= USER_LIMIT) return false; return v < USER_LIMIT - length; }
[ "static", "inline", "boolean", "validate_user_memory", "(", "const", "void", "*", "p", ",", "bytes", "length", ",", "boolean", "write", ")", "{", "u64", "v", "=", "u64_from_pointer", "(", "p", ")", ";", "if", "(", "v", "<", "PAGESIZE", ")", "return", "false", ";", "if", "(", "length", ">=", "USER_LIMIT", ")", "return", "false", ";", "return", "v", "<", "USER_LIMIT", "-", "length", ";", "}" ]
This "validation" is just a simple limit check right now, but this could optionally expand to do more rigorous validation (e.g.
[ "This", "\"", "validation", "\"", "is", "just", "a", "simple", "limit", "check", "right", "now", "but", "this", "could", "optionally", "expand", "to", "do", "more", "rigorous", "validation", "(", "e", ".", "g", "." ]
[ "/* no zero page access */" ]
[ { "param": "p", "type": "void" }, { "param": "length", "type": "bytes" }, { "param": "write", "type": "boolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "length", "type": "bytes", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "write", "type": "boolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6a24b3b783c0c23e5c9e5bb32b487be406bd7952
nanovms/nanos
src/unix/unix_internal.h
[ "Apache-2.0" ]
C
validate_process_memory
boolean
static inline boolean validate_process_memory(process p, const void *a, bytes length, boolean write) { u64 v = u64_from_pointer(a); return vmap_validate_range(p, irange(v, v + length)); }
/* XXX This should eventually be rolled into validate_user_memory */
XXX This should eventually be rolled into validate_user_memory
[ "XXX", "This", "should", "eventually", "be", "rolled", "into", "validate_user_memory" ]
static inline boolean validate_process_memory(process p, const void *a, bytes length, boolean write) { u64 v = u64_from_pointer(a); return vmap_validate_range(p, irange(v, v + length)); }
[ "static", "inline", "boolean", "validate_process_memory", "(", "process", "p", ",", "const", "void", "*", "a", ",", "bytes", "length", ",", "boolean", "write", ")", "{", "u64", "v", "=", "u64_from_pointer", "(", "a", ")", ";", "return", "vmap_validate_range", "(", "p", ",", "irange", "(", "v", ",", "v", "+", "length", ")", ")", ";", "}" ]
XXX This should eventually be rolled into validate_user_memory
[ "XXX", "This", "should", "eventually", "be", "rolled", "into", "validate_user_memory" ]
[]
[ { "param": "p", "type": "process" }, { "param": "a", "type": "void" }, { "param": "length", "type": "bytes" }, { "param": "write", "type": "boolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "process", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "a", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "length", "type": "bytes", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "write", "type": "boolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3f84bb56bcae56c7ff4d01b90f349f8257e46ce1
nanovms/nanos
src/kernel/kernel.h
[ "Apache-2.0" ]
C
spin_lock_2
void
static inline void spin_lock_2(spinlock l1, spinlock l2) { spin_lock(l1); while (!spin_try(l2)) { spin_unlock(l1); kern_pause(); spin_lock(l1); } }
/* Acquires 2 locks, guarding against potential deadlock resulting from a concurrent thread trying * to acquire the same locks. */
Acquires 2 locks, guarding against potential deadlock resulting from a concurrent thread trying to acquire the same locks.
[ "Acquires", "2", "locks", "guarding", "against", "potential", "deadlock", "resulting", "from", "a", "concurrent", "thread", "trying", "to", "acquire", "the", "same", "locks", "." ]
static inline void spin_lock_2(spinlock l1, spinlock l2) { spin_lock(l1); while (!spin_try(l2)) { spin_unlock(l1); kern_pause(); spin_lock(l1); } }
[ "static", "inline", "void", "spin_lock_2", "(", "spinlock", "l1", ",", "spinlock", "l2", ")", "{", "spin_lock", "(", "l1", ")", ";", "while", "(", "!", "spin_try", "(", "l2", ")", ")", "{", "spin_unlock", "(", "l1", ")", ";", "kern_pause", "(", ")", ";", "spin_lock", "(", "l1", ")", ";", "}", "}" ]
Acquires 2 locks, guarding against potential deadlock resulting from a concurrent thread trying to acquire the same locks.
[ "Acquires", "2", "locks", "guarding", "against", "potential", "deadlock", "resulting", "from", "a", "concurrent", "thread", "trying", "to", "acquire", "the", "same", "locks", "." ]
[]
[ { "param": "l1", "type": "spinlock" }, { "param": "l2", "type": "spinlock" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "l1", "type": "spinlock", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "l2", "type": "spinlock", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7e87309fb7182a6a9570580bd75bfa0fa1e25ee3
nanovms/nanos
src/unix/filesystem.c
[ "Apache-2.0" ]
C
fsfile_open_or_create
fsfile
fsfile fsfile_open_or_create(buffer file_path) { tuple file; fsfile fsf; filesystem fs = get_root_fs(); tuple root = filesystem_getroot(fs); char *file_str = buffer_to_cstring(file_path); int separator = buffer_strrchr(file_path, '/'); fs_status s; if (separator > 0) { file_str[separator] = '\0'; s = filesystem_mkdirpath(fs, 0, file_str, true); if ((s != FS_STATUS_OK) && (s != FS_STATUS_EXIST)) return 0; file_str[separator] = '/'; } s = filesystem_get_node(&fs, inode_from_tuple(root), file_str, true, true, false, &file, &fsf); if (s == FS_STATUS_OK) { filesystem_put_node(fs, file); return fsf; } return 0; }
/* file_path is treated as an absolute path. */
file_path is treated as an absolute path.
[ "file_path", "is", "treated", "as", "an", "absolute", "path", "." ]
fsfile fsfile_open_or_create(buffer file_path) { tuple file; fsfile fsf; filesystem fs = get_root_fs(); tuple root = filesystem_getroot(fs); char *file_str = buffer_to_cstring(file_path); int separator = buffer_strrchr(file_path, '/'); fs_status s; if (separator > 0) { file_str[separator] = '\0'; s = filesystem_mkdirpath(fs, 0, file_str, true); if ((s != FS_STATUS_OK) && (s != FS_STATUS_EXIST)) return 0; file_str[separator] = '/'; } s = filesystem_get_node(&fs, inode_from_tuple(root), file_str, true, true, false, &file, &fsf); if (s == FS_STATUS_OK) { filesystem_put_node(fs, file); return fsf; } return 0; }
[ "fsfile", "fsfile_open_or_create", "(", "buffer", "file_path", ")", "{", "tuple", "file", ";", "fsfile", "fsf", ";", "filesystem", "fs", "=", "get_root_fs", "(", ")", ";", "tuple", "root", "=", "filesystem_getroot", "(", "fs", ")", ";", "char", "*", "file_str", "=", "buffer_to_cstring", "(", "file_path", ")", ";", "int", "separator", "=", "buffer_strrchr", "(", "file_path", ",", "'", "'", ")", ";", "fs_status", "s", ";", "if", "(", "separator", ">", "0", ")", "{", "file_str", "[", "separator", "]", "=", "'", "\\0", "'", ";", "s", "=", "filesystem_mkdirpath", "(", "fs", ",", "0", ",", "file_str", ",", "true", ")", ";", "if", "(", "(", "s", "!=", "FS_STATUS_OK", ")", "&&", "(", "s", "!=", "FS_STATUS_EXIST", ")", ")", "return", "0", ";", "file_str", "[", "separator", "]", "=", "'", "'", ";", "}", "s", "=", "filesystem_get_node", "(", "&", "fs", ",", "inode_from_tuple", "(", "root", ")", ",", "file_str", ",", "true", ",", "true", ",", "false", ",", "&", "file", ",", "&", "fsf", ")", ";", "if", "(", "s", "==", "FS_STATUS_OK", ")", "{", "filesystem_put_node", "(", "fs", ",", "file", ")", ";", "return", "fsf", ";", "}", "return", "0", ";", "}" ]
file_path is treated as an absolute path.
[ "file_path", "is", "treated", "as", "an", "absolute", "path", "." ]
[]
[ { "param": "file_path", "type": "buffer" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "file_path", "type": "buffer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8af815546426ee79f9390fe8778bb1ba680f9b8e
nanovms/nanos
src/aws/ena/ena.c
[ "Apache-2.0" ]
C
ena_setup_tx_resources
int
static int ena_setup_tx_resources(struct ena_adapter *adapter, int qid) { struct ena_que *que = &adapter->que[qid]; struct ena_ring *tx_ring = que->tx_ring; int size, i; size = sizeof(struct ena_tx_buffer) * tx_ring->ring_size; tx_ring->tx_buffer_info = allocate_zero(adapter->general, size); if (unlikely(tx_ring->tx_buffer_info == INVALID_ADDRESS)) return ENA_COM_NO_MEM; size = sizeof(uint16_t) * tx_ring->ring_size; tx_ring->free_tx_ids = allocate_zero(adapter->general, size); if (unlikely(tx_ring->free_tx_ids == INVALID_ADDRESS)) goto err_buf_info_free; size = tx_ring->tx_max_header_size; tx_ring->push_buf_intermediate_buf = allocate_zero(adapter->general, size); if (unlikely(tx_ring->push_buf_intermediate_buf == INVALID_ADDRESS)) goto err_tx_ids_free; /* Req id stack for TX OOO completions */ for (i = 0; i < tx_ring->ring_size; i++) tx_ring->free_tx_ids[i] = i; /* Reset TX statistics. */ ena_reset_counters(&tx_ring->tx_stats, sizeof(tx_ring->tx_stats)); tx_ring->next_to_use = 0; tx_ring->next_to_clean = 0; tx_ring->acum_pkts = 0; ENA_RING_MTX_LOCK(tx_ring); ena_txring_flush(tx_ring); ENA_RING_MTX_UNLOCK(tx_ring); init_closure(&tx_ring->enqueue_task, ena_enqueue_task, tx_ring); tx_ring->running = true; return 0; err_tx_ids_free: deallocate(adapter->general, tx_ring->free_tx_ids, sizeof(uint16_t) * tx_ring->ring_size); tx_ring->free_tx_ids = NULL; err_buf_info_free: deallocate(adapter->general, tx_ring->tx_buffer_info, sizeof(struct ena_tx_buffer) * tx_ring->ring_size); tx_ring->tx_buffer_info = NULL; return ENA_COM_NO_MEM; }
/** * ena_setup_tx_resources - allocate Tx resources (Descriptors) * @adapter: network interface device structure * @qid: queue index * * Returns 0 on success, otherwise on failure. **/
allocate Tx resources (Descriptors) @adapter: network interface device structure @qid: queue index Returns 0 on success, otherwise on failure.
[ "allocate", "Tx", "resources", "(", "Descriptors", ")", "@adapter", ":", "network", "interface", "device", "structure", "@qid", ":", "queue", "index", "Returns", "0", "on", "success", "otherwise", "on", "failure", "." ]
static int ena_setup_tx_resources(struct ena_adapter *adapter, int qid) { struct ena_que *que = &adapter->que[qid]; struct ena_ring *tx_ring = que->tx_ring; int size, i; size = sizeof(struct ena_tx_buffer) * tx_ring->ring_size; tx_ring->tx_buffer_info = allocate_zero(adapter->general, size); if (unlikely(tx_ring->tx_buffer_info == INVALID_ADDRESS)) return ENA_COM_NO_MEM; size = sizeof(uint16_t) * tx_ring->ring_size; tx_ring->free_tx_ids = allocate_zero(adapter->general, size); if (unlikely(tx_ring->free_tx_ids == INVALID_ADDRESS)) goto err_buf_info_free; size = tx_ring->tx_max_header_size; tx_ring->push_buf_intermediate_buf = allocate_zero(adapter->general, size); if (unlikely(tx_ring->push_buf_intermediate_buf == INVALID_ADDRESS)) goto err_tx_ids_free; for (i = 0; i < tx_ring->ring_size; i++) tx_ring->free_tx_ids[i] = i; ena_reset_counters(&tx_ring->tx_stats, sizeof(tx_ring->tx_stats)); tx_ring->next_to_use = 0; tx_ring->next_to_clean = 0; tx_ring->acum_pkts = 0; ENA_RING_MTX_LOCK(tx_ring); ena_txring_flush(tx_ring); ENA_RING_MTX_UNLOCK(tx_ring); init_closure(&tx_ring->enqueue_task, ena_enqueue_task, tx_ring); tx_ring->running = true; return 0; err_tx_ids_free: deallocate(adapter->general, tx_ring->free_tx_ids, sizeof(uint16_t) * tx_ring->ring_size); tx_ring->free_tx_ids = NULL; err_buf_info_free: deallocate(adapter->general, tx_ring->tx_buffer_info, sizeof(struct ena_tx_buffer) * tx_ring->ring_size); tx_ring->tx_buffer_info = NULL; return ENA_COM_NO_MEM; }
[ "static", "int", "ena_setup_tx_resources", "(", "struct", "ena_adapter", "*", "adapter", ",", "int", "qid", ")", "{", "struct", "ena_que", "*", "que", "=", "&", "adapter", "->", "que", "[", "qid", "]", ";", "struct", "ena_ring", "*", "tx_ring", "=", "que", "->", "tx_ring", ";", "int", "size", ",", "i", ";", "size", "=", "sizeof", "(", "struct", "ena_tx_buffer", ")", "*", "tx_ring", "->", "ring_size", ";", "tx_ring", "->", "tx_buffer_info", "=", "allocate_zero", "(", "adapter", "->", "general", ",", "size", ")", ";", "if", "(", "unlikely", "(", "tx_ring", "->", "tx_buffer_info", "==", "INVALID_ADDRESS", ")", ")", "return", "ENA_COM_NO_MEM", ";", "size", "=", "sizeof", "(", "uint16_t", ")", "*", "tx_ring", "->", "ring_size", ";", "tx_ring", "->", "free_tx_ids", "=", "allocate_zero", "(", "adapter", "->", "general", ",", "size", ")", ";", "if", "(", "unlikely", "(", "tx_ring", "->", "free_tx_ids", "==", "INVALID_ADDRESS", ")", ")", "goto", "err_buf_info_free", ";", "size", "=", "tx_ring", "->", "tx_max_header_size", ";", "tx_ring", "->", "push_buf_intermediate_buf", "=", "allocate_zero", "(", "adapter", "->", "general", ",", "size", ")", ";", "if", "(", "unlikely", "(", "tx_ring", "->", "push_buf_intermediate_buf", "==", "INVALID_ADDRESS", ")", ")", "goto", "err_tx_ids_free", ";", "for", "(", "i", "=", "0", ";", "i", "<", "tx_ring", "->", "ring_size", ";", "i", "++", ")", "tx_ring", "->", "free_tx_ids", "[", "i", "]", "=", "i", ";", "ena_reset_counters", "(", "&", "tx_ring", "->", "tx_stats", ",", "sizeof", "(", "tx_ring", "->", "tx_stats", ")", ")", ";", "tx_ring", "->", "next_to_use", "=", "0", ";", "tx_ring", "->", "next_to_clean", "=", "0", ";", "tx_ring", "->", "acum_pkts", "=", "0", ";", "ENA_RING_MTX_LOCK", "(", "tx_ring", ")", ";", "ena_txring_flush", "(", "tx_ring", ")", ";", "ENA_RING_MTX_UNLOCK", "(", "tx_ring", ")", ";", "init_closure", "(", "&", "tx_ring", "->", "enqueue_task", ",", "ena_enqueue_task", ",", "tx_ring", ")", ";", "tx_ring", "->", "running", "=", "true", ";", "return", "0", ";", "err_tx_ids_free", ":", "deallocate", "(", "adapter", "->", "general", ",", "tx_ring", "->", "free_tx_ids", ",", "sizeof", "(", "uint16_t", ")", "*", "tx_ring", "->", "ring_size", ")", ";", "tx_ring", "->", "free_tx_ids", "=", "NULL", ";", "err_buf_info_free", ":", "deallocate", "(", "adapter", "->", "general", ",", "tx_ring", "->", "tx_buffer_info", ",", "sizeof", "(", "struct", "ena_tx_buffer", ")", "*", "tx_ring", "->", "ring_size", ")", ";", "tx_ring", "->", "tx_buffer_info", "=", "NULL", ";", "return", "ENA_COM_NO_MEM", ";", "}" ]
ena_setup_tx_resources - allocate Tx resources (Descriptors) @adapter: network interface device structure @qid: queue index
[ "ena_setup_tx_resources", "-", "allocate", "Tx", "resources", "(", "Descriptors", ")", "@adapter", ":", "network", "interface", "device", "structure", "@qid", ":", "queue", "index" ]
[ "/* Req id stack for TX OOO completions */", "/* Reset TX statistics. */" ]
[ { "param": "adapter", "type": "struct ena_adapter" }, { "param": "qid", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "adapter", "type": "struct ena_adapter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "qid", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8af815546426ee79f9390fe8778bb1ba680f9b8e
nanovms/nanos
src/aws/ena/ena.c
[ "Apache-2.0" ]
C
ena_free_tx_resources
void
static void ena_free_tx_resources(struct ena_adapter *adapter, int qid) { struct ena_ring *tx_ring = &adapter->tx_ring[qid]; ENA_RING_MTX_LOCK(tx_ring); /* Flush buffer ring */ ena_txring_flush(tx_ring); lwip_lock(); for (int i = 0; i < tx_ring->ring_size; i++) { pbuf_free(tx_ring->tx_buffer_info[i].mbuf); tx_ring->tx_buffer_info[i].mbuf = NULL; } lwip_unlock(); ENA_RING_MTX_UNLOCK(tx_ring); /* And free allocated memory. */ deallocate(adapter->general, tx_ring->tx_buffer_info, sizeof(struct ena_tx_buffer) * tx_ring->ring_size); tx_ring->tx_buffer_info = NULL; deallocate(adapter->general, tx_ring->free_tx_ids, sizeof(uint16_t) * tx_ring->ring_size); tx_ring->free_tx_ids = NULL; deallocate(adapter->general, tx_ring->push_buf_intermediate_buf, tx_ring->tx_max_header_size); tx_ring->push_buf_intermediate_buf = NULL; }
/** * ena_free_tx_resources - Free Tx Resources per Queue * @adapter: network interface device structure * @qid: queue index * * Free all transmit software resources **/
Free Tx Resources per Queue @adapter: network interface device structure @qid: queue index Free all transmit software resources
[ "Free", "Tx", "Resources", "per", "Queue", "@adapter", ":", "network", "interface", "device", "structure", "@qid", ":", "queue", "index", "Free", "all", "transmit", "software", "resources" ]
static void ena_free_tx_resources(struct ena_adapter *adapter, int qid) { struct ena_ring *tx_ring = &adapter->tx_ring[qid]; ENA_RING_MTX_LOCK(tx_ring); ena_txring_flush(tx_ring); lwip_lock(); for (int i = 0; i < tx_ring->ring_size; i++) { pbuf_free(tx_ring->tx_buffer_info[i].mbuf); tx_ring->tx_buffer_info[i].mbuf = NULL; } lwip_unlock(); ENA_RING_MTX_UNLOCK(tx_ring); deallocate(adapter->general, tx_ring->tx_buffer_info, sizeof(struct ena_tx_buffer) * tx_ring->ring_size); tx_ring->tx_buffer_info = NULL; deallocate(adapter->general, tx_ring->free_tx_ids, sizeof(uint16_t) * tx_ring->ring_size); tx_ring->free_tx_ids = NULL; deallocate(adapter->general, tx_ring->push_buf_intermediate_buf, tx_ring->tx_max_header_size); tx_ring->push_buf_intermediate_buf = NULL; }
[ "static", "void", "ena_free_tx_resources", "(", "struct", "ena_adapter", "*", "adapter", ",", "int", "qid", ")", "{", "struct", "ena_ring", "*", "tx_ring", "=", "&", "adapter", "->", "tx_ring", "[", "qid", "]", ";", "ENA_RING_MTX_LOCK", "(", "tx_ring", ")", ";", "ena_txring_flush", "(", "tx_ring", ")", ";", "lwip_lock", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "tx_ring", "->", "ring_size", ";", "i", "++", ")", "{", "pbuf_free", "(", "tx_ring", "->", "tx_buffer_info", "[", "i", "]", ".", "mbuf", ")", ";", "tx_ring", "->", "tx_buffer_info", "[", "i", "]", ".", "mbuf", "=", "NULL", ";", "}", "lwip_unlock", "(", ")", ";", "ENA_RING_MTX_UNLOCK", "(", "tx_ring", ")", ";", "deallocate", "(", "adapter", "->", "general", ",", "tx_ring", "->", "tx_buffer_info", ",", "sizeof", "(", "struct", "ena_tx_buffer", ")", "*", "tx_ring", "->", "ring_size", ")", ";", "tx_ring", "->", "tx_buffer_info", "=", "NULL", ";", "deallocate", "(", "adapter", "->", "general", ",", "tx_ring", "->", "free_tx_ids", ",", "sizeof", "(", "uint16_t", ")", "*", "tx_ring", "->", "ring_size", ")", ";", "tx_ring", "->", "free_tx_ids", "=", "NULL", ";", "deallocate", "(", "adapter", "->", "general", ",", "tx_ring", "->", "push_buf_intermediate_buf", ",", "tx_ring", "->", "tx_max_header_size", ")", ";", "tx_ring", "->", "push_buf_intermediate_buf", "=", "NULL", ";", "}" ]
ena_free_tx_resources - Free Tx Resources per Queue @adapter: network interface device structure @qid: queue index
[ "ena_free_tx_resources", "-", "Free", "Tx", "Resources", "per", "Queue", "@adapter", ":", "network", "interface", "device", "structure", "@qid", ":", "queue", "index" ]
[ "/* Flush buffer ring */", "/* And free allocated memory. */" ]
[ { "param": "adapter", "type": "struct ena_adapter" }, { "param": "qid", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "adapter", "type": "struct ena_adapter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "qid", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8af815546426ee79f9390fe8778bb1ba680f9b8e
nanovms/nanos
src/aws/ena/ena.c
[ "Apache-2.0" ]
C
ena_setup_all_tx_resources
int
static int ena_setup_all_tx_resources(struct ena_adapter *adapter) { int i, rc; for (i = 0; i < adapter->num_io_queues; i++) { rc = ena_setup_tx_resources(adapter, i); if (rc != 0) { device_printf(adapter->pdev, "Allocation for Tx Queue %d failed\n", i); goto err_setup_tx; } } return 0; err_setup_tx: /* Rewind the index freeing the rings as we go */ while (i--) ena_free_tx_resources(adapter, i); return rc; }
/** * ena_setup_all_tx_resources - allocate all queues Tx resources * @adapter: network interface device structure * * Returns 0 on success, otherwise on failure. **/
allocate all queues Tx resources @adapter: network interface device structure Returns 0 on success, otherwise on failure.
[ "allocate", "all", "queues", "Tx", "resources", "@adapter", ":", "network", "interface", "device", "structure", "Returns", "0", "on", "success", "otherwise", "on", "failure", "." ]
static int ena_setup_all_tx_resources(struct ena_adapter *adapter) { int i, rc; for (i = 0; i < adapter->num_io_queues; i++) { rc = ena_setup_tx_resources(adapter, i); if (rc != 0) { device_printf(adapter->pdev, "Allocation for Tx Queue %d failed\n", i); goto err_setup_tx; } } return 0; err_setup_tx: while (i--) ena_free_tx_resources(adapter, i); return rc; }
[ "static", "int", "ena_setup_all_tx_resources", "(", "struct", "ena_adapter", "*", "adapter", ")", "{", "int", "i", ",", "rc", ";", "for", "(", "i", "=", "0", ";", "i", "<", "adapter", "->", "num_io_queues", ";", "i", "++", ")", "{", "rc", "=", "ena_setup_tx_resources", "(", "adapter", ",", "i", ")", ";", "if", "(", "rc", "!=", "0", ")", "{", "device_printf", "(", "adapter", "->", "pdev", ",", "\"", "\\n", "\"", ",", "i", ")", ";", "goto", "err_setup_tx", ";", "}", "}", "return", "0", ";", "err_setup_tx", ":", "while", "(", "i", "--", ")", "ena_free_tx_resources", "(", "adapter", ",", "i", ")", ";", "return", "rc", ";", "}" ]
ena_setup_all_tx_resources - allocate all queues Tx resources @adapter: network interface device structure
[ "ena_setup_all_tx_resources", "-", "allocate", "all", "queues", "Tx", "resources", "@adapter", ":", "network", "interface", "device", "structure" ]
[ "/* Rewind the index freeing the rings as we go */" ]
[ { "param": "adapter", "type": "struct ena_adapter" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "adapter", "type": "struct ena_adapter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8af815546426ee79f9390fe8778bb1ba680f9b8e
nanovms/nanos
src/aws/ena/ena.c
[ "Apache-2.0" ]
C
ena_free_all_tx_resources
void
static void ena_free_all_tx_resources(struct ena_adapter *adapter) { int i; for (i = 0; i < adapter->num_io_queues; i++) ena_free_tx_resources(adapter, i); }
/** * ena_free_all_tx_resources - Free Tx Resources for All Queues * @adapter: network interface device structure * * Free all transmit software resources **/
Free Tx Resources for All Queues @adapter: network interface device structure Free all transmit software resources
[ "Free", "Tx", "Resources", "for", "All", "Queues", "@adapter", ":", "network", "interface", "device", "structure", "Free", "all", "transmit", "software", "resources" ]
static void ena_free_all_tx_resources(struct ena_adapter *adapter) { int i; for (i = 0; i < adapter->num_io_queues; i++) ena_free_tx_resources(adapter, i); }
[ "static", "void", "ena_free_all_tx_resources", "(", "struct", "ena_adapter", "*", "adapter", ")", "{", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "adapter", "->", "num_io_queues", ";", "i", "++", ")", "ena_free_tx_resources", "(", "adapter", ",", "i", ")", ";", "}" ]
ena_free_all_tx_resources - Free Tx Resources for All Queues @adapter: network interface device structure
[ "ena_free_all_tx_resources", "-", "Free", "Tx", "Resources", "for", "All", "Queues", "@adapter", ":", "network", "interface", "device", "structure" ]
[]
[ { "param": "adapter", "type": "struct ena_adapter" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "adapter", "type": "struct ena_adapter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8af815546426ee79f9390fe8778bb1ba680f9b8e
nanovms/nanos
src/aws/ena/ena.c
[ "Apache-2.0" ]
C
ena_setup_rx_resources
int
static int ena_setup_rx_resources(struct ena_adapter *adapter, unsigned int qid) { struct ena_que *que = &adapter->que[qid]; struct ena_ring *rx_ring = que->rx_ring; int size, i; size = sizeof(struct ena_rx_buffer) * rx_ring->ring_size; /* * Alloc extra element so in rx path * we can always prefetch rx_info + 1 */ size += sizeof(struct ena_rx_buffer); rx_ring->rx_buffer_info = allocate_zero(adapter->general, size); if (rx_ring->rx_buffer_info == INVALID_ADDRESS) return ENA_COM_NO_MEM; rx_ring->free_rx_ids = allocate_zero(adapter->general, sizeof(uint16_t) * rx_ring->ring_size); if (rx_ring->free_rx_ids == INVALID_ADDRESS) goto err_free_binfo; for (i = 0; i < rx_ring->ring_size; i++) rx_ring->free_rx_ids[i] = i; /* Reset RX statistics. */ ena_reset_counters(&rx_ring->rx_stats, sizeof(rx_ring->rx_stats)); rx_ring->next_to_clean = 0; rx_ring->next_to_use = 0; return 0; err_free_binfo: deallocate(adapter->general, rx_ring->rx_buffer_info, size); rx_ring->rx_buffer_info = NULL; return ENA_COM_NO_MEM; }
/** * ena_setup_rx_resources - allocate Rx resources (Descriptors) * @adapter: network interface device structure * @qid: queue index * * Returns 0 on success, otherwise on failure. **/
allocate Rx resources (Descriptors) @adapter: network interface device structure @qid: queue index Returns 0 on success, otherwise on failure.
[ "allocate", "Rx", "resources", "(", "Descriptors", ")", "@adapter", ":", "network", "interface", "device", "structure", "@qid", ":", "queue", "index", "Returns", "0", "on", "success", "otherwise", "on", "failure", "." ]
static int ena_setup_rx_resources(struct ena_adapter *adapter, unsigned int qid) { struct ena_que *que = &adapter->que[qid]; struct ena_ring *rx_ring = que->rx_ring; int size, i; size = sizeof(struct ena_rx_buffer) * rx_ring->ring_size; size += sizeof(struct ena_rx_buffer); rx_ring->rx_buffer_info = allocate_zero(adapter->general, size); if (rx_ring->rx_buffer_info == INVALID_ADDRESS) return ENA_COM_NO_MEM; rx_ring->free_rx_ids = allocate_zero(adapter->general, sizeof(uint16_t) * rx_ring->ring_size); if (rx_ring->free_rx_ids == INVALID_ADDRESS) goto err_free_binfo; for (i = 0; i < rx_ring->ring_size; i++) rx_ring->free_rx_ids[i] = i; ena_reset_counters(&rx_ring->rx_stats, sizeof(rx_ring->rx_stats)); rx_ring->next_to_clean = 0; rx_ring->next_to_use = 0; return 0; err_free_binfo: deallocate(adapter->general, rx_ring->rx_buffer_info, size); rx_ring->rx_buffer_info = NULL; return ENA_COM_NO_MEM; }
[ "static", "int", "ena_setup_rx_resources", "(", "struct", "ena_adapter", "*", "adapter", ",", "unsigned", "int", "qid", ")", "{", "struct", "ena_que", "*", "que", "=", "&", "adapter", "->", "que", "[", "qid", "]", ";", "struct", "ena_ring", "*", "rx_ring", "=", "que", "->", "rx_ring", ";", "int", "size", ",", "i", ";", "size", "=", "sizeof", "(", "struct", "ena_rx_buffer", ")", "*", "rx_ring", "->", "ring_size", ";", "size", "+=", "sizeof", "(", "struct", "ena_rx_buffer", ")", ";", "rx_ring", "->", "rx_buffer_info", "=", "allocate_zero", "(", "adapter", "->", "general", ",", "size", ")", ";", "if", "(", "rx_ring", "->", "rx_buffer_info", "==", "INVALID_ADDRESS", ")", "return", "ENA_COM_NO_MEM", ";", "rx_ring", "->", "free_rx_ids", "=", "allocate_zero", "(", "adapter", "->", "general", ",", "sizeof", "(", "uint16_t", ")", "*", "rx_ring", "->", "ring_size", ")", ";", "if", "(", "rx_ring", "->", "free_rx_ids", "==", "INVALID_ADDRESS", ")", "goto", "err_free_binfo", ";", "for", "(", "i", "=", "0", ";", "i", "<", "rx_ring", "->", "ring_size", ";", "i", "++", ")", "rx_ring", "->", "free_rx_ids", "[", "i", "]", "=", "i", ";", "ena_reset_counters", "(", "&", "rx_ring", "->", "rx_stats", ",", "sizeof", "(", "rx_ring", "->", "rx_stats", ")", ")", ";", "rx_ring", "->", "next_to_clean", "=", "0", ";", "rx_ring", "->", "next_to_use", "=", "0", ";", "return", "0", ";", "err_free_binfo", ":", "deallocate", "(", "adapter", "->", "general", ",", "rx_ring", "->", "rx_buffer_info", ",", "size", ")", ";", "rx_ring", "->", "rx_buffer_info", "=", "NULL", ";", "return", "ENA_COM_NO_MEM", ";", "}" ]
ena_setup_rx_resources - allocate Rx resources (Descriptors) @adapter: network interface device structure @qid: queue index
[ "ena_setup_rx_resources", "-", "allocate", "Rx", "resources", "(", "Descriptors", ")", "@adapter", ":", "network", "interface", "device", "structure", "@qid", ":", "queue", "index" ]
[ "/*\n * Alloc extra element so in rx path\n * we can always prefetch rx_info + 1\n */", "/* Reset RX statistics. */" ]
[ { "param": "adapter", "type": "struct ena_adapter" }, { "param": "qid", "type": "unsigned int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "adapter", "type": "struct ena_adapter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "qid", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8af815546426ee79f9390fe8778bb1ba680f9b8e
nanovms/nanos
src/aws/ena/ena.c
[ "Apache-2.0" ]
C
ena_free_rx_resources
void
static void ena_free_rx_resources(struct ena_adapter *adapter, unsigned int qid) { struct ena_ring *rx_ring = &adapter->rx_ring[qid]; lwip_lock(); for (int i = 0; i < rx_ring->ring_size; i++) { pbuf_free(rx_ring->rx_buffer_info[i].mbuf); rx_ring->rx_buffer_info[i].mbuf = NULL; } lwip_unlock(); /* free allocated memory */ deallocate(adapter->general, rx_ring->rx_buffer_info, sizeof(struct ena_rx_buffer) * (rx_ring->ring_size + 1)); rx_ring->rx_buffer_info = NULL; deallocate(adapter->general, rx_ring->free_rx_ids, sizeof(uint16_t) * rx_ring->ring_size); rx_ring->free_rx_ids = NULL; }
/** * ena_free_rx_resources - Free Rx Resources * @adapter: network interface device structure * @qid: queue index * * Free all receive software resources **/
Free Rx Resources @adapter: network interface device structure @qid: queue index Free all receive software resources
[ "Free", "Rx", "Resources", "@adapter", ":", "network", "interface", "device", "structure", "@qid", ":", "queue", "index", "Free", "all", "receive", "software", "resources" ]
static void ena_free_rx_resources(struct ena_adapter *adapter, unsigned int qid) { struct ena_ring *rx_ring = &adapter->rx_ring[qid]; lwip_lock(); for (int i = 0; i < rx_ring->ring_size; i++) { pbuf_free(rx_ring->rx_buffer_info[i].mbuf); rx_ring->rx_buffer_info[i].mbuf = NULL; } lwip_unlock(); deallocate(adapter->general, rx_ring->rx_buffer_info, sizeof(struct ena_rx_buffer) * (rx_ring->ring_size + 1)); rx_ring->rx_buffer_info = NULL; deallocate(adapter->general, rx_ring->free_rx_ids, sizeof(uint16_t) * rx_ring->ring_size); rx_ring->free_rx_ids = NULL; }
[ "static", "void", "ena_free_rx_resources", "(", "struct", "ena_adapter", "*", "adapter", ",", "unsigned", "int", "qid", ")", "{", "struct", "ena_ring", "*", "rx_ring", "=", "&", "adapter", "->", "rx_ring", "[", "qid", "]", ";", "lwip_lock", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "rx_ring", "->", "ring_size", ";", "i", "++", ")", "{", "pbuf_free", "(", "rx_ring", "->", "rx_buffer_info", "[", "i", "]", ".", "mbuf", ")", ";", "rx_ring", "->", "rx_buffer_info", "[", "i", "]", ".", "mbuf", "=", "NULL", ";", "}", "lwip_unlock", "(", ")", ";", "deallocate", "(", "adapter", "->", "general", ",", "rx_ring", "->", "rx_buffer_info", ",", "sizeof", "(", "struct", "ena_rx_buffer", ")", "*", "(", "rx_ring", "->", "ring_size", "+", "1", ")", ")", ";", "rx_ring", "->", "rx_buffer_info", "=", "NULL", ";", "deallocate", "(", "adapter", "->", "general", ",", "rx_ring", "->", "free_rx_ids", ",", "sizeof", "(", "uint16_t", ")", "*", "rx_ring", "->", "ring_size", ")", ";", "rx_ring", "->", "free_rx_ids", "=", "NULL", ";", "}" ]
ena_free_rx_resources - Free Rx Resources @adapter: network interface device structure @qid: queue index
[ "ena_free_rx_resources", "-", "Free", "Rx", "Resources", "@adapter", ":", "network", "interface", "device", "structure", "@qid", ":", "queue", "index" ]
[ "/* free allocated memory */" ]
[ { "param": "adapter", "type": "struct ena_adapter" }, { "param": "qid", "type": "unsigned int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "adapter", "type": "struct ena_adapter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "qid", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8af815546426ee79f9390fe8778bb1ba680f9b8e
nanovms/nanos
src/aws/ena/ena.c
[ "Apache-2.0" ]
C
ena_setup_all_rx_resources
int
static int ena_setup_all_rx_resources(struct ena_adapter *adapter) { int i, rc = 0; for (i = 0; i < adapter->num_io_queues; i++) { rc = ena_setup_rx_resources (adapter, i); if (rc != 0) { device_printf(adapter->pdev, "Allocation for Rx Queue %d failed\n", i); goto err_setup_rx; } } return 0; err_setup_rx: /* rewind the index freeing the rings as we go */ while (i--) ena_free_rx_resources (adapter, i); return rc; }
/** * ena_setup_all_rx_resources - allocate all queues Rx resources * @adapter: network interface device structure * * Returns 0 on success, otherwise on failure. **/
allocate all queues Rx resources @adapter: network interface device structure Returns 0 on success, otherwise on failure.
[ "allocate", "all", "queues", "Rx", "resources", "@adapter", ":", "network", "interface", "device", "structure", "Returns", "0", "on", "success", "otherwise", "on", "failure", "." ]
static int ena_setup_all_rx_resources(struct ena_adapter *adapter) { int i, rc = 0; for (i = 0; i < adapter->num_io_queues; i++) { rc = ena_setup_rx_resources (adapter, i); if (rc != 0) { device_printf(adapter->pdev, "Allocation for Rx Queue %d failed\n", i); goto err_setup_rx; } } return 0; err_setup_rx: while (i--) ena_free_rx_resources (adapter, i); return rc; }
[ "static", "int", "ena_setup_all_rx_resources", "(", "struct", "ena_adapter", "*", "adapter", ")", "{", "int", "i", ",", "rc", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "adapter", "->", "num_io_queues", ";", "i", "++", ")", "{", "rc", "=", "ena_setup_rx_resources", "(", "adapter", ",", "i", ")", ";", "if", "(", "rc", "!=", "0", ")", "{", "device_printf", "(", "adapter", "->", "pdev", ",", "\"", "\\n", "\"", ",", "i", ")", ";", "goto", "err_setup_rx", ";", "}", "}", "return", "0", ";", "err_setup_rx", ":", "while", "(", "i", "--", ")", "ena_free_rx_resources", "(", "adapter", ",", "i", ")", ";", "return", "rc", ";", "}" ]
ena_setup_all_rx_resources - allocate all queues Rx resources @adapter: network interface device structure
[ "ena_setup_all_rx_resources", "-", "allocate", "all", "queues", "Rx", "resources", "@adapter", ":", "network", "interface", "device", "structure" ]
[ "/* rewind the index freeing the rings as we go */" ]
[ { "param": "adapter", "type": "struct ena_adapter" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "adapter", "type": "struct ena_adapter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8af815546426ee79f9390fe8778bb1ba680f9b8e
nanovms/nanos
src/aws/ena/ena.c
[ "Apache-2.0" ]
C
ena_free_all_rx_resources
void
static void ena_free_all_rx_resources(struct ena_adapter *adapter) { int i; for (i = 0; i < adapter->num_io_queues; i++) ena_free_rx_resources(adapter, i); }
/** * ena_free_all_rx_resources - Free Rx resources for all queues * @adapter: network interface device structure * * Free all receive software resources **/
Free Rx resources for all queues @adapter: network interface device structure Free all receive software resources
[ "Free", "Rx", "resources", "for", "all", "queues", "@adapter", ":", "network", "interface", "device", "structure", "Free", "all", "receive", "software", "resources" ]
static void ena_free_all_rx_resources(struct ena_adapter *adapter) { int i; for (i = 0; i < adapter->num_io_queues; i++) ena_free_rx_resources(adapter, i); }
[ "static", "void", "ena_free_all_rx_resources", "(", "struct", "ena_adapter", "*", "adapter", ")", "{", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "adapter", "->", "num_io_queues", ";", "i", "++", ")", "ena_free_rx_resources", "(", "adapter", ",", "i", ")", ";", "}" ]
ena_free_all_rx_resources - Free Rx resources for all queues @adapter: network interface device structure
[ "ena_free_all_rx_resources", "-", "Free", "Rx", "resources", "for", "all", "queues", "@adapter", ":", "network", "interface", "device", "structure" ]
[]
[ { "param": "adapter", "type": "struct ena_adapter" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "adapter", "type": "struct ena_adapter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8af815546426ee79f9390fe8778bb1ba680f9b8e
nanovms/nanos
src/aws/ena/ena.c
[ "Apache-2.0" ]
C
ena_refill_rx_bufs
int
int ena_refill_rx_bufs(struct ena_ring *rx_ring, uint32_t num) { struct ena_adapter *adapter = rx_ring->adapter; uint16_t next_to_use, req_id; uint32_t i; int rc; ena_trace(NULL, ENA_DBG | ENA_RXPTH | ENA_RSC, "refill qid: %d\n", rx_ring->qid); next_to_use = rx_ring->next_to_use; for (i = 0; i < num; i++) { struct ena_rx_buffer *rx_info; ena_trace(NULL, ENA_DBG | ENA_RXPTH | ENA_RSC, "RX buffer - next to use: %d\n", next_to_use); req_id = rx_ring->free_rx_ids[next_to_use]; rx_info = &rx_ring->rx_buffer_info[req_id]; rc = ena_alloc_rx_mbuf(adapter, rx_ring, rx_info); if (unlikely(rc != 0)) { ena_trace(NULL, ENA_WARNING, "failed to alloc buffer for rx queue %d\n", rx_ring->qid); break; } rc = ena_com_add_single_rx_desc(rx_ring->ena_com_io_sq, &rx_info->ena_buf, req_id); if (unlikely(rc != 0)) { ena_trace(NULL, ENA_WARNING, "failed to add buffer for rx queue %d\n", rx_ring->qid); break; } next_to_use = ENA_RX_RING_IDX_NEXT(next_to_use, rx_ring->ring_size); } if (unlikely(i < num)) { rx_ring->rx_stats.refil_partial++; ena_trace(NULL, ENA_WARNING, "refilled rx qid %d with only %d mbufs (from %d)\n", rx_ring->qid, i, num); } if (likely(i != 0)) ena_com_write_sq_doorbell(rx_ring->ena_com_io_sq); rx_ring->next_to_use = next_to_use; return i; }
/** * ena_refill_rx_bufs - Refills ring with descriptors * @rx_ring: the ring which we want to feed with free descriptors * @num: number of descriptors to refill * Refills the ring with newly allocated DMA-mapped mbufs for receiving **/
Refills ring with descriptors @rx_ring: the ring which we want to feed with free descriptors @num: number of descriptors to refill Refills the ring with newly allocated DMA-mapped mbufs for receiving
[ "Refills", "ring", "with", "descriptors", "@rx_ring", ":", "the", "ring", "which", "we", "want", "to", "feed", "with", "free", "descriptors", "@num", ":", "number", "of", "descriptors", "to", "refill", "Refills", "the", "ring", "with", "newly", "allocated", "DMA", "-", "mapped", "mbufs", "for", "receiving" ]
int ena_refill_rx_bufs(struct ena_ring *rx_ring, uint32_t num) { struct ena_adapter *adapter = rx_ring->adapter; uint16_t next_to_use, req_id; uint32_t i; int rc; ena_trace(NULL, ENA_DBG | ENA_RXPTH | ENA_RSC, "refill qid: %d\n", rx_ring->qid); next_to_use = rx_ring->next_to_use; for (i = 0; i < num; i++) { struct ena_rx_buffer *rx_info; ena_trace(NULL, ENA_DBG | ENA_RXPTH | ENA_RSC, "RX buffer - next to use: %d\n", next_to_use); req_id = rx_ring->free_rx_ids[next_to_use]; rx_info = &rx_ring->rx_buffer_info[req_id]; rc = ena_alloc_rx_mbuf(adapter, rx_ring, rx_info); if (unlikely(rc != 0)) { ena_trace(NULL, ENA_WARNING, "failed to alloc buffer for rx queue %d\n", rx_ring->qid); break; } rc = ena_com_add_single_rx_desc(rx_ring->ena_com_io_sq, &rx_info->ena_buf, req_id); if (unlikely(rc != 0)) { ena_trace(NULL, ENA_WARNING, "failed to add buffer for rx queue %d\n", rx_ring->qid); break; } next_to_use = ENA_RX_RING_IDX_NEXT(next_to_use, rx_ring->ring_size); } if (unlikely(i < num)) { rx_ring->rx_stats.refil_partial++; ena_trace(NULL, ENA_WARNING, "refilled rx qid %d with only %d mbufs (from %d)\n", rx_ring->qid, i, num); } if (likely(i != 0)) ena_com_write_sq_doorbell(rx_ring->ena_com_io_sq); rx_ring->next_to_use = next_to_use; return i; }
[ "int", "ena_refill_rx_bufs", "(", "struct", "ena_ring", "*", "rx_ring", ",", "uint32_t", "num", ")", "{", "struct", "ena_adapter", "*", "adapter", "=", "rx_ring", "->", "adapter", ";", "uint16_t", "next_to_use", ",", "req_id", ";", "uint32_t", "i", ";", "int", "rc", ";", "ena_trace", "(", "NULL", ",", "ENA_DBG", "|", "ENA_RXPTH", "|", "ENA_RSC", ",", "\"", "\\n", "\"", ",", "rx_ring", "->", "qid", ")", ";", "next_to_use", "=", "rx_ring", "->", "next_to_use", ";", "for", "(", "i", "=", "0", ";", "i", "<", "num", ";", "i", "++", ")", "{", "struct", "ena_rx_buffer", "*", "rx_info", ";", "ena_trace", "(", "NULL", ",", "ENA_DBG", "|", "ENA_RXPTH", "|", "ENA_RSC", ",", "\"", "\\n", "\"", ",", "next_to_use", ")", ";", "req_id", "=", "rx_ring", "->", "free_rx_ids", "[", "next_to_use", "]", ";", "rx_info", "=", "&", "rx_ring", "->", "rx_buffer_info", "[", "req_id", "]", ";", "rc", "=", "ena_alloc_rx_mbuf", "(", "adapter", ",", "rx_ring", ",", "rx_info", ")", ";", "if", "(", "unlikely", "(", "rc", "!=", "0", ")", ")", "{", "ena_trace", "(", "NULL", ",", "ENA_WARNING", ",", "\"", "\\n", "\"", ",", "rx_ring", "->", "qid", ")", ";", "break", ";", "}", "rc", "=", "ena_com_add_single_rx_desc", "(", "rx_ring", "->", "ena_com_io_sq", ",", "&", "rx_info", "->", "ena_buf", ",", "req_id", ")", ";", "if", "(", "unlikely", "(", "rc", "!=", "0", ")", ")", "{", "ena_trace", "(", "NULL", ",", "ENA_WARNING", ",", "\"", "\\n", "\"", ",", "rx_ring", "->", "qid", ")", ";", "break", ";", "}", "next_to_use", "=", "ENA_RX_RING_IDX_NEXT", "(", "next_to_use", ",", "rx_ring", "->", "ring_size", ")", ";", "}", "if", "(", "unlikely", "(", "i", "<", "num", ")", ")", "{", "rx_ring", "->", "rx_stats", ".", "refil_partial", "++", ";", "ena_trace", "(", "NULL", ",", "ENA_WARNING", ",", "\"", "\\n", "\"", ",", "rx_ring", "->", "qid", ",", "i", ",", "num", ")", ";", "}", "if", "(", "likely", "(", "i", "!=", "0", ")", ")", "ena_com_write_sq_doorbell", "(", "rx_ring", "->", "ena_com_io_sq", ")", ";", "rx_ring", "->", "next_to_use", "=", "next_to_use", ";", "return", "i", ";", "}" ]
ena_refill_rx_bufs - Refills ring with descriptors @rx_ring: the ring which we want to feed with free descriptors @num: number of descriptors to refill Refills the ring with newly allocated DMA-mapped mbufs for receiving
[ "ena_refill_rx_bufs", "-", "Refills", "ring", "with", "descriptors", "@rx_ring", ":", "the", "ring", "which", "we", "want", "to", "feed", "with", "free", "descriptors", "@num", ":", "number", "of", "descriptors", "to", "refill", "Refills", "the", "ring", "with", "newly", "allocated", "DMA", "-", "mapped", "mbufs", "for", "receiving" ]
[]
[ { "param": "rx_ring", "type": "struct ena_ring" }, { "param": "num", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rx_ring", "type": "struct ena_ring", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "num", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8af815546426ee79f9390fe8778bb1ba680f9b8e
nanovms/nanos
src/aws/ena/ena.c
[ "Apache-2.0" ]
C
ena_refill_all_rx_bufs
void
static void ena_refill_all_rx_bufs(struct ena_adapter *adapter) { struct ena_ring *rx_ring; int i, rc, bufs_num; for (i = 0; i < adapter->num_io_queues; i++) { rx_ring = &adapter->rx_ring[i]; bufs_num = rx_ring->ring_size - 1; rc = ena_refill_rx_bufs (rx_ring, bufs_num); if (unlikely(rc != bufs_num)) ena_trace(NULL, ENA_WARNING, "refilling Queue %d failed. " "Allocated %d buffers from: %d\n", i, rc, bufs_num); } }
/** * ena_refill_all_rx_bufs - allocate all queues Rx buffers * @adapter: network interface device structure * */
allocate all queues Rx buffers @adapter: network interface device structure
[ "allocate", "all", "queues", "Rx", "buffers", "@adapter", ":", "network", "interface", "device", "structure" ]
static void ena_refill_all_rx_bufs(struct ena_adapter *adapter) { struct ena_ring *rx_ring; int i, rc, bufs_num; for (i = 0; i < adapter->num_io_queues; i++) { rx_ring = &adapter->rx_ring[i]; bufs_num = rx_ring->ring_size - 1; rc = ena_refill_rx_bufs (rx_ring, bufs_num); if (unlikely(rc != bufs_num)) ena_trace(NULL, ENA_WARNING, "refilling Queue %d failed. " "Allocated %d buffers from: %d\n", i, rc, bufs_num); } }
[ "static", "void", "ena_refill_all_rx_bufs", "(", "struct", "ena_adapter", "*", "adapter", ")", "{", "struct", "ena_ring", "*", "rx_ring", ";", "int", "i", ",", "rc", ",", "bufs_num", ";", "for", "(", "i", "=", "0", ";", "i", "<", "adapter", "->", "num_io_queues", ";", "i", "++", ")", "{", "rx_ring", "=", "&", "adapter", "->", "rx_ring", "[", "i", "]", ";", "bufs_num", "=", "rx_ring", "->", "ring_size", "-", "1", ";", "rc", "=", "ena_refill_rx_bufs", "(", "rx_ring", ",", "bufs_num", ")", ";", "if", "(", "unlikely", "(", "rc", "!=", "bufs_num", ")", ")", "ena_trace", "(", "NULL", ",", "ENA_WARNING", ",", "\"", "\"", "\"", "\\n", "\"", ",", "i", ",", "rc", ",", "bufs_num", ")", ";", "}", "}" ]
ena_refill_all_rx_bufs - allocate all queues Rx buffers @adapter: network interface device structure
[ "ena_refill_all_rx_bufs", "-", "allocate", "all", "queues", "Rx", "buffers", "@adapter", ":", "network", "interface", "device", "structure" ]
[]
[ { "param": "adapter", "type": "struct ena_adapter" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "adapter", "type": "struct ena_adapter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8af815546426ee79f9390fe8778bb1ba680f9b8e
nanovms/nanos
src/aws/ena/ena.c
[ "Apache-2.0" ]
C
ena_free_tx_bufs
void
static void ena_free_tx_bufs(struct ena_adapter *adapter, unsigned int qid) { bool print_once = true; struct ena_ring *tx_ring = &adapter->tx_ring[qid]; ENA_RING_MTX_LOCK(tx_ring); lwip_lock(); for (int i = 0; i < tx_ring->ring_size; i++) { struct ena_tx_buffer *tx_info = &tx_ring->tx_buffer_info[i]; if (tx_info->mbuf == NULL) continue; if (print_once) { device_printf(adapter->pdev, "free uncompleted tx mbuf qid %d idx 0x%x\n", qid, i); print_once = false; } else { ena_trace(NULL, ENA_DBG, "free uncompleted tx mbuf qid %d idx 0x%x\n", qid, i); } pbuf_free(tx_info->mbuf); tx_info->mbuf = NULL; } lwip_unlock(); ENA_RING_MTX_UNLOCK(tx_ring); }
/** * ena_free_tx_bufs - Free Tx Buffers per Queue * @adapter: network interface device structure * @qid: queue index **/
Free Tx Buffers per Queue @adapter: network interface device structure @qid: queue index
[ "Free", "Tx", "Buffers", "per", "Queue", "@adapter", ":", "network", "interface", "device", "structure", "@qid", ":", "queue", "index" ]
static void ena_free_tx_bufs(struct ena_adapter *adapter, unsigned int qid) { bool print_once = true; struct ena_ring *tx_ring = &adapter->tx_ring[qid]; ENA_RING_MTX_LOCK(tx_ring); lwip_lock(); for (int i = 0; i < tx_ring->ring_size; i++) { struct ena_tx_buffer *tx_info = &tx_ring->tx_buffer_info[i]; if (tx_info->mbuf == NULL) continue; if (print_once) { device_printf(adapter->pdev, "free uncompleted tx mbuf qid %d idx 0x%x\n", qid, i); print_once = false; } else { ena_trace(NULL, ENA_DBG, "free uncompleted tx mbuf qid %d idx 0x%x\n", qid, i); } pbuf_free(tx_info->mbuf); tx_info->mbuf = NULL; } lwip_unlock(); ENA_RING_MTX_UNLOCK(tx_ring); }
[ "static", "void", "ena_free_tx_bufs", "(", "struct", "ena_adapter", "*", "adapter", ",", "unsigned", "int", "qid", ")", "{", "bool", "print_once", "=", "true", ";", "struct", "ena_ring", "*", "tx_ring", "=", "&", "adapter", "->", "tx_ring", "[", "qid", "]", ";", "ENA_RING_MTX_LOCK", "(", "tx_ring", ")", ";", "lwip_lock", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "tx_ring", "->", "ring_size", ";", "i", "++", ")", "{", "struct", "ena_tx_buffer", "*", "tx_info", "=", "&", "tx_ring", "->", "tx_buffer_info", "[", "i", "]", ";", "if", "(", "tx_info", "->", "mbuf", "==", "NULL", ")", "continue", ";", "if", "(", "print_once", ")", "{", "device_printf", "(", "adapter", "->", "pdev", ",", "\"", "\\n", "\"", ",", "qid", ",", "i", ")", ";", "print_once", "=", "false", ";", "}", "else", "{", "ena_trace", "(", "NULL", ",", "ENA_DBG", ",", "\"", "\\n", "\"", ",", "qid", ",", "i", ")", ";", "}", "pbuf_free", "(", "tx_info", "->", "mbuf", ")", ";", "tx_info", "->", "mbuf", "=", "NULL", ";", "}", "lwip_unlock", "(", ")", ";", "ENA_RING_MTX_UNLOCK", "(", "tx_ring", ")", ";", "}" ]
ena_free_tx_bufs - Free Tx Buffers per Queue @adapter: network interface device structure @qid: queue index
[ "ena_free_tx_bufs", "-", "Free", "Tx", "Buffers", "per", "Queue", "@adapter", ":", "network", "interface", "device", "structure", "@qid", ":", "queue", "index" ]
[]
[ { "param": "adapter", "type": "struct ena_adapter" }, { "param": "qid", "type": "unsigned int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "adapter", "type": "struct ena_adapter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "qid", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8af815546426ee79f9390fe8778bb1ba680f9b8e
nanovms/nanos
src/aws/ena/ena.c
[ "Apache-2.0" ]
C
ena_intr_msix_mgmnt
void
static void ena_intr_msix_mgmnt(void *arg) { struct ena_adapter *adapter = (struct ena_adapter *)arg; ena_com_admin_q_comp_intr_handler(adapter->ena_dev); if (likely(ENA_FLAG_ISSET(ENA_FLAG_DEVICE_RUNNING, adapter))) ena_com_aenq_intr_handler(adapter->ena_dev, arg); }
/** * ena_intr_msix_mgmnt - MSIX Interrupt Handler for admin/async queue * @arg: network adapter **/
MSIX Interrupt Handler for admin/async queue @arg: network adapter
[ "MSIX", "Interrupt", "Handler", "for", "admin", "/", "async", "queue", "@arg", ":", "network", "adapter" ]
static void ena_intr_msix_mgmnt(void *arg) { struct ena_adapter *adapter = (struct ena_adapter *)arg; ena_com_admin_q_comp_intr_handler(adapter->ena_dev); if (likely(ENA_FLAG_ISSET(ENA_FLAG_DEVICE_RUNNING, adapter))) ena_com_aenq_intr_handler(adapter->ena_dev, arg); }
[ "static", "void", "ena_intr_msix_mgmnt", "(", "void", "*", "arg", ")", "{", "struct", "ena_adapter", "*", "adapter", "=", "(", "struct", "ena_adapter", "*", ")", "arg", ";", "ena_com_admin_q_comp_intr_handler", "(", "adapter", "->", "ena_dev", ")", ";", "if", "(", "likely", "(", "ENA_FLAG_ISSET", "(", "ENA_FLAG_DEVICE_RUNNING", ",", "adapter", ")", ")", ")", "ena_com_aenq_intr_handler", "(", "adapter", "->", "ena_dev", ",", "arg", ")", ";", "}" ]
ena_intr_msix_mgmnt - MSIX Interrupt Handler for admin/async queue @arg: network adapter
[ "ena_intr_msix_mgmnt", "-", "MSIX", "Interrupt", "Handler", "for", "admin", "/", "async", "queue", "@arg", ":", "network", "adapter" ]
[]
[ { "param": "arg", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "arg", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8af815546426ee79f9390fe8778bb1ba680f9b8e
nanovms/nanos
src/aws/ena/ena.c
[ "Apache-2.0" ]
C
check_for_admin_com_state
void
static void check_for_admin_com_state(struct ena_adapter *adapter) { if (unlikely(ena_com_get_admin_running_state(adapter->ena_dev) == false)) { device_printf(adapter->pdev, "ENA admin queue is not in running state!\n"); adapter->dev_stats.admin_q_pause++; ena_trigger_reset(adapter, ENA_REGS_RESET_ADMIN_TO); } }
/* Check if admin queue is enabled */
Check if admin queue is enabled
[ "Check", "if", "admin", "queue", "is", "enabled" ]
static void check_for_admin_com_state(struct ena_adapter *adapter) { if (unlikely(ena_com_get_admin_running_state(adapter->ena_dev) == false)) { device_printf(adapter->pdev, "ENA admin queue is not in running state!\n"); adapter->dev_stats.admin_q_pause++; ena_trigger_reset(adapter, ENA_REGS_RESET_ADMIN_TO); } }
[ "static", "void", "check_for_admin_com_state", "(", "struct", "ena_adapter", "*", "adapter", ")", "{", "if", "(", "unlikely", "(", "ena_com_get_admin_running_state", "(", "adapter", "->", "ena_dev", ")", "==", "false", ")", ")", "{", "device_printf", "(", "adapter", "->", "pdev", ",", "\"", "\\n", "\"", ")", ";", "adapter", "->", "dev_stats", ".", "admin_q_pause", "++", ";", "ena_trigger_reset", "(", "adapter", ",", "ENA_REGS_RESET_ADMIN_TO", ")", ";", "}", "}" ]
Check if admin queue is enabled
[ "Check", "if", "admin", "queue", "is", "enabled" ]
[]
[ { "param": "adapter", "type": "struct ena_adapter" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "adapter", "type": "struct ena_adapter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8af815546426ee79f9390fe8778bb1ba680f9b8e
nanovms/nanos
src/aws/ena/ena.c
[ "Apache-2.0" ]
C
check_for_missing_completions
void
static void check_for_missing_completions(struct ena_adapter *adapter) { struct ena_ring *tx_ring; struct ena_ring *rx_ring; int i, budget, rc; /* Make sure the driver doesn't turn the device in other process */ read_barrier(); if (!ENA_FLAG_ISSET(ENA_FLAG_DEV_UP, adapter)) return; if (ENA_FLAG_ISSET(ENA_FLAG_TRIGGER_RESET, adapter)) return; if (adapter->missing_tx_timeout == ENA_HW_HINTS_NO_TIMEOUT) return; budget = adapter->missing_tx_max_queues; for (i = adapter->next_monitored_tx_qid; i < adapter->num_io_queues; i++) { tx_ring = &adapter->tx_ring[i]; rx_ring = &adapter->rx_ring[i]; rc = check_missing_comp_in_tx_queue(adapter, tx_ring); if (unlikely(rc != 0)) return; rc = check_for_rx_interrupt_queue(adapter, rx_ring); if (unlikely(rc != 0)) return; budget--; if (budget == 0) { i++; break; } } adapter->next_monitored_tx_qid = i % adapter->num_io_queues; }
/* * Check for TX which were not completed on time. * Timeout is defined by "missing_tx_timeout". * Reset will be performed if number of incompleted * transactions exceeds "missing_tx_threshold". */
Check for TX which were not completed on time. Timeout is defined by "missing_tx_timeout". Reset will be performed if number of incompleted transactions exceeds "missing_tx_threshold".
[ "Check", "for", "TX", "which", "were", "not", "completed", "on", "time", ".", "Timeout", "is", "defined", "by", "\"", "missing_tx_timeout", "\"", ".", "Reset", "will", "be", "performed", "if", "number", "of", "incompleted", "transactions", "exceeds", "\"", "missing_tx_threshold", "\"", "." ]
static void check_for_missing_completions(struct ena_adapter *adapter) { struct ena_ring *tx_ring; struct ena_ring *rx_ring; int i, budget, rc; read_barrier(); if (!ENA_FLAG_ISSET(ENA_FLAG_DEV_UP, adapter)) return; if (ENA_FLAG_ISSET(ENA_FLAG_TRIGGER_RESET, adapter)) return; if (adapter->missing_tx_timeout == ENA_HW_HINTS_NO_TIMEOUT) return; budget = adapter->missing_tx_max_queues; for (i = adapter->next_monitored_tx_qid; i < adapter->num_io_queues; i++) { tx_ring = &adapter->tx_ring[i]; rx_ring = &adapter->rx_ring[i]; rc = check_missing_comp_in_tx_queue(adapter, tx_ring); if (unlikely(rc != 0)) return; rc = check_for_rx_interrupt_queue(adapter, rx_ring); if (unlikely(rc != 0)) return; budget--; if (budget == 0) { i++; break; } } adapter->next_monitored_tx_qid = i % adapter->num_io_queues; }
[ "static", "void", "check_for_missing_completions", "(", "struct", "ena_adapter", "*", "adapter", ")", "{", "struct", "ena_ring", "*", "tx_ring", ";", "struct", "ena_ring", "*", "rx_ring", ";", "int", "i", ",", "budget", ",", "rc", ";", "read_barrier", "(", ")", ";", "if", "(", "!", "ENA_FLAG_ISSET", "(", "ENA_FLAG_DEV_UP", ",", "adapter", ")", ")", "return", ";", "if", "(", "ENA_FLAG_ISSET", "(", "ENA_FLAG_TRIGGER_RESET", ",", "adapter", ")", ")", "return", ";", "if", "(", "adapter", "->", "missing_tx_timeout", "==", "ENA_HW_HINTS_NO_TIMEOUT", ")", "return", ";", "budget", "=", "adapter", "->", "missing_tx_max_queues", ";", "for", "(", "i", "=", "adapter", "->", "next_monitored_tx_qid", ";", "i", "<", "adapter", "->", "num_io_queues", ";", "i", "++", ")", "{", "tx_ring", "=", "&", "adapter", "->", "tx_ring", "[", "i", "]", ";", "rx_ring", "=", "&", "adapter", "->", "rx_ring", "[", "i", "]", ";", "rc", "=", "check_missing_comp_in_tx_queue", "(", "adapter", ",", "tx_ring", ")", ";", "if", "(", "unlikely", "(", "rc", "!=", "0", ")", ")", "return", ";", "rc", "=", "check_for_rx_interrupt_queue", "(", "adapter", ",", "rx_ring", ")", ";", "if", "(", "unlikely", "(", "rc", "!=", "0", ")", ")", "return", ";", "budget", "--", ";", "if", "(", "budget", "==", "0", ")", "{", "i", "++", ";", "break", ";", "}", "}", "adapter", "->", "next_monitored_tx_qid", "=", "i", "%", "adapter", "->", "num_io_queues", ";", "}" ]
Check for TX which were not completed on time.
[ "Check", "for", "TX", "which", "were", "not", "completed", "on", "time", "." ]
[ "/* Make sure the driver doesn't turn the device in other process */" ]
[ { "param": "adapter", "type": "struct ena_adapter" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "adapter", "type": "struct ena_adapter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8af815546426ee79f9390fe8778bb1ba680f9b8e
nanovms/nanos
src/aws/ena/ena.c
[ "Apache-2.0" ]
C
check_for_empty_rx_ring
void
static void check_for_empty_rx_ring(struct ena_adapter *adapter) { struct ena_ring *rx_ring; int i, refill_required; if (!ENA_FLAG_ISSET(ENA_FLAG_DEV_UP, adapter)) return; if (ENA_FLAG_ISSET(ENA_FLAG_TRIGGER_RESET, adapter)) return; for (i = 0; i < adapter->num_io_queues; i++) { rx_ring = &adapter->rx_ring[i]; refill_required = ena_com_free_q_entries(rx_ring->ena_com_io_sq); if (unlikely(refill_required == (rx_ring->ring_size - 1))) { rx_ring->empty_rx_queue++; if (rx_ring->empty_rx_queue >= EMPTY_RX_REFILL) { rx_ring->rx_stats.empty_rx_ring++; device_printf(adapter->pdev, "trigger refill for ring %d\n", i); enqueue_irqsafe(runqueue, &rx_ring->que->cleanup_task); rx_ring->empty_rx_queue = 0; } } else { rx_ring->empty_rx_queue = 0; } } }
/* For the rare case where the device runs out of Rx descriptors and the * msix handler failed to refill new Rx descriptors (due to a lack of memory * for example). * This case will lead to a deadlock: * The device won't send interrupts since all the new Rx packets will be dropped * The msix handler won't allocate new Rx descriptors so the device won't be * able to send new packets. * * When such a situation is detected - execute rx cleanup task in another thread */
For the rare case where the device runs out of Rx descriptors and the msix handler failed to refill new Rx descriptors (due to a lack of memory for example). This case will lead to a deadlock: The device won't send interrupts since all the new Rx packets will be dropped The msix handler won't allocate new Rx descriptors so the device won't be able to send new packets. When such a situation is detected - execute rx cleanup task in another thread
[ "For", "the", "rare", "case", "where", "the", "device", "runs", "out", "of", "Rx", "descriptors", "and", "the", "msix", "handler", "failed", "to", "refill", "new", "Rx", "descriptors", "(", "due", "to", "a", "lack", "of", "memory", "for", "example", ")", ".", "This", "case", "will", "lead", "to", "a", "deadlock", ":", "The", "device", "won", "'", "t", "send", "interrupts", "since", "all", "the", "new", "Rx", "packets", "will", "be", "dropped", "The", "msix", "handler", "won", "'", "t", "allocate", "new", "Rx", "descriptors", "so", "the", "device", "won", "'", "t", "be", "able", "to", "send", "new", "packets", ".", "When", "such", "a", "situation", "is", "detected", "-", "execute", "rx", "cleanup", "task", "in", "another", "thread" ]
static void check_for_empty_rx_ring(struct ena_adapter *adapter) { struct ena_ring *rx_ring; int i, refill_required; if (!ENA_FLAG_ISSET(ENA_FLAG_DEV_UP, adapter)) return; if (ENA_FLAG_ISSET(ENA_FLAG_TRIGGER_RESET, adapter)) return; for (i = 0; i < adapter->num_io_queues; i++) { rx_ring = &adapter->rx_ring[i]; refill_required = ena_com_free_q_entries(rx_ring->ena_com_io_sq); if (unlikely(refill_required == (rx_ring->ring_size - 1))) { rx_ring->empty_rx_queue++; if (rx_ring->empty_rx_queue >= EMPTY_RX_REFILL) { rx_ring->rx_stats.empty_rx_ring++; device_printf(adapter->pdev, "trigger refill for ring %d\n", i); enqueue_irqsafe(runqueue, &rx_ring->que->cleanup_task); rx_ring->empty_rx_queue = 0; } } else { rx_ring->empty_rx_queue = 0; } } }
[ "static", "void", "check_for_empty_rx_ring", "(", "struct", "ena_adapter", "*", "adapter", ")", "{", "struct", "ena_ring", "*", "rx_ring", ";", "int", "i", ",", "refill_required", ";", "if", "(", "!", "ENA_FLAG_ISSET", "(", "ENA_FLAG_DEV_UP", ",", "adapter", ")", ")", "return", ";", "if", "(", "ENA_FLAG_ISSET", "(", "ENA_FLAG_TRIGGER_RESET", ",", "adapter", ")", ")", "return", ";", "for", "(", "i", "=", "0", ";", "i", "<", "adapter", "->", "num_io_queues", ";", "i", "++", ")", "{", "rx_ring", "=", "&", "adapter", "->", "rx_ring", "[", "i", "]", ";", "refill_required", "=", "ena_com_free_q_entries", "(", "rx_ring", "->", "ena_com_io_sq", ")", ";", "if", "(", "unlikely", "(", "refill_required", "==", "(", "rx_ring", "->", "ring_size", "-", "1", ")", ")", ")", "{", "rx_ring", "->", "empty_rx_queue", "++", ";", "if", "(", "rx_ring", "->", "empty_rx_queue", ">=", "EMPTY_RX_REFILL", ")", "{", "rx_ring", "->", "rx_stats", ".", "empty_rx_ring", "++", ";", "device_printf", "(", "adapter", "->", "pdev", ",", "\"", "\\n", "\"", ",", "i", ")", ";", "enqueue_irqsafe", "(", "runqueue", ",", "&", "rx_ring", "->", "que", "->", "cleanup_task", ")", ";", "rx_ring", "->", "empty_rx_queue", "=", "0", ";", "}", "}", "else", "{", "rx_ring", "->", "empty_rx_queue", "=", "0", ";", "}", "}", "}" ]
For the rare case where the device runs out of Rx descriptors and the msix handler failed to refill new Rx descriptors (due to a lack of memory for example).
[ "For", "the", "rare", "case", "where", "the", "device", "runs", "out", "of", "Rx", "descriptors", "and", "the", "msix", "handler", "failed", "to", "refill", "new", "Rx", "descriptors", "(", "due", "to", "a", "lack", "of", "memory", "for", "example", ")", "." ]
[]
[ { "param": "adapter", "type": "struct ena_adapter" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "adapter", "type": "struct ena_adapter", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8af815546426ee79f9390fe8778bb1ba680f9b8e
nanovms/nanos
src/aws/ena/ena.c
[ "Apache-2.0" ]
C
ena_attach
boolean
static boolean ena_attach(heap general, heap page_allocator, pci_dev d) { struct ena_com_dev_get_features_ctx get_feat_ctx; struct ena_llq_configurations llq_config; struct ena_calc_queue_size_ctx calc_queue_ctx = { 0 }; static int version_printed; struct ena_adapter *adapter; struct ena_com_dev *ena_dev = NULL; uint32_t max_num_io_queues; int rc; adapter = allocate(general, sizeof(struct ena_adapter)); if (adapter == INVALID_ADDRESS) return false; adapter->general = general; adapter->contiguous = page_allocator; adapter->pdev = d; ENA_LOCK_INIT(adapter); /* * Set up the timer service - driver is responsible for avoiding * concurrency, as the callout won't be using any locking inside. */ init_timer(&adapter->timer_service); adapter->keep_alive_timeout = DEFAULT_KEEP_ALIVE_TO; adapter->missing_tx_timeout = DEFAULT_TX_CMP_TO; adapter->missing_tx_max_queues = DEFAULT_TX_MONITORED_QUEUES; adapter->missing_tx_threshold = DEFAULT_TX_CMP_THRESHOLD; if (version_printed++ == 0) ena_trace(NULL, ENA_INFO, "%s\n", ena_version); /* Allocate memory for ena_dev structure */ ena_dev = allocate_zero(general, sizeof(struct ena_com_dev)); if (ena_dev == INVALID_ADDRESS) goto err_adapter_free; adapter->ena_dev = ena_dev; ena_dev->dmadev = adapter; pci_bar_init(adapter->pdev, &adapter->registers, ENA_REG_BAR, 0, -1); ena_dev->bus = allocate(general, sizeof(struct ena_bus)); if (ena_dev->bus == INVALID_ADDRESS) goto err_dev_free; /* Store register resources */ ((struct ena_bus *)(ena_dev->bus))->reg_bar = &adapter->registers; ena_dev->tx_mem_queue_type = ENA_ADMIN_PLACEMENT_POLICY_HOST; /* Initially clear all the flags */ ENA_FLAG_ZERO(adapter); /* Device initialization */ rc = ena_device_init(adapter, &get_feat_ctx, &adapter->wd_active); if (unlikely(rc != 0)) { device_printf(d, "ENA device init failed! (err: %d)\n", rc); rc = ENA_COM_EIO; goto err_bus_free; } set_default_llq_configurations(&llq_config); rc = ena_set_queues_placement_policy(adapter, &get_feat_ctx.llq, &llq_config); if (unlikely (rc != 0)) { device_printf (d, "failed to set placement policy\n"); goto err_com_free; } adapter->keep_alive_timestamp = uptime(); calc_queue_ctx.ena_dev = ena_dev; calc_queue_ctx.get_feat_ctx = &get_feat_ctx; /* Calculate initial and maximum IO queue number and size */ max_num_io_queues = ena_calc_max_io_queue_num(adapter, &get_feat_ctx); rc = ena_calc_io_queue_size(&calc_queue_ctx); if (unlikely((rc != 0) || (max_num_io_queues <= 0))) { rc = ENA_COM_FAULT; goto err_com_free; } adapter->requested_tx_ring_size = calc_queue_ctx.tx_queue_size; adapter->requested_rx_ring_size = calc_queue_ctx.rx_queue_size; adapter->max_tx_sgl_size = calc_queue_ctx.max_tx_sgl_size; adapter->max_rx_sgl_size = calc_queue_ctx.max_rx_sgl_size; adapter->max_num_io_queues = max_num_io_queues; adapter->buf_ring_size = ENA_DEFAULT_BUF_RING_SIZE; adapter->max_mtu = get_feat_ctx.dev_attr.max_mtu; adapter->reset_reason = ENA_REGS_RESET_NORMAL; /* * The amount of requested MSIX vectors is equal to * adapter::max_num_io_queues (see `ena_enable_msix()`), plus a constant * number of admin queue interrupts. The former is initially determined * by HW capabilities (see `ena_calc_max_io_queue_num())` but may not be * achieved if there are not enough system resources. By default, the * number of effectively used IO queues is the same but later on it can * be limited by the user using sysctl interface. */ rc = ena_enable_msix_and_set_admin_interrupts(adapter); if (unlikely(rc != 0)) { device_printf(d, "Failed to enable and set the admin interrupts\n"); goto err_io_free; } /* By default all of allocated MSIX vectors are actively used */ adapter->num_io_queues = adapter->msix_vecs - ENA_ADMIN_MSIX_VEC; /* initialize rings basic information */ ena_init_io_rings(adapter); /* setup network interface */ rc = ena_setup_ifnet(adapter, &get_feat_ctx); if (unlikely(rc != 0)) { device_printf(d, "Error with network interface setup\n"); goto err_msix_free; } init_closure(&adapter->reset_task, ena_reset_task, adapter); /* Initialize statistics */ zero(&adapter->dev_stats, sizeof(struct ena_stats_dev)); zero(&adapter->hw_stats, sizeof(struct ena_hw_stats)); init_closure(&adapter->link_up_task, ena_link_up_task, adapter); init_closure(&adapter->link_down_task, ena_link_down_task, adapter); ENA_FLAG_SET_ATOMIC(ENA_FLAG_DEVICE_RUNNING, adapter); ena_up(adapter); return true; err_msix_free: ena_com_dev_reset(adapter->ena_dev, ENA_REGS_RESET_INIT_ERR); ena_free_mgmnt_irq(adapter); ena_disable_msix(adapter); err_io_free: ena_free_all_io_rings_resources(adapter); err_com_free: ena_com_admin_destroy(ena_dev); ena_com_delete_host_info(ena_dev); ena_com_mmio_reg_read_request_destroy(ena_dev); err_bus_free: deallocate(general, ena_dev->bus, sizeof(struct ena_bus)); err_dev_free: deallocate(general, ena_dev, sizeof(struct ena_com_dev)); err_adapter_free: deallocate(general, adapter, sizeof(*adapter)); return false; }
/** * ena_attach - Device Initialization Routine * * ena_attach initializes an adapter identified by a device structure. * The OS initialization, configuring of the adapter private structure, * and a hardware reset occur. **/
Device Initialization Routine ena_attach initializes an adapter identified by a device structure. The OS initialization, configuring of the adapter private structure, and a hardware reset occur.
[ "Device", "Initialization", "Routine", "ena_attach", "initializes", "an", "adapter", "identified", "by", "a", "device", "structure", ".", "The", "OS", "initialization", "configuring", "of", "the", "adapter", "private", "structure", "and", "a", "hardware", "reset", "occur", "." ]
static boolean ena_attach(heap general, heap page_allocator, pci_dev d) { struct ena_com_dev_get_features_ctx get_feat_ctx; struct ena_llq_configurations llq_config; struct ena_calc_queue_size_ctx calc_queue_ctx = { 0 }; static int version_printed; struct ena_adapter *adapter; struct ena_com_dev *ena_dev = NULL; uint32_t max_num_io_queues; int rc; adapter = allocate(general, sizeof(struct ena_adapter)); if (adapter == INVALID_ADDRESS) return false; adapter->general = general; adapter->contiguous = page_allocator; adapter->pdev = d; ENA_LOCK_INIT(adapter); init_timer(&adapter->timer_service); adapter->keep_alive_timeout = DEFAULT_KEEP_ALIVE_TO; adapter->missing_tx_timeout = DEFAULT_TX_CMP_TO; adapter->missing_tx_max_queues = DEFAULT_TX_MONITORED_QUEUES; adapter->missing_tx_threshold = DEFAULT_TX_CMP_THRESHOLD; if (version_printed++ == 0) ena_trace(NULL, ENA_INFO, "%s\n", ena_version); ena_dev = allocate_zero(general, sizeof(struct ena_com_dev)); if (ena_dev == INVALID_ADDRESS) goto err_adapter_free; adapter->ena_dev = ena_dev; ena_dev->dmadev = adapter; pci_bar_init(adapter->pdev, &adapter->registers, ENA_REG_BAR, 0, -1); ena_dev->bus = allocate(general, sizeof(struct ena_bus)); if (ena_dev->bus == INVALID_ADDRESS) goto err_dev_free; ((struct ena_bus *)(ena_dev->bus))->reg_bar = &adapter->registers; ena_dev->tx_mem_queue_type = ENA_ADMIN_PLACEMENT_POLICY_HOST; ENA_FLAG_ZERO(adapter); rc = ena_device_init(adapter, &get_feat_ctx, &adapter->wd_active); if (unlikely(rc != 0)) { device_printf(d, "ENA device init failed! (err: %d)\n", rc); rc = ENA_COM_EIO; goto err_bus_free; } set_default_llq_configurations(&llq_config); rc = ena_set_queues_placement_policy(adapter, &get_feat_ctx.llq, &llq_config); if (unlikely (rc != 0)) { device_printf (d, "failed to set placement policy\n"); goto err_com_free; } adapter->keep_alive_timestamp = uptime(); calc_queue_ctx.ena_dev = ena_dev; calc_queue_ctx.get_feat_ctx = &get_feat_ctx; max_num_io_queues = ena_calc_max_io_queue_num(adapter, &get_feat_ctx); rc = ena_calc_io_queue_size(&calc_queue_ctx); if (unlikely((rc != 0) || (max_num_io_queues <= 0))) { rc = ENA_COM_FAULT; goto err_com_free; } adapter->requested_tx_ring_size = calc_queue_ctx.tx_queue_size; adapter->requested_rx_ring_size = calc_queue_ctx.rx_queue_size; adapter->max_tx_sgl_size = calc_queue_ctx.max_tx_sgl_size; adapter->max_rx_sgl_size = calc_queue_ctx.max_rx_sgl_size; adapter->max_num_io_queues = max_num_io_queues; adapter->buf_ring_size = ENA_DEFAULT_BUF_RING_SIZE; adapter->max_mtu = get_feat_ctx.dev_attr.max_mtu; adapter->reset_reason = ENA_REGS_RESET_NORMAL; rc = ena_enable_msix_and_set_admin_interrupts(adapter); if (unlikely(rc != 0)) { device_printf(d, "Failed to enable and set the admin interrupts\n"); goto err_io_free; } adapter->num_io_queues = adapter->msix_vecs - ENA_ADMIN_MSIX_VEC; ena_init_io_rings(adapter); rc = ena_setup_ifnet(adapter, &get_feat_ctx); if (unlikely(rc != 0)) { device_printf(d, "Error with network interface setup\n"); goto err_msix_free; } init_closure(&adapter->reset_task, ena_reset_task, adapter); zero(&adapter->dev_stats, sizeof(struct ena_stats_dev)); zero(&adapter->hw_stats, sizeof(struct ena_hw_stats)); init_closure(&adapter->link_up_task, ena_link_up_task, adapter); init_closure(&adapter->link_down_task, ena_link_down_task, adapter); ENA_FLAG_SET_ATOMIC(ENA_FLAG_DEVICE_RUNNING, adapter); ena_up(adapter); return true; err_msix_free: ena_com_dev_reset(adapter->ena_dev, ENA_REGS_RESET_INIT_ERR); ena_free_mgmnt_irq(adapter); ena_disable_msix(adapter); err_io_free: ena_free_all_io_rings_resources(adapter); err_com_free: ena_com_admin_destroy(ena_dev); ena_com_delete_host_info(ena_dev); ena_com_mmio_reg_read_request_destroy(ena_dev); err_bus_free: deallocate(general, ena_dev->bus, sizeof(struct ena_bus)); err_dev_free: deallocate(general, ena_dev, sizeof(struct ena_com_dev)); err_adapter_free: deallocate(general, adapter, sizeof(*adapter)); return false; }
[ "static", "boolean", "ena_attach", "(", "heap", "general", ",", "heap", "page_allocator", ",", "pci_dev", "d", ")", "{", "struct", "ena_com_dev_get_features_ctx", "get_feat_ctx", ";", "struct", "ena_llq_configurations", "llq_config", ";", "struct", "ena_calc_queue_size_ctx", "calc_queue_ctx", "=", "{", "0", "}", ";", "static", "int", "version_printed", ";", "struct", "ena_adapter", "*", "adapter", ";", "struct", "ena_com_dev", "*", "ena_dev", "=", "NULL", ";", "uint32_t", "max_num_io_queues", ";", "int", "rc", ";", "adapter", "=", "allocate", "(", "general", ",", "sizeof", "(", "struct", "ena_adapter", ")", ")", ";", "if", "(", "adapter", "==", "INVALID_ADDRESS", ")", "return", "false", ";", "adapter", "->", "general", "=", "general", ";", "adapter", "->", "contiguous", "=", "page_allocator", ";", "adapter", "->", "pdev", "=", "d", ";", "ENA_LOCK_INIT", "(", "adapter", ")", ";", "init_timer", "(", "&", "adapter", "->", "timer_service", ")", ";", "adapter", "->", "keep_alive_timeout", "=", "DEFAULT_KEEP_ALIVE_TO", ";", "adapter", "->", "missing_tx_timeout", "=", "DEFAULT_TX_CMP_TO", ";", "adapter", "->", "missing_tx_max_queues", "=", "DEFAULT_TX_MONITORED_QUEUES", ";", "adapter", "->", "missing_tx_threshold", "=", "DEFAULT_TX_CMP_THRESHOLD", ";", "if", "(", "version_printed", "++", "==", "0", ")", "ena_trace", "(", "NULL", ",", "ENA_INFO", ",", "\"", "\\n", "\"", ",", "ena_version", ")", ";", "ena_dev", "=", "allocate_zero", "(", "general", ",", "sizeof", "(", "struct", "ena_com_dev", ")", ")", ";", "if", "(", "ena_dev", "==", "INVALID_ADDRESS", ")", "goto", "err_adapter_free", ";", "adapter", "->", "ena_dev", "=", "ena_dev", ";", "ena_dev", "->", "dmadev", "=", "adapter", ";", "pci_bar_init", "(", "adapter", "->", "pdev", ",", "&", "adapter", "->", "registers", ",", "ENA_REG_BAR", ",", "0", ",", "-1", ")", ";", "ena_dev", "->", "bus", "=", "allocate", "(", "general", ",", "sizeof", "(", "struct", "ena_bus", ")", ")", ";", "if", "(", "ena_dev", "->", "bus", "==", "INVALID_ADDRESS", ")", "goto", "err_dev_free", ";", "(", "(", "struct", "ena_bus", "*", ")", "(", "ena_dev", "->", "bus", ")", ")", "->", "reg_bar", "=", "&", "adapter", "->", "registers", ";", "ena_dev", "->", "tx_mem_queue_type", "=", "ENA_ADMIN_PLACEMENT_POLICY_HOST", ";", "ENA_FLAG_ZERO", "(", "adapter", ")", ";", "rc", "=", "ena_device_init", "(", "adapter", ",", "&", "get_feat_ctx", ",", "&", "adapter", "->", "wd_active", ")", ";", "if", "(", "unlikely", "(", "rc", "!=", "0", ")", ")", "{", "device_printf", "(", "d", ",", "\"", "\\n", "\"", ",", "rc", ")", ";", "rc", "=", "ENA_COM_EIO", ";", "goto", "err_bus_free", ";", "}", "set_default_llq_configurations", "(", "&", "llq_config", ")", ";", "rc", "=", "ena_set_queues_placement_policy", "(", "adapter", ",", "&", "get_feat_ctx", ".", "llq", ",", "&", "llq_config", ")", ";", "if", "(", "unlikely", "(", "rc", "!=", "0", ")", ")", "{", "device_printf", "(", "d", ",", "\"", "\\n", "\"", ")", ";", "goto", "err_com_free", ";", "}", "adapter", "->", "keep_alive_timestamp", "=", "uptime", "(", ")", ";", "calc_queue_ctx", ".", "ena_dev", "=", "ena_dev", ";", "calc_queue_ctx", ".", "get_feat_ctx", "=", "&", "get_feat_ctx", ";", "max_num_io_queues", "=", "ena_calc_max_io_queue_num", "(", "adapter", ",", "&", "get_feat_ctx", ")", ";", "rc", "=", "ena_calc_io_queue_size", "(", "&", "calc_queue_ctx", ")", ";", "if", "(", "unlikely", "(", "(", "rc", "!=", "0", ")", "||", "(", "max_num_io_queues", "<=", "0", ")", ")", ")", "{", "rc", "=", "ENA_COM_FAULT", ";", "goto", "err_com_free", ";", "}", "adapter", "->", "requested_tx_ring_size", "=", "calc_queue_ctx", ".", "tx_queue_size", ";", "adapter", "->", "requested_rx_ring_size", "=", "calc_queue_ctx", ".", "rx_queue_size", ";", "adapter", "->", "max_tx_sgl_size", "=", "calc_queue_ctx", ".", "max_tx_sgl_size", ";", "adapter", "->", "max_rx_sgl_size", "=", "calc_queue_ctx", ".", "max_rx_sgl_size", ";", "adapter", "->", "max_num_io_queues", "=", "max_num_io_queues", ";", "adapter", "->", "buf_ring_size", "=", "ENA_DEFAULT_BUF_RING_SIZE", ";", "adapter", "->", "max_mtu", "=", "get_feat_ctx", ".", "dev_attr", ".", "max_mtu", ";", "adapter", "->", "reset_reason", "=", "ENA_REGS_RESET_NORMAL", ";", "rc", "=", "ena_enable_msix_and_set_admin_interrupts", "(", "adapter", ")", ";", "if", "(", "unlikely", "(", "rc", "!=", "0", ")", ")", "{", "device_printf", "(", "d", ",", "\"", "\\n", "\"", ")", ";", "goto", "err_io_free", ";", "}", "adapter", "->", "num_io_queues", "=", "adapter", "->", "msix_vecs", "-", "ENA_ADMIN_MSIX_VEC", ";", "ena_init_io_rings", "(", "adapter", ")", ";", "rc", "=", "ena_setup_ifnet", "(", "adapter", ",", "&", "get_feat_ctx", ")", ";", "if", "(", "unlikely", "(", "rc", "!=", "0", ")", ")", "{", "device_printf", "(", "d", ",", "\"", "\\n", "\"", ")", ";", "goto", "err_msix_free", ";", "}", "init_closure", "(", "&", "adapter", "->", "reset_task", ",", "ena_reset_task", ",", "adapter", ")", ";", "zero", "(", "&", "adapter", "->", "dev_stats", ",", "sizeof", "(", "struct", "ena_stats_dev", ")", ")", ";", "zero", "(", "&", "adapter", "->", "hw_stats", ",", "sizeof", "(", "struct", "ena_hw_stats", ")", ")", ";", "init_closure", "(", "&", "adapter", "->", "link_up_task", ",", "ena_link_up_task", ",", "adapter", ")", ";", "init_closure", "(", "&", "adapter", "->", "link_down_task", ",", "ena_link_down_task", ",", "adapter", ")", ";", "ENA_FLAG_SET_ATOMIC", "(", "ENA_FLAG_DEVICE_RUNNING", ",", "adapter", ")", ";", "ena_up", "(", "adapter", ")", ";", "return", "true", ";", "err_msix_free", ":", "ena_com_dev_reset", "(", "adapter", "->", "ena_dev", ",", "ENA_REGS_RESET_INIT_ERR", ")", ";", "ena_free_mgmnt_irq", "(", "adapter", ")", ";", "ena_disable_msix", "(", "adapter", ")", ";", "err_io_free", ":", "ena_free_all_io_rings_resources", "(", "adapter", ")", ";", "err_com_free", ":", "ena_com_admin_destroy", "(", "ena_dev", ")", ";", "ena_com_delete_host_info", "(", "ena_dev", ")", ";", "ena_com_mmio_reg_read_request_destroy", "(", "ena_dev", ")", ";", "err_bus_free", ":", "deallocate", "(", "general", ",", "ena_dev", "->", "bus", ",", "sizeof", "(", "struct", "ena_bus", ")", ")", ";", "err_dev_free", ":", "deallocate", "(", "general", ",", "ena_dev", ",", "sizeof", "(", "struct", "ena_com_dev", ")", ")", ";", "err_adapter_free", ":", "deallocate", "(", "general", ",", "adapter", ",", "sizeof", "(", "*", "adapter", ")", ")", ";", "return", "false", ";", "}" ]
ena_attach - Device Initialization Routine ena_attach initializes an adapter identified by a device structure.
[ "ena_attach", "-", "Device", "Initialization", "Routine", "ena_attach", "initializes", "an", "adapter", "identified", "by", "a", "device", "structure", "." ]
[ "/*\n * Set up the timer service - driver is responsible for avoiding\n * concurrency, as the callout won't be using any locking inside.\n */", "/* Allocate memory for ena_dev structure */", "/* Store register resources */", "/* Initially clear all the flags */", "/* Device initialization */", "/* Calculate initial and maximum IO queue number and size */", "/*\n * The amount of requested MSIX vectors is equal to\n * adapter::max_num_io_queues (see `ena_enable_msix()`), plus a constant\n * number of admin queue interrupts. The former is initially determined\n * by HW capabilities (see `ena_calc_max_io_queue_num())` but may not be\n * achieved if there are not enough system resources. By default, the\n * number of effectively used IO queues is the same but later on it can\n * be limited by the user using sysctl interface.\n */", "/* By default all of allocated MSIX vectors are actively used */", "/* initialize rings basic information */", "/* setup network interface */", "/* Initialize statistics */" ]
[ { "param": "general", "type": "heap" }, { "param": "page_allocator", "type": "heap" }, { "param": "d", "type": "pci_dev" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "general", "type": "heap", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "page_allocator", "type": "heap", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "d", "type": "pci_dev", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8af815546426ee79f9390fe8778bb1ba680f9b8e
nanovms/nanos
src/aws/ena/ena.c
[ "Apache-2.0" ]
C
ena_update_on_link_change
void
static void ena_update_on_link_change(void *adapter_data, struct ena_admin_aenq_entry *aenq_e) { struct ena_adapter *adapter = (struct ena_adapter *)adapter_data; struct ena_admin_aenq_link_change_desc *aenq_desc; int status; aenq_desc = (struct ena_admin_aenq_link_change_desc *)aenq_e; status = aenq_desc->flags & ENA_ADMIN_AENQ_LINK_CHANGE_DESC_LINK_STATUS_MASK; if (status != 0) { ena_trace(NULL, ENA_INFO, "link UP interrupt\n"); enqueue(runqueue, &adapter->link_up_task); } else { ena_trace(NULL, ENA_INFO, "link DOWN interrupt\n"); enqueue(runqueue, &adapter->link_down_task); } }
/** * ena_update_on_link_change: * Notify the network interface about the change in link status **/
Notify the network interface about the change in link status
[ "Notify", "the", "network", "interface", "about", "the", "change", "in", "link", "status" ]
static void ena_update_on_link_change(void *adapter_data, struct ena_admin_aenq_entry *aenq_e) { struct ena_adapter *adapter = (struct ena_adapter *)adapter_data; struct ena_admin_aenq_link_change_desc *aenq_desc; int status; aenq_desc = (struct ena_admin_aenq_link_change_desc *)aenq_e; status = aenq_desc->flags & ENA_ADMIN_AENQ_LINK_CHANGE_DESC_LINK_STATUS_MASK; if (status != 0) { ena_trace(NULL, ENA_INFO, "link UP interrupt\n"); enqueue(runqueue, &adapter->link_up_task); } else { ena_trace(NULL, ENA_INFO, "link DOWN interrupt\n"); enqueue(runqueue, &adapter->link_down_task); } }
[ "static", "void", "ena_update_on_link_change", "(", "void", "*", "adapter_data", ",", "struct", "ena_admin_aenq_entry", "*", "aenq_e", ")", "{", "struct", "ena_adapter", "*", "adapter", "=", "(", "struct", "ena_adapter", "*", ")", "adapter_data", ";", "struct", "ena_admin_aenq_link_change_desc", "*", "aenq_desc", ";", "int", "status", ";", "aenq_desc", "=", "(", "struct", "ena_admin_aenq_link_change_desc", "*", ")", "aenq_e", ";", "status", "=", "aenq_desc", "->", "flags", "&", "ENA_ADMIN_AENQ_LINK_CHANGE_DESC_LINK_STATUS_MASK", ";", "if", "(", "status", "!=", "0", ")", "{", "ena_trace", "(", "NULL", ",", "ENA_INFO", ",", "\"", "\\n", "\"", ")", ";", "enqueue", "(", "runqueue", ",", "&", "adapter", "->", "link_up_task", ")", ";", "}", "else", "{", "ena_trace", "(", "NULL", ",", "ENA_INFO", ",", "\"", "\\n", "\"", ")", ";", "enqueue", "(", "runqueue", ",", "&", "adapter", "->", "link_down_task", ")", ";", "}", "}" ]
ena_update_on_link_change: Notify the network interface about the change in link status
[ "ena_update_on_link_change", ":", "Notify", "the", "network", "interface", "about", "the", "change", "in", "link", "status" ]
[]
[ { "param": "adapter_data", "type": "void" }, { "param": "aenq_e", "type": "struct ena_admin_aenq_entry" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "adapter_data", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "aenq_e", "type": "struct ena_admin_aenq_entry", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8af815546426ee79f9390fe8778bb1ba680f9b8e
nanovms/nanos
src/aws/ena/ena.c
[ "Apache-2.0" ]
C
unimplemented_aenq_handler
void
static void unimplemented_aenq_handler(void *adapter_data, struct ena_admin_aenq_entry *aenq_e) { device_printf(((struct ena_adapter *)adapter_data)->pdev, "Unknown event was received or event with unimplemented handler\n"); }
/** * This handler will called for unknown event group or unimplemented handlers **/
This handler will called for unknown event group or unimplemented handlers
[ "This", "handler", "will", "called", "for", "unknown", "event", "group", "or", "unimplemented", "handlers" ]
static void unimplemented_aenq_handler(void *adapter_data, struct ena_admin_aenq_entry *aenq_e) { device_printf(((struct ena_adapter *)adapter_data)->pdev, "Unknown event was received or event with unimplemented handler\n"); }
[ "static", "void", "unimplemented_aenq_handler", "(", "void", "*", "adapter_data", ",", "struct", "ena_admin_aenq_entry", "*", "aenq_e", ")", "{", "device_printf", "(", "(", "(", "struct", "ena_adapter", "*", ")", "adapter_data", ")", "->", "pdev", ",", "\"", "\\n", "\"", ")", ";", "}" ]
This handler will called for unknown event group or unimplemented handlers
[ "This", "handler", "will", "called", "for", "unknown", "event", "group", "or", "unimplemented", "handlers" ]
[]
[ { "param": "adapter_data", "type": "void" }, { "param": "aenq_e", "type": "struct ena_admin_aenq_entry" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "adapter_data", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "aenq_e", "type": "struct ena_admin_aenq_entry", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7137f77e4f41fff0995439db023da4f9b1501011
nanovms/nanos
src/kernel/storage.c
[ "Apache-2.0" ]
C
storage_get_volume
volume
static volume storage_get_volume(tuple root) { list_foreach(&storage.volumes, e) { volume v = struct_from_list(e, volume, l); if (v->fs && (filesystem_getroot(v->fs) == root)) { return v; } } return 0; }
/* Called with mutex locked. */ // XXX this won't work with wrapped root...
Called with mutex locked. XXX this won't work with wrapped root
[ "Called", "with", "mutex", "locked", ".", "XXX", "this", "won", "'", "t", "work", "with", "wrapped", "root" ]
static volume storage_get_volume(tuple root) { list_foreach(&storage.volumes, e) { volume v = struct_from_list(e, volume, l); if (v->fs && (filesystem_getroot(v->fs) == root)) { return v; } } return 0; }
[ "static", "volume", "storage_get_volume", "(", "tuple", "root", ")", "{", "list_foreach", "(", "&", "storage", ".", "volumes", ",", "e", ")", "", "{", "volume", "v", "=", "struct_from_list", "(", "e", ",", "volume", ",", "l", ")", ";", "if", "(", "v", "->", "fs", "&&", "(", "filesystem_getroot", "(", "v", "->", "fs", ")", "==", "root", ")", ")", "{", "return", "v", ";", "}", "}", "return", "0", ";", "}" ]
Called with mutex locked.
[ "Called", "with", "mutex", "locked", "." ]
[]
[ { "param": "root", "type": "tuple" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root", "type": "tuple", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
67b6149a1a40dffe4242bb4bd46b9b718dcc4a56
nanovms/nanos
src/unix/socket.c
[ "Apache-2.0" ]
C
unixsock_dealloc
void
static void unixsock_dealloc(unixsock s) { deallocate_queue(s->data); s->data = 0; unixsock_unlock(s); unixsock peer = (s->sock.type == SOCK_STREAM) ? s->peer : 0; if (peer) { unixsock_lock(peer); blockq bq = peer->data ? peer->sock.rxbq : 0; if (bq) blockq_reserve(bq); unixsock_unlock(peer); if (bq) { blockq_flush(bq); blockq_release(bq); } } blockq_flush(s->sock.txbq); /* unblock any sockets connecting or writing to this socket */ if (s->notify_handle != INVALID_ADDRESS) notify_remove(s->peer->sock.f.ns, s->notify_handle, false); unixsock_disconnect(s); deallocate_closure(s->sock.f.read); deallocate_closure(s->sock.f.write); deallocate_closure(s->sock.f.events); deallocate_closure(s->sock.f.close); socket_deinit(&s->sock); refcount_release(&s->refcount); }
/* Called with lock acquired, returns with lock released. */
Called with lock acquired, returns with lock released.
[ "Called", "with", "lock", "acquired", "returns", "with", "lock", "released", "." ]
static void unixsock_dealloc(unixsock s) { deallocate_queue(s->data); s->data = 0; unixsock_unlock(s); unixsock peer = (s->sock.type == SOCK_STREAM) ? s->peer : 0; if (peer) { unixsock_lock(peer); blockq bq = peer->data ? peer->sock.rxbq : 0; if (bq) blockq_reserve(bq); unixsock_unlock(peer); if (bq) { blockq_flush(bq); blockq_release(bq); } } blockq_flush(s->sock.txbq); if (s->notify_handle != INVALID_ADDRESS) notify_remove(s->peer->sock.f.ns, s->notify_handle, false); unixsock_disconnect(s); deallocate_closure(s->sock.f.read); deallocate_closure(s->sock.f.write); deallocate_closure(s->sock.f.events); deallocate_closure(s->sock.f.close); socket_deinit(&s->sock); refcount_release(&s->refcount); }
[ "static", "void", "unixsock_dealloc", "(", "unixsock", "s", ")", "{", "deallocate_queue", "(", "s", "->", "data", ")", ";", "s", "->", "data", "=", "0", ";", "unixsock_unlock", "(", "s", ")", ";", "unixsock", "peer", "=", "(", "s", "->", "sock", ".", "type", "==", "SOCK_STREAM", ")", "?", "s", "->", "peer", ":", "0", ";", "if", "(", "peer", ")", "{", "unixsock_lock", "(", "peer", ")", ";", "blockq", "bq", "=", "peer", "->", "data", "?", "peer", "->", "sock", ".", "rxbq", ":", "0", ";", "if", "(", "bq", ")", "blockq_reserve", "(", "bq", ")", ";", "unixsock_unlock", "(", "peer", ")", ";", "if", "(", "bq", ")", "{", "blockq_flush", "(", "bq", ")", ";", "blockq_release", "(", "bq", ")", ";", "}", "}", "blockq_flush", "(", "s", "->", "sock", ".", "txbq", ")", ";", "if", "(", "s", "->", "notify_handle", "!=", "INVALID_ADDRESS", ")", "notify_remove", "(", "s", "->", "peer", "->", "sock", ".", "f", ".", "ns", ",", "s", "->", "notify_handle", ",", "false", ")", ";", "unixsock_disconnect", "(", "s", ")", ";", "deallocate_closure", "(", "s", "->", "sock", ".", "f", ".", "read", ")", ";", "deallocate_closure", "(", "s", "->", "sock", ".", "f", ".", "write", ")", ";", "deallocate_closure", "(", "s", "->", "sock", ".", "f", ".", "events", ")", ";", "deallocate_closure", "(", "s", "->", "sock", ".", "f", ".", "close", ")", ";", "socket_deinit", "(", "&", "s", "->", "sock", ")", ";", "refcount_release", "(", "&", "s", "->", "refcount", ")", ";", "}" ]
Called with lock acquired, returns with lock released.
[ "Called", "with", "lock", "acquired", "returns", "with", "lock", "released", "." ]
[ "/* unblock any sockets connecting or writing to this socket */" ]
[ { "param": "s", "type": "unixsock" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "s", "type": "unixsock", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
67b6149a1a40dffe4242bb4bd46b9b718dcc4a56
nanovms/nanos
src/unix/socket.c
[ "Apache-2.0" ]
C
unixsock_notify_writer
void
static inline void unixsock_notify_writer(unixsock s) { blockq_wake_one(s->sock.txbq); fdesc_notify_events(&s->sock.f); }
/* The argument refers to the destination socket, not to the sending socket. */
The argument refers to the destination socket, not to the sending socket.
[ "The", "argument", "refers", "to", "the", "destination", "socket", "not", "to", "the", "sending", "socket", "." ]
static inline void unixsock_notify_writer(unixsock s) { blockq_wake_one(s->sock.txbq); fdesc_notify_events(&s->sock.f); }
[ "static", "inline", "void", "unixsock_notify_writer", "(", "unixsock", "s", ")", "{", "blockq_wake_one", "(", "s", "->", "sock", ".", "txbq", ")", ";", "fdesc_notify_events", "(", "&", "s", "->", "sock", ".", "f", ")", ";", "}" ]
The argument refers to the destination socket, not to the sending socket.
[ "The", "argument", "refers", "to", "the", "destination", "socket", "not", "to", "the", "sending", "socket", "." ]
[]
[ { "param": "s", "type": "unixsock" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "s", "type": "unixsock", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
352dca7d58fe1ae7942cff1edc25a9a8ae72e03e
nanovms/nanos
src/kernel/pagecache.c
[ "Apache-2.0" ]
C
pagecache_map_page_if_filled
boolean
boolean pagecache_map_page_if_filled(pagecache_node pn, u64 node_offset, u64 vaddr, pageflags flags, status_handler complete) { boolean mapped = false; pagecache_lock_node(pn); pagecache_page pp = page_lookup_nodelocked(pn, node_offset >> pn->pv->pc->page_order); pagecache_debug("%s: pn %p, node_offset 0x%lx, vaddr 0x%lx, flags 0x%lx, pp %p\n", __func__, pn, node_offset, vaddr, flags.w, pp); if (pp == INVALID_ADDRESS) goto out; if (touch_or_fill_page_nodelocked(pn, pp, 0)) { mapped = true; map_page(pn->pv->pc, pp, vaddr, flags, complete); } refcount_reserve(&pp->refcount); out: pagecache_unlock_node(pn); return mapped; }
/* no-alloc / no-fill path, meant to be safe outside of kernel lock */
no-alloc / no-fill path, meant to be safe outside of kernel lock
[ "no", "-", "alloc", "/", "no", "-", "fill", "path", "meant", "to", "be", "safe", "outside", "of", "kernel", "lock" ]
boolean pagecache_map_page_if_filled(pagecache_node pn, u64 node_offset, u64 vaddr, pageflags flags, status_handler complete) { boolean mapped = false; pagecache_lock_node(pn); pagecache_page pp = page_lookup_nodelocked(pn, node_offset >> pn->pv->pc->page_order); pagecache_debug("%s: pn %p, node_offset 0x%lx, vaddr 0x%lx, flags 0x%lx, pp %p\n", __func__, pn, node_offset, vaddr, flags.w, pp); if (pp == INVALID_ADDRESS) goto out; if (touch_or_fill_page_nodelocked(pn, pp, 0)) { mapped = true; map_page(pn->pv->pc, pp, vaddr, flags, complete); } refcount_reserve(&pp->refcount); out: pagecache_unlock_node(pn); return mapped; }
[ "boolean", "pagecache_map_page_if_filled", "(", "pagecache_node", "pn", ",", "u64", "node_offset", ",", "u64", "vaddr", ",", "pageflags", "flags", ",", "status_handler", "complete", ")", "{", "boolean", "mapped", "=", "false", ";", "pagecache_lock_node", "(", "pn", ")", ";", "pagecache_page", "pp", "=", "page_lookup_nodelocked", "(", "pn", ",", "node_offset", ">>", "pn", "->", "pv", "->", "pc", "->", "page_order", ")", ";", "pagecache_debug", "(", "\"", "\\n", "\"", ",", "__func__", ",", "pn", ",", "node_offset", ",", "vaddr", ",", "flags", ".", "w", ",", "pp", ")", ";", "if", "(", "pp", "==", "INVALID_ADDRESS", ")", "goto", "out", ";", "if", "(", "touch_or_fill_page_nodelocked", "(", "pn", ",", "pp", ",", "0", ")", ")", "{", "mapped", "=", "true", ";", "map_page", "(", "pn", "->", "pv", "->", "pc", ",", "pp", ",", "vaddr", ",", "flags", ",", "complete", ")", ";", "}", "refcount_reserve", "(", "&", "pp", "->", "refcount", ")", ";", "out", ":", "pagecache_unlock_node", "(", "pn", ")", ";", "return", "mapped", ";", "}" ]
no-alloc / no-fill path, meant to be safe outside of kernel lock
[ "no", "-", "alloc", "/", "no", "-", "fill", "path", "meant", "to", "be", "safe", "outside", "of", "kernel", "lock" ]
[]
[ { "param": "pn", "type": "pagecache_node" }, { "param": "node_offset", "type": "u64" }, { "param": "vaddr", "type": "u64" }, { "param": "flags", "type": "pageflags" }, { "param": "complete", "type": "status_handler" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pn", "type": "pagecache_node", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "node_offset", "type": "u64", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "vaddr", "type": "u64", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "flags", "type": "pageflags", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "complete", "type": "status_handler", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
352dca7d58fe1ae7942cff1edc25a9a8ae72e03e
nanovms/nanos
src/kernel/pagecache.c
[ "Apache-2.0" ]
C
pagecache_deallocate_node
void
void pagecache_deallocate_node(pagecache_node pn) { if (pn->fs_read) deallocate_closure(pn->fs_read); deallocate_closure(pn->cache_read); #ifndef PAGECACHE_READ_ONLY if (pn->fs_write) deallocate_closure(pn->fs_write); if (pn->fs_reserve) deallocate_closure(pn->fs_reserve); deallocate_closure(pn->cache_write); #endif destruct_rbtree(&pn->pages, stack_closure(pagecache_page_release)); list_delete(&pn->l); deallocate_rangemap(pn->shared_maps, stack_closure(pagecache_node_assert)); deallocate(pn->pv->pc->h, pn, sizeof(*pn)); }
/* This function can only be called when no I/O operations are pending. */
This function can only be called when no I/O operations are pending.
[ "This", "function", "can", "only", "be", "called", "when", "no", "I", "/", "O", "operations", "are", "pending", "." ]
void pagecache_deallocate_node(pagecache_node pn) { if (pn->fs_read) deallocate_closure(pn->fs_read); deallocate_closure(pn->cache_read); #ifndef PAGECACHE_READ_ONLY if (pn->fs_write) deallocate_closure(pn->fs_write); if (pn->fs_reserve) deallocate_closure(pn->fs_reserve); deallocate_closure(pn->cache_write); #endif destruct_rbtree(&pn->pages, stack_closure(pagecache_page_release)); list_delete(&pn->l); deallocate_rangemap(pn->shared_maps, stack_closure(pagecache_node_assert)); deallocate(pn->pv->pc->h, pn, sizeof(*pn)); }
[ "void", "pagecache_deallocate_node", "(", "pagecache_node", "pn", ")", "{", "if", "(", "pn", "->", "fs_read", ")", "deallocate_closure", "(", "pn", "->", "fs_read", ")", ";", "deallocate_closure", "(", "pn", "->", "cache_read", ")", ";", "#ifndef", "PAGECACHE_READ_ONLY", "if", "(", "pn", "->", "fs_write", ")", "deallocate_closure", "(", "pn", "->", "fs_write", ")", ";", "if", "(", "pn", "->", "fs_reserve", ")", "deallocate_closure", "(", "pn", "->", "fs_reserve", ")", ";", "deallocate_closure", "(", "pn", "->", "cache_write", ")", ";", "#endif", "destruct_rbtree", "(", "&", "pn", "->", "pages", ",", "stack_closure", "(", "pagecache_page_release", ")", ")", ";", "list_delete", "(", "&", "pn", "->", "l", ")", ";", "deallocate_rangemap", "(", "pn", "->", "shared_maps", ",", "stack_closure", "(", "pagecache_node_assert", ")", ")", ";", "deallocate", "(", "pn", "->", "pv", "->", "pc", "->", "h", ",", "pn", ",", "sizeof", "(", "*", "pn", ")", ")", ";", "}" ]
This function can only be called when no I/O operations are pending.
[ "This", "function", "can", "only", "be", "called", "when", "no", "I", "/", "O", "operations", "are", "pending", "." ]
[]
[ { "param": "pn", "type": "pagecache_node" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pn", "type": "pagecache_node", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7e66ce26ae0694d360ca0a75f488f64496121266
nanovms/nanos
src/unix/syscall.c
[ "Apache-2.0" ]
C
mkdirat
sysreturn
sysreturn mkdirat(int dirfd, char *pathname, int mode) { if (!validate_user_string(pathname)) return -EFAULT; thread_log(current, "mkdirat: \"%s\", dirfd %d, mode 0x%x", pathname, dirfd, mode); filesystem fs; inode cwd; cwd = resolve_dir(fs, dirfd, pathname); sysreturn rv = sysreturn_from_fs_status(filesystem_mkdir(fs, cwd, pathname)); filesystem_release(fs); return rv; }
/* If the pathname given in pathname is relative, then it is interpreted relative to the directory referred to by the file descriptor dirfd (rather than relative to the current working directory of the calling process, as is done by open() for a relative pathname). If pathname is relative and dirfd is the special value AT_FDCWD, then pathname is interpreted relative to the current working directory of the calling process (like open()). If pathname is absolute, then dirfd is ignore */
If the pathname given in pathname is relative, then it is interpreted relative to the directory referred to by the file descriptor dirfd (rather than relative to the current working directory of the calling process, as is done by open() for a relative pathname). If pathname is relative and dirfd is the special value AT_FDCWD, then pathname is interpreted relative to the current working directory of the calling process (like open()). If pathname is absolute, then dirfd is ignore
[ "If", "the", "pathname", "given", "in", "pathname", "is", "relative", "then", "it", "is", "interpreted", "relative", "to", "the", "directory", "referred", "to", "by", "the", "file", "descriptor", "dirfd", "(", "rather", "than", "relative", "to", "the", "current", "working", "directory", "of", "the", "calling", "process", "as", "is", "done", "by", "open", "()", "for", "a", "relative", "pathname", ")", ".", "If", "pathname", "is", "relative", "and", "dirfd", "is", "the", "special", "value", "AT_FDCWD", "then", "pathname", "is", "interpreted", "relative", "to", "the", "current", "working", "directory", "of", "the", "calling", "process", "(", "like", "open", "()", ")", ".", "If", "pathname", "is", "absolute", "then", "dirfd", "is", "ignore" ]
sysreturn mkdirat(int dirfd, char *pathname, int mode) { if (!validate_user_string(pathname)) return -EFAULT; thread_log(current, "mkdirat: \"%s\", dirfd %d, mode 0x%x", pathname, dirfd, mode); filesystem fs; inode cwd; cwd = resolve_dir(fs, dirfd, pathname); sysreturn rv = sysreturn_from_fs_status(filesystem_mkdir(fs, cwd, pathname)); filesystem_release(fs); return rv; }
[ "sysreturn", "mkdirat", "(", "int", "dirfd", ",", "char", "*", "pathname", ",", "int", "mode", ")", "{", "if", "(", "!", "validate_user_string", "(", "pathname", ")", ")", "return", "-", "EFAULT", ";", "thread_log", "(", "current", ",", "\"", "\\\"", "\\\"", "\"", ",", "pathname", ",", "dirfd", ",", "mode", ")", ";", "filesystem", "fs", ";", "inode", "cwd", ";", "cwd", "=", "resolve_dir", "(", "fs", ",", "dirfd", ",", "pathname", ")", ";", "sysreturn", "rv", "=", "sysreturn_from_fs_status", "(", "filesystem_mkdir", "(", "fs", ",", "cwd", ",", "pathname", ")", ")", ";", "filesystem_release", "(", "fs", ")", ";", "return", "rv", ";", "}" ]
If the pathname given in pathname is relative, then it is interpreted relative to the directory referred to by the file descriptor dirfd (rather than relative to the current working directory of the calling process, as is done by open() for a relative pathname).
[ "If", "the", "pathname", "given", "in", "pathname", "is", "relative", "then", "it", "is", "interpreted", "relative", "to", "the", "directory", "referred", "to", "by", "the", "file", "descriptor", "dirfd", "(", "rather", "than", "relative", "to", "the", "current", "working", "directory", "of", "the", "calling", "process", "as", "is", "done", "by", "open", "()", "for", "a", "relative", "pathname", ")", "." ]
[]
[ { "param": "dirfd", "type": "int" }, { "param": "pathname", "type": "char" }, { "param": "mode", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dirfd", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pathname", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mode", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e4ee853aa154639f9351477b4ed08df558789583
nanovms/nanos
src/runtime/timer.c
[ "Apache-2.0" ]
C
timer_compare
boolean
static boolean timer_compare(void *za, void *zb) { /* XXX FIXME This will fail if monotonic now ever wraps. From the clock_gettime(2) manpage, the clock starts at some "unspecified starting point." This could be resolved by comparing deltas to some reference point, perhaps even set once on boot (good for ~68 years). */ return timer_expiry((timer)za) > timer_expiry((timer)zb); }
/* The lower time expiry is the higher priority. */
The lower time expiry is the higher priority.
[ "The", "lower", "time", "expiry", "is", "the", "higher", "priority", "." ]
static boolean timer_compare(void *za, void *zb) { return timer_expiry((timer)za) > timer_expiry((timer)zb); }
[ "static", "boolean", "timer_compare", "(", "void", "*", "za", ",", "void", "*", "zb", ")", "{", "return", "timer_expiry", "(", "(", "timer", ")", "za", ")", ">", "timer_expiry", "(", "(", "timer", ")", "zb", ")", ";", "}" ]
The lower time expiry is the higher priority.
[ "The", "lower", "time", "expiry", "is", "the", "higher", "priority", "." ]
[ "/* XXX FIXME This will fail if monotonic now ever wraps. From the\n clock_gettime(2) manpage, the clock starts at some \"unspecified\n starting point.\" This could be resolved by comparing deltas to some\n reference point, perhaps even set once on boot (good for ~68 years). */" ]
[ { "param": "za", "type": "void" }, { "param": "zb", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "za", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "zb", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e6dd9cb2b72899b140766759c9c004c69bc8a6d3
skadauke/jdupes
jdupes.c
[ "MIT" ]
C
check_singlefile
int
static int check_singlefile(file_t * const restrict newfile) { static char tempname[PATHBUF_SIZE * 2]; char * restrict tp = tempname; int excluded; if (newfile == NULL) nullptr("check_singlefile()"); LOUD(fprintf(stderr, "check_singlefile: checking '%s'\n", newfile->d_name)); /* Exclude hidden files if requested */ if (ISFLAG(flags, F_EXCLUDEHIDDEN)) { if (newfile->d_name == NULL) nullptr("check_singlefile newfile->d_name"); strcpy(tp, newfile->d_name); tp = basename(tp); if (tp[0] == '.' && strcmp(tp, ".") && strcmp(tp, "..")) { LOUD(fprintf(stderr, "check_singlefile: excluding hidden file (-A on)\n")); return 1; } } /* Get file information and check for validity */ const int i = getfilestats(newfile); if (i || newfile->size == -1) { LOUD(fprintf(stderr, "check_singlefile: excluding due to bad stat()\n")); return 1; } if (!S_ISDIR(newfile->mode)) { /* Exclude zero-length files if requested */ if (newfile->size == 0 && !ISFLAG(flags, F_INCLUDEEMPTY)) { LOUD(fprintf(stderr, "check_singlefile: excluding zero-length empty file (-z not set)\n")); return 1; } /* Exclude files based on exclusion stack size specs */ excluded = 0; for (struct exclude *excl = exclude_head; excl != NULL; excl = excl->next) { uint32_t sflag = excl->flags & XX_EXCL_SIZE; if ( ((sflag == X_SIZE_EQ) && (newfile->size != excl->size)) || ((sflag == X_SIZE_LTEQ) && (newfile->size <= excl->size)) || ((sflag == X_SIZE_GTEQ) && (newfile->size >= excl->size)) || ((sflag == X_SIZE_GT) && (newfile->size > excl->size)) || ((sflag == X_SIZE_LT) && (newfile->size < excl->size)) ) excluded = 1; } if (excluded) { LOUD(fprintf(stderr, "check_singlefile: excluding based on xsize limit (-x set)\n")); return 1; } } #ifdef ON_WINDOWS /* Windows has a 1023 (+1) hard link limit. If we're hard linking, * ignore all files that have hit this limit */ #ifndef NO_HARDLINKS if (ISFLAG(flags, F_HARDLINKFILES) && newfile->nlink >= 1024) { #ifdef DEBUG hll_exclude++; #endif LOUD(fprintf(stderr, "check_singlefile: excluding due to Windows 1024 hard link limit\n")); return 1; } #endif /* NO_HARDLINKS */ #endif /* ON_WINDOWS */ return 0; }
/* Check for exclusion conditions for a single file (1 = fail) */
Check for exclusion conditions for a single file (1 = fail)
[ "Check", "for", "exclusion", "conditions", "for", "a", "single", "file", "(", "1", "=", "fail", ")" ]
static int check_singlefile(file_t * const restrict newfile) { static char tempname[PATHBUF_SIZE * 2]; char * restrict tp = tempname; int excluded; if (newfile == NULL) nullptr("check_singlefile()"); LOUD(fprintf(stderr, "check_singlefile: checking '%s'\n", newfile->d_name)); if (ISFLAG(flags, F_EXCLUDEHIDDEN)) { if (newfile->d_name == NULL) nullptr("check_singlefile newfile->d_name"); strcpy(tp, newfile->d_name); tp = basename(tp); if (tp[0] == '.' && strcmp(tp, ".") && strcmp(tp, "..")) { LOUD(fprintf(stderr, "check_singlefile: excluding hidden file (-A on)\n")); return 1; } } const int i = getfilestats(newfile); if (i || newfile->size == -1) { LOUD(fprintf(stderr, "check_singlefile: excluding due to bad stat()\n")); return 1; } if (!S_ISDIR(newfile->mode)) { if (newfile->size == 0 && !ISFLAG(flags, F_INCLUDEEMPTY)) { LOUD(fprintf(stderr, "check_singlefile: excluding zero-length empty file (-z not set)\n")); return 1; } excluded = 0; for (struct exclude *excl = exclude_head; excl != NULL; excl = excl->next) { uint32_t sflag = excl->flags & XX_EXCL_SIZE; if ( ((sflag == X_SIZE_EQ) && (newfile->size != excl->size)) || ((sflag == X_SIZE_LTEQ) && (newfile->size <= excl->size)) || ((sflag == X_SIZE_GTEQ) && (newfile->size >= excl->size)) || ((sflag == X_SIZE_GT) && (newfile->size > excl->size)) || ((sflag == X_SIZE_LT) && (newfile->size < excl->size)) ) excluded = 1; } if (excluded) { LOUD(fprintf(stderr, "check_singlefile: excluding based on xsize limit (-x set)\n")); return 1; } } #ifdef ON_WINDOWS #ifndef NO_HARDLINKS if (ISFLAG(flags, F_HARDLINKFILES) && newfile->nlink >= 1024) { #ifdef DEBUG hll_exclude++; #endif LOUD(fprintf(stderr, "check_singlefile: excluding due to Windows 1024 hard link limit\n")); return 1; } #endif #endif return 0; }
[ "static", "int", "check_singlefile", "(", "file_t", "*", "const", "restrict", "newfile", ")", "{", "static", "char", "tempname", "[", "PATHBUF_SIZE", "*", "2", "]", ";", "char", "*", "restrict", "tp", "=", "tempname", ";", "int", "excluded", ";", "if", "(", "newfile", "==", "NULL", ")", "nullptr", "(", "\"", "\"", ")", ";", "LOUD", "(", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "newfile", "->", "d_name", ")", ")", ";", "if", "(", "ISFLAG", "(", "flags", ",", "F_EXCLUDEHIDDEN", ")", ")", "{", "if", "(", "newfile", "->", "d_name", "==", "NULL", ")", "nullptr", "(", "\"", "\"", ")", ";", "strcpy", "(", "tp", ",", "newfile", "->", "d_name", ")", ";", "tp", "=", "basename", "(", "tp", ")", ";", "if", "(", "tp", "[", "0", "]", "==", "'", "'", "&&", "strcmp", "(", "tp", ",", "\"", "\"", ")", "&&", "strcmp", "(", "tp", ",", "\"", "\"", ")", ")", "{", "LOUD", "(", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ")", ")", ";", "return", "1", ";", "}", "}", "const", "int", "i", "=", "getfilestats", "(", "newfile", ")", ";", "if", "(", "i", "||", "newfile", "->", "size", "==", "-1", ")", "{", "LOUD", "(", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ")", ")", ";", "return", "1", ";", "}", "if", "(", "!", "S_ISDIR", "(", "newfile", "->", "mode", ")", ")", "{", "if", "(", "newfile", "->", "size", "==", "0", "&&", "!", "ISFLAG", "(", "flags", ",", "F_INCLUDEEMPTY", ")", ")", "{", "LOUD", "(", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ")", ")", ";", "return", "1", ";", "}", "excluded", "=", "0", ";", "for", "(", "struct", "exclude", "*", "excl", "=", "exclude_head", ";", "excl", "!=", "NULL", ";", "excl", "=", "excl", "->", "next", ")", "{", "uint32_t", "sflag", "=", "excl", "->", "flags", "&", "XX_EXCL_SIZE", ";", "if", "(", "(", "(", "sflag", "==", "X_SIZE_EQ", ")", "&&", "(", "newfile", "->", "size", "!=", "excl", "->", "size", ")", ")", "||", "(", "(", "sflag", "==", "X_SIZE_LTEQ", ")", "&&", "(", "newfile", "->", "size", "<=", "excl", "->", "size", ")", ")", "||", "(", "(", "sflag", "==", "X_SIZE_GTEQ", ")", "&&", "(", "newfile", "->", "size", ">=", "excl", "->", "size", ")", ")", "||", "(", "(", "sflag", "==", "X_SIZE_GT", ")", "&&", "(", "newfile", "->", "size", ">", "excl", "->", "size", ")", ")", "||", "(", "(", "sflag", "==", "X_SIZE_LT", ")", "&&", "(", "newfile", "->", "size", "<", "excl", "->", "size", ")", ")", ")", "excluded", "=", "1", ";", "}", "if", "(", "excluded", ")", "{", "LOUD", "(", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ")", ")", ";", "return", "1", ";", "}", "}", "#ifdef", "ON_WINDOWS", "#ifndef", "NO_HARDLINKS", "if", "(", "ISFLAG", "(", "flags", ",", "F_HARDLINKFILES", ")", "&&", "newfile", "->", "nlink", ">=", "1024", ")", "{", "#ifdef", "DEBUG", "hll_exclude", "++", ";", "#endif", "LOUD", "(", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ")", ")", ";", "return", "1", ";", "}", "#endif", "#endif", "return", "0", ";", "}" ]
Check for exclusion conditions for a single file (1 = fail)
[ "Check", "for", "exclusion", "conditions", "for", "a", "single", "file", "(", "1", "=", "fail", ")" ]
[ "/* Exclude hidden files if requested */", "/* Get file information and check for validity */", "/* Exclude zero-length files if requested */", "/* Exclude files based on exclusion stack size specs */", "/* Windows has a 1023 (+1) hard link limit. If we're hard linking,\n * ignore all files that have hit this limit */", "/* NO_HARDLINKS */", "/* ON_WINDOWS */" ]
[ { "param": "newfile", "type": "file_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "newfile", "type": "file_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e6dd9cb2b72899b140766759c9c004c69bc8a6d3
skadauke/jdupes
jdupes.c
[ "MIT" ]
C
rebalance_tree
void
static inline void rebalance_tree(filetree_t * const tree) { filetree_t * restrict promote; filetree_t * restrict demote; int difference, direction; #ifdef CONSIDER_IMBALANCE int l, r, imbalance; #endif if (!tree) return; /* Rebalance all children first */ if (tree->left_weight > BALANCE_THRESHOLD) rebalance_tree(tree->left); if (tree->right_weight > BALANCE_THRESHOLD) rebalance_tree(tree->right); /* If weights are within a certain threshold, do nothing */ direction = tree->right_weight - tree->left_weight; difference = direction; if (difference < 0) difference = -difference; if (difference <= BALANCE_THRESHOLD) return; /* Determine if a tree rotation will help, and do it if so */ if (direction > 0) { #ifdef CONSIDER_IMBALANCE l = tree->right->left_weight + tree->right_weight; r = tree->right->right_weight; imbalance = l - r; if (imbalance < 0) imbalance = -imbalance; /* Don't rotate if imbalance will increase */ if (imbalance >= difference) return; #endif /* CONSIDER_IMBALANCE */ /* Rotate the right node up one level */ promote = tree->right; demote = tree; /* Attach new parent's left tree to old parent */ demote->right = promote->left; demote->right_weight = promote->left_weight; /* Attach old parent to new parent */ promote->left = demote; promote->left_weight = demote->left_weight + demote->right_weight + 1; /* Reconnect parent linkages */ promote->parent = demote->parent; if (demote->right) demote->right->parent = demote; demote->parent = promote; if (promote->parent == NULL) checktree = promote; else if (promote->parent->left == demote) promote->parent->left = promote; else promote->parent->right = promote; return; } else if (direction < 0) { #ifdef CONSIDER_IMBALANCE r = tree->left->right_weight + tree->left_weight; l = tree->left->left_weight; imbalance = r - l; if (imbalance < 0) imbalance = -imbalance; /* Don't rotate if imbalance will increase */ if (imbalance >= difference) return; #endif /* CONSIDER_IMBALANCE */ /* Rotate the left node up one level */ promote = tree->left; demote = tree; /* Attach new parent's right tree to old parent */ demote->left = promote->right; demote->left_weight = promote->right_weight; /* Attach old parent to new parent */ promote->right = demote; promote->right_weight = demote->right_weight + demote->left_weight + 1; /* Reconnect parent linkages */ promote->parent = demote->parent; if (demote->left) demote->left->parent = demote; demote->parent = promote; if (promote->parent == NULL) checktree = promote; else if (promote->parent->left == demote) promote->parent->left = promote; else promote->parent->right = promote; return; } /* Fall through */ return; }
/* Rebalance the file tree to reduce search depth */
Rebalance the file tree to reduce search depth
[ "Rebalance", "the", "file", "tree", "to", "reduce", "search", "depth" ]
static inline void rebalance_tree(filetree_t * const tree) { filetree_t * restrict promote; filetree_t * restrict demote; int difference, direction; #ifdef CONSIDER_IMBALANCE int l, r, imbalance; #endif if (!tree) return; if (tree->left_weight > BALANCE_THRESHOLD) rebalance_tree(tree->left); if (tree->right_weight > BALANCE_THRESHOLD) rebalance_tree(tree->right); direction = tree->right_weight - tree->left_weight; difference = direction; if (difference < 0) difference = -difference; if (difference <= BALANCE_THRESHOLD) return; if (direction > 0) { #ifdef CONSIDER_IMBALANCE l = tree->right->left_weight + tree->right_weight; r = tree->right->right_weight; imbalance = l - r; if (imbalance < 0) imbalance = -imbalance; if (imbalance >= difference) return; #endif promote = tree->right; demote = tree; demote->right = promote->left; demote->right_weight = promote->left_weight; promote->left = demote; promote->left_weight = demote->left_weight + demote->right_weight + 1; promote->parent = demote->parent; if (demote->right) demote->right->parent = demote; demote->parent = promote; if (promote->parent == NULL) checktree = promote; else if (promote->parent->left == demote) promote->parent->left = promote; else promote->parent->right = promote; return; } else if (direction < 0) { #ifdef CONSIDER_IMBALANCE r = tree->left->right_weight + tree->left_weight; l = tree->left->left_weight; imbalance = r - l; if (imbalance < 0) imbalance = -imbalance; if (imbalance >= difference) return; #endif promote = tree->left; demote = tree; demote->left = promote->right; demote->left_weight = promote->right_weight; promote->right = demote; promote->right_weight = demote->right_weight + demote->left_weight + 1; promote->parent = demote->parent; if (demote->left) demote->left->parent = demote; demote->parent = promote; if (promote->parent == NULL) checktree = promote; else if (promote->parent->left == demote) promote->parent->left = promote; else promote->parent->right = promote; return; } return; }
[ "static", "inline", "void", "rebalance_tree", "(", "filetree_t", "*", "const", "tree", ")", "{", "filetree_t", "*", "restrict", "promote", ";", "filetree_t", "*", "restrict", "demote", ";", "int", "difference", ",", "direction", ";", "#ifdef", "CONSIDER_IMBALANCE", "int", "l", ",", "r", ",", "imbalance", ";", "#endif", "if", "(", "!", "tree", ")", "return", ";", "if", "(", "tree", "->", "left_weight", ">", "BALANCE_THRESHOLD", ")", "rebalance_tree", "(", "tree", "->", "left", ")", ";", "if", "(", "tree", "->", "right_weight", ">", "BALANCE_THRESHOLD", ")", "rebalance_tree", "(", "tree", "->", "right", ")", ";", "direction", "=", "tree", "->", "right_weight", "-", "tree", "->", "left_weight", ";", "difference", "=", "direction", ";", "if", "(", "difference", "<", "0", ")", "difference", "=", "-", "difference", ";", "if", "(", "difference", "<=", "BALANCE_THRESHOLD", ")", "return", ";", "if", "(", "direction", ">", "0", ")", "{", "#ifdef", "CONSIDER_IMBALANCE", "l", "=", "tree", "->", "right", "->", "left_weight", "+", "tree", "->", "right_weight", ";", "r", "=", "tree", "->", "right", "->", "right_weight", ";", "imbalance", "=", "l", "-", "r", ";", "if", "(", "imbalance", "<", "0", ")", "imbalance", "=", "-", "imbalance", ";", "if", "(", "imbalance", ">=", "difference", ")", "return", ";", "#endif", "promote", "=", "tree", "->", "right", ";", "demote", "=", "tree", ";", "demote", "->", "right", "=", "promote", "->", "left", ";", "demote", "->", "right_weight", "=", "promote", "->", "left_weight", ";", "promote", "->", "left", "=", "demote", ";", "promote", "->", "left_weight", "=", "demote", "->", "left_weight", "+", "demote", "->", "right_weight", "+", "1", ";", "promote", "->", "parent", "=", "demote", "->", "parent", ";", "if", "(", "demote", "->", "right", ")", "demote", "->", "right", "->", "parent", "=", "demote", ";", "demote", "->", "parent", "=", "promote", ";", "if", "(", "promote", "->", "parent", "==", "NULL", ")", "checktree", "=", "promote", ";", "else", "if", "(", "promote", "->", "parent", "->", "left", "==", "demote", ")", "promote", "->", "parent", "->", "left", "=", "promote", ";", "else", "promote", "->", "parent", "->", "right", "=", "promote", ";", "return", ";", "}", "else", "if", "(", "direction", "<", "0", ")", "{", "#ifdef", "CONSIDER_IMBALANCE", "r", "=", "tree", "->", "left", "->", "right_weight", "+", "tree", "->", "left_weight", ";", "l", "=", "tree", "->", "left", "->", "left_weight", ";", "imbalance", "=", "r", "-", "l", ";", "if", "(", "imbalance", "<", "0", ")", "imbalance", "=", "-", "imbalance", ";", "if", "(", "imbalance", ">=", "difference", ")", "return", ";", "#endif", "promote", "=", "tree", "->", "left", ";", "demote", "=", "tree", ";", "demote", "->", "left", "=", "promote", "->", "right", ";", "demote", "->", "left_weight", "=", "promote", "->", "right_weight", ";", "promote", "->", "right", "=", "demote", ";", "promote", "->", "right_weight", "=", "demote", "->", "right_weight", "+", "demote", "->", "left_weight", "+", "1", ";", "promote", "->", "parent", "=", "demote", "->", "parent", ";", "if", "(", "demote", "->", "left", ")", "demote", "->", "left", "->", "parent", "=", "demote", ";", "demote", "->", "parent", "=", "promote", ";", "if", "(", "promote", "->", "parent", "==", "NULL", ")", "checktree", "=", "promote", ";", "else", "if", "(", "promote", "->", "parent", "->", "left", "==", "demote", ")", "promote", "->", "parent", "->", "left", "=", "promote", ";", "else", "promote", "->", "parent", "->", "right", "=", "promote", ";", "return", ";", "}", "return", ";", "}" ]
Rebalance the file tree to reduce search depth
[ "Rebalance", "the", "file", "tree", "to", "reduce", "search", "depth" ]
[ "/* Rebalance all children first */", "/* If weights are within a certain threshold, do nothing */", "/* Determine if a tree rotation will help, and do it if so */", "/* Don't rotate if imbalance will increase */", "/* CONSIDER_IMBALANCE */", "/* Rotate the right node up one level */", "/* Attach new parent's left tree to old parent */", "/* Attach old parent to new parent */", "/* Reconnect parent linkages */", "/* Don't rotate if imbalance will increase */", "/* CONSIDER_IMBALANCE */", "/* Rotate the left node up one level */", "/* Attach new parent's right tree to old parent */", "/* Attach old parent to new parent */", "/* Reconnect parent linkages */", "/* Fall through */" ]
[ { "param": "tree", "type": "filetree_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tree", "type": "filetree_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e6dd9cb2b72899b140766759c9c004c69bc8a6d3
skadauke/jdupes
jdupes.c
[ "MIT" ]
C
confirmmatch
int
static inline int confirmmatch(FILE * const restrict file1, FILE * const restrict file2, off_t size) { static char c1[CHUNK_SIZE], c2[CHUNK_SIZE]; size_t r1, r2; off_t bytes = 0; int check = 0; if (file1 == NULL || file2 == NULL) nullptr("confirmmatch()"); LOUD(fprintf(stderr, "confirmmatch running\n")); fseek(file1, 0, SEEK_SET); fseek(file2, 0, SEEK_SET); do { if (interrupt) return 0; r1 = fread(c1, sizeof(char), auto_chunk_size, file1); r2 = fread(c2, sizeof(char), auto_chunk_size, file2); if (r1 != r2) return 0; /* file lengths are different */ if (memcmp (c1, c2, r1)) return 0; /* file contents are different */ if (!ISFLAG(flags, F_HIDEPROGRESS)) { check++; bytes += (off_t)r1; if (check > CHECK_MINIMUM) { update_progress("confirm", (int)((bytes * 100) / size)); check = 0; } } } while (r2); return 1; }
/* Do a byte-by-byte comparison in case two different files produce the same signature. Unlikely, but better safe than sorry. */
Do a byte-by-byte comparison in case two different files produce the same signature. Unlikely, but better safe than sorry.
[ "Do", "a", "byte", "-", "by", "-", "byte", "comparison", "in", "case", "two", "different", "files", "produce", "the", "same", "signature", ".", "Unlikely", "but", "better", "safe", "than", "sorry", "." ]
static inline int confirmmatch(FILE * const restrict file1, FILE * const restrict file2, off_t size) { static char c1[CHUNK_SIZE], c2[CHUNK_SIZE]; size_t r1, r2; off_t bytes = 0; int check = 0; if (file1 == NULL || file2 == NULL) nullptr("confirmmatch()"); LOUD(fprintf(stderr, "confirmmatch running\n")); fseek(file1, 0, SEEK_SET); fseek(file2, 0, SEEK_SET); do { if (interrupt) return 0; r1 = fread(c1, sizeof(char), auto_chunk_size, file1); r2 = fread(c2, sizeof(char), auto_chunk_size, file2); if (r1 != r2) return 0; if (memcmp (c1, c2, r1)) return 0; if (!ISFLAG(flags, F_HIDEPROGRESS)) { check++; bytes += (off_t)r1; if (check > CHECK_MINIMUM) { update_progress("confirm", (int)((bytes * 100) / size)); check = 0; } } } while (r2); return 1; }
[ "static", "inline", "int", "confirmmatch", "(", "FILE", "*", "const", "restrict", "file1", ",", "FILE", "*", "const", "restrict", "file2", ",", "off_t", "size", ")", "{", "static", "char", "c1", "[", "CHUNK_SIZE", "]", ",", "c2", "[", "CHUNK_SIZE", "]", ";", "size_t", "r1", ",", "r2", ";", "off_t", "bytes", "=", "0", ";", "int", "check", "=", "0", ";", "if", "(", "file1", "==", "NULL", "||", "file2", "==", "NULL", ")", "nullptr", "(", "\"", "\"", ")", ";", "LOUD", "(", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ")", ")", ";", "fseek", "(", "file1", ",", "0", ",", "SEEK_SET", ")", ";", "fseek", "(", "file2", ",", "0", ",", "SEEK_SET", ")", ";", "do", "{", "if", "(", "interrupt", ")", "return", "0", ";", "r1", "=", "fread", "(", "c1", ",", "sizeof", "(", "char", ")", ",", "auto_chunk_size", ",", "file1", ")", ";", "r2", "=", "fread", "(", "c2", ",", "sizeof", "(", "char", ")", ",", "auto_chunk_size", ",", "file2", ")", ";", "if", "(", "r1", "!=", "r2", ")", "return", "0", ";", "if", "(", "memcmp", "(", "c1", ",", "c2", ",", "r1", ")", ")", "return", "0", ";", "if", "(", "!", "ISFLAG", "(", "flags", ",", "F_HIDEPROGRESS", ")", ")", "{", "check", "++", ";", "bytes", "+=", "(", "off_t", ")", "r1", ";", "if", "(", "check", ">", "CHECK_MINIMUM", ")", "{", "update_progress", "(", "\"", "\"", ",", "(", "int", ")", "(", "(", "bytes", "*", "100", ")", "/", "size", ")", ")", ";", "check", "=", "0", ";", "}", "}", "}", "while", "(", "r2", ")", ";", "return", "1", ";", "}" ]
Do a byte-by-byte comparison in case two different files produce the same signature.
[ "Do", "a", "byte", "-", "by", "-", "byte", "comparison", "in", "case", "two", "different", "files", "produce", "the", "same", "signature", "." ]
[ "/* file lengths are different */", "/* file contents are different */" ]
[ { "param": "file1", "type": "FILE" }, { "param": "file2", "type": "FILE" }, { "param": "size", "type": "off_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "file1", "type": "FILE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "file2", "type": "FILE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "off_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
cd7e3087f8e4d40272ed011377bae2e6c71cfc87
SiliconLabs/Gecko_SDK
app/common/example/se_manager_tamper/app_process.c
[ "Zlib" ]
C
app_iostream_usart_process_action
void
static void app_iostream_usart_process_action(void) { int8_t c; c = getchar(); if (c > 0) { if (c == ' ') { space_press = true; } if (c == '\r') { enter_press = true; } } }
/***************************************************************************/ /** * Retrieve input character from VCOM port. ******************************************************************************/
Retrieve input character from VCOM port.
[ "Retrieve", "input", "character", "from", "VCOM", "port", "." ]
static void app_iostream_usart_process_action(void) { int8_t c; c = getchar(); if (c > 0) { if (c == ' ') { space_press = true; } if (c == '\r') { enter_press = true; } } }
[ "static", "void", "app_iostream_usart_process_action", "(", "void", ")", "{", "int8_t", "c", ";", "c", "=", "getchar", "(", ")", ";", "if", "(", "c", ">", "0", ")", "{", "if", "(", "c", "==", "'", "'", ")", "{", "space_press", "=", "true", ";", "}", "if", "(", "c", "==", "'", "\\r", "'", ")", "{", "enter_press", "=", "true", ";", "}", "}", "}" ]
Retrieve input character from VCOM port.
[ "Retrieve", "input", "character", "from", "VCOM", "port", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
cd7e3087f8e4d40272ed011377bae2e6c71cfc87
SiliconLabs/Gecko_SDK
app/common/example/se_manager_tamper/app_process.c
[ "Zlib" ]
C
print_tamper_conf
void
static void print_tamper_conf(void) { uint32_t i; sl_se_otp_init_t *conf = get_se_otp_conf_buf_ptr(); // Print tamper configuration printf(" + Secure boot: "); if (conf->enable_secure_boot) { printf("Enabled\n"); } else { printf("Disabled\n"); } printf(" + Tamper source level\n"); for (i = 0; i < SL_SE_TAMPER_SIGNAL_NUM_SIGNALS; i++) { if (tamper_source[i] != NULL) { printf(" %s %d\n", tamper_source[i], conf->tamper_levels[i]); } } printf(" + Reset period for the tamper filter counter: ~32 ms x %u\n", 1 << conf->tamper_filter_period); printf(" + Activation threshold for the tamper filter: %d\n", 256 / (1 << conf->tamper_filter_threshold)); if (conf->tamper_flags) { printf(" + Digital glitch detector always on: Enabled\n"); } else { printf(" + Digital glitch detector always on: Disabled\n"); } printf(" + Tamper reset threshold: %d\n", conf->tamper_reset_threshold); // Check tamper configuration can run on this example or not if (conf->tamper_levels[SL_SE_TAMPER_SIGNAL_FILTER_COUNTER] == SL_SE_TAMPER_LEVEL_INTERRUPT && conf->tamper_levels[SL_SE_TAMPER_SIGNAL_PRS0] == SL_SE_TAMPER_LEVEL_INTERRUPT && conf->tamper_levels[SL_SE_TAMPER_SIGNAL_PRS2] == SL_SE_TAMPER_LEVEL_FILTER && conf->tamper_levels[SL_SE_TAMPER_SIGNAL_PRS4] == SL_SE_TAMPER_LEVEL_RESET && conf->tamper_levels[SL_SE_TAMPER_SIGNAL_PRS5] == SL_SE_TAMPER_LEVEL_RESET && conf->tamper_filter_period == SL_SE_TAMPER_FILTER_PERIOD_33S && conf->tamper_filter_threshold >= SL_SE_TAMPER_FILTER_THRESHOLD_8 && conf->tamper_reset_threshold <= 8) { print_tamper_test(); } else { printf(" + The tamper configuration does not match with this example.\n"); app_state = SE_MANAGER_EXIT; } }
/***************************************************************************/ /** * Print and verify tamper configuration. ******************************************************************************/
Print and verify tamper configuration.
[ "Print", "and", "verify", "tamper", "configuration", "." ]
static void print_tamper_conf(void) { uint32_t i; sl_se_otp_init_t *conf = get_se_otp_conf_buf_ptr(); printf(" + Secure boot: "); if (conf->enable_secure_boot) { printf("Enabled\n"); } else { printf("Disabled\n"); } printf(" + Tamper source level\n"); for (i = 0; i < SL_SE_TAMPER_SIGNAL_NUM_SIGNALS; i++) { if (tamper_source[i] != NULL) { printf(" %s %d\n", tamper_source[i], conf->tamper_levels[i]); } } printf(" + Reset period for the tamper filter counter: ~32 ms x %u\n", 1 << conf->tamper_filter_period); printf(" + Activation threshold for the tamper filter: %d\n", 256 / (1 << conf->tamper_filter_threshold)); if (conf->tamper_flags) { printf(" + Digital glitch detector always on: Enabled\n"); } else { printf(" + Digital glitch detector always on: Disabled\n"); } printf(" + Tamper reset threshold: %d\n", conf->tamper_reset_threshold); if (conf->tamper_levels[SL_SE_TAMPER_SIGNAL_FILTER_COUNTER] == SL_SE_TAMPER_LEVEL_INTERRUPT && conf->tamper_levels[SL_SE_TAMPER_SIGNAL_PRS0] == SL_SE_TAMPER_LEVEL_INTERRUPT && conf->tamper_levels[SL_SE_TAMPER_SIGNAL_PRS2] == SL_SE_TAMPER_LEVEL_FILTER && conf->tamper_levels[SL_SE_TAMPER_SIGNAL_PRS4] == SL_SE_TAMPER_LEVEL_RESET && conf->tamper_levels[SL_SE_TAMPER_SIGNAL_PRS5] == SL_SE_TAMPER_LEVEL_RESET && conf->tamper_filter_period == SL_SE_TAMPER_FILTER_PERIOD_33S && conf->tamper_filter_threshold >= SL_SE_TAMPER_FILTER_THRESHOLD_8 && conf->tamper_reset_threshold <= 8) { print_tamper_test(); } else { printf(" + The tamper configuration does not match with this example.\n"); app_state = SE_MANAGER_EXIT; } }
[ "static", "void", "print_tamper_conf", "(", "void", ")", "{", "uint32_t", "i", ";", "sl_se_otp_init_t", "*", "conf", "=", "get_se_otp_conf_buf_ptr", "(", ")", ";", "printf", "(", "\"", "\"", ")", ";", "if", "(", "conf", "->", "enable_secure_boot", ")", "{", "printf", "(", "\"", "\\n", "\"", ")", ";", "}", "else", "{", "printf", "(", "\"", "\\n", "\"", ")", ";", "}", "printf", "(", "\"", "\\n", "\"", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "SL_SE_TAMPER_SIGNAL_NUM_SIGNALS", ";", "i", "++", ")", "{", "if", "(", "tamper_source", "[", "i", "]", "!=", "NULL", ")", "{", "printf", "(", "\"", "\\n", "\"", ",", "tamper_source", "[", "i", "]", ",", "conf", "->", "tamper_levels", "[", "i", "]", ")", ";", "}", "}", "printf", "(", "\"", "\\n", "\"", ",", "1", "<<", "conf", "->", "tamper_filter_period", ")", ";", "printf", "(", "\"", "\\n", "\"", ",", "256", "/", "(", "1", "<<", "conf", "->", "tamper_filter_threshold", ")", ")", ";", "if", "(", "conf", "->", "tamper_flags", ")", "{", "printf", "(", "\"", "\\n", "\"", ")", ";", "}", "else", "{", "printf", "(", "\"", "\\n", "\"", ")", ";", "}", "printf", "(", "\"", "\\n", "\"", ",", "conf", "->", "tamper_reset_threshold", ")", ";", "if", "(", "conf", "->", "tamper_levels", "[", "SL_SE_TAMPER_SIGNAL_FILTER_COUNTER", "]", "==", "SL_SE_TAMPER_LEVEL_INTERRUPT", "&&", "conf", "->", "tamper_levels", "[", "SL_SE_TAMPER_SIGNAL_PRS0", "]", "==", "SL_SE_TAMPER_LEVEL_INTERRUPT", "&&", "conf", "->", "tamper_levels", "[", "SL_SE_TAMPER_SIGNAL_PRS2", "]", "==", "SL_SE_TAMPER_LEVEL_FILTER", "&&", "conf", "->", "tamper_levels", "[", "SL_SE_TAMPER_SIGNAL_PRS4", "]", "==", "SL_SE_TAMPER_LEVEL_RESET", "&&", "conf", "->", "tamper_levels", "[", "SL_SE_TAMPER_SIGNAL_PRS5", "]", "==", "SL_SE_TAMPER_LEVEL_RESET", "&&", "conf", "->", "tamper_filter_period", "==", "SL_SE_TAMPER_FILTER_PERIOD_33S", "&&", "conf", "->", "tamper_filter_threshold", ">=", "SL_SE_TAMPER_FILTER_THRESHOLD_8", "&&", "conf", "->", "tamper_reset_threshold", "<=", "8", ")", "{", "print_tamper_test", "(", ")", ";", "}", "else", "{", "printf", "(", "\"", "\\n", "\"", ")", ";", "app_state", "=", "SE_MANAGER_EXIT", ";", "}", "}" ]
Print and verify tamper configuration.
[ "Print", "and", "verify", "tamper", "configuration", "." ]
[ "// Print tamper configuration", "// Check tamper configuration can run on this example or not" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
cd7e3087f8e4d40272ed011377bae2e6c71cfc87
SiliconLabs/Gecko_SDK
app/common/example/se_manager_tamper/app_process.c
[ "Zlib" ]
C
print_buf
void
void print_buf(uint8_t *buf, size_t len) { uint32_t i; uint8_t hex_array[16] = "0123456789ABCDEF"; for (i = 0; i < len; i++) { if ((i % 16) == 0) { printf("\n "); } printf("%c", hex_array[(buf[i] >> 4) & 0x0f]); printf("%c ", hex_array[buf[i] & 0x0f]); } printf("\n"); }
/***************************************************************************/ /** * Print buffer data in ASCII hex. ******************************************************************************/
Print buffer data in ASCII hex.
[ "Print", "buffer", "data", "in", "ASCII", "hex", "." ]
void print_buf(uint8_t *buf, size_t len) { uint32_t i; uint8_t hex_array[16] = "0123456789ABCDEF"; for (i = 0; i < len; i++) { if ((i % 16) == 0) { printf("\n "); } printf("%c", hex_array[(buf[i] >> 4) & 0x0f]); printf("%c ", hex_array[buf[i] & 0x0f]); } printf("\n"); }
[ "void", "print_buf", "(", "uint8_t", "*", "buf", ",", "size_t", "len", ")", "{", "uint32_t", "i", ";", "uint8_t", "hex_array", "[", "16", "]", "=", "\"", "\"", ";", "for", "(", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "if", "(", "(", "i", "%", "16", ")", "==", "0", ")", "{", "printf", "(", "\"", "\\n", "\"", ")", ";", "}", "printf", "(", "\"", "\"", ",", "hex_array", "[", "(", "buf", "[", "i", "]", ">>", "4", ")", "&", "0x0f", "]", ")", ";", "printf", "(", "\"", "\"", ",", "hex_array", "[", "buf", "[", "i", "]", "&", "0x0f", "]", ")", ";", "}", "printf", "(", "\"", "\\n", "\"", ")", ";", "}" ]
Print buffer data in ASCII hex.
[ "Print", "buffer", "data", "in", "ASCII", "hex", "." ]
[]
[ { "param": "buf", "type": "uint8_t" }, { "param": "len", "type": "size_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "buf", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "len", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
cd7e3087f8e4d40272ed011377bae2e6c71cfc87
SiliconLabs/Gecko_SDK
app/common/example/se_manager_tamper/app_process.c
[ "Zlib" ]
C
issue_tamper_disable
void
static void issue_tamper_disable(void) { app_state = SE_MANAGER_EXIT; printf("\n . Start the tamper disable processes.\n"); printf(" + Creating a private certificate key in a buffer... "); if (create_private_certificate_key() != SL_STATUS_OK) { return; } printf(" + Exporting a public certificate key from a private certificate " "key... "); if (export_public_certificate_key() != SL_STATUS_OK) { return; } printf(" + Read the serial number of the SE and save it to access " "certificate... "); if (read_serial_number() != SL_STATUS_OK) { return; } printf(" + Signing the access certificate with private command key... "); if (sign_access_certificate() != SL_STATUS_OK) { return; } printf(" + Request challenge from the SE and save it to challenge " "response... "); if (request_challenge() != SL_STATUS_OK) { return; } printf(" + Signing the challenge response with private certificate key... "); if (sign_challenge_response() != SL_STATUS_OK) { return; } printf(" + Creating a tamper disable token to disable tamper signals... "); if (create_tamper_disable_token() == SL_STATUS_OK) { printf(" + Success to disable the tamper signals!\n"); // Print tamper disable test instructions printf("\n . Tamper disable test instructions:\n"); printf(" + Press PB0 to increase filter counter and tamper status " "is displayed.\n"); printf(" + PRS will NOT issue a tamper reset even filter counter reaches " "%d within ~32 ms x %u.\n", 256 / (1 << get_se_otp_conf_buf_ptr()->tamper_filter_threshold), 1 << get_se_otp_conf_buf_ptr()->tamper_filter_period); printf(" + Press PB1 will NOT issue a tamper reset.\n"); printf(" + Issue a power-on or pin reset to re-enable the tamper " "signals.\n"); printf(" + Press ENTER to roll the challenge to invalidate the current " "tamper disable token or press SPACE to exit.\n"); enable_tamper_int(); init_tamper_prs(); app_state = WAIT_TAMPER_SIGNAL; } else { printf(" + Fail to disable the tamper signals!\n"); } }
/***************************************************************************/ /** * Issue a tamper disable token to the device. ******************************************************************************/
Issue a tamper disable token to the device.
[ "Issue", "a", "tamper", "disable", "token", "to", "the", "device", "." ]
static void issue_tamper_disable(void) { app_state = SE_MANAGER_EXIT; printf("\n . Start the tamper disable processes.\n"); printf(" + Creating a private certificate key in a buffer... "); if (create_private_certificate_key() != SL_STATUS_OK) { return; } printf(" + Exporting a public certificate key from a private certificate " "key... "); if (export_public_certificate_key() != SL_STATUS_OK) { return; } printf(" + Read the serial number of the SE and save it to access " "certificate... "); if (read_serial_number() != SL_STATUS_OK) { return; } printf(" + Signing the access certificate with private command key... "); if (sign_access_certificate() != SL_STATUS_OK) { return; } printf(" + Request challenge from the SE and save it to challenge " "response... "); if (request_challenge() != SL_STATUS_OK) { return; } printf(" + Signing the challenge response with private certificate key... "); if (sign_challenge_response() != SL_STATUS_OK) { return; } printf(" + Creating a tamper disable token to disable tamper signals... "); if (create_tamper_disable_token() == SL_STATUS_OK) { printf(" + Success to disable the tamper signals!\n"); printf("\n . Tamper disable test instructions:\n"); printf(" + Press PB0 to increase filter counter and tamper status " "is displayed.\n"); printf(" + PRS will NOT issue a tamper reset even filter counter reaches " "%d within ~32 ms x %u.\n", 256 / (1 << get_se_otp_conf_buf_ptr()->tamper_filter_threshold), 1 << get_se_otp_conf_buf_ptr()->tamper_filter_period); printf(" + Press PB1 will NOT issue a tamper reset.\n"); printf(" + Issue a power-on or pin reset to re-enable the tamper " "signals.\n"); printf(" + Press ENTER to roll the challenge to invalidate the current " "tamper disable token or press SPACE to exit.\n"); enable_tamper_int(); init_tamper_prs(); app_state = WAIT_TAMPER_SIGNAL; } else { printf(" + Fail to disable the tamper signals!\n"); } }
[ "static", "void", "issue_tamper_disable", "(", "void", ")", "{", "app_state", "=", "SE_MANAGER_EXIT", ";", "printf", "(", "\"", "\\n", "\\n", "\"", ")", ";", "printf", "(", "\"", "\"", ")", ";", "if", "(", "create_private_certificate_key", "(", ")", "!=", "SL_STATUS_OK", ")", "{", "return", ";", "}", "printf", "(", "\"", "\"", "\"", "\"", ")", ";", "if", "(", "export_public_certificate_key", "(", ")", "!=", "SL_STATUS_OK", ")", "{", "return", ";", "}", "printf", "(", "\"", "\"", "\"", "\"", ")", ";", "if", "(", "read_serial_number", "(", ")", "!=", "SL_STATUS_OK", ")", "{", "return", ";", "}", "printf", "(", "\"", "\"", ")", ";", "if", "(", "sign_access_certificate", "(", ")", "!=", "SL_STATUS_OK", ")", "{", "return", ";", "}", "printf", "(", "\"", "\"", "\"", "\"", ")", ";", "if", "(", "request_challenge", "(", ")", "!=", "SL_STATUS_OK", ")", "{", "return", ";", "}", "printf", "(", "\"", "\"", ")", ";", "if", "(", "sign_challenge_response", "(", ")", "!=", "SL_STATUS_OK", ")", "{", "return", ";", "}", "printf", "(", "\"", "\"", ")", ";", "if", "(", "create_tamper_disable_token", "(", ")", "==", "SL_STATUS_OK", ")", "{", "printf", "(", "\"", "\\n", "\"", ")", ";", "printf", "(", "\"", "\\n", "\\n", "\"", ")", ";", "printf", "(", "\"", "\"", "\"", "\\n", "\"", ")", ";", "printf", "(", "\"", "\"", "\"", "\\n", "\"", ",", "256", "/", "(", "1", "<<", "get_se_otp_conf_buf_ptr", "(", ")", "->", "tamper_filter_threshold", ")", ",", "1", "<<", "get_se_otp_conf_buf_ptr", "(", ")", "->", "tamper_filter_period", ")", ";", "printf", "(", "\"", "\\n", "\"", ")", ";", "printf", "(", "\"", "\"", "\"", "\\n", "\"", ")", ";", "printf", "(", "\"", "\"", "\"", "\\n", "\"", ")", ";", "enable_tamper_int", "(", ")", ";", "init_tamper_prs", "(", ")", ";", "app_state", "=", "WAIT_TAMPER_SIGNAL", ";", "}", "else", "{", "printf", "(", "\"", "\\n", "\"", ")", ";", "}", "}" ]
Issue a tamper disable token to the device.
[ "Issue", "a", "tamper", "disable", "token", "to", "the", "device", "." ]
[ "// Print tamper disable test instructions" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
315a799802839c9b000bbd4a71dc3fa173738474
SiliconLabs/Gecko_SDK
platform/radio/rail_lib/plugin/coexistence/hal/efr32/coexistence-hal.c
[ "Zlib" ]
C
linearFeedbackShift
uint16_t
static uint16_t linearFeedbackShift(uint16_t *val, uint16_t taps) { uint16_t newVal = *val; if ((newVal & 0x8000U) != 0U) { newVal ^= taps; } *val = newVal << 1; return newVal; }
/***************************************************************************/ /** * This function performs a linear feedback shift. * @param val Pointer to random seed to update * @param taps The feedback polynomial mask * * @return Returns a 16 bit random value. * ******************************************************************************/
This function performs a linear feedback shift. @param val Pointer to random seed to update @param taps The feedback polynomial mask @return Returns a 16 bit random value.
[ "This", "function", "performs", "a", "linear", "feedback", "shift", ".", "@param", "val", "Pointer", "to", "random", "seed", "to", "update", "@param", "taps", "The", "feedback", "polynomial", "mask", "@return", "Returns", "a", "16", "bit", "random", "value", "." ]
static uint16_t linearFeedbackShift(uint16_t *val, uint16_t taps) { uint16_t newVal = *val; if ((newVal & 0x8000U) != 0U) { newVal ^= taps; } *val = newVal << 1; return newVal; }
[ "static", "uint16_t", "linearFeedbackShift", "(", "uint16_t", "*", "val", ",", "uint16_t", "taps", ")", "{", "uint16_t", "newVal", "=", "*", "val", ";", "if", "(", "(", "newVal", "&", "0x8000U", ")", "!=", "0U", ")", "{", "newVal", "^=", "taps", ";", "}", "*", "val", "=", "newVal", "<<", "1", ";", "return", "newVal", ";", "}" ]
This function performs a linear feedback shift.
[ "This", "function", "performs", "a", "linear", "feedback", "shift", "." ]
[]
[ { "param": "val", "type": "uint16_t" }, { "param": "taps", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "val", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "taps", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
315a799802839c9b000bbd4a71dc3fa173738474
SiliconLabs/Gecko_SDK
platform/radio/rail_lib/plugin/coexistence/hal/efr32/coexistence-hal.c
[ "Zlib" ]
C
seedPseudoRandom
void
static void seedPseudoRandom(void) { randomSeed[0] = (uint16_t)DEVINFO->EUI48L; pseudoRandomSeeded = true; }
/******************************************************************************* * This function seeds the pseudo random number. * ******************************************************************************/
This function seeds the pseudo random number.
[ "This", "function", "seeds", "the", "pseudo", "random", "number", "." ]
static void seedPseudoRandom(void) { randomSeed[0] = (uint16_t)DEVINFO->EUI48L; pseudoRandomSeeded = true; }
[ "static", "void", "seedPseudoRandom", "(", "void", ")", "{", "randomSeed", "[", "0", "]", "=", "(", "uint16_t", ")", "DEVINFO", "->", "EUI48L", ";", "pseudoRandomSeeded", "=", "true", ";", "}" ]
This function seeds the pseudo random number.
[ "This", "function", "seeds", "the", "pseudo", "random", "number", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
f21b416bd2d76e6df4b8a9c3d45fdcbc1b1fea3a
SiliconLabs/Gecko_SDK
protocol/z-wave/ZAF/CommandClasses/Association/association_plus.c
[ "Zlib" ]
C
ReorderGroupAfterRemove
void
static void ReorderGroupAfterRemove( uint8_t groupIden, uint8_t ep, uint8_t emptyIndx) { uint8_t move; destination_info_t * pNodeToMove; destination_info_t * pNode; const uint32_t iArraySize = sizeof_array(groups[ep][groupIden].subGrp); for(move = emptyIndx; move < (iArraySize - 1); move++) { pNode = GetNode(ep, groupIden + 1, move); pNodeToMove = GetNode(ep, groupIden + 1, move + 1); if (IsFree(pNodeToMove)) break; *pNode = *pNodeToMove; } Free(&groups[ep][groupIden].subGrp[move]); }
/** * @brief Reorders nodes in a given group. * @param groupIden Given group ID. * @param ep Given endpoint. * @param emptyIndx Location in index which must be filled up. */
@brief Reorders nodes in a given group. @param groupIden Given group ID. @param ep Given endpoint. @param emptyIndx Location in index which must be filled up.
[ "@brief", "Reorders", "nodes", "in", "a", "given", "group", ".", "@param", "groupIden", "Given", "group", "ID", ".", "@param", "ep", "Given", "endpoint", ".", "@param", "emptyIndx", "Location", "in", "index", "which", "must", "be", "filled", "up", "." ]
static void ReorderGroupAfterRemove( uint8_t groupIden, uint8_t ep, uint8_t emptyIndx) { uint8_t move; destination_info_t * pNodeToMove; destination_info_t * pNode; const uint32_t iArraySize = sizeof_array(groups[ep][groupIden].subGrp); for(move = emptyIndx; move < (iArraySize - 1); move++) { pNode = GetNode(ep, groupIden + 1, move); pNodeToMove = GetNode(ep, groupIden + 1, move + 1); if (IsFree(pNodeToMove)) break; *pNode = *pNodeToMove; } Free(&groups[ep][groupIden].subGrp[move]); }
[ "static", "void", "ReorderGroupAfterRemove", "(", "uint8_t", "groupIden", ",", "uint8_t", "ep", ",", "uint8_t", "emptyIndx", ")", "{", "uint8_t", "move", ";", "destination_info_t", "*", "pNodeToMove", ";", "destination_info_t", "*", "pNode", ";", "const", "uint32_t", "iArraySize", "=", "sizeof_array", "(", "groups", "[", "ep", "]", "[", "groupIden", "]", ".", "subGrp", ")", ";", "for", "(", "move", "=", "emptyIndx", ";", "move", "<", "(", "iArraySize", "-", "1", ")", ";", "move", "++", ")", "{", "pNode", "=", "GetNode", "(", "ep", ",", "groupIden", "+", "1", ",", "move", ")", ";", "pNodeToMove", "=", "GetNode", "(", "ep", ",", "groupIden", "+", "1", ",", "move", "+", "1", ")", ";", "if", "(", "IsFree", "(", "pNodeToMove", ")", ")", "break", ";", "*", "pNode", "=", "*", "pNodeToMove", ";", "}", "Free", "(", "&", "groups", "[", "ep", "]", "[", "groupIden", "]", ".", "subGrp", "[", "move", "]", ")", ";", "}" ]
@brief Reorders nodes in a given group.
[ "@brief", "Reorders", "nodes", "in", "a", "given", "group", "." ]
[]
[ { "param": "groupIden", "type": "uint8_t" }, { "param": "ep", "type": "uint8_t" }, { "param": "emptyIndx", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "groupIden", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ep", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "emptyIndx", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f21b416bd2d76e6df4b8a9c3d45fdcbc1b1fea3a
SiliconLabs/Gecko_SDK
protocol/z-wave/ZAF/CommandClasses/Association/association_plus.c
[ "Zlib" ]
C
isGroupIdValid
bool
static bool isGroupIdValid(uint8_t groupId, uint8_t endpoint) { if ((NOT_VALID_GROUP_ID == groupId) // Group ID zero is invalid || (CC_AGI_groupCount_handler(endpoint) < groupId )) // Check with AGI. { return false; // Not a valid group ID } return true; }
/** * Returns whether a given group ID is valid or not. * @param groupId The group ID to check. * @param endpoint The endpoint to which the group belongs. * @return true if group ID is valid, false otherwise. */
Returns whether a given group ID is valid or not. @param groupId The group ID to check. @param endpoint The endpoint to which the group belongs. @return true if group ID is valid, false otherwise.
[ "Returns", "whether", "a", "given", "group", "ID", "is", "valid", "or", "not", ".", "@param", "groupId", "The", "group", "ID", "to", "check", ".", "@param", "endpoint", "The", "endpoint", "to", "which", "the", "group", "belongs", ".", "@return", "true", "if", "group", "ID", "is", "valid", "false", "otherwise", "." ]
static bool isGroupIdValid(uint8_t groupId, uint8_t endpoint) { if ((NOT_VALID_GROUP_ID == groupId) || (CC_AGI_groupCount_handler(endpoint) < groupId )) { return false; } return true; }
[ "static", "bool", "isGroupIdValid", "(", "uint8_t", "groupId", ",", "uint8_t", "endpoint", ")", "{", "if", "(", "(", "NOT_VALID_GROUP_ID", "==", "groupId", ")", "||", "(", "CC_AGI_groupCount_handler", "(", "endpoint", ")", "<", "groupId", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Returns whether a given group ID is valid or not.
[ "Returns", "whether", "a", "given", "group", "ID", "is", "valid", "or", "not", "." ]
[ "// Group ID zero is invalid", "// Check with AGI.", "// Not a valid group ID" ]
[ { "param": "groupId", "type": "uint8_t" }, { "param": "endpoint", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "groupId", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "endpoint", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f21b416bd2d76e6df4b8a9c3d45fdcbc1b1fea3a
SiliconLabs/Gecko_SDK
protocol/z-wave/ZAF/CommandClasses/Association/association_plus.c
[ "Zlib" ]
C
IsNewNodeGreater
int32_t
static int32_t IsNewNodeGreater(destination_info_t * pNodeExisting, destination_info_t * pNodeNew) { // Check to see if they are equal (memcmp() could not be used for this) if ( (pNodeExisting->node.nodeId == pNodeNew->node.nodeId) && (pNodeExisting->node.endpoint == pNodeNew->node.endpoint) && (pNodeExisting->node.BitAddress == pNodeNew->node.BitAddress)) { return 0; // Equal/Identical } /* * In case of endpoints that are higher than 7, we have a special case where we no longer can use BitAddressing, * so we must treat these as none-endpoint node associations. Doing the following will push the new node further * down in the list of nodes during sorting in node addition. */ if (pNodeNew->node.endpoint > ENDPOINT_VALUE_VALID_MAX) { if (pNodeExisting->node.endpoint < pNodeNew->node.endpoint) { return -1; // The new node is bigger than the existing node } else if (pNodeExisting->node.endpoint > pNodeNew->node.endpoint) { return 1; // The new node is smaller than the existing node } } // Check to see if the new node is smaller or bigger than pNodeExisting. if ((pNodeExisting->node.nodeId > pNodeNew->node.nodeId) && (pNodeExisting->node.endpoint >= ENDPOINT_VALUE_VALID_MIN) && (0 == pNodeNew->node.endpoint)) { return -1; // The new node is bigger than the existing node } else if ((pNodeExisting->node.nodeId < pNodeNew->node.nodeId) && (pNodeNew->node.endpoint >= ENDPOINT_VALUE_VALID_MIN) && (0 == pNodeExisting->node.endpoint)) { return 1; // The new node is smaller than the existing node } // As last resort, use memcmp() to get a comparison value return memcmp(&pNodeExisting->node, &pNodeNew->node, sizeof(MULTICHAN_DEST_NODE_ID)); }
/** * Returns the result of comparing two nodes. * * The function compares node ID and endpoint, but has one twist: It considers a node with an * endpoint as a lower node than a node without an endpoint. * * NOTICE that it does matter which node is passed to which argument. * @param pNodeExisting Must be the existing node. * @param pNodeNew Must be a new node to insert in the list of existing nodes. * @return -1 means that the new node is bigger than the existing node, 1 is vice versa, and 0 is equal! */
Returns the result of comparing two nodes. The function compares node ID and endpoint, but has one twist: It considers a node with an endpoint as a lower node than a node without an endpoint. NOTICE that it does matter which node is passed to which argument. @param pNodeExisting Must be the existing node. @param pNodeNew Must be a new node to insert in the list of existing nodes. @return -1 means that the new node is bigger than the existing node, 1 is vice versa, and 0 is equal!
[ "Returns", "the", "result", "of", "comparing", "two", "nodes", ".", "The", "function", "compares", "node", "ID", "and", "endpoint", "but", "has", "one", "twist", ":", "It", "considers", "a", "node", "with", "an", "endpoint", "as", "a", "lower", "node", "than", "a", "node", "without", "an", "endpoint", ".", "NOTICE", "that", "it", "does", "matter", "which", "node", "is", "passed", "to", "which", "argument", ".", "@param", "pNodeExisting", "Must", "be", "the", "existing", "node", ".", "@param", "pNodeNew", "Must", "be", "a", "new", "node", "to", "insert", "in", "the", "list", "of", "existing", "nodes", ".", "@return", "-", "1", "means", "that", "the", "new", "node", "is", "bigger", "than", "the", "existing", "node", "1", "is", "vice", "versa", "and", "0", "is", "equal!" ]
static int32_t IsNewNodeGreater(destination_info_t * pNodeExisting, destination_info_t * pNodeNew) { if ( (pNodeExisting->node.nodeId == pNodeNew->node.nodeId) && (pNodeExisting->node.endpoint == pNodeNew->node.endpoint) && (pNodeExisting->node.BitAddress == pNodeNew->node.BitAddress)) { return 0; } if (pNodeNew->node.endpoint > ENDPOINT_VALUE_VALID_MAX) { if (pNodeExisting->node.endpoint < pNodeNew->node.endpoint) { return -1; } else if (pNodeExisting->node.endpoint > pNodeNew->node.endpoint) { return 1; } } if ((pNodeExisting->node.nodeId > pNodeNew->node.nodeId) && (pNodeExisting->node.endpoint >= ENDPOINT_VALUE_VALID_MIN) && (0 == pNodeNew->node.endpoint)) { return -1; } else if ((pNodeExisting->node.nodeId < pNodeNew->node.nodeId) && (pNodeNew->node.endpoint >= ENDPOINT_VALUE_VALID_MIN) && (0 == pNodeExisting->node.endpoint)) { return 1; } return memcmp(&pNodeExisting->node, &pNodeNew->node, sizeof(MULTICHAN_DEST_NODE_ID)); }
[ "static", "int32_t", "IsNewNodeGreater", "(", "destination_info_t", "*", "pNodeExisting", ",", "destination_info_t", "*", "pNodeNew", ")", "{", "if", "(", "(", "pNodeExisting", "->", "node", ".", "nodeId", "==", "pNodeNew", "->", "node", ".", "nodeId", ")", "&&", "(", "pNodeExisting", "->", "node", ".", "endpoint", "==", "pNodeNew", "->", "node", ".", "endpoint", ")", "&&", "(", "pNodeExisting", "->", "node", ".", "BitAddress", "==", "pNodeNew", "->", "node", ".", "BitAddress", ")", ")", "{", "return", "0", ";", "}", "if", "(", "pNodeNew", "->", "node", ".", "endpoint", ">", "ENDPOINT_VALUE_VALID_MAX", ")", "{", "if", "(", "pNodeExisting", "->", "node", ".", "endpoint", "<", "pNodeNew", "->", "node", ".", "endpoint", ")", "{", "return", "-1", ";", "}", "else", "if", "(", "pNodeExisting", "->", "node", ".", "endpoint", ">", "pNodeNew", "->", "node", ".", "endpoint", ")", "{", "return", "1", ";", "}", "}", "if", "(", "(", "pNodeExisting", "->", "node", ".", "nodeId", ">", "pNodeNew", "->", "node", ".", "nodeId", ")", "&&", "(", "pNodeExisting", "->", "node", ".", "endpoint", ">=", "ENDPOINT_VALUE_VALID_MIN", ")", "&&", "(", "0", "==", "pNodeNew", "->", "node", ".", "endpoint", ")", ")", "{", "return", "-1", ";", "}", "else", "if", "(", "(", "pNodeExisting", "->", "node", ".", "nodeId", "<", "pNodeNew", "->", "node", ".", "nodeId", ")", "&&", "(", "pNodeNew", "->", "node", ".", "endpoint", ">=", "ENDPOINT_VALUE_VALID_MIN", ")", "&&", "(", "0", "==", "pNodeExisting", "->", "node", ".", "endpoint", ")", ")", "{", "return", "1", ";", "}", "return", "memcmp", "(", "&", "pNodeExisting", "->", "node", ",", "&", "pNodeNew", "->", "node", ",", "sizeof", "(", "MULTICHAN_DEST_NODE_ID", ")", ")", ";", "}" ]
Returns the result of comparing two nodes.
[ "Returns", "the", "result", "of", "comparing", "two", "nodes", "." ]
[ "// Check to see if they are equal (memcmp() could not be used for this)", "// Equal/Identical", "/*\n * In case of endpoints that are higher than 7, we have a special case where we no longer can use BitAddressing,\n * so we must treat these as none-endpoint node associations. Doing the following will push the new node further\n * down in the list of nodes during sorting in node addition.\n */", "// The new node is bigger than the existing node", "// The new node is smaller than the existing node", "// Check to see if the new node is smaller or bigger than pNodeExisting.", "// The new node is bigger than the existing node", "// The new node is smaller than the existing node", "// As last resort, use memcmp() to get a comparison value" ]
[ { "param": "pNodeExisting", "type": "destination_info_t" }, { "param": "pNodeNew", "type": "destination_info_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pNodeExisting", "type": "destination_info_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pNodeNew", "type": "destination_info_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f21b416bd2d76e6df4b8a9c3d45fdcbc1b1fea3a
SiliconLabs/Gecko_SDK
protocol/z-wave/ZAF/CommandClasses/Association/association_plus.c
[ "Zlib" ]
C
RemoveAssociationsFromGroup
void
static void RemoveAssociationsFromGroup( uint8_t cmdClass, uint8_t ep, uint8_t groupId, ASSOCIATION_NODE_LIST * pListOfNodes) { uint8_t numberOfNodes; // We have to go through the loop once, even when the list is empty. numberOfNodes = ((0 == pListOfNodes->noOfNodes) ? 1 : pListOfNodes->noOfNodes); // Remove all Node ID Associations in the given list. for (uint8_t i = 0; i < numberOfNodes; i++) { for (int8_t indx = MAX_ASSOCIATION_IN_GROUP - 1; indx >= 0; indx--) { destination_info_t * pCurrentNode = GetNode(ep, groupId, (uint8_t)indx); if (!IsFree(pCurrentNode) && (false == HasEndpoint(pCurrentNode)) && ((0 == pListOfNodes->noOfNodes && 0 == pListOfNodes->noOfMulchanNodes) || pCurrentNode->node.nodeId == pListOfNodes->pNodeId[i])) { DPRINTF("sa: Remove: %u.%u\n",pCurrentNode->node.nodeId, pCurrentNode->node.endpoint); Free(pCurrentNode); /* * Do reorder after freeing each entry because the command might originate from * CC Association and then endpoint destinations will not be deleted. Hence, they must be * ordered. */ ReorderGroupAfterRemove(groupId-1, ep, (uint8_t)indx); } } } if (COMMAND_CLASS_ASSOCIATION == cmdClass) { return; } numberOfNodes = ((0 == pListOfNodes->noOfMulchanNodes) ? 1 : pListOfNodes->noOfMulchanNodes); // Remove all Endpoint Node ID Associations in the given list. for (uint8_t i = 0; i < numberOfNodes; i++) { for (int8_t indx = MAX_ASSOCIATION_IN_GROUP - 1; indx >= 0; indx--) { destination_info_t * pCurrentNode = GetNode(ep, groupId, (uint8_t)indx); // Remove node if: // List of simple and multichannel nodes is zero (remove everything) // OR Remove single node with specified NodeId, EP and bitmask, and it is found in list of multichannel associations // OR Only EP was specified, but not NodeID. Then remove all associations with matching End Point. if (!IsFree(pCurrentNode) && (true == HasEndpoint(pCurrentNode)) && ((0 == pListOfNodes->noOfNodes && 0 == pListOfNodes->noOfMulchanNodes) || (((pCurrentNode->node.nodeId == pListOfNodes->pMulChanNodeId[i].nodeId) || (0 == pListOfNodes->pMulChanNodeId[i].nodeId)) && (pCurrentNode->node.endpoint == pListOfNodes->pMulChanNodeId[i].endpoint) && (pCurrentNode->node.BitAddress == pListOfNodes->pMulChanNodeId[i].BitAddress)))) { DPRINTF("mlc: Remove %u.%u\n", pCurrentNode->node.nodeId, pCurrentNode->node.endpoint); Free(pCurrentNode); /* * In case specific multi channel destinations are specified, we need to reorder those that * will not be removed. * If no multi channel destinations are specified, it means that all nodes in the group * will be removed. Hence, no need to reorder. */ if (0 < pListOfNodes->noOfMulchanNodes) { ReorderGroupAfterRemove(groupId-1, ep, (uint8_t)indx); } } } } }
/** * @brief Removes given associations or all associations from a given group. * @param cmdClass Command Class: Association or MultiChannel Association. * @param ep EndPoint to be removed, used in case of MultiChannel Association CC * @param groupId ID of the group from where the associations must be removed. * @param listOfNodes List of nodes/associations that must be removed. */
@brief Removes given associations or all associations from a given group. @param cmdClass Command Class: Association or MultiChannel Association. @param ep EndPoint to be removed, used in case of MultiChannel Association CC @param groupId ID of the group from where the associations must be removed. @param listOfNodes List of nodes/associations that must be removed.
[ "@brief", "Removes", "given", "associations", "or", "all", "associations", "from", "a", "given", "group", ".", "@param", "cmdClass", "Command", "Class", ":", "Association", "or", "MultiChannel", "Association", ".", "@param", "ep", "EndPoint", "to", "be", "removed", "used", "in", "case", "of", "MultiChannel", "Association", "CC", "@param", "groupId", "ID", "of", "the", "group", "from", "where", "the", "associations", "must", "be", "removed", ".", "@param", "listOfNodes", "List", "of", "nodes", "/", "associations", "that", "must", "be", "removed", "." ]
static void RemoveAssociationsFromGroup( uint8_t cmdClass, uint8_t ep, uint8_t groupId, ASSOCIATION_NODE_LIST * pListOfNodes) { uint8_t numberOfNodes; numberOfNodes = ((0 == pListOfNodes->noOfNodes) ? 1 : pListOfNodes->noOfNodes); for (uint8_t i = 0; i < numberOfNodes; i++) { for (int8_t indx = MAX_ASSOCIATION_IN_GROUP - 1; indx >= 0; indx--) { destination_info_t * pCurrentNode = GetNode(ep, groupId, (uint8_t)indx); if (!IsFree(pCurrentNode) && (false == HasEndpoint(pCurrentNode)) && ((0 == pListOfNodes->noOfNodes && 0 == pListOfNodes->noOfMulchanNodes) || pCurrentNode->node.nodeId == pListOfNodes->pNodeId[i])) { DPRINTF("sa: Remove: %u.%u\n",pCurrentNode->node.nodeId, pCurrentNode->node.endpoint); Free(pCurrentNode); ReorderGroupAfterRemove(groupId-1, ep, (uint8_t)indx); } } } if (COMMAND_CLASS_ASSOCIATION == cmdClass) { return; } numberOfNodes = ((0 == pListOfNodes->noOfMulchanNodes) ? 1 : pListOfNodes->noOfMulchanNodes); for (uint8_t i = 0; i < numberOfNodes; i++) { for (int8_t indx = MAX_ASSOCIATION_IN_GROUP - 1; indx >= 0; indx--) { destination_info_t * pCurrentNode = GetNode(ep, groupId, (uint8_t)indx); if (!IsFree(pCurrentNode) && (true == HasEndpoint(pCurrentNode)) && ((0 == pListOfNodes->noOfNodes && 0 == pListOfNodes->noOfMulchanNodes) || (((pCurrentNode->node.nodeId == pListOfNodes->pMulChanNodeId[i].nodeId) || (0 == pListOfNodes->pMulChanNodeId[i].nodeId)) && (pCurrentNode->node.endpoint == pListOfNodes->pMulChanNodeId[i].endpoint) && (pCurrentNode->node.BitAddress == pListOfNodes->pMulChanNodeId[i].BitAddress)))) { DPRINTF("mlc: Remove %u.%u\n", pCurrentNode->node.nodeId, pCurrentNode->node.endpoint); Free(pCurrentNode); if (0 < pListOfNodes->noOfMulchanNodes) { ReorderGroupAfterRemove(groupId-1, ep, (uint8_t)indx); } } } } }
[ "static", "void", "RemoveAssociationsFromGroup", "(", "uint8_t", "cmdClass", ",", "uint8_t", "ep", ",", "uint8_t", "groupId", ",", "ASSOCIATION_NODE_LIST", "*", "pListOfNodes", ")", "{", "uint8_t", "numberOfNodes", ";", "numberOfNodes", "=", "(", "(", "0", "==", "pListOfNodes", "->", "noOfNodes", ")", "?", "1", ":", "pListOfNodes", "->", "noOfNodes", ")", ";", "for", "(", "uint8_t", "i", "=", "0", ";", "i", "<", "numberOfNodes", ";", "i", "++", ")", "{", "for", "(", "int8_t", "indx", "=", "MAX_ASSOCIATION_IN_GROUP", "-", "1", ";", "indx", ">=", "0", ";", "indx", "--", ")", "{", "destination_info_t", "*", "pCurrentNode", "=", "GetNode", "(", "ep", ",", "groupId", ",", "(", "uint8_t", ")", "indx", ")", ";", "if", "(", "!", "IsFree", "(", "pCurrentNode", ")", "&&", "(", "false", "==", "HasEndpoint", "(", "pCurrentNode", ")", ")", "&&", "(", "(", "0", "==", "pListOfNodes", "->", "noOfNodes", "&&", "0", "==", "pListOfNodes", "->", "noOfMulchanNodes", ")", "||", "pCurrentNode", "->", "node", ".", "nodeId", "==", "pListOfNodes", "->", "pNodeId", "[", "i", "]", ")", ")", "{", "DPRINTF", "(", "\"", "\\n", "\"", ",", "pCurrentNode", "->", "node", ".", "nodeId", ",", "pCurrentNode", "->", "node", ".", "endpoint", ")", ";", "Free", "(", "pCurrentNode", ")", ";", "ReorderGroupAfterRemove", "(", "groupId", "-", "1", ",", "ep", ",", "(", "uint8_t", ")", "indx", ")", ";", "}", "}", "}", "if", "(", "COMMAND_CLASS_ASSOCIATION", "==", "cmdClass", ")", "{", "return", ";", "}", "numberOfNodes", "=", "(", "(", "0", "==", "pListOfNodes", "->", "noOfMulchanNodes", ")", "?", "1", ":", "pListOfNodes", "->", "noOfMulchanNodes", ")", ";", "for", "(", "uint8_t", "i", "=", "0", ";", "i", "<", "numberOfNodes", ";", "i", "++", ")", "{", "for", "(", "int8_t", "indx", "=", "MAX_ASSOCIATION_IN_GROUP", "-", "1", ";", "indx", ">=", "0", ";", "indx", "--", ")", "{", "destination_info_t", "*", "pCurrentNode", "=", "GetNode", "(", "ep", ",", "groupId", ",", "(", "uint8_t", ")", "indx", ")", ";", "if", "(", "!", "IsFree", "(", "pCurrentNode", ")", "&&", "(", "true", "==", "HasEndpoint", "(", "pCurrentNode", ")", ")", "&&", "(", "(", "0", "==", "pListOfNodes", "->", "noOfNodes", "&&", "0", "==", "pListOfNodes", "->", "noOfMulchanNodes", ")", "||", "(", "(", "(", "pCurrentNode", "->", "node", ".", "nodeId", "==", "pListOfNodes", "->", "pMulChanNodeId", "[", "i", "]", ".", "nodeId", ")", "||", "(", "0", "==", "pListOfNodes", "->", "pMulChanNodeId", "[", "i", "]", ".", "nodeId", ")", ")", "&&", "(", "pCurrentNode", "->", "node", ".", "endpoint", "==", "pListOfNodes", "->", "pMulChanNodeId", "[", "i", "]", ".", "endpoint", ")", "&&", "(", "pCurrentNode", "->", "node", ".", "BitAddress", "==", "pListOfNodes", "->", "pMulChanNodeId", "[", "i", "]", ".", "BitAddress", ")", ")", ")", ")", "{", "DPRINTF", "(", "\"", "\\n", "\"", ",", "pCurrentNode", "->", "node", ".", "nodeId", ",", "pCurrentNode", "->", "node", ".", "endpoint", ")", ";", "Free", "(", "pCurrentNode", ")", ";", "if", "(", "0", "<", "pListOfNodes", "->", "noOfMulchanNodes", ")", "{", "ReorderGroupAfterRemove", "(", "groupId", "-", "1", ",", "ep", ",", "(", "uint8_t", ")", "indx", ")", ";", "}", "}", "}", "}", "}" ]
@brief Removes given associations or all associations from a given group.
[ "@brief", "Removes", "given", "associations", "or", "all", "associations", "from", "a", "given", "group", "." ]
[ "// We have to go through the loop once, even when the list is empty.", "// Remove all Node ID Associations in the given list.", "/*\n * Do reorder after freeing each entry because the command might originate from\n * CC Association and then endpoint destinations will not be deleted. Hence, they must be\n * ordered.\n */", "// Remove all Endpoint Node ID Associations in the given list.", "// Remove node if:", "// List of simple and multichannel nodes is zero (remove everything)", "// OR Remove single node with specified NodeId, EP and bitmask, and it is found in list of multichannel associations", "// OR Only EP was specified, but not NodeID. Then remove all associations with matching End Point.", "/*\n * In case specific multi channel destinations are specified, we need to reorder those that\n * will not be removed.\n * If no multi channel destinations are specified, it means that all nodes in the group\n * will be removed. Hence, no need to reorder.\n */" ]
[ { "param": "cmdClass", "type": "uint8_t" }, { "param": "ep", "type": "uint8_t" }, { "param": "groupId", "type": "uint8_t" }, { "param": "pListOfNodes", "type": "ASSOCIATION_NODE_LIST" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cmdClass", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ep", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "groupId", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pListOfNodes", "type": "ASSOCIATION_NODE_LIST", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f21b416bd2d76e6df4b8a9c3d45fdcbc1b1fea3a
SiliconLabs/Gecko_SDK
protocol/z-wave/ZAF/CommandClasses/Association/association_plus.c
[ "Zlib" ]
C
generateAssociationAndWrite
void
static void generateAssociationAndWrite(NVM_ACTION action, SAssociationInfo *pAssociationInfo) { Ecode_t errCode = 0; bool writeFile = false; /* * Notice the +1 for the endpoint expression. This ensures that this loop will run for the * root device. */ for (uint8_t endpoint = 0; endpoint < (NUMBER_OF_ENDPOINTS + 1); endpoint++) { for (uint8_t group = 0; group < MAX_ASSOCIATION_GROUPS; group++) { for (uint8_t node = 0; node < MAX_ASSOCIATION_IN_GROUP; node++) { if ((action == NVM_ACTION_INIT_CORRECT_INVALID_NODEID && 0 == pAssociationInfo->Groups[endpoint][group].subGrp[node].node.nodeId) || action == NVM_ACTION_INIT_FORCE_CLEAR_MEM) { pAssociationInfo->Groups[endpoint][group].subGrp[node].node.nodeId = FREE_VALUE; // Free writeFile = true; } } } } if(writeFile) { errCode = nvm3_writeData(pFileSystem, ZAF_FILE_ID_ASSOCIATIONINFO, pAssociationInfo, sizeof(SAssociationInfo)); ASSERT(ECODE_NVM3_OK == errCode); } }
/** * This function takes care of stepping through the entire association table that is in memory. * The input is used to identify the need for table initialization or checking for valid NodeID and correction. * * This function further writes the table to NVM3. */
This function takes care of stepping through the entire association table that is in memory. The input is used to identify the need for table initialization or checking for valid NodeID and correction. This function further writes the table to NVM3.
[ "This", "function", "takes", "care", "of", "stepping", "through", "the", "entire", "association", "table", "that", "is", "in", "memory", ".", "The", "input", "is", "used", "to", "identify", "the", "need", "for", "table", "initialization", "or", "checking", "for", "valid", "NodeID", "and", "correction", ".", "This", "function", "further", "writes", "the", "table", "to", "NVM3", "." ]
static void generateAssociationAndWrite(NVM_ACTION action, SAssociationInfo *pAssociationInfo) { Ecode_t errCode = 0; bool writeFile = false; for (uint8_t endpoint = 0; endpoint < (NUMBER_OF_ENDPOINTS + 1); endpoint++) { for (uint8_t group = 0; group < MAX_ASSOCIATION_GROUPS; group++) { for (uint8_t node = 0; node < MAX_ASSOCIATION_IN_GROUP; node++) { if ((action == NVM_ACTION_INIT_CORRECT_INVALID_NODEID && 0 == pAssociationInfo->Groups[endpoint][group].subGrp[node].node.nodeId) || action == NVM_ACTION_INIT_FORCE_CLEAR_MEM) { pAssociationInfo->Groups[endpoint][group].subGrp[node].node.nodeId = FREE_VALUE; writeFile = true; } } } } if(writeFile) { errCode = nvm3_writeData(pFileSystem, ZAF_FILE_ID_ASSOCIATIONINFO, pAssociationInfo, sizeof(SAssociationInfo)); ASSERT(ECODE_NVM3_OK == errCode); } }
[ "static", "void", "generateAssociationAndWrite", "(", "NVM_ACTION", "action", ",", "SAssociationInfo", "*", "pAssociationInfo", ")", "{", "Ecode_t", "errCode", "=", "0", ";", "bool", "writeFile", "=", "false", ";", "for", "(", "uint8_t", "endpoint", "=", "0", ";", "endpoint", "<", "(", "NUMBER_OF_ENDPOINTS", "+", "1", ")", ";", "endpoint", "++", ")", "{", "for", "(", "uint8_t", "group", "=", "0", ";", "group", "<", "MAX_ASSOCIATION_GROUPS", ";", "group", "++", ")", "{", "for", "(", "uint8_t", "node", "=", "0", ";", "node", "<", "MAX_ASSOCIATION_IN_GROUP", ";", "node", "++", ")", "{", "if", "(", "(", "action", "==", "NVM_ACTION_INIT_CORRECT_INVALID_NODEID", "&&", "0", "==", "pAssociationInfo", "->", "Groups", "[", "endpoint", "]", "[", "group", "]", ".", "subGrp", "[", "node", "]", ".", "node", ".", "nodeId", ")", "||", "action", "==", "NVM_ACTION_INIT_FORCE_CLEAR_MEM", ")", "{", "pAssociationInfo", "->", "Groups", "[", "endpoint", "]", "[", "group", "]", ".", "subGrp", "[", "node", "]", ".", "node", ".", "nodeId", "=", "FREE_VALUE", ";", "writeFile", "=", "true", ";", "}", "}", "}", "}", "if", "(", "writeFile", ")", "{", "errCode", "=", "nvm3_writeData", "(", "pFileSystem", ",", "ZAF_FILE_ID_ASSOCIATIONINFO", ",", "pAssociationInfo", ",", "sizeof", "(", "SAssociationInfo", ")", ")", ";", "ASSERT", "(", "ECODE_NVM3_OK", "==", "errCode", ")", ";", "}", "}" ]
This function takes care of stepping through the entire association table that is in memory.
[ "This", "function", "takes", "care", "of", "stepping", "through", "the", "entire", "association", "table", "that", "is", "in", "memory", "." ]
[ "/*\n * Notice the +1 for the endpoint expression. This ensures that this loop will run for the\n * root device.\n */", "// Free" ]
[ { "param": "action", "type": "NVM_ACTION" }, { "param": "pAssociationInfo", "type": "SAssociationInfo" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "action", "type": "NVM_ACTION", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pAssociationInfo", "type": "SAssociationInfo", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f21b416bd2d76e6df4b8a9c3d45fdcbc1b1fea3a
SiliconLabs/Gecko_SDK
protocol/z-wave/ZAF/CommandClasses/Association/association_plus.c
[ "Zlib" ]
C
NVM_Action
void
static void NVM_Action(NVM_ACTION action) { uint8_t i,j,k; Ecode_t errCode = 0; uint32_t objectType; size_t dataLen = 0; bool forceClearMem = false; SAssociationInfo associationInfo; // This can become a large allocation on the stack SAssociationInfo* pSource = &associationInfo; pFileSystem = ZAF_GetFileSystemHandle(); ASSERT(pFileSystem != 0); switch(action) { case NVM_ACTION_INIT_FORCE_CLEAR_MEM: forceClearMem = true; // Fall through case NVM_ACTION_INIT_CORRECT_INVALID_NODEID: // Fetch the stored data, since we are not clearing it. if (!forceClearMem) { errCode = nvm3_getObjectInfo(pFileSystem, ZAF_FILE_ID_ASSOCIATIONINFO, &objectType, &dataLen); } /* * If the stored NMV3 file structure for the Association Info is different than expected here, * erase it and create a new file. */ if ((ECODE_NVM3_OK != errCode) || (ZAF_FILE_SIZE_ASSOCIATIONINFO != dataLen) || (true == forceClearMem)) { //Write default Association Info file memset(&associationInfo, 0 , sizeof(SAssociationInfo)); generateAssociationAndWrite(action, &associationInfo); } else { // Make sure that free nodeIds are not set to legacy zero value nvm3_readData(pFileSystem, ZAF_FILE_ID_ASSOCIATIONINFO, &associationInfo, sizeof(SAssociationInfo)); generateAssociationAndWrite(action, &associationInfo); } // Fall through case NVM_ACTION_READ_DATA: errCode = nvm3_readData(pFileSystem, ZAF_FILE_ID_ASSOCIATIONINFO, &associationInfo, sizeof(SAssociationInfo)); ASSERT(ECODE_NVM3_OK == errCode); for(i = 0; i < MAX_ASSOCIATION_GROUPS; i++) { for(j = 0; j < NUMBER_OF_ENDPOINTS + 1; j++) { for(k = 0; k < MAX_ASSOCIATION_IN_GROUP; k++) { groups[j][i].subGrp[k].node.nodeId = pSource->Groups[j][i].subGrp[k].node.nodeId; //1Byte groups[j][i].subGrp[k].node.endpoint = pSource->Groups[j][i].subGrp[k].node.endpoint; //7bits groups[j][i].subGrp[k].node.BitAddress = pSource->Groups[j][i].subGrp[k].node.BitAddress; //1bit /* * Ignore bitfield conversion warnings as there is no good solution other than stop * using bitfields. */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" groups[j][i].subGrp[k].nodeInfo.BitMultiChannelEncap = pSource->Groups[j][i].subGrp[k].nodeInfoPacked.BitMultiChannelEncap; //1bit to uint8_t groups[j][i].subGrp[k].nodeInfo.security = (security_key_t)pSource->Groups[j][i].subGrp[k].nodeInfoPacked.security; //4bits to enum #pragma GCC diagnostic pop } } } break; case NVM_ACTION_WRITE_DATA: for(i = 0; i < MAX_ASSOCIATION_GROUPS; i++) { for(j = 0; j < NUMBER_OF_ENDPOINTS + 1; j++) { for(k = 0; k < MAX_ASSOCIATION_IN_GROUP; k++) { associationInfo.Groups[j][i].subGrp[k].node.nodeId = (uint8_t)groups[j][i].subGrp[k].node.nodeId; //1Byte associationInfo.Groups[j][i].subGrp[k].node.endpoint = groups[j][i].subGrp[k].node.endpoint; //7bits associationInfo.Groups[j][i].subGrp[k].node.BitAddress = groups[j][i].subGrp[k].node.BitAddress; //1bit /* * Ignore bitfield conversion warnings as there is no good solution other than stop * using bitfields. */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" associationInfo.Groups[j][i].subGrp[k].nodeInfoPacked.BitMultiChannelEncap = groups[j][i].subGrp[k].nodeInfo.BitMultiChannelEncap; //uint8_t to 1 bit associationInfo.Groups[j][i].subGrp[k].nodeInfoPacked.security = (uint8_t)groups[j][i].subGrp[k].nodeInfo.security; //enum to 4bits #pragma GCC diagnostic pop DPRINTF("associationInfo.Groups[%d][%d].subGrp[%d].node.nodeId: %d\r\n", j,i,k, associationInfo.Groups[j][i].subGrp[k].node.nodeId); } } } errCode = nvm3_writeData(pFileSystem, ZAF_FILE_ID_ASSOCIATIONINFO, &associationInfo, sizeof(SAssociationInfo)); ASSERT(ECODE_NVM3_OK == errCode); break; default: DPRINT("FATAL: Case not handled. Invalid input."); ASSERT(0); // Invalid input } }
/** * @brief Reads/Writes association data to the NVM. * @param action The action to take. */
@brief Reads/Writes association data to the NVM. @param action The action to take.
[ "@brief", "Reads", "/", "Writes", "association", "data", "to", "the", "NVM", ".", "@param", "action", "The", "action", "to", "take", "." ]
static void NVM_Action(NVM_ACTION action) { uint8_t i,j,k; Ecode_t errCode = 0; uint32_t objectType; size_t dataLen = 0; bool forceClearMem = false; SAssociationInfo associationInfo; SAssociationInfo* pSource = &associationInfo; pFileSystem = ZAF_GetFileSystemHandle(); ASSERT(pFileSystem != 0); switch(action) { case NVM_ACTION_INIT_FORCE_CLEAR_MEM: forceClearMem = true; case NVM_ACTION_INIT_CORRECT_INVALID_NODEID: if (!forceClearMem) { errCode = nvm3_getObjectInfo(pFileSystem, ZAF_FILE_ID_ASSOCIATIONINFO, &objectType, &dataLen); } if ((ECODE_NVM3_OK != errCode) || (ZAF_FILE_SIZE_ASSOCIATIONINFO != dataLen) || (true == forceClearMem)) { memset(&associationInfo, 0 , sizeof(SAssociationInfo)); generateAssociationAndWrite(action, &associationInfo); } else { nvm3_readData(pFileSystem, ZAF_FILE_ID_ASSOCIATIONINFO, &associationInfo, sizeof(SAssociationInfo)); generateAssociationAndWrite(action, &associationInfo); } case NVM_ACTION_READ_DATA: errCode = nvm3_readData(pFileSystem, ZAF_FILE_ID_ASSOCIATIONINFO, &associationInfo, sizeof(SAssociationInfo)); ASSERT(ECODE_NVM3_OK == errCode); for(i = 0; i < MAX_ASSOCIATION_GROUPS; i++) { for(j = 0; j < NUMBER_OF_ENDPOINTS + 1; j++) { for(k = 0; k < MAX_ASSOCIATION_IN_GROUP; k++) { groups[j][i].subGrp[k].node.nodeId = pSource->Groups[j][i].subGrp[k].node.nodeId; groups[j][i].subGrp[k].node.endpoint = pSource->Groups[j][i].subGrp[k].node.endpoint; groups[j][i].subGrp[k].node.BitAddress = pSource->Groups[j][i].subGrp[k].node.BitAddress; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" groups[j][i].subGrp[k].nodeInfo.BitMultiChannelEncap = pSource->Groups[j][i].subGrp[k].nodeInfoPacked.BitMultiChannelEncap; to uint8_t groups[j][i].subGrp[k].nodeInfo.security = (security_key_t)pSource->Groups[j][i].subGrp[k].nodeInfoPacked.security; #pragma GCC diagnostic pop } } } break; case NVM_ACTION_WRITE_DATA: for(i = 0; i < MAX_ASSOCIATION_GROUPS; i++) { for(j = 0; j < NUMBER_OF_ENDPOINTS + 1; j++) { for(k = 0; k < MAX_ASSOCIATION_IN_GROUP; k++) { associationInfo.Groups[j][i].subGrp[k].node.nodeId = (uint8_t)groups[j][i].subGrp[k].node.nodeId; associationInfo.Groups[j][i].subGrp[k].node.endpoint = groups[j][i].subGrp[k].node.endpoint; associationInfo.Groups[j][i].subGrp[k].node.BitAddress = groups[j][i].subGrp[k].node.BitAddress; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" associationInfo.Groups[j][i].subGrp[k].nodeInfoPacked.BitMultiChannelEncap = groups[j][i].subGrp[k].nodeInfo.BitMultiChannelEncap; associationInfo.Groups[j][i].subGrp[k].nodeInfoPacked.security = (uint8_t)groups[j][i].subGrp[k].nodeInfo.security; #pragma GCC diagnostic pop DPRINTF("associationInfo.Groups[%d][%d].subGrp[%d].node.nodeId: %d\r\n", j,i,k, associationInfo.Groups[j][i].subGrp[k].node.nodeId); } } } errCode = nvm3_writeData(pFileSystem, ZAF_FILE_ID_ASSOCIATIONINFO, &associationInfo, sizeof(SAssociationInfo)); ASSERT(ECODE_NVM3_OK == errCode); break; default: DPRINT("FATAL: Case not handled. Invalid input."); ASSERT(0); } }
[ "static", "void", "NVM_Action", "(", "NVM_ACTION", "action", ")", "{", "uint8_t", "i", ",", "j", ",", "k", ";", "Ecode_t", "errCode", "=", "0", ";", "uint32_t", "objectType", ";", "size_t", "dataLen", "=", "0", ";", "bool", "forceClearMem", "=", "false", ";", "SAssociationInfo", "associationInfo", ";", "SAssociationInfo", "*", "pSource", "=", "&", "associationInfo", ";", "pFileSystem", "=", "ZAF_GetFileSystemHandle", "(", ")", ";", "ASSERT", "(", "pFileSystem", "!=", "0", ")", ";", "switch", "(", "action", ")", "{", "case", "NVM_ACTION_INIT_FORCE_CLEAR_MEM", ":", "forceClearMem", "=", "true", ";", "case", "NVM_ACTION_INIT_CORRECT_INVALID_NODEID", ":", "if", "(", "!", "forceClearMem", ")", "{", "errCode", "=", "nvm3_getObjectInfo", "(", "pFileSystem", ",", "ZAF_FILE_ID_ASSOCIATIONINFO", ",", "&", "objectType", ",", "&", "dataLen", ")", ";", "}", "if", "(", "(", "ECODE_NVM3_OK", "!=", "errCode", ")", "||", "(", "ZAF_FILE_SIZE_ASSOCIATIONINFO", "!=", "dataLen", ")", "||", "(", "true", "==", "forceClearMem", ")", ")", "{", "memset", "(", "&", "associationInfo", ",", "0", ",", "sizeof", "(", "SAssociationInfo", ")", ")", ";", "generateAssociationAndWrite", "(", "action", ",", "&", "associationInfo", ")", ";", "}", "else", "{", "nvm3_readData", "(", "pFileSystem", ",", "ZAF_FILE_ID_ASSOCIATIONINFO", ",", "&", "associationInfo", ",", "sizeof", "(", "SAssociationInfo", ")", ")", ";", "generateAssociationAndWrite", "(", "action", ",", "&", "associationInfo", ")", ";", "}", "case", "NVM_ACTION_READ_DATA", ":", "errCode", "=", "nvm3_readData", "(", "pFileSystem", ",", "ZAF_FILE_ID_ASSOCIATIONINFO", ",", "&", "associationInfo", ",", "sizeof", "(", "SAssociationInfo", ")", ")", ";", "ASSERT", "(", "ECODE_NVM3_OK", "==", "errCode", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "MAX_ASSOCIATION_GROUPS", ";", "i", "++", ")", "{", "for", "(", "j", "=", "0", ";", "j", "<", "NUMBER_OF_ENDPOINTS", "+", "1", ";", "j", "++", ")", "{", "for", "(", "k", "=", "0", ";", "k", "<", "MAX_ASSOCIATION_IN_GROUP", ";", "k", "++", ")", "{", "groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "node", ".", "nodeId", "=", "pSource", "->", "Groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "node", ".", "nodeId", ";", "groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "node", ".", "endpoint", "=", "pSource", "->", "Groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "node", ".", "endpoint", ";", "groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "node", ".", "BitAddress", "=", "pSource", "->", "Groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "node", ".", "BitAddress", ";", "#pragma", " GCC diagnostic push", "\n", "#pragma", " GCC diagnostic ignored \"-Wconversion\"", "\n", "groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "nodeInfo", ".", "BitMultiChannelEncap", "=", "pSource", "->", "Groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "nodeInfoPacked", ".", "BitMultiChannelEncap", ";", "groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "nodeInfo", ".", "security", "=", "(", "security_key_t", ")", "pSource", "->", "Groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "nodeInfoPacked", ".", "security", ";", "#pragma", " GCC diagnostic pop", "\n", "}", "}", "}", "break", ";", "case", "NVM_ACTION_WRITE_DATA", ":", "for", "(", "i", "=", "0", ";", "i", "<", "MAX_ASSOCIATION_GROUPS", ";", "i", "++", ")", "{", "for", "(", "j", "=", "0", ";", "j", "<", "NUMBER_OF_ENDPOINTS", "+", "1", ";", "j", "++", ")", "{", "for", "(", "k", "=", "0", ";", "k", "<", "MAX_ASSOCIATION_IN_GROUP", ";", "k", "++", ")", "{", "associationInfo", ".", "Groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "node", ".", "nodeId", "=", "(", "uint8_t", ")", "groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "node", ".", "nodeId", ";", "associationInfo", ".", "Groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "node", ".", "endpoint", "=", "groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "node", ".", "endpoint", ";", "associationInfo", ".", "Groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "node", ".", "BitAddress", "=", "groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "node", ".", "BitAddress", ";", "#pragma", " GCC diagnostic push", "\n", "#pragma", " GCC diagnostic ignored \"-Wconversion\"", "\n", "associationInfo", ".", "Groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "nodeInfoPacked", ".", "BitMultiChannelEncap", "=", "groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "nodeInfo", ".", "BitMultiChannelEncap", ";", "associationInfo", ".", "Groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "nodeInfoPacked", ".", "security", "=", "(", "uint8_t", ")", "groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "nodeInfo", ".", "security", ";", "#pragma", " GCC diagnostic pop", "\n\n", "DPRINTF", "(", "\"", "\\r", "\\n", "\"", ",", "j", ",", "i", ",", "k", ",", "associationInfo", ".", "Groups", "[", "j", "]", "[", "i", "]", ".", "subGrp", "[", "k", "]", ".", "node", ".", "nodeId", ")", ";", "}", "}", "}", "errCode", "=", "nvm3_writeData", "(", "pFileSystem", ",", "ZAF_FILE_ID_ASSOCIATIONINFO", ",", "&", "associationInfo", ",", "sizeof", "(", "SAssociationInfo", ")", ")", ";", "ASSERT", "(", "ECODE_NVM3_OK", "==", "errCode", ")", ";", "break", ";", "default", ":", "DPRINT", "(", "\"", "\"", ")", ";", "ASSERT", "(", "0", ")", ";", "}", "}" ]
@brief Reads/Writes association data to the NVM.
[ "@brief", "Reads", "/", "Writes", "association", "data", "to", "the", "NVM", "." ]
[ "// This can become a large allocation on the stack", "// Fall through", "// Fetch the stored data, since we are not clearing it.", "/*\n * If the stored NMV3 file structure for the Association Info is different than expected here,\n * erase it and create a new file.\n */", "//Write default Association Info file", "// Make sure that free nodeIds are not set to legacy zero value", "// Fall through", "//1Byte", "//7bits", "//1bit", "/*\n * Ignore bitfield conversion warnings as there is no good solution other than stop\n * using bitfields.\n */", "//1bit to uint8_t", "//4bits to enum", "//1Byte", "//7bits", "//1bit", "/*\n * Ignore bitfield conversion warnings as there is no good solution other than stop\n * using bitfields.\n */", "//uint8_t to 1 bit", "//enum to 4bits", "// Invalid input" ]
[ { "param": "action", "type": "NVM_ACTION" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "action", "type": "NVM_ACTION", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f21b416bd2d76e6df4b8a9c3d45fdcbc1b1fea3a
SiliconLabs/Gecko_SDK
protocol/z-wave/ZAF/CommandClasses/Association/association_plus.c
[ "Zlib" ]
C
AssociationStoreAll
void
static void AssociationStoreAll(void) { NVM_Action(NVM_ACTION_WRITE_DATA); }
/** * @brief Stores all associations in the NVM. */
@brief Stores all associations in the NVM.
[ "@brief", "Stores", "all", "associations", "in", "the", "NVM", "." ]
static void AssociationStoreAll(void) { NVM_Action(NVM_ACTION_WRITE_DATA); }
[ "static", "void", "AssociationStoreAll", "(", "void", ")", "{", "NVM_Action", "(", "NVM_ACTION_WRITE_DATA", ")", ";", "}" ]
@brief Stores all associations in the NVM.
[ "@brief", "Stores", "all", "associations", "in", "the", "NVM", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
f21b416bd2d76e6df4b8a9c3d45fdcbc1b1fea3a
SiliconLabs/Gecko_SDK
protocol/z-wave/ZAF/CommandClasses/Association/association_plus.c
[ "Zlib" ]
C
ExtractCmdClassNodeList
void
static void ExtractCmdClassNodeList( ASSOCIATION_NODE_LIST* plist, ZW_MULTI_CHANNEL_ASSOCIATION_SET_1BYTE_V2_FRAME* pCmd, uint8_t cmdLength, uint8_t commandClass) { plist->pNodeId = &pCmd->nodeId1; plist->noOfNodes = 0; plist->pMulChanNodeId = NULL; plist->noOfMulchanNodes = 0; if (3 >= cmdLength) { /* * If the length is less than or equal to three, it means that it's a get or a remove. In the * first case we shouldn't end up here. In the second case, we must return, since the remove * command should remove all nodes. */ plist->pNodeId = NULL; return; } cmdLength -= OFFSET_PARAM_2; /*calc length on node-Id's*/ uint8_t * currentListElement = plist->pNodeId; for (uint8_t i = 0; i < cmdLength; i++, currentListElement++) { if ((COMMAND_CLASS_MULTI_CHANNEL_ASSOCIATION_V3 == commandClass) && (MULTI_CHANNEL_ASSOCIATION_SET_MARKER_V2 == *currentListElement)) { plist->noOfMulchanNodes = (uint8_t)(cmdLength - (uint8_t)(i + 1)) / 2; if (0 != plist->noOfMulchanNodes) { plist->pMulChanNodeId = (MULTICHAN_DEST_NODE_ID_8bit*)(currentListElement + 1); /*Point after the marker*/ // all done, exit return; } } else { plist->noOfNodes = i + 1; } } }
/** * @brief Extracts nodes and endpoints from a given (Multi Channel) Association frame. * @param[out] plist * @param[in] pCmd * @param[in] cmdLength * @param[in] commandClass */
@brief Extracts nodes and endpoints from a given (Multi Channel) Association frame.
[ "@brief", "Extracts", "nodes", "and", "endpoints", "from", "a", "given", "(", "Multi", "Channel", ")", "Association", "frame", "." ]
static void ExtractCmdClassNodeList( ASSOCIATION_NODE_LIST* plist, ZW_MULTI_CHANNEL_ASSOCIATION_SET_1BYTE_V2_FRAME* pCmd, uint8_t cmdLength, uint8_t commandClass) { plist->pNodeId = &pCmd->nodeId1; plist->noOfNodes = 0; plist->pMulChanNodeId = NULL; plist->noOfMulchanNodes = 0; if (3 >= cmdLength) { plist->pNodeId = NULL; return; } cmdLength -= OFFSET_PARAM_2; uint8_t * currentListElement = plist->pNodeId; for (uint8_t i = 0; i < cmdLength; i++, currentListElement++) { if ((COMMAND_CLASS_MULTI_CHANNEL_ASSOCIATION_V3 == commandClass) && (MULTI_CHANNEL_ASSOCIATION_SET_MARKER_V2 == *currentListElement)) { plist->noOfMulchanNodes = (uint8_t)(cmdLength - (uint8_t)(i + 1)) / 2; if (0 != plist->noOfMulchanNodes) { plist->pMulChanNodeId = (MULTICHAN_DEST_NODE_ID_8bit*)(currentListElement + 1); return; } } else { plist->noOfNodes = i + 1; } } }
[ "static", "void", "ExtractCmdClassNodeList", "(", "ASSOCIATION_NODE_LIST", "*", "plist", ",", "ZW_MULTI_CHANNEL_ASSOCIATION_SET_1BYTE_V2_FRAME", "*", "pCmd", ",", "uint8_t", "cmdLength", ",", "uint8_t", "commandClass", ")", "{", "plist", "->", "pNodeId", "=", "&", "pCmd", "->", "nodeId1", ";", "plist", "->", "noOfNodes", "=", "0", ";", "plist", "->", "pMulChanNodeId", "=", "NULL", ";", "plist", "->", "noOfMulchanNodes", "=", "0", ";", "if", "(", "3", ">=", "cmdLength", ")", "{", "plist", "->", "pNodeId", "=", "NULL", ";", "return", ";", "}", "cmdLength", "-=", "OFFSET_PARAM_2", ";", "uint8_t", "*", "currentListElement", "=", "plist", "->", "pNodeId", ";", "for", "(", "uint8_t", "i", "=", "0", ";", "i", "<", "cmdLength", ";", "i", "++", ",", "currentListElement", "++", ")", "{", "if", "(", "(", "COMMAND_CLASS_MULTI_CHANNEL_ASSOCIATION_V3", "==", "commandClass", ")", "&&", "(", "MULTI_CHANNEL_ASSOCIATION_SET_MARKER_V2", "==", "*", "currentListElement", ")", ")", "{", "plist", "->", "noOfMulchanNodes", "=", "(", "uint8_t", ")", "(", "cmdLength", "-", "(", "uint8_t", ")", "(", "i", "+", "1", ")", ")", "/", "2", ";", "if", "(", "0", "!=", "plist", "->", "noOfMulchanNodes", ")", "{", "plist", "->", "pMulChanNodeId", "=", "(", "MULTICHAN_DEST_NODE_ID_8bit", "*", ")", "(", "currentListElement", "+", "1", ")", ";", "return", ";", "}", "}", "else", "{", "plist", "->", "noOfNodes", "=", "i", "+", "1", ";", "}", "}", "}" ]
@brief Extracts nodes and endpoints from a given (Multi Channel) Association frame.
[ "@brief", "Extracts", "nodes", "and", "endpoints", "from", "a", "given", "(", "Multi", "Channel", ")", "Association", "frame", "." ]
[ "/*\n * If the length is less than or equal to three, it means that it's a get or a remove. In the\n * first case we shouldn't end up here. In the second case, we must return, since the remove\n * command should remove all nodes.\n */", "/*calc length on node-Id's*/", "/*Point after the marker*/", "// all done, exit" ]
[ { "param": "plist", "type": "ASSOCIATION_NODE_LIST" }, { "param": "pCmd", "type": "ZW_MULTI_CHANNEL_ASSOCIATION_SET_1BYTE_V2_FRAME" }, { "param": "cmdLength", "type": "uint8_t" }, { "param": "commandClass", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "plist", "type": "ASSOCIATION_NODE_LIST", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pCmd", "type": "ZW_MULTI_CHANNEL_ASSOCIATION_SET_1BYTE_V2_FRAME", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cmdLength", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "commandClass", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f21b416bd2d76e6df4b8a9c3d45fdcbc1b1fea3a
SiliconLabs/Gecko_SDK
protocol/z-wave/ZAF/CommandClasses/Association/association_plus.c
[ "Zlib" ]
C
AssGroupMappingLookUp
bool
static bool AssGroupMappingLookUp( uint8_t* pEndpoint, uint8_t* pGroupID) { if ((false == ((ENDPOINT_ROOT == *pEndpoint) && (LIFELINE_GROUP_ID != *pGroupID))) || (1 == handleGetMaxAssociationGroups(1)) ) { return false; } uint8_t grpTest = 1; uint8_t grpInput = *pGroupID; for (uint8_t ep = 1; ep <= NUMBER_OF_ENDPOINTS; ep++) { uint8_t epGrpCount = handleGetMaxAssociationGroups(ep) - 1; grpTest += epGrpCount; if (grpInput <= grpTest) { *pGroupID = (uint8_t)((epGrpCount - (grpTest - grpInput)) + 1); *pEndpoint = ep; return true; } } return false; }
/** * @brief Finds a mapping between groupID and endpoint and returns the * mapping through the same pointer. * * @param[in/out] pEndpoint IN = Pointer to endpoint value. OUT = The mapped Endpoint to the root group ID. * @param[in/out] pRootGroupID IN = Pointer to a Root Group ID. OUT = The mapped Endpoint Group ID. * @return true if the mapping was found, false otherwise. */
@brief Finds a mapping between groupID and endpoint and returns the mapping through the same pointer. @param[in/out] pEndpoint IN = Pointer to endpoint value. OUT = The mapped Endpoint to the root group ID. @param[in/out] pRootGroupID IN = Pointer to a Root Group ID. OUT = The mapped Endpoint Group ID. @return true if the mapping was found, false otherwise.
[ "@brief", "Finds", "a", "mapping", "between", "groupID", "and", "endpoint", "and", "returns", "the", "mapping", "through", "the", "same", "pointer", ".", "@param", "[", "in", "/", "out", "]", "pEndpoint", "IN", "=", "Pointer", "to", "endpoint", "value", ".", "OUT", "=", "The", "mapped", "Endpoint", "to", "the", "root", "group", "ID", ".", "@param", "[", "in", "/", "out", "]", "pRootGroupID", "IN", "=", "Pointer", "to", "a", "Root", "Group", "ID", ".", "OUT", "=", "The", "mapped", "Endpoint", "Group", "ID", ".", "@return", "true", "if", "the", "mapping", "was", "found", "false", "otherwise", "." ]
static bool AssGroupMappingLookUp( uint8_t* pEndpoint, uint8_t* pGroupID) { if ((false == ((ENDPOINT_ROOT == *pEndpoint) && (LIFELINE_GROUP_ID != *pGroupID))) || (1 == handleGetMaxAssociationGroups(1)) ) { return false; } uint8_t grpTest = 1; uint8_t grpInput = *pGroupID; for (uint8_t ep = 1; ep <= NUMBER_OF_ENDPOINTS; ep++) { uint8_t epGrpCount = handleGetMaxAssociationGroups(ep) - 1; grpTest += epGrpCount; if (grpInput <= grpTest) { *pGroupID = (uint8_t)((epGrpCount - (grpTest - grpInput)) + 1); *pEndpoint = ep; return true; } } return false; }
[ "static", "bool", "AssGroupMappingLookUp", "(", "uint8_t", "*", "pEndpoint", ",", "uint8_t", "*", "pGroupID", ")", "{", "if", "(", "(", "false", "==", "(", "(", "ENDPOINT_ROOT", "==", "*", "pEndpoint", ")", "&&", "(", "LIFELINE_GROUP_ID", "!=", "*", "pGroupID", ")", ")", ")", "||", "(", "1", "==", "handleGetMaxAssociationGroups", "(", "1", ")", ")", ")", "{", "return", "false", ";", "}", "uint8_t", "grpTest", "=", "1", ";", "uint8_t", "grpInput", "=", "*", "pGroupID", ";", "for", "(", "uint8_t", "ep", "=", "1", ";", "ep", "<=", "NUMBER_OF_ENDPOINTS", ";", "ep", "++", ")", "{", "uint8_t", "epGrpCount", "=", "handleGetMaxAssociationGroups", "(", "ep", ")", "-", "1", ";", "grpTest", "+=", "epGrpCount", ";", "if", "(", "grpInput", "<=", "grpTest", ")", "{", "*", "pGroupID", "=", "(", "uint8_t", ")", "(", "(", "epGrpCount", "-", "(", "grpTest", "-", "grpInput", ")", ")", "+", "1", ")", ";", "*", "pEndpoint", "=", "ep", ";", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
@brief Finds a mapping between groupID and endpoint and returns the mapping through the same pointer.
[ "@brief", "Finds", "a", "mapping", "between", "groupID", "and", "endpoint", "and", "returns", "the", "mapping", "through", "the", "same", "pointer", "." ]
[]
[ { "param": "pEndpoint", "type": "uint8_t" }, { "param": "pGroupID", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pEndpoint", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pGroupID", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f21b416bd2d76e6df4b8a9c3d45fdcbc1b1fea3a
SiliconLabs/Gecko_SDK
protocol/z-wave/ZAF/CommandClasses/Association/association_plus.c
[ "Zlib" ]
C
AssociationGetNextSinglecastDestination
destination_info_t
destination_info_t * AssociationGetNextSinglecastDestination() { destination_info_t * pNode = NULL; for (uint8_t j = 0; j < MAX_ASSOCIATION_IN_GROUP; j++) { pNode = associatedDestinationArray[singlecastDestIndex % associatedDestinationsCount]; // The modulus of associatedDestinationsCount might no longer be needed. singlecastDestIndex++; if (NULL != pNode) { break; // Return node } } ASSERT(pNode != NULL); // We must never return NULL return pNode; }
/* * This functions like an iterator. * It iterates through all nodes in the associatedDestinationArray as initialized from the association list. * The initialization was done in AssociationGetDestinationInit(). */
This functions like an iterator. It iterates through all nodes in the associatedDestinationArray as initialized from the association list. The initialization was done in AssociationGetDestinationInit().
[ "This", "functions", "like", "an", "iterator", ".", "It", "iterates", "through", "all", "nodes", "in", "the", "associatedDestinationArray", "as", "initialized", "from", "the", "association", "list", ".", "The", "initialization", "was", "done", "in", "AssociationGetDestinationInit", "()", "." ]
destination_info_t * AssociationGetNextSinglecastDestination() { destination_info_t * pNode = NULL; for (uint8_t j = 0; j < MAX_ASSOCIATION_IN_GROUP; j++) { pNode = associatedDestinationArray[singlecastDestIndex % associatedDestinationsCount]; singlecastDestIndex++; if (NULL != pNode) { break; } } ASSERT(pNode != NULL); return pNode; }
[ "destination_info_t", "*", "AssociationGetNextSinglecastDestination", "(", ")", "{", "destination_info_t", "*", "pNode", "=", "NULL", ";", "for", "(", "uint8_t", "j", "=", "0", ";", "j", "<", "MAX_ASSOCIATION_IN_GROUP", ";", "j", "++", ")", "{", "pNode", "=", "associatedDestinationArray", "[", "singlecastDestIndex", "%", "associatedDestinationsCount", "]", ";", "singlecastDestIndex", "++", ";", "if", "(", "NULL", "!=", "pNode", ")", "{", "break", ";", "}", "}", "ASSERT", "(", "pNode", "!=", "NULL", ")", ";", "return", "pNode", ";", "}" ]
This functions like an iterator.
[ "This", "functions", "like", "an", "iterator", "." ]
[ "// The modulus of associatedDestinationsCount might no longer be needed.", "// Return node", "// We must never return NULL" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
ba453797f442e9ec4d470c9c4cfebd69aacb4dbf
SiliconLabs/Gecko_SDK
platform/service/cpc/src/sl_cpc_system_secondary.c
[ "Zlib" ]
C
on_write_completed
void
static void on_write_completed(sl_cpc_user_endpoint_id_t endpoint_id, void *buffer, void *arg, sl_status_t status) { (void) endpoint_id; (void) status; sli_cpc_free_command_buffer(buffer); #if (!defined(SLI_CPC_DEVICE_UNDER_TEST)) if ((uint32_t) arg == 0xDEADBEEF) { // The reset command asked to perform a reset. BootloaderResetCause_t* resetCause = (BootloaderResetCause_t*) (RAM_MEM_BASE); // Set reset reason to bootloader entry switch (prop_bootloader_reboot_mode) { case REBOOT_APPLICATION: resetCause->reason = BOOTLOADER_RESET_REASON_GO; break; case REBOOT_BOOTLOADER: resetCause->reason = BOOTLOADER_RESET_REASON_BOOTLOAD; break; default: return; } resetCause->signature = BOOTLOADER_RESET_SIGNATURE_VALID; #if defined(RMU_PRESENT) // Clear resetcause RMU->CMD = RMU_CMD_RCCLR; // Trigger a software system reset RMU->CTRL = (RMU->CTRL & ~_RMU_CTRL_SYSRMODE_MASK) | RMU_CTRL_SYSRMODE_FULL; #endif NVIC_SystemReset(); } #else (void)arg; #endif }
/***************************************************************************/ /** * System endpoint on write completed callback ******************************************************************************/
System endpoint on write completed callback
[ "System", "endpoint", "on", "write", "completed", "callback" ]
static void on_write_completed(sl_cpc_user_endpoint_id_t endpoint_id, void *buffer, void *arg, sl_status_t status) { (void) endpoint_id; (void) status; sli_cpc_free_command_buffer(buffer); #if (!defined(SLI_CPC_DEVICE_UNDER_TEST)) if ((uint32_t) arg == 0xDEADBEEF) { BootloaderResetCause_t* resetCause = (BootloaderResetCause_t*) (RAM_MEM_BASE); switch (prop_bootloader_reboot_mode) { case REBOOT_APPLICATION: resetCause->reason = BOOTLOADER_RESET_REASON_GO; break; case REBOOT_BOOTLOADER: resetCause->reason = BOOTLOADER_RESET_REASON_BOOTLOAD; break; default: return; } resetCause->signature = BOOTLOADER_RESET_SIGNATURE_VALID; #if defined(RMU_PRESENT) RMU->CMD = RMU_CMD_RCCLR; RMU->CTRL = (RMU->CTRL & ~_RMU_CTRL_SYSRMODE_MASK) | RMU_CTRL_SYSRMODE_FULL; #endif NVIC_SystemReset(); } #else (void)arg; #endif }
[ "static", "void", "on_write_completed", "(", "sl_cpc_user_endpoint_id_t", "endpoint_id", ",", "void", "*", "buffer", ",", "void", "*", "arg", ",", "sl_status_t", "status", ")", "{", "(", "void", ")", "endpoint_id", ";", "(", "void", ")", "status", ";", "sli_cpc_free_command_buffer", "(", "buffer", ")", ";", "#if", "(", "!", "defined", "(", "SLI_CPC_DEVICE_UNDER_TEST", ")", ")", "\n", "if", "(", "(", "uint32_t", ")", "arg", "==", "0xDEADBEEF", ")", "{", "BootloaderResetCause_t", "*", "resetCause", "=", "(", "BootloaderResetCause_t", "*", ")", "(", "RAM_MEM_BASE", ")", ";", "switch", "(", "prop_bootloader_reboot_mode", ")", "{", "case", "REBOOT_APPLICATION", ":", "resetCause", "->", "reason", "=", "BOOTLOADER_RESET_REASON_GO", ";", "break", ";", "case", "REBOOT_BOOTLOADER", ":", "resetCause", "->", "reason", "=", "BOOTLOADER_RESET_REASON_BOOTLOAD", ";", "break", ";", "default", ":", "return", ";", "}", "resetCause", "->", "signature", "=", "BOOTLOADER_RESET_SIGNATURE_VALID", ";", "#if", "defined", "(", "RMU_PRESENT", ")", "\n", "RMU", "->", "CMD", "=", "RMU_CMD_RCCLR", ";", "RMU", "->", "CTRL", "=", "(", "RMU", "->", "CTRL", "&", "~", "_RMU_CTRL_SYSRMODE_MASK", ")", "|", "RMU_CTRL_SYSRMODE_FULL", ";", "#endif", "NVIC_SystemReset", "(", ")", ";", "}", "#else", "(", "void", ")", "arg", ";", "#endif", "}" ]
System endpoint on write completed callback
[ "System", "endpoint", "on", "write", "completed", "callback" ]
[ "// The reset command asked to perform a reset.", "// Set reset reason to bootloader entry", "// Clear resetcause", "// Trigger a software system reset" ]
[ { "param": "endpoint_id", "type": "sl_cpc_user_endpoint_id_t" }, { "param": "buffer", "type": "void" }, { "param": "arg", "type": "void" }, { "param": "status", "type": "sl_status_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "endpoint_id", "type": "sl_cpc_user_endpoint_id_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buffer", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "arg", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "status", "type": "sl_status_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba453797f442e9ec4d470c9c4cfebd69aacb4dbf
SiliconLabs/Gecko_SDK
platform/service/cpc/src/sl_cpc_system_secondary.c
[ "Zlib" ]
C
sli_cpc_send_disconnection_notification
sl_status_t
sl_status_t sli_cpc_send_disconnection_notification(uint8_t endpoint_id) { sl_status_t status; sl_cpc_system_cmd_t *tx_command; sl_cpc_system_property_cmd_t *tx_prop_command; sl_cpc_endpoint_state_t *ep_state; status = sli_cpc_get_system_command_buffer(&tx_command); if (status != SL_STATUS_OK) { return status; } tx_command->header.command_id = CMD_SYSTEM_PROP_VALUE_IS; /* Seq is irrelevant in u-frame information */ tx_command->header.seq = 0; tx_prop_command = (sl_cpc_system_property_cmd_t*)(tx_command->payload); tx_prop_command->property_id = EP_ID_TO_PROPERTY_ID(endpoint_id); ep_state = (sl_cpc_endpoint_state_t *)tx_prop_command->payload; tx_command->header.length = sizeof(sl_cpc_system_property_cmd_t) + sizeof(sl_cpc_endpoint_state_t); *ep_state = SL_CPC_STATE_CLOSING; status = sl_cpc_write(&system_ep, (void *)tx_command, sizeof(sl_cpc_system_cmd_header_t) + tx_command->header.length, SL_CPC_FLAG_UNNUMBERED_INFORMATION, NULL); EFM_ASSERT(status == SL_STATUS_OK); return SL_STATUS_OK; }
/***************************************************************************/ /** * Endpoint was closed, notify the host ******************************************************************************/
Endpoint was closed, notify the host
[ "Endpoint", "was", "closed", "notify", "the", "host" ]
sl_status_t sli_cpc_send_disconnection_notification(uint8_t endpoint_id) { sl_status_t status; sl_cpc_system_cmd_t *tx_command; sl_cpc_system_property_cmd_t *tx_prop_command; sl_cpc_endpoint_state_t *ep_state; status = sli_cpc_get_system_command_buffer(&tx_command); if (status != SL_STATUS_OK) { return status; } tx_command->header.command_id = CMD_SYSTEM_PROP_VALUE_IS; tx_command->header.seq = 0; tx_prop_command = (sl_cpc_system_property_cmd_t*)(tx_command->payload); tx_prop_command->property_id = EP_ID_TO_PROPERTY_ID(endpoint_id); ep_state = (sl_cpc_endpoint_state_t *)tx_prop_command->payload; tx_command->header.length = sizeof(sl_cpc_system_property_cmd_t) + sizeof(sl_cpc_endpoint_state_t); *ep_state = SL_CPC_STATE_CLOSING; status = sl_cpc_write(&system_ep, (void *)tx_command, sizeof(sl_cpc_system_cmd_header_t) + tx_command->header.length, SL_CPC_FLAG_UNNUMBERED_INFORMATION, NULL); EFM_ASSERT(status == SL_STATUS_OK); return SL_STATUS_OK; }
[ "sl_status_t", "sli_cpc_send_disconnection_notification", "(", "uint8_t", "endpoint_id", ")", "{", "sl_status_t", "status", ";", "sl_cpc_system_cmd_t", "*", "tx_command", ";", "sl_cpc_system_property_cmd_t", "*", "tx_prop_command", ";", "sl_cpc_endpoint_state_t", "*", "ep_state", ";", "status", "=", "sli_cpc_get_system_command_buffer", "(", "&", "tx_command", ")", ";", "if", "(", "status", "!=", "SL_STATUS_OK", ")", "{", "return", "status", ";", "}", "tx_command", "->", "header", ".", "command_id", "=", "CMD_SYSTEM_PROP_VALUE_IS", ";", "tx_command", "->", "header", ".", "seq", "=", "0", ";", "tx_prop_command", "=", "(", "sl_cpc_system_property_cmd_t", "*", ")", "(", "tx_command", "->", "payload", ")", ";", "tx_prop_command", "->", "property_id", "=", "EP_ID_TO_PROPERTY_ID", "(", "endpoint_id", ")", ";", "ep_state", "=", "(", "sl_cpc_endpoint_state_t", "*", ")", "tx_prop_command", "->", "payload", ";", "tx_command", "->", "header", ".", "length", "=", "sizeof", "(", "sl_cpc_system_property_cmd_t", ")", "+", "sizeof", "(", "sl_cpc_endpoint_state_t", ")", ";", "*", "ep_state", "=", "SL_CPC_STATE_CLOSING", ";", "status", "=", "sl_cpc_write", "(", "&", "system_ep", ",", "(", "void", "*", ")", "tx_command", ",", "sizeof", "(", "sl_cpc_system_cmd_header_t", ")", "+", "tx_command", "->", "header", ".", "length", ",", "SL_CPC_FLAG_UNNUMBERED_INFORMATION", ",", "NULL", ")", ";", "EFM_ASSERT", "(", "status", "==", "SL_STATUS_OK", ")", ";", "return", "SL_STATUS_OK", ";", "}" ]
Endpoint was closed, notify the host
[ "Endpoint", "was", "closed", "notify", "the", "host" ]
[ "/* Seq is irrelevant in u-frame information */" ]
[ { "param": "endpoint_id", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "endpoint_id", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba453797f442e9ec4d470c9c4cfebd69aacb4dbf
SiliconLabs/Gecko_SDK
platform/service/cpc/src/sl_cpc_system_secondary.c
[ "Zlib" ]
C
on_property_get_last_status
void
static void on_property_get_last_status(sl_cpc_system_cmd_t *tx_command) { sl_cpc_system_property_cmd_t *prop_cmd_buff; prop_cmd_buff = (sl_cpc_system_property_cmd_t*) tx_command->payload; prop_cmd_buff->property_id = PROP_LAST_STATUS; *((sl_cpc_system_status_t*)(prop_cmd_buff->payload)) = STATUS_OK; tx_command->header.length = sizeof(sl_cpc_property_id_t) + sizeof(sl_cpc_system_status_t); }
/***************************************************************************/ /** * Command ID: CMD_PROPERTY_GET * Property ID: PROP_LAST_STATUS * When replying to any CMD_PROPERTY_GET/SET which result in an unsuccessful * operation, the RCP will reply with PROP_LAST_STATUS instead. Here, this * property is specifically queried. There is nothing more meaningful than * to reply with a STATUS_OK. ******************************************************************************/
Command ID: CMD_PROPERTY_GET Property ID: PROP_LAST_STATUS When replying to any CMD_PROPERTY_GET/SET which result in an unsuccessful operation, the RCP will reply with PROP_LAST_STATUS instead. Here, this property is specifically queried. There is nothing more meaningful than to reply with a STATUS_OK.
[ "Command", "ID", ":", "CMD_PROPERTY_GET", "Property", "ID", ":", "PROP_LAST_STATUS", "When", "replying", "to", "any", "CMD_PROPERTY_GET", "/", "SET", "which", "result", "in", "an", "unsuccessful", "operation", "the", "RCP", "will", "reply", "with", "PROP_LAST_STATUS", "instead", ".", "Here", "this", "property", "is", "specifically", "queried", ".", "There", "is", "nothing", "more", "meaningful", "than", "to", "reply", "with", "a", "STATUS_OK", "." ]
static void on_property_get_last_status(sl_cpc_system_cmd_t *tx_command) { sl_cpc_system_property_cmd_t *prop_cmd_buff; prop_cmd_buff = (sl_cpc_system_property_cmd_t*) tx_command->payload; prop_cmd_buff->property_id = PROP_LAST_STATUS; *((sl_cpc_system_status_t*)(prop_cmd_buff->payload)) = STATUS_OK; tx_command->header.length = sizeof(sl_cpc_property_id_t) + sizeof(sl_cpc_system_status_t); }
[ "static", "void", "on_property_get_last_status", "(", "sl_cpc_system_cmd_t", "*", "tx_command", ")", "{", "sl_cpc_system_property_cmd_t", "*", "prop_cmd_buff", ";", "prop_cmd_buff", "=", "(", "sl_cpc_system_property_cmd_t", "*", ")", "tx_command", "->", "payload", ";", "prop_cmd_buff", "->", "property_id", "=", "PROP_LAST_STATUS", ";", "*", "(", "(", "sl_cpc_system_status_t", "*", ")", "(", "prop_cmd_buff", "->", "payload", ")", ")", "=", "STATUS_OK", ";", "tx_command", "->", "header", ".", "length", "=", "sizeof", "(", "sl_cpc_property_id_t", ")", "+", "sizeof", "(", "sl_cpc_system_status_t", ")", ";", "}" ]
Command ID: CMD_PROPERTY_GET Property ID: PROP_LAST_STATUS When replying to any CMD_PROPERTY_GET/SET which result in an unsuccessful operation, the RCP will reply with PROP_LAST_STATUS instead.
[ "Command", "ID", ":", "CMD_PROPERTY_GET", "Property", "ID", ":", "PROP_LAST_STATUS", "When", "replying", "to", "any", "CMD_PROPERTY_GET", "/", "SET", "which", "result", "in", "an", "unsuccessful", "operation", "the", "RCP", "will", "reply", "with", "PROP_LAST_STATUS", "instead", "." ]
[]
[ { "param": "tx_command", "type": "sl_cpc_system_cmd_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tx_command", "type": "sl_cpc_system_cmd_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba453797f442e9ec4d470c9c4cfebd69aacb4dbf
SiliconLabs/Gecko_SDK
platform/service/cpc/src/sl_cpc_system_secondary.c
[ "Zlib" ]
C
on_property_get_protocol_version
void
static void on_property_get_protocol_version(sl_cpc_system_cmd_t *tx_command) { sl_cpc_system_property_cmd_t *prop_cmd_buff; uint32_t* version; prop_cmd_buff = (sl_cpc_system_property_cmd_t*) tx_command->payload; prop_cmd_buff->property_id = PROP_PROTOCOL_VERSION; version = (uint32_t*)(prop_cmd_buff->payload); version[0] = SL_GSDK_MAJOR_VERSION; version[1] = SL_GSDK_MINOR_VERSION; version[2] = SL_GSDK_PATCH_VERSION; tx_command->header.length = sizeof(sl_cpc_property_id_t) + (3 * sizeof(uint32_t)); }
/***************************************************************************/ /** * Command ID: CMD_PROPERTY_GET * Property ID: PROP_PROTOCOL_VERSION * Ship the hardcoded major and minor version number back to the primary. ******************************************************************************/
Command ID: CMD_PROPERTY_GET Property ID: PROP_PROTOCOL_VERSION Ship the hardcoded major and minor version number back to the primary.
[ "Command", "ID", ":", "CMD_PROPERTY_GET", "Property", "ID", ":", "PROP_PROTOCOL_VERSION", "Ship", "the", "hardcoded", "major", "and", "minor", "version", "number", "back", "to", "the", "primary", "." ]
static void on_property_get_protocol_version(sl_cpc_system_cmd_t *tx_command) { sl_cpc_system_property_cmd_t *prop_cmd_buff; uint32_t* version; prop_cmd_buff = (sl_cpc_system_property_cmd_t*) tx_command->payload; prop_cmd_buff->property_id = PROP_PROTOCOL_VERSION; version = (uint32_t*)(prop_cmd_buff->payload); version[0] = SL_GSDK_MAJOR_VERSION; version[1] = SL_GSDK_MINOR_VERSION; version[2] = SL_GSDK_PATCH_VERSION; tx_command->header.length = sizeof(sl_cpc_property_id_t) + (3 * sizeof(uint32_t)); }
[ "static", "void", "on_property_get_protocol_version", "(", "sl_cpc_system_cmd_t", "*", "tx_command", ")", "{", "sl_cpc_system_property_cmd_t", "*", "prop_cmd_buff", ";", "uint32_t", "*", "version", ";", "prop_cmd_buff", "=", "(", "sl_cpc_system_property_cmd_t", "*", ")", "tx_command", "->", "payload", ";", "prop_cmd_buff", "->", "property_id", "=", "PROP_PROTOCOL_VERSION", ";", "version", "=", "(", "uint32_t", "*", ")", "(", "prop_cmd_buff", "->", "payload", ")", ";", "version", "[", "0", "]", "=", "SL_GSDK_MAJOR_VERSION", ";", "version", "[", "1", "]", "=", "SL_GSDK_MINOR_VERSION", ";", "version", "[", "2", "]", "=", "SL_GSDK_PATCH_VERSION", ";", "tx_command", "->", "header", ".", "length", "=", "sizeof", "(", "sl_cpc_property_id_t", ")", "+", "(", "3", "*", "sizeof", "(", "uint32_t", ")", ")", ";", "}" ]
Command ID: CMD_PROPERTY_GET Property ID: PROP_PROTOCOL_VERSION Ship the hardcoded major and minor version number back to the primary.
[ "Command", "ID", ":", "CMD_PROPERTY_GET", "Property", "ID", ":", "PROP_PROTOCOL_VERSION", "Ship", "the", "hardcoded", "major", "and", "minor", "version", "number", "back", "to", "the", "primary", "." ]
[]
[ { "param": "tx_command", "type": "sl_cpc_system_cmd_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tx_command", "type": "sl_cpc_system_cmd_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba453797f442e9ec4d470c9c4cfebd69aacb4dbf
SiliconLabs/Gecko_SDK
platform/service/cpc/src/sl_cpc_system_secondary.c
[ "Zlib" ]
C
on_property_get_capabilities
void
static void on_property_get_capabilities(sl_cpc_system_cmd_t *tx_command) { sl_cpc_system_property_cmd_t *prop_cmd_buff; uint8_t* capabilities; prop_cmd_buff = (sl_cpc_system_property_cmd_t*) tx_command->payload; prop_cmd_buff->property_id = PROP_CAPABILITIES; capabilities = (uint8_t*)(prop_cmd_buff->payload); capabilities[0] = CAPABILITIES; tx_command->header.length = sizeof(sl_cpc_property_id_t) + sizeof(uint8_t); }
/***************************************************************************/ /** * Command ID: CMD_PROPERTY_GET * Property ID: PROP_CAPABILITIES * Send the capabilities of the secondary to the primary ******************************************************************************/
Command ID: CMD_PROPERTY_GET Property ID: PROP_CAPABILITIES Send the capabilities of the secondary to the primary
[ "Command", "ID", ":", "CMD_PROPERTY_GET", "Property", "ID", ":", "PROP_CAPABILITIES", "Send", "the", "capabilities", "of", "the", "secondary", "to", "the", "primary" ]
static void on_property_get_capabilities(sl_cpc_system_cmd_t *tx_command) { sl_cpc_system_property_cmd_t *prop_cmd_buff; uint8_t* capabilities; prop_cmd_buff = (sl_cpc_system_property_cmd_t*) tx_command->payload; prop_cmd_buff->property_id = PROP_CAPABILITIES; capabilities = (uint8_t*)(prop_cmd_buff->payload); capabilities[0] = CAPABILITIES; tx_command->header.length = sizeof(sl_cpc_property_id_t) + sizeof(uint8_t); }
[ "static", "void", "on_property_get_capabilities", "(", "sl_cpc_system_cmd_t", "*", "tx_command", ")", "{", "sl_cpc_system_property_cmd_t", "*", "prop_cmd_buff", ";", "uint8_t", "*", "capabilities", ";", "prop_cmd_buff", "=", "(", "sl_cpc_system_property_cmd_t", "*", ")", "tx_command", "->", "payload", ";", "prop_cmd_buff", "->", "property_id", "=", "PROP_CAPABILITIES", ";", "capabilities", "=", "(", "uint8_t", "*", ")", "(", "prop_cmd_buff", "->", "payload", ")", ";", "capabilities", "[", "0", "]", "=", "CAPABILITIES", ";", "tx_command", "->", "header", ".", "length", "=", "sizeof", "(", "sl_cpc_property_id_t", ")", "+", "sizeof", "(", "uint8_t", ")", ";", "}" ]
Command ID: CMD_PROPERTY_GET Property ID: PROP_CAPABILITIES Send the capabilities of the secondary to the primary
[ "Command", "ID", ":", "CMD_PROPERTY_GET", "Property", "ID", ":", "PROP_CAPABILITIES", "Send", "the", "capabilities", "of", "the", "secondary", "to", "the", "primary" ]
[]
[ { "param": "tx_command", "type": "sl_cpc_system_cmd_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tx_command", "type": "sl_cpc_system_cmd_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba453797f442e9ec4d470c9c4cfebd69aacb4dbf
SiliconLabs/Gecko_SDK
platform/service/cpc/src/sl_cpc_system_secondary.c
[ "Zlib" ]
C
on_property_get_rx_capabilities
void
static void on_property_get_rx_capabilities(sl_cpc_system_cmd_t *tx_command) { sl_cpc_system_property_cmd_t *prop_cmd_buff; uint16_t *rx_capability; prop_cmd_buff = (sl_cpc_system_property_cmd_t*) tx_command->payload; prop_cmd_buff->property_id = PROP_RX_CAPABILITY; rx_capability = (uint16_t *)(prop_cmd_buff->payload); *rx_capability = SL_CPC_RX_PAYLOAD_MAX_LENGTH; tx_command->header.length = sizeof(sl_cpc_property_id_t) + sizeof(uint16_t); }
/***************************************************************************/ /** * Command ID: CMD_PROPERTY_GET * Property ID: PROP_RX_CAPABILITY * Send the rx buffer capability of the secondary to the primary ******************************************************************************/
Command ID: CMD_PROPERTY_GET Property ID: PROP_RX_CAPABILITY Send the rx buffer capability of the secondary to the primary
[ "Command", "ID", ":", "CMD_PROPERTY_GET", "Property", "ID", ":", "PROP_RX_CAPABILITY", "Send", "the", "rx", "buffer", "capability", "of", "the", "secondary", "to", "the", "primary" ]
static void on_property_get_rx_capabilities(sl_cpc_system_cmd_t *tx_command) { sl_cpc_system_property_cmd_t *prop_cmd_buff; uint16_t *rx_capability; prop_cmd_buff = (sl_cpc_system_property_cmd_t*) tx_command->payload; prop_cmd_buff->property_id = PROP_RX_CAPABILITY; rx_capability = (uint16_t *)(prop_cmd_buff->payload); *rx_capability = SL_CPC_RX_PAYLOAD_MAX_LENGTH; tx_command->header.length = sizeof(sl_cpc_property_id_t) + sizeof(uint16_t); }
[ "static", "void", "on_property_get_rx_capabilities", "(", "sl_cpc_system_cmd_t", "*", "tx_command", ")", "{", "sl_cpc_system_property_cmd_t", "*", "prop_cmd_buff", ";", "uint16_t", "*", "rx_capability", ";", "prop_cmd_buff", "=", "(", "sl_cpc_system_property_cmd_t", "*", ")", "tx_command", "->", "payload", ";", "prop_cmd_buff", "->", "property_id", "=", "PROP_RX_CAPABILITY", ";", "rx_capability", "=", "(", "uint16_t", "*", ")", "(", "prop_cmd_buff", "->", "payload", ")", ";", "*", "rx_capability", "=", "SL_CPC_RX_PAYLOAD_MAX_LENGTH", ";", "tx_command", "->", "header", ".", "length", "=", "sizeof", "(", "sl_cpc_property_id_t", ")", "+", "sizeof", "(", "uint16_t", ")", ";", "}" ]
Command ID: CMD_PROPERTY_GET Property ID: PROP_RX_CAPABILITY Send the rx buffer capability of the secondary to the primary
[ "Command", "ID", ":", "CMD_PROPERTY_GET", "Property", "ID", ":", "PROP_RX_CAPABILITY", "Send", "the", "rx", "buffer", "capability", "of", "the", "secondary", "to", "the", "primary" ]
[]
[ { "param": "tx_command", "type": "sl_cpc_system_cmd_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tx_command", "type": "sl_cpc_system_cmd_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba453797f442e9ec4d470c9c4cfebd69aacb4dbf
SiliconLabs/Gecko_SDK
platform/service/cpc/src/sl_cpc_system_secondary.c
[ "Zlib" ]
C
on_property_get_bootloader_reboot_mode
void
static void on_property_get_bootloader_reboot_mode(sl_cpc_system_cmd_t *tx_command) { sl_cpc_system_property_cmd_t *tx_property; sl_cpc_system_reboot_mode_t* mode; tx_property = (sl_cpc_system_property_cmd_t*) tx_command->payload; tx_property->property_id = PROP_BOOTLOADER_REBOOT_MODE; mode = (sl_cpc_system_reboot_mode_t*)(tx_property->payload); *mode = prop_bootloader_reboot_mode; tx_command->header.length = sizeof(sl_cpc_property_id_t) + sizeof(sl_cpc_system_reboot_mode_t); }
/***************************************************************************/ /** * Command ID: CMD_PROPERTY_GET * Property ID: PROP_BOOTLOADER_REBOOT_MODE * Reply to the PRIMARY the bootloader reboot mode. ******************************************************************************/
Command ID: CMD_PROPERTY_GET Property ID: PROP_BOOTLOADER_REBOOT_MODE Reply to the PRIMARY the bootloader reboot mode.
[ "Command", "ID", ":", "CMD_PROPERTY_GET", "Property", "ID", ":", "PROP_BOOTLOADER_REBOOT_MODE", "Reply", "to", "the", "PRIMARY", "the", "bootloader", "reboot", "mode", "." ]
static void on_property_get_bootloader_reboot_mode(sl_cpc_system_cmd_t *tx_command) { sl_cpc_system_property_cmd_t *tx_property; sl_cpc_system_reboot_mode_t* mode; tx_property = (sl_cpc_system_property_cmd_t*) tx_command->payload; tx_property->property_id = PROP_BOOTLOADER_REBOOT_MODE; mode = (sl_cpc_system_reboot_mode_t*)(tx_property->payload); *mode = prop_bootloader_reboot_mode; tx_command->header.length = sizeof(sl_cpc_property_id_t) + sizeof(sl_cpc_system_reboot_mode_t); }
[ "static", "void", "on_property_get_bootloader_reboot_mode", "(", "sl_cpc_system_cmd_t", "*", "tx_command", ")", "{", "sl_cpc_system_property_cmd_t", "*", "tx_property", ";", "sl_cpc_system_reboot_mode_t", "*", "mode", ";", "tx_property", "=", "(", "sl_cpc_system_property_cmd_t", "*", ")", "tx_command", "->", "payload", ";", "tx_property", "->", "property_id", "=", "PROP_BOOTLOADER_REBOOT_MODE", ";", "mode", "=", "(", "sl_cpc_system_reboot_mode_t", "*", ")", "(", "tx_property", "->", "payload", ")", ";", "*", "mode", "=", "prop_bootloader_reboot_mode", ";", "tx_command", "->", "header", ".", "length", "=", "sizeof", "(", "sl_cpc_property_id_t", ")", "+", "sizeof", "(", "sl_cpc_system_reboot_mode_t", ")", ";", "}" ]
Command ID: CMD_PROPERTY_GET Property ID: PROP_BOOTLOADER_REBOOT_MODE Reply to the PRIMARY the bootloader reboot mode.
[ "Command", "ID", ":", "CMD_PROPERTY_GET", "Property", "ID", ":", "PROP_BOOTLOADER_REBOOT_MODE", "Reply", "to", "the", "PRIMARY", "the", "bootloader", "reboot", "mode", "." ]
[]
[ { "param": "tx_command", "type": "sl_cpc_system_cmd_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tx_command", "type": "sl_cpc_system_cmd_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba453797f442e9ec4d470c9c4cfebd69aacb4dbf
SiliconLabs/Gecko_SDK
platform/service/cpc/src/sl_cpc_system_secondary.c
[ "Zlib" ]
C
on_property_get_security_state
void
static void on_property_get_security_state(sl_cpc_system_cmd_t *tx_command) { sl_cpc_system_property_cmd_t *tx_property; uint32_t* security_state; tx_property = (sl_cpc_system_property_cmd_t*) tx_command->payload; security_state = (uint32_t*)(tx_property->payload); #ifdef SL_CATALOG_CPC_SECURITY_SECONDARY_PRESENT tx_property->property_id = PROP_SECURITY_STATE; *security_state = sl_cpc_security_get_state(); #else tx_property->property_id = PROP_LAST_STATUS; *security_state = STATUS_UNIMPLEMENTED; #endif tx_command->header.length = sizeof(sl_cpc_property_id_t) + sizeof(sl_cpc_system_reboot_mode_t); }
/***************************************************************************/ /** * Command ID: CMD_PROPERTY_GET * Property ID: PROP_SECURITY_STATE * Reply to the PRIMARY the security state. ******************************************************************************/
Command ID: CMD_PROPERTY_GET Property ID: PROP_SECURITY_STATE Reply to the PRIMARY the security state.
[ "Command", "ID", ":", "CMD_PROPERTY_GET", "Property", "ID", ":", "PROP_SECURITY_STATE", "Reply", "to", "the", "PRIMARY", "the", "security", "state", "." ]
static void on_property_get_security_state(sl_cpc_system_cmd_t *tx_command) { sl_cpc_system_property_cmd_t *tx_property; uint32_t* security_state; tx_property = (sl_cpc_system_property_cmd_t*) tx_command->payload; security_state = (uint32_t*)(tx_property->payload); #ifdef SL_CATALOG_CPC_SECURITY_SECONDARY_PRESENT tx_property->property_id = PROP_SECURITY_STATE; *security_state = sl_cpc_security_get_state(); #else tx_property->property_id = PROP_LAST_STATUS; *security_state = STATUS_UNIMPLEMENTED; #endif tx_command->header.length = sizeof(sl_cpc_property_id_t) + sizeof(sl_cpc_system_reboot_mode_t); }
[ "static", "void", "on_property_get_security_state", "(", "sl_cpc_system_cmd_t", "*", "tx_command", ")", "{", "sl_cpc_system_property_cmd_t", "*", "tx_property", ";", "uint32_t", "*", "security_state", ";", "tx_property", "=", "(", "sl_cpc_system_property_cmd_t", "*", ")", "tx_command", "->", "payload", ";", "security_state", "=", "(", "uint32_t", "*", ")", "(", "tx_property", "->", "payload", ")", ";", "#ifdef", "SL_CATALOG_CPC_SECURITY_SECONDARY_PRESENT", "tx_property", "->", "property_id", "=", "PROP_SECURITY_STATE", ";", "*", "security_state", "=", "sl_cpc_security_get_state", "(", ")", ";", "#else", "tx_property", "->", "property_id", "=", "PROP_LAST_STATUS", ";", "*", "security_state", "=", "STATUS_UNIMPLEMENTED", ";", "#endif", "tx_command", "->", "header", ".", "length", "=", "sizeof", "(", "sl_cpc_property_id_t", ")", "+", "sizeof", "(", "sl_cpc_system_reboot_mode_t", ")", ";", "}" ]
Command ID: CMD_PROPERTY_GET Property ID: PROP_SECURITY_STATE Reply to the PRIMARY the security state.
[ "Command", "ID", ":", "CMD_PROPERTY_GET", "Property", "ID", ":", "PROP_SECURITY_STATE", "Reply", "to", "the", "PRIMARY", "the", "security", "state", "." ]
[]
[ { "param": "tx_command", "type": "sl_cpc_system_cmd_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tx_command", "type": "sl_cpc_system_cmd_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba453797f442e9ec4d470c9c4cfebd69aacb4dbf
SiliconLabs/Gecko_SDK
platform/service/cpc/src/sl_cpc_system_secondary.c
[ "Zlib" ]
C
on_property_get_endpoint_state
void
static void on_property_get_endpoint_state(sl_cpc_system_cmd_t *tx_command, uint8_t ep_id) { sl_cpc_system_property_cmd_t *reply_prop_cmd_buff; sl_cpc_endpoint_state_t *reply_ep_state; sl_cpc_endpoint_handle_t dummy_ep; reply_prop_cmd_buff = (sl_cpc_system_property_cmd_t*) tx_command->payload; reply_ep_state = (sl_cpc_endpoint_state_t*) reply_prop_cmd_buff->payload; dummy_ep.ep = NULL; dummy_ep.id = ep_id; reply_prop_cmd_buff->property_id = EP_ID_TO_PROPERTY_ID(ep_id); *reply_ep_state = sl_cpc_get_endpoint_state(&dummy_ep); tx_command->header.length = sizeof(sl_cpc_property_id_t) + sizeof(sl_cpc_endpoint_state_t); }
/***************************************************************************/ /** * Command ID: CMD_PROPERTY_GET * Property ID: PROP_ENDPOINT_STATE_x * The primary queried the status of a specific endpoint number. ******************************************************************************/
Command ID: CMD_PROPERTY_GET Property ID: PROP_ENDPOINT_STATE_x The primary queried the status of a specific endpoint number.
[ "Command", "ID", ":", "CMD_PROPERTY_GET", "Property", "ID", ":", "PROP_ENDPOINT_STATE_x", "The", "primary", "queried", "the", "status", "of", "a", "specific", "endpoint", "number", "." ]
static void on_property_get_endpoint_state(sl_cpc_system_cmd_t *tx_command, uint8_t ep_id) { sl_cpc_system_property_cmd_t *reply_prop_cmd_buff; sl_cpc_endpoint_state_t *reply_ep_state; sl_cpc_endpoint_handle_t dummy_ep; reply_prop_cmd_buff = (sl_cpc_system_property_cmd_t*) tx_command->payload; reply_ep_state = (sl_cpc_endpoint_state_t*) reply_prop_cmd_buff->payload; dummy_ep.ep = NULL; dummy_ep.id = ep_id; reply_prop_cmd_buff->property_id = EP_ID_TO_PROPERTY_ID(ep_id); *reply_ep_state = sl_cpc_get_endpoint_state(&dummy_ep); tx_command->header.length = sizeof(sl_cpc_property_id_t) + sizeof(sl_cpc_endpoint_state_t); }
[ "static", "void", "on_property_get_endpoint_state", "(", "sl_cpc_system_cmd_t", "*", "tx_command", ",", "uint8_t", "ep_id", ")", "{", "sl_cpc_system_property_cmd_t", "*", "reply_prop_cmd_buff", ";", "sl_cpc_endpoint_state_t", "*", "reply_ep_state", ";", "sl_cpc_endpoint_handle_t", "dummy_ep", ";", "reply_prop_cmd_buff", "=", "(", "sl_cpc_system_property_cmd_t", "*", ")", "tx_command", "->", "payload", ";", "reply_ep_state", "=", "(", "sl_cpc_endpoint_state_t", "*", ")", "reply_prop_cmd_buff", "->", "payload", ";", "dummy_ep", ".", "ep", "=", "NULL", ";", "dummy_ep", ".", "id", "=", "ep_id", ";", "reply_prop_cmd_buff", "->", "property_id", "=", "EP_ID_TO_PROPERTY_ID", "(", "ep_id", ")", ";", "*", "reply_ep_state", "=", "sl_cpc_get_endpoint_state", "(", "&", "dummy_ep", ")", ";", "tx_command", "->", "header", ".", "length", "=", "sizeof", "(", "sl_cpc_property_id_t", ")", "+", "sizeof", "(", "sl_cpc_endpoint_state_t", ")", ";", "}" ]
Command ID: CMD_PROPERTY_GET Property ID: PROP_ENDPOINT_STATE_x The primary queried the status of a specific endpoint number.
[ "Command", "ID", ":", "CMD_PROPERTY_GET", "Property", "ID", ":", "PROP_ENDPOINT_STATE_x", "The", "primary", "queried", "the", "status", "of", "a", "specific", "endpoint", "number", "." ]
[]
[ { "param": "tx_command", "type": "sl_cpc_system_cmd_t" }, { "param": "ep_id", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tx_command", "type": "sl_cpc_system_cmd_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ep_id", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba453797f442e9ec4d470c9c4cfebd69aacb4dbf
SiliconLabs/Gecko_SDK
platform/service/cpc/src/sl_cpc_system_secondary.c
[ "Zlib" ]
C
on_property_get_endpoint_states
void
static void on_property_get_endpoint_states(sl_cpc_system_cmd_t *tx_command) { sl_cpc_system_property_cmd_t *reply_prop_cmd_buff; uint8_t *reply_ep_states; reply_prop_cmd_buff = (sl_cpc_system_property_cmd_t*) tx_command->payload; reply_ep_states = (uint8_t*)(reply_prop_cmd_buff->payload); reply_prop_cmd_buff->property_id = PROP_ENDPOINT_STATES; // process 2 endpoints per iteration for (size_t i = 0; i != SL_CPC_ENDPOINT_MAX_COUNT / 2; i++) { sl_cpc_endpoint_handle_t dummy_ep1 = { .ep = NULL, .id = 2 * i }; sl_cpc_endpoint_handle_t dummy_ep2 = { .ep = NULL, .id = 2 * i + 1 }; sl_cpc_endpoint_state_t ep1_state = sl_cpc_get_endpoint_state(&dummy_ep1); sl_cpc_endpoint_state_t ep2_state = sl_cpc_get_endpoint_state(&dummy_ep2); // Although an 'sl_cpc_endpoint_state_t' is an 8 bit value, the number of // values in the enum makes it possible to encode it with a nibble (4 bits) // as only 3 bits are required to encode those 6 values. Put the first // endpoint in the low nibble and the second in the high nibble. // This aggregation will make it possible to send all 256 endpoint states // in one reply as it will fit within 255 bytes (limited by the length field // within a command frame) reply_ep_states[i] = (ep2_state << 4) | ep1_state; } tx_command->header.length = sizeof(sl_cpc_property_id_t) + (SL_CPC_ENDPOINT_MAX_COUNT * sizeof(uint8_t) / 2); }
/***************************************************************************/ /** * Command ID: CMD_PROPERTY_GET * Property ID: PROP_ENDPOINT_STATES * The primary queried the status of all endpoints. ******************************************************************************/
Command ID: CMD_PROPERTY_GET Property ID: PROP_ENDPOINT_STATES The primary queried the status of all endpoints.
[ "Command", "ID", ":", "CMD_PROPERTY_GET", "Property", "ID", ":", "PROP_ENDPOINT_STATES", "The", "primary", "queried", "the", "status", "of", "all", "endpoints", "." ]
static void on_property_get_endpoint_states(sl_cpc_system_cmd_t *tx_command) { sl_cpc_system_property_cmd_t *reply_prop_cmd_buff; uint8_t *reply_ep_states; reply_prop_cmd_buff = (sl_cpc_system_property_cmd_t*) tx_command->payload; reply_ep_states = (uint8_t*)(reply_prop_cmd_buff->payload); reply_prop_cmd_buff->property_id = PROP_ENDPOINT_STATES; for (size_t i = 0; i != SL_CPC_ENDPOINT_MAX_COUNT / 2; i++) { sl_cpc_endpoint_handle_t dummy_ep1 = { .ep = NULL, .id = 2 * i }; sl_cpc_endpoint_handle_t dummy_ep2 = { .ep = NULL, .id = 2 * i + 1 }; sl_cpc_endpoint_state_t ep1_state = sl_cpc_get_endpoint_state(&dummy_ep1); sl_cpc_endpoint_state_t ep2_state = sl_cpc_get_endpoint_state(&dummy_ep2); reply_ep_states[i] = (ep2_state << 4) | ep1_state; } tx_command->header.length = sizeof(sl_cpc_property_id_t) + (SL_CPC_ENDPOINT_MAX_COUNT * sizeof(uint8_t) / 2); }
[ "static", "void", "on_property_get_endpoint_states", "(", "sl_cpc_system_cmd_t", "*", "tx_command", ")", "{", "sl_cpc_system_property_cmd_t", "*", "reply_prop_cmd_buff", ";", "uint8_t", "*", "reply_ep_states", ";", "reply_prop_cmd_buff", "=", "(", "sl_cpc_system_property_cmd_t", "*", ")", "tx_command", "->", "payload", ";", "reply_ep_states", "=", "(", "uint8_t", "*", ")", "(", "reply_prop_cmd_buff", "->", "payload", ")", ";", "reply_prop_cmd_buff", "->", "property_id", "=", "PROP_ENDPOINT_STATES", ";", "for", "(", "size_t", "i", "=", "0", ";", "i", "!=", "SL_CPC_ENDPOINT_MAX_COUNT", "/", "2", ";", "i", "++", ")", "{", "sl_cpc_endpoint_handle_t", "dummy_ep1", "=", "{", ".", "ep", "=", "NULL", ",", ".", "id", "=", "2", "*", "i", "}", ";", "sl_cpc_endpoint_handle_t", "dummy_ep2", "=", "{", ".", "ep", "=", "NULL", ",", ".", "id", "=", "2", "*", "i", "+", "1", "}", ";", "sl_cpc_endpoint_state_t", "ep1_state", "=", "sl_cpc_get_endpoint_state", "(", "&", "dummy_ep1", ")", ";", "sl_cpc_endpoint_state_t", "ep2_state", "=", "sl_cpc_get_endpoint_state", "(", "&", "dummy_ep2", ")", ";", "reply_ep_states", "[", "i", "]", "=", "(", "ep2_state", "<<", "4", ")", "|", "ep1_state", ";", "}", "tx_command", "->", "header", ".", "length", "=", "sizeof", "(", "sl_cpc_property_id_t", ")", "+", "(", "SL_CPC_ENDPOINT_MAX_COUNT", "*", "sizeof", "(", "uint8_t", ")", "/", "2", ")", ";", "}" ]
Command ID: CMD_PROPERTY_GET Property ID: PROP_ENDPOINT_STATES The primary queried the status of all endpoints.
[ "Command", "ID", ":", "CMD_PROPERTY_GET", "Property", "ID", ":", "PROP_ENDPOINT_STATES", "The", "primary", "queried", "the", "status", "of", "all", "endpoints", "." ]
[ "// process 2 endpoints per iteration", "// Although an 'sl_cpc_endpoint_state_t' is an 8 bit value, the number of", "// values in the enum makes it possible to encode it with a nibble (4 bits)", "// as only 3 bits are required to encode those 6 values. Put the first", "// endpoint in the low nibble and the second in the high nibble.", "// This aggregation will make it possible to send all 256 endpoint states", "// in one reply as it will fit within 255 bytes (limited by the length field", "// within a command frame)" ]
[ { "param": "tx_command", "type": "sl_cpc_system_cmd_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tx_command", "type": "sl_cpc_system_cmd_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba453797f442e9ec4d470c9c4cfebd69aacb4dbf
SiliconLabs/Gecko_SDK
platform/service/cpc/src/sl_cpc_system_secondary.c
[ "Zlib" ]
C
on_property_get_set_not_found
void
static void on_property_get_set_not_found(sl_cpc_system_cmd_t *tx_command) { sl_cpc_system_property_cmd_t *tx_property_cmd; tx_property_cmd = (sl_cpc_system_property_cmd_t*) tx_command->payload; tx_property_cmd->property_id = PROP_LAST_STATUS; *((sl_cpc_system_status_t*)(tx_property_cmd->payload)) = STATUS_PROP_NOT_FOUND; tx_command->header.length = sizeof(sl_cpc_property_id_t) + sizeof(sl_cpc_system_status_t); }
/***************************************************************************/ /** * Handler for when the primary asks about a property not found: * As with any property-get/set which is unsuccessful, the rcp replies with * a property id of PROP_LAST_STATUS. Since the property the primary asked about * can't be handled by the rcp, the status returned is STATUS_PROP_NOT_FOUND. ******************************************************************************/
Handler for when the primary asks about a property not found: As with any property-get/set which is unsuccessful, the rcp replies with a property id of PROP_LAST_STATUS. Since the property the primary asked about can't be handled by the rcp, the status returned is STATUS_PROP_NOT_FOUND.
[ "Handler", "for", "when", "the", "primary", "asks", "about", "a", "property", "not", "found", ":", "As", "with", "any", "property", "-", "get", "/", "set", "which", "is", "unsuccessful", "the", "rcp", "replies", "with", "a", "property", "id", "of", "PROP_LAST_STATUS", ".", "Since", "the", "property", "the", "primary", "asked", "about", "can", "'", "t", "be", "handled", "by", "the", "rcp", "the", "status", "returned", "is", "STATUS_PROP_NOT_FOUND", "." ]
static void on_property_get_set_not_found(sl_cpc_system_cmd_t *tx_command) { sl_cpc_system_property_cmd_t *tx_property_cmd; tx_property_cmd = (sl_cpc_system_property_cmd_t*) tx_command->payload; tx_property_cmd->property_id = PROP_LAST_STATUS; *((sl_cpc_system_status_t*)(tx_property_cmd->payload)) = STATUS_PROP_NOT_FOUND; tx_command->header.length = sizeof(sl_cpc_property_id_t) + sizeof(sl_cpc_system_status_t); }
[ "static", "void", "on_property_get_set_not_found", "(", "sl_cpc_system_cmd_t", "*", "tx_command", ")", "{", "sl_cpc_system_property_cmd_t", "*", "tx_property_cmd", ";", "tx_property_cmd", "=", "(", "sl_cpc_system_property_cmd_t", "*", ")", "tx_command", "->", "payload", ";", "tx_property_cmd", "->", "property_id", "=", "PROP_LAST_STATUS", ";", "*", "(", "(", "sl_cpc_system_status_t", "*", ")", "(", "tx_property_cmd", "->", "payload", ")", ")", "=", "STATUS_PROP_NOT_FOUND", ";", "tx_command", "->", "header", ".", "length", "=", "sizeof", "(", "sl_cpc_property_id_t", ")", "+", "sizeof", "(", "sl_cpc_system_status_t", ")", ";", "}" ]
Handler for when the primary asks about a property not found: As with any property-get/set which is unsuccessful, the rcp replies with a property id of PROP_LAST_STATUS.
[ "Handler", "for", "when", "the", "primary", "asks", "about", "a", "property", "not", "found", ":", "As", "with", "any", "property", "-", "get", "/", "set", "which", "is", "unsuccessful", "the", "rcp", "replies", "with", "a", "property", "id", "of", "PROP_LAST_STATUS", "." ]
[]
[ { "param": "tx_command", "type": "sl_cpc_system_cmd_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tx_command", "type": "sl_cpc_system_cmd_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba453797f442e9ec4d470c9c4cfebd69aacb4dbf
SiliconLabs/Gecko_SDK
platform/service/cpc/src/sl_cpc_system_secondary.c
[ "Zlib" ]
C
on_property_set_state
void
static void on_property_set_state(uint8_t endpoint_id, sl_cpc_system_cmd_t *tx_command, sl_cpc_system_cmd_t *rx_command) { (void)rx_command; sl_cpc_system_property_cmd_t *tx_property_command; tx_property_command = (sl_cpc_system_property_cmd_t*) tx_command->payload; sli_cpc_remote_disconnected(endpoint_id); tx_command->header.length = sizeof(sl_cpc_property_id_t); tx_property_command->property_id = EP_ID_TO_PROPERTY_ID(endpoint_id); }
/***************************************************************************/ /** * Command ID: CMD_PROPERTY_SET: * Property ID: PROP_ENDPOINT_STATE_x * The primary notifies the secondary of an endpoint state change ******************************************************************************/
Command ID: CMD_PROPERTY_SET: Property ID: PROP_ENDPOINT_STATE_x The primary notifies the secondary of an endpoint state change
[ "Command", "ID", ":", "CMD_PROPERTY_SET", ":", "Property", "ID", ":", "PROP_ENDPOINT_STATE_x", "The", "primary", "notifies", "the", "secondary", "of", "an", "endpoint", "state", "change" ]
static void on_property_set_state(uint8_t endpoint_id, sl_cpc_system_cmd_t *tx_command, sl_cpc_system_cmd_t *rx_command) { (void)rx_command; sl_cpc_system_property_cmd_t *tx_property_command; tx_property_command = (sl_cpc_system_property_cmd_t*) tx_command->payload; sli_cpc_remote_disconnected(endpoint_id); tx_command->header.length = sizeof(sl_cpc_property_id_t); tx_property_command->property_id = EP_ID_TO_PROPERTY_ID(endpoint_id); }
[ "static", "void", "on_property_set_state", "(", "uint8_t", "endpoint_id", ",", "sl_cpc_system_cmd_t", "*", "tx_command", ",", "sl_cpc_system_cmd_t", "*", "rx_command", ")", "{", "(", "void", ")", "rx_command", ";", "sl_cpc_system_property_cmd_t", "*", "tx_property_command", ";", "tx_property_command", "=", "(", "sl_cpc_system_property_cmd_t", "*", ")", "tx_command", "->", "payload", ";", "sli_cpc_remote_disconnected", "(", "endpoint_id", ")", ";", "tx_command", "->", "header", ".", "length", "=", "sizeof", "(", "sl_cpc_property_id_t", ")", ";", "tx_property_command", "->", "property_id", "=", "EP_ID_TO_PROPERTY_ID", "(", "endpoint_id", ")", ";", "}" ]
Command ID: CMD_PROPERTY_SET: Property ID: PROP_ENDPOINT_STATE_x The primary notifies the secondary of an endpoint state change
[ "Command", "ID", ":", "CMD_PROPERTY_SET", ":", "Property", "ID", ":", "PROP_ENDPOINT_STATE_x", "The", "primary", "notifies", "the", "secondary", "of", "an", "endpoint", "state", "change" ]
[]
[ { "param": "endpoint_id", "type": "uint8_t" }, { "param": "tx_command", "type": "sl_cpc_system_cmd_t" }, { "param": "rx_command", "type": "sl_cpc_system_cmd_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "endpoint_id", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "tx_command", "type": "sl_cpc_system_cmd_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rx_command", "type": "sl_cpc_system_cmd_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba453797f442e9ec4d470c9c4cfebd69aacb4dbf
SiliconLabs/Gecko_SDK
platform/service/cpc/src/sl_cpc_system_secondary.c
[ "Zlib" ]
C
on_property_set_read_only
void
static void on_property_set_read_only(sl_cpc_system_cmd_t *tx_command) { sl_cpc_system_property_cmd_t *tx_property_cmd; tx_property_cmd = (sl_cpc_system_property_cmd_t*) tx_command->payload; tx_property_cmd->property_id = PROP_LAST_STATUS; *((sl_cpc_system_status_t*)(tx_property_cmd->payload)) = STATUS_INVALID_COMMAND_FOR_PROP; tx_command->header.length = sizeof(sl_cpc_property_id_t) + sizeof(sl_cpc_system_status_t); }
/***************************************************************************/ /** * Handler for when the primary sets a read-only property ******************************************************************************/
Handler for when the primary sets a read-only property
[ "Handler", "for", "when", "the", "primary", "sets", "a", "read", "-", "only", "property" ]
static void on_property_set_read_only(sl_cpc_system_cmd_t *tx_command) { sl_cpc_system_property_cmd_t *tx_property_cmd; tx_property_cmd = (sl_cpc_system_property_cmd_t*) tx_command->payload; tx_property_cmd->property_id = PROP_LAST_STATUS; *((sl_cpc_system_status_t*)(tx_property_cmd->payload)) = STATUS_INVALID_COMMAND_FOR_PROP; tx_command->header.length = sizeof(sl_cpc_property_id_t) + sizeof(sl_cpc_system_status_t); }
[ "static", "void", "on_property_set_read_only", "(", "sl_cpc_system_cmd_t", "*", "tx_command", ")", "{", "sl_cpc_system_property_cmd_t", "*", "tx_property_cmd", ";", "tx_property_cmd", "=", "(", "sl_cpc_system_property_cmd_t", "*", ")", "tx_command", "->", "payload", ";", "tx_property_cmd", "->", "property_id", "=", "PROP_LAST_STATUS", ";", "*", "(", "(", "sl_cpc_system_status_t", "*", ")", "(", "tx_property_cmd", "->", "payload", ")", ")", "=", "STATUS_INVALID_COMMAND_FOR_PROP", ";", "tx_command", "->", "header", ".", "length", "=", "sizeof", "(", "sl_cpc_property_id_t", ")", "+", "sizeof", "(", "sl_cpc_system_status_t", ")", ";", "}" ]
Handler for when the primary sets a read-only property
[ "Handler", "for", "when", "the", "primary", "sets", "a", "read", "-", "only", "property" ]
[]
[ { "param": "tx_command", "type": "sl_cpc_system_cmd_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tx_command", "type": "sl_cpc_system_cmd_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba453797f442e9ec4d470c9c4cfebd69aacb4dbf
SiliconLabs/Gecko_SDK
platform/service/cpc/src/sl_cpc_system_secondary.c
[ "Zlib" ]
C
on_noop
void
static void on_noop(sl_cpc_system_cmd_t *noop, uint32_t *reply_data_lenght) { noop->header.command_id = CMD_SYSTEM_NOOP; noop->header.length = 0; *reply_data_lenght = sizeof(sl_cpc_system_cmd_header_t) + noop->header.length; }
/***************************************************************************/ /** * Handle no-op from PRIMARY: * This functions is called when a no-op command is received from the PRIMARY. * The RCP simply sends a no-op back so that the primary can assert the success * of the operation. ******************************************************************************/
Handle no-op from PRIMARY: This functions is called when a no-op command is received from the PRIMARY. The RCP simply sends a no-op back so that the primary can assert the success of the operation.
[ "Handle", "no", "-", "op", "from", "PRIMARY", ":", "This", "functions", "is", "called", "when", "a", "no", "-", "op", "command", "is", "received", "from", "the", "PRIMARY", ".", "The", "RCP", "simply", "sends", "a", "no", "-", "op", "back", "so", "that", "the", "primary", "can", "assert", "the", "success", "of", "the", "operation", "." ]
static void on_noop(sl_cpc_system_cmd_t *noop, uint32_t *reply_data_lenght) { noop->header.command_id = CMD_SYSTEM_NOOP; noop->header.length = 0; *reply_data_lenght = sizeof(sl_cpc_system_cmd_header_t) + noop->header.length; }
[ "static", "void", "on_noop", "(", "sl_cpc_system_cmd_t", "*", "noop", ",", "uint32_t", "*", "reply_data_lenght", ")", "{", "noop", "->", "header", ".", "command_id", "=", "CMD_SYSTEM_NOOP", ";", "noop", "->", "header", ".", "length", "=", "0", ";", "*", "reply_data_lenght", "=", "sizeof", "(", "sl_cpc_system_cmd_header_t", ")", "+", "noop", "->", "header", ".", "length", ";", "}" ]
Handle no-op from PRIMARY: This functions is called when a no-op command is received from the PRIMARY.
[ "Handle", "no", "-", "op", "from", "PRIMARY", ":", "This", "functions", "is", "called", "when", "a", "no", "-", "op", "command", "is", "received", "from", "the", "PRIMARY", "." ]
[]
[ { "param": "noop", "type": "sl_cpc_system_cmd_t" }, { "param": "reply_data_lenght", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "noop", "type": "sl_cpc_system_cmd_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reply_data_lenght", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba453797f442e9ec4d470c9c4cfebd69aacb4dbf
SiliconLabs/Gecko_SDK
platform/service/cpc/src/sl_cpc_system_secondary.c
[ "Zlib" ]
C
on_property_get
void
static void on_property_get(sl_cpc_system_cmd_t *rx_command, sl_cpc_system_cmd_t *reply, uint32_t *reply_data_lenght) { sl_cpc_system_property_cmd_t *rx_property_cmd = (sl_cpc_system_property_cmd_t *)rx_command->payload; // Reply to a PROPERTY-GET with a PROPERTY-IS reply->header.command_id = CMD_SYSTEM_PROP_VALUE_IS; // Populate the reply command buffer according to the property_id switch (rx_property_cmd->property_id) { case PROP_LAST_STATUS: on_property_get_last_status(reply); break; case PROP_PROTOCOL_VERSION: on_property_get_protocol_version(reply); break; case PROP_CAPABILITIES: on_property_get_capabilities(reply); break; case PROP_RX_CAPABILITY: on_property_get_rx_capabilities(reply); break; #if (!defined(SLI_CPC_DEVICE_UNDER_TEST)) case PROP_BOOTLOADER_INFO: on_property_get_bootloader_info(reply); break; #endif case PROP_BOOTLOADER_REBOOT_MODE: on_property_get_bootloader_reboot_mode(reply); break; case PROP_SECURITY_STATE: on_property_get_security_state(reply); break; case PROP_ENDPOINT_STATES: on_property_get_endpoint_states(reply); break; default: // Deal with endpoint state range if (rx_property_cmd->property_id >= PROP_ENDPOINT_STATE_0 && rx_property_cmd->property_id <= PROP_ENDPOINT_STATE_255) { uint8_t ep_id = PROPERTY_ID_TO_EP_ID(rx_property_cmd->property_id); on_property_get_endpoint_state(reply, ep_id); break; } on_property_get_set_not_found(reply); break; } *reply_data_lenght = sizeof(sl_cpc_system_cmd_header_t) + reply->header.length; }
/***************************************************************************/ /** * Handle property-get from PRIMARY: * This functions is called when a property-get command is received from the * PRIMARY. Causes the SECONDARY to emit a "CMD_PROP_VALUE_IS" command for the * given property identifier. ******************************************************************************/
Handle property-get from PRIMARY: This functions is called when a property-get command is received from the PRIMARY. Causes the SECONDARY to emit a "CMD_PROP_VALUE_IS" command for the given property identifier.
[ "Handle", "property", "-", "get", "from", "PRIMARY", ":", "This", "functions", "is", "called", "when", "a", "property", "-", "get", "command", "is", "received", "from", "the", "PRIMARY", ".", "Causes", "the", "SECONDARY", "to", "emit", "a", "\"", "CMD_PROP_VALUE_IS", "\"", "command", "for", "the", "given", "property", "identifier", "." ]
static void on_property_get(sl_cpc_system_cmd_t *rx_command, sl_cpc_system_cmd_t *reply, uint32_t *reply_data_lenght) { sl_cpc_system_property_cmd_t *rx_property_cmd = (sl_cpc_system_property_cmd_t *)rx_command->payload; reply->header.command_id = CMD_SYSTEM_PROP_VALUE_IS; switch (rx_property_cmd->property_id) { case PROP_LAST_STATUS: on_property_get_last_status(reply); break; case PROP_PROTOCOL_VERSION: on_property_get_protocol_version(reply); break; case PROP_CAPABILITIES: on_property_get_capabilities(reply); break; case PROP_RX_CAPABILITY: on_property_get_rx_capabilities(reply); break; #if (!defined(SLI_CPC_DEVICE_UNDER_TEST)) case PROP_BOOTLOADER_INFO: on_property_get_bootloader_info(reply); break; #endif case PROP_BOOTLOADER_REBOOT_MODE: on_property_get_bootloader_reboot_mode(reply); break; case PROP_SECURITY_STATE: on_property_get_security_state(reply); break; case PROP_ENDPOINT_STATES: on_property_get_endpoint_states(reply); break; default: if (rx_property_cmd->property_id >= PROP_ENDPOINT_STATE_0 && rx_property_cmd->property_id <= PROP_ENDPOINT_STATE_255) { uint8_t ep_id = PROPERTY_ID_TO_EP_ID(rx_property_cmd->property_id); on_property_get_endpoint_state(reply, ep_id); break; } on_property_get_set_not_found(reply); break; } *reply_data_lenght = sizeof(sl_cpc_system_cmd_header_t) + reply->header.length; }
[ "static", "void", "on_property_get", "(", "sl_cpc_system_cmd_t", "*", "rx_command", ",", "sl_cpc_system_cmd_t", "*", "reply", ",", "uint32_t", "*", "reply_data_lenght", ")", "{", "sl_cpc_system_property_cmd_t", "*", "rx_property_cmd", "=", "(", "sl_cpc_system_property_cmd_t", "*", ")", "rx_command", "->", "payload", ";", "reply", "->", "header", ".", "command_id", "=", "CMD_SYSTEM_PROP_VALUE_IS", ";", "switch", "(", "rx_property_cmd", "->", "property_id", ")", "{", "case", "PROP_LAST_STATUS", ":", "on_property_get_last_status", "(", "reply", ")", ";", "break", ";", "case", "PROP_PROTOCOL_VERSION", ":", "on_property_get_protocol_version", "(", "reply", ")", ";", "break", ";", "case", "PROP_CAPABILITIES", ":", "on_property_get_capabilities", "(", "reply", ")", ";", "break", ";", "case", "PROP_RX_CAPABILITY", ":", "on_property_get_rx_capabilities", "(", "reply", ")", ";", "break", ";", "#if", "(", "!", "defined", "(", "SLI_CPC_DEVICE_UNDER_TEST", ")", ")", "\n", "case", "PROP_BOOTLOADER_INFO", ":", "on_property_get_bootloader_info", "(", "reply", ")", ";", "break", ";", "#endif", "case", "PROP_BOOTLOADER_REBOOT_MODE", ":", "on_property_get_bootloader_reboot_mode", "(", "reply", ")", ";", "break", ";", "case", "PROP_SECURITY_STATE", ":", "on_property_get_security_state", "(", "reply", ")", ";", "break", ";", "case", "PROP_ENDPOINT_STATES", ":", "on_property_get_endpoint_states", "(", "reply", ")", ";", "break", ";", "default", ":", "if", "(", "rx_property_cmd", "->", "property_id", ">=", "PROP_ENDPOINT_STATE_0", "&&", "rx_property_cmd", "->", "property_id", "<=", "PROP_ENDPOINT_STATE_255", ")", "{", "uint8_t", "ep_id", "=", "PROPERTY_ID_TO_EP_ID", "(", "rx_property_cmd", "->", "property_id", ")", ";", "on_property_get_endpoint_state", "(", "reply", ",", "ep_id", ")", ";", "break", ";", "}", "on_property_get_set_not_found", "(", "reply", ")", ";", "break", ";", "}", "*", "reply_data_lenght", "=", "sizeof", "(", "sl_cpc_system_cmd_header_t", ")", "+", "reply", "->", "header", ".", "length", ";", "}" ]
Handle property-get from PRIMARY: This functions is called when a property-get command is received from the PRIMARY.
[ "Handle", "property", "-", "get", "from", "PRIMARY", ":", "This", "functions", "is", "called", "when", "a", "property", "-", "get", "command", "is", "received", "from", "the", "PRIMARY", "." ]
[ "// Reply to a PROPERTY-GET with a PROPERTY-IS", "// Populate the reply command buffer according to the property_id", "// Deal with endpoint state range" ]
[ { "param": "rx_command", "type": "sl_cpc_system_cmd_t" }, { "param": "reply", "type": "sl_cpc_system_cmd_t" }, { "param": "reply_data_lenght", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rx_command", "type": "sl_cpc_system_cmd_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reply", "type": "sl_cpc_system_cmd_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reply_data_lenght", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba453797f442e9ec4d470c9c4cfebd69aacb4dbf
SiliconLabs/Gecko_SDK
platform/service/cpc/src/sl_cpc_system_secondary.c
[ "Zlib" ]
C
on_property_set
void
static void on_property_set(sl_cpc_system_cmd_t* rx_command, sl_cpc_system_cmd_t *reply, uint32_t * reply_data_lenght) { sl_cpc_system_property_cmd_t *rx_property_cmd; rx_property_cmd = (sl_cpc_system_property_cmd_t*)(rx_command->payload); // Reply to a PROPERTY-GET with a PROPERTY-IS reply->header.command_id = CMD_SYSTEM_PROP_VALUE_IS; // Populate the reply command buffer according to the property_id if (rx_property_cmd->property_id >= PROP_ENDPOINT_STATE_0 && rx_property_cmd->property_id <= PROP_ENDPOINT_STATE_255) { on_property_set_state(PROPERTY_ID_TO_EP_ID(rx_property_cmd->property_id), reply, rx_command); } else { switch (rx_property_cmd->property_id) { case PROP_LAST_STATUS: case PROP_PROTOCOL_VERSION: case PROP_CAPABILITIES: case PROP_BOOTLOADER_INFO: case PROP_SECURITY_STATE: case PROP_ENDPOINT_STATES: // All those properties fall through read-only handling on_property_set_read_only(reply); break; case PROP_BOOTLOADER_REBOOT_MODE: on_property_set_bootloader_reboot_mode(reply, rx_command); break; default: on_property_get_set_not_found(reply); break; } } *reply_data_lenght = sizeof(sl_cpc_system_cmd_header_t) + reply->header.length; }
/***************************************************************************/ /** * Handle property-set from PRIMARY: * This functions is called when a property-set command is received from the * PRIMARY. Causes the RCP to emit a "CMD_PROP_VALUE_IS" command for the given * property identifier. ******************************************************************************/
Handle property-set from PRIMARY: This functions is called when a property-set command is received from the PRIMARY. Causes the RCP to emit a "CMD_PROP_VALUE_IS" command for the given property identifier.
[ "Handle", "property", "-", "set", "from", "PRIMARY", ":", "This", "functions", "is", "called", "when", "a", "property", "-", "set", "command", "is", "received", "from", "the", "PRIMARY", ".", "Causes", "the", "RCP", "to", "emit", "a", "\"", "CMD_PROP_VALUE_IS", "\"", "command", "for", "the", "given", "property", "identifier", "." ]
static void on_property_set(sl_cpc_system_cmd_t* rx_command, sl_cpc_system_cmd_t *reply, uint32_t * reply_data_lenght) { sl_cpc_system_property_cmd_t *rx_property_cmd; rx_property_cmd = (sl_cpc_system_property_cmd_t*)(rx_command->payload); reply->header.command_id = CMD_SYSTEM_PROP_VALUE_IS; if (rx_property_cmd->property_id >= PROP_ENDPOINT_STATE_0 && rx_property_cmd->property_id <= PROP_ENDPOINT_STATE_255) { on_property_set_state(PROPERTY_ID_TO_EP_ID(rx_property_cmd->property_id), reply, rx_command); } else { switch (rx_property_cmd->property_id) { case PROP_LAST_STATUS: case PROP_PROTOCOL_VERSION: case PROP_CAPABILITIES: case PROP_BOOTLOADER_INFO: case PROP_SECURITY_STATE: case PROP_ENDPOINT_STATES: on_property_set_read_only(reply); break; case PROP_BOOTLOADER_REBOOT_MODE: on_property_set_bootloader_reboot_mode(reply, rx_command); break; default: on_property_get_set_not_found(reply); break; } } *reply_data_lenght = sizeof(sl_cpc_system_cmd_header_t) + reply->header.length; }
[ "static", "void", "on_property_set", "(", "sl_cpc_system_cmd_t", "*", "rx_command", ",", "sl_cpc_system_cmd_t", "*", "reply", ",", "uint32_t", "*", "reply_data_lenght", ")", "{", "sl_cpc_system_property_cmd_t", "*", "rx_property_cmd", ";", "rx_property_cmd", "=", "(", "sl_cpc_system_property_cmd_t", "*", ")", "(", "rx_command", "->", "payload", ")", ";", "reply", "->", "header", ".", "command_id", "=", "CMD_SYSTEM_PROP_VALUE_IS", ";", "if", "(", "rx_property_cmd", "->", "property_id", ">=", "PROP_ENDPOINT_STATE_0", "&&", "rx_property_cmd", "->", "property_id", "<=", "PROP_ENDPOINT_STATE_255", ")", "{", "on_property_set_state", "(", "PROPERTY_ID_TO_EP_ID", "(", "rx_property_cmd", "->", "property_id", ")", ",", "reply", ",", "rx_command", ")", ";", "}", "else", "{", "switch", "(", "rx_property_cmd", "->", "property_id", ")", "{", "case", "PROP_LAST_STATUS", ":", "case", "PROP_PROTOCOL_VERSION", ":", "case", "PROP_CAPABILITIES", ":", "case", "PROP_BOOTLOADER_INFO", ":", "case", "PROP_SECURITY_STATE", ":", "case", "PROP_ENDPOINT_STATES", ":", "on_property_set_read_only", "(", "reply", ")", ";", "break", ";", "case", "PROP_BOOTLOADER_REBOOT_MODE", ":", "on_property_set_bootloader_reboot_mode", "(", "reply", ",", "rx_command", ")", ";", "break", ";", "default", ":", "on_property_get_set_not_found", "(", "reply", ")", ";", "break", ";", "}", "}", "*", "reply_data_lenght", "=", "sizeof", "(", "sl_cpc_system_cmd_header_t", ")", "+", "reply", "->", "header", ".", "length", ";", "}" ]
Handle property-set from PRIMARY: This functions is called when a property-set command is received from the PRIMARY.
[ "Handle", "property", "-", "set", "from", "PRIMARY", ":", "This", "functions", "is", "called", "when", "a", "property", "-", "set", "command", "is", "received", "from", "the", "PRIMARY", "." ]
[ "// Reply to a PROPERTY-GET with a PROPERTY-IS", "// Populate the reply command buffer according to the property_id", "// All those properties fall through read-only handling" ]
[ { "param": "rx_command", "type": "sl_cpc_system_cmd_t" }, { "param": "reply", "type": "sl_cpc_system_cmd_t" }, { "param": "reply_data_lenght", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "rx_command", "type": "sl_cpc_system_cmd_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reply", "type": "sl_cpc_system_cmd_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reply_data_lenght", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ba453797f442e9ec4d470c9c4cfebd69aacb4dbf
SiliconLabs/Gecko_SDK
platform/service/cpc/src/sl_cpc_system_secondary.c
[ "Zlib" ]
C
on_poll
void
static void on_poll(uint8_t endpoint_id, void *arg, void *poll_data, uint32_t poll_data_length, void **reply_data, uint32_t *reply_data_lenght, void **on_write_complete_arg) { sl_cpc_system_cmd_t *rx_command = (sl_cpc_system_cmd_t *)poll_data; sl_cpc_system_cmd_t *tx_command; *reply_data = NULL; *reply_data_lenght = 0; (void)endpoint_id; (void)arg; EFM_ASSERT(endpoint_id == SL_CPC_ENDPOINT_SYSTEM); // Make sure the length of the payload from the command matches the returned length. EFM_ASSERT(rx_command->header.length == (poll_data_length - sizeof(sl_cpc_system_cmd_header_t))); *on_write_complete_arg = NULL; // Allocate command buffer. Freed on acknowledgment. (On write completion callback) sl_status_t status = sli_cpc_get_system_command_buffer(&tx_command); // If no more memory, leave the reply data to NULL and let the upper layer retry later if (status == SL_STATUS_NO_MORE_RESOURCE) { return; } EFM_ASSERT(status == SL_STATUS_OK); *reply_data = tx_command; // Assign the sequence number of the request to the reply so the primary can // route it back to the right request. tx_command->header.seq = rx_command->header.seq; switch (rx_command->header.command_id) { case CMD_SYSTEM_NOOP: on_noop((sl_cpc_system_cmd_t *)*reply_data, reply_data_lenght); break; #if (!defined(SLI_CPC_DEVICE_UNDER_TEST)) case CMD_SYSTEM_RESET: on_reset((sl_cpc_system_cmd_t *)*reply_data, reply_data_lenght, on_write_complete_arg); break; #endif case CMD_SYSTEM_PROP_VALUE_GET: on_property_get(rx_command, (sl_cpc_system_cmd_t *)*reply_data, reply_data_lenght); break; case CMD_SYSTEM_PROP_VALUE_SET: on_property_set(rx_command, (sl_cpc_system_cmd_t *)*reply_data, reply_data_lenght); break; default: // Command not recognized EFM_ASSERT(false); break; } }
/***************************************************************************/ /** * This function is called by CPC core when uframe/poll is received ******************************************************************************/
This function is called by CPC core when uframe/poll is received
[ "This", "function", "is", "called", "by", "CPC", "core", "when", "uframe", "/", "poll", "is", "received" ]
static void on_poll(uint8_t endpoint_id, void *arg, void *poll_data, uint32_t poll_data_length, void **reply_data, uint32_t *reply_data_lenght, void **on_write_complete_arg) { sl_cpc_system_cmd_t *rx_command = (sl_cpc_system_cmd_t *)poll_data; sl_cpc_system_cmd_t *tx_command; *reply_data = NULL; *reply_data_lenght = 0; (void)endpoint_id; (void)arg; EFM_ASSERT(endpoint_id == SL_CPC_ENDPOINT_SYSTEM); EFM_ASSERT(rx_command->header.length == (poll_data_length - sizeof(sl_cpc_system_cmd_header_t))); *on_write_complete_arg = NULL; sl_status_t status = sli_cpc_get_system_command_buffer(&tx_command); if (status == SL_STATUS_NO_MORE_RESOURCE) { return; } EFM_ASSERT(status == SL_STATUS_OK); *reply_data = tx_command; tx_command->header.seq = rx_command->header.seq; switch (rx_command->header.command_id) { case CMD_SYSTEM_NOOP: on_noop((sl_cpc_system_cmd_t *)*reply_data, reply_data_lenght); break; #if (!defined(SLI_CPC_DEVICE_UNDER_TEST)) case CMD_SYSTEM_RESET: on_reset((sl_cpc_system_cmd_t *)*reply_data, reply_data_lenght, on_write_complete_arg); break; #endif case CMD_SYSTEM_PROP_VALUE_GET: on_property_get(rx_command, (sl_cpc_system_cmd_t *)*reply_data, reply_data_lenght); break; case CMD_SYSTEM_PROP_VALUE_SET: on_property_set(rx_command, (sl_cpc_system_cmd_t *)*reply_data, reply_data_lenght); break; default: EFM_ASSERT(false); break; } }
[ "static", "void", "on_poll", "(", "uint8_t", "endpoint_id", ",", "void", "*", "arg", ",", "void", "*", "poll_data", ",", "uint32_t", "poll_data_length", ",", "void", "*", "*", "reply_data", ",", "uint32_t", "*", "reply_data_lenght", ",", "void", "*", "*", "on_write_complete_arg", ")", "{", "sl_cpc_system_cmd_t", "*", "rx_command", "=", "(", "sl_cpc_system_cmd_t", "*", ")", "poll_data", ";", "sl_cpc_system_cmd_t", "*", "tx_command", ";", "*", "reply_data", "=", "NULL", ";", "*", "reply_data_lenght", "=", "0", ";", "(", "void", ")", "endpoint_id", ";", "(", "void", ")", "arg", ";", "EFM_ASSERT", "(", "endpoint_id", "==", "SL_CPC_ENDPOINT_SYSTEM", ")", ";", "EFM_ASSERT", "(", "rx_command", "->", "header", ".", "length", "==", "(", "poll_data_length", "-", "sizeof", "(", "sl_cpc_system_cmd_header_t", ")", ")", ")", ";", "*", "on_write_complete_arg", "=", "NULL", ";", "sl_status_t", "status", "=", "sli_cpc_get_system_command_buffer", "(", "&", "tx_command", ")", ";", "if", "(", "status", "==", "SL_STATUS_NO_MORE_RESOURCE", ")", "{", "return", ";", "}", "EFM_ASSERT", "(", "status", "==", "SL_STATUS_OK", ")", ";", "*", "reply_data", "=", "tx_command", ";", "tx_command", "->", "header", ".", "seq", "=", "rx_command", "->", "header", ".", "seq", ";", "switch", "(", "rx_command", "->", "header", ".", "command_id", ")", "{", "case", "CMD_SYSTEM_NOOP", ":", "on_noop", "(", "(", "sl_cpc_system_cmd_t", "*", ")", "*", "reply_data", ",", "reply_data_lenght", ")", ";", "break", ";", "#if", "(", "!", "defined", "(", "SLI_CPC_DEVICE_UNDER_TEST", ")", ")", "\n", "case", "CMD_SYSTEM_RESET", ":", "on_reset", "(", "(", "sl_cpc_system_cmd_t", "*", ")", "*", "reply_data", ",", "reply_data_lenght", ",", "on_write_complete_arg", ")", ";", "break", ";", "#endif", "case", "CMD_SYSTEM_PROP_VALUE_GET", ":", "on_property_get", "(", "rx_command", ",", "(", "sl_cpc_system_cmd_t", "*", ")", "*", "reply_data", ",", "reply_data_lenght", ")", ";", "break", ";", "case", "CMD_SYSTEM_PROP_VALUE_SET", ":", "on_property_set", "(", "rx_command", ",", "(", "sl_cpc_system_cmd_t", "*", ")", "*", "reply_data", ",", "reply_data_lenght", ")", ";", "break", ";", "default", ":", "EFM_ASSERT", "(", "false", ")", ";", "break", ";", "}", "}" ]
This function is called by CPC core when uframe/poll is received
[ "This", "function", "is", "called", "by", "CPC", "core", "when", "uframe", "/", "poll", "is", "received" ]
[ "// Make sure the length of the payload from the command matches the returned length.", "// Allocate command buffer. Freed on acknowledgment. (On write completion callback)", "// If no more memory, leave the reply data to NULL and let the upper layer retry later", "// Assign the sequence number of the request to the reply so the primary can", "// route it back to the right request.", "// Command not recognized" ]
[ { "param": "endpoint_id", "type": "uint8_t" }, { "param": "arg", "type": "void" }, { "param": "poll_data", "type": "void" }, { "param": "poll_data_length", "type": "uint32_t" }, { "param": "reply_data", "type": "void" }, { "param": "reply_data_lenght", "type": "uint32_t" }, { "param": "on_write_complete_arg", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "endpoint_id", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "arg", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "poll_data", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "poll_data_length", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reply_data", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reply_data_lenght", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "on_write_complete_arg", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
24beef876c276ed52984cb73d1e321e34dd7623c
SiliconLabs/Gecko_SDK
platform/radio/mac/lower-mac-rail-802.15.4.c
[ "Zlib" ]
C
sl_mac_lower_mac_set_radio_idle_mode
sl_status_t
sl_status_t sl_mac_lower_mac_set_radio_idle_mode(uint8_t mac_index, RadioPowerMode mode) { UNUSED_VAR(mac_index); LOWER_MAC_ASSERT(sl_mac_lower_mac_is_idle(mac_index)); radioIdle(); return SL_STATUS_OK; }
// We don't store the idle mode here at the lower MAC, we just get it from the // upper MAC.
We don't store the idle mode here at the lower MAC, we just get it from the upper MAC.
[ "We", "don", "'", "t", "store", "the", "idle", "mode", "here", "at", "the", "lower", "MAC", "we", "just", "get", "it", "from", "the", "upper", "MAC", "." ]
sl_status_t sl_mac_lower_mac_set_radio_idle_mode(uint8_t mac_index, RadioPowerMode mode) { UNUSED_VAR(mac_index); LOWER_MAC_ASSERT(sl_mac_lower_mac_is_idle(mac_index)); radioIdle(); return SL_STATUS_OK; }
[ "sl_status_t", "sl_mac_lower_mac_set_radio_idle_mode", "(", "uint8_t", "mac_index", ",", "RadioPowerMode", "mode", ")", "{", "UNUSED_VAR", "(", "mac_index", ")", ";", "LOWER_MAC_ASSERT", "(", "sl_mac_lower_mac_is_idle", "(", "mac_index", ")", ")", ";", "radioIdle", "(", ")", ";", "return", "SL_STATUS_OK", ";", "}" ]
We don't store the idle mode here at the lower MAC, we just get it from the upper MAC.
[ "We", "don", "'", "t", "store", "the", "idle", "mode", "here", "at", "the", "lower", "MAC", "we", "just", "get", "it", "from", "the", "upper", "MAC", "." ]
[]
[ { "param": "mac_index", "type": "uint8_t" }, { "param": "mode", "type": "RadioPowerMode" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mac_index", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mode", "type": "RadioPowerMode", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
24beef876c276ed52984cb73d1e321e34dd7623c
SiliconLabs/Gecko_SDK
platform/radio/mac/lower-mac-rail-802.15.4.c
[ "Zlib" ]
C
RAIL_GetRssi
int16_t
int16_t RAIL_GetRssi(RAIL_Handle_t railHandle, bool wait) { if (currentChannel >= SL_MIN_802_15_4_CHANNEL_NUMBER) { return energyLevels[currentChannel - SL_MIN_802_15_4_CHANNEL_NUMBER]; } return -128; }
// this is here instead of rail-stub, because it requires the current channel
this is here instead of rail-stub, because it requires the current channel
[ "this", "is", "here", "instead", "of", "rail", "-", "stub", "because", "it", "requires", "the", "current", "channel" ]
int16_t RAIL_GetRssi(RAIL_Handle_t railHandle, bool wait) { if (currentChannel >= SL_MIN_802_15_4_CHANNEL_NUMBER) { return energyLevels[currentChannel - SL_MIN_802_15_4_CHANNEL_NUMBER]; } return -128; }
[ "int16_t", "RAIL_GetRssi", "(", "RAIL_Handle_t", "railHandle", ",", "bool", "wait", ")", "{", "if", "(", "currentChannel", ">=", "SL_MIN_802_15_4_CHANNEL_NUMBER", ")", "{", "return", "energyLevels", "[", "currentChannel", "-", "SL_MIN_802_15_4_CHANNEL_NUMBER", "]", ";", "}", "return", "-128", ";", "}" ]
this is here instead of rail-stub, because it requires the current channel
[ "this", "is", "here", "instead", "of", "rail", "-", "stub", "because", "it", "requires", "the", "current", "channel" ]
[]
[ { "param": "railHandle", "type": "RAIL_Handle_t" }, { "param": "wait", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "railHandle", "type": "RAIL_Handle_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "wait", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
24beef876c276ed52984cb73d1e321e34dd7623c
SiliconLabs/Gecko_SDK
platform/radio/mac/lower-mac-rail-802.15.4.c
[ "Zlib" ]
C
sl_mac_get_current_packet_sync_word_detection_elapsed_time_us
uint32_t
uint32_t sl_mac_get_current_packet_sync_word_detection_elapsed_time_us(void) { uint8_t *currentIncomingFramePtr; uint16_t currentIncomingFrameBufferLength; uint32_t syncTimeUs; LOWER_MAC_ASSERT(currentIncomingFrame != NULL_BUFFER); currentIncomingFramePtr = emGetBufferPointer(currentIncomingFrame); currentIncomingFrameBufferLength = emGetBufferLength(currentIncomingFrame); syncTimeUs = emberFetchLowHighInt32u(currentIncomingFramePtr + currentIncomingFrameBufferLength - EMBER_APPENDED_INFO_TOTAL_LENGTH + EMBER_APPENDED_INFO_SYNC_TIME_OFFSET); return elapsedTimeInt32u(syncTimeUs, RAIL_GetTime()); }
// Note, this is just a temporary buffer system thing. We probably won't need this after the new buffer system
Note, this is just a temporary buffer system thing. We probably won't need this after the new buffer system
[ "Note", "this", "is", "just", "a", "temporary", "buffer", "system", "thing", ".", "We", "probably", "won", "'", "t", "need", "this", "after", "the", "new", "buffer", "system" ]
uint32_t sl_mac_get_current_packet_sync_word_detection_elapsed_time_us(void) { uint8_t *currentIncomingFramePtr; uint16_t currentIncomingFrameBufferLength; uint32_t syncTimeUs; LOWER_MAC_ASSERT(currentIncomingFrame != NULL_BUFFER); currentIncomingFramePtr = emGetBufferPointer(currentIncomingFrame); currentIncomingFrameBufferLength = emGetBufferLength(currentIncomingFrame); syncTimeUs = emberFetchLowHighInt32u(currentIncomingFramePtr + currentIncomingFrameBufferLength - EMBER_APPENDED_INFO_TOTAL_LENGTH + EMBER_APPENDED_INFO_SYNC_TIME_OFFSET); return elapsedTimeInt32u(syncTimeUs, RAIL_GetTime()); }
[ "uint32_t", "sl_mac_get_current_packet_sync_word_detection_elapsed_time_us", "(", "void", ")", "{", "uint8_t", "*", "currentIncomingFramePtr", ";", "uint16_t", "currentIncomingFrameBufferLength", ";", "uint32_t", "syncTimeUs", ";", "LOWER_MAC_ASSERT", "(", "currentIncomingFrame", "!=", "NULL_BUFFER", ")", ";", "currentIncomingFramePtr", "=", "emGetBufferPointer", "(", "currentIncomingFrame", ")", ";", "currentIncomingFrameBufferLength", "=", "emGetBufferLength", "(", "currentIncomingFrame", ")", ";", "syncTimeUs", "=", "emberFetchLowHighInt32u", "(", "currentIncomingFramePtr", "+", "currentIncomingFrameBufferLength", "-", "EMBER_APPENDED_INFO_TOTAL_LENGTH", "+", "EMBER_APPENDED_INFO_SYNC_TIME_OFFSET", ")", ";", "return", "elapsedTimeInt32u", "(", "syncTimeUs", ",", "RAIL_GetTime", "(", ")", ")", ";", "}" ]
Note, this is just a temporary buffer system thing.
[ "Note", "this", "is", "just", "a", "temporary", "buffer", "system", "thing", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
24beef876c276ed52984cb73d1e321e34dd7623c
SiliconLabs/Gecko_SDK
platform/radio/mac/lower-mac-rail-802.15.4.c
[ "Zlib" ]
C
sl_mac_lower_mac_radio_sleep
void
void sl_mac_lower_mac_radio_sleep(void) { // Need to clear the outgoing pending and cancel the TX sent timer so that we // can change the radio state without hitting the debug asserts. LOWER_MAC_DEBUG_SET_OUTGOING_PENDING(false, false); LOWER_MAC_DEBUG_CANCEL_TX_SENT_TIMER(false); #if defined(MAC_DEBUG_TOKEN) LOWER_MAC_DEBUG_DUMP_ACTIONS_TO_TOKEN(); #else LOWER_MAC_DEBUG_DUMP_ACTIONS(); #endif RAIL_Idle(connectRailHandle, RAIL_IDLE_ABORT, true); (void) onPtaStackEvent(SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_IDLED, 0U); (void) onPtaStackEvent(SL_RAIL_UTIL_IEEE802154_STACK_EVENT_RX_IDLED, 0U); #ifndef EMBER_TEST halStackRadioPowerDownBoard(); // Note: // We call halStackRadioPowerMainControl from here, which is documented to not // be called from ISR context -- so if sl_mac_lower_mac_radio_sleep is called // from interrupt context that contract is broken. // // Currently the only user of this API that is called in interrupt context is // in Zigbee's assert-crash-handlers.c, but we're already crashing there, so // we can ignore it for that case. radioPowerFem(false); #endif }
// TODO: this is a temporary API needed for a temporary workaround in the HAL // code: basically the code in assert-crash-handlers.c now calls emRadioSleep(). // This API is now also needed for a weird use case in misc-onboard.c
this is a temporary API needed for a temporary workaround in the HAL code: basically the code in assert-crash-handlers.c now calls emRadioSleep(). This API is now also needed for a weird use case in misc-onboard.c
[ "this", "is", "a", "temporary", "API", "needed", "for", "a", "temporary", "workaround", "in", "the", "HAL", "code", ":", "basically", "the", "code", "in", "assert", "-", "crash", "-", "handlers", ".", "c", "now", "calls", "emRadioSleep", "()", ".", "This", "API", "is", "now", "also", "needed", "for", "a", "weird", "use", "case", "in", "misc", "-", "onboard", ".", "c" ]
void sl_mac_lower_mac_radio_sleep(void) { LOWER_MAC_DEBUG_SET_OUTGOING_PENDING(false, false); LOWER_MAC_DEBUG_CANCEL_TX_SENT_TIMER(false); #if defined(MAC_DEBUG_TOKEN) LOWER_MAC_DEBUG_DUMP_ACTIONS_TO_TOKEN(); #else LOWER_MAC_DEBUG_DUMP_ACTIONS(); #endif RAIL_Idle(connectRailHandle, RAIL_IDLE_ABORT, true); (void) onPtaStackEvent(SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_IDLED, 0U); (void) onPtaStackEvent(SL_RAIL_UTIL_IEEE802154_STACK_EVENT_RX_IDLED, 0U); #ifndef EMBER_TEST halStackRadioPowerDownBoard(); Currently the only user of this API that is called in interrupt context is in Zigbee's assert-crash-handlers.c, but we're already crashing there, so we can ignore it for that case. radioPowerFem(false); #endif }
[ "void", "sl_mac_lower_mac_radio_sleep", "(", "void", ")", "{", "LOWER_MAC_DEBUG_SET_OUTGOING_PENDING", "(", "false", ",", "false", ")", ";", "LOWER_MAC_DEBUG_CANCEL_TX_SENT_TIMER", "(", "false", ")", ";", "#if", "defined", "(", "MAC_DEBUG_TOKEN", ")", "\n", "LOWER_MAC_DEBUG_DUMP_ACTIONS_TO_TOKEN", "(", ")", ";", "#else", "LOWER_MAC_DEBUG_DUMP_ACTIONS", "(", ")", ";", "#endif", "RAIL_Idle", "(", "connectRailHandle", ",", "RAIL_IDLE_ABORT", ",", "true", ")", ";", "(", "void", ")", "onPtaStackEvent", "(", "SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_IDLED", ",", "0U", ")", ";", "(", "void", ")", "onPtaStackEvent", "(", "SL_RAIL_UTIL_IEEE802154_STACK_EVENT_RX_IDLED", ",", "0U", ")", ";", "#ifndef", "EMBER_TEST", "halStackRadioPowerDownBoard", "(", ")", ";", "radioPowerFem", "(", "false", ")", ";", "#endif", "}" ]
TODO: this is a temporary API needed for a temporary workaround in the HAL code: basically the code in assert-crash-handlers.c now calls emRadioSleep().
[ "TODO", ":", "this", "is", "a", "temporary", "API", "needed", "for", "a", "temporary", "workaround", "in", "the", "HAL", "code", ":", "basically", "the", "code", "in", "assert", "-", "crash", "-", "handlers", ".", "c", "now", "calls", "emRadioSleep", "()", "." ]
[ "// Need to clear the outgoing pending and cancel the TX sent timer so that we", "// can change the radio state without hitting the debug asserts.", "// Note:", "// We call halStackRadioPowerMainControl from here, which is documented to not", "// be called from ISR context -- so if sl_mac_lower_mac_radio_sleep is called", "// from interrupt context that contract is broken.", "//", "// Currently the only user of this API that is called in interrupt context is", "// in Zigbee's assert-crash-handlers.c, but we're already crashing there, so", "// we can ignore it for that case." ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
24beef876c276ed52984cb73d1e321e34dd7623c
SiliconLabs/Gecko_SDK
platform/radio/mac/lower-mac-rail-802.15.4.c
[ "Zlib" ]
C
packetSentCallback
void
static void packetSentCallback(bool isAck) { #ifdef CSL_SUPPORT if (getInternalFlag(FLAG_CURRENT_TX_USE_WAKE_UP_FRAMES)) { cslPacketsSent++; if (cslPacketsSent != (totalWakeupFramesToSend + 1)) { fillTxFifoWithWakeupFrames(); return; } setInternalFlag(FLAG_CURRENT_TX_USE_WAKE_UP_FRAMES, false); LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_CSL_TX_COMPLETE, cslPacketsSent); } #endif // CSL_SUPPORT if (isAck) { // We successfully sent out an ACK. LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_TX_ACK_SENT, 0xFF); setInternalFlag(FLAG_ONGOING_TX_ACK, false); // We acked the packet we received after a poll: we can yield now. if (emLowerMacState == EMBER_MAC_STATE_EXPECTING_DATA) { RAIL_YieldRadio(connectRailHandle); } } else if (getInternalFlag(FLAG_ONGOING_TX_DATA)) { current_force_tx_after_failed_cca_attempts = 0; LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_TX_DATA_SENT, txCompleteStatusPending); LOWER_MAC_ASSERT(txCompleteStatusPending == TX_COMPLETE_RESULT_NONE); setInternalFlag(FLAG_ONGOING_TX_DATA, false); txCompleteStatusPending = TX_COMPLETE_RESULT_SUCCESS; if (emLowerMacState == EMBER_MAC_STATE_TX_WAITING_FOR_ACK) { setInternalFlag(FLAG_WAITING_FOR_ACK, true); (void) onPtaStackEvent(SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_ACK_WAITING, 0U); } LOWER_MAC_DEBUG_ASSERT_OUTGOING_PENDING(true, false); LOWER_MAC_DEBUG_SET_OUTGOING_PENDING(false, false); LOWER_MAC_DEBUG_CANCEL_TX_SENT_TIMER(true); if (emLowerMacState == EMBER_MAC_STATE_TX_NO_ACK) { (void) onPtaStackEvent(SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_ENDED, 0U); RAIL_YieldRadio(connectRailHandle); } STACK_WAKEUP_ISR_HANDLER; } }
// This callback fires if transmission was successful. // Notice that we configure RAIL so that the radio goes back to RX after any // TX operation.
This callback fires if transmission was successful. Notice that we configure RAIL so that the radio goes back to RX after any TX operation.
[ "This", "callback", "fires", "if", "transmission", "was", "successful", ".", "Notice", "that", "we", "configure", "RAIL", "so", "that", "the", "radio", "goes", "back", "to", "RX", "after", "any", "TX", "operation", "." ]
static void packetSentCallback(bool isAck) { #ifdef CSL_SUPPORT if (getInternalFlag(FLAG_CURRENT_TX_USE_WAKE_UP_FRAMES)) { cslPacketsSent++; if (cslPacketsSent != (totalWakeupFramesToSend + 1)) { fillTxFifoWithWakeupFrames(); return; } setInternalFlag(FLAG_CURRENT_TX_USE_WAKE_UP_FRAMES, false); LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_CSL_TX_COMPLETE, cslPacketsSent); } #endif if (isAck) { LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_TX_ACK_SENT, 0xFF); setInternalFlag(FLAG_ONGOING_TX_ACK, false); if (emLowerMacState == EMBER_MAC_STATE_EXPECTING_DATA) { RAIL_YieldRadio(connectRailHandle); } } else if (getInternalFlag(FLAG_ONGOING_TX_DATA)) { current_force_tx_after_failed_cca_attempts = 0; LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_TX_DATA_SENT, txCompleteStatusPending); LOWER_MAC_ASSERT(txCompleteStatusPending == TX_COMPLETE_RESULT_NONE); setInternalFlag(FLAG_ONGOING_TX_DATA, false); txCompleteStatusPending = TX_COMPLETE_RESULT_SUCCESS; if (emLowerMacState == EMBER_MAC_STATE_TX_WAITING_FOR_ACK) { setInternalFlag(FLAG_WAITING_FOR_ACK, true); (void) onPtaStackEvent(SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_ACK_WAITING, 0U); } LOWER_MAC_DEBUG_ASSERT_OUTGOING_PENDING(true, false); LOWER_MAC_DEBUG_SET_OUTGOING_PENDING(false, false); LOWER_MAC_DEBUG_CANCEL_TX_SENT_TIMER(true); if (emLowerMacState == EMBER_MAC_STATE_TX_NO_ACK) { (void) onPtaStackEvent(SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_ENDED, 0U); RAIL_YieldRadio(connectRailHandle); } STACK_WAKEUP_ISR_HANDLER; } }
[ "static", "void", "packetSentCallback", "(", "bool", "isAck", ")", "{", "#ifdef", "CSL_SUPPORT", "if", "(", "getInternalFlag", "(", "FLAG_CURRENT_TX_USE_WAKE_UP_FRAMES", ")", ")", "{", "cslPacketsSent", "++", ";", "if", "(", "cslPacketsSent", "!=", "(", "totalWakeupFramesToSend", "+", "1", ")", ")", "{", "fillTxFifoWithWakeupFrames", "(", ")", ";", "return", ";", "}", "setInternalFlag", "(", "FLAG_CURRENT_TX_USE_WAKE_UP_FRAMES", ",", "false", ")", ";", "LOWER_MAC_DEBUG_ADD_ACTION", "(", "LOWER_MAC_DEBUG_ACTION_CSL_TX_COMPLETE", ",", "cslPacketsSent", ")", ";", "}", "#endif", "if", "(", "isAck", ")", "{", "LOWER_MAC_DEBUG_ADD_ACTION", "(", "LOWER_MAC_DEBUG_ACTION_TX_ACK_SENT", ",", "0xFF", ")", ";", "setInternalFlag", "(", "FLAG_ONGOING_TX_ACK", ",", "false", ")", ";", "if", "(", "emLowerMacState", "==", "EMBER_MAC_STATE_EXPECTING_DATA", ")", "{", "RAIL_YieldRadio", "(", "connectRailHandle", ")", ";", "}", "}", "else", "if", "(", "getInternalFlag", "(", "FLAG_ONGOING_TX_DATA", ")", ")", "{", "current_force_tx_after_failed_cca_attempts", "=", "0", ";", "LOWER_MAC_DEBUG_ADD_ACTION", "(", "LOWER_MAC_DEBUG_ACTION_TX_DATA_SENT", ",", "txCompleteStatusPending", ")", ";", "LOWER_MAC_ASSERT", "(", "txCompleteStatusPending", "==", "TX_COMPLETE_RESULT_NONE", ")", ";", "setInternalFlag", "(", "FLAG_ONGOING_TX_DATA", ",", "false", ")", ";", "txCompleteStatusPending", "=", "TX_COMPLETE_RESULT_SUCCESS", ";", "if", "(", "emLowerMacState", "==", "EMBER_MAC_STATE_TX_WAITING_FOR_ACK", ")", "{", "setInternalFlag", "(", "FLAG_WAITING_FOR_ACK", ",", "true", ")", ";", "(", "void", ")", "onPtaStackEvent", "(", "SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_ACK_WAITING", ",", "0U", ")", ";", "}", "LOWER_MAC_DEBUG_ASSERT_OUTGOING_PENDING", "(", "true", ",", "false", ")", ";", "LOWER_MAC_DEBUG_SET_OUTGOING_PENDING", "(", "false", ",", "false", ")", ";", "LOWER_MAC_DEBUG_CANCEL_TX_SENT_TIMER", "(", "true", ")", ";", "if", "(", "emLowerMacState", "==", "EMBER_MAC_STATE_TX_NO_ACK", ")", "{", "(", "void", ")", "onPtaStackEvent", "(", "SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_ENDED", ",", "0U", ")", ";", "RAIL_YieldRadio", "(", "connectRailHandle", ")", ";", "}", "STACK_WAKEUP_ISR_HANDLER", ";", "}", "}" ]
This callback fires if transmission was successful.
[ "This", "callback", "fires", "if", "transmission", "was", "successful", "." ]
[ "// CSL_SUPPORT", "// We successfully sent out an ACK.", "// We acked the packet we received after a poll: we can yield now." ]
[ { "param": "isAck", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "isAck", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
24beef876c276ed52984cb73d1e321e34dd7623c
SiliconLabs/Gecko_SDK
platform/radio/mac/lower-mac-rail-802.15.4.c
[ "Zlib" ]
C
txFailedCallback
void
static void txFailedCallback(bool isAck, uint8_t status) { if (isAck) { // We failed to send out an ACK. LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_TX_FAILED_ACK, status); setInternalFlag(FLAG_ONGOING_TX_ACK, false); } else if (getInternalFlag(FLAG_ONGOING_TX_DATA)) { if (status == TX_COMPLETE_RESULT_CCA_FAIL && current_force_tx_after_failed_cca_attempts > 0) { current_force_tx_after_failed_cca_attempts -= 1; if (current_force_tx_after_failed_cca_attempts == 0) { setInternalFlag(FLAG_CURRENT_TX_USE_CSMA, false); } setInternalFlag(FLAG_ONGOING_TX_DATA, false); emLowerMacState = EMBER_MAC_STATE_BUSY; // Activate the event to try to send again sli_mac_activate_event(emLowerMacEvent); #ifdef EVENT_CONTROL_SYSTEM emberMarkTaskActive(emStackTask); #endif LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_MAC_EVENT, 5); } else { current_force_tx_after_failed_cca_attempts = 0; LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_TX_FAILED_DATA, status); setInternalFlag(FLAG_ONGOING_TX_DATA, false); LOWER_MAC_ASSERT(txCompleteStatusPending == TX_COMPLETE_RESULT_NONE); txCompleteStatusPending = status; LOWER_MAC_DEBUG_ASSERT_OUTGOING_PENDING(true, false); LOWER_MAC_DEBUG_SET_OUTGOING_PENDING(false, false); LOWER_MAC_DEBUG_CANCEL_TX_SENT_TIMER(true); STACK_WAKEUP_ISR_HANDLER; } } #ifndef EMBER_STACK_CONNECT if (status == TX_COMPLETE_RESULT_CCA_FAIL) { emBuildAndSendCounterInfo(EMBER_COUNTER_PHY_CCA_FAIL_COUNT, EMBER_NULL_NODE_ID /*emMacShortDestination(lowerMacState.outgoingHeader) */, 0); } #endif }
// This callback fires if transmission failed. // Notice that we configure RAIL so that the radio goes back to RX after any // TX operation.
This callback fires if transmission failed. Notice that we configure RAIL so that the radio goes back to RX after any TX operation.
[ "This", "callback", "fires", "if", "transmission", "failed", ".", "Notice", "that", "we", "configure", "RAIL", "so", "that", "the", "radio", "goes", "back", "to", "RX", "after", "any", "TX", "operation", "." ]
static void txFailedCallback(bool isAck, uint8_t status) { if (isAck) { LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_TX_FAILED_ACK, status); setInternalFlag(FLAG_ONGOING_TX_ACK, false); } else if (getInternalFlag(FLAG_ONGOING_TX_DATA)) { if (status == TX_COMPLETE_RESULT_CCA_FAIL && current_force_tx_after_failed_cca_attempts > 0) { current_force_tx_after_failed_cca_attempts -= 1; if (current_force_tx_after_failed_cca_attempts == 0) { setInternalFlag(FLAG_CURRENT_TX_USE_CSMA, false); } setInternalFlag(FLAG_ONGOING_TX_DATA, false); emLowerMacState = EMBER_MAC_STATE_BUSY; sli_mac_activate_event(emLowerMacEvent); #ifdef EVENT_CONTROL_SYSTEM emberMarkTaskActive(emStackTask); #endif LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_MAC_EVENT, 5); } else { current_force_tx_after_failed_cca_attempts = 0; LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_TX_FAILED_DATA, status); setInternalFlag(FLAG_ONGOING_TX_DATA, false); LOWER_MAC_ASSERT(txCompleteStatusPending == TX_COMPLETE_RESULT_NONE); txCompleteStatusPending = status; LOWER_MAC_DEBUG_ASSERT_OUTGOING_PENDING(true, false); LOWER_MAC_DEBUG_SET_OUTGOING_PENDING(false, false); LOWER_MAC_DEBUG_CANCEL_TX_SENT_TIMER(true); STACK_WAKEUP_ISR_HANDLER; } } #ifndef EMBER_STACK_CONNECT if (status == TX_COMPLETE_RESULT_CCA_FAIL) { emBuildAndSendCounterInfo(EMBER_COUNTER_PHY_CCA_FAIL_COUNT, EMBER_NULL_NODE_ID , 0); } #endif }
[ "static", "void", "txFailedCallback", "(", "bool", "isAck", ",", "uint8_t", "status", ")", "{", "if", "(", "isAck", ")", "{", "LOWER_MAC_DEBUG_ADD_ACTION", "(", "LOWER_MAC_DEBUG_ACTION_TX_FAILED_ACK", ",", "status", ")", ";", "setInternalFlag", "(", "FLAG_ONGOING_TX_ACK", ",", "false", ")", ";", "}", "else", "if", "(", "getInternalFlag", "(", "FLAG_ONGOING_TX_DATA", ")", ")", "{", "if", "(", "status", "==", "TX_COMPLETE_RESULT_CCA_FAIL", "&&", "current_force_tx_after_failed_cca_attempts", ">", "0", ")", "{", "current_force_tx_after_failed_cca_attempts", "-=", "1", ";", "if", "(", "current_force_tx_after_failed_cca_attempts", "==", "0", ")", "{", "setInternalFlag", "(", "FLAG_CURRENT_TX_USE_CSMA", ",", "false", ")", ";", "}", "setInternalFlag", "(", "FLAG_ONGOING_TX_DATA", ",", "false", ")", ";", "emLowerMacState", "=", "EMBER_MAC_STATE_BUSY", ";", "sli_mac_activate_event", "(", "emLowerMacEvent", ")", ";", "#ifdef", "EVENT_CONTROL_SYSTEM", "emberMarkTaskActive", "(", "emStackTask", ")", ";", "#endif", "LOWER_MAC_DEBUG_ADD_ACTION", "(", "LOWER_MAC_DEBUG_ACTION_MAC_EVENT", ",", "5", ")", ";", "}", "else", "{", "current_force_tx_after_failed_cca_attempts", "=", "0", ";", "LOWER_MAC_DEBUG_ADD_ACTION", "(", "LOWER_MAC_DEBUG_ACTION_TX_FAILED_DATA", ",", "status", ")", ";", "setInternalFlag", "(", "FLAG_ONGOING_TX_DATA", ",", "false", ")", ";", "LOWER_MAC_ASSERT", "(", "txCompleteStatusPending", "==", "TX_COMPLETE_RESULT_NONE", ")", ";", "txCompleteStatusPending", "=", "status", ";", "LOWER_MAC_DEBUG_ASSERT_OUTGOING_PENDING", "(", "true", ",", "false", ")", ";", "LOWER_MAC_DEBUG_SET_OUTGOING_PENDING", "(", "false", ",", "false", ")", ";", "LOWER_MAC_DEBUG_CANCEL_TX_SENT_TIMER", "(", "true", ")", ";", "STACK_WAKEUP_ISR_HANDLER", ";", "}", "}", "#ifndef", "EMBER_STACK_CONNECT", "if", "(", "status", "==", "TX_COMPLETE_RESULT_CCA_FAIL", ")", "{", "emBuildAndSendCounterInfo", "(", "EMBER_COUNTER_PHY_CCA_FAIL_COUNT", ",", "EMBER_NULL_NODE_ID", ",", "0", ")", ";", "}", "#endif", "}" ]
This callback fires if transmission failed.
[ "This", "callback", "fires", "if", "transmission", "failed", "." ]
[ "// We failed to send out an ACK.", "// Activate the event to try to send again", "/*emMacShortDestination(lowerMacState.outgoingHeader) */" ]
[ { "param": "isAck", "type": "bool" }, { "param": "status", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "isAck", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "status", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
24beef876c276ed52984cb73d1e321e34dd7623c
SiliconLabs/Gecko_SDK
platform/radio/mac/lower-mac-rail-802.15.4.c
[ "Zlib" ]
C
writeRendezvousIe
uint8_t
uint8_t writeRendezvousIe(uint8_t* buffer) { uint8_t* finger = buffer; // Header IE has format // length (bits 0-6) element ID (bits 7-14) type (bit 15) content ('length' bytes) uint16_t ieHeader = ((EMBER_802_15_4_IE_HEADER_LENGTH_RENDEZVOUS_TIME << EMBER_802_15_4_IE_HEADER_LENGTH_RENDEZVOUS_TIME_OFFSET) | (EMBER_802_15_4_IE_HEADER_ELEMENT_ID_RENDEZVOUS_TIME << EMBER_802_15_4_IE_HEADER_ELEMENT_ID_RENDEZVOUS_TIME_OFFSET)); emberStoreLowHighInt16u(finger, ieHeader); finger += 2; // -1 here because it's the time after this current frame transmits uint16_t symbolsUntilPayload = (totalWakeupFramesToSend - numWakeupFrameBeingSent - 1) * (TIME_BETWEEN_WAKEUP_FRAMES_IN_SYMBOLS + WAKEUP_FRAME_TX_TIME_IN_SYMBOLS); uint16_t rendezvousTimeInSymbols = symbolsUntilPayload / 10; // Time until payload frame, in units of 10 symbols emberStoreLowHighInt16u(finger, rendezvousTimeInSymbols); finger += 2; uint16_t wakeupIntervalInSymbols = TIME_BETWEEN_WAKEUP_FRAMES_IN_SYMBOLS; emberStoreLowHighInt16u(finger, wakeupIntervalInSymbols); finger += 2; return (finger - buffer); }
// This function writes to a buffer the Rendezvous Time IE
This function writes to a buffer the Rendezvous Time IE
[ "This", "function", "writes", "to", "a", "buffer", "the", "Rendezvous", "Time", "IE" ]
uint8_t writeRendezvousIe(uint8_t* buffer) { uint8_t* finger = buffer; uint16_t ieHeader = ((EMBER_802_15_4_IE_HEADER_LENGTH_RENDEZVOUS_TIME << EMBER_802_15_4_IE_HEADER_LENGTH_RENDEZVOUS_TIME_OFFSET) | (EMBER_802_15_4_IE_HEADER_ELEMENT_ID_RENDEZVOUS_TIME << EMBER_802_15_4_IE_HEADER_ELEMENT_ID_RENDEZVOUS_TIME_OFFSET)); emberStoreLowHighInt16u(finger, ieHeader); finger += 2; uint16_t symbolsUntilPayload = (totalWakeupFramesToSend - numWakeupFrameBeingSent - 1) * (TIME_BETWEEN_WAKEUP_FRAMES_IN_SYMBOLS + WAKEUP_FRAME_TX_TIME_IN_SYMBOLS); uint16_t rendezvousTimeInSymbols = symbolsUntilPayload / 10; emberStoreLowHighInt16u(finger, rendezvousTimeInSymbols); finger += 2; uint16_t wakeupIntervalInSymbols = TIME_BETWEEN_WAKEUP_FRAMES_IN_SYMBOLS; emberStoreLowHighInt16u(finger, wakeupIntervalInSymbols); finger += 2; return (finger - buffer); }
[ "uint8_t", "writeRendezvousIe", "(", "uint8_t", "*", "buffer", ")", "{", "uint8_t", "*", "finger", "=", "buffer", ";", "uint16_t", "ieHeader", "=", "(", "(", "EMBER_802_15_4_IE_HEADER_LENGTH_RENDEZVOUS_TIME", "<<", "EMBER_802_15_4_IE_HEADER_LENGTH_RENDEZVOUS_TIME_OFFSET", ")", "|", "(", "EMBER_802_15_4_IE_HEADER_ELEMENT_ID_RENDEZVOUS_TIME", "<<", "EMBER_802_15_4_IE_HEADER_ELEMENT_ID_RENDEZVOUS_TIME_OFFSET", ")", ")", ";", "emberStoreLowHighInt16u", "(", "finger", ",", "ieHeader", ")", ";", "finger", "+=", "2", ";", "uint16_t", "symbolsUntilPayload", "=", "(", "totalWakeupFramesToSend", "-", "numWakeupFrameBeingSent", "-", "1", ")", "*", "(", "TIME_BETWEEN_WAKEUP_FRAMES_IN_SYMBOLS", "+", "WAKEUP_FRAME_TX_TIME_IN_SYMBOLS", ")", ";", "uint16_t", "rendezvousTimeInSymbols", "=", "symbolsUntilPayload", "/", "10", ";", "emberStoreLowHighInt16u", "(", "finger", ",", "rendezvousTimeInSymbols", ")", ";", "finger", "+=", "2", ";", "uint16_t", "wakeupIntervalInSymbols", "=", "TIME_BETWEEN_WAKEUP_FRAMES_IN_SYMBOLS", ";", "emberStoreLowHighInt16u", "(", "finger", ",", "wakeupIntervalInSymbols", ")", ";", "finger", "+=", "2", ";", "return", "(", "finger", "-", "buffer", ")", ";", "}" ]
This function writes to a buffer the Rendezvous Time IE
[ "This", "function", "writes", "to", "a", "buffer", "the", "Rendezvous", "Time", "IE" ]
[ "// Header IE has format", "// length (bits 0-6) element ID (bits 7-14) type (bit 15) content ('length' bytes)", "// -1 here because it's the time after this current frame transmits", "// Time until payload frame, in units of 10 symbols" ]
[ { "param": "buffer", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "buffer", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
24beef876c276ed52984cb73d1e321e34dd7623c
SiliconLabs/Gecko_SDK
platform/radio/mac/lower-mac-rail-802.15.4.c
[ "Zlib" ]
C
radioSetTx
void
static void radioSetTx(uint8_t *dataPtr, uint8_t dataLength, uint16_t transactionTimeUs) { RAIL_Status_t status; uint16_t txFifoSize; RAIL_TxOptions_t txOptions = RAIL_TX_OPTIONS_DEFAULT; bool ackRequested = ( (emMfglibMode != 0u) ? false : sl_mac_flat_ack_requested(dataPtr, true) ); #if SLI_DMP_TUNING_SUPPORTED txSchedulerInfo.priority = radioSchedulerPriorityTable.tx; #endif//SLI_DMP_TUNING_SUPPORTED txSchedulerInfo.transactionTime = transactionTimeUs; if (ackRequested) { txOptions |= RAIL_TX_OPTION_WAIT_FOR_ACK; } #if (SLI_ANTDIV_SUPPORTED && defined(RAIL_TX_OPTION_ANTENNA0)) // Translate Tx antenna diversity mode into RAIL Tx Antenna options: // If enabled, use the currently-selected antenna, otherwise leave // both options 0 so Tx antenna tracks Rx antenna. if (sl_rail_util_ant_div_get_tx_antenna_mode() != SL_RAIL_UTIL_ANTENNA_MODE_DISABLED) { txOptions |= ((sl_rail_util_ant_div_get_tx_antenna_selected() == SL_RAIL_UTIL_ANTENNA_SELECT_ANTENNA1) ? RAIL_TX_OPTION_ANTENNA0 : RAIL_TX_OPTION_ANTENNA1); } #endif//(SLI_ANTDIV_SUPPORTED && defined(RAIL_TX_OPTION_ANTENNA0)) // Ensure that radio state is not being changed during TX. LOWER_MAC_DEBUG_ASSERT_OUTGOING_PENDING(false, false); uint16_t txFifoLengthRequested = EMBER_PHY_MAX_PACKET_LENGTH; #ifdef CSL_SUPPORT if (getInternalFlag(FLAG_CURRENT_TX_USE_WAKE_UP_FRAMES)) { addFirstWakeupFrameInFifo(dataPtr); // Hijack the buffer to send with a new buffer that contains a wake up frame dataPtr = cslFrameFifo; dataLength = WAKEUP_FRAME_SIZE_BYTES_NO_CRC; RAIL_TxRepeatConfig_t txRepeatConfig = { .iterations = totalWakeupFramesToSend, .repeatOptions = 0, .delayOrHop = RAIL_TRANSITION_TIME_KEEP }; (void)RAIL_SetNextTxRepeat(connectRailHandle, &txRepeatConfig); txFifoLengthRequested = sizeof(cslFrameFifo); } #endif // CSL_SUPPORT txFifoSize = RAIL_SetTxFifo(connectRailHandle, dataPtr, dataLength, txFifoLengthRequested); #ifndef LOWER_MAC_DEBUG (void)txFifoSize; #else // LOWER_MAC_DEBUG LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_SET_TX_FIFO, txFifoSize); #endif // LOWER_MAC_DEBUG currentRadioChannel = currentChannel; #ifdef CSL_SUPPORT if (getInternalFlag(FLAG_CURRENT_TX_USE_WAKE_UP_FRAMES)) { cslPacketsSent = 0; payloadFrameLoadedInTxFifo = false; fillTxFifoWithWakeupFrames(); LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_CSL_WAKEUP_FRAMES_ADDED, numWakeupFrameBeingSent + 1); } #endif // CSL_SUPPORT if (getInternalFlag(FLAG_CURRENT_TX_USE_CSMA)) { status = RAIL_StartCcaCsmaTx(connectRailHandle, currentRadioChannel, txOptions, &csmaParams, &txSchedulerInfo); LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_SET_RADIO_STATE_TX, ackRequested ? (((uint64_t)sl_mac_flat_sequence_number(dataPtr) << 32) | (0x11 | (status << 8))) : (((uint64_t)sl_mac_flat_sequence_number(dataPtr) << 32) | (0x10 | (status << 8)))); } else { status = RAIL_StartTx(connectRailHandle, currentRadioChannel, txOptions, &txSchedulerInfo); if (status == RAIL_STATUS_NO_ERROR) { (void) onPtaStackEvent(SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_STARTED, 0U); } LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_SET_RADIO_STATE_TX, ackRequested ? (((uint64_t)sl_mac_flat_sequence_number(dataPtr) << 32) | (0x01 | (status << 8))) : (((uint64_t)sl_mac_flat_sequence_number(dataPtr) << 32) | (0x00 | (status << 8)))); } #ifdef CSL_SUPPORT if ((status == RAIL_STATUS_NO_ERROR) && getInternalFlag(FLAG_CURRENT_TX_USE_WAKE_UP_FRAMES)) { // When sending wake up frames, we tell RAIL to alert us when the TX FIFO // drops below a certain threshold, so that we can fill it up again with // more frames. The threshold is high here because we don't want interrupt // latency to happen and find out the FIFO is (now) empty, causing a // RAIL_EVENT_TX_UNDERFLOW error to occur uint16_t threshold = (uint16_t)(0.95 * txFifoSize); uint16_t txThreshold = RAIL_SetTxFifoThreshold(connectRailHandle, threshold); #ifndef LOWER_MAC_DEBUG (void)txThreshold; #else // LOWER_MAC_DEBUG LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_CSL_TX_FIFO_THRESHOLD, txThreshold); #endif // LOWER_MAC_DEBUG } #endif // CSL_SUPPORT if (status != RAIL_STATUS_NO_ERROR) { (void) onPtaStackEvent(SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_BLOCKED, (uint32_t) ackRequested); } LOWER_MAC_ASSERT(status == RAIL_STATUS_NO_ERROR); }
// This is always called with interrupts disabled.
This is always called with interrupts disabled.
[ "This", "is", "always", "called", "with", "interrupts", "disabled", "." ]
static void radioSetTx(uint8_t *dataPtr, uint8_t dataLength, uint16_t transactionTimeUs) { RAIL_Status_t status; uint16_t txFifoSize; RAIL_TxOptions_t txOptions = RAIL_TX_OPTIONS_DEFAULT; bool ackRequested = ( (emMfglibMode != 0u) ? false : sl_mac_flat_ack_requested(dataPtr, true) ); #if SLI_DMP_TUNING_SUPPORTED txSchedulerInfo.priority = radioSchedulerPriorityTable.tx; #endif txSchedulerInfo.transactionTime = transactionTimeUs; if (ackRequested) { txOptions |= RAIL_TX_OPTION_WAIT_FOR_ACK; } #if (SLI_ANTDIV_SUPPORTED && defined(RAIL_TX_OPTION_ANTENNA0)) if (sl_rail_util_ant_div_get_tx_antenna_mode() != SL_RAIL_UTIL_ANTENNA_MODE_DISABLED) { txOptions |= ((sl_rail_util_ant_div_get_tx_antenna_selected() == SL_RAIL_UTIL_ANTENNA_SELECT_ANTENNA1) ? RAIL_TX_OPTION_ANTENNA0 : RAIL_TX_OPTION_ANTENNA1); } #endif LOWER_MAC_DEBUG_ASSERT_OUTGOING_PENDING(false, false); uint16_t txFifoLengthRequested = EMBER_PHY_MAX_PACKET_LENGTH; #ifdef CSL_SUPPORT if (getInternalFlag(FLAG_CURRENT_TX_USE_WAKE_UP_FRAMES)) { addFirstWakeupFrameInFifo(dataPtr); dataPtr = cslFrameFifo; dataLength = WAKEUP_FRAME_SIZE_BYTES_NO_CRC; RAIL_TxRepeatConfig_t txRepeatConfig = { .iterations = totalWakeupFramesToSend, .repeatOptions = 0, .delayOrHop = RAIL_TRANSITION_TIME_KEEP }; (void)RAIL_SetNextTxRepeat(connectRailHandle, &txRepeatConfig); txFifoLengthRequested = sizeof(cslFrameFifo); } #endif txFifoSize = RAIL_SetTxFifo(connectRailHandle, dataPtr, dataLength, txFifoLengthRequested); #ifndef LOWER_MAC_DEBUG (void)txFifoSize; #else LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_SET_TX_FIFO, txFifoSize); #endif currentRadioChannel = currentChannel; #ifdef CSL_SUPPORT if (getInternalFlag(FLAG_CURRENT_TX_USE_WAKE_UP_FRAMES)) { cslPacketsSent = 0; payloadFrameLoadedInTxFifo = false; fillTxFifoWithWakeupFrames(); LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_CSL_WAKEUP_FRAMES_ADDED, numWakeupFrameBeingSent + 1); } #endif if (getInternalFlag(FLAG_CURRENT_TX_USE_CSMA)) { status = RAIL_StartCcaCsmaTx(connectRailHandle, currentRadioChannel, txOptions, &csmaParams, &txSchedulerInfo); LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_SET_RADIO_STATE_TX, ackRequested ? (((uint64_t)sl_mac_flat_sequence_number(dataPtr) << 32) | (0x11 | (status << 8))) : (((uint64_t)sl_mac_flat_sequence_number(dataPtr) << 32) | (0x10 | (status << 8)))); } else { status = RAIL_StartTx(connectRailHandle, currentRadioChannel, txOptions, &txSchedulerInfo); if (status == RAIL_STATUS_NO_ERROR) { (void) onPtaStackEvent(SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_STARTED, 0U); } LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_SET_RADIO_STATE_TX, ackRequested ? (((uint64_t)sl_mac_flat_sequence_number(dataPtr) << 32) | (0x01 | (status << 8))) : (((uint64_t)sl_mac_flat_sequence_number(dataPtr) << 32) | (0x00 | (status << 8)))); } #ifdef CSL_SUPPORT if ((status == RAIL_STATUS_NO_ERROR) && getInternalFlag(FLAG_CURRENT_TX_USE_WAKE_UP_FRAMES)) { uint16_t threshold = (uint16_t)(0.95 * txFifoSize); uint16_t txThreshold = RAIL_SetTxFifoThreshold(connectRailHandle, threshold); #ifndef LOWER_MAC_DEBUG (void)txThreshold; #else LOWER_MAC_DEBUG_ADD_ACTION(LOWER_MAC_DEBUG_ACTION_CSL_TX_FIFO_THRESHOLD, txThreshold); #endif } #endif if (status != RAIL_STATUS_NO_ERROR) { (void) onPtaStackEvent(SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_BLOCKED, (uint32_t) ackRequested); } LOWER_MAC_ASSERT(status == RAIL_STATUS_NO_ERROR); }
[ "static", "void", "radioSetTx", "(", "uint8_t", "*", "dataPtr", ",", "uint8_t", "dataLength", ",", "uint16_t", "transactionTimeUs", ")", "{", "RAIL_Status_t", "status", ";", "uint16_t", "txFifoSize", ";", "RAIL_TxOptions_t", "txOptions", "=", "RAIL_TX_OPTIONS_DEFAULT", ";", "bool", "ackRequested", "=", "(", "(", "emMfglibMode", "!=", "0u", ")", "?", "false", ":", "sl_mac_flat_ack_requested", "(", "dataPtr", ",", "true", ")", ")", ";", "#if", "SLI_DMP_TUNING_SUPPORTED", "\n", "txSchedulerInfo", ".", "priority", "=", "radioSchedulerPriorityTable", ".", "tx", ";", "#endif", "txSchedulerInfo", ".", "transactionTime", "=", "transactionTimeUs", ";", "if", "(", "ackRequested", ")", "{", "txOptions", "|=", "RAIL_TX_OPTION_WAIT_FOR_ACK", ";", "}", "#if", "(", "SLI_ANTDIV_SUPPORTED", "&&", "defined", "(", "RAIL_TX_OPTION_ANTENNA0", ")", ")", "\n", "if", "(", "sl_rail_util_ant_div_get_tx_antenna_mode", "(", ")", "!=", "SL_RAIL_UTIL_ANTENNA_MODE_DISABLED", ")", "{", "txOptions", "|=", "(", "(", "sl_rail_util_ant_div_get_tx_antenna_selected", "(", ")", "==", "SL_RAIL_UTIL_ANTENNA_SELECT_ANTENNA1", ")", "?", "RAIL_TX_OPTION_ANTENNA0", ":", "RAIL_TX_OPTION_ANTENNA1", ")", ";", "}", "#endif", "LOWER_MAC_DEBUG_ASSERT_OUTGOING_PENDING", "(", "false", ",", "false", ")", ";", "uint16_t", "txFifoLengthRequested", "=", "EMBER_PHY_MAX_PACKET_LENGTH", ";", "#ifdef", "CSL_SUPPORT", "if", "(", "getInternalFlag", "(", "FLAG_CURRENT_TX_USE_WAKE_UP_FRAMES", ")", ")", "{", "addFirstWakeupFrameInFifo", "(", "dataPtr", ")", ";", "dataPtr", "=", "cslFrameFifo", ";", "dataLength", "=", "WAKEUP_FRAME_SIZE_BYTES_NO_CRC", ";", "RAIL_TxRepeatConfig_t", "txRepeatConfig", "=", "{", ".", "iterations", "=", "totalWakeupFramesToSend", ",", ".", "repeatOptions", "=", "0", ",", ".", "delayOrHop", "=", "RAIL_TRANSITION_TIME_KEEP", "}", ";", "(", "void", ")", "RAIL_SetNextTxRepeat", "(", "connectRailHandle", ",", "&", "txRepeatConfig", ")", ";", "txFifoLengthRequested", "=", "sizeof", "(", "cslFrameFifo", ")", ";", "}", "#endif", "txFifoSize", "=", "RAIL_SetTxFifo", "(", "connectRailHandle", ",", "dataPtr", ",", "dataLength", ",", "txFifoLengthRequested", ")", ";", "#ifndef", "LOWER_MAC_DEBUG", "(", "void", ")", "txFifoSize", ";", "#else", "LOWER_MAC_DEBUG_ADD_ACTION", "(", "LOWER_MAC_DEBUG_ACTION_SET_TX_FIFO", ",", "txFifoSize", ")", ";", "#endif", "currentRadioChannel", "=", "currentChannel", ";", "#ifdef", "CSL_SUPPORT", "if", "(", "getInternalFlag", "(", "FLAG_CURRENT_TX_USE_WAKE_UP_FRAMES", ")", ")", "{", "cslPacketsSent", "=", "0", ";", "payloadFrameLoadedInTxFifo", "=", "false", ";", "fillTxFifoWithWakeupFrames", "(", ")", ";", "LOWER_MAC_DEBUG_ADD_ACTION", "(", "LOWER_MAC_DEBUG_ACTION_CSL_WAKEUP_FRAMES_ADDED", ",", "numWakeupFrameBeingSent", "+", "1", ")", ";", "}", "#endif", "if", "(", "getInternalFlag", "(", "FLAG_CURRENT_TX_USE_CSMA", ")", ")", "{", "status", "=", "RAIL_StartCcaCsmaTx", "(", "connectRailHandle", ",", "currentRadioChannel", ",", "txOptions", ",", "&", "csmaParams", ",", "&", "txSchedulerInfo", ")", ";", "LOWER_MAC_DEBUG_ADD_ACTION", "(", "LOWER_MAC_DEBUG_ACTION_SET_RADIO_STATE_TX", ",", "ackRequested", "?", "(", "(", "(", "uint64_t", ")", "sl_mac_flat_sequence_number", "(", "dataPtr", ")", "<<", "32", ")", "|", "(", "0x11", "|", "(", "status", "<<", "8", ")", ")", ")", ":", "(", "(", "(", "uint64_t", ")", "sl_mac_flat_sequence_number", "(", "dataPtr", ")", "<<", "32", ")", "|", "(", "0x10", "|", "(", "status", "<<", "8", ")", ")", ")", ")", ";", "}", "else", "{", "status", "=", "RAIL_StartTx", "(", "connectRailHandle", ",", "currentRadioChannel", ",", "txOptions", ",", "&", "txSchedulerInfo", ")", ";", "if", "(", "status", "==", "RAIL_STATUS_NO_ERROR", ")", "{", "(", "void", ")", "onPtaStackEvent", "(", "SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_STARTED", ",", "0U", ")", ";", "}", "LOWER_MAC_DEBUG_ADD_ACTION", "(", "LOWER_MAC_DEBUG_ACTION_SET_RADIO_STATE_TX", ",", "ackRequested", "?", "(", "(", "(", "uint64_t", ")", "sl_mac_flat_sequence_number", "(", "dataPtr", ")", "<<", "32", ")", "|", "(", "0x01", "|", "(", "status", "<<", "8", ")", ")", ")", ":", "(", "(", "(", "uint64_t", ")", "sl_mac_flat_sequence_number", "(", "dataPtr", ")", "<<", "32", ")", "|", "(", "0x00", "|", "(", "status", "<<", "8", ")", ")", ")", ")", ";", "}", "#ifdef", "CSL_SUPPORT", "if", "(", "(", "status", "==", "RAIL_STATUS_NO_ERROR", ")", "&&", "getInternalFlag", "(", "FLAG_CURRENT_TX_USE_WAKE_UP_FRAMES", ")", ")", "{", "uint16_t", "threshold", "=", "(", "uint16_t", ")", "(", "0.95", "*", "txFifoSize", ")", ";", "uint16_t", "txThreshold", "=", "RAIL_SetTxFifoThreshold", "(", "connectRailHandle", ",", "threshold", ")", ";", "#ifndef", "LOWER_MAC_DEBUG", "(", "void", ")", "txThreshold", ";", "#else", "LOWER_MAC_DEBUG_ADD_ACTION", "(", "LOWER_MAC_DEBUG_ACTION_CSL_TX_FIFO_THRESHOLD", ",", "txThreshold", ")", ";", "#endif", "}", "#endif", "if", "(", "status", "!=", "RAIL_STATUS_NO_ERROR", ")", "{", "(", "void", ")", "onPtaStackEvent", "(", "SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_BLOCKED", ",", "(", "uint32_t", ")", "ackRequested", ")", ";", "}", "LOWER_MAC_ASSERT", "(", "status", "==", "RAIL_STATUS_NO_ERROR", ")", ";", "}" ]
This is always called with interrupts disabled.
[ "This", "is", "always", "called", "with", "interrupts", "disabled", "." ]
[ "//SLI_DMP_TUNING_SUPPORTED", "// Translate Tx antenna diversity mode into RAIL Tx Antenna options:", "// If enabled, use the currently-selected antenna, otherwise leave", "// both options 0 so Tx antenna tracks Rx antenna.", "//(SLI_ANTDIV_SUPPORTED && defined(RAIL_TX_OPTION_ANTENNA0))", "// Ensure that radio state is not being changed during TX.", "// Hijack the buffer to send with a new buffer that contains a wake up frame", "// CSL_SUPPORT", "// LOWER_MAC_DEBUG", "// LOWER_MAC_DEBUG", "// CSL_SUPPORT", "// When sending wake up frames, we tell RAIL to alert us when the TX FIFO", "// drops below a certain threshold, so that we can fill it up again with", "// more frames. The threshold is high here because we don't want interrupt", "// latency to happen and find out the FIFO is (now) empty, causing a", "// RAIL_EVENT_TX_UNDERFLOW error to occur", "// LOWER_MAC_DEBUG", "// LOWER_MAC_DEBUG", "// CSL_SUPPORT" ]
[ { "param": "dataPtr", "type": "uint8_t" }, { "param": "dataLength", "type": "uint8_t" }, { "param": "transactionTimeUs", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dataPtr", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dataLength", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "transactionTimeUs", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
24beef876c276ed52984cb73d1e321e34dd7623c
SiliconLabs/Gecko_SDK
platform/radio/mac/lower-mac-rail-802.15.4.c
[ "Zlib" ]
C
txCurrentPacket
void
static void txCurrentPacket(void) { #ifndef EMBER_TEST halStackIndicateActivity(true); #endif uint16_t transactionTimeUs = 0; LOWER_MAC_ASSERT(getInternalFlag(FLAG_ONGOING_TX_DATA)); LOWER_MAC_ASSERT(emLowerMacState == EMBER_MAC_STATE_TX_WAITING_FOR_ACK || emLowerMacState == EMBER_MAC_STATE_TX_NO_ACK); LOWER_MAC_ASSERT(currentOutgoingPacket != NULL); if (getInternalFlag(FLAG_CURRENT_TX_USE_CSMA)) { transactionTimeUs += CSMA_OVERHEAD_US; (void) onPtaStackEvent(SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_PENDED_PHY, (uint32_t) true); } else { (void) onPtaStackEvent(SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_PENDED_PHY, (uint32_t) false); } transactionTimeUs += sl_mac_get_bit_duration_us() * 8 * (EMBER_PHY_PREAMBLE_LENGTH + EMBER_PHY_SFD_LENGTH + EMBER_PHY_HEADER_LENGTH + sl_mac_flat_phy_payload_length(currentOutgoingPacket) + EMBER_PHY_CRC_LENGTH); if (emLowerMacState == EMBER_MAC_STATE_TX_WAITING_FOR_ACK) { transactionTimeUs += EMBER_MAC_ACK_TURNAROUND_DELAY_SYMBOLS * sl_mac_get_symbol_duration_us() + (sl_mac_get_bit_duration_us() * 8 * (EMBER_PHY_PREAMBLE_LENGTH + EMBER_PHY_SFD_LENGTH + EMBER_PHY_HEADER_LENGTH + 3 + EMBER_PHY_CRC_LENGTH)); } radioSetTx(currentOutgoingPacket, sl_mac_flat_phy_packet_length(currentOutgoingPacket) - EMBER_PHY_CRC_LENGTH, transactionTimeUs); LOWER_MAC_DEBUG_ASSERT_OUTGOING_PENDING(false, false); LOWER_MAC_DEBUG_SET_OUTGOING_PENDING(true, false); LOWER_MAC_DEBUG_START_TX_SENT_TIMER(true); #ifndef EMBER_TEST halStackIndicateActivity(false); #endif }
// This is always called with interrupts disabled.
This is always called with interrupts disabled.
[ "This", "is", "always", "called", "with", "interrupts", "disabled", "." ]
static void txCurrentPacket(void) { #ifndef EMBER_TEST halStackIndicateActivity(true); #endif uint16_t transactionTimeUs = 0; LOWER_MAC_ASSERT(getInternalFlag(FLAG_ONGOING_TX_DATA)); LOWER_MAC_ASSERT(emLowerMacState == EMBER_MAC_STATE_TX_WAITING_FOR_ACK || emLowerMacState == EMBER_MAC_STATE_TX_NO_ACK); LOWER_MAC_ASSERT(currentOutgoingPacket != NULL); if (getInternalFlag(FLAG_CURRENT_TX_USE_CSMA)) { transactionTimeUs += CSMA_OVERHEAD_US; (void) onPtaStackEvent(SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_PENDED_PHY, (uint32_t) true); } else { (void) onPtaStackEvent(SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_PENDED_PHY, (uint32_t) false); } transactionTimeUs += sl_mac_get_bit_duration_us() * 8 * (EMBER_PHY_PREAMBLE_LENGTH + EMBER_PHY_SFD_LENGTH + EMBER_PHY_HEADER_LENGTH + sl_mac_flat_phy_payload_length(currentOutgoingPacket) + EMBER_PHY_CRC_LENGTH); if (emLowerMacState == EMBER_MAC_STATE_TX_WAITING_FOR_ACK) { transactionTimeUs += EMBER_MAC_ACK_TURNAROUND_DELAY_SYMBOLS * sl_mac_get_symbol_duration_us() + (sl_mac_get_bit_duration_us() * 8 * (EMBER_PHY_PREAMBLE_LENGTH + EMBER_PHY_SFD_LENGTH + EMBER_PHY_HEADER_LENGTH + 3 + EMBER_PHY_CRC_LENGTH)); } radioSetTx(currentOutgoingPacket, sl_mac_flat_phy_packet_length(currentOutgoingPacket) - EMBER_PHY_CRC_LENGTH, transactionTimeUs); LOWER_MAC_DEBUG_ASSERT_OUTGOING_PENDING(false, false); LOWER_MAC_DEBUG_SET_OUTGOING_PENDING(true, false); LOWER_MAC_DEBUG_START_TX_SENT_TIMER(true); #ifndef EMBER_TEST halStackIndicateActivity(false); #endif }
[ "static", "void", "txCurrentPacket", "(", "void", ")", "{", "#ifndef", "EMBER_TEST", "halStackIndicateActivity", "(", "true", ")", ";", "#endif", "uint16_t", "transactionTimeUs", "=", "0", ";", "LOWER_MAC_ASSERT", "(", "getInternalFlag", "(", "FLAG_ONGOING_TX_DATA", ")", ")", ";", "LOWER_MAC_ASSERT", "(", "emLowerMacState", "==", "EMBER_MAC_STATE_TX_WAITING_FOR_ACK", "||", "emLowerMacState", "==", "EMBER_MAC_STATE_TX_NO_ACK", ")", ";", "LOWER_MAC_ASSERT", "(", "currentOutgoingPacket", "!=", "NULL", ")", ";", "if", "(", "getInternalFlag", "(", "FLAG_CURRENT_TX_USE_CSMA", ")", ")", "{", "transactionTimeUs", "+=", "CSMA_OVERHEAD_US", ";", "(", "void", ")", "onPtaStackEvent", "(", "SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_PENDED_PHY", ",", "(", "uint32_t", ")", "true", ")", ";", "}", "else", "{", "(", "void", ")", "onPtaStackEvent", "(", "SL_RAIL_UTIL_IEEE802154_STACK_EVENT_TX_PENDED_PHY", ",", "(", "uint32_t", ")", "false", ")", ";", "}", "transactionTimeUs", "+=", "sl_mac_get_bit_duration_us", "(", ")", "*", "8", "*", "(", "EMBER_PHY_PREAMBLE_LENGTH", "+", "EMBER_PHY_SFD_LENGTH", "+", "EMBER_PHY_HEADER_LENGTH", "+", "sl_mac_flat_phy_payload_length", "(", "currentOutgoingPacket", ")", "+", "EMBER_PHY_CRC_LENGTH", ")", ";", "if", "(", "emLowerMacState", "==", "EMBER_MAC_STATE_TX_WAITING_FOR_ACK", ")", "{", "transactionTimeUs", "+=", "EMBER_MAC_ACK_TURNAROUND_DELAY_SYMBOLS", "*", "sl_mac_get_symbol_duration_us", "(", ")", "+", "(", "sl_mac_get_bit_duration_us", "(", ")", "*", "8", "*", "(", "EMBER_PHY_PREAMBLE_LENGTH", "+", "EMBER_PHY_SFD_LENGTH", "+", "EMBER_PHY_HEADER_LENGTH", "+", "3", "+", "EMBER_PHY_CRC_LENGTH", ")", ")", ";", "}", "radioSetTx", "(", "currentOutgoingPacket", ",", "sl_mac_flat_phy_packet_length", "(", "currentOutgoingPacket", ")", "-", "EMBER_PHY_CRC_LENGTH", ",", "transactionTimeUs", ")", ";", "LOWER_MAC_DEBUG_ASSERT_OUTGOING_PENDING", "(", "false", ",", "false", ")", ";", "LOWER_MAC_DEBUG_SET_OUTGOING_PENDING", "(", "true", ",", "false", ")", ";", "LOWER_MAC_DEBUG_START_TX_SENT_TIMER", "(", "true", ")", ";", "#ifndef", "EMBER_TEST", "halStackIndicateActivity", "(", "false", ")", ";", "#endif", "}" ]
This is always called with interrupts disabled.
[ "This", "is", "always", "called", "with", "interrupts", "disabled", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
24beef876c276ed52984cb73d1e321e34dd7623c
SiliconLabs/Gecko_SDK
platform/radio/mac/lower-mac-rail-802.15.4.c
[ "Zlib" ]
C
emRadioCheckRadio
bool
bool emRadioCheckRadio(void) { // EFR32 calibration events are: IRCal and tempcal // RAIL Cal requests update the stack via pending bits // (RAILCb_CalNeeded callback fires also) //return RAIL_GetPendingCal(connectRailHandle); return false; }
//temporary workaround until Andrew's changes to this are merged here
temporary workaround until Andrew's changes to this are merged here
[ "temporary", "workaround", "until", "Andrew", "'", "s", "changes", "to", "this", "are", "merged", "here" ]
bool emRadioCheckRadio(void) { return false; }
[ "bool", "emRadioCheckRadio", "(", "void", ")", "{", "return", "false", ";", "}" ]
temporary workaround until Andrew's changes to this are merged here
[ "temporary", "workaround", "until", "Andrew", "'", "s", "changes", "to", "this", "are", "merged", "here" ]
[ "// EFR32 calibration events are: IRCal and tempcal", "// RAIL Cal requests update the stack via pending bits", "// (RAILCb_CalNeeded callback fires also)", "//return RAIL_GetPendingCal(connectRailHandle);" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
24beef876c276ed52984cb73d1e321e34dd7623c
SiliconLabs/Gecko_SDK
platform/radio/mac/lower-mac-rail-802.15.4.c
[ "Zlib" ]
C
emSetMacTxMode
void
void emSetMacTxMode(EmMacTxMode txMode) { if (txMode == MAC_TX_MODE_NORMAL) { sl_rail_util_coex_set_bool(SL_RAIL_UTIL_COEX_OPT_MAC_AND_FORCE_HOLDOFFS, false); } else if (txMode == MAC_TX_MODE_GRANT) { sl_rail_util_coex_set_bool(SL_RAIL_UTIL_COEX_OPT_MAC_HOLDOFF, true); sl_rail_util_coex_set_bool(SL_RAIL_UTIL_COEX_OPT_FORCE_HOLDOFF, false); } else if (txMode == MAC_TX_MODE_MAC_HO) { sl_rail_util_coex_set_bool(SL_RAIL_UTIL_COEX_OPT_MAC_AND_FORCE_HOLDOFFS, true); } }
//This does not seem to be ever used, but since the status of coex testing is not clear, //I replicate this here from pre-umac zigbee code /* * Truth table * m=SL_RAIL_UTIL_COEX_OPT_MAC_HOLDOFF, f=SL_RAIL_UTIL_COEX_OPT_FORCE_HOLDOFF * mf * 00:EmMacTxMode = MAC_TX_MODE_NORMAL w/o force holdoff * 01:EmMacTxMode = MAC_TX_MODE_NORMAL w/force holdoff * 10:EmMacTxMode = MAC_TX_MODE_GRANT * 11:EmMacTxMode = MAC_TX_MODE_MAC_HO */
This does not seem to be ever used, but since the status of coex testing is not clear, I replicate this here from pre-umac zigbee code
[ "This", "does", "not", "seem", "to", "be", "ever", "used", "but", "since", "the", "status", "of", "coex", "testing", "is", "not", "clear", "I", "replicate", "this", "here", "from", "pre", "-", "umac", "zigbee", "code" ]
void emSetMacTxMode(EmMacTxMode txMode) { if (txMode == MAC_TX_MODE_NORMAL) { sl_rail_util_coex_set_bool(SL_RAIL_UTIL_COEX_OPT_MAC_AND_FORCE_HOLDOFFS, false); } else if (txMode == MAC_TX_MODE_GRANT) { sl_rail_util_coex_set_bool(SL_RAIL_UTIL_COEX_OPT_MAC_HOLDOFF, true); sl_rail_util_coex_set_bool(SL_RAIL_UTIL_COEX_OPT_FORCE_HOLDOFF, false); } else if (txMode == MAC_TX_MODE_MAC_HO) { sl_rail_util_coex_set_bool(SL_RAIL_UTIL_COEX_OPT_MAC_AND_FORCE_HOLDOFFS, true); } }
[ "void", "emSetMacTxMode", "(", "EmMacTxMode", "txMode", ")", "{", "if", "(", "txMode", "==", "MAC_TX_MODE_NORMAL", ")", "{", "sl_rail_util_coex_set_bool", "(", "SL_RAIL_UTIL_COEX_OPT_MAC_AND_FORCE_HOLDOFFS", ",", "false", ")", ";", "}", "else", "if", "(", "txMode", "==", "MAC_TX_MODE_GRANT", ")", "{", "sl_rail_util_coex_set_bool", "(", "SL_RAIL_UTIL_COEX_OPT_MAC_HOLDOFF", ",", "true", ")", ";", "sl_rail_util_coex_set_bool", "(", "SL_RAIL_UTIL_COEX_OPT_FORCE_HOLDOFF", ",", "false", ")", ";", "}", "else", "if", "(", "txMode", "==", "MAC_TX_MODE_MAC_HO", ")", "{", "sl_rail_util_coex_set_bool", "(", "SL_RAIL_UTIL_COEX_OPT_MAC_AND_FORCE_HOLDOFFS", ",", "true", ")", ";", "}", "}" ]
This does not seem to be ever used, but since the status of coex testing is not clear, I replicate this here from pre-umac zigbee code
[ "This", "does", "not", "seem", "to", "be", "ever", "used", "but", "since", "the", "status", "of", "coex", "testing", "is", "not", "clear", "I", "replicate", "this", "here", "from", "pre", "-", "umac", "zigbee", "code" ]
[]
[ { "param": "txMode", "type": "EmMacTxMode" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "txMode", "type": "EmMacTxMode", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
24beef876c276ed52984cb73d1e321e34dd7623c
SiliconLabs/Gecko_SDK
platform/radio/mac/lower-mac-rail-802.15.4.c
[ "Zlib" ]
C
emberRadioSetSchedulerPriorities
EmberStatus
EmberStatus emberRadioSetSchedulerPriorities(const EmberMultiprotocolPriorities *priorities) { RAIL_Version_t railVersion; RAIL_GetVersion(&railVersion, false); if (railVersion.multiprotocol) { radioSchedulerPriorityTable = *priorities; changeDynamicEvents(); return EMBER_SUCCESS; } else { return EMBER_INVALID_CALL; } }
// This API should only be called prior to sl_mac_lower_mac_init() or when // the radio is OFF -- otherwise its new priorities won't be put // into effect until the next time the radio gets turned on.
This API should only be called prior to sl_mac_lower_mac_init() or when the radio is OFF -- otherwise its new priorities won't be put into effect until the next time the radio gets turned on.
[ "This", "API", "should", "only", "be", "called", "prior", "to", "sl_mac_lower_mac_init", "()", "or", "when", "the", "radio", "is", "OFF", "--", "otherwise", "its", "new", "priorities", "won", "'", "t", "be", "put", "into", "effect", "until", "the", "next", "time", "the", "radio", "gets", "turned", "on", "." ]
EmberStatus emberRadioSetSchedulerPriorities(const EmberMultiprotocolPriorities *priorities) { RAIL_Version_t railVersion; RAIL_GetVersion(&railVersion, false); if (railVersion.multiprotocol) { radioSchedulerPriorityTable = *priorities; changeDynamicEvents(); return EMBER_SUCCESS; } else { return EMBER_INVALID_CALL; } }
[ "EmberStatus", "emberRadioSetSchedulerPriorities", "(", "const", "EmberMultiprotocolPriorities", "*", "priorities", ")", "{", "RAIL_Version_t", "railVersion", ";", "RAIL_GetVersion", "(", "&", "railVersion", ",", "false", ")", ";", "if", "(", "railVersion", ".", "multiprotocol", ")", "{", "radioSchedulerPriorityTable", "=", "*", "priorities", ";", "changeDynamicEvents", "(", ")", ";", "return", "EMBER_SUCCESS", ";", "}", "else", "{", "return", "EMBER_INVALID_CALL", ";", "}", "}" ]
This API should only be called prior to sl_mac_lower_mac_init() or when the radio is OFF -- otherwise its new priorities won't be put into effect until the next time the radio gets turned on.
[ "This", "API", "should", "only", "be", "called", "prior", "to", "sl_mac_lower_mac_init", "()", "or", "when", "the", "radio", "is", "OFF", "--", "otherwise", "its", "new", "priorities", "won", "'", "t", "be", "put", "into", "effect", "until", "the", "next", "time", "the", "radio", "gets", "turned", "on", "." ]
[]
[ { "param": "priorities", "type": "EmberMultiprotocolPriorities" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "priorities", "type": "EmberMultiprotocolPriorities", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6fa2181b41fe4aa453206fc372c94b853e204785
SiliconLabs/Gecko_SDK
app/wisun/component/cli_util/sl_wisun_cli_util.c
[ "Zlib" ]
C
app_util_get_string
sl_status_t
sl_status_t app_util_get_string(char *const value_str, uint32_t value, const app_enum_t *const value_enum_list, uint8_t is_value_signed, uint8_t is_value_hex, uint8_t value_length) { const app_enum_t* value_enum; char value_format_str[10]; char value_temp[10]; // String is empty by default value_str[0] = '\0'; // Attempt to find a matching enumeration value_enum = app_util_get_enum_by_integer(value_enum_list, value); if (value_length && is_value_hex) { // Fixed-length hex values are always zero-filled sprintf(value_format_str, "%%0%u", value_length); } else if (value_length) { // Fixed-length value sprintf(value_format_str, "%%%u", value_length); } else { sprintf(value_format_str, "%%"); } if (is_value_hex) { // Hex value strcat(value_format_str, "lx"); sprintf(value_temp, value_format_str, (uint32_t)value); } else if (is_value_signed) { // Signed integer value strcat(value_format_str, "ld"); sprintf(value_temp, value_format_str, (int32_t)value); } else { // Unsigned integer value strcat(value_format_str, "lu"); sprintf(value_temp, value_format_str, (uint32_t)value); } // String starts with an enumeration if (value_enum) { sprintf(value_str, "%s (", value_enum->value_str); } // Hex value is prefixed with "0x" if (is_value_hex) { strcat(value_str, "0x"); } // Value itself strcat(value_str, value_temp); // Closing paranthesis in case an enumeration was used if (value_enum) { strcat(value_str, ")"); } // Success return SL_STATUS_OK; }
// ----------------------------------------------------------------------------- // Public Function Definitions // ----------------------------------------------------------------------------- /* App util get string */
Public Function Definitions App util get string
[ "Public", "Function", "Definitions", "App", "util", "get", "string" ]
sl_status_t app_util_get_string(char *const value_str, uint32_t value, const app_enum_t *const value_enum_list, uint8_t is_value_signed, uint8_t is_value_hex, uint8_t value_length) { const app_enum_t* value_enum; char value_format_str[10]; char value_temp[10]; value_str[0] = '\0'; value_enum = app_util_get_enum_by_integer(value_enum_list, value); if (value_length && is_value_hex) { sprintf(value_format_str, "%%0%u", value_length); } else if (value_length) { sprintf(value_format_str, "%%%u", value_length); } else { sprintf(value_format_str, "%%"); } if (is_value_hex) { strcat(value_format_str, "lx"); sprintf(value_temp, value_format_str, (uint32_t)value); } else if (is_value_signed) { strcat(value_format_str, "ld"); sprintf(value_temp, value_format_str, (int32_t)value); } else { strcat(value_format_str, "lu"); sprintf(value_temp, value_format_str, (uint32_t)value); } if (value_enum) { sprintf(value_str, "%s (", value_enum->value_str); } is prefixed with "0x" if (is_value_hex) { strcat(value_str, "0x"); } strcat(value_str, value_temp); if (value_enum) { strcat(value_str, ")"); } return SL_STATUS_OK; }
[ "sl_status_t", "app_util_get_string", "(", "char", "*", "const", "value_str", ",", "uint32_t", "value", ",", "const", "app_enum_t", "*", "const", "value_enum_list", ",", "uint8_t", "is_value_signed", ",", "uint8_t", "is_value_hex", ",", "uint8_t", "value_length", ")", "{", "const", "app_enum_t", "*", "value_enum", ";", "char", "value_format_str", "[", "10", "]", ";", "char", "value_temp", "[", "10", "]", ";", "value_str", "[", "0", "]", "=", "'", "\\0", "'", ";", "value_enum", "=", "app_util_get_enum_by_integer", "(", "value_enum_list", ",", "value", ")", ";", "if", "(", "value_length", "&&", "is_value_hex", ")", "{", "sprintf", "(", "value_format_str", ",", "\"", "\"", ",", "value_length", ")", ";", "}", "else", "if", "(", "value_length", ")", "{", "sprintf", "(", "value_format_str", ",", "\"", "\"", ",", "value_length", ")", ";", "}", "else", "{", "sprintf", "(", "value_format_str", ",", "\"", "\"", ")", ";", "}", "if", "(", "is_value_hex", ")", "{", "strcat", "(", "value_format_str", ",", "\"", "\"", ")", ";", "sprintf", "(", "value_temp", ",", "value_format_str", ",", "(", "uint32_t", ")", "value", ")", ";", "}", "else", "if", "(", "is_value_signed", ")", "{", "strcat", "(", "value_format_str", ",", "\"", "\"", ")", ";", "sprintf", "(", "value_temp", ",", "value_format_str", ",", "(", "int32_t", ")", "value", ")", ";", "}", "else", "{", "strcat", "(", "value_format_str", ",", "\"", "\"", ")", ";", "sprintf", "(", "value_temp", ",", "value_format_str", ",", "(", "uint32_t", ")", "value", ")", ";", "}", "if", "(", "value_enum", ")", "{", "sprintf", "(", "value_str", ",", "\"", "\"", ",", "value_enum", "->", "value_str", ")", ";", "}", "if", "(", "is_value_hex", ")", "{", "strcat", "(", "value_str", ",", "\"", "\"", ")", ";", "}", "strcat", "(", "value_str", ",", "value_temp", ")", ";", "if", "(", "value_enum", ")", "{", "strcat", "(", "value_str", ",", "\"", "\"", ")", ";", "}", "return", "SL_STATUS_OK", ";", "}" ]
Public Function Definitions App util get string
[ "Public", "Function", "Definitions", "App", "util", "get", "string" ]
[ "// String is empty by default", "// Attempt to find a matching enumeration", "// Fixed-length hex values are always zero-filled", "// Fixed-length value", "// Hex value", "// Signed integer value", "// Unsigned integer value", "// String starts with an enumeration", "// Hex value is prefixed with \"0x\"", "// Value itself", "// Closing paranthesis in case an enumeration was used", "// Success" ]
[ { "param": "value_str", "type": "char" }, { "param": "value", "type": "uint32_t" }, { "param": "value_enum_list", "type": "app_enum_t" }, { "param": "is_value_signed", "type": "uint8_t" }, { "param": "is_value_hex", "type": "uint8_t" }, { "param": "value_length", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "value_str", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "value", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "value_enum_list", "type": "app_enum_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "is_value_signed", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "is_value_hex", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "value_length", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6fa2181b41fe4aa453206fc372c94b853e204785
SiliconLabs/Gecko_SDK
app/wisun/component/cli_util/sl_wisun_cli_util.c
[ "Zlib" ]
C
app_util_get_enum_by_string
app_enum_t
const app_enum_t* app_util_get_enum_by_string(const app_enum_t *value_enum_list, const char *const value) { while (value_enum_list && value_enum_list->value_str) { if (!strcmp(value_enum_list->value_str, value)) { // Matching enumeration found return value_enum_list; } value_enum_list++; } return NULL; }
/* App util get enum by string */
App util get enum by string
[ "App", "util", "get", "enum", "by", "string" ]
const app_enum_t* app_util_get_enum_by_string(const app_enum_t *value_enum_list, const char *const value) { while (value_enum_list && value_enum_list->value_str) { if (!strcmp(value_enum_list->value_str, value)) { return value_enum_list; } value_enum_list++; } return NULL; }
[ "const", "app_enum_t", "*", "app_util_get_enum_by_string", "(", "const", "app_enum_t", "*", "value_enum_list", ",", "const", "char", "*", "const", "value", ")", "{", "while", "(", "value_enum_list", "&&", "value_enum_list", "->", "value_str", ")", "{", "if", "(", "!", "strcmp", "(", "value_enum_list", "->", "value_str", ",", "value", ")", ")", "{", "return", "value_enum_list", ";", "}", "value_enum_list", "++", ";", "}", "return", "NULL", ";", "}" ]
App util get enum by string
[ "App", "util", "get", "enum", "by", "string" ]
[ "// Matching enumeration found" ]
[ { "param": "value_enum_list", "type": "app_enum_t" }, { "param": "value", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "value_enum_list", "type": "app_enum_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "value", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6fa2181b41fe4aa453206fc372c94b853e204785
SiliconLabs/Gecko_SDK
app/wisun/component/cli_util/sl_wisun_cli_util.c
[ "Zlib" ]
C
app_util_get_enum_by_integer
app_enum_t
const app_enum_t* app_util_get_enum_by_integer(const app_enum_t *value_enum_list, uint32_t value) { while (value_enum_list && value_enum_list->value_str) { if (value_enum_list->value == value) { // Matching enumeration found return value_enum_list; } value_enum_list++; } return NULL; }
/* App util get enum by integerApp util get enum by integer */
App util get enum by integerApp util get enum by integer
[ "App", "util", "get", "enum", "by", "integerApp", "util", "get", "enum", "by", "integer" ]
const app_enum_t* app_util_get_enum_by_integer(const app_enum_t *value_enum_list, uint32_t value) { while (value_enum_list && value_enum_list->value_str) { if (value_enum_list->value == value) { return value_enum_list; } value_enum_list++; } return NULL; }
[ "const", "app_enum_t", "*", "app_util_get_enum_by_integer", "(", "const", "app_enum_t", "*", "value_enum_list", ",", "uint32_t", "value", ")", "{", "while", "(", "value_enum_list", "&&", "value_enum_list", "->", "value_str", ")", "{", "if", "(", "value_enum_list", "->", "value", "==", "value", ")", "{", "return", "value_enum_list", ";", "}", "value_enum_list", "++", ";", "}", "return", "NULL", ";", "}" ]
App util get enum by integerApp util get enum by integer
[ "App", "util", "get", "enum", "by", "integerApp", "util", "get", "enum", "by", "integer" ]
[ "// Matching enumeration found" ]
[ { "param": "value_enum_list", "type": "app_enum_t" }, { "param": "value", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "value_enum_list", "type": "app_enum_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "value", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6fa2181b41fe4aa453206fc372c94b853e204785
SiliconLabs/Gecko_SDK
app/wisun/component/cli_util/sl_wisun_cli_util.c
[ "Zlib" ]
C
app_util_get_mac_address_string
sl_status_t
sl_status_t app_util_get_mac_address_string(char *value_str, const sl_wisun_mac_address_t *value) { int i; for (i = 0; i < SL_WISUN_MAC_ADDRESS_SIZE; ++i) { sprintf(value_str, "%02x:", value->address[i]); value_str += 3; } // Remove the last colon *(value_str - 1) = '\0'; return SL_STATUS_OK; }
/* App util get MAC address string */
App util get MAC address string
[ "App", "util", "get", "MAC", "address", "string" ]
sl_status_t app_util_get_mac_address_string(char *value_str, const sl_wisun_mac_address_t *value) { int i; for (i = 0; i < SL_WISUN_MAC_ADDRESS_SIZE; ++i) { sprintf(value_str, "%02x:", value->address[i]); value_str += 3; } *(value_str - 1) = '\0'; return SL_STATUS_OK; }
[ "sl_status_t", "app_util_get_mac_address_string", "(", "char", "*", "value_str", ",", "const", "sl_wisun_mac_address_t", "*", "value", ")", "{", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "SL_WISUN_MAC_ADDRESS_SIZE", ";", "++", "i", ")", "{", "sprintf", "(", "value_str", ",", "\"", "\"", ",", "value", "->", "address", "[", "i", "]", ")", ";", "value_str", "+=", "3", ";", "}", "*", "(", "value_str", "-", "1", ")", "=", "'", "\\0", "'", ";", "return", "SL_STATUS_OK", ";", "}" ]
App util get MAC address string
[ "App", "util", "get", "MAC", "address", "string" ]
[ "// Remove the last colon" ]
[ { "param": "value_str", "type": "char" }, { "param": "value", "type": "sl_wisun_mac_address_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "value_str", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "value", "type": "sl_wisun_mac_address_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6fa2181b41fe4aa453206fc372c94b853e204785
SiliconLabs/Gecko_SDK
app/wisun/component/cli_util/sl_wisun_cli_util.c
[ "Zlib" ]
C
app_util_printable_data_next
char
char *app_util_printable_data_next(app_printable_data_ctx_t *const ctx) { int ret; if (!ctx->data || !ctx->data_left) { // All done return NULL; } // Get the next line if (ctx->is_hex) { ret = app_util_printable_hex_line(ctx->line_buffer, ctx->data, ctx->data_left, ctx->line_length); } else { ret = app_util_printable_line(ctx->line_buffer, ctx->data, ctx->data_left, ctx->line_length); } if (!ret) { // All done return NULL; } // Prepare for the next line ctx->data += ret; ctx->data_left -= ret; return ctx->line_buffer; }
/* App util get next printable data */
App util get next printable data
[ "App", "util", "get", "next", "printable", "data" ]
char *app_util_printable_data_next(app_printable_data_ctx_t *const ctx) { int ret; if (!ctx->data || !ctx->data_left) { return NULL; } if (ctx->is_hex) { ret = app_util_printable_hex_line(ctx->line_buffer, ctx->data, ctx->data_left, ctx->line_length); } else { ret = app_util_printable_line(ctx->line_buffer, ctx->data, ctx->data_left, ctx->line_length); } if (!ret) { return NULL; } ctx->data += ret; ctx->data_left -= ret; return ctx->line_buffer; }
[ "char", "*", "app_util_printable_data_next", "(", "app_printable_data_ctx_t", "*", "const", "ctx", ")", "{", "int", "ret", ";", "if", "(", "!", "ctx", "->", "data", "||", "!", "ctx", "->", "data_left", ")", "{", "return", "NULL", ";", "}", "if", "(", "ctx", "->", "is_hex", ")", "{", "ret", "=", "app_util_printable_hex_line", "(", "ctx", "->", "line_buffer", ",", "ctx", "->", "data", ",", "ctx", "->", "data_left", ",", "ctx", "->", "line_length", ")", ";", "}", "else", "{", "ret", "=", "app_util_printable_line", "(", "ctx", "->", "line_buffer", ",", "ctx", "->", "data", ",", "ctx", "->", "data_left", ",", "ctx", "->", "line_length", ")", ";", "}", "if", "(", "!", "ret", ")", "{", "return", "NULL", ";", "}", "ctx", "->", "data", "+=", "ret", ";", "ctx", "->", "data_left", "-=", "ret", ";", "return", "ctx", "->", "line_buffer", ";", "}" ]
App util get next printable data
[ "App", "util", "get", "next", "printable", "data" ]
[ "// All done", "// Get the next line", "// All done", "// Prepare for the next line" ]
[ { "param": "ctx", "type": "app_printable_data_ctx_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ctx", "type": "app_printable_data_ctx_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6fa2181b41fe4aa453206fc372c94b853e204785
SiliconLabs/Gecko_SDK
app/wisun/component/cli_util/sl_wisun_cli_util.c
[ "Zlib" ]
C
app_util_printable_line
int
static int app_util_printable_line(char *const line_buffer, const uint8_t *const data, const uint16_t data_length, uint8_t line_length) { if (data_length < line_length) { line_length = (uint8_t)data_length; } memcpy(line_buffer, data, line_length); line_buffer[line_length] = 0; return line_length; }
// ----------------------------------------------------------------------------- // Static Function Definitions // ----------------------------------------------------------------------------- /* App util printable line */
Static Function Definitions App util printable line
[ "Static", "Function", "Definitions", "App", "util", "printable", "line" ]
static int app_util_printable_line(char *const line_buffer, const uint8_t *const data, const uint16_t data_length, uint8_t line_length) { if (data_length < line_length) { line_length = (uint8_t)data_length; } memcpy(line_buffer, data, line_length); line_buffer[line_length] = 0; return line_length; }
[ "static", "int", "app_util_printable_line", "(", "char", "*", "const", "line_buffer", ",", "const", "uint8_t", "*", "const", "data", ",", "const", "uint16_t", "data_length", ",", "uint8_t", "line_length", ")", "{", "if", "(", "data_length", "<", "line_length", ")", "{", "line_length", "=", "(", "uint8_t", ")", "data_length", ";", "}", "memcpy", "(", "line_buffer", ",", "data", ",", "line_length", ")", ";", "line_buffer", "[", "line_length", "]", "=", "0", ";", "return", "line_length", ";", "}" ]
Static Function Definitions App util printable line
[ "Static", "Function", "Definitions", "App", "util", "printable", "line" ]
[]
[ { "param": "line_buffer", "type": "char" }, { "param": "data", "type": "uint8_t" }, { "param": "data_length", "type": "uint16_t" }, { "param": "line_length", "type": "uint8_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "line_buffer", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data_length", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "line_length", "type": "uint8_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1e61c4cf2f5164fb5de5a81edcd96f5c0e5da64c
SiliconLabs/Gecko_SDK
app/bluetooth/common/btmesh_sensor_server/sl_btmesh_sensor_server.c
[ "Zlib" ]
C
handle_sensor_server_get_request
void
static void handle_sensor_server_get_request( sl_btmesh_evt_sensor_server_get_request_t *evt) { // A slot for all sensor data uint8_t sensor_data[SENSOR_DATA_BUF_LEN]; uint8_t len = 0; sl_status_t sc; (void)evt; #ifdef SL_CATALOG_BTMESH_SENSOR_PEOPLE_COUNT_PRESENT if ((evt->property_id == PEOPLE_COUNT) || (evt->property_id == PROPERTY_ID_ALL)) { count16_t people_count = sl_btmesh_get_people_count(); sl_btmesh_sensor_server_on_people_count_measurement(people_count); len += mesh_sensor_data_to_buf(PEOPLE_COUNT, &sensor_data[len], (uint8_t*)&people_count); } #endif // SL_CATALOG_BTMESH_SENSOR_PEOPLE_COUNT_PRESENT #if defined(SL_BOARD_ENABLE_SENSOR_LIGHT) \ && SL_BOARD_ENABLE_SENSOR_LIGHT #if defined(SL_CATALOG_SENSOR_LIGHT_PRESENT) \ || defined(SL_CATALOG_SENSOR_LUX_PRESENT) if ((evt->property_id == PRESENT_AMBIENT_LIGHT_LEVEL) || (evt->property_id == PROPERTY_ID_ALL)) { illuminance_t light = get_light(); len += mesh_sensor_data_to_buf(PRESENT_AMBIENT_LIGHT_LEVEL, &sensor_data[len], (uint8_t*)&light); } #endif // SL_CATALOG_SENSOR_LIGHT_PRESENT || SL_CATALOG_SENSOR_LUX_PRESENT #endif // SL_BOARD_ENABLE_SENSOR_LIGHT #if defined(SL_CATALOG_SENSOR_RHT_PRESENT) \ && defined(SL_BOARD_ENABLE_SENSOR_RHT) \ && SL_BOARD_ENABLE_SENSOR_RHT if ((evt->property_id == PRESENT_AMBIENT_TEMPERATURE) || (evt->property_id == PROPERTY_ID_ALL)) { temperature_8_t temperature = get_temperature(); len += mesh_sensor_data_to_buf(PRESENT_AMBIENT_TEMPERATURE, &sensor_data[len], (uint8_t*)&temperature); } #endif // SL_CATALOG_SENSOR_RHT_PRESENT if (len > 0) { sc = sl_btmesh_sensor_server_send_status(evt->client_address, BTMESH_SENSOR_SERVER_MAIN, evt->appkey_index, NO_FLAGS, len, sensor_data); } else { sensor_data[0] = evt->property_id & 0xFF; sensor_data[1] = ((evt->property_id) >> 8) & 0xFF; sensor_data[2] = 0; // Length is 0 for unsupported property_id sc = sl_btmesh_sensor_server_send_status(evt->client_address, BTMESH_SENSOR_SERVER_MAIN, evt->appkey_index, NO_FLAGS, 3, sensor_data); } log_status_error_f(sc, SENSOR_SERVER_SEND_FAILED_TEXT, "status"); }
/***************************************************************************/ /** * Handling of sensor server get request event. * It sending sensor status message with data for all of supported Properties ID, * if there is no Property ID field in request. If request contains Property ID * that is supported, functions reply with the sensor status message with data * for this Property ID, in other case the message contains no data. * * @param[in] evt Pointer to sensor server get request event. ******************************************************************************/
Handling of sensor server get request event. It sending sensor status message with data for all of supported Properties ID, if there is no Property ID field in request. If request contains Property ID that is supported, functions reply with the sensor status message with data for this Property ID, in other case the message contains no data. @param[in] evt Pointer to sensor server get request event.
[ "Handling", "of", "sensor", "server", "get", "request", "event", ".", "It", "sending", "sensor", "status", "message", "with", "data", "for", "all", "of", "supported", "Properties", "ID", "if", "there", "is", "no", "Property", "ID", "field", "in", "request", ".", "If", "request", "contains", "Property", "ID", "that", "is", "supported", "functions", "reply", "with", "the", "sensor", "status", "message", "with", "data", "for", "this", "Property", "ID", "in", "other", "case", "the", "message", "contains", "no", "data", ".", "@param", "[", "in", "]", "evt", "Pointer", "to", "sensor", "server", "get", "request", "event", "." ]
static void handle_sensor_server_get_request( sl_btmesh_evt_sensor_server_get_request_t *evt) { uint8_t sensor_data[SENSOR_DATA_BUF_LEN]; uint8_t len = 0; sl_status_t sc; (void)evt; #ifdef SL_CATALOG_BTMESH_SENSOR_PEOPLE_COUNT_PRESENT if ((evt->property_id == PEOPLE_COUNT) || (evt->property_id == PROPERTY_ID_ALL)) { count16_t people_count = sl_btmesh_get_people_count(); sl_btmesh_sensor_server_on_people_count_measurement(people_count); len += mesh_sensor_data_to_buf(PEOPLE_COUNT, &sensor_data[len], (uint8_t*)&people_count); } #endif #if defined(SL_BOARD_ENABLE_SENSOR_LIGHT) \ && SL_BOARD_ENABLE_SENSOR_LIGHT #if defined(SL_CATALOG_SENSOR_LIGHT_PRESENT) \ || defined(SL_CATALOG_SENSOR_LUX_PRESENT) if ((evt->property_id == PRESENT_AMBIENT_LIGHT_LEVEL) || (evt->property_id == PROPERTY_ID_ALL)) { illuminance_t light = get_light(); len += mesh_sensor_data_to_buf(PRESENT_AMBIENT_LIGHT_LEVEL, &sensor_data[len], (uint8_t*)&light); } #endif #endif #if defined(SL_CATALOG_SENSOR_RHT_PRESENT) \ && defined(SL_BOARD_ENABLE_SENSOR_RHT) \ && SL_BOARD_ENABLE_SENSOR_RHT if ((evt->property_id == PRESENT_AMBIENT_TEMPERATURE) || (evt->property_id == PROPERTY_ID_ALL)) { temperature_8_t temperature = get_temperature(); len += mesh_sensor_data_to_buf(PRESENT_AMBIENT_TEMPERATURE, &sensor_data[len], (uint8_t*)&temperature); } #endif if (len > 0) { sc = sl_btmesh_sensor_server_send_status(evt->client_address, BTMESH_SENSOR_SERVER_MAIN, evt->appkey_index, NO_FLAGS, len, sensor_data); } else { sensor_data[0] = evt->property_id & 0xFF; sensor_data[1] = ((evt->property_id) >> 8) & 0xFF; sensor_data[2] = 0; sc = sl_btmesh_sensor_server_send_status(evt->client_address, BTMESH_SENSOR_SERVER_MAIN, evt->appkey_index, NO_FLAGS, 3, sensor_data); } log_status_error_f(sc, SENSOR_SERVER_SEND_FAILED_TEXT, "status"); }
[ "static", "void", "handle_sensor_server_get_request", "(", "sl_btmesh_evt_sensor_server_get_request_t", "*", "evt", ")", "{", "uint8_t", "sensor_data", "[", "SENSOR_DATA_BUF_LEN", "]", ";", "uint8_t", "len", "=", "0", ";", "sl_status_t", "sc", ";", "(", "void", ")", "evt", ";", "#ifdef", "SL_CATALOG_BTMESH_SENSOR_PEOPLE_COUNT_PRESENT", "if", "(", "(", "evt", "->", "property_id", "==", "PEOPLE_COUNT", ")", "||", "(", "evt", "->", "property_id", "==", "PROPERTY_ID_ALL", ")", ")", "{", "count16_t", "people_count", "=", "sl_btmesh_get_people_count", "(", ")", ";", "sl_btmesh_sensor_server_on_people_count_measurement", "(", "people_count", ")", ";", "len", "+=", "mesh_sensor_data_to_buf", "(", "PEOPLE_COUNT", ",", "&", "sensor_data", "[", "len", "]", ",", "(", "uint8_t", "*", ")", "&", "people_count", ")", ";", "}", "#endif", "#if", "defined", "(", "SL_BOARD_ENABLE_SENSOR_LIGHT", ")", "&&", "SL_BOARD_ENABLE_SENSOR_LIGHT", "\n", "#if", "defined", "(", "SL_CATALOG_SENSOR_LIGHT_PRESENT", ")", "||", "defined", "(", "SL_CATALOG_SENSOR_LUX_PRESENT", ")", "\n", "if", "(", "(", "evt", "->", "property_id", "==", "PRESENT_AMBIENT_LIGHT_LEVEL", ")", "||", "(", "evt", "->", "property_id", "==", "PROPERTY_ID_ALL", ")", ")", "{", "illuminance_t", "light", "=", "get_light", "(", ")", ";", "len", "+=", "mesh_sensor_data_to_buf", "(", "PRESENT_AMBIENT_LIGHT_LEVEL", ",", "&", "sensor_data", "[", "len", "]", ",", "(", "uint8_t", "*", ")", "&", "light", ")", ";", "}", "#endif", "#endif", "#if", "defined", "(", "SL_CATALOG_SENSOR_RHT_PRESENT", ")", "&&", "defined", "(", "SL_BOARD_ENABLE_SENSOR_RHT", ")", "&&", "SL_BOARD_ENABLE_SENSOR_RHT", "\n", "if", "(", "(", "evt", "->", "property_id", "==", "PRESENT_AMBIENT_TEMPERATURE", ")", "||", "(", "evt", "->", "property_id", "==", "PROPERTY_ID_ALL", ")", ")", "{", "temperature_8_t", "temperature", "=", "get_temperature", "(", ")", ";", "len", "+=", "mesh_sensor_data_to_buf", "(", "PRESENT_AMBIENT_TEMPERATURE", ",", "&", "sensor_data", "[", "len", "]", ",", "(", "uint8_t", "*", ")", "&", "temperature", ")", ";", "}", "#endif", "if", "(", "len", ">", "0", ")", "{", "sc", "=", "sl_btmesh_sensor_server_send_status", "(", "evt", "->", "client_address", ",", "BTMESH_SENSOR_SERVER_MAIN", ",", "evt", "->", "appkey_index", ",", "NO_FLAGS", ",", "len", ",", "sensor_data", ")", ";", "}", "else", "{", "sensor_data", "[", "0", "]", "=", "evt", "->", "property_id", "&", "0xFF", ";", "sensor_data", "[", "1", "]", "=", "(", "(", "evt", "->", "property_id", ")", ">>", "8", ")", "&", "0xFF", ";", "sensor_data", "[", "2", "]", "=", "0", ";", "sc", "=", "sl_btmesh_sensor_server_send_status", "(", "evt", "->", "client_address", ",", "BTMESH_SENSOR_SERVER_MAIN", ",", "evt", "->", "appkey_index", ",", "NO_FLAGS", ",", "3", ",", "sensor_data", ")", ";", "}", "log_status_error_f", "(", "sc", ",", "SENSOR_SERVER_SEND_FAILED_TEXT", ",", "\"", "\"", ")", ";", "}" ]
Handling of sensor server get request event.
[ "Handling", "of", "sensor", "server", "get", "request", "event", "." ]
[ "// A slot for all sensor data", "// SL_CATALOG_BTMESH_SENSOR_PEOPLE_COUNT_PRESENT", "// SL_CATALOG_SENSOR_LIGHT_PRESENT || SL_CATALOG_SENSOR_LUX_PRESENT", "// SL_BOARD_ENABLE_SENSOR_LIGHT", "// SL_CATALOG_SENSOR_RHT_PRESENT", "// Length is 0 for unsupported property_id" ]
[ { "param": "evt", "type": "sl_btmesh_evt_sensor_server_get_request_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "evt", "type": "sl_btmesh_evt_sensor_server_get_request_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1e61c4cf2f5164fb5de5a81edcd96f5c0e5da64c
SiliconLabs/Gecko_SDK
app/bluetooth/common/btmesh_sensor_server/sl_btmesh_sensor_server.c
[ "Zlib" ]
C
handle_sensor_server_get_column_request
void
static void handle_sensor_server_get_column_request( sl_btmesh_evt_sensor_server_get_column_request_t *evt) { sl_status_t sc; sc = sl_btmesh_sensor_server_send_column_status(evt->client_address, BTMESH_SENSOR_SERVER_MAIN, evt->appkey_index, NO_FLAGS, evt->property_id, evt->column_ids.len, evt->column_ids.data); log_status_error_f(sc, SENSOR_SERVER_SEND_FAILED_TEXT, "column status"); }
/***************************************************************************/ /** * Handling of sensor server get column request event. * Used Property IDs does not have sensor series column state, * so reply has the same data as request according to specification. * * @param[in] evt Pointer to sensor server get column request event. ******************************************************************************/
Handling of sensor server get column request event. Used Property IDs does not have sensor series column state, so reply has the same data as request according to specification. @param[in] evt Pointer to sensor server get column request event.
[ "Handling", "of", "sensor", "server", "get", "column", "request", "event", ".", "Used", "Property", "IDs", "does", "not", "have", "sensor", "series", "column", "state", "so", "reply", "has", "the", "same", "data", "as", "request", "according", "to", "specification", ".", "@param", "[", "in", "]", "evt", "Pointer", "to", "sensor", "server", "get", "column", "request", "event", "." ]
static void handle_sensor_server_get_column_request( sl_btmesh_evt_sensor_server_get_column_request_t *evt) { sl_status_t sc; sc = sl_btmesh_sensor_server_send_column_status(evt->client_address, BTMESH_SENSOR_SERVER_MAIN, evt->appkey_index, NO_FLAGS, evt->property_id, evt->column_ids.len, evt->column_ids.data); log_status_error_f(sc, SENSOR_SERVER_SEND_FAILED_TEXT, "column status"); }
[ "static", "void", "handle_sensor_server_get_column_request", "(", "sl_btmesh_evt_sensor_server_get_column_request_t", "*", "evt", ")", "{", "sl_status_t", "sc", ";", "sc", "=", "sl_btmesh_sensor_server_send_column_status", "(", "evt", "->", "client_address", ",", "BTMESH_SENSOR_SERVER_MAIN", ",", "evt", "->", "appkey_index", ",", "NO_FLAGS", ",", "evt", "->", "property_id", ",", "evt", "->", "column_ids", ".", "len", ",", "evt", "->", "column_ids", ".", "data", ")", ";", "log_status_error_f", "(", "sc", ",", "SENSOR_SERVER_SEND_FAILED_TEXT", ",", "\"", "\"", ")", ";", "}" ]
Handling of sensor server get column request event.
[ "Handling", "of", "sensor", "server", "get", "column", "request", "event", "." ]
[]
[ { "param": "evt", "type": "sl_btmesh_evt_sensor_server_get_column_request_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "evt", "type": "sl_btmesh_evt_sensor_server_get_column_request_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1e61c4cf2f5164fb5de5a81edcd96f5c0e5da64c
SiliconLabs/Gecko_SDK
app/bluetooth/common/btmesh_sensor_server/sl_btmesh_sensor_server.c
[ "Zlib" ]
C
handle_sensor_server_get_series_request
void
static void handle_sensor_server_get_series_request( sl_btmesh_evt_sensor_server_get_series_request_t *evt) { sl_status_t sc; sc = sl_btmesh_sensor_server_send_series_status(evt->client_address, BTMESH_SENSOR_SERVER_MAIN, evt->appkey_index, NO_FLAGS, evt->property_id, 0, NULL); log_status_error_f(sc, SENSOR_SERVER_SEND_FAILED_TEXT, "series status"); }
/***************************************************************************/ /** * Handling of sensor server get series request event. * Used Property IDs does not have sensor series column state, * so reply has only Property ID according to specification. * * @param[in] evt Pointer to sensor server get series request event. ******************************************************************************/
Handling of sensor server get series request event. Used Property IDs does not have sensor series column state, so reply has only Property ID according to specification. @param[in] evt Pointer to sensor server get series request event.
[ "Handling", "of", "sensor", "server", "get", "series", "request", "event", ".", "Used", "Property", "IDs", "does", "not", "have", "sensor", "series", "column", "state", "so", "reply", "has", "only", "Property", "ID", "according", "to", "specification", ".", "@param", "[", "in", "]", "evt", "Pointer", "to", "sensor", "server", "get", "series", "request", "event", "." ]
static void handle_sensor_server_get_series_request( sl_btmesh_evt_sensor_server_get_series_request_t *evt) { sl_status_t sc; sc = sl_btmesh_sensor_server_send_series_status(evt->client_address, BTMESH_SENSOR_SERVER_MAIN, evt->appkey_index, NO_FLAGS, evt->property_id, 0, NULL); log_status_error_f(sc, SENSOR_SERVER_SEND_FAILED_TEXT, "series status"); }
[ "static", "void", "handle_sensor_server_get_series_request", "(", "sl_btmesh_evt_sensor_server_get_series_request_t", "*", "evt", ")", "{", "sl_status_t", "sc", ";", "sc", "=", "sl_btmesh_sensor_server_send_series_status", "(", "evt", "->", "client_address", ",", "BTMESH_SENSOR_SERVER_MAIN", ",", "evt", "->", "appkey_index", ",", "NO_FLAGS", ",", "evt", "->", "property_id", ",", "0", ",", "NULL", ")", ";", "log_status_error_f", "(", "sc", ",", "SENSOR_SERVER_SEND_FAILED_TEXT", ",", "\"", "\"", ")", ";", "}" ]
Handling of sensor server get series request event.
[ "Handling", "of", "sensor", "server", "get", "series", "request", "event", "." ]
[]
[ { "param": "evt", "type": "sl_btmesh_evt_sensor_server_get_series_request_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "evt", "type": "sl_btmesh_evt_sensor_server_get_series_request_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }